Hi All,
I want to perform manual indexing for a view. I am using JPA and FullTextEntityManager.I am using CDI for injecting the EntityManager. The entity manager is a JTA Entity manager. My problem is that it is not indexing the new Entity. It is not throwing any exception/error either. I think the problem lies with committing the change in the index. Although CDI commits after the transaction so technically it should work but its not.
Please Help.
Thanks in advance,
Code:
@Inject
EntityManager entityManager;
public void startIndexer(RetailCustomerDetail retailCustomerDetails,
List<CustomerIdentityDetail> customerIdentityDetails) {
FullTextEntityManager fullTextEntityManager = Search
.getFullTextEntityManager(entityManager);
try {
for (CustomerIdentityDetail customerIdentityDetail : customerIdentityDetails) {
Long id = Long.valueOf(customerIdentityDetail.getCompositePK()
.getId());
Query query = entityManager
.createNamedQuery(CustomerSearch.FIND_BY_ID);
query.setParameter(1, id);
List<CustomerSearch> customerSearchDetails = query
.getResultList();
// important part
for (CustomerSearch customerSearch : customerSearchDetails) {
fullTextEntityManager.index(customerSearch);
}
}
}