Hi,

Given that it's a one-sided OneToMany, it sounds like it might be a
bug. Is it possible for you to provide us with more information, or
even a test case that fails?

Thanks,

-Patrick

On 10/26/07, Ajay Aggarwal <[EMAIL PROTECTED]> wrote:
> If I use FetchType.EAGER for my @OneToMany relation, things work fine
> and I correctly see following SQL statements in the trace log
>   - INSERT for new row into 'callLog'
>   - UPDATE for 'recPolicy'
>   - INSERT for a new row into association table 'recPolicy_callLog'
>
> So the question remains why is this not working for FetchType.LAZY? Is
> this a bug in openJPA 1.0 or incorrect-usage / user-error on my part?
>
>
> -----Original Message-----
> From: Ajay Aggarwal [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 26, 2007 1:39 PM
> To: [email protected]
> Subject: RE: OneToMany - related entry not getting persisted?
>
> Thanks. But in my case, I do not have a ManyToOne relation on the other
> side and that's on purpose.
>
> -----Original Message-----
> From: Gul Onural [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 26, 2007 1:30 PM
> To: [email protected]
> Subject: RE: OneToMany - related entry not getting persisted?
>
>
>
> Have you checked
> http://forums.java.net/jive/message.jspa?messageID=212597.
>
> I believe that will answer your question.
>
> Gul
>
> -----Original Message-----
> From: Ajay Aggarwal [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 26, 2007 1:19 PM
> To: [email protected]
> Subject: OneToMany - related entry not getting persisted?
>
> I am using openjpa1.0. My main entity class is RecPolicy which has a
> @OneToMany relation to entity 'CallLog'. I am using FetchType.LAZY  and
> CascadeType.ALL. See below:
>
>
>
>         Public class RecPolicy {
>
>             ...
>
>             @OneToMany (fetch=FetchType.LAZY, cascade=CascadeType.ALL)
>
>             private List <CallLog> calls;
>
>        }
>
>
>
>
>
> Now I am trying to add a CallLog entry to an existing RecPolicy entry,
> but it's not working. My code looks like
>
>
>
>                         EntityManager em =
> factory.createEntityManager();
>
>                         EntityTransaction tx = em.getTransaction();
>
>                         try {
>
>                                     tx.begin();
>
>                                     RecPolicy.RecPolicyId policyId = ...
>
>                                     RecPolicy policy =
> em.find(RecPolicy.class, policyId);
>
>                                     CallLog callLog = new CallLog(sid,
> this.fromUri, this.toUri);
>
>                                     policy.calls.add(callLog);
>
>                                     tx.commit();
>
>                         } catch (Exception e) {
>
>                                     if (tx.isActive()) tx.rollback();
>
>                         } finally {
>
>                                     em.close();
>
>                         }
>
>
>
>
>
> When I enable openjpa logging all I see is an UPDATE sql to update the
> RecPolicy, but no INSERT for CallLog? Do I need to persist new CallLog
> above explicitly? Is 'LAZY' fetch causing this behavior?
>
>
>
>


-- 
Patrick Linskey
202 669 5907

Reply via email to