-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Example cant search with id?
PostPosted: Fri Jul 15, 2005 10:10 pm 
Newbie

Joined: Mon Jul 12, 2004 2:52 am
Posts: 17
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?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 16, 2005 10:02 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
The reference manual says in chapter 16.6:

Quote:
Version properties, identifiers and associations are ignored.


HTH
Ernst


Top
 Profile  
 
 Post subject: Oh thx
PostPosted: Mon Jul 18, 2005 4:03 am 
Newbie

Joined: Mon Jul 12, 2004 2:52 am
Posts: 17
oops thx

I was refering to the book only ...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.