Skip to content

Commit

Permalink
HSEARCH-3607 Apply default GeoPoint bridge to any extends of GeoPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fax4ever authored and yrodiere committed Jul 16, 2019
1 parent 4a9a6e1 commit 87b8f7a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import javax.persistence.Id;
import javax.persistence.ManyToMany;

import org.hibernate.search.mapper.pojo.bridge.builtin.annotation.GeoPointBinding;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;

@Entity
Expand All @@ -31,7 +31,7 @@ public class Author {
private String lastName;

@Embedded
@GeoPointBinding
@GenericField
private EmbeddableGeoPoint placeOfBirth;

@ManyToMany(mappedBy = "authors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import javax.persistence.ManyToMany;

import org.hibernate.search.engine.backend.types.Projectable;
import org.hibernate.search.mapper.pojo.bridge.builtin.annotation.GeoPointBinding;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;

@Entity
Expand All @@ -32,7 +32,7 @@ public class Author {
private String lastName;

@Embedded
@GeoPointBinding(projectable = Projectable.YES)
@GenericField(projectable = Projectable.YES)
private EmbeddableGeoPoint placeOfBirth;

@ManyToMany(mappedBy = "authors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import javax.persistence.ManyToMany;

import org.hibernate.search.engine.backend.types.Sortable;
import org.hibernate.search.mapper.pojo.bridge.builtin.annotation.GeoPointBinding;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField;

Expand All @@ -35,7 +35,7 @@ public class Author {
private String lastName;

@Embedded
@GeoPointBinding(sortable = Sortable.YES)
@GenericField(sortable = Sortable.YES)
private EmbeddableGeoPoint placeOfBirth;

@ManyToMany(mappedBy = "authors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public BridgeResolver(TypePatternMatcherFactory typePatternMatcherFactory) {
TypePatternMatcher concreteEnumPattern = typePatternMatcherFactory.createRawSuperTypeMatcher( Enum.class )
.and( typePatternMatcherFactory.createExactRawTypeMatcher( Enum.class ).negate() );

TypePatternMatcher concreteGeoPointPattern = typePatternMatcherFactory.createRawSuperTypeMatcher( GeoPoint.class );

addIdentifierBridgeForExactRawType( Integer.class, new DefaultIntegerIdentifierBridge() );
addIdentifierBridgeForExactRawType( Long.class, new DefaultLongIdentifierBridge() );
addIdentifierBinderForTypePattern( concreteEnumPattern, new DefaultEnumIdentifierBridge.Binder() );
Expand Down Expand Up @@ -128,7 +130,7 @@ public BridgeResolver(TypePatternMatcherFactory typePatternMatcherFactory) {
addValueBridgeForExactRawType( java.sql.Date.class, new DefaultJavaSqlDateValueBridge() );
addValueBridgeForExactRawType( Timestamp.class, new DefaultJavaSqlTimestampValueBridge() );
addValueBridgeForExactRawType( Time.class, new DefaultJavaSqlTimeValueBridge() );
addValueBinderForExactRawType( GeoPoint.class, new PassThroughValueBridge.Binder<>( GeoPoint.class, ParseUtils::parseGeoPoint ) );
addValueBinderForTypePattern( concreteGeoPointPattern, new PassThroughValueBridge.Binder<>( GeoPoint.class, ParseUtils::parseGeoPoint ) );
}

public IdentifierBinder resolveIdentifierBinderForType(PojoGenericTypeModel<?> sourceType) {
Expand Down

0 comments on commit 87b8f7a

Please sign in to comment.