-->
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: Hibernate Search and bidirectional search
PostPosted: Mon May 05, 2014 3:20 am 
Beginner
Beginner

Joined: Mon Nov 26, 2012 4:08 am
Posts: 24
Hello!
I have come upon a problem in our application using Hibernate Search.

We have a class, A where we do hsearch against fields in class A and B and also Spatial search agaist class Address declared in A.
Everything works nicely.

Now we have to implement search the other way around also, we want to search class B for fields contained in B, A and spatial search against A.Address. Now we have a problem. Since
B has A declared as @ContainedIn, the fields of A isn't searcheable from B.
If we change @ContainedIn to @IndexEmbedded we get circular dependency because you can't have @IndexEmbedded on both sides.
Then I read that you can limit the depth on @IndexEmbedded so I tried that. I know that we aren't going to search deeper than A.?.?.? in B so I changed @ContainedIn to
@IndexEmbedded(depth = 4) on class A in class B.

Now when I start my application I get the following error:
org.hibernate.search.SearchException: HSEARCH000158: Class Address cannot have two @Spatial using default/same name

Has anyone ant tips on how to solve this?
We use Hibernate Search version 4.5.0.Final
Se the classes below.
Regards
Andreas

@Entity
@Indexed
@FullTextFilterDefs({
@FullTextFilterDef(name = "externalSearchFilterFactory", impl = ExternalSearchFilterFactory.class),
@FullTextFilterDef(name = "internalSearchFilterFactory", impl = InternalSearchFilterFactory.class)
})
@DynamicUpdate(value = true)
@Table(name = "A")
public class A extends DomainObjekt {

.....

@IndexedEmbedded
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE, optional = false)
@JoinColumn(name = "B_ID", referencedColumnName = "B_ID", nullable = false)
private B b;

@IndexedEmbedded
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE, optional = false)
@JoinColumn(name = "ADDRESS_ID", referencedColumnName = "ADDRESS_ID", nullable = false)
private Address adress;

.....

}


@Entity
@Indexed
@DynamicUpdate(value = true)
@Table(name = "B")
public class B extends DomainObjekt {

.....

@ContainedIn
@OneToMany(mappedBy = "b", fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
private Set<A> listOfA = new HashSet<A>();

.....
}

@Spatial(name = "location", spatialMode = SpatialMode.RANGE)
@Indexed
@Entity
@DynamicUpdate(value = true)
@Table(name = "ADDRESS")
@SuppressWarnings({"serial"})
public class Address extends DomainObjekt {

.....

@Latitude(of = "location")
@Column(name = "LATITUDE")
private Double latitude;

@Longitude(of = "location")
@Column(name = "LONGITUDE")
private Double longitude;

.....
}


Top
 Profile  
 
 Post subject: Re: Hibernate Search and bidirectional search
PostPosted: Tue May 06, 2014 10:26 am 
Beginner
Beginner

Joined: Mon Nov 26, 2012 4:08 am
Posts: 24
I solved the problem.
By using includePaths in @IndexEmbedded in class A and naming only the fields I was interested in, I got rid of the circular dependency problem I had.


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.