我有一个班级
@Entity
@Table(name = "machine_report")
public class MachineSalesReport implements Serializable, Cloneable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column
private int id;
@Column(name = "avery_sales_order_no")
private String averySalesOrderNo;
@Column(name = "editor")
private String editor;
@Column(name = "edit_date")
private Date editDate;
@Column(name = "ship_out_date")
private Date shipOutDate;
@Column(name = "remarks")
private String remarks;
@Column(name = "nature_of_sales")
private String natureOfSales;
@Column(name = "supply_agreement")
private String supplyagreement;
@Column(name = "retailer")
private String retailer;
@Column(name = "program")
private String program;
@Column(name = "product_line")
private String productLine;
@Column(name = "is_final")
private String isFinal;
@Column(name = "exists")
private String exists;
@Column(name = "contract_flag")
private boolean contractFlag;
@Column(name = "installation_flag")
private boolean installationFlag;
@Column(name = "last_update_date")
private Timestamp lastUpdateTime;
@Column(name = " last_update_editor")
private String lastUpdateEditor;
@Column(name = "email_flag")
private boolean emailFlag;
// private boolean serviceContract;
@OneToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
@JoinColumn(name = "internal_information_id")
private InternalInformation internalInformation;
@OneToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
@JoinColumn(name = "customer_information_id")
private CustomerInformation customerInformation;
@OneToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
@JoinColumn(name = "installation_information_id")
private InstallationInformation installationInformation;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "machineSalesReport")
private List<ContractsAndWarranty> contracts;
我想获得所有的MachineSalesReport,然后我的dao是
Criteria dc = session.createCriteria(MachineSalesReport.class);
dc.setFetchMode("installationInformation", FetchMode.JOIN);
dc.setFetchMode("customerInformation", FetchMode.JOIN);
dc.setFetchMode("internalInformation", FetchMode.JOIN);
dc.setFetchMode("contracts", FetchMode.JOIN);
dc.setMaxResults(1);
但是我发现控制台显示sql是:
Hibernate: select this_.id as id5_4_, this_.avery_sales_order_no as avery2_5_4_,this_.contract_flag as contract3_5_4_, this_.customer_information_id as customer19_5_4_, this_.edit_date as edit4_5_4_, this_.editor as editor5_4_, this_.email_flag as email6_5_4_, this_.exists as exists5_4_, this_.installation_flag as installa8_5_4_, this_.installation_information_id as install20_5_4_, this_.internal_information_id as internal21_5_4_, this_.is_final as is9_5_4_, this_. last_update_editor as column10_5_4_, this_.last_update_date as last11_5_4_, this_.nature_of_sales as nature12_5_4_, this_.product_line as product13_5_4_, this_.program as program5_4_, this_.remarks as remarks5_4_, this_.retailer as retailer5_4_, this_.ship_out_date as ship17_5_4_, this_.supply_agreement as supply18_5_4_, contracts2_.machine_report_id as machine16_5_6_, contracts2_.id as id0_6_, contracts2_.id as id0_0_, contracts2_.contract_from as contract2_0_0_, contracts2_.contract_no as contract3_0_0_, contracts2_.contract_price as contract4_0_0_, contracts2_.contract_to as contract5_0_0_, contracts2_.create_date as create6_0_0_, contracts2_.create_editor as create7_0_0_, contracts2_.is_final as is8_0_0_, contracts2_.last_date as last9_0_0_, contracts2_.last_editor as last10_0_0_, contracts2_.machine_report_id as machine16_0_0_, contracts2_.remark as remark0_0_, contracts2_.service_contract_years as service12_0_0_, contracts2_.service_left_no as service13_0_0_, contracts2_.service_no as service14_0_0_, contracts2_.type as type0_0_, customerin3_.id as id1_1_, customerin3_.bill_to_company_address_cn as bill2_1_1_, customerin3_.bill_to_company_address_en as bill3_1_1_, customerin3_.bill_to_company_name as bill4_1_1_, customerin3_.bill_to_code as bill5_1_1_, customerin3_.bill_to_country as bill6_1_1_, customerin3_.customer_email as customer7_1_1_, customerin3_.customer_fax as customer8_1_1_, customerin3_.customer_phone as customer9_1_1_, customerin3_.customer_name as customer10_1_1_, customerin3_.ship_from as ship11_1_1_, customerin3_.ship_to_company_address_cn as ship12_1_1_, customerin3_.ship_to_company_address_en as ship13_1_1_, customerin3_.ship_to_company_name as ship14_1_1_, installati4_.id as id2_2_, installati4_.customer_email as customer2_2_2_, installati4_.customer_fax as customer3_2_2_, installati4_.customer_name as customer4_2_2_, installati4_.customer_phone as customer5_2_2_, installati4_.factory_address_cn as factory6_2_2_, installati4_.factory_address_en as factory7_2_2_, installati4_.factory_name as factory8_2_2_, internalin5_.id as id3_3_, internalin5_.avery_entity_name as avery2_3_3_, internalin5_.city as city3_3_, internalin5_.country as country3_3_, internalin5_.csr_email as csr5_3_3_, internalin5_.csr_name as csr6_3_3_, internalin5_.csr_phone as csr7_3_3_, internalin5_.salesperson_email as salesper8_3_3_, internalin5_.salesperson_name as salesper9_3_3_, internalin5_.salesperson_phone as salespe10_3_3_ from machine_report this_ left outer join contracts2 contracts2_ on this_.id=contracts2_.machine_report_id left outer join customer_information customerin3_ on this_.customer_information_id=customerin3_.id left outer join installation_information installati4_ on this_.installation_information_id=installati4_.id left outer join internal_information internalin5_ on this_.internal_information_id=internalin5_.id where this_.is_final=? and this_.exists=? order by this_.id desc limit ?
Hibernate: select machinesal0_.id as id5_0_, machinesal0_.avery_sales_order_no as avery2_5_0_, machinesal0_.contract_flag as contract3_5_0_, machinesal0_.customer_information_id as customer19_5_0_, machinesal0_.edit_date as edit4_5_0_, machinesal0_.editor as editor5_0_, machinesal0_.email_flag as email6_5_0_, machinesal0_.exists as exists5_0_, machinesal0_.installation_flag as installa8_5_0_, machinesal0_.installation_information_id as install20_5_0_, machinesal0_.internal_information_id as internal21_5_0_, machinesal0_.is_final as is9_5_0_, machinesal0_. last_update_editor as column10_5_0_, machinesal0_.last_update_date as last11_5_0_, machinesal0_.nature_of_sales as nature12_5_0_, machinesal0_.product_line as product13_5_0_, machinesal0_.program as program5_0_, machinesal0_.remarks as remarks5_0_, machinesal0_.retailer as retailer5_0_, machinesal0_.ship_out_date as ship17_5_0_, machinesal0_.supply_agreement as supply18_5_0_ from machine_report machinesal0_ where machinesal0_.customer_information_id=?
Hibernate: select machinesal0_.id as id5_0_, machinesal0_.avery_sales_order_no as avery2_5_0_, machinesal0_.contract_flag as contract3_5_0_, machinesal0_.customer_information_id as customer19_5_0_, machinesal0_.edit_date as edit4_5_0_, machinesal0_.editor as editor5_0_, machinesal0_.email_flag as email6_5_0_, machinesal0_.exists as exists5_0_, machinesal0_.installation_flag as installa8_5_0_, machinesal0_.installation_information_id as install20_5_0_, machinesal0_.internal_information_id as internal21_5_0_, machinesal0_.is_final as is9_5_0_, machinesal0_. last_update_editor as column10_5_0_, machinesal0_.last_update_date as last11_5_0_, machinesal0_.nature_of_sales as nature12_5_0_, machinesal0_.product_line as product13_5_0_, machinesal0_.program as program5_0_, machinesal0_.remarks as remarks5_0_, machinesal0_.retailer as retailer5_0_, machinesal0_.ship_out_date as ship17_5_0_, machinesal0_.supply_agreement as supply18_5_0_ from machine_report machinesal0_ where machinesal0_.installation_information_id=?
Hibernate: select machinesal0_.id as id5_0_, machinesal0_.avery_sales_order_no as avery2_5_0_, machinesal0_.contract_flag as contract3_5_0_, machinesal0_.customer_information_id as customer19_5_0_, machinesal0_.edit_date as edit4_5_0_, machinesal0_.editor as editor5_0_, machinesal0_.email_flag as email6_5_0_, machinesal0_.exists as exists5_0_, machinesal0_.installation_flag as installa8_5_0_, machinesal0_.installation_information_id as install20_5_0_, machinesal0_.internal_information_id as internal21_5_0_, machinesal0_.is_final as is9_5_0_, machinesal0_. last_update_editor as column10_5_0_, machinesal0_.last_update_date as last11_5_0_, machinesal0_.nature_of_sales as nature12_5_0_, machinesal0_.product_line as product13_5_0_, machinesal0_.program as program5_0_, machinesal0_.remarks as remarks5_0_, machinesal0_.retailer as retailer5_0_, machinesal0_.ship_out_date as ship17_5_0_, machinesal0_.supply_agreement as supply18_5_0_ from machine_report machinesal0_ where machinesal0_.internal_information_id=?
为什么有这么多的sql?如果我想设置Max(1000),我将获得3000 sql。 我想要第一个sql,而不是所有sql。
答案 0 :(得分:0)