2

在 Glassfish v3 中使用 jdbcrealm 时,我必须如何严格遵循有关表格的建议?目前我有以下设置:

CREATE TABLE roles (
    id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
    username VARCHAR(255) NOT NULL,
    rolename VARCHAR(255) NOT NULL,     
);

CREATE TABLE users (
id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, 
    username VARCHAR(255) PRIMARY KEY NOT NULL,
    password VARCHAR(255) NOT NULL, 
    firstname VARCHAR(255),
    lastname VARCHAR(255),  
    email VARCHAR(255),
    status VARCHAR(255),
    role_id INTEGER,
    CONSTRAINT FOREIGN KEY(role_id) REFERENCES roles(id)    
);

是否可以在不更改任何内容的情况下使用此设置来创建 jdbcrealm 或者我必须更改我的表?

提前致谢!

4

1 回答 1

2

Have you tried it? It seems ok. The strange thing with the jdbcRealm is that it expects an unnormalized database, one would like something more like:

user (userid, username, passw, ...)
security_group (security_groupid, name)
user_in_group (user_in_groupid, userid, security_groupid)

Wich is more normalized. However this setup does not work. But if you're like me and think this should work take a look at the lovely custom Flexible JDBC Realm. It worked for me.

于 2010-12-28T21:37:35.400 回答