-->
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.  [ 2 posts ] 
Author Message
 Post subject: hibernate search and joda time.
PostPosted: Thu Sep 11, 2008 10:16 am 
Regular
Regular

Joined: Tue Apr 01, 2008 5:39 pm
Posts: 61
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.3.0 GA
3.1.0 Beta1

Mapping documents:
Code:
public class SpecialEvent extends Event
{
    // ... bunch of other fields relating to special event
    @Field(index=Index.UN_TOKENIZED)
    @DateBridge(resolution=Resolution.DAY)
    @Column
    @Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
    private DateTime endDate;
}


Full stack trace of any exception that occurs:
Code:
<error message="org.joda.time.DateTime cannot be cast to java.util.Date" type="java.lang.ClassCastException">java.lang.ClassCastException: org.joda.time.DateTime cannot be cast to java.util.Date
   at org.hibernate.search.bridge.builtin.DateBridge.objectToString(DateBridge.java:63)
   at org.hibernate.search.bridge.String2FieldBridgeAdaptor.set(String2FieldBridgeAdaptor.java:21)
   at org.hibernate.search.engine.DocumentBuilder.buildDocumentFields(DocumentBuilder.java:645)
   at org.hibernate.search.engine.DocumentBuilder.getDocument(DocumentBuilder.java:629)
   at org.hibernate.search.engine.DocumentBuilder.addWorkToQueue(DocumentBuilder.java:531)
   at org.hibernate.search.engine.DocumentBuilder.processContainedInValue(DocumentBuilder.java:612)
   at org.hibernate.search.engine.DocumentBuilder.processContainedIn(DocumentBuilder.java:595)
   at org.hibernate.search.engine.DocumentBuilder.addWorkToQueue(DocumentBuilder.java:562)
   at org.hibernate.search.backend.impl.BatchedQueueingProcessor.processWorkByLayer(BatchedQueueingProcessor.java:141)
   at org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:125)


Top
 Profile  
 
 Post subject: hibernate search and joda time.
PostPosted: Thu Oct 16, 2008 5:15 pm 
Newbie

Joined: Thu Oct 16, 2008 4:33 pm
Posts: 1
Instead of using the DateBridge in your Field annotation, you need to write and reference a bridge that converts between Joda DateTime and String.

Since conversion between Joda DateTime objects and java.util.Date objects is pretty simple, it's not hard to write a class implementing the same interfaces as DateBridge (TwoWayStringBridge and ParameterizedBridge) and delegating most of the work to a DateBridge object.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.