Hi,
I have two tables user and realm with the below mentioned structures
Realm Table
create table REALM (ur_id INT(18) NOT NULL AUTO_INCREMENT,ur_name varchar(200) UNIQUE NOT NULL, PRIMARY KEY (ur_id));
User Table
Create table USER (usr_id INT(18) NOT NULL AUTO_INCREMENT,usr_user_id varchar(200) UNIQUE NOT NULL,usr_urlm_id INT(18) PRIMARY KEY (usr_id));
alter table USER add constraint usersFK0 foreign key (usr_urlm_id ) references SEC_USER_REALM (ur_id)
It is a simple web based app,lication which uses mysql as the database
When we create the user with this structure, we get the realm name and user name as a string from the GUI where as the prioary keys are integer s as the primary key fields are auto generated
My question is how do u model them using the hibernate mapping file ..
the following are the corresponding mapping files
[code]
Realm.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.comverse.rtbd.security.dbaccess.IdentityManagement.UserRealm" table="REALM">
<id name="urId" column="UR_ID" type="int">
<generator class="assigned" />
</id>
<property name="urName" column="ur_name" type="string" not-null="true" />
<set name="users" cascade="all-delete-orphan" lazy="true" inverse="true">
<key column="usr_urlm_id" />
<one-to-many class="com.comverse.rtbd.security.dbaccess.IdentityManagement.User" />
</set>
</class>
</hibernate-mapping>
User.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.comverse.rtbd.security.dbaccess.IdentityManagement.User" table="sec_ccbs_user">
<id name="usrId" column="usr_id" type="int">
<generator class="assigned" />
</id>
<property name="usrUrlmId" column="usr_urlm_id" not-null="true" />
<property name="usrUserId" column="usr_user_id" type="string" not-null="true" />
<many-to-one name="usrUrlmId" column="usr_urlm_id" class="com.comverse.rtbd.security.dbaccess.IdentityManagement.UserRealm" cascade="save-update" />
</class>
</hibernate-mapping>
However, i always get a exception the Inavlis argumemnt exception when i execute the same .Please help me in solving this bug
[/code]
|