aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Adding to join table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Adding to join table" Watch "Adding to join table" New topic
Author

Adding to join table

tanil patel
Greenhorn

Joined: Apr 10, 2013
Posts: 1
Hi,
Background:

I have a TAG table and an ARTICLE table. The relationship in the ejb is set to many to many creating a join table automatically.

1) I get a string of tags and delimit them appropriately.
2) I then store each of the 'tokens' in an array.
3) Once getting these tokens, check each token and ensure it doesn't exist in the TAG table
3.1) If it does exist get that TAG object and store in the TAG_ARTICLE table
3.2) if it doesnt store the new tag in the TAG table aswell as the TAG_ARTICLE table.

Our problem is at 3.1; the tag is found but does not get added throwing an exception:
Error: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: entities.Tag

3.2 however is working perfectly.

Thanks in advance,
Tanil
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

Please, provide the code of your entities.


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding to join table