Yes, it is possible to change an embedded Hibernate entity to be mandatory by adding the @NotNull annotation on the corresponding field. For example:
@Entity
public class Customer {
@Embedded
@NotNull
private PersonalInfo personalInfo;
}
@Embeddable
public class PersonalInfo {
@NotNull
private String firstName;
@NotNull
private String lastName;
}
In the above example, the embedded entity PersonalInfo is made mandatory by adding the @NotNull annotation to its fields firstName and lastName. This ensures that whenever a Customer entity is persisted or updated, it must have a non-null PersonalInfo object that also has non-null firstName and lastName values.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-01-01 11:00:00 +0000
Seen: 15 times
Last updated: Jun 26 '21
Why is there a delay in reflecting a change when using the useState set method?
How to change the default keyboard shortcuts in Ace Editor?
How can the Arrow buttons be modified in the Slick slider?
When returning to HTML, does the null data in Ajax change to a different value?
How to change a Bitstring into an integer in Vertica?
How to change the data types of columns within a DataFrame using Polars?
How can we change a column of type String into JSON format in AWS Athena?
Is it possible to change the "table-layout: fixed" setting for just one row?