java - maintain the order of column when creating a new table using hibernate -


this pojo annotated entity

@entity @table(name = "book", catalog = "book_db") public class book {     private integer bookid;     private string bookname;     private string bookshortdesc;     private string bookdesc;     private string bookauthor; } @id @generatedvalue(strategy = identity) @column(name = "book_id", unique = true, nullable = false) public integer getbookid() {     return this.bookid; }  @column(name = "book_name", nullable = false, length = 256) public string getbookname() {     return this.bookname; } @column(name = "book_short_desc", nullable = false, length = 1024) public string getbookshortdesc() {     return this.bookshortdesc; } 

etc......

the above entity created using annotation, when mysql database,the columns not created in order, have written below, instead , first columns book_id, book_desc, book_athor, book_short_desc book_name.

my question how can tell hibernate create columns same order have written in java code ??

is there annotation ??

regards

your code should never depend on ordering of columns in database. in fact, there technically no guarantee columns returned in particular order when select *. if want columns in particular order, specify in sql query.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -