@ManyToOne @JoinColumn(name = "currency", referencedColumnName = "name") @NotFound(action = NotFoundAction.IGNORE) public Currency getCurrency() { return currency; }
boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); matchIgnoreNotFoundWithFetchType(propertyHolder.getEntityName(), property.getName(), ignoreNotFound, ann.fetch()); OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); collectionBinder.setIgnoreNotFound( ignoreNotFound ); collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() );
private static void manyToOne(FieldMap fieldMap, Field field) { JoinColumn column = field.getAnnotation(JoinColumn.class); String columnName = column.name(); FieldDefinition definition; if (field.isAnnotationPresent(NotFound.class)) { NotFound notFoundAnnotation = field.getAnnotation(NotFound.class); definition = notFoundAnnotation.action() == NotFoundAction.IGNORE ? new IgnorableFieldDefinition(field) : new FieldDefinition(field); } else { definition = new FieldDefinition(field); } fieldMap.put(columnName.toLowerCase(), definition); }
@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; } }
boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class ); boolean onDeleteCascade = onDeleteAnn != null && OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class ); boolean onDeleteCascade = onDeleteAnn != null && OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); collectionBinder.setIgnoreNotFound( ignoreNotFound ); collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() );
@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; } } }
Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); collectionBinder.setIgnoreNotFound( ignoreNotFound ); collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() );
@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<>(); }
boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class ); boolean onDeleteCascade = onDeleteAnn != null && OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class ); boolean onDeleteCascade = onDeleteAnn != null && OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); collectionBinder.setIgnoreNotFound( ignoreNotFound ); collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() );
@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; } } }
boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class ); boolean onDeleteCascade = onDeleteAnn != null && OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class ); boolean onDeleteCascade = onDeleteAnn != null && OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); collectionBinder.setIgnoreNotFound( ignoreNotFound ); collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() );
@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<>(); }
boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); matchIgnoreNotFoundWithFetchType(propertyHolder.getEntityName(), property.getName(), ignoreNotFound, ann.fetch()); OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); collectionBinder.setIgnoreNotFound( ignoreNotFound ); collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() );
@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 = "PersonOneToOneSelectIgnore" ) public static class PersonOneToOneSelectIgnore extends Person { @Id private Long id; @OneToOne(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; } }
@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; } } }
@NotFound ( action = NotFoundAction.IGNORE ) @JoinColumn( name = "cityName",