这是我的
当我执行main()函数时,会出现异常,并且有以下的堆栈跟踪信息 -
hibernate.cfg.xml
文件。<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- Assume hibernateTutorial is the database name -->
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernateTutorial</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.idle_test_period">3600</property>
<property name="hibernate.c3p0.timeout">28800</property>
<!-- List of XML mapping files. Give absolute path of the xml files after
src/ -->
<mapping resource="xml/Employee.hbm.xml"></mapping>
</session-factory>
</hibernate-configuration>
这是我的表格EMPLOYEE
desc EMPLOYEE;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| first_name | varchar(20) | YES | | NULL | |
| last_name | varchar(20) | YES | | NULL | |
| salary | int(11) | YES | | NULL | |
+------------+-------------+------+-----+---------+----------------+
这里是我的Employee.hbm.xml
(Employee.java位于dto包中)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="dto.Employee" table="EMPLOYEE">
<meta attribute="class-description">
This class contains the employee details.
</meta>
<id name="id" type="int" column="id">
<generator class="native" />
</id>
<property name="firstName" column="first_name" type="string" />
<property name="lastName" column="last_name" type="string" />
<property name="salary" column="salary" type="int" />
</class>
</hibernate-mapping>
这是我的主类 ManageEmployee.java
private static SessionFactory factory = null;
private static Session session = null;
@SuppressWarnings({ "deprecation", "unused" })
public static void main(String[] args) {
System.out.println("adding employees");
// Add employee
System.out.println("adding employee 1");
Integer emp1 = addEmployee("Emp1FN", "Emp1LN", 1000);
System.out.println("adding employee 2");
Integer emp2 = addEmployee("Emp2FN", "Emp2LN", 1000);
System.out.println("adding employee 3");
Integer emp3 = addEmployee("Emp3FN", "Emp3LN", 1000);
// list employees
System.out.println("listing employees");
List<Employee> employeeList = listEmployees();
System.out.println(employeeList);
// update employees
System.out.println("updating employee1");
updateEmployee(emp1, "Emp4FN", "Emp4LN", 5000);
// list employees
System.out.println("listing employees");
employeeList = listEmployees();
System.out.println(employeeList);
// delete employees
System.out.println("deleting employee 2");
deleteEmployee(emp2);
// list employees
System.out.println("listing employees");
employeeList = listEmployees();
System.out.println(employeeList);
}
@SuppressWarnings("deprecation")
private static void deleteEmployee(Integer empID) {
Transaction tx = null;
try {
factory = new Configuration().configure().buildSessionFactory();
System.out.println("factory configured");
session = factory.openSession();
tx = session.beginTransaction();
Employee emp = (Employee) session.get(Employee.class, empID);
session.delete(emp);
tx.commit();
} catch (HibernateException e) {
System.out
.println("HibernateException while deleting from EMPLOYEE :: "
+ e.getMessage());
e.printStackTrace();
if (tx != null) {
tx.rollback();
}
System.exit(1);
} finally {
if (session != null) {
session.close();
}
}
}
private static void updateEmployee(int empID, String firstName,
String lastName, int salary) {
Transaction tx = null;
try {
factory = new Configuration().configure().buildSessionFactory();
System.out.println("factory configured");
session = factory.openSession();
tx = session.beginTransaction();
Employee emp = (Employee) session.get(Employee.class, empID);
emp = new Employee(firstName, lastName, salary);
session.update(emp);
tx.commit();
} catch (HibernateException e) {
System.out
.println("HibernateException while updating into EMPLOYEE :: "
+ e.getMessage());
e.printStackTrace();
if (tx != null) {
tx.rollback();
}
System.exit(1);
} finally {
if (session != null) {
session.close();
}
}
}
@SuppressWarnings({ "unchecked", "deprecation" })
private static List<Employee> listEmployees() {
List<Employee> employeeList = new ArrayList<Employee>();
Transaction tx = null;
try {
factory = new Configuration().configure().buildSessionFactory();
System.out.println("factory configured");
session = factory.openSession();
tx = session.beginTransaction();
employeeList = session.createQuery("from EMPLOYEE").list();
} catch (HibernateException e) {
System.out
.println("HibernateException while selecting from EMPLOYEE :: "
+ e.getMessage());
e.printStackTrace();
if (tx != null) {
tx.rollback();
}
System.exit(1);
} finally {
if (session != null) {
session.close();
}
}
return employeeList;
}
private static Integer addEmployee(String firstName, String lastName,
int salary) {
Integer empID = null;
Transaction tx = null;
try {
factory = new Configuration().configure().buildSessionFactory();
System.out.println("factory configured");
session = factory.openSession();
tx = session.beginTransaction();
Employee emp = new Employee(firstName, lastName, salary);
empID = (Integer) session.save(emp);
tx.commit();
} catch (HibernateException e) {
System.out
.println("HibernateException while inserting into EMPLOYEE :: "
+ e.getMessage());
e.printStackTrace();
if (tx != null) {
tx.rollback();
}
System.exit(1);
} finally {
if (session != null) {
session.close();
}
}
return empID;
}
当我执行main()函数时,会出现异常,并且有以下的堆栈跟踪信息 -
adding employees
adding employee 1
Jul 5, 2013 2:05:12 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
Jul 5, 2013 2:05:12 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.3.Final}
Jul 5, 2013 2:05:12 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000205: Loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.h2.Driver, hibernate.dialect=org.hibernate.dialect.H2Dialect, hibernate.max_fetch_depth=5, hibernate.format_sql=true, hibernate.generate_statistics=true, hibernate.connection.username=sa, hibernate.connection.url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE, hibernate.bytecode.use_reflection_optimizer=false, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=5}
Jul 5, 2013 2:05:12 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Jul 5, 2013 2:05:13 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Jul 5, 2013 2:05:13 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Jul 5, 2013 2:05:13 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Jul 5, 2013 2:05:13 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: xml/Employee.hbm.xml
Jul 5, 2013 2:05:13 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Jul 5, 2013 2:05:13 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator getConfiguredConnectionProviderName
WARN: HHH000208: org.hibernate.connection.C3P0ConnectionProvider has been deprecated in favor of org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider; that provider will be used instead.
Jul 5, 2013 2:05:13 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator instantiateExplicitConnectionProvider
INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
Jul 5, 2013 2:05:13 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/hibernateTutorial
Jul 5, 2013 2:05:13 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH000046: Connection properties: {user=root, password=****}
Jul 5, 2013 2:05:13 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH000006: Autocommit mode: false
Jul 5, 2013 2:05:13 PM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
Jul 5, 2013 2:05:13 PM com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10]
Jul 5, 2013 2:05:13 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@143cf7f5 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@14e02320 [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge1778v1c9qur3n1bnbv|1d6a56e, idleConnectionTestPeriod -> 3600, initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 28800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@634a2fd5 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge1778v1c9qur3n1bnbv|16921fd, jdbcUrl -> jdbc:mysql://localhost/hibernateTutorial, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge1778v1c9qur3n1bnbv|1cb52ae, numHelperThreads -> 3 ]
Jul 5, 2013 2:05:13 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Jul 5, 2013 2:05:13 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
Jul 5, 2013 2:05:13 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Jul 5, 2013 2:05:13 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
factory configured
adding employee 2
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Jul 5, 2013 2:05:14 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: xml/Employee.hbm.xml
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator getConfiguredConnectionProviderName
WARN: HHH000208: org.hibernate.connection.C3P0ConnectionProvider has been deprecated in favor of org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider; that provider will be used instead.
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator instantiateExplicitConnectionProvider
INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/hibernateTutorial
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH000046: Connection properties: {user=root, password=****}
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH000006: Autocommit mode: false
Jul 5, 2013 2:05:14 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@5d5da90b [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1799a99f [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge1778v1c9qur3n1bnbv|1ac1e22, idleConnectionTestPeriod -> 3600, initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 28800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1158f897 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge1778v1c9qur3n1bnbv|1f8d077, jdbcUrl -> jdbc:mysql://localhost/hibernateTutorial, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge1778v1c9qur3n1bnbv|18ed77a, numHelperThreads -> 3 ]
Jul 5, 2013 2:05:14 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Jul 5, 2013 2:05:14 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
Jul 5, 2013 2:05:14 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Jul 5, 2013 2:05:14 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
factory configured
adding employee 3
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Jul 5, 2013 2:05:14 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: xml/Employee.hbm.xml
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator getConfiguredConnectionProviderName
WARN: HHH000208: org.hibernate.connection.C3P0ConnectionProvider has been deprecated in favor of org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider; that provider will be used instead.
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator instantiateExplicitConnectionProvider
INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/hibernateTutorial
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH000046: Connection properties: {user=root, password=****}
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH000006: Autocommit mode: false
Jul 5, 2013 2:05:14 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@ef16aa44 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@f894d859 [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge1778v1c9qur3n1bnbv|1a70b8, idleConnectionTestPeriod -> 3600, initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 28800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@62985545 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge1778v1c9qur3n1bnbv|15cd9c0, jdbcUrl -> jdbc:mysql://localhost/hibernateTutorial, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge1778v1c9qur3n1bnbv|83d37a, numHelperThreads -> 3 ]
Jul 5, 2013 2:05:14 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Jul 5, 2013 2:05:14 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
Jul 5, 2013 2:05:14 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Jul 5, 2013 2:05:14 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
factory configured
listing employees
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Jul 5, 2013 2:05:14 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: xml/Employee.hbm.xml
Jul 5, 2013 2:05:14 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator getConfiguredConnectionProviderName
WARN: HHH000208: org.hibernate.connection.C3P0ConnectionProvider has been deprecated in favor of org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider; that provider will be used instead.
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator instantiateExplicitConnectionProvider
INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/hibernateTutorial
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH000046: Connection properties: {user=root, password=****}
Jul 5, 2013 2:05:14 PM org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure
INFO: HHH000006: Autocommit mode: false
Jul 5, 2013 2:05:14 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@646ad3f9 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@ef169246 [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge1778v1c9qur3n1bnbv|83d8be, idleConnectionTestPeriod -> 3600, initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 28800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@a961744b [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge1778v1c9qur3n1bnbv|a010ba, jdbcUrl -> jdbc:mysql://localhost/hibernateTutorial, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge1778v1c9qur3n1bnbv|14aa2db, numHelperThreads -> 3 ]
Jul 5, 2013 2:05:14 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Jul 5, 2013 2:05:14 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
Jul 5, 2013 2:05:14 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Jul 5, 2013 2:05:14 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
factory configured
HibernateException while selecting from EMPLOYEE :: EMPLOYEE is not mapped [from EMPLOYEE]
org.hibernate.hql.internal.ast.QuerySyntaxException: EMPLOYEE is not mapped [from EMPLOYEE]
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:93)
at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:324)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3420)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3309)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:706)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:562)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:249)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:184)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:137)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:221)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:199)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1778)
at api.ManageEmployee.listEmployees(ManageEmployee.java:118)
at api.ManageEmployee.main(ManageEmployee.java:32)
我发现很难弄清楚我的问题出在哪里?我正在使用 hibernate.4.2.3.jar,已经包含了其中的所有 jar 包。