Creating an entity class for your Spring project can be easy if you have a finite number of columns in your database table. If they have more number of columns then the task becomes bit hard and can take up more time to complete creating one.
I have developed an online tool, which takes your table description (I will tell you how to get it here) and prepares an entity class for you instantly.
All you need to do is to run “table desc” query to get the table description and use the below tool to generate the entity class instantly.
What is a table desc?
A sample “table desc” is shown below for your reference. The DESC keyword followed by the table run in a sql query window will give you description of your table. This description contains the list of columns, its attributes such as data type, column size, and information such as whether a column is unique or not and so on.
sql > sql > desc user; Output: Name Null Type ID Not Null INT NAME CHAR(25) CITY VARCHAR2(25)
The above tool will take the desc query from you and create an entity Java class. The list of class member fields should be the columns present in the desc content. Data type will be appropriately be the same and nearer to the same as against each mentioned columns.
In addition to the regular data columns, a table may have an auto generated ID column marked within the content and would have a NON-NULL auto-increment label marked against such column. If such column found on the content, then the tool should add the column as a field with an annotation of “auto-generated” to it.
Please note that this implementation of special columns as a field in Java entity follows some standard as defined by their respective specifications. The tool has the common standard that most people use these days!
How useful was this post?
Click on a star to rate it!
Average rating 2.9 / 5. Vote count: 10
We are sorry that this post was not useful for you!
Let us improve this post!
Thanks for your feedback!