-->
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.  [ 7 posts ] 
Author Message
 Post subject: Unknown Entity: Event Chapter 2 reference tutorial
PostPosted: Fri Sep 30, 2005 5:39 am 
Newbie

Joined: Fri Sep 30, 2005 5:32 am
Posts: 5
Hallo,
ich bin absoluter Neuling was hibernate angeht und versuche nun schon seit 2 Tagen das Reference tutorial mit dem EventManager zum laufen zu bringen.

Alle config und mapping files sind vorhanden.

Ich bekomme immer diesen fehler.

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.MappingException: Unknown entity: Event
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1086)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:83)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
at EventManager.createAndStoreEvent(EventManager.java:25)
at EventManager.main(EventManager.java:13)


Kann mir einer erklären was diese Exception unknown Entity bedeuten soll ?




Meine hibernate.cfg.xml

<?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>
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:data/tutorial</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>

</session-factory>
</hibernate-configuration>

Meine Event.hbm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping>

<class name="Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="increment"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class>
</hibernate-mapping>







Hibernate version: 3.05



Full stack trace of any exception that occurs:

Name and version of the database you are using: HSQL


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 5:43 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Vergleiche mal die beiden Dateien:

http://hibernate.org/hib_docs/v3/refere ... figuration


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 7:23 am 
Newbie

Joined: Fri Sep 30, 2005 5:32 am
Posts: 5
christian wrote:



Also die beiden dateien sind gleich bis auf

<mapping resource="Event.hbm.xml"/> in der hibernate.cfg.xml.
wenn ich den eintrag reinmache findet er die Events.hbm.xml nicht mehr

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

dann kommt der fehler:

Alle klassen und xml files liegen im sourcefolder, habe noch nicht mal ein packsage erstellt. Hilfe



run:
[java] log4j:WARN No appenders could be found for logger (org.hibernate.cfg
.Environment).
[java] log4j:WARN Please initialize the log4j system properly.
[java] Initial SessionFactory creation failed.org.hibernate.MappingExceptio
n: Error reading resource: Event.hbm.xml
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at HibernateUtil.<clinit>(Unknown Source)
[java] at EventManager.createAndStoreEvent(Unknown Source)
[java] at EventManager.main(Unknown Source)
[java] Caused by: org.hibernate.MappingException: Error reading resource: E
vent.hbm.xml
[java] at org.hibernate.cfg.Configuration.addResource(Configuration.jav
a:452)
[java] at org.hibernate.cfg.Configuration.parseMappingElement(Configura
tion.java:1263)
[java] at org.hibernate.cfg.Configuration.parseSessionFactory(Configura
tion.java:1235)
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.jav
a:1217)
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.jav
a:1184)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:
1112)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:
1098)
[java] ... 3 more
[java] Caused by: org.hibernate.MappingException: invalid mapping
[java] at org.hibernate.cfg.Configuration.addInputStream(Configuration.
java:399)
[java] at org.hibernate.cfg.Configuration.addResource(Configuration.jav
a:449)
[java] ... 9 more
[java] Caused by: org.xml.sax.SAXParseException: Document is invalid: no gr
ammar found.
[java] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.c
reateSAXParseException(ErrorHandlerWrapper.java:236)
[java] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.e
rror(ErrorHandlerWrapper.java:172)
[java] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.repo
rtError(XMLErrorReporter.java:382)
[java] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.repo
rtError(XMLErrorReporter.java:316)
[java] at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerI
mpl.scanStartElement(XMLNSDocumentScannerImpl.java:177)
[java] at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerI
mpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:779)
[java] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentSc
annerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java
:1794)
[java] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentSc
annerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
[java] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration
.parse(XML11Configuration.java:834)
[java] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration
.parse(XML11Configuration.java:764)
[java] at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XM
LParser.java:148)
[java] at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.
parse(AbstractSAXParser.java:1242)
[java] at org.dom4j.io.SAXReader.read(SAXReader.java:465)
[java] at org.hibernate.cfg.Configuration.addInputStream(Configuration.
java:398)
[java] ... 10 more
[java] Java Result: 1


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 7:33 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Mit deinem Event.hbm.xml file stimmt was nicht:

[java] Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.

Keine Ahnung was das sein soll.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 7:51 am 
Newbie

Joined: Fri Sep 30, 2005 5:32 am
Posts: 5
hm und vorschläge ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 7:51 am 
Newbie

Joined: Fri Sep 30, 2005 5:32 am
Posts: 5
habs per paste copy aus dem tutorial


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 8:15 am 
Newbie

Joined: Fri Sep 30, 2005 5:32 am
Posts: 5
das hat gefehlt.

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


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