Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.5
Mapping documents:
Committee.hbm.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="gov.mtc.agenda.beans.event.Committee"
table="COMMITTEE"
>
<id
name="ID"
column="ID"
type="long"
unsaved-value="null"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Committee.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="name"
length="255"
/>
<property
name="description"
type="java.lang.String"
update="true"
insert="true"
column="description"
length="4000"
/>
<set
name="events"
lazy="false"
inverse="true"
cascade="all-delete-orphan"
sort="unsorted"
>
<key
column="EVENT_ID"
>
</key>
<one-to-many
class="gov.mtc.agenda.beans.event.Event"
/>
</set>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Committee.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Event.hbm.xmlCode:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="gov.mtc.agenda.beans.event.Event"
table="EVENT"
>
<id
name="ID"
column="ID"
type="long"
unsaved-value="null"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Event.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="name"
length="255"
/>
<property
name="notes"
type="java.lang.String"
update="true"
insert="true"
column="notes"
length="4000"
/>
<property
name="eventDate"
type="java.sql.Date"
update="true"
insert="true"
column="eventDate"
/>
<property
name="timeComment"
type="java.lang.String"
update="true"
insert="true"
column="timeComment"
length="4000"
/>
<property
name="endtime"
type="java.sql.Date"
update="true"
insert="true"
column="endtime"
length="255"
/>
<property
name="nextMeetingDate"
type="java.sql.Date"
update="true"
insert="true"
column="nextMeetingDate"
/>
<many-to-one
name="committee"
class="gov.mtc.agenda.beans.event.Committee"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="COMMITTEE_ID"
not-null="true"
/>
<property
name="revisedagenda"
type="boolean"
update="true"
insert="true"
column="revisedagenda"
/>
<property
name="audiocast"
type="boolean"
update="true"
insert="true"
column="audiocast"
/>
<property
name="hide"
type="boolean"
update="true"
insert="true"
column="hide"
/>
<property
name="modified"
type="java.sql.Date"
update="true"
insert="true"
column="modified"
/>
<property
name="audiocastmarker"
type="java.lang.String"
update="true"
insert="true"
column="audiocastmarker"
length="255"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Event.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close(): Code:
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.save(committee);
tx.commit();
HibernateUtil.closeSession();
Full stack trace of any exception that occurs:Code:
org.hibernate.MappingException: class Event not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:81)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:275)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:360)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:294)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:236)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
at org.hibernate.cfg.Configuration.add(Configuration.java:362)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
at gov.HibernateUtil.<clinit>(HibernateUtil.java:18)
at gov.mtc.agenda.legacydata.Main.processLegacyCommittee(Main.java:93)
at gov.mtc.agenda.legacydata.Main.main(Main.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)
Caused by: java.lang.ClassNotFoundException: Event
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:77)
... 22 more
Initial SessionFactory creation failed.org.hibernate.MappingException: Error reading resource: Event.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at gov.HibernateUtil.<clinit>(HibernateUtil.java:23)
at gov.mtc.agenda.legacydata.Main.processLegacyCommittee(Main.java:93)
at gov.mtc.agenda.legacydata.Main.main(Main.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)
Caused by: org.hibernate.MappingException: Error reading resource: Event.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
at gov.HibernateUtil.<clinit>(HibernateUtil.java:18)
... 7 more
Caused by: org.hibernate.MappingException: class Event not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:81)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:275)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:360)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:294)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:236)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
at org.hibernate.cfg.Configuration.add(Configuration.java:362)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
... 14 more
Caused by: java.lang.ClassNotFoundException: Event
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:77)
... 22 more
Process finished with exit code 1
Name and version of the database you are using:Oracle 9i
The generated SQL (show_sql=true):Debug level Hibernate log excerpt:Code:
12:58:26,328 INFO Environment:464 - Hibernate 3.0.5
12:58:26,343 INFO Environment:477 - hibernate.properties not found
12:58:26,343 INFO Environment:510 - using CGLIB reflection optimizer
12:58:26,343 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
12:58:26,421 INFO Configuration:1110 - configuring from resource: /hibernate.cfg.xml
12:58:26,421 INFO Configuration:1081 - Configuration resource: /hibernate.cfg.xml
12:58:26,703 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath under org/hibernate/
12:58:26,703 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath
12:58:26,750 DEBUG Configuration:1067 - dialect=org.hibernate.dialect.Oracle9Dialect
12:58:26,765 DEBUG Configuration:1067 - connection.driver_class=oracle.jdbc.driver.OracleDriver
12:58:26,765 DEBUG Configuration:1067 - connection.url=jdbc:oracle:thin:@localhost:1521:WORKDB
12:58:26,765 DEBUG Configuration:1067 - connection.username=agendahibernate
12:58:26,765 DEBUG Configuration:1067 - connection.password=*****
12:58:26,765 DEBUG Configuration:1067 - connection.pool_size=1
12:58:26,765 DEBUG Configuration:1067 - show_sql=true
12:58:26,765 DEBUG Configuration:1067 - hbm2ddl.auto=create
12:58:26,765 DEBUG Configuration:1067 - connection.shutdown=true
12:58:26,765 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@290fbc [Attribute: name resource value "Event.hbm.xml"]
12:58:26,765 INFO Configuration:444 - Mapping resource: Event.hbm.xml
12:58:26,781 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath under org/hibernate/
12:58:26,781 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath
12:58:26,921 INFO HbmBinder:260 - Mapping class: Event -> EVENTS
12:58:26,937 ERROR Configuration:365 - Could not compile the mapping document