hello,

i am new to OJB. i hope i can help some helps from here...
my problem is as followed:

i want to make a M:N relational mapping between two tables User and Role. so
my repository-user.xml
is such followed

<class-descriptor
        class="my.com.shinyang.eply.model.User"
        table="USERS">

      <field-descriptor
        name="label"
        column="LABEL"
        jdbc-type="VARCHAR"
        primarykey="true"
      />

      <field-descriptor
        name="password"
        column="PASSWORD"
        jdbc-type="VARCHAR"
      />

      <field-descriptor
        name="fullName"
        column="FULLNAME"
        jdbc-type="VARCHAR"
      />

      <field-descriptor
        name="designation"
        column="DESIGNATION"
        jdbc-type="VARCHAR"
      />

      <collection-descriptor
        name="roleList"
        element-class-ref="my.com.shinyang.eply.model.Role"
        auto-retrieve="true"
        auto-update="false"
        auto-delete="false"
        indirection-table="USERS_ROLES">
                <fk-pointing-to-this-class column="USERS_LABEL"/>
                <fk-pointing-to-element-class column="ROLES_LABEL"/>
      </collection-descriptor>
    </class-descriptor>

    <class-descriptor
     class="my.com.shinyang.eply.model.Role"
     table="ROLES">

        <field-descriptor
                name="label"
                column="LABEL"
                jdbc-type="VARCHAR"
                primarykey="true"
        />
        <field-descriptor
                name="roleName"
                column="ROLE_NAME"
                jdbc-type="VARCHAR"
        />
        <field-descriptor
                name="allowCreate"
                column="ALLOWCREATE"
                jdbc-type="INTEGER"
        />
        <field-descriptor
                name="allowSearch"
                column="ALLOWSEARCH"
                jdbc-type="INTEGER"
        />
        <field-descriptor
                name="allowEdit"
                column="ALLOWEDIT"
                jdbc-type="INTEGER"
        />
        <field-descriptor
                name="allowDelete"
                column="ALLOWDELETE"
                jdbc-type="INTEGER"
        />

        <collection-descriptor
         name="userList"
         element-class-ref="my.com.shinyang.eply.model.User"
         auto-retrieve="true"
         auto-update="false"
         auto-delete="false"
         indirection-table="USERS_ROLES"
        >
         <fk-pointing-to-this-class column="ROLES_LABEL"/>
         <fk-pointing-to-element-class column="USERS_LABEL"/>
      </collection-descriptor>

    </class-descriptor>

i created three tables with DDL, BTW i am using mysql as my persistence.

drop table if exists USERS;
CREATE TABLE USERS (
  LABEL varchar(25) NOT NULL default '',
  PASSWORD varchar(25) NOT NULL default '',
  FULLNAME varchar(25) default '',
  DESIGNATION varchar(25) default '',
  PRIMARY KEY  (LABEL)
) TYPE=MyISAM;

drop table if exists USERS_ROLES;
CREATE TABLE USERS_ROLES (
  USERS_LABEL varchar(25) NOT NULL default '',
  ROLES_LABEL varchar(25) NOT NULL default ''
) TYPE=MyISAM;

drop table if exists ROLES;
CREATE TABLE ROLES (
  LABEL varchar(100) NOT NULL default '0',
  ROLE_NAME varchar(100) NOT NULL default '',
  ALLOWCREATE tinyint(4) NOT NULL default '0',
  ALLOWSEARCH tinyint(4) NOT NULL default '0',
  ALLOWEDIT tinyint(4) NOT NULL default '0',
  ALLOWDELETE tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (LABEL)
) TYPE=MyISAM;

then, i have make a test case. then result as such.

2003-10-15 08:09:04,038 INFO
[my.com.shinyang.eply.service.ejb.UserSessionBean] LRB is created
2003-10-15 08:09:04,225 ERROR [STDERR] Query    "SET autocommit=0"      execution
time:   0
2003-10-15 08:09:04,225 ERROR [STDERR] Query    "SELECT
A0.LABEL,A0.PASSWORD,A0.FULLNAME,A0.DESIGNATION FROM USERS A0 WHERE A0.LABEL
=  'yenonn' "   execution time: 0       result set fetch time:  0
2003-10-15 08:09:04,241 ERROR [STDERR] Query    "SELECT
A0.ROLE_NAME,A0.ALLOWDELETE,A0.LABEL,A0.ALLOWCREATE,A0.ALLOWSEARCH,A0.ALLOWE
DIT FROM ROLES A0,USERS_ROLES WHERE (USERS_ROLES.USERS_LABEL =  'yenonn' )
AND USERS_ROLES.ROLES_LABEL = A0.LABEL" execution time: 0       result set fetch
time:   0
2003-10-15 08:09:04,272 ERROR [STDERR] Query    "commit"        execution time: 0
2003-10-15 08:09:04,272 ERROR [STDERR] Query    "SET autocommit=1"      execution
time:   0
2003-10-15 08:09:04,272 ERROR [STDERR] Query    "SHOW VARIABLES LIKE
'tx_isolation'" execution time: 0       result set fetch time:  0
2003-10-15 08:11:35,803 ERROR [STDERR] Query    "SET autocommit=0"      execution
time:   0
2003-10-15 08:11:35,819 ERROR [STDERR] Query    "SELECT
A0.LABEL,A0.PASSWORD,A0.FULLNAME,A0.DESIGNATION FROM USERS A0 WHERE A0.LABEL
=  'yenonn' "   execution time: 0       result set fetch time:  16
2003-10-15 08:11:35,866 ERROR [STDERR] Query    "SELECT
LABEL,PASSWORD,FULLNAME,DESIGNATION FROM USERS WHERE LABEL = 'yenonn' "
execution time: 0       result set fetch time:  0
2003-10-15 08:11:35,866 ERROR [STDERR] Query    "SELECT
ROLE_NAME,ALLOWDELETE,LABEL,ALLOWCREATE,ALLOWSEARCH,ALLOWEDIT FROM ROLES
WHERE LABEL = '121' "   execution time: 0       result set fetch time:  0
2003-10-15 08:11:35,881 ERROR [STDERR] Query    "SELECT
ROLE_NAME,ALLOWDELETE,LABEL,ALLOWCREATE,ALLOWSEARCH,ALLOWEDIT FROM ROLES
WHERE LABEL = '122' "   execution time: 0       result set fetch time:  0
2003-10-15 08:11:35,944 ERROR [STDERR] Query    "INSERT INTO USERS
(LABEL,PASSWORD,FULLNAME,DESIGNATION) VALUES
('yenonn','yenonn','yenonn','yenonn') " execution time: 0
2003-10-15 08:11:35,944 ERROR [STDERR] Query    "SELECT ROLES_LABEL FROM
USERS_ROLES WHERE USERS_LABEL='yenonn'" execution time: 0       result set fetch
time:   0
2003-10-15 08:11:35,960 ERROR [STDERR] Query    "INSERT INTO USERS_ROLES
(USERS_LABEL,ROLES_LABEL) VALUES ('yenonn','121')"      execution time: 0
2003-10-15 08:11:35,960 ERROR [STDERR] Query    "INSERT INTO USERS_ROLES
(USERS_LABEL,ROLES_LABEL) VALUES ('yenonn','122')"      execution time: 0
2003-10-15 08:11:35,960 ERROR [STDERR] Query    "INSERT INTO ROLES
(LABEL,ROLE_NAME,ALLOWCREATE,ALLOWSEARCH,ALLOWEDIT,ALLOWDELETE) VALUES
('121','admin',1,1,1,1) "       execution time: 0
2003-10-15 08:11:35,960 ERROR [STDERR] Query    "DELETE FROM USERS_ROLES WHERE
ROLES_LABEL='121'"      execution time: 0
2003-10-15 08:11:35,960 ERROR [STDERR] Query    "INSERT INTO ROLES
(LABEL,ROLE_NAME,ALLOWCREATE,ALLOWSEARCH,ALLOWEDIT,ALLOWDELETE) VALUES
('122','admin',1,1,1,1) "       execution time: 0
2003-10-15 08:11:35,960 ERROR [STDERR] Query    "DELETE FROM USERS_ROLES WHERE
ROLES_LABEL='122'"      execution time: 0
2003-10-15 08:11:35,975 ERROR [STDERR] Query    "commit"        execution time: 0
2003-10-15 08:11:35,975 ERROR [STDERR] Query    "SET autocommit=1"      execution
time:   0
2003-10-15 08:11:35,975 ERROR [STDERR] Query    "SHOW VARIABLES LIKE
'tx_isolation'" execution time: 0       result set fetch time:  0

the related information is persisted into a User and Role table, but,
Users_Roles tables are not persisted any foreign key of
both tables from User and Role.

Moreover, i discover that the Delete statement is executed (i highlighted in
red color)there after the insertion is done to the Users_Roles table.
so, why the deletion is executed to my Users_Roles table?? pls, notify...as
soon as possible.... thanks....



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to