Hi!
Can anyone help in this problem?
I have entities for table_action and table_list. I want to have in table_action entity a list of table_list elements. I cannot change the database model and I have to use hibernate.
TableAction.java :
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "table_action2list", joinColumns = {
@JoinColumn(name = "OBJID") }, inverseJoinColumns = {
@JoinColumn(name = "list_objid", referencedColumnName = "objid", nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "list_type", referencedColumnName = "list_type", nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "list_kind", referencedColumnName = "list_kind", nullable = false, insertable = false, updatable = false) })
private Set<TableList> tableList = new HashSet<TableList>();
This doesn`t work because i cannot join table_action2plan. This is the sql which works corrently:
select rl.*
from table_list rl
join table_action2list arc on arc.LIST_OBJID = rl.OBJID and arc.LIST_KIND = rl.LIST_KIND and arc.LIST_TYPE = rl.LIST_TYPE
join table_action2plan ac on ac.OBJID = arc.action2plan_objid
join table_action ta on ta.OBJID = ac.ACTION_OBJID
table_action2plan and table_action2list are secondary tables in my entity but i am free to create entities for them if needed.
Is this possible in Hibernate and do you have ideas on how to solve the problem?
Thanks a lot.!