Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.0 GA
Greetings,
I am fairly new to hibernate and I am trying to make a very small simple project to work. The project is the booking application from Seam and I am using SQL Server 2005 Express as the DB server. The project works, but my problem comes from generating the Hibernate mapping files. In Eclipse(I am using version 3.3 ie Europa), when you switch to the hibernate console perspective, I am creating a reveng.xml to generate the mapping. Here is what it looks like:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<table-filter match-catalog="booking" match-schema="dbo" match-name="Booking"/>
<table-filter match-catalog="booking" match-schema="dbo" match-name="Customer"/>
<table-filter match-catalog="booking" match-schema="dbo" match-name="Hotel"/>
</hibernate-reverse-engineering>
I am able to do the process of generating the mapping files. However, still in the Hibernate perspective, I am not able to open the SessionFactory option. I have selected the "jdk 1.5 + Annotation" in the hibernate config setup in Eclipse. I am getting the following error:
Quote:
org.hibernate.MappingException: entity class not found: Customer
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
at org.hibernate.validator.event.ValidateEventListener.initialize(ValidateEventListener.java:90)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:356)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1304)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:357)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:88)
at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:352)
at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:41)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:97)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:103)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:196)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.ClassNotFoundException: Customer
at java.lang.ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:429)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:369)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:357)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:96)
... 14 more
Here is a little info about my setup:
Eclipse Europa
JDK 1.5
Hibernate 3.2.0 GA
Seam Framework 2.0.1 GA
This is my hibernate.cfg.xml:
Code:
<?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>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.connection.autocommit">true</property>
<property name="hibernate.connection.datasource">java:/DefaultDS</property>
<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="hibernate.connection.password"><my password></property>
<property name="hibernate.connection.provider_class">org.hibernate.connection.DriverManagerConnectionProvider</property>
<property name="hibernate.connection.release_mode">auto</property>
<property name="hibernate.connection.url">jdbc:jtds:sqlserver://127.0.0.1:1433/booking</property>
<property name="hibernate.connection.username"><my username></property>
<property name="hibernate.datasource"></property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.ejb.discard_pc_on_close">false</property>
<property name="hibernate.query.jpaql_strict_compliance">true</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.transaction.factory_class">org.hibernate.ejb.transaction.JoinableCMTTransactionFactory</property>
<property name="hibernate.transaction.flush_before_completion">false</property>
<property name="hibernate.use_identifier_rollback">false</property>
<mapping resource="Customer.hbm.xml" />
<mapping resource="Hotel.hbm.xml" />
<mapping resource="Booking.hbm.xml" />
</session-factory>
</hibernate-configuration>
Here is the Customer.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 4-Apr-2008 4:26:25 PM by Hibernate Tools 3.2.0.CR1 -->
<hibernate-mapping>
<class name="Customer" table="Customer" schema="dbo" catalog="booking">
<id name="username" type="string">
<column name="username" length="15" />
<generator class="assigned" />
</id>
<property name="name" type="string">
<column name="name" length="100" not-null="true" />
</property>
<property name="password" type="string">
<column name="password" length="15" not-null="true" />
</property>
<set name="bookings" inverse="true">
<key>
<column name="user_username" length="15" not-null="true" />
</key>
<one-to-many class="Booking" />
</set>
</class>
</hibernate-mapping>
I am not sure where my problem is, so if anyone can help me on this, I would greatly appreciate it. If you need any other info, please let me know. I thank you all in advance for looking at my problem.