Database Reference
In-Depth Information
Location Entity
The Location entity, shown in Listing 11-50, has an outgoing relationship to Product that allows a location to have
multiple products. In addition, the entity includes a @Transient value. Transient values are not persisted or managed
in the database but contain values that an entity could use for display or other purposes. In this case, you will use the
distanceToLocation property to display a String value of the location's distance relative to the starting point in the search.
Listing 11-50. The Location Entity
@NodeEntity
@TypeAlias("Location")
public class Location {
@GraphId
private Long nodeId;
@Indexed
private String locationId;
private String name;
private String address;
private String city;
private String state;
private String zip;
private Double lat;
private Double lon;
@RelatedTo(type = GraphStoryConstants.HAS, direction =
Direction.OUTGOING, elementClass = Product.class)
private Set<Product> products;
@Transient
private String distanceToLocation;
// getters and setters
}
The User object also contains a relationship to Location via the HAS relationship type. User locations are
retrieved through the getUserLocation method, shown in Listing 11-51, which is located in the UserImpl class.
 
Search WWH ::




Custom Search