Hi all,

I have a simple node entity pretty much as follows
-------------------------------------------------
        @Id
        @GeneratedValue
        private Integer id;
        
        private String name;
        
        @ManyToOne(fetch=FetchType.LAZY)
        private Node parent;
        
        
@OneToMany(mappedBy="parent",fetch=FetchType.LAZY,cascade=CascadeType.ALL)
        private ArrayList<Node> children;

------------------------------------------------

When trying to insert into this table with a new entity whose parent is
already in the table, i.e already has an id I get the errror


The generated value processing detected an existing value assigned to this
field: com.abc.Node.id.  This existing value was either provided via an
initializer or by calling the setter method.  You either need to remove the
@GeneratedValue annotation or modify the code to remove the initializer
processing.

I have verified, via step through debug, that the id for the new entity is
definitely null when persist is called. I have tried flushing the entity
manager but the error is thrown immedialtly upon persist. The parent field,
which is the self referencing field, does not have its cascadeType set so I
cannot see why openjpa is attempting to persist the entity again.

Any ideas?

thanks
-- 
View this message in context: 
http://n2.nabble.com/Self-referencing-Entity-causes-id-already-assigned-value-on-entity-save-tp2241816p2241816.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to