Hibernate version: 3 - also using entity manager and annotations for JPA
I have an entity with 2 collections in it (both Lists). The collections are both parameterised to subclass types of the same abstract superclass:
Code:
@OneToMany(targetEntity=ClassTimetable.class)
@JoinTable (name="uwe_timetable_users",
joinColumns=@JoinColumn(name="userID"),
inverseJoinColumns=@JoinColumn(name="TtID")
)
private List<ClassTimetable> classTimetables;
@OneToMany(targetEntity=ExamTimetable.class)
@JoinTable (name="uwe_timetable_users",
joinColumns=@JoinColumn(name="userID"),
inverseJoinColumns=@JoinColumn(name="TtID")
)
private List<ExamTimetable> examTimetables;
The result of either getExamTimetables() or getClassTimetables() both return all the timetables regardless of type...
How can I get hibernate to distinguish which timetables to return? I'm using discriminator columns to distinguish types in the Db with a SINGLE_TABLE strategy. I have little/no control over the Db schema.
MS SQL Server 2005The generated SQL (show_sql=true):Code:
select
classtimet0_.userID as userID1_,
classtimet0_.TtID as TtID1_,
classtimet1_.TtID as TtID1_0_,
classtimet1_.disabledText as disabled3_1_0_,
classtimet1_.PortalURL as PortalURL1_0_,
classtimet1_.TtName as TtName1_0_
from
uwe_timetable_users classtimet0_
left outer join
UWE_TIMETABLES classtimet1_
on classtimet0_.TtID=classtimet1_.TtID
where
classtimet0_.userID=?