Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..???

Java
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
Comments
Prasad Khandekar 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 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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900