as part of a website i'm building using Spring Boot, I receive input via Thymeleaf form. To validate the input i have created a class and annotated its fields:
package com.bank.domain;
import java.util.Date;
import javax.persistence.Column;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class NewClass {
//if record is active/inactive (hidden)
@Column
private boolean active=true;
//bank of account holder
@NotNull
@Size(min = 2, max =3)
private String banknum;
//branch
@NotNull
@Size(min = 1, max =3)
private String branchnum;
// account number
@NotNull
@Size(min = 4, max =10)
private String accountnum;
// number / range of numbers of Check
@NotNull
@Digits(integer=9, fraction=0)
@Column(columnDefinition = "UNSIGNED INT(9) not null",nullable=false)
private String fromchecknum;
// number / range of numbers of Check
@NotNull
@Digits(integer=9, fraction=0)
@Column(columnDefinition = "UNSIGNED INT(9) not null",nullable=false)
private String tochecknum;
}
because I have debug turned on, i see that sql output in dumped to the log, even though there is no table for this class in the database. I want to not waste resources on the SQL queries or whatever they are, since there is no underlying table, just a class with fields that have validators.
So my question is -
is it possible to just use a regular class and also employing the various annotation such as @Size
, @Min
, @NotNull
, @Digits
, etc?