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(); } }
相关推荐
HibernateSessionFactory.java
在`HibernateSessionFactory.java`这个文件中,我们可能看到对上述过程的封装,例如创建`SessionFactory`的静态方法,以及提供会话的获取和关闭功能。这样的封装有助于代码的整洁和复用。 在实际应用中,`...
本篇文章将深入探讨`HibernateSessionFactory`及其在Hibernate中的作用,以及如何使用它来实现增、删、查、改(CRUD)操作。 `SessionFactory`是Hibernate的核心组件,它是线程安全的,负责管理数据库连接和会话。`...
Session s= HibernateSessionFactory.getSession(); 就是Hibernate的工具java类
标题提到的"新Hibernate SessionFactory().getCurrentSession()猫腻"揭示了一个常见的使用误区或者说是陷阱,即不正确地使用SessionFactory的getCurrentSession()方法。这篇文章可能探讨了这个方法在实际应用中的...
用于获得Session会话及关闭Session会话
本文将详细讲解如何在Spring 3.2.3版本中配置SessionFactory,以便整合Hibernate 4.2.2,实现对数据库操作的高效管理。SessionFactory是Hibernate的核心组件,它负责创建Session对象,而Session则是与数据库交互的...
修改了Hibernate的源码,可动态增加映射文件
Session session = HibernateSessionFactory.currentSession(); Transaction t = session.beginTransaction(); session.save(o); t.commit(); HibernateSessionFactory.clossSession(); } ``` 2. 删除数据...
Session session = HibernateSessionFactory.getSession(); Transaction tx = session.beginTransaction(); session.save(user); // 保存用户 tx.commit(); HibernateSessionFactory.closeSession(); } ``` ...
`HibernateSessionFactory` 类是Hibernate应用中常见的一个工具类,用于管理和提供与当前线程相关的Session实例。让我们详细了解一下`HibernateSessionFactory`类中的关键方法和其背后的原理。 1. **配置和初始化...
通过以上步骤,我们就完成了Spring Boot与Hibernate的集成,且在DAO层使用SessionFactory进行数据库操作。这种方式允许我们充分利用Hibernate的灵活性,同时避免了JPA的一些限制。在实际项目中,根据需求选择适合的...
如果选择自定义配置文件的位置或名称,则需要通过`HibernateSessionFactory`类中的`CONFIG_FILE_LOCATION`属性来指定实际的配置文件路径。 **配置文件中的主要内容包括:** - **数据库连接信息**:包括数据库的URL...
SessionFactory中 加入为了能得到同一个Session”表明本文要讨论的是在使用Spring框架整合Hibernate时,如何实现Spring管理Hibernate的SessionFactory对象,以便能够共享同一个数据库连接会话。 SSH框架指的是...
首先,`HibernateSessionFactory`是Hibernate的核心组件之一,它负责创建`Session`对象。`Session`对象是与数据库进行交互的接口,类似于JDBC中的Connection。`HibernateSessionFactory`通常在应用启动时初始化一次...