2013-07-05 7 views
5

यहाँ है मैप नहीं है मेरी hibernate.cfg.xml org.hibernate.hql.internal.ast.QuerySyntaxException: <table_name> [<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 पैकेज डीटीओ के अंतर्गत आता है)

<?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]6aa44 [ 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 का उपयोग कर रहा हूं और इसमें शामिल सभी जार शामिल हैं।

+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 में है।

Thats जहां हाइबरनेट कक्षा (ClassNotFoundException) लोड करने में सक्षम नहीं है।

+0

धन्यवाद @zerocool। वह काम किया। लेकिन संदेश 'org.hibernate.hql.internal.ast.QuerySyntaxException के बारे में क्या: EMPLOYEE मैप नहीं किया गया है [EMPLOYEE से] ' – AlwaysALearner

+0

ओह, क्या उपर्युक्त समस्या हल हो गई है? ऐसा लगता है कि हाइबरनेट कॉन्फ़िगरेशन में आपके द्वारा उल्लिखित मैपिंग फ़ाइल का पता लगाने में सक्षम नहीं है। (। hbm फ़ाइल) – zerocool

+0

क्या आप वाकई समस्या हो सकती हैं? क्योंकि, सम्मिलित क्वेरी काम कर रही है। यह वह चयन है जो नहीं है। – AlwaysALearner

1

listEmployees() विधि में आप कर्मचारी को कर्मचारी को बदलने की जरूरत:
employeeList = session.createQuery("from Employee").list();

यह मेरे लिए काम किया। समस्या के अच्छे विवरण के लिए

संबंधित मुद्दे