I am a first-time user of Hibernate. Hibernate appears not to be creating
the database table for my class. The class is firsthib.SalesPerson.
I'm sure I'm doing something wrong but I can't figure it out. I assume
that Hibernate should create the database tables the first time I use
them. It isn't.
(This is my first post and I'm not sure if the format below is right.
What is the [b] stuff?
Thanks for any help.
Steve
[b]Hibernate version:[/b] 2.1.6
[b]Mapping documents:[/b]
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="firsthib.SalesPerson" table="SalesPeople">
<id name="id" type="long" column="id">
<generator class="increment"/>
<!--
<generator class="hilo">
<param name="table">hi_value</param>
<param name="column">next_value</param>
<param name="max_lo">100</param>
</generator>
-->
</id>
<property name="lastName"/>
<property name="city"/>
<property name="commission"/>
</class>
</hibernate-mapping>
[b]Code between sessionFactory.openSession() and session.close():[/b]
SalesPerson sp = new SalesPerson();
sp.setLastName("Buroff");
sp.setCity("Rockaway");
sp.setCommission(0.25f);
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
session.saveOrUpdate(sp);
tx.commit();
session.close();
[b]Full stack trace of any exception that occurs:[/b]
java.sql.SQLException: Base table or view not found message from server: "Table 'firsthib.salespeople' doesn't exist"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2746)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1532)
at com.mysql.jdbc.ServerPreparedStatement.serverPrepare(ServerPreparedStatement.java:1431)
at com.mysql.jdbc.ServerPreparedStatement.<init>(ServerPreparedStatement.java:144)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1288)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1260)
at net.sf.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:64)
at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:42)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:765)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at firsthib.Test1.testA(Test1.java:52)
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:582)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
[b]Name and version of the database you are using:[/b]
MySQL 4.1.3 beta
[b]Debug level Hibernate log excerpt:[/b]
Aug 11, 2004 11:37:33 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.6
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: firsthib.SalesPerson -> SalesPeople
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Aug 11, 2004 11:37:34 AM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximim outer join fetch depth: 1
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
Aug 11, 2004 11:37:34 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Aug 11, 2004 11:37:34 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
Aug 11, 2004 11:37:34 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///firsthib
Aug 11, 2004 11:37:34 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=}
Aug 11, 2004 11:37:34 AM net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): true
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0}
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: query cache factory: net.sf.hibernate.cache.StandardQueryCacheFactory
Aug 11, 2004 11:37:34 AM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
Aug 11, 2004 11:37:34 AM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Aug 11, 2004 11:37:35 AM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Aug 11, 2004 11:37:35 AM net.sf.hibernate.cache.UpdateTimestampsCache <init>
INFO: starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache
Aug 11, 2004 11:37:35 AM net.sf.ehcache.config.Configurator configure
WARNING: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Hibernate/lib/ehcache-0.9.jar!/ehcache-failsafe.xml
Aug 11, 2004 11:37:35 AM net.sf.hibernate.cache.EhCache <init>
WARNING: Could not find configuration for net.sf.hibernate.cache.UpdateTimestampsCache. Configuring using the defaultCache settings.
Aug 11, 2004 11:37:35 AM net.sf.hibernate.cache.StandardQueryCache <init>
INFO: starting query cache at region: net.sf.hibernate.cache.StandardQueryCache
Aug 11, 2004 11:37:35 AM net.sf.hibernate.cache.EhCache <init>
WARNING: Could not find configuration for net.sf.hibernate.cache.StandardQueryCache. Configuring using the defaultCache settings.
Aug 11, 2004 11:37:35 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 1146, SQLState: 42S02
Aug 11, 2004 11:37:35 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Base table or view not found message from server: "Table 'firsthib.salespeople' doesn't exist"
Aug 11, 2004 11:37:35 AM net.sf.hibernate.JDBCException <init>
SEVERE: Could not save object
|