i have a simple Criterion and conjunctions like this. Code:
protected Conjunction simpleFilterings(){return (org.hibernate.criterion.Conjunction)Restrictions.conjunction().add(Restrictions.equals("isDeleted","N")).add(Restrictions.isNotNull("studentSchool").add(Restrictions.isNotNull("studentHome");}
protected Criterion filterOnlyNotDeleted(){return equals("isDeleted","N");}
protected Conjunction homeFilterings(){return (org.hibernate.criterion.Conjunction)Restrictions.conjunction().add(Restrictions.eq("currentCode",1)).add(Restrictions.eq("currentStatus",1)).add(Restrictions.eq("isDeleted","N"));}
this filters are constant they do not change at any moment.
later i apply on a simple Criteria like this.
Code:
final Criteria like = session.createCriteria(Student.class).add(simpleFilterings());
final Criteria schoolCriteria = like.createCriteria("studentSchool","school",JoinType.INNER_JOIN,filterOnlyNotDeleted());
final Criteria homeCriteria = like.createCriteria("studentHome","home",JoinType.INNER_JOIN,homeFilterings());
Student have many to One relationship to School and Home means that a student can have one School and one home..
there is strange behavior in the generated SQL because is `homeFilterings` i have a Conjunction with some types of the fields like `isDelete='N' and currentCode=1 and currentStatus=1` as is show above, but when i add this conjunction in the criteria namely
Code:
like.createCriteria("studentHome","home",JoinType.INNER_JOIN,homeFilterings());
this is generating the wrong data binding i can see it through `P6SpyDriver` the corrent would be
isDeleted='N' and currentCode=1 and currentStatus=1
and is generating something like
isDeleted=1 and currentCode=1 and currentStatus='N'
`of course this is wrong`
in Hibernate is returning 0 results when i know there is results i copy the generated SQL into console and is returning
Truncated incorrect DOUBLE value: 'N'
if i delete the `schoolCriteria` it works or if i use
Code:
like.createCriteria("studentHome","home",JoinType.INNER_JOIN).add(homeFilterings());
generated the right SQL what i am doing wrong my environment is.
tested on Netbeans,Java 8,Hibernate 4.3.4 and mysql 5.5
the API i am using is this.
![Criteria API][1]
but strangely Hibernate is populating the properties with wrong values.
any help is hugely appreciate.