Is there an argument for @Column
to prevent an empty String value ? Empty values are being a problem inside JLists. If not, what concise logic is the norm to be added to the entity to avoid this.
@Entity
public class Role {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(unique=true, nullable=false)
private String roleName;
You can use @Size annotation like this:
@Size(min=1)
@Column(unique=true, nullable=false)
private String roleName;
You should use Java Bean Validation. These annotations will help you:
@Pattern
- define a regular expression to detect empty values@Size
- check the size of the String.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With