-->
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 solve exceptions
PostPosted: Thu Apr 28, 2005 5:25 am 
Newbie

Joined: Thu Apr 28, 2005 5:11 am
Posts: 1
I am using mysql, I wrote a piece of code:

public class User {
private long userID;
private String userName;
private String password;
private String emailAddress;
...
}

public class HiTest {
public static void main(String[] args) throws Exception {
SessionFactory sf = cfg.buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
User user = new User();
user.setID(1);
user.setName("Somebody");
user.setPassword("password");
user.setEmailAddress("email@email.com");
session.save(user);
}


and have the exception:

.....
16:22:17,524 INFO SettingsFactory:203 - Query cache: disabled
16:22:17,534 INFO SettingsFactory:214 - Statistics: disabled
16:22:17,534 INFO SettingsFactory:218 - Deleted entity synthetic identifier rol
lback: disabled
16:22:17,534 INFO SettingsFactory:232 - Default entity-mode: pojo
16:22:17,844 INFO SessionFactoryImpl:140 - building session factory
16:22:17,864 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI,
no JNDI name configured
16:22:17,864 INFO SessionFactoryImpl:366 - Checking 0 named queries
Exception in thread "main" org.hibernate.MappingException: Unknown entity: User
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFacto
ryImpl.java:489)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:10
21)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId
(AbstractSaveEventListener.java:83)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGene
ratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrR
equestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTran
sient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(
DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpda
te(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:429)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:424)
at HiTest.main(HiTest.java:40)

Is it due to configuration or coding?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 8:20 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Have you mapped the user class? Show your mapping files.


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.