I guess I really need to show some of my mapping file and then the generated SQL...
excerpt...
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="CLIENT_INFO">
<class name="this.is.my.package.Client"
table="CLIENT">
<id name="id"
column="CLIENT_ID"/>
...Code:
<property name="relatedInfo"
column="CLIENT_ID"
type="string"
formula="( SELECT infoTable.info FROM GENERAL_INFO.INFO infoTable WHERE substr(client_id, 1, (length(client_id)-3)) = infoTable.info_code group by infoTable.info)"/>
</class>
</hibernate-mapping>
end excerpt...Generated SQL for the "relatedInfo" portion:
Code:
(SELECT infoTable.info
FROM GENERAL_INFO.INFO infoTable
WHERE substr(client_inf0_.client_id,
1,
(length(client_inf0_.client_id)-3)) = infoTable.info_code
GROUP BY infoTable.info
) AS formula0_
All I really want to do is put FETCH FIRST ROW ONLY instead of GROUP BY infoTable.info.
I tried putting the following in my hibernate.properties:
hibernate.query.substitutions fetch=FETCH
hibernate.query.substitutions first=FIRST
hibernate.query.substitutions row=ROW
hibernate.query.substitutions only=ONLY
and putting "fetch first row only" at the end of my query, but hibernate still attempted to interpret the words:
Code:
(SELECT infoTable.info
FROM GENERAL_INFO.INFO infoTable
WHERE substr(client_inf0_.client_id,
1,
(length(client_inf0_.client_id)-3)) = infoTable.info_code
client_inf0_.fetch client_inf0_.first client_inf0_.row client_inf0_.only
) AS formula0_
I'm not sure how in this case I could even use custom sql for loading... I'm only getting back a string...
Thanks for trying to help, but I really am still stuck. Maybe you could explain how I might use one or the other. Or maybe I am just really approaching this whole thing wrong...