You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Antonio Sánchez (JIRA)" <ji...@apache.org> on 2008/08/30 18:39:44 UTC

[jira] Created: (OPENJPA-707) Recursively related entities not loaded

Recursively related entities not loaded
---------------------------------------

                 Key: OPENJPA-707
                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
             Project: OpenJPA
          Issue Type: Bug
          Components: jpa
    Affects Versions: 1.1.0
         Environment: * [OpenJPA 1.1.0]
* [derby 10.4.1.3]
* [java hotspot 1.6.0_06-b02]
* [ubuntu 8.04.1 2.6.24-19-generic] 
            Reporter: Antonio Sánchez


OpenJPA is failing to load data from the database in recursive
many-to-one relationships (and possibly other types of relationships).

CASE (Steps 1 to 4 follow) ---------->

STEP 1.- I'm using a recursive table (most probably the same case
applies for non-recursive relationships):

create table "SA"."RECURSIVA" (
   PK int primary key not null,
   DATO varchar(10),
   PADRE int references RECURSIVA
);

INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);

STEP 2.- This is the entity (the recursive many-to-one relationship is
supposed to be eagerly fetched, according to the spec.):

@Entity
@Table(name = "RECURSIVA")
public class Recursiva implements Serializable {
    @Id
    @Column(name = "PK", nullable = false)
    private Integer pk;
    @Column(name = "DATO")
    private String dato;
    @OneToMany(mappedBy = "padre")
    private Collection<Recursiva> recursivaCollection;
    @JoinColumn(name = "PADRE", referencedColumnName = "PK")
    @ManyToOne
    private Recursiva padre;
    ....

STEP 3.- This is the data retrieval code.

        EntityManagerFactory emf =
Persistence.createEntityManagerFactory("mijpa");;
        EntityManager em = emf.createEntityManager();
        Recursiva rc = null;
       
        rc = em.find(Recursiva.class, 7);      
       
        while (rc != null) {
            System.out.println(rc.getDato());
            rc = rc.getPadre();
        }
       
        em.close();
        emf.close();

STEP 4.- Results:

n7
n6

I would have expected to be printed the whole hierarchy up to the root,
i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz

NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-707) Recursively related entities not loaded

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12630324#action_12630324 ] 

Fay Wang commented on OPENJPA-707:
----------------------------------

Hi Antonio,
   I ran the test case outside Eclipse using your compile.sh and run.sh. I did see the problem you described. After some investigation, it is found that you did not call PCEnhancer to enhance your entity. You should add the following statement in your compile.sh:

      java org.apache.openjpa.enhance.PCEnhancer -p persistence.xml#nocarga

The purpose of the enhancer is to enhance the entity class file by adding the bytecode that openjpa needs for proper runtime operation. After this step, the test case works just fine.  Please let me know if you still have problem. 


> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar, testcase.tar.gz
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-707) Recursively related entities not loaded

Posted by "Antonio Sánchez (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12628789#action_12628789 ] 

Antonio Sánchez commented on OPENJPA-707:
-----------------------------------------

I'm sorry I didn't realize 1.2 have been released; actually, I am off-line since a few days ago.

Fay:

I will download 1.2 an test on it, and will also try your test case on 1.1 and will let you know, hopefully next week.

> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-707) Recursively related entities not loaded

Posted by "Antonio Sánchez (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12630144#action_12630144 ] 

Antonio Sánchez commented on OPENJPA-707:
-----------------------------------------

Test performed with negative results for both 1.1 and 1.2. See details in attachment 'testcase.tar.gz'.



> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-707) Recursively related entities not loaded

Posted by "Antonio Sánchez (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12630546#action_12630546 ] 

Antonio Sánchez commented on OPENJPA-707:
-----------------------------------------

Hi Fay, 
  it is now working correctly and I can use openjpa again in my application.

Just a question: so, is actually the enhancer a requisite to make jpa work properly instead of just a way to make it work better?

Thank you very much for your help.


> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar, testcase.tar.gz
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-707) Recursively related entities not loaded

Posted by "Antonio Sánchez (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12630967#action_12630967 ] 

Antonio Sánchez commented on OPENJPA-707:
-----------------------------------------

Thanks Fay. This issue is done for me, should I close it myself?

> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar, testcase.tar.gz
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-707) Recursively related entities not loaded

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12627824#action_12627824 ] 

Fay Wang commented on OPENJPA-707:
----------------------------------

Just noticed that the test case works fine with openjpa trunk. It failed as Antonio indicated when running against openjpa 1.1.x. This bug apparently is fixed in the trunk. 

> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (OPENJPA-707) Recursively related entities not loaded

Posted by "Antonio Sánchez (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antonio Sánchez resolved OPENJPA-707.
-------------------------------------

    Resolution: Invalid

Enhancer is required.

> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar, testcase.tar.gz
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-707) Recursively related entities not loaded

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fay Wang updated OPENJPA-707:
-----------------------------

    Attachment: test.jar

I could not reproduce this problem. Attached is my test case based on the description of this JIRA. My backend is DB2. The test case works just fine. 

> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-707) Recursively related entities not loaded

Posted by "Antonio Sánchez (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12628774#action_12628774 ] 

Antonio Sánchez commented on OPENJPA-707:
-----------------------------------------

I think this should be tested again against next release. I'm sorry  I'll be off-line for a while and will not be able to test against the trunk.

> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-707) Recursively related entities not loaded

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12630589#action_12630589 ] 

Fay Wang commented on OPENJPA-707:
----------------------------------

Hi Antonio, Enhancer is required to make openjpa work. 

> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar, testcase.tar.gz
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-707) Recursively related entities not loaded

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12628785#action_12628785 ] 

Fay Wang commented on OPENJPA-707:
----------------------------------

Actually, I re-ran the test case that I attached to this JIRA on openjpa 1.1.x, it works just fine. Can you try this test case on your machine to see if it works?

> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-707) Recursively related entities not loaded

Posted by "Antonio Sánchez (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-707?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antonio Sánchez updated OPENJPA-707:
------------------------------------

    Attachment: testcase.tar.gz

> Recursively related entities not loaded
> ---------------------------------------
>
>                 Key: OPENJPA-707
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-707
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 1.1.0
>         Environment: * [OpenJPA 1.1.0]
> * [derby 10.4.1.3]
> * [java hotspot 1.6.0_06-b02]
> * [ubuntu 8.04.1 2.6.24-19-generic] 
>            Reporter: Antonio Sánchez
>         Attachments: test.jar, testcase.tar.gz
>
>
> OpenJPA is failing to load data from the database in recursive
> many-to-one relationships (and possibly other types of relationships).
> CASE (Steps 1 to 4 follow) ---------->
> STEP 1.- I'm using a recursive table (most probably the same case
> applies for non-recursive relationships):
> create table "SA"."RECURSIVA" (
>    PK int primary key not null,
>    DATO varchar(10),
>    PADRE int references RECURSIVA
> );
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (0,'Raiz',null);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (1,'n1',0);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (2,'n2',1);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (3,'n3',2);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (4,'n4',3);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (5,'n5',4);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (6,'n6',5);
> INSERT INTO "SA"."RECURSIVA" (PK,DATO,PADRE) VALUES (7,'n7',6);
> STEP 2.- This is the entity (the recursive many-to-one relationship is
> supposed to be eagerly fetched, according to the spec.):
> @Entity
> @Table(name = "RECURSIVA")
> public class Recursiva implements Serializable {
>     @Id
>     @Column(name = "PK", nullable = false)
>     private Integer pk;
>     @Column(name = "DATO")
>     private String dato;
>     @OneToMany(mappedBy = "padre")
>     private Collection<Recursiva> recursivaCollection;
>     @JoinColumn(name = "PADRE", referencedColumnName = "PK")
>     @ManyToOne
>     private Recursiva padre;
>     ....
> STEP 3.- This is the data retrieval code.
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("mijpa");;
>         EntityManager em = emf.createEntityManager();
>         Recursiva rc = null;
>        
>         rc = em.find(Recursiva.class, 7);      
>        
>         while (rc != null) {
>             System.out.println(rc.getDato());
>             rc = rc.getPadre();
>         }
>        
>         em.close();
>         emf.close();
> STEP 4.- Results:
> n7
> n6
> I would have expected to be printed the whole hierarchy up to the root,
> i.e.: n7 n6 n5 n4 n3 n2 n1 Raiz
> NOTE: TopLink Essentials does it as expected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.