-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping Attribute
PostPosted: Tue Apr 16, 2013 6:01 am 
Newbie

Joined: Fri Apr 12, 2013 1:53 am
Posts: 18
I have two entities Student and Address which has one-to-one relation. I have done the mapping without using annotations. The following is the error I got while executing the file::::
Failed to create sessionFactory object.org.hibernate.MappingException: An association from the table student refers to an unmapped class: com.vaannila.student.Address
Exception in thread "main" java.lang.ExceptionInInitializerError
at oomapping.OOMapping.main(OOMapping.java:21)
Caused by: org.hibernate.MappingException: An association from the table student refers to an unmapped class: com.vaannila.student.Address
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1252)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1170)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at oomapping.OOMapping.main(OOMapping.java:18)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

The following is the code in Student.hbm.xml file::::
<hibernate-mapping>
<class name="oomapping.Student" table="student">
<meta attribute="class-description">This class contains student details.</meta>
<id name="id" type="int" column="student_id">
<generator class="native" />
</id>
<property name="studentName" type="string" not-null="true" length="100" column="student_name" />
<many-to-one name="studentAddress" class="oomapping.Address" column="STUDENT_ADDRESS" not-null="true" cascade="all" unique="true" />
</class>
</hibernate-mapping>


The following is the code in hibernate.cfg.xml file:::::
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/database1?zeroDateTimeBehavior=convertToNull</property>
<mapping resource="Student.hbm.xml"/>
<mapping resource="Address.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject: Re: Mapping Attribute
PostPosted: Wed Apr 17, 2013 5:49 am 
Newbie

Joined: Wed Apr 17, 2013 2:41 am
Posts: 4
Where do you have Address mapped?? It seems you donĀ“t mapped the other table


Top
 Profile  
 
 Post subject: Re: Mapping Attribute
PostPosted: Wed Apr 17, 2013 5:56 am 
Newbie

Joined: Fri Apr 12, 2013 1:53 am
Posts: 18
The mapping is between
Address.hbm.xml file to address
Student.hbm.xml file to student


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.