-->
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: How can I restrict on a Join rather than on Filter condition
PostPosted: Tue Sep 16, 2008 5:49 am 
Newbie

Joined: Tue Sep 16, 2008 4:48 am
Posts: 2
Hibernate version:3.2.5
Name and version of the database you are using:Oracle 10g XE


Hi,

A quick simple question. Using the Criteria API, how can I make Hibernate generate a restriction on a left join condition rather than on the WHERE clause filter?

i.e. The SQL I'm looking for is like (a) the SQL I get is like (b)


(a) select * from test1
left outer join test2 on test1.name = test2.name and test2.colour = 'red';

(b) select * from test1
left outer join test2 on test1.name = test2.name
where test2.colour = 'red';

The relevant lines of my java code looks something like this;

Criteria criteria = getHibernateTemplate().getSessionFactory().getCurrentSession().createCriteria(Test1.class, "test1")
criteria.createAlias("test1.test2", "test2", CriteriaSpecification.LEFT_JOIN);

criteria.add(Restrictions.eq("test2.colour", "red" ));

Thanks


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.