0

I have been trying to persist an object which has a Composite ID.

TABLEUSER
ID - auto_increment
name


TABLEUSER2
userid (foreing key from tableUSER)
keynum2

I have tried lareadt with the @EmbeddedId annotation. The problem is that I'm trying to get the foreign key as follows

@GeneratedValue(generator = "foreign")
@GenericGenerator(
        name = "foreign",
        strategy = "foreign",
        parameters = {@org.hibernate.annotations.Parameter(name = "property", value = "user")}) 

This would work perfect if it was a single key in TABLE USER, but as it's a composite ID I cannot set it.

Is there a way to do so?

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
cri_sys
  • 472
  • 1
  • 5
  • 17
  • possible duplicate of [How can I use generated value within composite keys?](http://stackoverflow.com/questions/4120414/how-can-i-use-generated-value-within-composite-keys) – Rohit Jain Nov 19 '12 at 12:38
  • In fact! i read that post before, and didnt get to any conclusion. Now i have done something different but related the link, without using EmbbededID at all and it works. the difference is that i keep using GenericGenerator as i did before instance of TableGenerator – cri_sys Nov 19 '12 at 13:19
  • the link was, http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#d0e1150 – cri_sys Nov 19 '12 at 13:28

0 Answers0