anchor.diff:  The only property stored on the relationship is going to be the index of the association when required,
   for example when the association is annotated with +@OrderColumn+ or when a +java.util.Map+ is used.
   
  -.Example of bidirectional @ManyToMany
  -====
  -[source, JAVA]
  -----
  -@Entity
  -class AccountOwner {
  -
  -    @Id
  -    String sSN;
  +In Neo4j nodes are connected via relationship, this means that we don't need to create properties
  +which store foreign column keys. This means that annotation like +@JoinColumn+ won't have any effect.
  +
  +.Unidirectional one-to-one
  +====
  +[source, JAVA]
  +----
  +@Entity
  +public class Vehicule {
  +
  +    @Id
  +    private String id;
  +    private String brand;
  +
  +    // getters, setters ...
  +}
  +
  +
  +@Entity
  +public class Wheel {
  +
  +    @Id
  +    private String id;
  +    private String company;
  +    private double diameter;
  +
  +    @OneToOne
  +    private Vehicule vehicule;
  +
  +    // getters, setters ...
  +}
  +----
  +
  +image::images/neo4j-uni-one-to-one-example.png[align="center", depth="", scalefit="1"]
  +====
  +
  +.Bidirectional one-to-one
  +====
  +[source, JAVA]
  +----
  +@Entity
  +public class Husband {
  +
  +    @Id
  +    private String id;
  +    private String name;
  +
  +    @OneToOne
  +    private Wife wife;
  +
  +    // getters, setters ...
  +}
  +
  +@Entity
  +public class Wife {
  +
  +    @Id
  +    private String id;
  +    private String name;
  +
  +    @OneToOne(mappedBy = "wife")
  +    private Husband husband;
  +
  +    // getters, setters ...
  +}
  +----
  +
  +image::images/neo4j-bi-one-to-one-example.png[align="center", depth="", scalefit="1"]
  +====
  +
  +.Unidirectional one-to-many
  +====
  +[source, JAVA]
  +----
  +@Entity
  +public class Basket {
  +
  +    @Id
  +    private String id;
  +
  +    private String owner;
  +
  +    @OneToMany
  +    private List<Product> products = new ArrayList<Product>();
  +
  +    // getters, setters ...
  +}
  +
  +@Entity
  +public class Product {
  +
  +    @Id
  +    private String name;
  +
  +    private String description;
  +
  +    // getters, setters ...
  +}
  +----
  +
  +image::images/neo4j-uni-one-to-many-example.png[align="center", depth="", scalefit="1"]
  +====
  +
  +.Unidirectional one-to-many using maps with defaults
  +====
  +[source, JAVA]
  +----
  +@Entity
  +public class User {
  +
  +    @Id
  +    private String id;
  +
  +    @OneToMany
  +    private Map<String, Address> addresses = new HashMap<String, Address>();
  +
  +    // getters, setters ...
  +}
  +
  +@Entity
  +public class Address {
  +
  +    @Id
  +    private String id;
  +    private String city;
  +
  +    // getters, setters ...
  +}
  +----
  +
  +image::images/neo4j-uni-one-to-many-with-map-example.png[align="center", depth="", scalefit="1"]
  +====
  +
  +.Unidirectional one-to-many using maps with @MapKeyColumn
  +====
  +[source, JAVA]
  +----
  +@Entity
  +public class User {
  +
  +    @Id
  +    private String id;
  +
  +    @OneToMany
  +    @MapKeyColumn(name = "addressType")
  +    private Map<String, Address> addresses = new HashMap<String, Address>();
  +
  +    // getters, setters ...
  +}
  +
  +@Entity
  +public class Address {
  +
  +    @Id
  +    private String id;
  +    private String city;
  +
  +    // getters, setters ...
  +}
  +----
  +
  +image::images/neo4j-uni-one-to-many-with-@MapKeyColumn-example.png[align="center", depth="", scalefit="1"]
  +====
  +
  +.Unidirectional many-to-one
  +====
  +[source, JAVA]
  +----
  +@Entity
  +public class JavaUserGroup {
  +
  +    @Id
  +    private String jug_id;
  +    private String name;
  +
  +    // getters, setters ...
  +}
  +
  +@Entity
  +public class Member {
  +
  +    @Id
  +    private String id;
  +    private String name;
  +
  +    @ManyToOne
  +    private JavaUserGroup memberOf;
  +
  +    // getters, setters ...
  +}
  +----
  +
  +image::images/neo4j-uni-many-to-one-example.png[align="center", depth="", scalefit="1"]
  +====
  +
  +.Bidirectional many-to-one 
  +====
  +[source, JAVA]
  +----
  +@Entity
  +public class SalesForce {
  +
  +    @Id
  +    private String id;
  +    private String corporation;
  +
  +    @OneToMany(mappedBy = "salesForce")
  +    private Set<SalesGuy> salesGuys = new HashSet<SalesGuy>();
  +
  +    // getters, setters ...
  +}
  +
  +@Entity
  +public class SalesGuy {
  +    private String id;
  +    private String name;
  +
  +    @ManyToOne
  +    private SalesForce salesForce;
  +
  +    // getters, setters ...
  +}
  +----
  +
  +image::images/neo4j-bi-many-to-one-example.png[align="center", depth="", scalefit="1"]
  +====
  +
  +.Unidirectional many-to-many
  +====
  +[source, JAVA]
  +----
  +@Entity
  +public class Student {
  +
  +    @Id
  +    private String id;
  +    private String name;
  +
  +    // getters, setters ...
  +}
  +
  +@Entity
  +public class ClassRoom {
  +
  +    @Id
  +    private long id;
  +    private String lesson;
   
       @ManyToMany
  -    Set<BankAccount> bankAccounts = new HashSet<BankAccount>();
  -
  -}
  -
  -@Entity
  -class BankAccount {
  -
  -    @Id
  -    String accountNumber;
  -
  -    @ManyToMany(mappedBy = "bankAccounts")
  -    Set<AccountOwner> owners = new HashSet<AccountOwner>();
  -
  -}
  -----
  -
  -[subs="verbatim,attributes"]
  -----
  -(:AccountOwner:ENTITY {...}) - [:bankAccounts] -> (:BankAccount:ENTITY {...})
  -----
  -
  -====
  -
  -.Example of unidirectional @ManyToOne with @OrderColumn
  -====
  -[source, JAVA]
  -----
  -@Entity
  -class Father {
  -    @Id
  -    String name;
  -
  -    @OneToMany
  -    @OrderColumn(name = "birthorder")
  -    List<Child> children = new ArrayList<Child>();
  -}
  -
  -@Entity
  -class Child {
  -    @Id
  -    String name;
  -}
  -
  -----
  -
  -[subs="verbatim,attributes"]
  -----
  -(:Father:ENTITY {...}) - [:children { birthorder: 0 }] -> (:Child:ENTITY {...})
  -(:Father:ENTITY {...}) - [:children { birthorder: 1 }] -> (:Child:ENTITY {...})
  -----
  -
  -====
  -
  -.Example of bidirectional @OneToOne
  -====
  -[source, JAVA]
  -----
  -@Entity
  -class Husband {
  -	String id;
  -	String name;
  -	Wife wife;
  -
  -	@Id
  -	Long getId() {
  -		return id;
  -	}
  -
  -	...
  -
  -	@OneToOne(fetch = FetchType.LAZY)
  -	@JoinColumn(name = "wife")
  -	Wife getWife() {
  -		return wife;
  -	}
  -
  -	void setWife(Wife wife) {
  -		this.wife = wife;
  -	}
  -
  -}
  -
  -@Entity
  -class Wife {
  -	String id;
  -	String name;
  -	...
  -	
  -	@Id
  -	Long getId() {
  -		return id;
  -	}
  -
  -	...
  -
  -	@OneToOne(mappedBy = "wife")
  -	public Husband getHusband() {
  -		return husband;
  -	}
  -
  -}
  -
  -----
  -
  -[subs="verbatim,attributes"]
  -----
  -(:Wife:ENTITY { id: 1, name: "Karen" }) <- [:wife] - (:Husband:ENTITY {id: 2, name: "Mark"})
  -----
  -
  -====
  -
  -.Example of collection of @Embeddable
  -====
  -[source, JAVA]
  -----
  -@Entity
  -class MultiAddressAccount {
  -	String login;
  -	String password;
  -	List<Address> addresses = new ArrayList<Address>();
  -
  -	@Id
  -	public String getLogin() {
  -		return login;
  -	}
  -
  -	...
  -
  -	@ElementCollection
  -	public List<Address> getAddresses() {
  -		return addresses;
  -	}
  -
  -	public void setAddresses(List<Address> addresses) {
  -		this.addresses = addresses;
  -	}
  -}
  -
  -@Embeddable
  -public class Address {
  -	String street1;
  -	String street2;
  -	String city;
  -	String country;
  -
  -	@Column(name = "postal_code")
  -	String zipCode;
  -}
  -----
  -
  -[subs="verbatim,attributes"]
  -----
  -(:MultiAddressAccount:ENTITY{login: '...', password: '...' }) - [:addresses] -> (:MultiAddressAccount_addresses:EMBEDDED {street1: '...', city: '...', country: '...', postal_code: '...'})
  -----
  -
  +    private List<Student> students = new ArrayList<Student>();
  +
  +    // getters, setters ...
  +}
  +----
  +
  +image::images/neo4j-uni-many-to-many-example.png[align="center", depth="", scalefit="1"]
  +====
  +
  +.Bidirectional many-to-many 
  +====
  +[source, JAVA]
  +----
  +@Entity
  +public class AccountOwner {
  +
  +    @Id
  +    private String id;
  +
  +    private String SSN;
  +
  +    @ManyToMany
  +    private Set<BankAccount> bankAccounts;
  +
  +    // getters, setters ...
  +}
  +
  +@Entity
  +public class BankAccount {
  +
  +    @Id
  +    private String id;
  +
  +    private String accountNumber;
  +
  +    @ManyToMany( mappedBy = "bankAccounts" )
  +    private Set<AccountOwner> owners = new HashSet<AccountOwner>();
  +
  +    // getters, setters ...
  +}
  +----
  +
  +image::images/neo4j-bi-many-to-many-example.png[align="center", depth="", scalefit="1"]
   ====
   
   ===== Auto-generated Values
  
positive.code: 
  An additional label +ENTITY+ is added to the node. 
  
  .Example of entity and the corresponding representation using Cypher
  ====
  [source, JAVA]
  ----
  @Entity
  class Account {
  
      @Id
      String login;
  
      String password;
  
  }
  ----
  
  [subs="verbatim,attributes"]
  ----
  Using Cypher:
  
  (n:Account:ENTITY {login: '...', password: '...'})
  ----
  ====
  
  .Example of enitty with @Embaddable
  ====
  [source, JAVA]
  ----
  @Entity
  class Account {
  	String login;
  	String password;
  	Address homeAddress;
  	...
  }
  
  @Embeddable
  public class Address {
  	String street1;
  	String street2;
  	String city;
  	String country;
  
  	@Column(name = "postal_code")
  	String zipCode;
  }
  ----
  
  [subs="verbatim,attributes"]
  ----
  (n:Account:ENTITY {login: ..., 
                     , password: ...
                     , `homeAddress.street1`: ...
                     , `homeAddress.city`: ...
                     , `homeAddress.country`: ...
                     , postal_code`: ...})
  ----
  
  ====
  
  Currently an embeddable element is stored saving the values on the node that represents the entity.
  
  Hibernate OGM will create unique constraints for the identifier of entities and for the properties defined
  as unique using:
  
  * @NaturalId
  * @Column(unique = true)
  * @Table(uniqueConstraints = @UniqueConstraint(columnNames = { "column_name" }
  
    Neo4j does not support constraints on more than one property.
    For this reason, Hibernate OGM will create a unique constraint only when
    defined on a single column and it will ignore the ones defined on multiple columns.
  
  ===== Associations
  
  
negative.code: 
  Table-based generators are represented by nodes in the following form:
  
  .GenerationType.TABLE
  ====
  [source, JAVA]
  ----
  @Entity
  public class Video {
  
      ...
  
      @Id
      @GeneratedValue( strategy = GenerationType.TABLE, generator = "video" )
      @TableGenerator(
           name = "video",
           table = "Sequences",
           pkColumnName = "key",
           pkColumnValue = "video",
           valueColumnName = "seed"
      )
      public Integer getId() {
          return id;
      }
  
      ...
  ----
  
  image::images/neo4j-table-based-sequence-example.png[align="center", depth="", scalefit="1"]
  ====
  
  Each table generator node is labelled with +TABLE_BASED_SEQUENCE+
  