Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: J2EE database list object
I am using this code to retrive object from database. but this code returns a object but type of that object is just object. I want to return "Pcinitialdata" type object. But it returns just object and its type is Object.. How can i solve it..???
 
String qryStrforCom = "select pci.fileNo,pci.projectNo,pci.fundId,pci.decrp,pci.devSec,pci.estBy,pci.areaCode,pci.targetDate,pci.jobnoRecedate,pci.conBy,pci.supBy,pci.ht33,pci.lt11,pci.sub11,pci.lt3Phase,pci.ltsPhase,pci.abc5w,pci.abc4w,pci.abcsecct,pci.perCapacity,pci.newCapacity,pci.proLtrToEsOn,pci.stdCost,pci.detailCost,pci.varianceNew from Pcinitialdata pci where TRIM(pci.estNo) = :value";
 
Query querycom = getEntityManager(webAppName).createQuery(qryStrforCom);
querycom.setParameter("value", value);
List<Pcinitialdata> listCom=querycom.getResultList();
if (listCom.isEmpty()) {
    return null;
}
return listCom;
Posted 27-Mar-13 0:22am
Comments
Prasad Khandekar at 27-Mar-13 5:50am
   
According to JavaDoc the entity class must satisfy these requirements:
<ul>
<li>The class must be annotated with the javax.persistence.Entity annotation.</li>
<li>The class must have a public or protected, no-argument constructor. The class may have other constructors.</li>
<li>The class must not be declared final. No methods or persistent instance variables must be declared final.</li>
<li>If an entity instance be passed by value as a detached object, such as through a session bean’s remote business interface, the class must implement the Serializable interface.</li>
<li>Entities may extend both entity and non-entity classes, and non-entity classes may extend entity classes.</li>
<li>Persistent instance variables must be declared private, protected, or package-private, and can only be accessed directly by the entity class’s methods. Clients must access the entity’s state through accessor or business methods.</li>
</ul>
 
Make sure Pcinitialdata class adheres to these rules. Also make sure that persistence.xml is also defined properly. The code otherwise looks proper and should return you a list of Pcinitialdata.
 
Regards,
doree007 at 27-Mar-13 6:47am
   
I am new to this area and i cant understand last 4 points correctly.. can u please help me with that??
Prasad Khandekar at 27-Mar-13 14:01pm
   
Please have a look at this tutorial. http://docs.oracle.com/javaee/5/tutorial/doc/bnbpz.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,327
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,920


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 27 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100