[jboss-user] [JBoss Seam] - Re: @OneToMany Question

Holger Prause do-not-reply at jboss.com
Thu Jul 27 19:28:09 EDT 2006


Hello

anonymous wrote : 
  | It sounds like you want a ManyToMany relation. If Tasks can have many TaskItems and a TaskItem can be associated with more than one Task this is a ManyToMany relation, not a OneToMany.
  | 

Hmm but the TaskItem dont have any information about the task it owns
(no getTask() method) and its not biderectional.I shoudl learn sth about database design.

Thx for giving me the right hint i changed my code to:


  |     @ManyToMany(
  |             targetEntity=TaskItem.class,
  |             cascade={CascadeType.PERSIST, CascadeType.MERGE}
  |     )
  |     @JoinTable(
  |             name="task_taskItems",
  |             joinColumns = { @JoinColumn( name="task_id", unique = false)},
  |             inverseJoinColumns = @JoinColumn( name="taskItem_id", unique = false)
  |     )
  | 

and now its working - no complaining anymore about duplicated entry.

Thank u very much, helped me a lot and sorry for posting in wrong forum.

Bye,

Holger

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961449#3961449

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961449



More information about the jboss-user mailing list