I am new to Java and Hibernate. I've got problem with composite key. I am trying to do something like that:
@Entity
class A {
@Id
int id;
}
@Entity
class B {
@Id
int id;
}
@Entity
class C {
@EmbeddedId
C_PK c_pk;
}
@Embeddable
class C_PK {
A a;
B b;
}
When I perform
...
session.save(c);
...
Then exception is thrown that type of A and B cannot be inserted into database. Is it possible to somehow tell hibernate to don't save the A object but only the A id? Is my approach absolutely wrong and should I just use primitive data types at C_PK class?