-->
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.  [ 4 posts ] 
Author Message
 Post subject: Question about the criteria and many-to-one mapping
PostPosted: Tue Aug 17, 2004 5:53 am 
Newbie

Joined: Wed Jul 21, 2004 3:58 am
Posts: 17
Hi !
I've got a sale object wich is composed by a custommer. My mapping look like this :

Mapping documents:
<class name="SaleDTO" table="Sale">
<id name="id" type="long" unsaved-value="null">
<column name="Av_Id" sql-type="bigint" not-null="true"/>
<generator class="identity"/>
</id>
<property name="offer">
<column name="Off_Name" length="32" not-null="true"/>
</property>
<many-to-one name="custommer" />
<many-to-one name="employe" />
</class>
<class name="custommerDTO" table="Custommer">
<id name="id" type="long" unsaved-value="null">
<column name="Cl_Id" sql-type="bigint" not-null="true"/>
<generator class="identity"/>
</id>
<property name="name">
<column name="Cl_name" length="32" not-null="true"/>
</property>
</class>

So my question is : Is it possible to add to the saleobject a search criteria like custommer name ?
I have try crit.add(Expression.like("custommer.name", "john")); and it's not working.
Thank you in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 5:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
use createCriteria() or createAlias()


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 6:09 am 
Newbie

Joined: Wed Jul 21, 2004 3:58 am
Posts: 17
In fact I want to make a method wich is making searches in the sale table based on several criteria. All of this criteria are attributes of sales, except the custommer name. Can I add this criteria to the others ?
Here is a part of my method :

Criteria crit = session.createCriteria(SaleDTO.class);

//search on name
String name = dto.getname();
if (!((name == null) || (name.length() == 0))) {
log.warn("Crit


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 8:42 am 
Newbie

Joined: Wed Jul 21, 2004 3:58 am
Posts: 17
That's ok, I've found a solution.

But i've got another question : Is it possible to order the list of sales with the name of the custommer for example ?

Thx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.