Here's some code snippets. They're pretty simple, I'm not doing anything out of the ordinary
Model with extraneous JPA properties snipped out:
Code:
@Entity
@Table(name="identity")
@NodeEntity(partial=true)
public class Identity {
@Id
@Column
@GeneratedValue(strategy=GenerationType.AUTO)
protected int id;
/**
* Name displayed on identity view
*/
@Column(length=80)
protected String displayName;
/**
* Copy of displayName for raw graph queries
*/
@GraphProperty
@Transient
String graphName;
@RelatedTo(elementClass=Identity.class, type="FRIENDS", direction=Direction.BOTH)
Set<Identity> friends;
...
DAO, the persist method calls a parent persit method which is just a wrapper around entityManager.persist() (same thing with flush()). This is being called from a controller method that just instantiates a new Identity, sets a couple of values, they persists it.
Code:
public void persist(Identity entity) {
super.persist(entity);
this.flush();
entity.persist();
}