Created
November 11, 2013 00:39
-
-
Save volgar1x/7405971 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope = Parent.class) | |
public static class Parent { | |
private long id; | |
private String name; | |
@OneToMany | |
private List<Child> children = new ArrayList<>(); | |
public long getId() { | |
return id; | |
} | |
public void setId(long id) { | |
this.id = id; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public List<Child> getChildren() { | |
return children; | |
} | |
public Parent addChild(Child child) { | |
this.children.add(child); | |
return this; | |
} | |
public void setChildren(List<Child> children) { | |
this.children = children; | |
} | |
} | |
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope = Child.class) | |
public static class Child { | |
private long id; | |
private String name; | |
@ManyToOne | |
private Parent parent; | |
public long getId() { | |
return id; | |
} | |
public void setId(long id) { | |
this.id = id; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public Parent getParent() { | |
return parent; | |
} | |
public void setParent(Parent parent) { | |
this.parent = parent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment