-->
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: Criteria API - add Restrictions to 4 joined tables
PostPosted: Sun Oct 29, 2006 12:16 am 
Newbie

Joined: Thu Oct 19, 2006 7:53 pm
Posts: 10
Hibernate version: 3.2

Mapping documents:
20:54:56,281 INFO HbmBinder:300 - Mapping class: domain.Office -> office
20:54:56,281 DEBUG HbmBinder:1270 - Mapped property: id -> office_id
20:54:56,281 DEBUG HbmBinder:1270 - Mapped property: name -> name

20:54:56,328 INFO HbmBinder:300 - Mapping class: domain.Property -> property
20:54:56,328 DEBUG HbmBinder:1270 - Mapped property: id -> property_id
20:54:56,343 DEBUG HbmBinder:1270 - Mapped property: office -> office_id
20:54:56,343 DEBUG HbmBinder:1270 - Mapped property: style -> type_id
20:54:56,343 DEBUG HbmBinder:1270 - Mapped property: address -> address_id
20:54:56,343 DEBUG HbmBinder:1270 - Mapped property: appearOnPublic -> public_access
20:54:56,343 DEBUG HbmBinder:1270 - Mapped property: price -> price

20:54:56,390 INFO HbmBinder:300 - Mapping class: domain.Address -> address
20:54:56,390 DEBUG HbmBinder:1270 - Mapped property: id -> address_id
20:54:56,390 DEBUG HbmBinder:1270 - Mapped property: street -> street
20:54:56,390 DEBUG HbmBinder:1270 - Mapped property: city -> city
20:54:56,390 DEBUG HbmBinder:1270 - Mapped property: state -> state
20:54:56,390 DEBUG HbmBinder:1270 - Mapped property: country -> country
20:54:56,390 DEBUG HbmBinder:1270 - Mapped property: zip -> zip

Code between sessionFactory.openSession() and session.close():
Criteria crit = ((((session.createCriteria(Property.class)
.add(Restrictions.between("price", minPrice, maxPrice)))
.createCriteria("office")
.add(Restrictions.eq("id", officeId)))
.createCriteria("address")
.add(Restrictions.like("city", "%" + city +"%")))
.createCriteria("style")
.add(Restrictions.like("id", "%" + styleId +"%")));

Full stack trace of any exception that occurs:
could not resolve property: address of: domain.Office

Name and version of the database you are using:
MySQL
The generated SQL (show_sql=true):
SELECT *
FROM
property p
LEFT JOIN office o ON o.office_id = p.office_id
LEFT JOIN address a ON a.address_id = p.address_id
LEFT JOIN type t ON t.type_id = p.type_id
WHERE p.price > 0 AND p.price <= 99999999
AND o.office_id = 1
AND a.city = ‘NY’
AND t.type_id = 1

Debug level Hibernate log excerpt:


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.