Saturday 15 February 2014

java - How to update hibernate entity when DDL update to add a new column is required -



java - How to update hibernate entity when DDL update to add a new column is required -

i have created application using struts2 , hibernate uploads excel file in database , perform other crud operations. alter requirement has come user should able command database schema ui means user should have ability add together new columns on fly through user interface whenever excel file has new columns within database.

i not sure how can accomplish updating database still leave entity class untouched.

to illustate issue consider situation: have ab excel file of employee 2 columns : name , roll number. create entity class

class student{ int id; string name; getters , setters }

using entity class can perform crud operations , upload excel file in database.

now do if need have new column in excel "age" , and "age" should created within database. , new column has added dynamically user interface.

is there way update entity on fly or there other way accomplish it.

my advice :

class student{ int id; string name; list<attribute> attributelist; getters , setters } class attribute { int id; string key; object value; }

with onetomany relationship between students , attributes should have no issues having dynamic fields in students.

hope helps!

java hibernate

No comments:

Post a Comment