Hi,
I have an issue with automatic indexing failing. It seems to be related to the use of transactions. I use Spring 2.5.6, Hibernate 3.3.1 and Hibernate Search 3.1.0 with annotations.
My transaction setup applies transaction automatically at the service level like so.
Code:
Applicationcontext-service.xml
<aop:config>
<aop:advisor id="userManagerTx" advice-ref="userManagerTxAdvice" pointcut="execution(* *..service.UserManager.*(..))" order="0"/>
<aop:advisor id="userManagerSecurity" advice-ref="userSecurityAdvice" pointcut="execution(* *..service.UserManager.saveUser(..))" order="1"/>
<aop:advisor id="managerTx" advice-ref="txAdvice" pointcut="execution(* *..service.*Manager.*(..))" order="2"/>
</aop:config>
persistence.xml
<property name="hibernate.search.default.directory_provider"
value="org.hibernate.search.store.FSDirectoryProvider" />
<property name="hibernate.bytecode.provider"
value="javaassist" />
<property name="hibernate.search.autoregister_listeners"
value="true" />
<property name="hibernate.search.default.batch.merge_factor" value="1"/>
<property name="hibernate.search.default.indexBase"
value="d:/Java/Projects/indexes" />
<property name="hibernate.search.autoregister_listeners" value="true"/>
Offer is a class I'm trying to index with child classes saved as joined subclasses
Code:
@Entity
@Table(name = "Offers")
@Inheritance(strategy = InheritanceType.JOINED)
//@DiscriminatorValue(value = "OFFER")
@Indexed
@FullTextFilterDefs( {
@FullTextFilterDef(name = "offerTerms", impl = OfferFilterFactory.class),
@FullTextFilterDef(name = "validUntil", impl = RangeFilterFactory.class) })
public class Offer implements IOffer, Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "offerID", updatable = false, insertable = false)
@DocumentId
public Long getId() {
return id;
}
@Column
@Field(index = Index.TOKENIZED, store = Store.YES)
public String getTitle() {
return title;
}
etc
}
In the following cases, when I save an object, the index is not automatically updated. Nor is it updated if I explicitly index the object.
Code:
**DAO**
Offer off = super.save(offer);
return off;
**DAO**
Offer off = super.save(offer);
FullTextSession fts = Search.getFullTextSession(this
.getSessionFactory().getCurrentSession());
if (offer.isActive() || offer.isValid()) {
fts.index(off);
} else {
fts.purge(Offer.class, offer.getId());
}
return off;
In the following case it is indexed properly.
Code:
Offer off = super.save(offer);
FullTextSession fts = Search.getFullTextSession(this
.getSessionFactory().getCurrentSession());
Transaction tx = fts.beginTransaction();
if (offer.isActive() || offer.isValid()) {
fts.index(off);
} else {
fts.purge(Offer.class, offer.getId());
}
tx.commit();
return off;
The difference being the explicit transaction demarcation. Now, I would expect an successful update based on the first case, since we are talking automatic indexing here.
Code:
Offer off = super.save(offer);
return off;
Any idea what I might be doing wrong?
Kind regards,
Marc
Kind regards,
Marc