java - Validation doesn't work on EntityManager.merge() -
i have few validations on entity, @notnull, , generation,
@id @generatedvalue(strategy = auto) @column(name = "id") private long id; @column @generatedvalue(strategy = generationtype.auto) private long referencenumber; however when calling entitymanager.merge() values not generated. null fields @notnull annotation passed without complain. id not generated.
should switch generation on somehow? how, , where?
in addition kraftan's answer:
by default automatic bean validation in jpa 2.0 works if validation provider "present in environment", otherwise silently doesn't work. can add
<validation-mode>callback</validation-mode>to
persistence.xmlin order generate error if validation provider not found.- jpa doesn't support generation of arbitrary (non-id) properties. jpa providers may have extensions.
Comments
Post a Comment