Enrico,
I have two findBy operations in my test case using the same em, and it works
fine. According to your sql, you have FND_CDE in the where clause (see below):
SELECT t0.AMDCTL_ID, t0.VRS_NBR, t0.AMDSEQ_CDE, t0.DPLORD_NBR, t0.FND_CDE,
t0.RSL_DTE FROM EBSTATUS.TBL_AMDCTL t0 WHERE t0.FND_CDE = ?
[params=(String) 0001001]
SELECT t0.AMDCTL_ID, t1.AMDDES_ID, t1.VRS_NBR, t1.AMD_DES, t1.AMDCTL_ID,
t1.EFC_DTE FROM EBSTATUS.TBL_AMDCTL t0 INNER JOIN EBSTATUS.TBL_AMDDES t1 ON
t0.AMDCTL_ID = t1.AMDCTL_ID WHERE t0.FND_CDE = ? ORDER BY t0.AMDCTL_ID ASC
[params=(String) 0000001]
Is FND_CDE the primary key? Do you call:
TblAmdctl ctl2 = em.find(TblAmdctl.class, 1);
It would be greatly appreciated if you could provide more information on the
TblAmdctl.java and TblAmddes.java for us to debug the cache problem. Thanks!
-Fay
--- On Sat, 9/20/08, egoosen <[EMAIL PROTECTED]> wrote:
> From: egoosen <[EMAIL PROTECTED]>
> Subject: Re: OpenJPA 1.2.0 Bug on FetchType.EAGER
> To: [email protected]
> Date: Saturday, September 20, 2008, 9:30 AM
> Hi Fay,
>
> I think it would be difficult to recreate this bug in a
> standalone test case
> like you have created.
> As mentioned previously, this bug only surfaces on the
> second find.
>
> Perhaps if you modify your test case by reusing the em for
> the create and
> the find, it could reproduce the bug?
>
> Regards,
> Enrico
>
>
>
> Fay Wang wrote:
> >
> > Sorry, I spoke too soon. My test case actually runs
> fine. The following
> > listings are my TblAmdCtl.java, TblAmdDes.java and
> TestQuerySQLCache.
> > Could you attach your test case to reproduce this
> problem in the JIRA?
> > Thanks!
> >
> > (1) TblAmdCtl.java
> >
> > @Entity
> > public class TblAmdctl {
> > @OneToMany(mappedBy="tblAmdctl",fetch =
> FetchType.EAGER,cascade = {
> > CascadeType.PERSIST,CascadeType.MERGE})
> > private Collection<TblAmddes> tblAmddess = new
> ArrayList<TblAmddes>();
> >
> > @Id
> > @Column(name="AMDCTL_ID")
> > private int AMDCTL_ID;
> >
> > public void setId(int id) {
> > this.AMDCTL_ID = id;
> > }
> >
> > public int getId() {
> > return AMDCTL_ID;
> > }
> >
> > public Collection getTblAmddes() {
> > return tblAmddess;
> > }
> >
> > public void addTblAmddes(TblAmddes t) {
> > tblAmddess.add(t);
> > }
> > }
> >
> > (2) TblAmddes.java
> > @Entity
> > public class TblAmddes {
> > @ManyToOne(fetch = FetchType.LAZY,cascade = {
> > CascadeType.PERSIST,CascadeType.MERGE })
> > @JoinColumns([EMAIL PROTECTED](name =
> >
> "AMDCTL_ID",referencedColumnName="AMDCTL_ID")})
>
> > @ForeignKey
> > private TblAmdctl tblAmdctl;
> >
> > @Id
> > private int id;
> >
> > public void setId(int id) {
> > this.id = id;
> > }
> >
> > public int getId() {
> > return id;
> > }
> >
> > public TblAmdctl getTblAmdctl() {
> > return tblAmdctl;
> > }
> >
> > public void setTblAmdctl(TblAmdctl t) {
> > tblAmdctl = t;
> > }
> >
> > }
> >
> > (3) test case:
> > public class TestQuerySQLCache {
> >
> > public static void main (String[] args) {
> > createObj();
> > findObj();
> > }
> >
> > public static void createObj() {
> > EntityManager em =
> Persistence.createEntityManagerFactory("JpaDemo2").
> > createEntityManager();
> > EntityTransaction tran = em.getTransaction();
> >
> > TblAmdctl ctl1 = new TblAmdctl();
> > ctl1.setId(1);
> >
> > TblAmddes des1 = new TblAmddes();
> > des1.setId(1);
> > des1.setTblAmdctl(ctl1);
> >
> > TblAmddes des2 = new TblAmddes();
> > des2.setId(2);
> > des2.setTblAmdctl(ctl1);
> > ctl1.addTblAmddes(des1);
> > ctl1.addTblAmddes(des2);
> >
> > TblAmdctl ctl2 = new TblAmdctl();
> > ctl2.setId(2);
> >
> > TblAmddes des3 = new TblAmddes();
> > des3.setId(3);
> > des3.setTblAmdctl(ctl2);
> >
> > TblAmddes des4 = new TblAmddes();
> > des4.setId(4);
> > des4.setTblAmdctl(ctl2);
> > ctl2.addTblAmddes(des3);
> > ctl2.addTblAmddes(des4);
> >
> > tran.begin();
> > em.persist(ctl1);
> > em.persist(ctl2);
> > em.persist(des1);
> > em.persist(des2);
> > em.persist(des3);
> > em.persist(des4);
> >
> > em.flush();
> > tran.commit();
> > }
> >
> > public static void findObj() {
> > EntityManager em =
> Persistence.createEntityManagerFactory("JpaDemo2").
> > createEntityManager();
> > EntityTransaction tran = em.getTransaction();
> > TblAmdctl ctl1 = em.find(TblAmdctl.class, 1);
> > Collection<TblAmddes> dess1 =
> ctl1.getTblAmddes();
> > for (TblAmddes des : dess1)
> > System.out.println("des id = " +
> des.getId());
> >
> > TblAmdctl ctl2 = em.find(TblAmdctl.class, 2);
> > Collection<TblAmddes> dess2 =
> ctl2.getTblAmddes();
> > for (TblAmddes des : dess2)
> > System.out.println("des id = " +
> des.getId());
> >
> > }
> > }
> >
>
> --
> View this message in context:
> http://n2.nabble.com/OpenJPA-1.2.0-Bug-on-FetchType.EAGER-tp1100274p1106516.html
> Sent from the OpenJPA Users mailing list archive at
> Nabble.com.