-->
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.  [ 6 posts ] 
Author Message
 Post subject: org.hibernate.MappingException: Unknown entity
PostPosted: Thu Dec 13, 2007 1:03 pm 
Newbie

Joined: Wed Dec 12, 2007 1:58 pm
Posts: 5
Hi all,

I try to insert a row in the table, but i get this error message:

Hibernate version: hibernate-3.2.5.ga

Java code:

Code:
public class TestUser {
   public static void main(String[] args) {
      Configuration conf = new AnnotationConfiguration();
      conf.configure();
      SessionFactory factory = conf.buildSessionFactory();
      Session session = factory.openSession();
      User u = new User();
      u.setUser("admin");
      u.setPasswd("admin");
      Transaction t = session.beginTransaction();
      session.save(u);
      t.commit();
      session.close();
   }
}



Console output:

Quote:
14:57:49,984 DEBUG DefaultSaveOrUpdateEventListener:158 - saving transient instance
Exception in thread "main" org.hibernate.MappingException: Unknown entity: br.org.xxxxxxxx.jdbc.model.User
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at br.org.xxxxxxxx.hibernate.TestUser.main(TestUser.java:21)
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 13, 2007 11:21 pm 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
This exception happens when you try to save a class which has no mapping. May be you forget to create a mapping file or you did not include your mapping file in the hibernate.cfg.xml.

http://www.laliluna.de/253.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 14, 2007 6:21 am 
Newbie

Joined: Wed Dec 12, 2007 1:58 pm
Posts: 5
Mapping? what mapping do you mean?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 15, 2007 10:45 am 
Newbie

Joined: Tue Nov 27, 2007 6:11 am
Posts: 12
eduacsp wrote:
Mapping? what mapping do you mean?


You have to specify in the hibernate config file the mapping about each entity that hibernate should manage persistently. For instance in the hibernate config file you should have a line like the following:

<mapping resource="Person.hbm.xml"/>

where Person.hbm.xml contains the mapping definition of a (Person) class.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 15, 2007 11:32 am 
Newbie

Joined: Wed Dec 12, 2007 1:58 pm
Posts: 5
cat4hire wrote:
eduacsp wrote:
Mapping? what mapping do you mean?


You have to specify in the hibernate config file the mapping about each entity that hibernate should manage persistently. For instance in the hibernate config file you should have a line like the following:

<mapping resource="Person.hbm.xml"/>

where Person.hbm.xml contains the mapping definition of a (Person) class.



Even with hibernate 3????


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 17, 2007 7:01 am 
Newbie

Joined: Wed Dec 12, 2007 1:58 pm
Posts: 5
eduacsp wrote:
cat4hire wrote:
eduacsp wrote:
Mapping? what mapping do you mean?


You have to specify in the hibernate config file the mapping about each entity that hibernate should manage persistently. For instance in the hibernate config file you should have a line like the following:

<mapping resource="Person.hbm.xml"/>

where Person.hbm.xml contains the mapping definition of a (Person) class.



Even with hibernate 3????


i create the hbm.xml file, but the error persists. :(


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