-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Fetching with join problem
PostPosted: Fri Oct 19, 2007 4:05 pm 
Newbie

Joined: Sat Jul 22, 2006 3:08 pm
Posts: 6
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 23, 2007 12:14 pm 
Regular
Regular

Joined: Mon Jan 22, 2007 10:32 am
Posts: 101
try setting hibernate.max_fetch_depth property to something between 1-3.

_________________
Please rate this post if you find it helpful


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.