简体   繁体   English

如何在Glassfish 3.0中配置jdbc领域

[英]How to configure a jdbc realm in glassfish 3.0

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. 我正在遵循本教程,我发现http://www.vitruvimente.be/?p=768创建了JDBC领域,因此我可以在Web应用程序上登录和注销用户,但是我遇到了问题。

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. 但是我在不同的类中有3种不同类型的用户(Admin,Buyer,Seller),我没有一个称为用户的类,因为它们的属性非常不相关。 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)? 我的问题是,我应该在glassfish新领域页面(localhost:4848)上添加哪些设置? Can somebody give me some tips on how to configure this realm? 有人可以给我一些有关如何配置此领域的提示吗?

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. 我在不同的类中有3种不同类型的用户(管理员,买方,卖方),我没有一个称为用户的类,因为它们的属性非常不相关。

There's something wrong in your model design. 您的模型设计有问题。 You should really have a single table User with at least the login name and password. 您实际上应该有一个表User ,至少包含登录名和密码。 For the more specific user roles, you need a table Role . 对于更特定的用户角色,您需要一个表Role To relate them to each other, have a join table User_Role (which you map in Java as a Set<Role> in User entity). 要将它们彼此关联,请具有一个User_RoleUser_Role (您可以在Java User_Role其映射为User实体中的Set<Role> )。 For the buyer/seller part it makes sense to have a Product table with a FK to User (the seller) and an Order table with a FK to User (the buyer) and Product (the ordered item). 对于买方/卖方一部分是有意义的有一个Product表与FK到User (卖方)和Order表与FK到User (买方)和Product (有序的项目)。

After all, you should end up with a single User table/model which you could then just map in the realm. 毕竟,您应该最终得到一个User表/模型,然后可以将其映射到领域中。

如果您已经按照BalusC的建议更改了模型,那么我会在这里推荐这个很好的教程来使用glassfish设置JDBC领域

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM