-->
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: MappingException
PostPosted: Sat Jul 30, 2011 12:19 pm 
Newbie

Joined: Sat Jul 30, 2011 12:15 pm
Posts: 2
Hi All,

I am very new to Hibernate Framework.I have a small registration page which inserts data into the DB through hibernate cfg operation.In this process i am getting the below exception.Can somebody throw some light onto it of what might be the issue behind this.

SEVERE: org.hibernate.MappingException: Unknown entity: com.erm.beanmodules.UserAccountParameter

Thank you

regards,
Viswanadh.


Top
 Profile  
 
 Post subject: Re: MappingException
PostPosted: Sun Jul 31, 2011 1:55 pm 
Newbie

Joined: Sat Mar 26, 2011 8:57 am
Posts: 6
It looks like you havn't registered UserAccountParameter to the SessionFactory.

If you are using a config-file like hibernate.cfg.xml than insert this line:
<mapping class="com.erm.beanmodules.UserAccountParameter"/>

if you configure your SessionFactory through java use something like this:
... new Configuration().addClass(com.erm.beanmodules.UserAccountParameter.class);

Background:
Your SessionFactory needs to know all classes to handle with. Therefore you need to "register" all classes to the SessionFactory.
If you try to use Java-code like:

session.save(MyObject);

and MyObject.class is unknown for the SessionFactory, this exception will be thrown

R3van


Top
 Profile  
 
 Post subject: Re: MappingException
PostPosted: Mon Aug 01, 2011 2:14 pm 
Newbie

Joined: Sat Jul 30, 2011 12:15 pm
Posts: 2
Hi,

Thanks for the reply.I have tried in the below manner,still i observe the same problem.

My xml looks like this after adding mapping class tag.

Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
  <mapping class="com.erm.beanmodules.UserAccountParameter"/>
  <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/employeeresourcemanagement</property>
  <property name="hibernate.connection.username">root</property>
  <property name="hibernate.connection.password">myadmin</property>
  <property name="hibernate.connection.pool_size">100</property>
  <property name="hibernate.jdbc.batch_size">0</property>
  <property name="show_sql">true</property>
  <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  <property name="hibernate.hbm2ddl.auto">update</property>
  <!-- Mapping files -->
  <mapping resource="adminaccount.hbm.xml"/>
  <mapping resource="useraccount.hbm.xml"/>
</session-factory>
</hibernate-configuration>


2 xml files are mapped in resources one is with admin and the other is with useraccount which is creating is actual problem.

In the sessionfactory class i am using something like this.

Code:
sessionFact = new Configuration().configure().buildSessionFactory();


Could you please help me on the same..

regards,
Viswanadh.


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.