Enums

 Enums with JPA and SpringBoot


What are Enums?

Enums are a type of list that contains constants. You should use an enum when you need a predeterminated collection of values that represent numeric or textual data.(It has to be small set of possible values)



First create the Enum file.


Then added enums to the relevent entity



Want to set the staus as A when inserting the data and updating the data, and want to set status as D when calling the delete method.(When calling the delete method the data set will not be deleted from the database, what happens here is the status is set as D)


When calling save() and update() methods:




Whan calling delete() method:





Now data stores in the admin table like this:



Post a Comment

0 Comments