Wednesday, July 30, 2008

Generating distinct rows in hibernate

You can not put a distinct in the clause.

You can select distinct rows though:
select distinct b.institution from MyBank b where b.institution LIKE UPPER(:startsWith)

This gives all institutions attached to a MyBank matching the startsWith.

Sunday, July 27, 2008

Retrieving hibernate generated id

The ID will be available just after Session.save(object) is called.

Another method that could be of interest if the entitiy is associated with a session:
Session.getIdentifier()


http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html

Wednesday, July 23, 2008

Using Sequence of Oracle in Hibernate

For using sequence create in oracle in hibernate, make following confguration

<class name="className" table="tableName"
schema="databasename">
<id name="id" type="java.lang.Long"
unsaved-value="null" column="ID">
<generator
class="sequence">
<param
name="sequence">USERS_SEQ</param>
</generator>
</id>

Sunday, June 29, 2008

Hibernate Interview questions

A set of hibernate interview questions to check before appearing for a hibernate related interview. This set contains basic questions to brainstroming one. A great compilation.

http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php