Looks like clash between standard Spring Security DB tables fields and requirements of Hibernate for fields,in particularly, id field.
From one side, have standard Spring tables(http://static.springsource.org/sprin...ix-schema.html):
these tables don't contain id fields.Code:create table users( username varchar_ignorecase(50) not null primary key, password varchar_ignorecase(50) not null, enabled boolean not null); create table authorities ( username varchar_ignorecase(50) not null, authority varchar_ignorecase(50) not null, constraint fk_authorities_users foreign key(username) references users(username)); create unique index ix_auth_username on authorities (username,authority);
From other side,have Hibernate configuration:
Code:<class name="model.Authorities" table="authorities"> <id name="username" column="username"/> <property name="authority" column="authority"/> <many-to-one name="userDetails" class="model.UserDetails" not-null="false" column="username"/> </class>Exception got:Code:<class name="model.UserDetails" table="users"> <id name="username" column="username"/> <property name="password" column="password"/> <property name="enabled" column="enabled"/> <set name="authorities" cascade="all" inverse="true"> <key column="username" not-null="true"/> <one-to-many class="model.Authorities"/> </set> </class>
Code:org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): model.Authorities
What is the best practice?
This case(in order to fix problem) I should add to Hibernate config following:
Should I make changes to standard Spring tables and add id fields there?Code:<id name="id"> <generator class="assigned"/> </id>
Is it acceptable or there is other more gracefull solution?


Reply With Quote