samedi 22 juin 2019

find correct column name by reflection when we have similar column name

I have a column name that is different from the correct name and I want to find the correct name.

In the writing of an entity, the field names are written in camel case But in some cases it should be used as a underline . Also, the column name may differ by the name of the field . for example :

1- private String bookCategory ;
2- private int book_id;
3-@Column(name = "writer")
  private String author;

Now if they give us the column name as the following:

1-bookcategory or BOOK category or book_kategory
2-book id or bookid or book_id 
3-author or writer 

How can I find the correct column name in the mysql database table?

*I have an entity class *I have get all fields name or column name by reflection and simplify them (such as bookcategory , bookid ) and compare with the name I received but this method is not optimal and should run well at many times.

So I'm looking for a better solution . please guide me .





Aucun commentaire:

Enregistrer un commentaire