请教关于hibernate的问题
小弟最近正在自学hibernate的配置,自己在网上找了个例子,对数据库进行查询,每次运行java类的时候都输出一些好象是连接数据库的信息:
2008-10-5 22:58:14 org.hibernate.cfg.Environment <clinit>
信息: Hibernate 3.2.0
2008-10-5 22:58:15 org.hibernate.cfg.Environment <clinit>
信息: loaded properties from resource hibernate.properties: {hibernate.connection.username=root, hibernate.connection.password=****, hibernate.dialect=org.hibernate.dialect.MySQL5Dialect, hibernate.show_sql=true, hibernate.connection.url=jdbc:mysql://localhost:3306/myex, hibernate.bytecode.use_reflection_optimizer=false, hibernate.connection.driver_class=com.mysql.jdbc.Driver}
2008-10-5 22:58:15 org.hibernate.cfg.Environment buildBytecodeProvider
信息: Bytecode provider name : cglib
2008-10-5 22:58:15 org.hibernate.cfg.Environment <clinit>
信息: using JDK 1.4 java.sql.Timestamp handling
2008-10-5 22:58:15 org.hibernate.cfg.Configuration addClass
信息: Reading mappings from resource: bean/Student.hbm.xml
2008-10-5 22:58:15 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
信息: Mapping class: bean.Student -> student
2008-10-5 22:58:15 org.hibernate.cfg.Configuration addClass
信息: Reading mappings from resource: bean/Teacher.hbm.xml
2008-10-5 22:58:16 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
信息: Mapping class: bean.Teacher -> teacher
2008-10-5 22:58:16 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
信息: Mapping collection: bean.Student.teachers -> teacher
2008-10-5 22:58:16 org.hibernate.connection.DriverManagerConnectionProvider configure
信息: Using Hibernate built-in connection pool (not for production use!)
2008-10-5 22:58:16 org.hibernate.connection.DriverManagerConnectionProvider configure
信息: Hibernate connection pool size: 20
2008-10-5 22:58:16 org.hibernate.connection.DriverManagerConnectionProvider configure
信息: autocommit mode: false
2008-10-5 22:58:16 org.hibernate.connection.DriverManagerConnectionProvider configure
信息: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/myex
2008-10-5 22:58:16 org.hibernate.connection.DriverManagerConnectionProvider configure
信息: connection properties: {user=root, password=****}
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: RDBMS: MySQL, version: 5.0.51a-community-nt
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.8 ( Revision: ${svn.Revision} )
2008-10-5 22:58:19 org.hibernate.dialect.Dialect <init>
信息: Using dialect: org.hibernate.dialect.MySQL5Dialect
2008-10-5 22:58:19 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
信息: Using default transaction strategy (direct JDBC transactions)
2008-10-5 22:58:19 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
信息: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Automatic flush during beforeCompletion(): disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Automatic session close at end of transaction: disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: JDBC batch size: 15
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: JDBC batch updates for versioned data: disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Scrollable result sets: enabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: JDBC3 getGeneratedKeys(): enabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Connection release mode: auto
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Maximum outer join fetch depth: 2
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Default batch fetch size: 1
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Generate SQL with comments: disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Order SQL updates by primary key: disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
信息: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2008-10-5 22:58:19 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
信息: Using ASTQueryTranslatorFactory
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Query language substitutions: {}
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: JPA-QL strict compliance: disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Second-level cache: enabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Query cache: disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory createCacheProvider
信息: Cache provider: org.hibernate.cache.NoCacheProvider
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Optimize cache for minimal puts: disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Structured second-level cache entries: disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Echoing all SQL to stdout
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Statistics: disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Deleted entity synthetic identifier rollback: disabled
2008-10-5 22:58:19 org.hibernate.cfg.SettingsFactory buildSettings
信息: Default entity-mode: pojo
2008-10-5 22:58:19 org.hibernate.impl.SessionFactoryImpl <init>
信息: building session factory
2008-10-5 22:58:20 org.hibernate.impl.SessionFactoryObjectFactory addInstance
信息: Not binding factory to JNDI, no JNDI name configured
上边的完事了,才开始对数据库进行查询.
Hibernate: select student0_.id as id0_, student0_.name as name0_, student0_.t_id as t3_0_ from student student0_ where student0_.t_id=1
Hibernate: select teachers0_.id as id1_, teachers0_.id as id1_0_, teachers0_.name as name1_0_ from teacher teachers0_ where teachers0_.id=?
Hibernate: select teachers0_.id as id1_, teachers0_.id as id1_0_, teachers0_.name as name1_0_ from teacher teachers0_ where teachers0_.id=?
Hibernate: select teachers0_.id as id1_, teachers0_.id as id1_0_, teachers0_.name as name1_0_ from teacher teachers0_ where teachers0_.id=?
这只是一个单独的例子.
请问如果要使用struts + hibernate做个东西的话应该是在tomcat启动的时候就连上数据库了吧?
为了这个我下载了一个MyEclipse, 然后自动生成了hibernate的东西, 其中有个HibernateSessionFactory的类, 启动hibernate就应该用它吧?
请问应该在web.xml中怎么配置呢??
谢谢,希望能提供个struts+hibernate的最简单的例子,谢谢.