@ManyToOne @JoinColumn(name = "currency", referencedColumnName = "name") @NotFound(action = NotFoundAction.IGNORE) public Currency getCurrency() { return currency; }
@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; } } }
@Entity(name = "Employee") public static class Employee { @Id private String name; @OneToOne(optional = true) @JoinColumn(foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) @NotFound(action = NotFoundAction.IGNORE) private Task task; private Employee() { } private Employee(String name) { this.name = name; } }
@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; } } }
@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<>(); }
@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; } } }
@Entity @Table( name = "PersonManyToOneSelectIgnore" ) public static class PersonManyToOneSelectIgnore extends Person { @Id private Long id; @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) @NotFound( action = NotFoundAction.IGNORE ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) private City city; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public City getCity() { return city; } @Override 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) @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; } } }
@Entity @Table( name = "PersonOneToOneSelectIgnore" ) public static class PersonOneToOneSelectIgnore extends Person { @Id private Long id; @OneToOne(cascade = CascadeType.PERSIST) @NotFound( action = NotFoundAction.IGNORE ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @Fetch( FetchMode.SELECT ) private City city; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public City getCity() { return city; } @Override public void setCity(City city) { this.city = city; } }
@Entity @Table( name = "PersonManyToOneSelectIgnore" ) public static class PersonManyToOneSelectIgnore extends Person { @Id private Long id; @ManyToOne(cascade = CascadeType.PERSIST) @NotFound( action = NotFoundAction.IGNORE ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @Fetch( FetchMode.SELECT ) private City city; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public City getCity() { return city; } @Override 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; } } }
@Embeddable public static class CityInEmbeddable { @OneToOne(cascade = CascadeType.PERSIST) @PrimaryKeyJoinColumn @NotFound(action = NotFoundAction.IGNORE) @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) @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; } } }
@Embeddable public static class CityInEmbeddable { @OneToOne @MapsId @NotFound(action = NotFoundAction.IGNORE) @JoinColumn(name = "fk", 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 @MapsId @NotFound(action = NotFoundAction.IGNORE) @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; } } }
@Entity @Table( name = "PersonPkjcJoinIgnore" ) public static class PersonPkjcJoinIgnore extends Person { @Id private Long id; @OneToOne(cascade = CascadeType.PERSIST) @PrimaryKeyJoinColumn @NotFound(action = NotFoundAction.IGNORE) @Fetch(FetchMode.JOIN ) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) private City city; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public City getCity() { return city; } @Override public void setCity(City city) { this.city = city; } }