Hibernate version: 3.1
Name and version of the database you are using: MySql 4.0.18
The generated SQL (show_sql=true):
Hibernate: select this_.id as id34_0_, this_.name as name34_0_, this_.product_id as product3_34_0_, this_.initialowner as initialo4_34_0_, this_.initialqacontact as initialq5_34_0_, this_.description as descript6_34_0_ from bugs.components this_ where (this_.product_id=? and this_.initialowner=?) order by this_.name asc
Debug level Hibernate log excerpt:
DEBUG ShortType:74 - binding '1' to parameter: 1
DEBUG IntegerType:74 - binding '0' to parameter: 2
Ok, here's my problem. I've looked at the Ref docs on Querying by example, and on the forums, but I havent been able to find a cause for what I'm experienceing. I'm creating an object and assigning a SINGLE parameter to it, and then using that instance as an example to query by. HOWEVER, as is show above in the Debug, its binding TWO parameters...neither of which are an ID, or in anyay connected to a primary key.
Why would hibernate be creating a default value an binding it to a column when I never specified a paramter? This is happening for all my query by Examples, and the other parameter it picks is seemingly random.
My code follows:
Code:
Business Object:
Profiles profile = new Profiles();
profile.setLoginName(email);
new ProfilesHome().findByExample(profile);
...
Data Access Object:
public List findByExample(Profiles instance) {
List results = sessionFactory.getCurrentSession().
createCriteria(Profiles.class).
add(Example.create(instance)).list();
return results;
}