Spring Security 标准表字段 VS Hibernate 必填字段
对标准 Spring Security
表字段进行更改是否可以接受? http://static.springsource。 org/spring-security/site/docs/3.0.x/reference/appendix-schema.html
特别是,Hibernate
要求我添加 id
字段对于这些表:
users
authorities
例外:
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): model.Authorities
这意味着,我应该将 id 字段添加到我的模型 bean 中,并将以下配置添加到 *hbm.xml
:
<id name="id">
<generator class="assigned"/>
</id>
最佳实践是什么?
我应该更改 Spring Security DB 表结构还是以某种方式处理 Hibernate?
Is it acceptable to make changes to standard Spring Security
table fields?
http://static.springsource.org/spring-security/site/docs/3.0.x/reference/appendix-schema.html
In, particularly, Hibernate
required me to add id
field for these tables:
users
authorities
exception:
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): model.Authorities
That means,that I should add id fields to my model beans and following config to *hbm.xml
:
<id name="id">
<generator class="assigned"/>
</id>
What is the best practice?
Should I change Spring Security DB table structure or somehow deal with Hibernate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只要
JdbcDaoImpl
不受影响。即使您需要更改这些查询,也可以通过适当配置 JdbcDaoImpl 来完成。但是,也许最好创建
UserDetailsService
它将重用您的 DAO 来加载用户信息,并将 Spring Security 配置为将其用作It's fine as long as SQL queries issued by
JdbcDaoImpl
are not affected. And even if you need to change these queries, you can do it by configuringJdbcDaoImpl
appropriately.However, perhaps it would be better to create a custom implementation of
UserDetailsService
that would reuse your DAOs to load user information, and configure Spring Security to use it as