Given are the following two JPA entities:
@Entity
public class Event {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Access(AccessType.PROPERTY)
private Long id;
@ElementCollection
private Set<Tag> tags;
}
@Embeddable
public class Tag {
@Column(nullable = false)
private String value;
}
It seems that Hibernate disregards the @Column(nullable = false) annotation on Tag.value if and only if Event.id is annotated with @Access(AccessType.PROPERTY). I published a minimal test case on https://github.com/bwaldvogel/hibernate-element-collection-access-type-issue. EventTest.testPersistInvalidTag() fails on the assertion (unexpected) if and only if @Access(AccessType.PROPERTY) is used on Event.id. |