For the following mapping:
Code:
@Entity
@Table(name = "FILTER_ENTITIES")
@FilterDef(name = "theFilter", parameters = @ParamDef(name = "theFilter", type = "integer"))
@Filter(name = "theFilter", condition = "theFilter = :theFilter")
public class FilterEntity {
private Integer id;
private Integer thefilter;
private List<Integer> theValues;
public FilterEntity() {
}
public FilterEntity(Integer thefilter) {
this.thefilter = thefilter;
}
@Id
@GeneratedValue
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getThefilter() {
return thefilter;
}
public void setThefilter(Integer thefilter) {
this.thefilter = thefilter;
}
@CollectionOfElements(fetch = FetchType.EAGER)
@org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
@JoinTable(name = "FILTER_ENTITIES_THEVALUES")
public List<Integer> getTheValues() {
return theValues;
}
public void setTheValues(List<Integer> theValues) {
this.theValues = theValues;
}
}
, this query:
Code:
session.enableFilter("theFilter").setParameter("theFilter", 1);
List<FilterEntity> filterEntities = session.createQuery("from " + FilterEntity.class.getName()).list();
, will fail with:
Code:
org.hibernate.exception.GenericJDBCException: could not load collection by subselect: [masinatii4.hibernatefilters.FilterEntity.theValues#<2, 1>]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.loadCollectionSubselect(Loader.java:2097)
at org.hibernate.loader.collection.SubselectCollectionLoader.initialize(SubselectCollectionLoader.java:81)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:587)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1744)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:476)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:867)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:264)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
Caused by: com.jnetdirect.jsql.g: Value not set for parameter number 1
at com.jnetdirect.jsql.g.a(Unknown Source)
at com.jnetdirect.jsql.JSQLConnection.buildParamTypeDefinitions(Unknown Source)
at com.jnetdirect.jsql.JSQLConnection.prePrepare(Unknown Source)
at com.jnetdirect.jsql.JSQLConnection.getPreparedStatementHandle(Unknown Source)
at com.jnetdirect.jsql.af.executeQuery(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.loadCollectionSubselect(Loader.java:2091)
... 45 more
It was working in 3.3.1. Anything additional that I need to configure or is it an issue in 3.3.2?
Thanks,
Adrian Miron