Field Joda Time in index
smoers Mar 20, 2014 8:16 AMHi all,
In my project, I use the package "Joda Time" to manipulate the dates.
I have problems to insert this object type in the index key.
If I not use a specific annotation, I receive this error : "Exception in thread "main" org.hibernate.search.SearchException: HSEARCH000135: Unable to guess FieldBridge for borndate in org.joda.time.DateTime"
I have try to use the annotation "@DateBridge(resolution=Resolution.DAY)", but I receive an error at the execution "Caused by: java.lang.ClassCastException: org.joda.time.DateTime cannot be cast to java.util.Date"
Can you help me ?
import java.io.Serializable; import java.util.Hashtable; import java.util.UUID; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.OneToMany; import org.hibernate.search.annotations.DateBridge; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.IndexedEmbedded; import org.hibernate.search.annotations.Resolution; import org.joda.time.DateTime; @Entity @Indexed public class AuthorInfinispan implements IAuthor,Serializable { @Id private UUID id; @Field private String lastname; @Field private String firstname; @Field private String authoralias; private IPhotoOrCover photo; @Field private String website; @Field private String biography; @Field private String comment; @Field @DateBridge(resolution=Resolution.DAY) private DateTime borndate; @Field @DateBridge(resolution=Resolution.DAY) private DateTime creationdate; @OneToMany(mappedBy="author") @IndexedEmbedded private Hashtable<UUID, ICycle> listcycle; public AuthorInfinispan(){ this.id = UUID.randomUUID(); this.creationdate = DateTime.now(); this.listcycle = new Hashtable<UUID, ICycle>(); } @Override public UUID getID() { return this.id; } @Override public void setLastName(String lastname) { this.lastname = lastname; } @Override public String getLastName() { return this.lastname; } @Override public void setFirstName(String firstname) { this.firstname = firstname; } @Override public String getFirstName() { return this.firstname; } @Override public void setAuthorAlias(String authoralias) { this.authoralias = authoralias; } @Override public String getAuthorAlias() { return this.authoralias; } @Override public void setPhoto(IPhotoOrCover photo) { this.photo = photo; } @Override public IPhotoOrCover getPhoto() { return this.photo; } @Override public void setWebSite(String website) { this.website = website; } @Override public String getWebSite() { return this.website; } @Override public void setBiography(String biography) { this.biography = biography; } @Override public String getBiography() { return this.biography; } @Override public void setComment(String comment) { this.comment = comment; } @Override public String getComment() { return this.comment; } @Override public void setBornDate(DateTime borndate) { this.borndate = borndate; } @Override public DateTime getBornDate() { return this.borndate; } @Override public void setCreationDate(DateTime creationdate) { this.creationdate = creationdate; } @Override public DateTime getCreationDate() { return this.creationdate; } @Override public void setListCycle(Hashtable listcycle) { this.listcycle = listcycle; } @Override public Hashtable<UUID, ICycle> getListCycle() { return this.listcycle; } }
Many thanks,
Serge