Issue Details (XML | Word | Printable)

Key: OPENJPA-313
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Catalina Wei
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenJPA

list of objects returned by query partially correct

Created: 10/Aug/07 11:14 PM   Updated: 16/Aug/07 02:49 PM
Return to search
Component/s: jdbc
Affects Version/s: None
Fix Version/s: 1.0.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works jpa1.0.0.patch 2007-08-10 11:34 PM Catalina Wei 2 kB
Text File Licensed for inclusion in ASF works OPENJPA-313.2.patch 2007-08-15 02:23 AM Catalina Wei 3 kB
Text File Licensed for inclusion in ASF works OPENJPA-313.r564688.patch 2007-08-14 04:27 AM Catalina Wei 2 kB
Text File Licensed for inclusion in ASF works OPENJPA-313.r564688.patch 2007-08-11 02:53 AM Catalina Wei 2 kB

Resolution Date: 16/Aug/07 02:49 PM


 Description  « Hide
We have an object inheritance hierarchy as follows.

    FixedAnnuity extends Annuity
    EquityAnnuity extends Annuity

Then we have following code:

    List<IAnnuity> annuities = getServerAdapter().findHolderAnnuities(holder);

from which we expect to have a list of "Annuity" (could be Annuity, FixedAnnuity or
EquityAnnuity) from following code
EntityManager em = null;
try{
em = factory.createEntityManager();
Query query = em.createNamedQuery("GetHolderAnnuities");
query.setParameter("holderId", holder.getId());
return (List<IAnnuity>) query.getResultList();
}

Here is the query
<named-query name="GetHolderAnnuities">
<query>SELECT a FROM Annuity AS a WHERE a.annuityHolderId = :holderId</query>
</named-query>

In the end, the list returned only the first object with the correct Object, the
rest of the objects all casted into the basic type "Annuity"
e.g. we have following code:

EntityManager em = null;
try{
em = factory.createEntityManager();
Query query = em.createNamedQuery("GetHolderAnnuities");
query.setParameter("holderId", holder.getId());
return (List<IAnnuity>) query.getResultList();
}

FixedAnnuity fixed1 = new FixedAnnuity();
fixed1.setHolder(holder);
EquityAnnuity equity1 = new EquityAnnuity();
equity1.setHolder(holder);
FixedAnnuity fixed1 = new FixedAnnuity();
fixed2.setHolder(holder);
EquityAnnuity equity2 = new EquityAnnuity();
equity2.setHolder(holder);

List<IAnnuity> annuities = getServerAdapter().findHolderAnnuities(holder);

Only annuities.get(0) returns the correct object as FixedAnnuity, the other 3
objects returned all returned as Annuity

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #565845 Tue Aug 14 17:38:00 UTC 2007 wisneskid Help Catalina committing OPENJPA-313.r564688.patch
Files Changed
MODIFY /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java

Repository Revision Date User Message
ASF #565896 Tue Aug 14 20:17:39 UTC 2007 kwsutter OPENJPA-313. Looks like this patch wasn't quite ready for prime time. I attempted to re-build and re-test right after applying this change and I got several testcase errors in openjpa-persistence-jdbc. I revert back ClassMapping.java and the problems go away. Needs some more work...
Files Changed
MODIFY /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java

Repository Revision Date User Message
ASF #566006 Wed Aug 15 02:24:50 UTC 2007 wisneskid Help Catalina committing OPENJPA-313.2.patch
Files Changed
MODIFY /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
MODIFY /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java

Repository Revision Date User Message
ASF #692299 Thu Sep 04 23:12:27 UTC 2008 ssegu OPENJPA-313.2.patch
Files Changed
MODIFY /openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
MODIFY /openjpa/branches/0.9.7-r547073/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java