Java – Validation does not apply to entitymanager merge()

I rarely verify my entities, such as @ notnull, and some generations, such as

@Id
@GeneratedValue(strategy = AUTO)
@Column(name = "ID")
private Long id;

@Column
@GeneratedValue(strategy = GenerationType.AUTO)
private Long referenceNumber;

However, when calling entitymanager This value is not generated when merge() Empty fields with @ notnull annotation are passed without any complaints Even IDs are not generated

Should I switch this generation in some way? How's it going? Where is it?

Solution

In addition to kafudan's answer:

>By default, if the validation provider "exists in the environment", automatic bean validation in JPA 2.0 will work, otherwise it will not work properly You can add

<validation-mode>CALLBACK</validation-mode>

Persistence. If the validation provider cannot be found XML to generate errors. > JPA does not support generating arbitrary (non ID) attributes Some JPA providers may have extensions

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>