You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Johannes Mathes (JIRA)" <ji...@apache.org> on 2010/11/08 21:31:05 UTC

[jira] Created: (OPENJPA-1878) SQL Code 803 - Multiple identical entries to insert whith ForeignKey Annotation in Batch Flush with hierarchical self-reference

SQL Code 803 - Multiple identical entries to insert whith ForeignKey Annotation in Batch Flush with hierarchical self-reference
-------------------------------------------------------------------------------------------------------------------------------

                 Key: OPENJPA-1878
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1878
             Project: OpenJPA
          Issue Type: Bug
          Components: kernel
    Affects Versions: 2.0.1
         Environment: DB2 9.5 / LUW
            Reporter: Johannes Mathes


Hi there, 

I'm having trouble persisting an hierarchy:

I have an Entity TestDefinition which is hierarchical (tree). So there is a root, e.g. ROOT and a child CHILD and a GRANDCHILD, forming a hierarchy:
ROOT->CHILD->GRANDCHILD.
The Entitiy has an optional foreign key relationship to its parent. 
At the beginning I create the hierarchy and then attach the entries to the entity manager via merge. The database knows the foreign key constraints and enforces them. This is why I added the ForeignKey Tag to the parent-Attribute. 
When I flush or commit, I get an sql code 803 and I can see that the batch manager wants to insert the root multiple times! It seems that the engine is confused by the hierarchy and does not know that the root has been allready attached.

I see this multiple inserting also for other nodes, not just the root (in fact, I have a bit deeper hierarchy as stated here).

The entity is definied as follows: 
 @Id
    @Column(name = "TESD_ID", length = 255)
    private String definition;

    @ForeignKey
    @ManyToOne(cascade = CascadeType.ALL, optional = true)
    @Column(name = "TESD_PARENT_ID", length = 255)
    private TestDefinition parent;


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