-->
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.  [ 2 posts ] 
Author Message
 Post subject: Can't Initialize Hibernate Session Error ..
PostPosted: Wed Apr 14, 2004 11:52 am 
Newbie

Joined: Tue Mar 23, 2004 12:21 pm
Posts: 11
Hello All,
I have two database tables which are shown below:


TABLE 1 ~ maps to class1
postal code (PK)
location object id (FK)
.........
........
.........

TABLE2 ~ maps to class2
location object id (PK)
...........
...........
..........

table 1 has one to one relationship with table 2 and table 2 has one to many relation ship with table 1.

my config file for an entity corresponding to table 1 looks like the following:

---------------------------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="com.abc.managed.xyz.entity.Class1" table="Table1">
<id name="postalCode" column="POSTAL_CODE" type="String" unsaved-value="null" >
<generator class="assigned"/>
</id>
<property name="twcLocationId" column="TWC_LOCATION_ID" type="string" length="128" not-null="false"/>
<property name="lastModifyDate" column="LAST_MODIFY_DATE" type="date" not-null="false"/>
<one-to-one name="location" column="LOCATION_OBJECTID" class="com.abc.managed.xyz.entity.Class2" />
</class>
</hibernate-mapping>
---------------------------------------------------------------------------------

when I run mu code , I get an exception which i sshown below:
P.S -- last line of the exception trace says "columnn ame nust be added to element one-to-one but I already have column name added".

Any help is appreciated ...Thanks

--------------------------------------------------------------------------
DAOSession :: Can't Initialize Hibernate Session
net.sf.hibernate.MappingException: Error reading resource: com/abc/managed/xyz/entity/Class1.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:318)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:976)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:928)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:856)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:842)
at com.abc.managed.xyz.database.hibernate.DAOSession.init(DAOSession.java:41)
at com.xyz.managed.abc.database.hibernate.DAOSession.getDAOSessionInstance(DAOSession.java:108)
at com.xyz.managed.abc.database.hibernate.DataAccessObject.retrieveObjects(DataAccessObject.java:211)
at com.xyz.managed.abc.database.hibernate.TestingJunction.testMyCode(TestingJunction.java:78)
at com.xyz.managed.abc.database.hibernate.TestingJunction.main(TestingJunction.java:30)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:284)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:315)
... 9 more
Caused by: org.xml.sax.SAXParseException: Attribute "column" must be declared for element type "one-to-one".


--------------------------------------------------------------------------


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 15, 2004 6:58 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The messages says that <one-to-one> has _no_ column name, but you added one. Please read the reference documentation for the correct usage of one-to-one (you probably should also try to use a <many-to-one> in your case).

_________________
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.  [ 2 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.