-->
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.  [ 3 posts ] 
Author Message
 Post subject: Criteria API questions
PostPosted: Fri Feb 09, 2007 8:43 am 
Newbie

Joined: Mon Aug 28, 2006 12:01 pm
Posts: 11
Hi,

I need a little help with the Criteria API.

Lets assume I have the following classes

A {
private String name;
private B b;
private Set<C> cSet;
}

B{
private String someProperty;
private D dObj;
}

C{
private String whatever;
}

D{
private String anotherProperty;
}

First of all, what is the difference between using:
a. criteria.createAlias()
b. CriteriaImpl.Subcriteria
c. criteria.createCriteria()

Second,

How can I select all A objects that have b.someProperty = 'a' AND b.d.anotherProperty='fff' AND a.c.whatever = 'ffggg'

and the same but with OR



Can I combine in one Junction criterions from different criterias ?

Thanks in advance.


Hibernate version:3.2.2


Top
 Profile  
 
 Post subject: Difference between createAlias() and createCriteria()
PostPosted: Wed Jan 09, 2008 11:33 am 
Beginner
Beginner

Joined: Tue Jan 08, 2008 2:15 pm
Posts: 22
I am looking too for the difference between these two methods, which is not clear at all since they seem to lead to the same results, both return a Criteria, both take the same arguments.

Can someone explain the difference between the two?


Top
 Profile  
 
 Post subject: Difference between createAlias() and createCriteria()
PostPosted: Wed Jan 09, 2008 11:42 am 
Beginner
Beginner

Joined: Tue Jan 08, 2008 2:15 pm
Posts: 22
I looked in the source code (I had to do it many times since the documentation is incomplete here and there):

from org.hibernate.CriteriaImpl:

...
public Criteria createAlias(String associationPath, String alias) {
return createAlias( associationPath, alias, INNER_JOIN );
}

public Criteria createAlias(String associationPath, String alias, int joinType) {
new Subcriteria( this, associationPath, alias, joinType );
return this;
}

public Criteria createCriteria(String associationPath) {
return createCriteria( associationPath, INNER_JOIN );
}

public Criteria createCriteria(String associationPath, int joinType) {
return new Subcriteria( this, associationPath, joinType );
}

public Criteria createCriteria(String associationPath, String alias) {
return createCriteria( associationPath, alias, INNER_JOIN );
}

public Criteria createCriteria(String associationPath, String alias, int joinType) {
return new Subcriteria( this, associationPath, alias, joinType );
}
..

it seems to me there is no implementation difference between createAlias() and createCriteria().

However, I don't know what difference there should be conceptually, if any.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.