Hmmm... so I have not been able to make any progress on this. I hope that by posting more information, someone will see something that I am doing wrong.
I've created a new project with 1 table to try to just get this working. My problem is that in the Hibernate Console Configuration, when I try to expand the Session Factory section. I get an error.
Either it cannot find the hbm.xml file or it cannot find the class. When I put an entry into the mappings section of the configuration console, it cannot find the class. When I try to put a <mapping resource="Main.hbm.xml"/> call in the hibernate.cfg.xml file, it cannot find the hbm.xml file. I'm not sure what I am doing wrong.
This is the Main.hbm.xml file:
<?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 Feb 27, 2007 9:18:47 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="events.Main" table="Main" schema="dbo">
<id name="c1" type="int">
<column name="c1" />
<generator class="assigned" />
</id>
<property name="c2" type="java.lang.Integer">
<column name="c2" />
</property>
</class>
</hibernate-mapping>
This is the hibernate.cfg.xml file
<?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.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.password">test</property>
<property name="hibernate.connection.url">jdbc:sqlserver://Latitude32:1433</property>
<property name="hibernate.connection.username">test</property>
<property name="hibernate.default_catalog">hibernate</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
</session-factory>
</hibernate-configuration>
This is the Main.java file:
package events;
// default package
// Generated Feb 27, 2007 9:18:47 PM by Hibernate Tools 3.2.0.b9
/**
* Main generated by hbm2java
*/
public class Main {
private int c1;
private Integer c2;
public Main() {
}
public Main(int c1) {
this.c1 = c1;
}
public Main(int c1, Integer c2) {
this.c1 = c1;
this.c2 = c2;
}
public int getC1() {
return this.c1;
}
public void setC1(int c1) {
this.c1 = c1;
}
public Integer getC2() {
return this.c2;
}
public void setC2(Integer c2) {
this.c2 = c2;
}
}
Full Error Log:
org.hibernate.MappingException: entity class not found: events.Main
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:168)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:118)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:425)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:317)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:89)
at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:312)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:55)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:63)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: java.lang.ClassNotFoundException: events.Main
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:402)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:347)
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)
... 40 more
File Structure:
HBTest3
+src
+events
Main.java
Main.hbm.xml
hibernate.cfg.xml
+bin
+events
Main.class
Main.hbm.xml
hibernate.cfg.xml
(I think) I have imported the jar files correctly. I am using Eclipse and done the alt+r -> n. Gone to the classpath and imported the external jar files. All of the files under the /lib directory where I decompressed hibernate + hibernate3.jar file. I also have included my jdbc driver.
I am able to connect to the database (that is how the Main.hbm.xml file got created.)
I'm missing something and I don't see it. I've tried to go through the documentation, but I still not getting it. I've tried to add package attributes as well as putting the class attribute of Main.hbm.xml.
My environment:
XP Pro
Eclipse 3.2
Hibernate 3.2.2
Tools 3.2 beta 9
JDBC Driver = MS 1.1
Database = SQL 2000
If anyone has anything that I can try, I'll be more then willing to do it. If someone has a page of the documentation that I should reread, I'll do it.
This is driving me crazy!
Matt
|