-->
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: ClassCastException using sort=<ComparatorClass> for Tr
PostPosted: Wed Apr 05, 2006 9:33 am 
Newbie

Joined: Wed Apr 05, 2006 9:21 am
Posts: 1
I have the following as part of my definition of a FilterField:

Code:
  private Set details;
  private Comparator comparator = new FilterFieldDetailComparator();

  public FilterField() {
    details = new TreeSet(comparator);
  }


The relevant part of the hibernate mapping file I have shows:

Code:
       <set
            name="details"
            table="PROSPECT_FILTER_FIELD_DETAIL"
            lazy="false"
            cascade="all"            sort="com.genalytics.prospect.domain.FilterFieldDetailComparator"
        >
            <key
                column="PROSPECT_FILTER_FIELD_ID"
            >
            </key>
            <composite-element
                class="com.genalytics.prospect.domain.FilterFieldDetail"
            >
                  <parent
                       name="filterField"
                  />
                <property
                      name="value"
                      type="java.lang.String"
                      update="true"
                      insert="true"
                      column="VARIABLE_VALUE"
               />
            </composite-element>
        </set>

The comparator could be any comparator--even one that simply returns 1 and I get the exception below:

Full stack trace of any exception that occurs:
java.lang.ClassCastException: com.genalytics.prospect.domain.FilterFieldDetail
at java.util.TreeMap.compare(TreeMap.java:1093)
at java.util.TreeMap.put(TreeMap.java:465)
at java.util.TreeSet.add(TreeSet.java:210)
at java.util.AbstractCollection.addAll(AbstractCollection.java:318)
at java.util.TreeSet.addAll(TreeSet.java:258)
at org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:273
)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollection(Colle
ctionLoadContext.java:183)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(Coll
ectionLoadContext.java:268)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(Coll
ectionLoadContext.java:249)
at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:866)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.j
ava:853)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo
ader.java:223)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1916)
at org.hibernate.loader.collection.CollectionLoader.initialize(Collectio
nLoader.java:71)
at org.hibernate.persister.collection.AbstractCollectionPersister.initia
lize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onIn
itializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:
1593)
at org.hibernate.collection.AbstractPersistentCollection.forceInitializa
tion(AbstractPersistentCollection.java:454)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyColl
ections(StatefulPersistenceContext.java:791)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo
ader.java:228)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1916)
at org.hibernate.loader.collection.CollectionLoader.initialize(Collectio
nLoader.java:71)
at org.hibernate.persister.collection.AbstractCollectionPersister.initia
lize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onIn
itializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:
1593)
at org.hibernate.collection.AbstractPersistentCollection.initialize(Abst
ractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPe
rsistentCollection.java:86)
at org.hibernate.collection.AbstractPersistentCollection.readSize(Abstra
ctPersistentCollection.java:109)
at org.hibernate.collection.PersistentSet.size(PersistentSet.java:114)
at org.apache.jsp.views.list_005fedit_jsp._jspService(org.apache.jsp.vie
ws.list_005fedit_jsp:1242)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
14)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
ispatcher.java:574)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
patcher.java:499)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
.java:966)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
a:604)
at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:10
1)
at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:137)
at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:758
)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(Inser
tTag.java:890)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:460)

at org.apache.jsp.common.basic_005flayout_jsp._jspx_meth_tiles_get_3(org
.apache.jsp.common.basic_005flayout_jsp:252)
at org.apache.jsp.common.basic_005flayout_jsp._jspService(org.apache.jsp
.common.basic_005flayout_jsp:138)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
14)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(Applica
tionDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD
ispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis
patcher.java:301)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.
java:1056)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestP
rocessor.java:261)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(
TilesRequestProcessor.java:237)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(Ti
lesRequestProcessor.java:300)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:231)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:116
4)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at com.genalytics.prospect.struts.TransactionFilter.doFilter(Transaction
Filter.java:31)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
at java.lang.Thread.run(Thread.java:595)

Hibernate version: 3.0.5

Name and version of the database you are using: Oracle 10g


What am I doing wrong? Let me know if you need more information. Thanks a lot.


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.