I get lost in how to use compound keys with annotations and sleeping ...
So, for example, I have this table that has:
TABLE_A
INIT, NUM, CNT, TYP
TABLE_B
INIT, NUM, V_CNT
TABLES A and B primary keys are composite keys consisting of INIT and NUM
I want to fulfill my request:
"FROM TABLE_A AS A " +
"LEFT JOIN A.hiber_join AS B " +
"WHERE A.INIT||A.NUM IN (:carList) AND A.INIT IN (:initList) AND A.NUM IN (:numberList) " +
"AND B.V_CNT > 0
My classes look like this:
* Class_A *
public class TABLE_A implements Serializable{
private String INIT;
private String NUM;
private Integer CNT;
private String TYP;
@OneToOne
@JoinTable(name = "TABLE_B",
joinColumns = {@JoinColumn(name = "INIT"), @JoinColumn(name = "NUM")}
)
protected TABLE_B hiber_join;
public TABLE_A()
{}
public void doHibernateStuff()
{
}
}
// Class B
public class TABLE_B implements Serializable{
private String NUM;
private String INIT;
private Integer V_CNT;
}
I tried to make it as simple as possible because I needed to use hibernation and annotations from the very beginning ... since you can say that I worked for a while, and the dormant documentation and other issues did not seem to help ...
source
share