-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Behavior off @OneToMany cascade
PostPosted: Wed Apr 09, 2008 9:18 am 
Newbie

Joined: Wed Apr 09, 2008 8:51 am
Posts: 1
I just started with JPA.

I try build some entities and found a problem with @OneToMany behavior.

My annotation is:

@OneToMany(mappedBy="parent")
@JoinColumn(name="parent_id ", insertable=false, updatable=false)
private List<Types> types;

When I merge the entity with this annotation, the parent entity try delete types entities. I don't understand this because these JPA spec reasons:

1. The @OneToMany don't have any cascade information.
2. The owner of relationship is the other entity that have parent attribute.
3. The @JoinColumn isn't insertable and updatable.

Somebody can help me?

Hibernate version:
3.0


Top
 Profile  
 
 Post subject: Re: Behavior off @OneToMany cascade
PostPosted: Sat Apr 12, 2008 8:06 am 
Newbie

Joined: Sat Apr 12, 2008 3:09 am
Posts: 3
mauromacedo wrote:
@OneToMany(mappedBy="parent")
@JoinColumn(name="parent_id ", insertable=false, updatable=false)
private List<Type> types;


You don't need @JoinColumn. This association is immutable already (due mappedBy).

Code:
@ManyToOne
@JoinColumn(name = "parent_id")
private Type parent;

@OneToMany(mappedBy="parent")
private List<Type> types;


Top
 Profile  
 
 Post subject: Re: Behavior off @OneToMany cascade
PostPosted: Sat Apr 12, 2008 8:07 am 
Newbie

Joined: Sat Apr 12, 2008 3:09 am
Posts: 3
del


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.