-->
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.  [ 1 post ] 
Author Message
 Post subject: QBE - Example query
PostPosted: Wed Jan 05, 2005 9:14 pm 
Newbie

Joined: Mon Aug 30, 2004 1:37 am
Posts: 16
Hibernate version:
2.1.4
Mapping documents:
from CaveatEmptor 0.9.5
Code between sessionFactory.openSession() and session.close():
//using hibernateConsole 2.1:
User u = new User();
u.setAdmin(false);
Item i = new Item();
Example exampleUser = Example.create(u).ignoreCase().enableLike(MatchMode.ANYWHERE).excludeZeroes();
Example exampleItem = Example.create(i).ignoreCase().enableLike(MatchMode.ANYWHERE);
session.createCriteria(User.class).add(exampleUser)
.createCriteria("items").add(exampleItem).list();

Full stack trace of any exception that occurs:
n/a
Name and version of the database you are using:
hsqldb
The generated SQL (show_sql=true):
select this.USER_ID as USER_ID1_, this.VERSION as VERSION1_, this.FIRSTNAME as FIRSTNAME1_, this.LASTNAME as LASTNAME1_, this.USERNAME as USERNAME1_, this."PASSWORD" as y6_1_, this.EMAIL as EMAIL1_, this.RANKING as RANKING1_, this.IS_ADMIN as IS_ADMIN1_, this.CREATED as CREATED1_, this.DEFAULT_BILLING_DETAILS_ID as DEFAULT11_1_, this.STREET as STREET1_, this.ZIPCODE as ZIPCODE1_, this.CITY as CITY1_,
x0_.ITEM_ID as ITEM_ID0_, x0_.VERSION as VERSION0_, x0_.NAME as NAME0_, x0_.DESCRIPTION as DESCRIPT4_0_, x0_.INITIAL_PRICE as INITIAL_5_0_, x0_.INITIAL_PRICE_CURRENCY as INITIAL_6_0_, x0_.RESERVE_PRICE as RESERVE_7_0_, x0_.RESERVE_PRICE_CURRENCY as RESERVE_8_0_, x0_.START_DATE as START_DATE0_, x0_.END_DATE as END_DATE0_, x0_.STATE as STATE0_, x0_.APPROVAL_DATETIME as APPROVA12_0_, x0_.CREATED as CREATED0_, x0_.APPROVED_BY_USER_ID as APPROVE14_0_, x0_.SELLER_ID as SELLER_ID0_, x0_.SUCCESSFUL_BID_ID as SUCCESS16_0_
from USERS this inner join ITEM x0_ on this.USER_ID=x0_.SELLER_ID
where (this.IS_ADMIN=?) and (1=1)

Debug level Hibernate log excerpt:
n/a

This question is really to clarify my understanding of Example queries. Using the CaveatEmptor applicaiton, I modified the User and Item classes to make the no argument constructors public so I could use them for the Example queries, other than that no changes were made. Then using HibernateConsole I executed the above java code, based on the example given on page 279 of HIA. The SQL which resulted is listed above.
On page 264 of HIA it says:
Quote:
By default, a criteria query returns only the root entity - in this case the Items - in the query result.

Since an Example is just an ordinary Criterion (page 278 HIA) I thought that the generated SQL would only select the fields for the root entity - in this case User, but as can be seen above it selects the fields for all the Example classes (User and Item).
Is there an easy way to control this so that the fields from Item are not selected? I'm really impressed with the power of Example queries, especially this way of combining them - but am worried about all that extra network traffic.
Thanks for any insights.
Grainne.


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

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.