日期:2014-05-16  浏览次数:20577 次

使用Hibernate进行数据查询却清除了数据库对应表的内容

这些天,在运用Hibernate框架的时候,出现了一个问题,我在插入数据的时候,能够正确的运行,一查询数据,即使是最简单的将一个表中的所有数据查询出来都不能成功,最郁闷的是,经过查询后,还把数据库中表中数据全部清除了,将hibernate下的log4j.properties引入后,查看日志: 22:04:59,359 INFO Environment:479 - Hibernate 3.1.2 22:04:59,390 INFO Environment:509 - hibernate.properties not found 22:04:59,390 INFO Environment:525 - using CGLIB reflection optimizer 22:04:59,390 INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling 22:04:59,468 INFO Configuration:1342 - configuring from file: hibernate.cfg.xml 22:05:12,687 INFO Configuration:469 - Reading mappings from resource: ch3/User.hbm.xml 22:05:22,890 INFO HbmBinder:309 - Mapping class: ch3.User -> myusertable 22:05:23,187 INFO Configuration:1419 - Configured SessionFactory: null 22:05:24,375 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!) 22:05:24,375 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20 22:05:24,375 INFO DriverManagerConnectionProvider:45 - autocommit mode: false 22:05:24,531 INFO DriverManagerConnectionProvider:80 - using driver: com.microsoft.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mypro 22:05:24,531 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****} 22:05:25,734 INFO SettingsFactory:77 - RDBMS: Microsoft SQL Server, version: Microsoft SQL Server 2000 - 8.00.2039 (Intel X86) May 3 2005 23:18:38 Copyright (c) 1988-2003 Microsoft Corporation Personal Edition on Windows NT 5.1 (Build 2600: Service Pack 2) 22:05:25,734 INFO SettingsFactory:78 - JDBC driver: SQLServer, version: 2.2.0040 22:05:25,921 INFO Dialect:103 - Using dialect: org.hibernate.dialect.SQLServerDialect 22:05:25,968 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions) 22:05:25,968 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 22:05:25,968 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled 22:05:25,968 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled 22:05:25,984 INFO SettingsFactory:144 - Scrollable result sets: enabled 22:05:25,984 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled 22:05:25,984 INFO SettingsFactory:160 - Connection release mode: auto 22:05:25,984 INFO SettingsFactory:187 - Default batch fetch size: 1 22:05:26,000 INFO SettingsFactory:191 - Generate SQL with comments: disabled 22:05:26,000 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled 22:05:26,000 INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 22:05:26,046 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory 22:05:26,046 INFO SettingsFactory:203 - Query language substitutions: {} 22:05:26,046 INFO SettingsFactory:209 - Second-level cache: enabled 22:05:26,046 INFO SettingsFactory:213 - Query cache: disabled 22:05:26,046 INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.EhCacheProvider 22:05:26,140 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled 22:05:26,140 INFO SettingsFactory:237 - Structured second-level cache entries: disabled 22:05:26,281 INFO SettingsFactory:257 - Echoing all SQL to stdout 22:05:26,281 INFO SettingsFactory:264 - Statistics: disabled 22:05:26,281 INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled 22:05:26,281 INFO SettingsFactory:283 - Default entity-mode: pojo 22:05:26,812 INFO SessionFactoryImpl:153 - building session factory 22:05:26,953 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/E:/web/HibernateHome/hibernate-3.1/lib/ehcache-1.1.jar!/ehcache-failsafe.xml 22:05:28,921 INFO SessionFactoryObjectFactory:82 - Not binding factory