> Why is the user's name in the role's table assumed to have the same > column name as in the user's table? > > I think a lot of people already discussed about this topic, > and I know how to correctly manage the configuration, > but I still don't understand why this limitation has been introduced. > > I know I can easly extend the class > org.apache.catalina.realm.JDBCRealm > to add a new attribute and override the query used to retrieve the > user's roles > (this is what I've been doing) but I don't want to rebuilt my project > each time > I change the version of the application server just to be sure that my > class > extendes the correct class. > > Wouldn't be easyer to add an attribute "userRoleNameCol" to the > standard JDBCRealm > If that value is missing, than the column name can be supposed to be > equal to the > column name in the user's table. > > Note: I don't think it's right to write the DB according to what the > application server imposes! > Also because many times I develop applications based on the customer > DB, therefore I can > not change it! > A general DB structure, according to me, is:
users table; +-----------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+---------------+------+-----+---------+-------+ | us_name | varchar(16) | | PRI | | | | us_pwd | varchar(16) | | | | | +-----------+---------------+------+-----+---------+-------+ user roles table; +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | ur_user | varchar(16) | | PRI | | | | ur_role | varchar(16) | | PRI | | | +-----------+-------------+------+-----+---------+-------+