/** * A Role relationship entity between an actor and movie. * * @author Luanne Misquitta * @author Michael J. Simons */ @RelationshipEntity(type = "ACTED_IN") @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) @Getter public class Role { private @Id @GeneratedValue Long id; private @StartNode Actor actor; private String role; private @EndNode Movie movie; Role(Actor actor, String role, Movie movie) { this.actor = actor; this.role = role; this.movie = movie; } }
/** * A Movie node entity. * * @author Luanne Misquitta * @author Oliver Gierke * @author Michael J. Simons */ @NodeEntity(label = "Movie") @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) @Getter public class Movie { private @Id @GeneratedValue Long id; private String title; private @Relationship(type = "ACTED_IN", direction = "INCOMING") Set<Role> roles = new HashSet<>(); public Movie(String title) { this.title = title; } }
@NodeEntity public class Warehouse { @GraphId private Long id; @Relationship(type="HAS_ADDRESS") private Address address;
@RelationshipEntity(type = "Arc") public static class Arc { Long id; Long created; @StartNode Vertex from; @EndNode Vertex to; } }
@NodeEntity public static class Something { @Id @GeneratedValue private Long id; private String name; } }
@NodeEntity public class Product { @GraphId private Long id; private String name, productId, description; private Double unitPrice; @Transient private Boolean inStock;
@NodeEntity public class Address { @GraphId private Long id;
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (isNotTraditionalGetter(method)) { log.warn("QueryResult interface method " + method.getName() + " doesn't appear to be a getter and therefore may not return the correct result."); } if (method.isAnnotationPresent(Property.class)) { Property annotation = method.getAnnotation(Property.class); return Utils.coerceTypes(method.getReturnType(), data.get(annotation.name())); } Matcher matcher = beanGetterPattern.matcher(method.getName()); if (matcher.matches()) { String propertyKey = matcher.group(2); propertyKey = propertyKey.substring(0, 1).toLowerCase().concat(propertyKey.substring(1)); return Utils.coerceTypes(method.getReturnType(), data.get(propertyKey)); } return Utils.coerceTypes(method.getReturnType(), data.get(method.getName())); }
@RelationshipEntity("PLAYS") public class Plays { @Id @GeneratedValue private Long id; @StartNode private User user; @EndNode private Hobby hobby; private String level; }
@NodeEntity public class Catalog { @GraphId private Long id; @Relationship(type = "HAS_PRODUCT", direction = "OUTGOING") private List<Product> products = new ArrayList<>();
/** * @author vince */ @RelationshipEntity(type = "KNOWS") public class Knows { Long id; @StartNode Entity knower; @EndNode Entity knowee; }
/** * An Actor node entity. * * @author Luanne Misquitta * @author Oliver Gierke * @author Michael J. Simons */ @NodeEntity(label = "Actor") @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) @Getter public class Actor { private @Id @GeneratedValue Long id; private String name; private @Relationship(type = "ACTED_IN") Set<Role> roles = new HashSet<>(); public Actor(String name) { this.name = name; } public void actedIn(Movie movie, String roleName) { Role role = new Role(this, roleName, movie); roles.add(role); movie.getRoles().add(role); } }
@NodeEntity public class Pet { @Id @GeneratedValue private Long id; private String name; }
@RelationshipEntity(type = "LIKES") static class Likes { Long id; @Id String uuid; @StartNode User from; @EndNode User to; int stars; } }
@NodeEntity public class Inventory { @GraphId private Long id; @Relationship(type = "PRODUCT_TYPE", direction = "OUTGOING") private Product product; @Relationship(type = "STOCKED_IN", direction = "OUTGOING") private Warehouse warehouse;
@RelationshipEntity(type = "abstractDynamicProperty") public abstract class L<T> { Long id; private T property; @StartNode public SomeNode a; @EndNode public SomeOtherNode b; }
@NodeEntity("C") public static class C { @Id @GeneratedValue private Long id; private String name; }
@NodeEntity public class Shipment { @GraphId private Long id; @Relationship(type = "CONTAINS_PRODUCT") private Set<Inventory> inventories = new HashSet<>(); @Relationship(type = "SHIP_TO") private Address deliveryAddress; @Relationship(type = "SHIP_FROM") private Warehouse fromWarehouse;
/** * @author Frantisek Hartman */ @RelationshipEntity(type = "ASSOCIATED_WITH") public class Associated<S extends Entity, T extends Entity> { private Long id; @StartNode S start; @EndNode T end; }
@RelationshipEntity(type = "GENERIC") public class GenericRelationship<S extends EntitySuperInterface, T extends EntitySuperInterface> { private Long id; @StartNode public S source; @EndNode public T target; }