I read through the Introduction chapter today (ok - I skimmed throught it) but couldnt find any answers to my questions there, nor in the FAQ.
Im a newcomer to Hibernate and trying to finish off what someone started :(
I have a mapping file as below for a User (a bit stripped down for clarity).
User.hbm.xml
----------------
<hibernate-mapping>
<class name="com.myApp.user.User" table="USER">
<id name="id" type="java.lang.Long">
<column name="ID" />
<generator class="native" />
</id>
<many-to-one name="domain" class="com.myApp.person.Domain" fetch="join">
<column name="DOMAIN_ID" not-null="true" />
</many-to-one>
<property name="emailAddress" type="java.lang.String">
<column name="EMAIL_ADDRESS" length="80" not-null="true" />
</property>
<property name="password" type="java.lang.String">
<column name="PASSWORD" length="25" not-null="true" />
</property>
<set name="userAddresses" inverse="true" cascade="all">
<key>
<column name="USER_ID" not-null="true" />
</key>
<one-to-many class="com.myApp.user.UserAddress" />
</set>
</class>
</hibernate-mapping>
My problem lies with the password field. I have an existing database of users who had their passwords encrypted using the mySql encode() function. So basically I wish to write a bit of SQL to run this native function for the password fetching.
My problem is that I dont understand Hibernate enough yet to figure out whether I can implement some SQL just for 1 field rathe than having to write the whole SELECT statement for getting the user/s.
I did look through chapter 16 of the documentation on Native SQL but couldnt find examples in there to help me out.
http://www.hibernate.org/hib_docs/v3/re ... rysql-load
The DAO is making use of a Criteria implementation:
get() method
---------------
Criteria criteria = getSession().createCriteria(type);
criteria.add(Restrictions.eq(MappingConstants.EMAIL_ADDRESS, emailAddress));
createCriteria(criteria, MappingConstants.DOMAIN, MappingConstants.CODE, domainCode);
List<T> dataObjList = criteria.list();
Any suggestions as to where to find the information I need is greatly appreciated from this newcomer.
Jon