Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Hibernate Restrictions.in with a List<enum>
    primarykey
    data
    text
    <p>How do I use Restrictions.in with an field that is a List?</p> <p>Here is my model:</p> <pre><code>@Entity @Table(name = "W_GROUP", schema = "U_FRONTEND") public class UserGroup { @Id @Column(name = "GROUP_ID") private Long id; @Column(name = "NAME", length = 100, nullable = false, unique = true) private String name; @ElementCollection(targetClass = Feature.class) @JoinTable(name = "W_FEATURE", joinColumns = @JoinColumn(name = "GROUP_ID", nullable = false), schema = "U_FRONTEND") @Column(name = "NAME", nullable = false, length = 50) @Enumerated(EnumType.STRING) private List&lt;Feature&gt; features; @JoinTable(name = "W_USER_GROUP", joinColumns = @JoinColumn(name = "GROUP_ID"), inverseJoinColumns = @JoinColumn(name = "USER_ID"), schema = "U_FRONTEND") @ManyToMany private List&lt;User&gt; users; @Column(name = "UPD_USER", nullable = false, length = 50) private String updUser; @Column(name = "UPD_DATE", nullable = false, columnDefinition = "date") private Calendar updDate; // Getters and setters } </code></pre> <p>I'm trying to get only the groups that have some Features:</p> <pre><code>Criteria criteria = session.createCriteria(UserGroup.class); criteria.addOrder(new Sort(Order.ASC, "name").getOrder()); criteria.add(Restrictions.not(Restrictions.in("features", FeatureUtils.getInvalids()))); </code></pre> <p>But this returns an error:</p> <blockquote> <p>Caused by: org.hibernate.exception.GenericJDBCException: Missing IN or OUT parameter at index:: 1 at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129) at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81) at $Proxy35.executeQuery(Unknown Source) at org.hibernate.loader.Loader.getResultSet(Loader.java:1926) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1727) at org.hibernate.loader.Loader.doQuery(Loader.java:852) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:293) at org.hibernate.loader.Loader.doList(Loader.java:2411) at org.hibernate.loader.Loader.doList(Loader.java:2397) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2227) at org.hibernate.loader.Loader.list(Loader.java:2222) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:122) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1621) at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374) at hamburgsud.frontend.dao.UserGroupDAO.list(UserGroupDAO.java:39) at hamburgsud.frontend.controller.UserController.form(UserController.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:61) ... 43 more Caused by: java.sql.SQLException: Missing IN or OUT parameter at index:: 1 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) ... 63 more</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload