Please ignore my last msg about error from enhancer ant task. It looks like my environment/classpath related error.
-----Original Message----- From: Ajay Aggarwal [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 30, 2007 1:39 PM To: [email protected] Subject: RE: OneToMany - related entry not getting persisted? I tried build time enhancer via ant task and I am getting following error. My entity classes are attached here. enhance: [openjpac] java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: com.covergence.soa.covapi.recpolicy.CallLog [openjpac] at serp.util.Strings.toClass(Strings.java:164) [openjpac] at serp.util.Strings.toClass(Strings.java:108) [openjpac] at org.apache.openjpa.lib.meta.ClassArgParser.parseTypes(ClassArgParser.jav a:164) [openjpac] at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4321) [openjpac] at org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTask.java:89) [openjpac] at org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:172) [openjpac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [openjpac] at org.apache.tools.ant.Task.perform(Task.java:364) [openjpac] at org.apache.tools.ant.Target.execute(Target.java:341) [openjpac] at org.apache.tools.ant.Target.performTasks(Target.java:369) [openjpac] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [openjpac] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [openjpac] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecut or.java:40) [openjpac] at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets( EclipseDefaultExecutor.java:32) [openjpac] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [openjpac] at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunne r.java:706) [openjpac] at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunne r.java:584) [openjpac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [openjpac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:64) [openjpac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:43) [openjpac] at java.lang.reflect.Method.invoke(Method.java:615) [openjpac] at org.eclipse.ant.core.AntRunner.run(AntRunner.java:494) [openjpac] at com.ibm.ant.extras.RunAnt.run(RunAnt.java:24) [openjpac] at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActiva tor.java:78) [openjpac] at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplicat ion(EclipseAppLauncher.java:92) [openjpac] at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Eclip seAppLauncher.java:68) [openjpac] at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java: 400) [openjpac] at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java: 177) [openjpac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [openjpac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:64) [openjpac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:43) [openjpac] at java.lang.reflect.Method.invoke(Method.java:615) [openjpac] at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336) [openjpac] at org.eclipse.core.launcher.Main.basicRun(Main.java:280) [openjpac] at org.eclipse.core.launcher.Main.run(Main.java:977) [openjpac] at org.eclipse.core.launcher.Main.main(Main.java:952) -----Original Message----- From: Ajay Aggarwal [mailto:[EMAIL PROTECTED] Sent: Monday, October 29, 2007 3:49 PM To: [email protected] Subject: RE: OneToMany - related entry not getting persisted? I am using "Field" Access type. I will have to learn Enhancer to give you the answer to your last question. Meanwhile here are the openjpa configuration properties I am using in persistence.xml <persistence-unit name="covApiService" transaction-type="RESOURCE_LOCAL"> <provider> org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <class>com.covergence.soa.covapi.recpolicy.RecPolicy</class> <class>com.covergence.soa.covapi.recpolicy.CallLog</class> <properties> <property name="openjpa.ConnectionURL" value="jdbc:postgresql://localhost:5432/wlDemo"/> <property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"/> <property name="openjpa.ConnectionUserName" value="xxx"/> <property name="openjpa.ConnectionPassword" value="xxx"/> <property name="openjpa.jdbc.SynchronizeMappings" value="refresh"/> <property name="openjpa.Log" value="File=stdout, DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/> </properties> </persistence-unit> -----Original Message----- From: Patrick Linskey [mailto:[EMAIL PROTECTED] Sent: Monday, October 29, 2007 3:07 PM To: [email protected] Subject: Re: OneToMany - related entry not getting persisted? > Yes, let me know what additional information you would need to reproduce > this. It's a pretty straight forward test case. Ideally, the actual sources. In the absence of the source code: - what access type are you using? - what are all your OpenJPA configuration options set to? - does this happen if you do run the OpenJPA enhancer? -Patrick On 10/29/07, Ajay Aggarwal <[EMAIL PROTECTED]> wrote: > Yes, let me know what additional information you would need to reproduce > this. It's a pretty straight forward test case. > > I have two entity beans A and B > A has OneToMany relationship to B with persist=ALL, fetch=LAZY > There is no inverse relation from B to A. > I am using it inside servlets (inside WebSphere Application Server 6.1) > Now inside a transaction > - I find an instance of A using entity manager > - I get the list of 'B' from this instance of A and add a new instance > of B to this list > - I commit this transaction > > The new instance of B does not get added. > > However if I change fetch=EAGER for this relation, things work fine and > new instance of B above gets inserted. > > One more piece of information. I am not using OpenJPA enhancer and when > I deploy my application with fetch=LAZY I see this log/error. Note: In > my actual application RecPolicy has OneToMany relation to CallLog. > > [10/25/07 12:45:22:129 EDT] 00000024 SystemErr R 5517137 > covApiService INFO [WebContainer : 2] openjpa.Enhance - Creating > subclass and redefining methods for "[class > com.covergence.soa.covapi.recpolicy.CallLog, class > com.covergence.soa.covapi.recpolicy.RecPolicy]". This means that your > application will be less efficient than it would if you ran the OpenJPA > enhancer. > > -----Original Message----- > From: Patrick Linskey [mailto:[EMAIL PROTECTED] > Sent: Monday, October 29, 2007 1:18 PM > To: [email protected] > Subject: Re: OneToMany - related entry not getting persisted? > > 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 > -- Patrick Linskey 202 669 5907
