java - Upgrade to Hibernate4 and @ElementCollection results in inability to lookup existing data -


we have model class user had list<string> of permissions, so:

@lazycollection(lazycollectionoption.false) @collectionofelements @column() private list<string> permissions = collections.emptylist(); 

it produced sql table entry following:

user permissions before h4 upgrade

we upgraded hibernate 4, , @collectionofelements annotation has gone deprecated removed, figured time move on @elementcollection, so:

@lazycollection(lazycollectionoption.false) @elementcollection // << changed @column() private list<string> permissions = collections.emptylist(); 

upon launching, however, unable log in our administrative account. curious, examined database using h2's jar, , found table had been altered:

user permissions after

my questions:

  1. is there comprehensive list of ddl/schema changes old @collectionofelements new @elementcollection?
  2. is there recommended practice, or additional annotation can provide these properties, ensure backwards compatibility? (can specify specific name-mapping scheme or column name?)
  3. finally, assume collection types affected change - sets, maps, etc. want ensure don't leave data behind, or stone unturned, during our upgrade.

first question:

i don't know of any. jpa specification freely available , describes default table , column names are.

second question:

@elementcollection @collectiontable(name = "user_permissions"                  joincolumns = @joincolumn(name = "user_id")) @column(name = "element") private list<string> permissions = collections.emptylist(); 

i specify table , column names. avoids kind of surprise, allows me choose names want, , self-documentary. , prefer creating database schema , ddl myself. ensures required indices, constraints, comments, etc. created correctly.

third question: yes, nature of collection doesn't matter. see answer second question avoid these kinds of problems.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -