Hello
when I try to use a StringBridge in my project I see that the objectToString(Object obj) method is being called at least twice. One time with the Object which will be mapped to a String, and a second time with the resulting String, which leads to a ClassCastException.
Code:
public class SchluessellisteBridge implements StringBridge {
@Override
public String objectToString(Object obj) {
if (obj == null) {
return "";
}
Schluesselliste schluesselliste = (Schluesselliste) obj;
return schluesselliste.getLangname();
}
}
Code:
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "rv_entscheidungArt_id")
@Field
@FieldBridge(impl = SchluessellisteBridge.class)
protected Rechtsvorgang entscheidungArt;
Even when I use the @DateBridge I get this behavior
Code:
@Field(analyze = Analyze.NO)
@DateBridge(resolution = Resolution.DAY)
@Temporal(TemporalType.DATE)
Did I misunderstand the purpose of StringBridge????
I am using Hibernate Search 5.3 with Hibernate 4.3
Code:
<property name="hibernate.search.default.directory_provider"
value="filesystem" />
<property name="hibernate.search.default.indexBase" value="/var/lucene/indexes" />
My entities are JPA Entities. For searching I use the Hibernate API like
Code:
List<Gesamtentscheidung> gesamtentscheidungen = null;
EntityManager em = PersistenceService.getInstance().getEntityManagerFactory().createEntityManager();
Session session = em.unwrap(Session.class);
FullTextSession fullTextSession = Search.getFullTextSession(session);
fullTextSession.beginTransaction();
QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(Gesamtentscheidung.class).get();
org.apache.lucene.search.Query luceneQuery = queryBuilder
.keyword()
.onFields("betreff", "tatbestaende.aktenzeichen", "entscheidungArt")
.matching(searchString)
.createQuery();
org.hibernate.Query hibernateQuery = fullTextSession.createFullTextQuery(luceneQuery, Gesamtentscheidung.class);
gesamtentscheidungen = hibernateQuery.list();
fullTextSession.getTransaction().commit();
em.close();
return gesamtentscheidungen;