-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: getting No persister for:java.lang.String error
PostPosted: Tue Feb 10, 2004 1:40 pm 
Newbie

Joined: Tue Feb 10, 2004 12:03 am
Posts: 16
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]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2004 1:45 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This mapping

<many-to-one name="addressTypeOid" class="com.test.vo.LookupCodeBean" column="ADDRESS_TYPE_OID" update="false" insert="false" />-

shows that you are probably not aware how Hibernate deals with class associations and you probably have a property named "addressTypeOid" of type "java.lang.String" in your Java class. Hibernate persists associations directly, no need to mess around with identifiers. Read one of the beginner tutorials linked on the website.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 1:49 am 
Newbie

Joined: Tue Feb 10, 2004 12:03 am
Posts: 16
i am still getting the same exception. can somebody point out , what exactly the problem is...

Thanks
in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 6:06 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The problem is that you don't know how to use Hibernate, basically. Please read one of the tutorials and please post more information if you ask questions, as described here:

http://www.hibernate.org/160.html

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.