-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: How to annotate recursive mapping in hibernate search?
PostPosted: Fri Oct 29, 2010 7:16 pm 
Newbie

Joined: Fri Jun 11, 2010 3:00 am
Posts: 14
I am unable to figure out how to add annotations in case of same class is used as parent and child entity. Here is example

@Indexed
public class Space{

@DocumentId(name = "spaceId")
private Long id;

@Field(name="spaceName", index = Index.TOKENIZED, store = Store.NO)
private String name;

@Field(name = "spacePermissions", index = Index.TOKENIZED, store = Store.NO)
private String permissions;


private Space parent;

private Set<Space> folders;
}

I have also configured 6 listeners for insert/update/delete (also for collections) and flush events.

I tried several combinations by having @ContainedIn and @IndexedEmbedded on both parent and folders. It generates indices properly on insert and delete of a folder. But on update a folder, it is not generating indices with updated folder/space name;

My search is unable to find the updated folder. What am I missing here?


Top
 Profile  
 
 Post subject: Re: How to annotate recursive mapping in hibernate search?
PostPosted: Sat Oct 30, 2010 8:44 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
interesting, this seems an issue with your specific domain model - I had a similar use case working so I'm interested in all details. Could you provide a testcase highlighting the problem? in case please open a JIRA issue and attach it there, I'll be glad to look at it.
thanks

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: How to annotate recursive mapping in hibernate search?
PostPosted: Wed Nov 03, 2010 7:31 pm 
Newbie

Joined: Fri Jun 11, 2010 3:00 am
Posts: 14
Hi Sanne,

Sorry for the late reply. I was trying to collect enough information whether an upgrade will work but it is not (A strange error).

Environment:
Hibernate Search 3.1.1
Hibernate 3.3.1

File List
Space.java
package com.fiesta.ws.portal.bean;

@Entity
@Indexed(index = "Space")
@Boost(value = PortalConstants.BOOST_SPACE)
public class Space extends BaseDAOBean implements Serializable, Cloneable {

private static final long serialVersionUID = 1L;

@DocumentId(name = "spaceId")
private Long id;

@Field(name = "spaceName", index = Index.TOKENIZED, store = Store.NO)
@Boost(value = PortalConstants.BOOST_TITLE)
private String name;

@Field(name = "spaceStatus", index = Index.UN_TOKENIZED, store = Store.NO)
private String status;

@ContainedIn
@OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
@Field(name = "spaceLastUpdatedDate", index = Index.UN_TOKENIZED, store = Store.NO)
@DateBridge(resolution = Resolution.MILLISECOND)
private Date updatedAt;

@ContainedIn
@OneToMany(mappedBy = "spaceLastUpdatedDate", cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
@IndexedEmbedded(depth = 1, prefix = "folder_")
private Space parent;

@Field(name = "spaceType", index = Index.UN_TOKENIZED, store = Store.NO)
private String type;

@ContainedIn
@OneToMany(mappedBy = "spaceLastUpdatedDate", cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
@IndexedEmbedded(depth = 1, prefix = "folder_")
@Boost(value = PortalConstants.BOOST_FOLDERS)
private Set<Space> folders;
}

Space.hbm.xml
<hibernate-mapping>
<class name="com.fiesta.ws.portal.bean.Space" table="space">
<id name="id" type="java.lang.Long">
<column name="id" />
<generator class="identity" />
</id>
<property name="name" type="string">
<column name="name" length="255"/>
</property>
<property name="description" type="string">
<column name="description" length="1024"/>
</property>
<property name="createdAt" type="java.util.Date">
<column name="created_at" />
</property>
<property name="updatedAt" type="java.util.Date">
<column name="updated_at" />
</property>
<property name="status" type="string">
<column name="status" length="1" />
</property>
<property name="parentId" type="java.lang.Long" update="false" insert="false">
<column name="parent_id" />
</property>
<many-to-one name="parent" class="com.fiesta.ws.portal.bean.Space" lazy="proxy">
<column name="parent_id" />
</many-to-one>
<property name="type" type="string">
<column name="type"/>
</property>
<many-to-one name="createdBy" class="com.fiesta.ws.portal.bean.User" lazy="proxy">
<column name="creator_id" />
</many-to-one>

<set name="folders" inverse="true" lazy="true" fetch="subselect" where="type = 'F'">
<key>
<column name="parent_id" />
</key>
<one-to-many class="com.fiesta.ws.portal.bean.Space" />
</set>
</class>
</hibernate-mapping>

SpaceAction.java
Space folder = spaceDao.getSpaceById(folderId);
folder.setName(folderName);
folder.setUpdatedAt(new Date(System.currentTimeMillis()));
Space parent = folder.getParent();
log.info("Updating folder...");
parent.getFolders().add(folder);
parent.setUpdateAt(new Date(System.currentTimeMillis()));
spaceDao.update(parent);

Please let me know if you need further information. It worked well when eager loading of folders were used, but we turned lazy="proxy"/lazy="true" for performance reasons. After the change, when we edit folder name it is not updating indices.

NOTE: I am seeing these logs.

[DEBUG] 04 Nov 2010 16:11:24,129 [TP-Processor8] [org.hibernate.search.backend.impl.EventSourceTransactionContext.getIndexWorkFlushEventListener():84] : No FullTextIndexEventListener was registered
[DEBUG] 04 Nov 2010 16:11:24,129 [TP-Processor8] [org.hibernate.search.backend.impl.EventSourceTransactionContext.getIndexWorkFlushEventListener():84] : No FullTextIndexEventListener was registered
[DEBUG] 04 Nov 2010 16:11:24,211 [pool-1-thread-1] [org.hibernate.search.backend.impl.lucene.PerDPQueueProcessor.useWriterOnly():154] : Skipping usage of an IndexReader for updates
[DEBUG] 04 Nov 2010 16:11:24,211 [pool-1-thread-1] [org.hibernate.search.backend.impl.lucene.PerDPQueueProcessor.performWriterWorks():103] : Opening an IndexWriter for update


Top
 Profile  
 
 Post subject: Re: How to annotate recursive mapping in hibernate search?
PostPosted: Sat Nov 06, 2010 11:02 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Environment:
Hibernate Search 3.1.1
Hibernate 3.3.1

Hi, are you "upgrading" to these? I'd recommend you to try the latest Hibernate Search 3.3 beta, or at least the 3.2.1 stable.

What is the error you get?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: How to annotate recursive mapping in hibernate search?
PostPosted: Tue Nov 16, 2010 7:34 pm 
Newbie

Joined: Fri Jun 11, 2010 3:00 am
Posts: 14
Thanks Sanne.

I tried to upgrade to hibernate-search.3.2.1.GA, hibernate.3.5.4.Final with lucene-2.9.3.

Is something changed for depth attribute? Looking at stack trace, it looks like it is getting into infinite loop w/o respecting depth. I may be wrong, but just a thought.

{noformat}
[ERROR] 16 Nov 2010 15:26:39,986 [TP-Processor7] [org.hibernate.transaction.JDBCTransaction.notifyLocalSynchsBeforeTransactionCompletion():277] : exception calling user Synchronization
java.lang.StackOverflowError
at java.text.DecimalFormat.getPositivePrefixFieldPositions(DecimalFormat.java:1657)
at java.text.DecimalFormat.subformat(DecimalFormat.java:885)
at java.text.DecimalFormat.format(DecimalFormat.java:674)
at java.text.DecimalFormat.format(DecimalFormat.java:608)
at java.text.SimpleDateFormat.zeroPaddingNumber(SimpleDateFormat.java:1203)
at java.text.SimpleDateFormat.subFormat(SimpleDateFormat.java:1142)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:899)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:869)
at java.text.DateFormat.format(DateFormat.java:316)
at org.apache.lucene.document.DateTools.timeToString(DateTools.java:119)
at org.apache.lucene.document.DateTools.dateToString(DateTools.java:90)
at org.hibernate.search.bridge.builtin.DateBridge.objectToString(DateBridge.java:85)
at org.hibernate.search.bridge.String2FieldBridgeAdaptor.set(String2FieldBridgeAdaptor.java:42)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:440)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:484)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:471)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:414)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:364)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:348)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkForEmbeddedValue(DocumentBuilderContainedEntity.java:738)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:721)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:676)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:717)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:671)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:624)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:359)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkForEmbeddedValue(DocumentBuilderContainedEntity.java:738)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:721)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:676)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:717)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:671)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:624)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:359)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkForEmbeddedValue(DocumentBuilderContainedEntity.java:738)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:721)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:676)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:717)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:671)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:624)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:359)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkForEmbeddedValue(DocumentBuilderContainedEntity.java:738)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:721)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:676)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:717)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:671)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:624)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:359)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkForEmbeddedValue(DocumentBuilderContainedEntity.java:738)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:721)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:676)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:717)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:671)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:624)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:359)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkForEmbeddedValue(DocumentBuilderContainedEntity.java:738)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:721)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:676)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:717)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:671)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:624)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:359)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkForEmbeddedValue(DocumentBuilderContainedEntity.java:738)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:721)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:676)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:717)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:671)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:624)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:359)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkForEmbeddedValue(DocumentBuilderContainedEntity.java:738)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:721)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:676)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:717)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:671)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:624)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:359)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkForEmbeddedValue(DocumentBuilderContainedEntity.java:738)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:721)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:676)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:717)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedInInstances(DocumentBuilderContainedEntity.java:671)
at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:624)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:359)

{noformat}


Top
 Profile  
 
 Post subject: Re: How to annotate recursive mapping in hibernate search?
PostPosted: Tue Dec 21, 2010 11:41 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, sorry I forgot about this post. It would be nice if you could try out version 3.3.0.Final, as we basically rewrote the engine taking care of ContainedIn and IndexedEmbedded; we did it for performance reasons, not sure if it affects your case.
If it doesn't fix your issue, could you please open an issue on JIRA so that we don't forget this? A testcase is appreciated.
thanks

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: How to annotate recursive mapping in hibernate search?
PostPosted: Thu May 19, 2011 6:30 am 
Newbie

Joined: Fri Jun 11, 2010 3:00 am
Posts: 14
Thanks Sanne. I have been working on some other stuff but definitely, I would check and do and log in JIRA


Top
 Profile  
 
 Post subject: Re: How to annotate recursive mapping in hibernate search?
PostPosted: Thu May 19, 2011 6:45 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, welcome back. well at this point you might want to check 3.4.0.Final first, it got even better about graph optimizations.

there's still one open case in the area:
http://opensource.atlassian.com/project ... SEARCH-638

we had to move that to version 4 as it implies some API changes and we don't like breaking that in minor versions.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.