我的hibernate.cfg.xml 文件如下:
  
     <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hiberation/Hiberation Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  <hibernate-configuration>    <session-factory>         
        <property name="connection.url">
            jdbc:mysql://localhost:3308/test
        </property>
        
        <property name="connection.driver_class">
           org.gjt.mm.mysql.Driver
        </property>
        
        <property name="connection.username">
           root
         </property>
         <property name="connection.password">"123456"</property>
         
         <property name="dialect">
            net.sf.hibernate.dialect.MySQLDialect
         </property>
         
         <property name="show_sql">
            true
          </property>                
        
        <property name="hibernate.transaction.factory_class">
           net.sf.hibernate.transaction.JDBCTransactionFactory
        </property> 
        
        <property name="hibernate.use_outer_join">
             true
        </property>             
        <mapping resource="javax/hibernate/Tuser.hbm.xml"/>        
      
      </session-factory></hibernate-configuration>

解决方案 »

  1.   

    Tuser.hbm.xml文件如下:    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC
       "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
       "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
        <hibernate-mapping>
          <class name = "javax.hibernate.Tuser" 
                 table = "t_user">
                 <id
                    name="id"
                    column="id"
                    type="java.lang.Integer"
                  >   
                    <generator class="native"/>
                  </id>
                  <property
                     name="name"
                     column="name"
                     type="java.lang.String"
                   />
                   <property
                      name="password"
                      column="password"
                      type="java.lang.String"
                    />   
             </class>
        </hibernate-mapping>
      

  2.   

    运行之后的结果:
    cfg.Environment                     483 ) Hibernate 2.1.8
    (cfg.Environment                     512 ) hibernate.properties not found
    (cfg.Environment                     543 ) using CGLIB reflection optimizer
    (cfg.Environment                     572 ) using JDK 1.4 java.sql.Timestamp handling
    (cfg.Configuration                   909 ) configuring from resource: /hibernate.cfg.xml
    (cfg.Configuration                   881 ) Configuration resource: /hibernate.cfg.xml
    (cfg.Configuration                   332 ) Mapping resource: javax/hibernate/Tuser.hbm.xml
    (cfg.Binder                          229 ) Mapping class: javax.hibernate.Tuser -> t_user
    (cfg.Configuration                   1067) Configured SessionFactory: null
    (cfg.Configuration                   641 ) processing one-to-many association mappings
    (cfg.Configuration                   650 ) processing one-to-one association property references
    (cfg.Configuration                   675 ) processing foreign key constraints
    (dialect.Dialect                     86  ) Using dialect: net.sf.hibernate.dialect.MySQLDialect
    (cfg.SettingsFactory                 70  ) Maximim outer join fetch depth: 2
    (cfg.SettingsFactory                 74  ) Use outer join fetching: true
    (connection.DriverManagerConnectionProvider 42  ) Using Hibernate built-in connection pool (not for production use!)
    (connection.DriverManagerConnectionProvider 43  ) Hibernate connection pool size: 20
    (connection.DriverManagerConnectionProvider 77  ) using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3308/test
    (connection.DriverManagerConnectionProvider 78  ) connection properties: {user=root, password="123456"}
    (transaction.TransactionFactoryFactory 31  ) Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
    (transaction.TransactionManagerLookupFactory 33  ) No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
    (cfg.SettingsFactory                 107 ) Could not obtain connection metadata