Quote:
There is a feature you are planning on putting into Hibernate 2.2 (was 2.1 but got pushed). "named native SQL queries defined in mapping file" My team and I are very interested in this feature and I was just wondering if you were planning to do with 2.2 the same that you did with 2.1, being release 2.2 beta 1 at the same time as the official release of 2.1.
We have not added named sql queries yet to hibernate - any patches for doing it is welcome ;)
[qoute]
Also, I noticed that in the query example ...
<sql-query name="mySqlQuery">
<return alias="person" class="eg.Person"/>
SELECT {person}.NAME AS {person.name}, {person}.AGE AS {person. age}, {person}.SEX AS {person.sex}
FROM PERSON {person} WHERE {person}.NAME LIKE 'Hiber%'
</sql-query>
you prefix all of the columns with the object as opposed to the table name then "as" them to the object.property. I'm wondering what exactly is NEEDED in these situations. Do we have to "as" them like that and is it possible to use table.column as opposed to {object}.column in some places?
[/quote]
createSQLQuery() utilizes the exact same code HQL queries uses to get the data from an resultset - thus it is a requirement that the column names is aliased exactly the same way as if it was retreived from the original mapped table. Furthermore having the {} syntax makes it quite easy to avoid having hardcoded sql column/table names.
So, you most likely need to "as" them, but you are totally free to do table.column instead of {class}.column
Quote:
Lastly, when you use the ":replacementValue" format... is there anything planned for future development where we can pass in a map of all the replacements and there would be a mechanism that goes in, interates the map and does the proper "set{Type}" on the query for each name-value pair in the map? I'm wondering this mainly b/c if you are going to be building it soon (or already have and I don't know about it), I won't bother building one.
I think we would accept such a patch. You would like something like Query.setPropertiesFromMap(Map map);, right ?
Have you taken a look at Query.setProperties(Object); which does what you mention via get/setters on an Object ?
(I reckon using this as inspiration (look at AbstractQuery.setProperties(Object)) will make it easy for you to do the above request ;)
/max