-->
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: one to one mapping
PostPosted: Mon Apr 15, 2013 5:40 am 
Newbie

Joined: Fri Apr 12, 2013 1:53 am
Posts: 18
I have two POJO classes (Student and Address) that has one to many mapping. The following is the Configuration code.

<?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.url">jdbc:mysql://localhost:3306/database1?zeroDateTimeBehavior=convertToNull</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</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="format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<mapping resource="/Student.hbm.xml"/>
<mapping resource="/Address.hbm.xml"/>
</session-factory>
</hibernate-configuration>

The folder structure is
Source Package
|
|______>Default Package
| |
| |_____>Address.hbm.xml
| |_____>Student.hbm.xml
| |_____>hibernate.cfg.xml
|
|_______>oomapping
| |
| |_____>Address.java(pojo class)
| |_____>Student.java(pojo class)
| |_____>OOMapping.java(main class>
|


Top
 Profile  
 
 Post subject: Re: one to one mapping
PostPosted: Mon Apr 15, 2013 7:13 am 
Beginner
Beginner

Joined: Thu May 17, 2007 9:56 am
Posts: 21
Location: India
Can you please state the problem you are facing?

_________________
Kuzhali


Top
 Profile  
 
 Post subject: Re: one to one mapping
PostPosted: Mon Apr 15, 2013 11:49 am 
Newbie

Joined: Fri Apr 12, 2013 1:53 am
Posts: 18
This is the error message I got:

INFO: Reading mappings from resource : /Student.hbm.xml
Failed to create sessionFactory object.org.hibernate.MappingNotFoundException: resource: /Student.hbm.xml not found
Exception in thread "main" java.lang.ExceptionInInitializerError
at oomapping.OOMapping.main(OOMapping.java:21)
Caused by: org.hibernate.MappingNotFoundException: resource: /Student.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:563)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at oomapping.OOMapping.main(OOMapping.java:18)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)


Top
 Profile  
 
 Post subject: Re: one to one mapping
PostPosted: Tue Apr 16, 2013 2:08 pm 
Regular
Regular

Joined: Wed Apr 10, 2013 1:02 am
Posts: 50
Please move you hbm files in the package oomapping and cfg in src directory I also verify if the cfg mapping to hbm is correct

_________________
Regards
Akash Miital
http://akash.thegrassroots.co.in/hibernate/


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.