-->
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: Query problem: binding a List to a named Parameter
PostPosted: Thu Jan 29, 2004 5:16 pm 
Newbie

Joined: Mon Dec 08, 2003 1:44 pm
Posts: 16
Location: Germany
Imagine the following class:

Code:
public class Cat {

    List kittens;
    String name;

    //getters and setters
}


Now the following java code:

Code:
kitten1 = new Cat();
kitten2 = new Cat();
parent = new Cat();
parent.setKittens(new ArrayList());
parent.getKittens().add(kitten1);
parent.getKittens().add(kitten2);

// somehow saving the parent with its kittens ...

...


Does the following query work? I got errors when trying to compare with a List.

Code:
...

Query q = session.createQuery("
    from Cat c where c.kittens = :kittens");
q.setParameter("kittens", parent.getKittens());
Cat result = q.list().get(0);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 5:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No, that wouldn't work ;)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2004 4:25 am 
Newbie

Joined: Mon Dec 08, 2003 1:44 pm
Posts: 16
Location: Germany
So... how can I solve this problem? I'd just like to check, if two lists are the same.


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.