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

Holger Prause do-not-reply at jboss.com
Thu Jul 27 18:23:47 EDT 2006


i have a site where the uses can select TaskItems (entities from the database)
and set it to a task.

I use a OneToMany relationship (a task hast many taskitems)
When i set the TaskItems to the task and save it, everything will be ok.

But when i save another task whith the same TaskItems, it will fail becourse the primary key of the temporary join table "task_taskItems"
is the foreign key to the task item, this means in my case when then taskitems were set to a task, no other other task can have these taskitems

So the question is:

How can i specify the primary key of the temporary table?

As Workaround i could write a Class which wraps around the TaskItems
and inside there i can use @JoinColumn but it will mess up my code :-/

  |  @OneToMany
  |     @JoinTable(
  |             name="task_taskItems",
  |             joinColumns = { @JoinColumn( name="task_id", unique = false), @JoinColumn( name="task_taskItems_id", unique = true) },
  |             inverseJoinColumns = @JoinColumn( name="taskItem_id", unique = false)
  |     )
  |     public List<TaskItem> getTaskItems() {
  |     	return this.taskItems;
  |     }
  |     public void setTaskItems(List<TaskItem> taskItems) {
  |     	this.taskItems = taskItems;
  |     }

Thank u very much,


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

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

More information about the jboss-user mailing list