-->
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.  [ 4 posts ] 
Author Message
 Post subject: ClassCastException while indexing database
PostPosted: Sat Nov 30, 2013 11:08 am 
Newbie

Joined: Sat Nov 30, 2013 10:51 am
Posts: 3
Hi Community,

I have following problem:

For my application I have an EMF-Model (which cannot be changed). To create a Hibernate database I'm using Teneo. The creation of the Hibernate database is working quite well. Now I created the Search-Mapping for the classes to index via Programmatic API, looking like this (only the important part of the Factory):

Code:
SearchMapping searchMapping = new SearchMapping();
      
      searchMapping.entity(Items.impl.PersonImpl.class).indexed()
      .property("ident", ElementType.METHOD).documentId()
      .property("firstname", ElementType.METHOD).field()
      .property("lastname", ElementType.METHOD).field()
      .property("birthday", ElementType.METHOD).field()
      .property("address", ElementType.METHOD).containedIn()
      .property("email", ElementType.METHOD).containedIn()
      
      
      .entity(Items.impl.AddressImpl.class).indexed()
      .property("ident", ElementType.METHOD).documentId()
      .property("street", ElementType.METHOD).field()
      .property("number", ElementType.METHOD).field()
      .property("postalCode", ElementType.METHOD).field()
      .property("city", ElementType.METHOD).field()
      
      .entity(Items.impl.EMailImpl.class).indexed()
      .property("ident", ElementType.METHOD).documentId()
      .property("address", ElementType.METHOD).field()
      .property("tag", ElementType.METHOD).field();

Important to know is, that the attribute "ident" of each entity is of type String.

When I start indexing the data from the database I get some errors like this:

Code:
ERROR: HSEARCH000058: HSEARCH000116: Unexpected error during MassIndexer operation
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
   at org.hibernate.type.descriptor.java.StringTypeDescriptor.unwrap(StringTypeDescriptor.java:39)
   at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$1.doBind(VarcharTypeDescriptor.java:57)
   at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:93)
   at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:280)
   at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:275)
   at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1969)
   at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1940)
   at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1875)
   at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1836)
   at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1816)
   at org.hibernate.loader.Loader.doQuery(Loader.java:900)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342)
   at org.hibernate.loader.Loader.doList(Loader.java:2526)
   at org.hibernate.loader.Loader.doList(Loader.java:2512)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2342)
   at org.hibernate.loader.Loader.list(Loader.java:2337)
   at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:124)
   at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1662)
   at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)
   at org.hibernate.search.batchindexing.impl.IdentifierConsumerEntityProducer.loadList(IdentifierConsumerEntityProducer.java:152)
   at org.hibernate.search.batchindexing.impl.IdentifierConsumerEntityProducer.loadAllFromQueue(IdentifierConsumerEntityProducer.java:118)
   at org.hibernate.search.batchindexing.impl.IdentifierConsumerEntityProducer.run(IdentifierConsumerEntityProducer.java:95)
   at org.hibernate.search.batchindexing.impl.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:117)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)



I thought it should be due to the String-Type of the "ident" attribute and tried a TwoWayStringBridge without any success.


Google did not bring an answer to me, does anyone know how to solve this?



Kind regards,


Steven Künzel


Top
 Profile  
 
 Post subject: Re: ClassCastException while indexing database
PostPosted: Tue Dec 03, 2013 8:37 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi Steven,
could you post the source of the entity as well? I'd need to try reproducing this locally.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: ClassCastException while indexing database
PostPosted: Thu Dec 05, 2013 1:18 pm 
Newbie

Joined: Sat Nov 30, 2013 10:51 am
Posts: 3
Hi,

I just found a possible solution:

I simply had to change the id generated by Hibernate from type long to java.lang.String and choose an appropriate generator, like uuid:

Code:
<id type="long" name="ident" column="`ident`" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler">
   <meta attribute="syntheticId" inherit="false">true</meta>
   <generator class="native"/>
</id>


to

Code:
<id type="java.lang.String" name="ident" column="`ident`" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler">
   <meta attribute="syntheticId" inherit="false">true</meta>
   <generator class="uuid"/>
</id>




Regards,


Steven Künzel


Top
 Profile  
 
 Post subject: Re: ClassCastException while indexing database
PostPosted: Thu Dec 05, 2013 2:07 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi Steven,
I agree that could be a good workaround, but if you could share some more details of your entities we could fix the problem. Always better, and it would allow you to have a choice on how to map.
Could you post the source code of your entity? Or even better a simplified version which has only the properties needed to trigger the problem?

_________________
Sanne
http://in.relation.to/


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

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.