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;
..... }
|