我有以下HQL语句:
Query q = session.createQuery(
"SELECT ze " +
"FROM NormaleZone zo " +
"LEFT JOIN zo.zaal za " +
"LEFT JOIN za.vertoningen v " +
"LEFT JOIN zo.normaleZetels ze " +
"WHERE v = :vertoning " +
" AND zo = :zone " +
" AND ze NOT IN (SELECT t.zetel FROM Ticket t WHERE t.vertoning = :vertoning)"
);
我遇到的问题是NormaleZone
继承自Zone
,HandicapZone
和LoveZone
也是如此。
我想做的是以下内容:
Query q = session.createQuery(
"SELECT ze " +
"FROM Zone zo " +
"LEFT JOIN zo.zaal za " +
"LEFT JOIN za.vertoningen v " +
"LEFT JOIN zo.??? ze " +
"WHERE v = :vertoning " +
" AND zo = :zone " +
" AND ze NOT IN (SELECT t.zetel FROM Ticket t WHERE t.vertoning = :vertoning)"
);
你可以看到我把zo.???
放在那里。这个HQL的目的是找出尚未在电影院中拍摄的座位。问题是抽象类Zone
没有席位(ze
将是席位的别名。)
我不明白如何解决这个问题,除了查看该方法中的传入Zone
对象,然后创建两个字符串,一个用于区域,一个用于席位,然后在HQL字符串中连接它们
答案 0 :(得分:4)
有一个隐藏属性,表示对象的类。使用ze.class = :seatclass
和(“seatclass”,Seat.class)