-->
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.  [ 2 posts ] 
Author Message
 Post subject: ContainedIn Multiple Classes (Hibernate Search 5.1.1)
PostPosted: Thu Jul 16, 2015 5:00 pm 
Newbie

Joined: Thu Jul 16, 2015 4:29 pm
Posts: 3
Here is the issue.

I have classes A and B, each of which hold a reference to an object of class C. There is nothing in common between A & B other than the fact that they both contain a C.

I would like to have C @IndexEmbedded (OneToOne) in both A & B.... And this works fine as long as I want to manually update the indexes when C changes, but I would prefer to avoid that.

I only really need these one way associations in my domain, but it appears I need the inverse OneToMany association annotated with @ContainedIn to enable HS to handle the automatic index update. Is my only option to alter the data model and inject a superclass to hold the association to C and then have A and B extend it (thereby providing a superclass to reference in the inverse association)? If so, does that require using a table per class inheritance approach or can I get by with a @MappedSuperclass? This seems like it would be a common problem but I haven't found any documentation referencing it. Any thoughts would be appreciated.

Thanks,
Keith


Top
 Profile  
 
 Post subject: Re: ContainedIn Multiple Classes (Hibernate Search 5.1.1)
PostPosted: Tue Jul 28, 2015 2:32 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The alternative is to add two different @OneToMany on C, one pointing to A and one pointing to B. That way you don't need the superclass.

We do require the bidirectional approach as we need to know which A and B instances are containing a given instance of C. The explicit mapping is our way of discovering that.
That made me think that we could theoretically go without it and use a query instead. I have created a feature request for it https://hibernate.atlassian.net/browse/HSEARCH-1937

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.