2014-8-8 17:29:19 org.hibernate.cfg.Environment <clinit> 信息: Hibernate 3.2.7 2014-8-8 17:29:19 org.hibernate.cfg.Environment <clinit> 信息: hibernate.properties not found 2014-8-8 17:29:19 org.hibernate.cfg.Environment buildBytecodeProvider 信息: Bytecode provider name : cglib 2014-8-8 17:29:19 org.hibernate.cfg.Environment <clinit> 信息: using JDK 1.4 java.sql.Timestamp handling 2014-8-8 17:29:19 org.hibernate.cfg.Configuration configure 信息: configuring from resource: /hibernate.cfg.xml 2014-8-8 17:29:19 org.hibernate.cfg.Configuration getConfigurationInputStream 信息: Configuration resource: /hibernate.cfg.xml 2014-8-8 17:29:19 org.hibernate.cfg.Configuration addResource 信息: Reading mappings from resource : com/bjsxt/hibernate/Student.hbm.xml 2014-8-8 17:29:20 org.hibernate.cfg.Configuration doConfigure 信息: Configured SessionFactory: null 2014-8-8 17:29:20 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues 信息: Mapping class: com.bjsxt.hibernate.Student -> Student 2014-8-8 17:29:20 org.hibernate.connection.DriverManagerConnectionProvider configure 信息: Using Hibernate built-in connection pool (not for production use!) 2014-8-8 17:29:20 org.hibernate.connection.DriverManagerConnectionProvider configure 信息: Hibernate connection pool size: 1 2014-8-8 17:29:20 org.hibernate.connection.DriverManagerConnectionProvider configure 信息: autocommit mode: false 2014-8-8 17:29:20 org.hibernate.connection.DriverManagerConnectionProvider configure 信息: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521:orcl 2014-8-8 17:29:20 org.hibernate.connection.DriverManagerConnectionProvider configure 信息: connection properties: {user=machanglun, password=****} 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: RDBMS: Oracle, version: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC driver: Oracle JDBC driver, version: 9.2.0.3.0 2014-8-8 17:29:21 org.hibernate.dialect.Dialect <init> 信息: Using dialect: org.hibernate.dialect.OracleDialect 2014-8-8 17:29:21 org.hibernate.dialect.Oracle9Dialect <init> 警告: The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead 2014-8-8 17:29:21 org.hibernate.dialect.OracleDialect <init> 警告: The OracleDialect dialect has been deprecated; use Oracle8iDialect instead 2014-8-8 17:29:21 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory 信息: Using default transaction strategy (direct JDBC transactions) 2014-8-8 17:29:21 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup 信息: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Automatic flush during beforeCompletion(): disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Automatic session close at end of transaction: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC batch size: 15 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC batch updates for versioned data: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Scrollable result sets: enabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC3 getGeneratedKeys(): disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Connection release mode: auto 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Default batch fetch size: 1 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Generate SQL with comments: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Order SQL updates by primary key: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Order SQL inserts for batching: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory 信息: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2014-8-8 17:29:21 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init> 信息: Using ASTQueryTranslatorFactory 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Query language substitutions: {} 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: JPA-QL strict compliance: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Second-level cache: enabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Query cache: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory createCacheProvider 信息: Cache provider: org.hibernate.cache.NoCacheProvider 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Optimize cache for minimal puts: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Structured second-level cache entries: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Echoing all SQL to stdout 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Statistics: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Deleted entity synthetic identifier rollback: disabled 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Default entity-mode: pojo 2014-8-8 17:29:21 org.hibernate.cfg.SettingsFactory buildSettings 信息: Named query checking : enabled 2014-8-8 17:29:21 org.hibernate.impl.SessionFactoryImpl <init> 信息: building session factory Exception in thread "main" org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer] at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135) at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56) at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:323) at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:433) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:231) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1313) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867) at com.bjsxt.hibernate.TeacherTest.main(TeacherTest.java:14) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107) ... 10 more Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter at org.hibernate.bytecode.cglib.BytecodeProviderImpl.getProxyFactoryFactory(BytecodeProviderImpl.java:33) at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactoryInternal(PojoEntityTuplizer.java:208) at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:186) at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:128) at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:78) ... 15 more Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.CallbackFilter at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 20 more
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property> <property name="connection.username">xxx</property> <property name="connection.password">xxx</property> <!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.OracleDialect</property> <!-- Enable Hibernate's automatic session context management --> <property name="current_session_context_class">thread</property> <!-- Disable the second-level cache --> <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property> <!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">update</property> <mapping resource="com/bjsxt/hibernate/Student.hbm.xml"/> <mapping class="com.bjsxt.hibernate.Teacher"/> </session-factory> </hibernate-configuration>
package com.bjsxt.hibernate; import javax.persistence.Entity; import javax.persistence.Id; @Entity public class Teacher { private int id; private String name; private String title; @Id public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } }
package com.bjsxt.hibernate; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; public class TeacherTest { public static void main(String[] args) { Teacher t = new Teacher(); t.setId(1); t.setName("t1"); t.setTitle("middle"); SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); Session session = sessionFactory.getCurrentSession(); session.beginTransaction(); session.save(t); session.getTransaction().commit(); } }