I don't get it.
I have the following setup:
2 clases:
public class ClientOrder {
private int orderId;
private String orderNo, orderState;
private Client orderClient;
private Date orderDate, stateDate;
private Address address;
private double totalNet, totalVat, totalGross, amountPayed;
private Set<OrderLine> orderLines;}
public class Client {
private int clientId;
private Address address;
private String firstName;
private String lastName;
private String login;
private String password;
private String email;
private boolean spamAcc;
private String clientType;
private String nip;
private String status;}
The mappings are:
<class name="axmar.dao.ClientOrder" table="client_order" lazy="false">
<id name="orderId" column="order_id">
<generator class="native"/>
</id>
<property name="orderNo" column="order_no"/>
<property name="orderDate" column="order_date"/>
<property name="orderState" column="order_state"/>
<property name="stateDate" column="state_date"/>
<property name="totalNet" column="total_net"/>
<property name="totalVat" column="total_vat"/>
<property name="totalGross" column="total_gross"/>
<property name="amountPayed" column="amount_payed"/>
<many-to-one name="address" class="axmar.dao.Address"
column="address_id" fetch="join" lazy="false"/>
<many-to-one name="orderClient" class="axmar.dao.Client"
column="client_id" fetch="join" lazy="false"/>
<set name="orderLines" lazy="true" inverse="true">
<key column="order_id"/>
<one-to-many class="axmar.dao.OrderLine" not-found="ignore"/>
</set>
</class>
<class name="axmar.dao.Client" table="client">
<id name="clientId" column="client_id">
<generator class="native"/>
</id>
<property name="clientType" column="client_type"/>
<property name="email"/>
<property name="firstName" column="first_name"/>
<property name="lastName" column="last_name"/>
<property name="login"/>
<property name="nip"/>
<property name="password"/>
<property name="spamAcc" column="spam_acc"/>
<property name="status"/>
<many-to-one name="address"
class="axmar.dao.Address"
column="address_id"
unique="true"
cascade="save-update"
not-found="ignore"/>
</class>
And when I load ClientOrder list:
session.createQuery("from ClientOrder").list();
Hibernate issues one select statement from client order
and then multiple select statements from client and address.
How do I make it so I get singe select with join ???
Alek
|