[jboss-user] [EJB 3.0] - Using SQL IN
monkeyden
do-not-reply at jboss.com
Fri Oct 20 12:12:09 EDT 2006
What is the proper way to do a query using SQL "IN"? The only reference I found is this: http://www.jofti.com/guide/ch3-1.html#title_3_1_8, which is complaining about the colon for the parameter.
unexpected token: : near line 1, column 54 [from com.xxxxx.entity.Listing where id IN :ids]
id is the primary key of Listing. My code is as follows:
@Entity
| @Name("listing")
| @Table(name = "LISTING")
| public class Listing implements java.io.Serializable {
|
| @Id
| @Column(name = "LISTING_ID", length = 22, nullable = false)
| public Long getId() {
| return this.id;
| }
| ...
| }
| List<Long> glids = new ArrayList<Long>();
|
| String queryStr = "from Listing where id IN :ids";
| Query query = em.createQuery(queryStr);
| query.setParameter("ids", glids);
| Object result = query.getResultList();
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979687#3979687
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979687
More information about the jboss-user
mailing list