Correctness18 - SpotBugsExtensionForSpringFrameWork/CS5098 GitHub Wiki
(Suitable) Bug Name
Description
In Hibernate, this will come down to an entity being persisted with a problem. Either the entity has a null property which is defined with a not-null constraint, or an association of the entity may reference an unsaved, transient instance.
@Entity
public class Foo {
...
@Column(nullable = false) // not-null constraint
private String name;
...
}
------------------------------------------------------------
@Test(expected = DataIntegrityViolationException.class)
public void whenInvalidEntityIsCreated_thenDataException() {
fooService.create(new Foo()); // having null property -> error occur
}