@OneToMany(cascade=CascadeType.ALL, mappedBy = "veryOldPerson") @Fetch(FetchMode.SELECT) public Collection<Stay> getVeryOldStays() { return veryOldStays; }
@ManyToOne(targetEntity = Team.class) @Fetch(FetchMode.SELECT) @JoinColumn(name = "team_id") public Team getTeam() { return team; }
@ManyToOne(cascade = CascadeType.ALL) @LazyToOne(LazyToOneOption.PROXY) @Fetch(FetchMode.SELECT) @JoinColumn(name = "oldperson") public Person getOldPerson() { return oldPerson; }
@OneToMany(cascade=CascadeType.ALL, mappedBy = "oldPerson") @LazyCollection(LazyCollectionOption.EXTRA) @Fetch(FetchMode.SUBSELECT) public Collection<Stay> getOldStays() { return oldStays; }
@OneToMany(targetEntity = Player.class, mappedBy = "team", fetch = FetchType.EAGER) @Fetch(FetchMode.SELECT) @Loader(namedQuery = "loadByTeam") public Set<Player> getPlayers() { return players; }
@OneToMany(targetEntity = ChildEntity.class, mappedBy = "parent") @LazyCollection(LazyCollectionOption.EXTRA) @Fetch(FetchMode.SELECT) public Set<ChildEntity> getChildren() { return children; }
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @LazyToOne(LazyToOneOption.PROXY) @Fetch(FetchMode.JOIN) @JoinColumn(name = "veryoldperson") public Person getVeryOldPerson() { return veryOldPerson; }
@Entity(name = "Product") public static class Product { @Id @GeneratedValue private int id; @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @NotFound(action = NotFoundAction.IGNORE) @JoinColumn(name = "categoryId") @Fetch(FetchMode.SELECT) private Category category; private ContainedCategory containedCategory; @ElementCollection(fetch = FetchType.EAGER) private Set<ContainedCategory> containedCategories = new HashSet<>(); }
@Entity(name = "Product") public static class Product { @Id @GeneratedValue private int id; @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @NotFound(action = NotFoundAction.IGNORE) @JoinColumn(name = "categoryId") @Fetch(FetchMode.JOIN) private Category category; private ContainedCategory containedCategory; @ElementCollection(fetch = FetchType.EAGER) private Set<ContainedCategory> containedCategories = new HashSet<>(); }
@Embeddable public static class ContainedCategory { @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @NotFound(action = NotFoundAction.IGNORE) @JoinColumn(name = "containedCategoryId") @Fetch(FetchMode.JOIN) private Category category; public ContainedCategory() { } public ContainedCategory(Category category) { this.category = category; } } }
@Embeddable public static class ContainedCategory { @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @NotFound(action = NotFoundAction.IGNORE) @JoinColumn(name = "containedCategoryId") @Fetch(FetchMode.SELECT) private Category category; public ContainedCategory() { } public ContainedCategory(Category category) { this.category = category; } } }
@Embeddable public static class CityInEmbeddable { @OneToOne(cascade = CascadeType.PERSIST) @NotFound( action = NotFoundAction.IGNORE ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @Fetch( FetchMode.JOIN ) private City city; public City getCity() { return city; } public void setCity(City city) { this.city = city; } } }
@Embeddable public static class CityInEmbeddable { @ManyToOne(cascade = CascadeType.PERSIST) @NotFound( action = NotFoundAction.IGNORE ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @Fetch( FetchMode.JOIN ) private City city; public City getCity() { return city; } public void setCity(City city) { this.city = city; } } }
@Embeddable public static class CityInEmbeddable { @OneToOne(cascade = CascadeType.PERSIST) @NotFound( action = NotFoundAction.IGNORE ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @Fetch( FetchMode.SELECT ) private City city; public City getCity() { return city; } public void setCity(City city) { this.city = city; } } }
@Embeddable public static class CityInEmbeddable { @ManyToOne(cascade = CascadeType.PERSIST) @NotFound( action = NotFoundAction.IGNORE ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @Fetch( FetchMode.SELECT ) private City city; public City getCity() { return city; } public void setCity(City city) { this.city = city; } } }
@Embeddable public static class CityInEmbeddable { @OneToOne(cascade = CascadeType.PERSIST) @PrimaryKeyJoinColumn @Fetch(FetchMode.JOIN ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) private City city; public City getCity() { return city; } public void setCity(City city) { this.city = city; } } }
@OneToMany(cascade=CascadeType.ALL) @LazyCollection(LazyCollectionOption.EXTRA) @Fetch(FetchMode.SUBSELECT) @OrderColumn(name="orderedStayIndex") public List<Stay> getOrderedStay() { return orderedStay; }
@Embeddable public static class CityInEmbeddable { @OneToOne(cascade = CascadeType.PERSIST) @PrimaryKeyJoinColumn @Fetch(FetchMode.SELECT ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) private City city; public City getCity() { return city; } public void setCity(City city) { this.city = city; } } }
@Embeddable public static class CityInEmbeddable { @OneToOne @MapsId @NotFound(action = NotFoundAction.IGNORE) @JoinColumn(name = "fk", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @Fetch(FetchMode.JOIN) private City city; public City getCity() { return city; } public void setCity(City city) { this.city = city; } } }
@Embeddable public static class CityInEmbeddable { @OneToOne(cascade = CascadeType.PERSIST) @PrimaryKeyJoinColumn @NotFound(action = NotFoundAction.IGNORE) @Fetch(FetchMode.JOIN ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) private City city; public City getCity() { return city; } public void setCity(City city) { this.city = city; } } }