• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

@ManytoMany with join table and @CollectionOfElements : conceptual difference

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All!!

I need some conceptual explanations from you gurus:

I was designing an entity bean and this entity "UserType" has a relationship with Questions so i had a join table where I had the relationship for the two and an extra column defining the order of the questions (Table: UserTypeId , QuestionID , Order):

Firstly as I would always use I used @manytoMany like this :



what happened in this one was that when ever I tried to use EntityHome.remove() ( this is a jboss seam's component which only calls the entitymanager's remove method and some message methods ) what it would do is try to put null in the UserTypeId column ( in the join table) which cannot be null it did not remove the whole row as it should. The other way would have been to fire a native sql query which was not a good solution. Just to explain, I was not doing a delete on the question object because it was just a part of the join table so what I did was to query the object that depicted the whole row of the join table with the "ORDER" field and a composite primary key ((UserTypeId and QuestionId) and Order) and then did a remove on that which was the way one deletes any row form the table. Right?

SO... I was advised to use this instead:



this one works perfect, Now as per my concepts the one with @ManytoMany should work as well. but it didnt. My question here is why? why it did not work. and Why does this one works. I have put this annotation and its working but i want to understand why is this one working. now I remove anything from the list and the remove is automatically triggered to the table as well.

I will really appreciate the answers and explanations.

Thanks in advance.

El Cid
 
Syed Mahdi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no one !!!
 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic