如何在 glassfish 3.0 中配置 jdbc 领域
我正在按照本教程找到 http://www.vitruvimente.be/?p=768 创建一个 JDBC 领域,这样我就可以在我的 Web 应用程序上登录和退出我的用户,但我有一个问题。
但我在不同的类中有 3 种不同类型的用户(管理员、买家、卖家),我没有一个名为用户的类,因为它们的属性非常不相关。 我在教程中看到他们添加了一个名为 user-table 的属性,我应该在那里添加什么?
我的问题是,我应该在 glassfish 新领域页面(localhost:4848)添加什么设置? 有人可以给我一些关于如何配置这个领域的提示吗?
I am following this tutorial i found http://www.vitruvimente.be/?p=768 to create a JDBC realm, so i can login and out my users on my web app, but i have a problem.
But i have 3 different types of users in different classes(Admin,Buyer,Seller) I dont have a single class called users because their attributes are very unrelated.
I see in the tutorial they add a property called user-table, whay should i add there?
My question, is what settings should i add at the glassfish new realm page(localhost:4848)?
Can somebody give me some tips on how to configure this realm?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的模型设计有问题。您实际上应该有一个表
User
,其中至少包含登录名和密码。对于更具体的用户角色,您需要一个表Role
。要将它们相互关联,需要有一个连接表User_Role
(在 Java 中将其映射为User
实体中的Set
)。对于买方/卖方部分,有一个带有 FK 的Product
表和一个带有User
(卖方)的Order
表是有意义的。 FK 至User
(买家)和Product
(订购的商品)。毕竟,您最终应该得到一个
User
表/模型,然后您可以将其映射到领域中。There's something wrong in your model design. You should really have a single table
User
with at least the login name and password. For the more specific user roles, you need a tableRole
. To relate them to each other, have a join tableUser_Role
(which you map in Java as aSet<Role>
inUser
entity). For the buyer/seller part it makes sense to have aProduct
table with a FK toUser
(the seller) and anOrder
table with a FK toUser
(the buyer) andProduct
(the ordered item).After all, you should end up with a single
User
table/model which you could then just map in the realm.如果您按照 BalusC 的建议更改了模型,我会推荐这个 这里是关于使用 glassfish 设置 JDBC 领域的好教程。
If you have changed your model as suggested by BalusC, I would recommend this good tutorial here for setting up a JDBC realm with glassfish.