i got 3 tables named, address, lookup_code,state
CREATE TABLE `address` (
`OID` varchar(35) NOT NULL default '',
`ADDRESS_TYPE_OID` varchar(35) default NULL,
`ADDRESS_LINE_1` varchar(25) NOT NULL default '',
`ADDRESS_LINE_2` varchar(25) default NULL,
`STREET_TYPE_OID` varchar(35) default NULL,
`UNIT_NUMBER` varchar(15) default NULL,
`CITY` varchar(25) NOT NULL default '',
`STATE_OID` varchar(35) NOT NULL default '',
`ZIP` varchar(10) NOT NULL default '',
`CREATE_DTM` datetime NOT NULL default '0000-00-00 00:00:00',
`UPDATE_DTM` datetime NOT NULL default '0000-00-00 00:00:00',
`CREATED_BY` varchar(35) NOT NULL default '',
`UPDATED_BY` varchar(35) NOT NULL default '',
PRIMARY KEY (`OID`),
UNIQUE KEY `XPKADDRESS` (`OID`),
KEY `XIF89ADDRESS` (`ADDRESS_TYPE_OID`),
KEY `XIF90ADDRESS` (`STREET_TYPE_OID`),
KEY `XIF91ADDRESS` (`STATE_OID`),
CONSTRAINT `0_222` FOREIGN KEY (`STATE_OID`) REFERENCES `state` (`OID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `0_224` FOREIGN KEY (`STREET_TYPE_OID`) REFERENCES `lookup_code` (`OID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `0_226` FOREIGN KEY (`ADDRESS_TYPE_OID`) REFERENCES `lookup_code` (`OID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) TYPE=InnoDB;
CREATE TABLE `lookup_code` (
`OID` varchar(35) NOT NULL default '',
`TYPE` varchar(15) NOT NULL default '',
`LABEL` varchar(255) NOT NULL default '',
`WEIGHT` int(11) default NULL,
`VALUE` float default NULL,
PRIMARY KEY (`OID`),
UNIQUE KEY `XPKLOOKUP_CODE` (`OID`)
) TYPE=InnoDB;
CREATE TABLE `state` (
`OID` varchar(35) NOT NULL default '',
`STATE_CD` char(2) NOT NULL default '',
`STATE_NAME` varchar(35) NOT NULL default '',
`CREATE_DTM` datetime NOT NULL default '0000-00-00 00:00:00',
`UPDATE_DTM` datetime NOT NULL default '0000-00-00 00:00:00',
`CREATED_BY` varchar(35) NOT NULL default '',
`UPDATED_BY` varchar(35) NOT NULL default '',
PRIMARY KEY (`OID`),
UNIQUE KEY `XPKSTATE` (`OID`)
) TYPE=InnoDB;
and here are my hbm files
AddressVO.hbm.xml
<class name="com.test.vo.AddressVO" table="address">
<id name="oid" type="string" column="OID" >
<generator class="assigned" />
</id>
<property name="addressTypeOid" type="string" column="ADDRESS_TYPE_OID" length="35" />
<property name="addressLine1" type="string" column="ADDRESS_LINE_1" not-null="true" length="25" />
<property name="addressLine2" type="string" column="ADDRESS_LINE_2" length="25" />
<property name="streetTypeOid" type="string" column="STREET_TYPE_OID" length="35" />
<property name="unitNumber" type="string" column="UNIT_NUMBER" length="15" />
<property name="city" type="string" column="CITY" not-null="true" length="25" />
<property name="stateOid" type="string" column="STATE_OID" not-null="true" length="35" />-->
<property name="zip" type="string" column="ZIP" not-null="true" length="10" />
<property name="createDtm" type="timestamp" column="CREATE_DTM" not-null="true" length="19" />
<property name="updateDtm" type="timestamp" column="UPDATE_DTM" not-null="true" length="19" />
<property name="createdBy" type="string" column="CREATED_BY" not-null="true" length="35" />
<property name="updatedBy" type="string" column="UPDATED_BY" not-null="true" length="35" />
<!-- associations -->
<many-to-one name="addressTypeOid" class="com.test.vo.LookupCodeBean" column="ADDRESS_TYPE_OID" update="false" insert="false" />-
<many-to-one name="streetTypeOid" class="com.test.vo.LookupCodeBean" ccolumn="STREET_TYPE_OID" update="false" insert="false" />-
<many-to-one name="stateOid" class="com.test.vo.StateVO" column name="oid" not-null="true" update="false" insert="false" />
</class>
</hibernate-mapping>
LookupCodeBean.hbm.xml
<hibernate-mapping>
<class name="com.test.vo.LookupCodeBean" table="lookup_code">
<id name="oid" type="string" column="OID" length="32" >
<generator class="assigned"/>
</id>
<property name="label" column="TYPE" type="string" length="15" not-null="true" />
<property name="type" column="LABEL" type="string" length="255" not-null="true" />
<property name="weight" column="WEIGHT" type="integer" length="11" not-null="false" />
<property name="value" column="VALUE" type="double" length="12" not-null="false" />
</class>
</hibernate-mapping>
StateVO.hbm.xml
<hibernate-mapping>
<class name="com.aib.vo.StateVO" table="state">
<id name="oid" type="string" column="OID" >
<generator class="assigned" />
</id>
<property name="stateCd" type="string" column="STATE_CD" not-null="true" length="2" />
<property name="stateName" type="string" column="STATE_NAME" not-null="true" length="35" />
<property name="createDtm" type="timestamp" column="CREATE_DTM" not-null="true" length="19" />
<property name="updateDtm" type="timestamp" column="UPDATE_DTM" not-null="true" length="19" />
<property name="createdBy" type="string" column="CREATED_BY" not-null="true" length="35" />
<property name="updatedBy" type="string" column="UPDATED_BY" not-null="true" length="35" />
<!-- associations -->
</class>
</hibernate-mapping>
when i am trying to insert in to address table using
Transaction tx=null;
Session sess=null;
String addOID="";
sess=getSession();
tx=sess.beginTransaction();
addVO.toValues();
addOID=(String)sess.save(addVO);
sess.flush();
tx.commit();
When i try to insert with all the refernces i get this error
No persister for: java.lang.String
any help.. with this!!![/b]
|