[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-124) Double lucene document created when inserting entities (@IndexEmbedded)
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Tue Oct 30 16:44:39 EDT 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28637 ]
Emmanuel Bernard commented on HSEARCH-124:
------------------------------------------
If you can post the main class maybe I could see something. Also try to peel off the dependencies one by one (Spring etc etc) until you stop having the issue.
The way the test is committed, you won't see the indexes through Luke because it's an in memory Directory. But if you add this code to the test case, you will be able to see them
protected void configure(org.hibernate.cfg.Configuration cfg) {
super.configure( cfg );
File sub = getBaseIndexDir();
cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );
cfg.setProperty( "hibernate.search.default.directory_provider", FSDirectoryProvider.class.getName() );
}
protected void setUp() throws Exception {
File sub = getBaseIndexDir();
sub.mkdir();
File[] files = sub.listFiles();
for (File file : files) {
if ( file.isDirectory() ) {
delete( file );
}
}
//super.setUp(); //we need a fresh session factory each time for index set up
buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
}
private File getBaseIndexDir() {
File current = new File( "." );
File sub = new File( current, "indextemp" );
return sub;
}
protected void tearDown() throws Exception {
super.tearDown();
File sub = getBaseIndexDir();
delete( sub );
}
private void delete(File sub) {
if ( sub.isDirectory() ) {
for ( File file : sub.listFiles() ) {
delete( file );
}
sub.delete();
}
else {
sub.delete();
}
}
> Double lucene document created when inserting entities (@IndexEmbedded)
> -----------------------------------------------------------------------
>
> Key: HSEARCH-124
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-124
> Project: Hibernate Search
> Issue Type: Bug
> Affects Versions: 3.0.0.cr1
> Environment: Hibernate version: 3.2.5.ga
> Database platform: MySQL
> OS: Mac OS 10.4.10
> Spring Framework 2.0
> Reporter: Amin Mohammed-Coleman
> Fix For: 3.0.1
>
> Attachments: phone-app.zip
>
>
> When inserting an entity using hibernate, double lucene documents are created for entities associated with the original entity. Please refer to :
> http://forum.hibernate.org/viewtopic.php?t=980102
> For example the below code used to populate/create a Contact entity produces two lucene documents for Address and Phone entities. The database has only entry for the Address and Phone.
> [code]
> Address address = new Address();
> address.setAddress1("TEST1");
> address.setAddress2("N/A");
> address.setTown("TEST TOWN");
> address.setCounty("TEST COUNTY");
> address.setCountry("UK");
> address.setPostcode("XXXXXXX");
> address.setActive(true);
> address.setCreatedOn(new Date());
> address.setLastUpdatedOn(new Date());
> Phone phone = new Phone();
> phone.setNumber("01273234122");
> phone.setType("HOME");
> phone.setCreatedOn(new Date());
> phone.setLastUpdatedOn(new Date());
> PersonalContact contact = new PersonalContact();
> contact.setFirstname("Amin");
> contact.setSurname("Mohammed-Coleman");
> contact.setEmail("address at hotmail.com");
> contact.setDateOfBirth(new Date());
> contact.setNotifyBirthDay(false);
> contact.setCreatedOn(new Date());
> contact.setLastUpdatedOn(new Date());
> contact.setNotes("TEST");
> contact.addAddressToContact(address);
> contact.addPhoneToContact(phone);
> ApplicationContext appCtx = new ClassPathXmlApplicationContext(new String[]{"/spring/context-dao.xml"});
> ContactDao contactDao = (ContactDao)appCtx.getBean("contactDao");
> contactDao.createContact(contact);
> List<Contact> contacts = contactDao.search("address at hotmail.com");
> System.out.println("contacts = " + contacts);
> [/code]
> Please find attached the entities I am using. I am not sure if there is enough information but the post provides all the information.
> Thanks
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list