-->
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: Merge and Cascades
PostPosted: Mon Oct 02, 2006 1:47 pm 
Newbie

Joined: Sun Jun 25, 2006 9:27 pm
Posts: 18
Hi,
i have a problem with merging of detached entities. I have a Text-Object that contains Sentence Objects which in turn contain words. Now I don't want to have double entries of certain words but rather e.g. persisting "This car is his car" should not add two times "car" into the DB. I tried using the EntityManager.merge method and have Cascading turned on (CascadeStyle.MERGE) for the relationship and I can see some attempted selects. However I get EntityExists exceptions with that... So I tried the same without the hirarchy by just persisting the same word multiple times (via merge) and that worked. So I conclude there is something wrong with the Cascading settings. I use Hibernate Entity Manager 3.2.0CR1 along with Annotations 3.2.0 CR1.
Any clues on this?
THanks,
Joey


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 02, 2006 2:20 pm 
Newbie

Joined: Sun Jun 25, 2006 9:27 pm
Posts: 18
Hi,
so i found the problem but no solution. The problem is that the foreign key of the referenced "Word" is inside the Join-Table marked as unique, which I switched manually to index.
Anyone got any clues on how I can avoid the word_content being unique in the join table? Thanks!!

[code]

@OneToMany
@JoinTable(name="sentence_word",
joinColumns={@JoinColumn(name="sentence_id")},
inverseJoinColumns={@JoinColumn(name="word_content",referencedColumnName="content")})

/**
* @return the words
*/
public Collection<Word> getWords() {
return words;
}
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 09, 2006 4:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@ManyToMany

_________________
Emmanuel


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.