Click here to Skip to main content
11,806,575 members (39,621 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Java SE J2EE database
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 at 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 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.

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

  Print Answers RSS
0 ppolymorphe 295
1 OriginalGriff 150
2 George Jonsson 135
3 Richard Deeming 120
4 CPallini 100
0 OriginalGriff 3,380
1 Maciej Los 1,990
2 CPallini 1,915
3 KrunalRohit 1,907
4 ppolymorphe 1,317

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 27 Mar 2013
Copyright © CodeProject, 1999-2015
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