Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: Hibernate 3
Mapping documents:
Code:
<class name="vo.sku.Sku" table="sku">
<id name="id" column="id" type="string" length="15">
<generator class="assigned"/>
</id>
<property name="title" column="title" type="string" length="150" not-null="true"/>
<property name="description" column="description" type="string"/>
<property name="picUrl" column="picUrl" length="150" type="string"/>
<property name="brand" column="brand" length="50" type="string"/>
<property name="model" column="model" length="50" type="string"/>
<property name="productType" column="productType" length="20" type="string"/>
<property name="supplyType" column="supplyType" length="1" type="string" not-null="true"/>
<property name="status" column="status" length="1" type="string" not-null="true"/>
</class>
Code between sessionFactory.openSession() and session.close():Code:
Sku sku = new Sku();
sku.setId("anId");
sku.setSupplyType(Sku.FromStock);
Example example = Example.create(sku).ignoreCase().enableLike(MatchMode.ANYWHERE);
Collection c = getSession().createCriteria(Sku.class).add(example).list();
Name and version of the database you are using:Mysql
The generated SQL (show_sql=true):Code:
select this_.id as id0_, this_.title as title1_0_, this_.description as descript3_1_0_, this_.picUrl as picUrl1_0_, this_.brand as brand1_0_, this_.model as model1_0_, this_.productType as productT7_1_0_, this_.supplyType as supplyType1_0_, this_.status as status1_0_ from sku this_ where (lower(this_.supplyType) like ?)
There's no exception raised, the sql simply doesnt consider the sku.id constraint.
but the id is searchable when i add ".add(Expression.eq("id", sku.getId())" into the criteria
why is that?