2013-07-05 2 views
5

[ から]マップされていません。ここに私 hibernate.cfg.xml org.hibernate.hql.internal.ast.QuerySyntaxException:<table_name>がここ

<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 |    | 
+------------+-------------+------+-----+---------+----------------+ 
です

ここに私のです0(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; 
} 

ですトレース-

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... [email protected] [ connectionPoolDataSource -> [email protected] [ 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 -> [email protected] [ 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... [email protected] [ connectionPoolDataSource -> [email protected] [ 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 -> [email protected] [ 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... [email protected] [ connectionPoolDataSource -> [email protected] [ 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 -> [email protected] [ 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... [email protected] [ connectionPoolDataSource -> [email protected] [ 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 -> [email protected] [ 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ファイルが含まれています。

+1

+1この問題の詳細な説明は、私は別のタイトルを使用します:) –

+0

@Stefan Beike私はこの新しいタイトルがより適していると思います:)私はスタックトレースを更新しました。その問題について私に知らせてください。 – AlwaysALearner

答えて

5

設定ファイルに以下のプロパティを置換:

<property name="current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</property> 

私はちょうど今、むしろパッケージにそこにいないで休止状態 - コア - 4.2.2.Final.jar、ThreadLocalSessionContextをorg.hibernate.context確認これはorg.hibernate.context.internalにあります。

ここで、hibernateはクラスをロードできません(ClassNotFoundException)。 listEmployees()メソッドで

+0

ありがとうございます@zerocool。それはうまくいった。しかし、メッセージ 'org.hibernate.hql.internal.ast.QuerySyntaxException:EMPLOYEEは[従業員から]マッピングされていません。 ' – AlwaysALearner

+0

ooh、上記の問題は解決しましたか? hibernateが設定で言及したマッピングファイルを見つけることができないように見えます(.hbmファイル) – zerocool

+0

あなたは問題になる可能性はありますか?これは、挿入クエリが機能しているためです。それはそうではないSELECTです。 – AlwaysALearner

1

あなたは従業員にEMPLOYEEを変更する必要があります:
employeeList = session.createQuery("from Employee").list();

これは私のために働きました。