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:

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:

my questions:
- is there comprehensive list of ddl/schema changes old
@collectionofelementsnew@elementcollection? - is there recommended practice, or additional annotation can provide these properties, ensure backwards compatibility? (can specify specific name-mapping scheme or column name?)
- finally, assume
collectiontypes 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
Post a Comment