I modified my earlier code to:
Code:
getHibernateTemplate().find("from AreaBO area where area.area = ?", "Western")
Which AFAIK is the correct way to say "get me a list of AreaBO objects that have an area value of Western"
Hibernate output sql:
Code:
Hibernate: select areabo0_.AREA_ID as AREA1_ from FORM4248_AREA areabo0_ where areabo0_.AREA=?
Which is incorrect.
Following Spring's HibernateTemplate source, my above find call gets "translated" into the below Hibernate code, almost to the variable name:
Code:
Query queryObject = session.createQuery("from AreaBO area where area.area = ?");
queryObject.setParameter(0, "Western");
List list = queryObject.list();
If I run this code, which is from my understanding how Spring executes my find(), in the same exact environment (same db, same objects) but outside of Spring and manually manage Hibernate Sessions, I get the expected results and the generated sql is correct.
Hibernate output sql:
Code:
Hibernate: select area0_.AREA_ID as AREA_ID, area0_.AREA as AREA from FORM4248_AREA area0_ where (area0_.AREA=? )
I'm don't know or understand what is going on but it looks like there is a bug somewhere in the Spring or Hibernate framework that is throwing things off. I can't explain it any other way. I don't know why the code inside Spring isn't working but the same code outside does.
Any takers before I fill out bug reports?