[hibernate-dev] [HSEARCH] HSEARCH-923 Use of Coordinates interface for lat ad long

Emmanuel Bernard emmanuel at hibernate.org
Fri Feb 10 12:34:04 EST 2012


Nicolas,

I'm geting a bit cold feet on our initial implementation. We have decided to use Coordinates as the placeholder of lat and long. Coordinates is an Hibernate Search interface. Reading the draft of your doc and as an app developer, I don't find it too attractive to have to use this interface in my domain model.
I'm wondering if we should rather do as Karel suggested: support the "free form" and wait for Hibernate Spatial types to introduce such a concept.

That means we need to find a way to tag the lat / long getters

## Option 1

```
@Spatial(
    field="coordinates", 
    latitude="latitude", //property name
    longitude="longitude",
    method=QUAD
)
public class Restaurant {
    public double getLatitude() { ... }
    public double getLongitude() { ... }
}
```

### Embedded objects

```
@Spatial(
    field="coordinates", 
    latitude="place.latitude", //property name
    longitude="place.longitude",
    method=QUAD
)
public class Restaurant {
    public Place getPlace {} { ... }

}

//user defined
public class Place {
    public double getLatitude() { ... }
    public double getLongitude() { ... }
}
```

```
public class Restaurant {
   @Spatial(
        field="coordinates", 
        latitude="latitude", //property name
        longitude="longitude",
        method=QUAD
    )
    public Place getPlace {} { ... }

}

//user defined
public class Place {
    public double getLatitude() { ... }
    public double getLongitude() { ... }
}
```


## Option 2

```
@Spatial(
    field="coordinates", 
    method=QUAD
)
public class Restaurant {
    @Latitude(for="coordinates")
    public double getLatitude() { ... }

    @Longitude(for="coordinates")
    public double getLongitude() { ... }
}
```

### Embedded objects

```
@Spatial(
    field="coordinates", 
    method=QUAD
)
public class Restaurant {
    public Place getPlace {} { ... }

}

//user defined
public class Place {
    @Latitude(for="coordinates")
    public double getLatitude() { ... }
    @Longitude(for="coordinates")
    public double getLongitude() { ... }
}
```

## Opinion

I am not thrilled by what I am proposing, esp since they involve String as the link in our metadata. If someone has something better, go ahead.
Otherwise, I think I like option 1 better for a few reasons:

- easier to implement
- easier to read
- supports nicely embedded objects
- does not force the embedded object to be annotated (limit of reuse?)\\

what do you all think?



More information about the hibernate-dev mailing list