リストであるフィールドで Restrictions.in を使用するにはどうすればよいですか?
これが私のモデルです:
@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<Feature> features;
@JoinTable(name = "W_USER_GROUP", joinColumns = @JoinColumn(name = "GROUP_ID"), inverseJoinColumns = @JoinColumn(name = "USER_ID"), schema = "U_FRONTEND")
@ManyToMany
private List<User> 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
}
いくつかの機能を持つグループのみを取得しようとしています:
Criteria criteria = session.createCriteria(UserGroup.class);
criteria.addOrder(new Sort(Order.ASC, "name").getOrder());
criteria.add(Restrictions.not(Restrictions.in("features",
FeatureUtils.getInvalids())));
しかし、これはエラーを返します:
原因: 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 org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) の .SqlExceptionHelper.convert(SqlExceptionHelper.java:125) org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler) org.hibernate.loader.Loader.getResultSet(Loader. java:1926) org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1727) で org.hibernate.loader.Loader.doQuery(Loader.java:852) org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:293) org.hibernate.loader.Loader.doList(Loader.java:2411) org .hibernate.loader.Loader.doList(Loader.java:2397) で org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2227) で org.hibernate.loader.Loader.list(Loader.java:2222) でorg.hibernate.internal.Criteria.CriteriaLoader.list(CriteriaLoader.java:122) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1621) at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java: 374) hamburgsud.frontend.dao.UserGroupDAO.list(UserGroupDAO.java:39) で hamburgsud.frontend.controller.UserController.form(UserController.java:38) で sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブ メソッド) で sun 。反射。NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) で sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) で java.lang.reflect.Method.invoke(Method.java:597) で br.com.caelum.vraptor .interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:61) ... 43 以上 原因: java.sql.SQLException: Missing IN or OUT parameter at index:: 1 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError. java:112) で oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) で oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681) で.java:3280) oracle.jdbc.driver.OraclePreparedStatement で。executeQuery(OraclePreparedStatement.java:3329) で com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76) で sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブ メソッド) で sun.reflect.NativeMethodAccessorImpl.invoke( NativeMethodAccessorImpl.java:39) で sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) で java.lang.reflect.Method.invoke(Method.java:597) で org.hibernate.engine.jdbc.internal.proxy .AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) ... 63 続きを読むNativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) で sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) で java.lang.reflect.Method.invoke(Method.java:597) で org.hibernate.engine.jdbc .internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) ... 63 詳細NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) で sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) で java.lang.reflect.Method.invoke(Method.java:597) で org.hibernate.engine.jdbc .internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) ... 63 詳細