Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Composite Key  RSS feed

 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

I have a composite key to user table.

so i have class for the composite-id - UserID (first,second)

I have class XXX like this:
1- the same pk like user
2- many to one to user.

in the many-to-one to the user i use in joincolumns like this:
@JoinColumns( { @JoinColumn(name = "first",referencedColumnName="first", @JoinColumn(name = "second",referencedColumnName="second") })

i get an exception:
repeated column for column- first
The same clumns are PK and FK.

Can you please advice.
 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classes:

 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The solution will be to use in "insertable=false"
like this:
@JoinColumns( { @JoinColumn(name = "first",referencedColumnName="first",insertable=false,updatable=false)
, @JoinColumn(name = "second",referencedColumnName="second",insertable=false,updatable=false) })
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!