Click here to Skip to main content
13,006,180 members (66,771 online)
Rate this:
Please Sign up or sign in to vote.
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 26-Mar-13 23:22pm
Prasad Khandekar 27-Mar-13 5:50am
According to JavaDoc the entity class must satisfy these requirements:
<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>

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.

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170628.1 | Last Updated 27 Mar 2013
Copyright © CodeProject, 1999-2017
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