These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Release 3.3.2 - FetchMode.SUBSELECT not working with filters
PostPosted: Tue Jul 14, 2009 8:24 am 
Newbie

Joined: Mon Sep 22, 2008 5:32 am
Posts: 4
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.