I am looking to pull data from a table that is two joins away from the current object's table. Is it possible to join a secondary table off another secondary table using annotations?
Currently, I am using
Code:
@Table(name = "testobject")
@SecondaryTables({
@SecondaryTable(name="users", pkJoinColumns={
@PrimaryKeyJoinColumn(name="userid", referencedColumnName="userid")}),
@SecondaryTable(name="groups",pkJoinColumns={
@PrimaryKeyJoinColumn(name="groupid", referencedColumnName="groupid")})
})
to annotate my class. This fails due to
Code:
Caused by: org.hibernate.MappingException: Unable to find column with logical name: companyid in org.hibernate.mapping.Table(testobject) and its related supertables and secondary tables
In this case, the current object has access to userid, but needs groupid to pull information from the groups table.
Any assistance would be appreciated.