Hey guys,
I just got the query to work. I found a little help from another post. : )
http://forum.hibernate.org/viewtopic.ph ... t=load+max
Here is what the code looked like in the end for anyone else that runs into this problem:
Query query = session.createQuery("from PnPrscp300 p where p.mpiKey = :prescriptionKey and p.version = (select max(q.version) from PnPrscp300 q where q.mpiKey = p.mpiKey)");
query.setString("prescriptionKey", prescriptionKey);
List results = query.list();
and the .hbm.xml looks like this:
<id
name="mpiKey"
type="java.lang.String"
column="MPI_KEY"
length="16"
>
<generator class="identity" />
</id>
<property name="version"
column="VERSION"
type="java.sql.Timestamp"
length="26"
/>
I still would like to have someone answer the other questions from my previous post though just for personal interest. ie. why does the class level where clause not get added on a load()? and is this the only way to to solve the problem or can the primary key on a load be dynamic?
Thanks.