JPA Relationship manytoone saving problem

225 views
Skip to first unread message

Kaushal Prajapati

unread,
Jul 25, 2013, 8:54:21 AM7/25/13
to google-a...@googlegroups.com
Exception  persist method Save Attempt to assign child with key Role(19003) to parent with key User(no-id-yet). Parent keys are immutable
Exception  persist method Save Detected attempt to establish User(19004) as the parent of Role(1) but the entity identified by Role(1) has already been persisted without a parent.  A parent cannot be established or changed once an object has been persisted.


I want to save user entity with role as a relation entity

public class User{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Key id;
@ManyToOne(fetch=FetchType.EAGER,cascade = CascadeType.ALL)
    @JoinColumn(name="role_id")   
    private Role role;
}
i cant save user entity when i assign role to user entity.


Bryan Paijit

unread,
Mar 11, 2014, 7:11:27 PM3/11/14
to google-a...@googlegroups.com
Did you ever get this resolved?  I'm having the same problem.

Aniruddha Das

unread,
Feb 9, 2015, 12:11:42 AM2/9/15
to google-a...@googlegroups.com
I am having the same problem when i try to persist parent entity after storing the clicd and passing the reference to parent. Any one have any idea?

Patrice

unread,
Mar 11, 2015, 6:21:34 PM3/11/15
to google-a...@googlegroups.com
Hey all!

I think that this kind of question, if you're looking for a workaround, would be better suited to www.stackoverflow.com.  If it's an actual Feature request or a Defect report, I would suggest that you go report it here : https://code.google.com/p/googleappengine/wiki/FilingIssues?tm=3

Thank you! :)
Reply all
Reply to author
Forward
0 new messages