I have the following table:
create table "product"
(
"uid" int8 not null,
"name" text not null unique,
"description" text
)
The uid is the id in the mapping file. But I'd like to be able to retrieve a row based on the name. Doing
Code:
Product prod = (Product) session.get(Product.class, name);
does not work, as the id is defined as Long, and hibernate is trying to cast it to a Long.
Here's my mapping:
Code:
<class name="com.mydomain.hb.Product" table="PRODUCT">
<id name="id" column="uid" type="long">
<generator class="increment"/>
</id>
<property name="name" column="name" update="false" not-null="true" unique="true"/>
<property name="description" column="description"/>
</class>
How can I retrieve a row using a name, just like I do with the id?
thnx