jpa - Hibernate: Adding versioning to a non versioned DB -


i created db time ago using hibernate (jpa), didn't included @version fields entities. turns out project became important , need use versioning (versioning optimistic locking).

i know need add new property (field) every single entity @version annotation.

question: know how can update real db (mysql) include version columns without data loss , work?

thanks much.

create sql statement create column tables of entities want , @version attribute. use other query set value of columns rows 1.

an little bit other way create column default value, , remove default. (works mysql)

alter table xyz add version integer not null default 1; alter table xyz change version version integer not null; 

the purpuse of approach long not run second statement (remove default), old application run, if not set value version column when creates new objects.


Comments

Popular posts from this blog

c# - BasicHttpBinding equivalent CustomBinding using WCF Client and PHP WebService -

sql server - python to mssql encoding problem -

java - SNMP4J General Variable Binding Error -