Hibernate version: 3
I was reading about new feature of overriding generated SQL by handwritten SQL embedded in the mapping document in blog "Using Hibernate3 as a JDBC framework".
I stopped at:
Code:
<class name="Person" lazy="true">
<id name="id" unsaved-value="0">
<generator class="increment"/>
</id>
<property name="name" not-null="true"/>
<loader query-ref="person"/>
<sql-insert>INSERT INTO PERSON (NAME, ID) VALUES ( UPPER(?), ? )</sql-insert>
<sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE ID=?</sql-update>
<sql-delete>DELETE FROM PERSON WHERE ID=?</sql-delete>
</class>
<sql-query name="person">
<return alias="p" class="Person" lock-mode="upgrade"/>
SELECT NAME AS {p.name}, ID AS {p.id} FROM PERSON WHERE ID=? FOR UPDATECode:
</sql-query>
If I am querying "person" by name or by any other property (not id), how can I override those kind of queries?
How is this solved hypothetically?
Thanks a lot,
Marko