openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Beer <david.m.b...@btinternet.com>
Subject Re: @OneToMany Strange Behaviour
Date Mon, 11 Feb 2008 10:18:19 GMT
Guys thanks for your reply. I will try this out later.

David

----- Original Message ----
From: Craig L Russell <Craig.Russell@Sun.COM>
To: users@openjpa.apache.org
Sent: Monday, 11 February, 2008 2:00:46 AM
Subject: Re: @OneToMany Strange Behaviour

Another (non-standard) way to make sure you retrieve the relationship  
information is to define a fetch plan that includes the relationship  
you want.

Craig

On Feb 10, 2008, at 5:49 PM, Pinaki Poddar wrote:

>
> Multi-cardinality relationships (such as  
> List<AdditionalInformation>) are
> fetched from database lazily.
> So either
> 1. set the relationship fetch strategy as EAGER
> or
> 2. invoke entity.getAdditionalInfo() within the same transaction in  
> which
> entity was queried.
>
>
>
> david Beer wrote:
>>
>> Hi All
>>
>> I am using the following code to set my OneToMany relationship,
>>
>> @OneToMany(cascade=CascadeType.ALL)
>> private List<AdditionalInformation> addInfo;
>>
>> I am able to persist the data properly to the database, the problem
  
>> is
>> that when I run the following query, Query query =
>> manager.createQuery("SELECT a FROM Entry a"); I get List of all  
>> results
>> as expected, but the addInfo value is empty even though there is
 data
>> associated with that result in the database.
>>
>> Tables
>>
>> ENTRY - contains all data
>> ADDITIONALINFORMATION
>> ENTRY_ADDITIONALINFORMATION - conatains IDs of both ENTRY and
>> ADDITIONALINFORMATION
>>
>> When I retrieve data from ENTRY there is no id or link to any other
>> table. How am I supposed to find out if an Entry has any
>> ADDITIONALINFORMATION.
>>
>> Thanks
>>
>> David
>>
>>
>
> -- 
> View this message in context:
 http://www.nabble.com/%40OneToMany-Strange-Behaviour-tp15403260p15404250.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!





Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message