English 中文(简体)
Best Practices for Building Where-In Clause in EclipseLink 1.1
原标题:

I m on a project using EclipseLink 1.1, and I have a query where the obvious thing for me to do is use a Where-In clause, like so:


      List<String> things = populateListOfThings(); 
      String queryString = " select s from Stuff s where s.thing in (:things) ";
      Query query = em.createQuery(queryString);
      query.setParameter("things", things);

This is, of course, a batch of fresh-brewed FAIL and at runtime will whine at me like this:

java.lang.IllegalArgumentException: You have attempted to set a value of type class java.util.ArrayList for parameter things with expected type of class java.lang.String from query string ....

Googling around indicates that EclipseLink 1.1 simply doesn t support dumping a list into a parameter like this; fair enough. How would people recommend working around this deficiency?

问题回答

暂无回答




相关问题
query must begin with SELECT or FROM: delete [delete

I am using JPA in addition to spring(3.0.0.M4). While deleting multiple records using query.executeUpdate() i am getting the following exception. org.springframework.web.util.NestedServletException: ...

Last update timestamp with JPA

I m playing around a bit with JPA(Eclipselink to be specific). The below entity have a timestamp that s supposed to reflect whenever that entity was last updated. What are the strategies for making ...

@IdClass with non primative @Id

I m trying to add a composite primary key to a class and having a bit of trouble. Here are the classes. class User { private long id; ... } class Token { private User user; private ...

Database not dropped in between unit test

Hello good people i came accross a weird behaviour in my test.I m using JPA hibernate annotation with spring. let say i have an Class MyObject and it s property email is marqued @Column(name="EMAIL", ...

Toplink trying to persist null object

I have an object "Instance" with another object "Course" inside. When trying to persist a new Instance object, I get the following error if Course is null: java.lang.IllegalStateException: During ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签