-->
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.  [ 2 posts ] 
Author Message
 Post subject: Can Hibernate manage my Many-toMany association?
PostPosted: Thu Dec 14, 2006 9:08 pm 
Newbie

Joined: Wed Oct 25, 2006 3:26 pm
Posts: 7
I have defined a MANY-TO-MANY relationship between two entities via a JoinTable.

ALERT
--------
alertId
alertType

ALERTCONTACTXREF
-----------------------------
alertId
contactId

CONTACT
-------------
contactId
contactName

The many to many association was defined on the alert entity. So there is this method on the alert entity:

@Entity
Alert {
@Column Long alertId;
@Column String alertType;

@ManyToMany( fetch=FetchType.EAGER )
@JoinTable( name="ALERTCONTACTXREF",
joinColumns= @JoinColumn( name="ALERTID",
referencedColumnName="ALERTID" ),
inverseJoinColumns= @JoinColumn( name="CONTACTID",
referencedColumnName="CONTACTID" ) )
private Set<Contact> contacts;

Set<Contact> getContacts();
}

My question is this:
If I delete a contact from the Set of contacts of an alert instance, will hibernate delete the corresponding record in the cross ref/join table (ie ALERTCONTACTXREF) ?

I would only want the association deleted, not the associated entity.

-Mike


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 15, 2006 1:26 am 
Newbie

Joined: Fri Dec 15, 2006 12:46 am
Posts: 3
I guess Hibernate deletes all relations in the relation-table on an update and afterwards inserts the relations again!!!

So my best guess on your question is Yes!!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.