Spring Security 标准表字段 VS Hibernate 必填字段

发布于 2024-12-20 08:11:13 字数 820 浏览 4 评论 0原文

对标准 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你与清晨阳光 2024-12-27 08:11:13

只要 JdbcDaoImpl 不受影响。即使您需要更改这些查询,也可以通过适当配置 JdbcDaoImpl 来完成。

但是,也许最好创建 UserDetailsS​​ervice 它将重用您的 DAO 来加载用户信息,并将 Spring Security 配置为将其用作

<security:authentication-provider user-service-ref = "..." />

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 configuring JdbcDaoImpl 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

<security:authentication-provider user-service-ref = "..." />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文