父类:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "DTYPE", discriminatorType = DiscriminatorType.STRING)
public class SettleBill extends PersistenceSupport {
子类:
@Entity
@DiscriminatorValue("SupplierVacationBill")
public class SupplierVacationBill extends SettleBill ;
@Entity
@GenericGenerator(name = "seq_gen", strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator", parameters = {@Parameter(name = "sequence_name", value = "seq_SupplierFlightBill"), @Parameter(name = "initial_value", value = "100000")})
public class SupplierFlightBill extends SettleBill;
@Entity
@GenericGenerator(name = "seq_gen", strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator", parameters = {@Parameter(name = "sequence_name", value = "seq_SupplierHotelBill"), @Parameter(name = "initial_value", value = "100000")})
public class SupplierHotelBill extends SettleBill;
@Entity
@GenericGenerator(name = "seq_gen", strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator", parameters = {@Parameter(name = "sequence_name", value = "SEQ_SETTLE_BILL"), @Parameter(name = "initial_value", value = "100000")})
public class SameTradeFlightBill extends SettleBill;
查询其中SupplierFlightBill ,SupplierHotelBill ,SupplierVacationBill 但是不查询SameTradeFlightBill 一次性查询:
本人解决方案:
DynamicQuery dquery = new DynamicQuery(" select distinct vb from " + searchCondition.getForTypeName() + " vb ");
// 设置查询的辨别列名称
dquery.append("and (");
dquery.append(" vb.class=SupplierFlightBill or vb.class=SupplierHotelBill or vb.class=SupplierVacationBill ");
dquery.append(" )");
请问高人有没有更简单的解决方案!本人认为自己的解决方案不够好!希望给出解决方案!!