Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.05
Mapping documents:
Not Necessary
Code between sessionFactory.openSession() and session.close():
Criteria criteria = sess.createCriteria ( Permission.class);
criteria.add ( Restrictions.eq ( "user", user));
Criteria subCriteria = criteria.createCriteria ( "accountGroup").createCriteria ( "groupedAccounts").createCriteria ( "account").createCriteria ( "cashMovements");
subCriteria.add ( Restrictions.eq ( "id", new Integer(1)));
Full stack trace of any exception that occurs:
No Exceptions.
Name and version of the database you are using:
Sybase ASE 12.5
The generated SQL (show_sql=true):
select ...... where this_.USER_ID=2
and cashmoveme4_.ID=1;
Debug level Hibernate log excerpt:
Not needed.
I could not find a way to get the "and" to change to an "or".
I went through the docs and then looked into the code also and found this in class CriteriaQueryTranslator
<code>
public String getWhereCondition() {
StringBuffer condition = new StringBuffer(30);
Iterator criterionIterator = rootCriteria.iterateExpressionEntries();
while ( criterionIterator.hasNext() ) {
CriteriaImpl.CriterionEntry entry = (CriteriaImpl.CriterionEntry) criterionIterator.next();
String sqlString = entry.getCriterion().toSqlString( entry.getCriteria(), this );
condition.append(sqlString);
if ( criterionIterator.hasNext() ) condition.append(" and ");
}
return condition.toString();
}
</code>
Looks like if you add 2 or more Criterion to a Criteria they are always "anded".
Is there some way around this ?