Hotware / Hibernate-Search-GenericJPA

Hibernate-Search with the JPA provider you want
http://hotware.github.io/Hibernate-Search-GenericJPA/
GNU Lesser General Public License v2.1
5 stars 3 forks source link

FIX JPAEventSource #9

Closed s4ke closed 9 years ago

s4ke commented 9 years ago

threadsafe queue to store all the data to be updated.

s4ke commented 9 years ago

the reason for this is that we can not reliably know in which order the events are being raised

s4ke commented 9 years ago

then make the JPAEventSource also the only way to interact with JPA events. (make the HSearchEventListener stuff default visible again)

s4ke commented 9 years ago

and maybe remove all the listenTo(...) logic from the HSearchEventListener to the JPAEventSource to then determine which eventconsumer wants what by giving them the listenTo(...) method

s4ke commented 9 years ago

annoyingly EclipseLink shouldn't trigger the events on em.flush() but when the transaction is commited...

s4ke commented 9 years ago

we have a way to make the index updates applied at commit time instead (if there is a transaction present) (for this we have to keep the changes or use hibernate-search's transaction mechanism for that)

s4ke commented 9 years ago

a version that would definitely work would look like this:

for every table that is index relevant we need a second table that holds all the id's of entites that need to be re-indexed. We poll from these tables every fixed amount of time and then reindex all the entities marked by the ids in those tables.

these tables have to be created via JPA by making an Entity class called Entity[Updates] annotated with @UpdatesFor({Entity.class, Entity2.class}) that uses the same ID class as the original Entity (for Bridge Table Entities we need all the IDs of the classes). These ID-Fields habe to be annotated with an annotation to mark them being the id for the given class (something along the lines of @IDFor(class = Entity.class, columnsInOriginal = {column}, columnsInUpdate={column])) so we can get the corresponding entity out of the table.

These tables are populated via triggers. These triggers can be dynamically generated by looking at the info in the @UpdatesFor annotation.