-->
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: search in a CollectionOfElements
PostPosted: Fri Jul 06, 2007 2:51 am 
Newbie

Joined: Thu May 24, 2007 8:28 am
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3

Name and version of the database you are using: Oracle9


i have an image-table and want to search for an Image with a certain keyword. Keywords are Strings collectet in a Set. how can i do this using .createCriteria?


Code:
   @CollectionOfElements
   public Set<String> getKeywords() {
      return keywords;
   }


just searching like:
Code:
criteria = session
      .createCriteria(Image.class,"i")
      .add(Restrictions.eq("i.keywords","uiae")

results in

xception in thread "AWT-EventQueue-0"
org.hibernate.exception.GenericJDBCException: could not execute query
at
...
Caused by: java.sql.SQLException: Fehlender IN- oder OUT-Parameter auf Index:: 2
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:190)[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 06, 2007 10:59 am 
Newbie

Joined: Mon Jul 02, 2007 2:12 pm
Posts: 18
Hi,

first ahve a look here: http://forum.hibernate.org/viewtopic.php?t=954121

One possible solution is to use sqlRestriction:

List<Image> found = s.createCriteria(Image.class, "i").add(Restrictions.sqlRestriction("id IN (SELECT image_id FROM imagekeywords WHERE element = 'Toll')"))
.list();

Otherwise create a POJO for keywords instead of java.lang.String.

-Thomas


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.