[hibernate-issues] [Hibernate-JIRA] Created: (HSEARCH-939) Can not manually update index for IndexedEmbedded changes

Jan Snelders (JIRA) noreply at atlassian.com
Wed Oct 5 07:38:22 EDT 2011


Can not manually update index for IndexedEmbedded changes
---------------------------------------------------------

                 Key: HSEARCH-939
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-939
             Project: Hibernate Search
          Issue Type: Bug
    Affects Versions: 3.4.1.Final
         Environment: Windows 7 64bit, Hibernate Search 3.4.1, Hibernate Core as bundled with JBoss 6.1 Final, Java 6u27, MySQL  5.5.16
            Reporter: Jan Snelders
         Attachments: testdb-dump.sql, TestEclipseProject.zip

I need to manually update the index but run into some trouble when updating @IndexedEmbedded objects.

In my domain I have Relations entities which can have multiple Addresses. The OneToMany link from Relation to Address is annotated with @IndexedEmbedded and the ManyToOne from Address to Relation annotated with @ContainedIn.

Once an Address is updated (address changes from 'AStreet' to 'BStreet') I update the index as follows:

Code:
Transaction tx = fullTextSession.beginTransaction();
Object address = fullTextSession.load(RelationAddress.class, 1);
fullTextSession.index(address);
tx.commit();


However I'm not able to find the updated relation when searching for 'BStreet' (I'm searching for the Relation, not the Address)

This all does work when I update the complete corresponding Relation instead of only the Address but that shouldn't be needed; that's what the @ContainedIn/@IndexedEmbedded annotations are for.

Attached you will find a MySQL database dump and an Eclipse project containing the annotated persistence classes Relation and RelationAddress. These is a third persistence class Member which can be ignored.
The project include a small program TestTools which demonstrates the problem. Before running this program you will need to import the database dump into a MySQL server and alter the db connection settings in hibernate.cfg.xml and set the hibernate.search.default.indexBase parameter to a valid path.

The output of the program is:
------------------------------
Updating address (id: 1) to value: 'AStreet' (through sql)
New full index created
Searching for Relation by address value 'AStreet'
	Found results: 1 (1 expected)
Updating address (id: 1) to value: 'BStreet' (through sql)
About to update the index for id: 1 (class: class com.trentt.persistence.RelationAddress)
	Update done. Performing commit()...
Searching for Relation by address value 'AStreet'
	Found results: 1 (0 expected)
Searching for Relation by address value 'BStreet'
	Found results: 0 (1 expected)
About to update the index for id: 1 (class: class com.trentt.persistence.Relation)
	Update done. Performing commit()...
Searching for Relation by address value 'AStreet'
	Found results: 0 (0 expected)
Searching for Relation by address value 'BStreet'
	Found results: 1 (1 expected)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list