tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ◙ Ludovic BERT ◙ <ludovic.b...@gmail.com>
Subject More Flexible DataSourceRealm
Date Thu, 30 Sep 2010 21:50:59 GMT
Dear,

I have developed a more flexible DataSourceRealm than the one provided in
standard with Tomcat. This new DataSourceRealm is strictly the same than the
one which is provided in standard, the difference is only in the way to
configure it.

This new realm does not expect several parameters for tables and for columns
to generate the 2 prepared statements but expect the prepared statements in
its configuration, so it gives more flexibility because, it can be plugged
on any kind of DB schema which was not possible with the previous realm.

For instance the previous realm could not plug to a complex DB schema like
the following:

CREATE TABLE USERS(
USR_UID BIGINT,
 USR_LOGIN VARCHAR(32) NOT NULL,
USR_PASSWORD VARCHAR(256) NOT NULL,
USR_FIRSTNAME VARCHAR(128) NOT NULL,
 USR_LASTNAME VARCHAR(128) NOT NULL,
URR_EMIL VARCHAR(256) NOT NULL,
CONSTRAINT USERS_PK PRIMARY KEY (USR_UID),
 CONSTRAINT UNIQUE_USR_LOGIN UNIQUE (USR_LOGIN)
);

CREATE TABLE GROUPS(
GRP_UID BIGINT,
 GRP_NAME VARCHAR(32) NOT NULL,
GRP_DESCRIPTION VARCHAR(256) NOT NULL,
CONSTRAINT GROUPS_PK PRIMARY KEY (GRP_UID),
 CONSTRAINT UNIQUE_GRP_NAME UNIQUE (GRP_NAME)
);

CREATE TABLE ROLES(
ROL_UID BIGINT,
 ROL_NAME VARCHAR(32) NOT NULL,
ROL_DESCRIPTION VARCHAR(256) NOT NULL,
CONSTRAINT ROLES_PK PRIMARY KEY (ROL_UID),
 CONSTRAINT UNIQUE_ROL_NAME UNIQUE (ROL_NAME)
);

CREATE TABLE USER_ROLE(
USR_UID BIGINT,
 ROL_UID BIGINT,
CONSTRAINT USER_ROLE_PK PRIMARY KEY(USR_UID, ROL_UID),
CONSTRAINT USER_ROLE_FK_USERS FOREIGN KEY(USR_UID) REFERENCES
USERS(USR_UID),
 CONSTRAINT USER_ROLE_FK_ROLES FOREIGN KEY(ROL_UID) REFERENCES
ROLES(ROL_UID)
);

CREATE TABLE GROUP_ROLE(
GRP_UID BIGINT,
 ROL_UID BIGINT,
CONSTRAINT GROUP_ROLE_PK PRIMARY KEY(GRP_UID, ROL_UID),
CONSTRAINT GROUP_ROLE_FK_GROUPS FOREIGN KEY(GRP_UID) REFERENCES
GROUPS(GRP_UID),
 CONSTRAINT GROUP_ROLE_FK_ROLES FOREIGN KEY(ROL_UID) REFERENCES
ROLES(ROL_UID)
);

CREATE TABLE USER_GROUP(
USR_UID BIGINT,
 GRP_UID BIGINT,
CONSTRAINT USER_GROUP_PK PRIMARY KEY(USR_UID, GRP_UID),
CONSTRAINT USER_GROUP_FK_USERS FOREIGN KEY(USR_UID) REFERENCES
USERS(USR_UID),
 CONSTRAINT USER_GROUP_FK_GROUPS FOREIGN KEY(GRP_UID) REFERENCES
GROUPS(GRP_UID)
);


With this new implementation, it is now possible to plug on any kind of DB
schema.

Please find enclosed the sources of this new data source realm
(DataSourceRealm2) to be adapted (very small evolution only renaming the
package name).

Let me know if you're interested.

Best regards,
Ludovic

Mime
View raw message