-->
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.  [ 1 post ] 
Author Message
 Post subject: 1-Many Association with Expression.in clause
PostPosted: Mon Sep 24, 2007 2:54 pm 
Newbie

Joined: Thu Aug 23, 2007 9:52 pm
Posts: 9
I have a simply query in existing system

select server.sid , group.gid from server , group
where server.sid = 10 and group.gid in (20.30)

But I can't get corresponding criteria api for this query. I wrote the following code to load data but it does not work. What code should be added to handle gid

Code:
//Code to load data
Criteria criteria = getSession().createCriteria(Server.class);
criteria.add(Expression.eq("sid", 10)); 
//I thought following will work but it does not
//Collection c = new Vector();
//c.add(20);       
//c.add(30);       
//criteria.add(Expression.in("serverGroupList", c));


I have write following code to represent system

Code:
public class Server implements Serializable {
   
    @Id @GeneratedValue
    @Column(name="SID")   
    private int serverID;

    @OneToMany 
    @JoinColumn(name="SID")
    private List<ServerGroup> serverGroupList;

}


public class ServerGroup implements Serializable {

    @Id @GeneratedValue
    @Column(name="GID")   
    private int groupid;
       
    @Column(name="SID")   
    private Integer serverId;

}


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

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.