Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-923 @embeddable with @spatial annotation test case
- Loading branch information
Showing
3 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
hibernate-search-orm/src/test/java/org/hibernate/search/test/spatial/Position.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.hibernate.search.test.spatial; | ||
|
||
import javax.persistence.Embeddable; | ||
|
||
import org.hibernate.search.annotations.Spatial; | ||
import org.hibernate.search.spatial.Coordinates; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: nicolashelleringer | ||
* Date: 30/05/12 | ||
* Time: 16:50 | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
@Embeddable | ||
public class Position { | ||
String address; | ||
double latitude; | ||
double longitude; | ||
|
||
@Spatial | ||
public Coordinates getLocation() { | ||
return new Coordinates() { | ||
@Override | ||
public Double getLatitude() { | ||
return latitude; | ||
} | ||
|
||
@Override | ||
public Double getLongitude() { | ||
return longitude; | ||
} | ||
}; | ||
} | ||
|
||
public Position() {} | ||
} |
63 changes: 63 additions & 0 deletions
63
hibernate-search-orm/src/test/java/org/hibernate/search/test/spatial/Restaurant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.hibernate.search.test.spatial; | ||
|
||
import org.hibernate.search.annotations.Field; | ||
import org.hibernate.search.annotations.Indexed; | ||
import org.hibernate.search.annotations.IndexedEmbedded; | ||
import org.hibernate.search.annotations.Spatial; | ||
import org.hibernate.search.annotations.Store; | ||
import org.hibernate.search.spatial.Coordinates; | ||
|
||
import javax.persistence.Embeddable; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
|
||
/** | ||
* Hibernate Search spatial : Point Of Interest test entity | ||
* | ||
* @author Nicolas Helleringer <nicolas.helleringer@novacodex.net> | ||
*/ | ||
@Entity | ||
@Indexed | ||
public class Restaurant { | ||
@Id | ||
Integer id; | ||
|
||
@Field(store = Store.YES) | ||
String name; | ||
|
||
@IndexedEmbedded | ||
Position position; | ||
|
||
public Restaurant(Integer id, String name, String address,double latitude, double longitude) { | ||
this.id = id; | ||
this.name = name; | ||
this.position= new Position(); | ||
this.position.address= address; | ||
this.position.latitude = latitude; | ||
this.position.longitude = longitude; | ||
} | ||
|
||
public Restaurant() { | ||
} | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getAddress() { | ||
return position.address; | ||
} | ||
|
||
public Double getLatitude() { | ||
return position.latitude; | ||
} | ||
|
||
public Double getLongitude() { | ||
return position.longitude; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters