-->
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: net.sf.hibernate.MappingException: No persister for
PostPosted: Thu Aug 26, 2004 10:43 am 
Newbie

Joined: Thu Aug 26, 2004 10:12 am
Posts: 2
hello all,

i am getting a "net.sf.hibernate.MappingException: No persister for" error. Googling this error doesnt shed much light.

i get the error when attempting to compile the program listed below.

any suggestions would help.

greg


Hibernate version:
Hibernate 2.1.6

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping
PUBLIC "=//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.dom.well.Well" table="WELL">
<meta attribute="class-description">
Represents a single well in the GWS Database.
@author Gregory Smith
</meta>
<id name="primaryKey" type="int" column="WELL_SEQ">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>

<property name="title" type="string" not-null="true"/>
<property name="botttomHoleTemperature" type="double" not-null="false"/>
<property name="casingSize" type="double" not-null="false"/>
<property name="notificationPressure" type="double" not-null="false"/>
<property name="sandTop" type="double" not-null="false"/>
<property name="pluggedDate" type="date" not-null="false"/>
<property name="checkValve" type="string" not-null="false"/>
<property name="masterMeter" type="string" not-null="false"/>
<property name="meter" type="string" not-null="false"/>
<property name="plugged" type="string" not-null="false"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public static void main(String[] args) throws Exception {
Transaction tx = null;
Configuration config = new Configuration();
SessionFactory sessionFactory = config.buildSessionFactory();
Session session = sessionFactory.openSession();
try {
config.addClass(Well.class);
tx = session.beginTransaction();
Well well = new Well("first", 1.5, 2.4, 3.3, 4.3, new Date(), "Y", "N", "N", "Y");
session.save(well);
well = new Well("second", 1.5, 2.4, 3.3, 4.3, new Date(), "Y", "N", "N", "Y");
session.save(well);
well = new Well("third", 1.5, 2.4, 3.3, 4.3, new Date(), "Y", "N", "N", "Y");
session.save(well);
tx.commit();
} catch (Exception ex) {
ex.printStackTrace();
if (tx != null) {
try {
tx.rollback();
} catch (Exception ex2) {
ex2.printStackTrace();
}
}
} finally {
session.close();
}
sessionFactory.close();
}

Full stack trace of any exception that occurs:
[java] 10:36:27,640 INFO SessionFactoryObjectFactory:82 - Not binding fact
ory to JNDI, no JNDI name configured
[java] 10:36:27,687 INFO Configuration:350 - Mapping resource: com/dom/wel
l/Well.hbm.xml
[java] 10:36:27,890 INFO Binder:229 - Mapping class: com.dom.well.Well ->
WELL
[java] net.sf.hibernate.MappingException: No persister for: com.dom.well.Well
[java] at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(Session
FactoryImpl.java:347)
[java] at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionIm
pl.java:2690)
[java] at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.ja
va:2697)
[java] at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier
(SessionImpl.java:763)
[java] at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
[java] at com.dom.well.WellTest.main(WellTest.java:21)
Name and version of the database you are using:
oracle 9i

Debug level Hibernate log excerpt:
n/a

_________________
greg


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 11:01 am 
Regular
Regular

Joined: Mon Feb 23, 2004 10:42 pm
Posts: 102
Location: Washington DC
Code:
Configuration config = new Configuration();
SessionFactory sessionFactory = config.buildSessionFactory();
Session session = sessionFactory.openSession();
try {
config.addClass(Well.class);
.
.
.


The configuration needs to be set before you build the sessionFactory.


[/code]

_________________
Matt Veitas


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 11:10 am 
Newbie

Joined: Thu Aug 26, 2004 10:12 am
Posts: 2
Code:
    public static void main(String[] args) throws Exception {
        Transaction tx = null;
        Configuration config = new Configuration();
        config.addClass(Well.class);
        SessionFactory sessionFactory = config.buildSessionFactory();
        Session session = sessionFactory.openSession();
        try {
            tx = session.beginTransaction();


i moved the config.addClass() and now it compiles. thanks matt.

_________________
greg


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.