@OneToMany(cascade=CascadeType.ALL, mappedBy = "oldPerson") @LazyCollection(LazyCollectionOption.EXTRA) @Fetch(FetchMode.SUBSELECT) public Collection<Stay> getOldStays() { return oldStays; }
@OneToMany(mappedBy = "forum", cascade = CascadeType.ALL , orphanRemoval = true, fetch = FetchType.LAZY) @LazyCollection(LazyCollectionOption.EXTRA) @OrderColumn(name = "idx3") public List<User> getUsers() { return users; }
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL , orphanRemoval = false, fetch = FetchType.LAZY) @LazyCollection(LazyCollectionOption.EXTRA) @OrderColumn(name = "idx") public List<Comment> getComments() { return comments; }
@OneToMany(targetEntity = ChildEntity.class, mappedBy = "parent") @LazyCollection(LazyCollectionOption.EXTRA) @Fetch(FetchMode.SELECT) public Set<ChildEntity> getChildren() { return children; }
@OneToMany(mappedBy = "forum", cascade = CascadeType.ALL , orphanRemoval = false, fetch = FetchType.LAZY) @LazyCollection(LazyCollectionOption.EXTRA) @OrderColumn(name = "idx2") public List<Comment> getPosts() { return posts; }
@Entity(name = "Parent") public static class Parent { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", orphanRemoval = true) @LazyCollection( value = LazyCollectionOption.EXTRA) private Set<Child> children = new HashSet<Child>(); public Parent() { } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Set<Child> getChildren() { return children; } public void addChild(Child child) { children.add(child); child.setParent(this); } public void removeChild(Child child) { children.remove(child); child.setParent(null); } }
@OneToMany(cascade=CascadeType.ALL) @LazyCollection(LazyCollectionOption.EXTRA) @Fetch(FetchMode.SUBSELECT) @OrderColumn(name="orderedStayIndex") public List<Stay> getOrderedStay() { return orderedStay; }
@Entity(name = "Department") public static class Department { @Id private Long id; @OneToMany(mappedBy = "department", cascade = CascadeType.ALL) @OrderColumn(name = "order_id") @LazyCollection( LazyCollectionOption.EXTRA ) private List<Employee> employees = new ArrayList<>(); //Getters and setters omitted for brevity //end::fetching-LazyCollection-domain-model-example[] public Long getId() { return id; } public void setId(Long id) { this.id = id; } public List<Employee> getEmployees() { return employees; } public void setEmployees(List<Employee> employees) { this.employees = employees; } public void addEmployee(Employee employee) { this.employees.add( employee ); employee.setDepartment( this ); } //tag::fetching-LazyCollection-domain-model-example[] }
@ManyToMany @LazyCollection(LazyCollectionOption.FALSE) public Set<Site> getSites() { return sites; }
@ElementCollection @LazyCollection(LazyCollectionOption.FALSE) public Set<String> getAuthorities() { return authorities; }
@ElementCollection @LazyCollection(LazyCollectionOption.FALSE) public Set<String> getScopes() { return scopes; }
@ElementCollection @LazyCollection(LazyCollectionOption.FALSE) public Set<String> getResourceIds() { return resourceIds; }
@ManyToMany( targetEntity = InteractionImpl.class, mappedBy = "experiments", cascade = CascadeType.REMOVE ) @LazyCollection(LazyCollectionOption.EXTRA) @OrderBy("created") public Collection<Interaction> getInteractions() { return interactions; }
@ManyToMany( targetEntity = InteractionImpl.class, mappedBy = "experiments", cascade = CascadeType.REMOVE ) @LazyCollection(LazyCollectionOption.EXTRA) @OrderBy("created") public Collection<Interaction> getInteractions() { return interactions; }
@LazyCollection(LazyCollectionOption.FALSE) private Map<String, String> properties;