-->
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.  [ 2 posts ] 
Author Message
 Post subject: Expression.like do not work
PostPosted: Fri Aug 26, 2005 10:29 pm 
Newbie

Joined: Fri Aug 26, 2005 9:32 pm
Posts: 1
Hi friends,

I try to use a criteria whit Expression.like and do not work. Someone can help whit that? Thanks.

Hibernate version: 2.1.8
Database: SQL Server 2000
Database Driver: sun.jdbc.odbc.JdbcOdbcDriver
Netbeans with Tomcat bundle: 4.1 / 5.5.7

Here is my code:

Code:
    //Create session
    HibernateBusinessObject hbo = new HibernateBusinessObject();

    List list1 = hbo.getSession().createCriteria(Author.class).add([color=red]Expression.like[/color]("au_lname", s1, MatchMode.ANYWHERE)).list();

    or

    //s1 is a String parameter of method
    List list1;
    Criteria criteira1 = hbo.getSession().createCriteria(Author.class);
    criteira1.add([color=red]Expression.like[/color]("au_lname", "%" + s1 + "%"));
    criteira1.setMaxResults(10);
    list1 = criteira1.list();   

    //Destroy session
    hbo.finalize();

    return list1;

_________________
--
Francisco Melo
Rio - RJ - Brazil


Top
 Profile  
 
 Post subject: guess
PostPosted: Sat Aug 27, 2005 11:05 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Just guessing: your object does not have property 'au_lname', that is the name of the column.
In the criteria we should use object property name, that means that if the Author class has lastName property (getLastName()/setLastName( String v)) then criteria looks like this:
criteira1.add(Expression.like("lastName", "%" + s1 + "%"));

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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