I have a simple scenario : My table config looks like this:
Code:
<class name="org.jvending.datastructure.CatalogProperty" table="catalog_property">
<composite-id name="pkey" class="org.jvending.datastructure.ParClientIdPk" >
<key-property name="parid" column="parid" />
<key-property name="clientbundleid" column="clientbundleid" />
<key-property name="id" column="id" />
</composite-id>
<property name="name" column="catalog_property_name" />
<property name="value" column="catalog_property_value" />
</class>
One Table CatalogProperty - 5 Columns, 3 form composite Key.
The following code works very fine, but I do not understand what is at List.get(0) ? Why 2 elements in the list I'll get one max(id) ?? (This is not the case for non aggregate functions - ref manual - chapter 11 getBlogAndAllItems method)
Code:
Query q = session.createQuery(
"select max(cp.pkey.id) " +
"from org.jvending.datastructure.CatalogProperty as cp " +
"where cp.pkey.parid = :name1 and cp.pkey.clientbundleid = :name2"
);
q.setString("name1", parid );
q.setString("name2", clientbundleid ) ;
List l = new ArrayList();
l = q.list() ;
if (l.size()==2)
in = (Integer) l.get(1);
I am using hibernate-2.1.2, mySql 4.0.17 -nt Database.
Thanks a lot for the response and your time.
Regards,
Rashmi