Hi All,
I am using JPA and Hibernate Search.I have a non-materialised view which is mapped to an entity. I have indexed the fields however it is not indexing the entity even if I use manual indexing using Mass-Indexer. I read in Hibernate Search in action that as there are no CRUD operations Hibernate Events are not fired and hence it does not perform automatic indexing. Hence manual indexing is required. One solution I thought of is to write custom events which are fired when any CRUD is performed on the tables which compose the view. But I am not sure exactly how to implement this. Or are there any better options.
The indexing has be immediate, i.e immediately after insertion the record should be searchable.
The ER structure is Customer Detail is the base class which contains all the address details like country,state etc.Private Customer is a sub-class of Customer Details and contains details like first name ,last name ,mobile etc. And finally Customer Identification contains details like Passport details,driving licence details etc. It has a one to many relationship with Customer Detail table with one customer having many identity proofs.
Thanks a lot in advance ,
Info for Code: Following is the code for the entity mapped to the view. It's id is in the base entity. The ID is a composite key, for which I have written a field bridge.
Code:
@Entity
@Table(name = "CUSTOMER_SEARCH_V")
@Indexed
@NamedQueries({
@NamedQuery(name = "CustomerSearch.findAll", query = "SELECT c FROM CustomerSearch c"),
@NamedQuery(name = "CustomerSearch.findByCriteria", query = "SELECT c FROM CustomerSearch c WHERE UPPER(c.firstName) LIKE ?1 OR c.mobile LIKE ?1 OR c.customerUniqueNo LIKE ?1 OR c.idfNo LIKE ?1") })
public class CustomerSearch extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
public static final String FIND_BY_CRITERIA = "CustomerSearch.findByCriteria";
@Column(name = "CUSTOMER_UNIQUE_NO")
private String customerUniqueNo;
private String address1;
@Column(name = "FIRST_NAME")
@Field
private String firstName;
@Column(name = "LAST_NAME")
@Field
private String lastName;
@Column(name="MOBILE")
@Field
private String mobile;
....
(remaining part are getter setters etc)