Hibernate version:2.1.7 (with MySQL 4.0.20)
I have a query which needs to return a hibernate entity and a scalar value. I'm using the count() and if() functions from mysql, so I believe I cannot use HQL. Additionally, the entity + scalara combination eliminates using createSQLQuery().
I can, however, retrieve all the properties for the entity instance in addition to the scalar value via jdbc.
The question is, can I use those property values to create an instance of the entity as though the instance was created by hibernate itself?
The goal is for the entity relationships (mapped with lazy initialization) to still be functional, even though I have manually instantiated the entity and populated the properties.
The other option seems to be to use jdbc to get the entity id and the scalara value, and then use HQL with the entity id to load the actual entity instance. Would be nice if I could skip the second query.
thanks,
Miguel
|