执行sql出现No Dialect mapping for JDBC type: -9错误

我在执行hibernatesql语句查询是报No Dialect mapping for JDBC type: -9错误,sql语句是:select top 3 name from sys.tables where name like 'LogInfo_%' and name <= 'LogInfo_2015_01' order by Name desc,是查询数据库表名称的,数据库测试语句没问题,数据库是SQLserver2008,各位大神帮看看啦,小弟第一次逛这里,对于悬赏什么的都不是很清楚,也没金币,但还是厚着脸皮问问各位大神,谢谢了

sql

4个回答

http://blog.csdn.net/xd195666916/article/details/5419316

import org.hibernate.dialect.SQLServerDialect;  

public class SqlServer2008Dialect extends SQLServerDialect {  

    public SqlServer2008Dialect() {  
        super();  
        registerHibernateType(1, "string");  
        registerHibernateType(-9, "string");  
        registerHibernateType(-16, "string");  
        registerHibernateType(3, "double");  
    }  
}  

name的数据类型是nvarchar吗?如果是改为varchar类型应该能运行,但是这个治标不治本,这是hibernate没映射nvarchar

and name <= 'LogInfo_2015_01'

name是字符串,怎么能 <='LogInfo_2015_01'

oracle sql不支持top,可以用rownum<=3这个条件来实现

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
谁能帮我看看这样写为什么不对啊
<pre name="code" class="java">public List&lt;dashiji&gt; showDashiji(final MyPagination mypage, int zuzhiid) { String sql = "select count(*) From dashiji where zuzhiid=" + zuzhiid; SQLQuery query = this.getSession().createSQLQuery(sql); int totalRecord = ((BigInteger) query.list().get(0)).intValue(); mypage.setTotalRecords(totalRecord); mypage.setTotalPages(mypage.getTotalPages()); final String sql2 = "select * from dashiji where zuzhiid=" + zuzhiid + " order by id desc"; // return (List&lt;dashiji&gt;) this.getHibernateTemplate().execute( // new HibernateCallback() { // public Object doInHibernate(Session session) // throws HibernateException, SQLException { // SQLQuery query2 = session.createSQLQuery(sql2); // query2.addEntity("d", DaShiJi.class); // query2.setFirstResult((mypage.getCurPage() - 1) // * mypage.getPageSize()); // query2.setMaxResults(mypage.getPageSize()); // return query2.list(); // } // }); SQLQuery query2 = this.getSession().createSQLQuery(sql2); query2.setFirstResult((mypage.getCurPage() - 1) * mypage.getPageSize()); query2.setMaxResults(mypage.getPageSize()); return query2.list(); }  错误提示: org.hibernate.MappingException: No Dialect mapping for JDBC type: -1 如果用注释了的那段代码就没问题了,这是怎么回事啊,大家帮帮忙,我是个新手,谢谢</pre>  
碰到no suitable driver found for jdbc:mysql//localhost:3306/qzhao 错误
我在家里的电脑上用eclipse建了一个简单的hibernate工程. 运行的时候碰到no suitable driver found for jdbc:mysql//localhost:3306/qzhao 异常。 我在网上搜了很多答案,比如把jar放在jre/lib/ext下面,都不行。 奇怪的是在我单位工作电脑上,同样的项目就能work。也没有把jar包放在jre下面。我家里用的是win7,jdk装在C:\pogram files下面。连接配置都是好的。还有家里mysql是和eclipse装在同一台电脑上。工作单位是在服务器上。 请高手解释?昨晚折腾了一夜。最后网速暴慢就睡觉了。 [b]问题补充:[/b] 我的不是一个web程序,就是一个普通的eclipse java project。我已经把jar加到eclipse project里面了。而且用这个jar包用一般的java code可以连接啊 [b]问题补充:[/b] 谢谢各位的答案 出现这样的情况,一般有四种原因: 一:连接URL格式出现了问题(Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/XX","root","XXXX") [qzhao]:我的配置如下: <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://10.111.3.244:3306/qzhao_opbook</property> <property name="connection.username">qzhao</property> <property name="connection.password">qzhao</property> <!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.MySQLDialect</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="org/hibernate/tutorial/domain/Event.hbm.xml" /> 而且在我单位电脑能work 二:驱动字符串出错(com.mysql.jdbc.Driver) 三:Classpath中没有加入合适的mysql_jdbc驱动(驱动要和你的数据库版本一致) 这个我用的是mysql-connector-java-5.0.4-bin.jar,数据库是5.0 四:驱动jar包放的位置不对 我把它加到eclipse project build path里面的。同样在单位电脑上可以工作的。所以我很疑惑,难道是因为家里的电脑jdk路径下面有空格或者是win7的原因?? [b]问题补充:[/b] 问题找到了,是url错了。 分就给walsh吧
ssh环境配置问题总是出现警告信息 数据库可以操作成功警告信息怎么去掉
2016-10-31 18:59:28 org.hibernate.annotations.common.Version <clinit> 信息: Hibernate Commons Annotations 3.2.0.Final 2016-10-31 18:59:28 org.hibernate.cfg.Environment <clinit> 信息: Hibernate 3.6.0.Final 2016-10-31 18:59:28 org.hibernate.cfg.Environment <clinit> 信息: hibernate.properties not found 2016-10-31 18:59:28 org.hibernate.cfg.Environment buildBytecodeProvider 信息: Bytecode provider name : javassist 2016-10-31 18:59:28 org.hibernate.cfg.Environment <clinit> 信息: using JDK 1.4 java.sql.Timestamp handling 2016-10-31 18:59:28 org.hibernate.util.DTDEntityResolver resolveEntity 警告: recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 2016-10-31 18:59:28 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues 信息: Mapping class: cn.itcast.test.entity.Person -> person 2016-10-31 18:59:28 org.hibernate.cfg.Configuration applyHibernateValidatorLegacyConstraintsOnDDL 信息: Hibernate Validator not found: ignoring 2016-10-31 18:59:28 org.hibernate.cfg.search.HibernateSearchEventListenerRegister enableHibernateSearch 信息: Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled. 2016-10-31 18:59:28 org.hibernate.connection.ConnectionProviderFactory initializeConnectionProviderFromConfig 信息: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Database -> name : MySQL version : 5.5.40 major : 5 minor : 5 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Driver -> name : MySQL-AB JDBC Driver version : mysql-connector-java-5.1.7 ( Revision: ${svn.Revision} ) major : 5 minor : 1 2016-10-31 18:59:28 org.hibernate.dialect.Dialect <init> 信息: Using dialect: org.hibernate.dialect.MySQL5Dialect 2016-10-31 18:59:28 org.hibernate.engine.jdbc.JdbcSupportLoader useContextualLobCreation 信息: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 2016-10-31 18:59:28 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory 信息: Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory 2016-10-31 18:59:28 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup 信息: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Automatic flush during beforeCompletion(): disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Automatic session close at end of transaction: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC batch size: 15 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC batch updates for versioned data: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Scrollable result sets: enabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC3 getGeneratedKeys(): enabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Connection release mode: auto 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Maximum outer join fetch depth: 2 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Default batch fetch size: 1 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Generate SQL with comments: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Order SQL updates by primary key: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Order SQL inserts for batching: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory 信息: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2016-10-31 18:59:28 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init> 信息: Using ASTQueryTranslatorFactory 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Query language substitutions: {} 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: JPA-QL strict compliance: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Second-level cache: enabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Query cache: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory createRegionFactory 信息: Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Optimize cache for minimal puts: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Structured second-level cache entries: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Echoing all SQL to stdout 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Statistics: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Deleted entity synthetic identifier rollback: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Default entity-mode: pojo 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Named query checking : enabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Check Nullability in Core (should be disabled when Bean Validation is on): disabled 2016-10-31 18:59:28 org.hibernate.impl.SessionFactoryImpl <init> 信息: building session factory 2016-10-31 18:59:28 org.hibernate.id.UUIDHexGenerator <init> 警告: Using org.hibernate.id.UUIDHexGenerator which does not generate IETF RFC 4122 compliant UUID values; consider using org.hibernate.id.UUIDGenerator instead 2016-10-31 18:59:29 org.hibernate.impl.SessionFactoryObjectFactory addInstance 信息: Not binding factory to JNDI, no JNDI name configured 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: Running hbm2ddl schema update 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: fetching database metadata 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: updating schema 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: table found: day17.person 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: columns: [id, name] 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: foreign keys: [] 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: indexes: [primary] 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: schema update complete Hibernate: insert into person (name, id) values (?, ?)
oracle11g连接Hibernate遇到问题了。连着连着就断开了。求大神解答
``` 2015-9-5 0:04:42 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000006: Autocommit mode: false 2015-9-5 0:04:42 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000401: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@localhost:1521:ORCL] 2015-9-5 0:04:42 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000046: Connection properties: {useUnicode=true, user=hr, password=****, characterEncoding=UTF-8, pool.size=1} 2015-9-5 0:04:43 org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.OracleDialect 2015-9-5 0:04:43 or ``` ``` g.hibernate.dialect.Oracle9Dialect <init> WARN: HHH000063: The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead 2015-9-5 0:04:43 org.hibernate.dialect.OracleDialect <init> WARN: HHH000064: The OracleDialect dialect has been deprecated; use Oracle8iDialect instead 2015-9-5 0:04:43 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException 2015-9-5 0:04:43 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService INFO: HHH000399: Using default transaction strategy (direct JDBC transactions) 2015-9-5 0:04:44 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init> INFO: HHH000397: Using ASTQueryTranslatorFactory ``` ------------------------------------------------ 以上是错误信息,下面是我的配置 -------------------------------------------------- ``` <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <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">hr</property> <property name="connection.password">08</property> <property name="dialect">org.hibernate.dialect.OracleDialect</property> <property name="show_sql">true</property> <property name="hibernate.connection.pool.size">1</property> <property name="hibernate.statement_cache.size">25</property> <property name="hibernate.jdbc.fetch_size">50</property> <property name="hibernate.jdbc.batch_size">30</property> <property name="connection.useUnicode">true</property> <property name="connection.characterEncoding">UTF-8</property> <mapping resource="com/wx/beans/User.hbm.xml"/> </session-factory> </hibernate-configuration> ``` 求高人解答。。
hibernate执行保存对象时出现异常:org.hibernate.exception.GenericJDBCException
hibernate执行保存对象时出现异常: org.hibernate.exception.GenericJDBCException: could not insert: [com.hibernate.domain.User] Caused by: java.sql.SQLException: Field 'user_id' doesn't have a default value 具体的代码和配置如下: **hibernate.cfg.xml:** <hibernate-configuration> <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/hibernate3</property> <property name="connection.username">root</property> <property name="connection.password">ytkj</property> <!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.MySQLDialect</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 --> <!-- show sql dml --> <property name="show_sql">true</property> <!-- Drop and re-create the database schema on startup --> <!-- <property name="hbm2ddl.auto">update</property> --> <mapping resource="com/hibernate/domain/User.hbm.xml"/> </session-factory> </hibernate-configuration> ------------------------------------------------------------------------ 建表语句(成功): CREATE TABLE `t_user` ( `user_id` int(11) NOT NULL, `user_name` varchar(20) default NULL, `user_age` int(11) default NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ------------------------------------------------------------------ **测试类:** package com.hibernate.manager; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import com.hibernate.domain.User; import com.hibernate.util.HibernateUtil; public class UserManager { public static void main(String[] args) { SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); Session session = sessionFactory.openSession(); Transaction ts = session.beginTransaction(); User user = new User(); user.setId(1); user.setName("zhangsan"); user.setAge(21); session.save(user); ts.commit(); session.close(); sessionFactory.close(); } } ----------------------------------------------------------------------- **User.hbm.xml:** <hibernate-mapping package="com.hibernate.domain"> <class name="User" table="t_user"> <id name="id" column="user_id"> <generator class="native"/> </id> <!-- <id name="id" type="int" column="user_id"/> --> <property name="name" type="string" column="user_name"/> <property name="age" type="int" column="user_age"/> </class> </hibernate-mapping> ------------------------------------------------------------------------- 以上代码执行过后,就包上面的异常。 如果不使用id生成策略(及时没有generator标签),则可以insert成功。 请问这问题是出在哪里?高手指点。
juit测试ssh时总是出现下面的红色字体,虽然不影响,但是怎么能不让他显示出来
2016-6-22 21:46:26 org.hibernate.annotations.common.Version <clinit> 信息: Hibernate Commons Annotations 3.2.0.Final 2016-6-22 21:46:26 org.hibernate.cfg.Environment <clinit> 信息: Hibernate 3.6.0.Final 2016-6-22 21:46:26 org.hibernate.cfg.Environment <clinit> 信息: hibernate.properties not found 2016-6-22 21:46:26 org.hibernate.cfg.Environment buildBytecodeProvider 信息: Bytecode provider name : javassist 2016-6-22 21:46:26 org.hibernate.cfg.Environment <clinit> 信息: using JDK 1.4 java.sql.Timestamp handling 2016-6-22 21:46:26 org.hibernate.util.DTDEntityResolver resolveEntity 警告: recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 2016-6-22 21:46:26 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues 信息: Mapping class: cn.itcast.test.entity.Person -> person 2016-6-22 21:46:26 org.hibernate.cfg.Configuration applyHibernateValidatorLegacyConstraintsOnDDL 信息: Hibernate Validator not found: ignoring 2016-6-22 21:46:26 org.hibernate.cfg.search.HibernateSearchEventListenerRegister enableHibernateSearch 信息: Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled. 2016-6-22 21:46:26 org.hibernate.connection.ConnectionProviderFactory initializeConnectionProviderFromConfig 信息: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider 2016-6-22 21:46:27 org.hibernate.dialect.Dialect <init> 信息: Using dialect: org.hibernate.dialect.MySQL5Dialect 2016-6-22 21:46:27 org.hibernate.engine.jdbc.JdbcSupportLoader useContextualLobCreation 信息: Disabling contextual LOB creation as connection was null 2016-6-22 21:46:27 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory 信息: Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory 2016-6-22 21:46:27 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup 信息: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Automatic flush during beforeCompletion(): disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Automatic session close at end of transaction: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Scrollable result sets: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC3 getGeneratedKeys(): disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Connection release mode: auto 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Maximum outer join fetch depth: 2 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Default batch fetch size: 1 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Generate SQL with comments: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Order SQL updates by primary key: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Order SQL inserts for batching: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory 信息: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2016-6-22 21:46:27 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init> 信息: Using ASTQueryTranslatorFactory 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Query language substitutions: {} 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: JPA-QL strict compliance: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Second-level cache: enabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Query cache: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory createRegionFactory 信息: Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Optimize cache for minimal puts: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Structured second-level cache entries: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Echoing all SQL to stdout 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Statistics: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Deleted entity synthetic identifier rollback: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Default entity-mode: pojo 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Named query checking : enabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Check Nullability in Core (should be disabled when Bean Validation is on): disabled 2016-6-22 21:46:27 org.hibernate.impl.SessionFactoryImpl <init> 信息: building session factory 2016-6-22 21:46:27 org.hibernate.id.UUIDHexGenerator <init> 警告: Using org.hibernate.id.UUIDHexGenerator which does not generate IETF RFC 4122 compliant UUID values; consider using org.hibernate.id.UUIDGenerator instead 2016-6-22 21:46:27 org.hibernate.impl.SessionFactoryObjectFactory addInstance 信息: Not binding factory to JNDI, no JNDI name configured 2016-6-22 21:46:27 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: Running hbm2ddl schema update 2016-6-22 21:46:27 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: fetching database metadata 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: updating schema 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: table found: itcastTax.person 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: columns: [id, name] 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: foreign keys: [] 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: indexes: [primary] 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: schema update complete
用SQL查询出现的错误!
List<Daymarketinfo> dkList = new ArrayList<Daymarketinfo>(); Session session = HibernateSessionFactory.getSession(); String sql = "SELECT Daymarketinfo.* FROM (select * from daymarketinfo d order by market_time desc ) as Daymarketinfo group by contract_id;"; Query query = session.createSQLQuery(sql); List<Daymarketinfo> list = query.list();//错误出现位置 for (Daymarketinfo dk : list) { dkList.add(dk); } request.setAttribute("dkList", dkList); return mapping.findForward("success"); org.hibernate.MappingException: No Dialect mapping for JDBC type: 7 at org.hibernate.dialect.TypeNames.get(TypeNames.java:56) at org.hibernate.dialect.TypeNames.get(TypeNames.java:81) at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:192) at org.hibernate.loader.custom.CustomLoader.getHibernateType(CustomLoader.java:161) at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:131) at org.hibernate.loader.Loader.getResultSet(Loader.java:1678) at org.hibernate.loader.Loader.doQuery(Loader.java:662) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.doList(Loader.java:2145) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) at org.hibernate.loader.Loader.list(Loader.java:2024) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164) at com.futures.action.manage.DaymarketinfoAction.execute(DaymarketinfoAction.java:57) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:105) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) [b]问题补充:[/b] <property name="dialect"> org.hibernate.dialect.MySQLDialect </property> 已经配置上了
handling transient entity in delete processing什么意思
菜鸟向各位高手求教,在使用delete时候,提示handling transient entity in delete processing. 方法如下: public void delete(Member persistentInstance) { log.debug("deleting Member instance"); try { getSession().beginTransaction(); getSession().delete(persistentInstance); log.debug("delete successful"); getSession().beginTransaction().commit(); } catch (RuntimeException re) { log.error("delete failed", re); throw re; } finally { if(getSession().beginTransaction()!=null) getSession().beginTransaction().rollback(); getSession().beginTransaction().commit(); Close(); } } 数据库是postgres。表结构CREATE TABLE member ( id integer NOT NULL, name character varying, pw character varying, sex character varying, identity serial NOT NULL, CONSTRAINT pk PRIMARY KEY (identity) ) 请指教,谢谢了!!! [b]问题补充:[/b] 其实也不是什么错误,就一直在delete processing中,就不删除数据。 信息如下: INFO - Hibernate 3.2.5 INFO - hibernate.properties not found INFO - Bytecode provider name : cglib INFO - using JDK 1.4 java.sql.Timestamp handling INFO - configuring from resource: /hibernate.cfg.xml INFO - Configuration resource: /hibernate.cfg.xml INFO - Reading mappings from resource : com/ison/hibernate/beans/Member.hbm.xml INFO - Mapping class: com.ison.hibernate.beans.Member -> member INFO - Reading mappings from resource : com/ison/hibernate/beans/Parnter.hbm.xml INFO - Mapping class: com.ison.hibernate.beans.Parnter -> parnter INFO - Configured SessionFactory: null INFO - Using Hibernate built-in connection pool (not for production use!) INFO - Hibernate connection pool size: 20 INFO - autocommit mode: false INFO - using driver: org.postgresql.Driver at URL: jdbc:postgresql://127.0.0.1:5432/Demo INFO - connection properties: {user=ison_sa, password=****} INFO - RDBMS: PostgreSQL, version: 8.2.3 INFO - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC3 with SSL (build 506) INFO - Using dialect: org.hibernate.dialect.PostgreSQLDialect INFO - Using default transaction strategy (direct JDBC transactions) INFO - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) INFO - Automatic flush during beforeCompletion(): disabled INFO - Automatic session close at end of transaction: disabled INFO - JDBC batch size: 15 INFO - JDBC batch updates for versioned data: disabled INFO - Scrollable result sets: enabled INFO - JDBC3 getGeneratedKeys(): disabled INFO - Connection release mode: auto INFO - Default batch fetch size: 1 INFO - Generate SQL with comments: enabled INFO - Order SQL updates by primary key: disabled INFO - Order SQL inserts for batching: disabled INFO - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory INFO - Using ASTQueryTranslatorFactory INFO - Query language substitutions: {} INFO - JPA-QL strict compliance: disabled INFO - Second-level cache: enabled INFO - Query cache: disabled INFO - Cache provider: org.hibernate.cache.NoCacheProvider INFO - Optimize cache for minimal puts: disabled INFO - Structured second-level cache entries: disabled INFO - Echoing all SQL to stdout INFO - Statistics: disabled INFO - Deleted entity synthetic identifier rollback: disabled INFO - Default entity-mode: pojo INFO - Named query checking : enabled INFO - building session factory INFO - Not binding factory to JNDI, no JNDI name configured INFO - handling transient entity in delete processing [b]问题补充:[/b] 现在上面提示不变,多了 Exception in thread "main" org.hibernate.SessionException: Session was already closed [b]问题补充:[/b] 对,你讲的非常正确!谢谢。 不过,那是我在试了N种方法后依然只得到handling transient entity in delete processing 这样的提示而无法从数据库中删除数据后,胡乱加的,呵呵。见笑了。 另外,我if控制的只有rollback(),现在我改了,可是依然没有删除数据啊, 我实在不解,请高手点拨啊! [b]问题补充:[/b] 我晕了,改了之后提示跟我一开始贴出来的一样,连结果都是一样,数据没有删除 [b]问题补充:[/b] 有id,但跟数据库的ID不一致。原来这样 [b]问题补充:[/b] 多谢! 有问题再请教!!
新手Hibernate写了个小程序,第一次运行报错如下,好像还有数据库连不上的问题,不知道该怎么改
九月 07, 2015 10:31:46 下午 org.hibernate.annotations.common.Version <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final} 九月 07, 2015 10:31:46 下午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.1.4.Final} 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: com/xdc/Product/Product.hbm.xml 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!) 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH000148: No JDBC Driver class was specified by property hibernate.connection.driver_class 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000115: Hibernate connection pool size: 20 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000006: Autocommit mode: false 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000401: using driver [null] at URL [jdbc:mysql://localhost:3306/db_database10] 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000046: Connection properties: {user=root, password=****} 九月 07, 2015 10:31:46 下午 org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure WARN: HHH000342: Could not obtain connection to query metadata : No suitable driver found for jdbc:mysql://localhost:3306/db_database10 九月 07, 2015 10:31:46 下午 org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 九月 07, 2015 10:31:46 下午 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation INFO: HHH000422: Disabling contextual LOB creation as connection was null 九月 07, 2015 10:31:46 下午 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService INFO: HHH000399: Using default transaction strategy (direct JDBC transactions) 九月 07, 2015 10:31:46 下午 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init> INFO: HHH000397: Using ASTQueryTranslatorFactory 九月 07, 2015 10:31:46 下午 org.hibernate.validator.util.Version <clinit> 信息: Hibernate Validator bean-validator-3.0-JBoss-4.0.2 九月 07, 2015 10:31:46 下午 org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA 信息: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver. 九月 07, 2015 10:31:46 下午 org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA 信息: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver. 九月 07, 2015 10:31:47 下午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions WARN: SQL Error: 0, SQLState: 08001 九月 07, 2015 10:31:47 下午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: No suitable driver found for jdbc:mysql://localhost:3306/db_database10 添加数据库失败! org.hibernate.exception.JDBCConnectionException: Could not open connection at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:131) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304) at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169) at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160) at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1396) at com.xdc.main.AddProduct.main(AddProduct.java:19) Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/db_database10 at java.sql.DriverManager.getConnection(DriverManager.java:596) at java.sql.DriverManager.getConnection(DriverManager.java:187) at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193) at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:281) at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297) ... 5 more 配置如下 <hibernate-configuration> <session-factory> <!-- 数据库驱动 --> <property name="connect.driver_class"> com.mysql.jdbc.Driver </property> <!-- 数据库连接的URL --> <property name="connection.url"> jdbc:mysql://localhost:3306/db_database10 </property> <!-- 数据库连接用户名 --> <property name="connection.username">root</property> <!-- 数据库连接密码 --> <property name="connection.password">123321</property> <!-- Hibernate方言 --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- 打印sql语句 --> <property name="show_sql">true</property> <!-- 映射文件 --> <mapping resource="com/xdc/Product/Product.hbm.xml" /> </session-factory> </hibernate-configuration>
hibernate的sessionFactory的问题
<div class="iteye-blog-content-contain" style="font-size: 14px;"> <pre name="code" class="错误信息">2014-8-8 17:29:19 org.hibernate.cfg.Environment &lt;clinit&gt; 信息: Hibernate 3.2.7 2014-8-8 17:29:19 org.hibernate.cfg.Environment &lt;clinit&gt; 信息: 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 &lt;clinit&gt; 信息: 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 -&gt; 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 &lt;init&gt; 信息: Using dialect: org.hibernate.dialect.OracleDialect 2014-8-8 17:29:21 org.hibernate.dialect.Oracle9Dialect &lt;init&gt; 警告: The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead 2014-8-8 17:29:21 org.hibernate.dialect.OracleDialect &lt;init&gt; 警告: 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 &lt;init&gt; 信息: 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 &lt;init&gt; 信息: 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.&lt;init&gt;(EntityEntityModeToTuplizerMapping.java:56) at org.hibernate.tuple.entity.EntityMetamodel.&lt;init&gt;(EntityMetamodel.java:323) at org.hibernate.persister.entity.AbstractEntityPersister.&lt;init&gt;(AbstractEntityPersister.java:433) at org.hibernate.persister.entity.SingleTableEntityPersister.&lt;init&gt;(SingleTableEntityPersister.java:109) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.&lt;init&gt;(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.&lt;init&gt;(AbstractEntityTuplizer.java:128) at org.hibernate.tuple.entity.PojoEntityTuplizer.&lt;init&gt;(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 </pre> <p> </p> <pre name="code" class="hibernate.cfg.xml">&lt;?xml version='1.0' encoding='utf-8'?&gt; &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt; &lt;hibernate-configuration&gt; &lt;session-factory&gt; &lt;!-- Database connection settings --&gt; &lt;property name="connection.driver_class"&gt;oracle.jdbc.driver.OracleDriver&lt;/property&gt; &lt;property name="connection.url"&gt;jdbc:oracle:thin:@localhost:1521:orcl&lt;/property&gt; &lt;property name="connection.username"&gt;xxx&lt;/property&gt; &lt;property name="connection.password"&gt;xxx&lt;/property&gt; &lt;!-- JDBC connection pool (use the built-in) --&gt; &lt;property name="connection.pool_size"&gt;1&lt;/property&gt; &lt;!-- SQL dialect --&gt; &lt;property name="dialect"&gt;org.hibernate.dialect.OracleDialect&lt;/property&gt; &lt;!-- Enable Hibernate's automatic session context management --&gt; &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt; &lt;!-- Disable the second-level cache --&gt; &lt;property name="cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt; &lt;!-- Echo all executed SQL to stdout --&gt; &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;!-- Drop and re-create the database schema on startup --&gt; &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt; &lt;mapping resource="com/bjsxt/hibernate/Student.hbm.xml"/&gt; &lt;mapping class="com.bjsxt.hibernate.Teacher"/&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt;</pre> <p> </p> <pre name="code" class="Teacher.java">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; } } </pre> <p> </p> <pre name="code" class="TeacherTest">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(); } } </pre> <p> </p> </div>
在eclipse中运行Hibernate,出现Autocommit mode: false错误
我的Hibernate版本是:5.2.2以下是代码与错误提示 no1 一月 13, 2017 9:25:47 下午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {5.2.2.Final} 一月 13, 2017 9:25:47 下午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 一月 13, 2017 9:25:47 下午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist no2 一月 13, 2017 9:25:47 下午 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 一月 13, 2017 9:25:47 下午 org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-mapping. Use namespace http://www.hibernate.org/dtd/hibernate-mapping instead. Support for obsolete DTD/XSD namespaces may be removed at any time. 一月 13, 2017 9:25:48 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!) 一月 13, 2017 9:25:48 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql:///testhibernate] 一月 13, 2017 9:25:48 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001001: Connection properties: {user=root, password=****} 一月 13, 2017 9:25:48 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001003: Autocommit mode: false Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:36) at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:20) at org.hibernate.engine.jdbc.connections.internal.PooledConnections$Builder.build(PooledConnections.java:161) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:109) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:72) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:240) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:257) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:231) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:240) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87) at org.hibernate.boot.MetadataSources.buildMetadata(MetadataSources.java:179) at com.hibernate.test1.test.main(test.java:17) --------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql:///testhibernate</property> <property name="connection.username">root</property> <property name="connection.password">root</property> <!-- <property name="dialect">org.hibernate.dialect.MySQLDialect</property> --> <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <property name="hbm2ddl.auto">update</property> <property name="show_sql">true</property> <mapping resource="com/hibernate/bean/LoginBean.hbm.xml"/> </session-factory> </hibernate-configuration> ----------------------------------------------------------- package com.hibernate.test1; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; public class test { public static void main(String[] args) { // TODO Auto-generated method stub StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build(); SessionFactory sessionfactory=new MetadataSources(registry).buildMetadata().buildSessionFactory(); Session session=sessionfactory.openSession(); Transaction transaction=session.beginTransaction(); log log1=new log(); log1.setName("nihao"); log1.setPass("dkjk"); session.save(log1); transaction.commit(); } } ----------------------------------------------- <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Generated 2017-1-13 18:13:48 by Hibernate Tools 3.5.0.Final --> <hibernate-mapping> <class name="com.hibernate.test.log" table="LOG"> <id name="name" type="java.lang.String"> <column name="NAME" /> <generator class="assigned" /> </id> <property name="pass" type="java.lang.String"> <column name="PASS" /> </property> </class> </hibernate-mapping>
hibernate查询是否使用了ehcache的缓存了?
下面是测试代码: package org.abin.lee.test; import java.util.List; import junit.framework.TestCase; import org.abin.lee.entity.Department; import org.abin.lee.service.UserService; import org.junit.Before; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class TestQueryEhCache extends TestCase { public UserService userService; private ApplicationContext context; @Before public void setUp() { context = new ClassPathXmlApplicationContext(new String[] { "org/abin/lee/spring/applicationContext-resource.xml", "org/abin/lee/spring/applicationContext-service.xml", "org/abin/lee/spring/applicationContext-dao.xml" }); } public void testQueryEhCache() { userService = (UserService) this.context.getBean("userService"); List<Department> list=null; System.out.println("下面是执行第一次查询"); try { list= this.userService.findAllDepartment(); } catch (Exception e) { e.printStackTrace(); } for(Department department:list){ System.out.println("did="+department.getDid()+",dname="+department.getDname()+",employee="+department.getEmployee()); } System.out.println("下面是执行第二次查询"); try { list= this.userService.findAllDepartment(); } catch (Exception e) { e.printStackTrace(); } for(Department department:list){ System.out.println("did="+department.getDid()+",dname="+department.getDname()+",employee="+department.getEmployee()); } } public UserService getUserService() { return userService; } public void setUserService(UserService userService) { this.userService = userService; } } 下面是控制台的打印信息: 2012-05-15 12:24:09 [org.springframework.context.support.ClassPathXmlApplicationContext]-[INFO] Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@a0dcd9: startup date [Tue May 15 12:24:09 CST 2012]; root of context hierarchy 2012-05-15 12:24:09 [org.springframework.beans.factory.xml.XmlBeanDefinitionReader]-[INFO] Loading XML bean definitions from class path resource [org/abin/lee/spring/applicationContext-resource.xml] 2012-05-15 12:24:10 [org.springframework.beans.factory.xml.XmlBeanDefinitionReader]-[INFO] Loading XML bean definitions from class path resource [org/abin/lee/spring/applicationContext-service.xml] 2012-05-15 12:24:10 [org.springframework.beans.factory.xml.XmlBeanDefinitionReader]-[INFO] Loading XML bean definitions from class path resource [org/abin/lee/spring/applicationContext-dao.xml] 2012-05-15 12:24:10 [org.springframework.beans.factory.support.DefaultListableBeanFactory]-[INFO] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1362012: defining beans [dataSource,sessionFactory,hibernateTemplate,transactionManager,transactionInterceptor,org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator#0,userService,userDao]; root of factory hierarchy 2012-05-15 12:24:10 [org.hibernate.cfg.Environment]-[INFO] Hibernate 3.2.5 2012-05-15 12:24:10 [org.hibernate.cfg.Environment]-[INFO] hibernate.properties not found 2012-05-15 12:24:10 [org.hibernate.cfg.Environment]-[INFO] Bytecode provider name : cglib 2012-05-15 12:24:10 [org.hibernate.cfg.Environment]-[INFO] using JDK 1.4 java.sql.Timestamp handling 2012-05-15 12:24:11 [org.hibernate.cfg.HbmBinder]-[INFO] Mapping class: org.abin.lee.entity.Department -> department 2012-05-15 12:24:11 [org.hibernate.cfg.HbmBinder]-[INFO] Mapping class: org.abin.lee.entity.Employee -> employee 2012-05-15 12:24:11 [org.hibernate.cfg.HbmBinder]-[INFO] Mapping collection: org.abin.lee.entity.Department.employee -> employee 2012-05-15 12:24:11 [org.springframework.orm.hibernate3.LocalSessionFactoryBean]-[INFO] Building new Hibernate SessionFactory 2012-05-15 12:24:11 [org.hibernate.connection.ConnectionProviderFactory]-[INFO] Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] RDBMS: MySQL, version: 5.5.15 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.0-beta ( $Date: 2005-11-17 16:14:47 +0100 (Thu, 17 Nov 2005) $, $Revision$ ) 2012-05-15 12:24:11 [org.hibernate.dialect.Dialect]-[INFO] Using dialect: org.hibernate.dialect.MySQLDialect 2012-05-15 12:24:11 [org.hibernate.transaction.TransactionFactoryFactory]-[INFO] Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory 2012-05-15 12:24:11 [org.hibernate.transaction.TransactionManagerLookupFactory]-[INFO] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Automatic flush during beforeCompletion(): disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Automatic session close at end of transaction: disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] JDBC batch size: 15 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] JDBC batch updates for versioned data: disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Scrollable result sets: enabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] JDBC3 getGeneratedKeys(): enabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Connection release mode: after_transaction 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Maximum outer join fetch depth: 2 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Default batch fetch size: 1 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Generate SQL with comments: disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Order SQL updates by primary key: disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Order SQL inserts for batching: disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2012-05-15 12:24:11 [org.hibernate.hql.ast.ASTQueryTranslatorFactory]-[INFO] Using ASTQueryTranslatorFactory 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Query language substitutions: {} 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] JPA-QL strict compliance: disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Second-level cache: enabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Query cache: enabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Cache provider: org.hibernate.cache.EhCacheProvider 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Optimize cache for minimal puts: disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Structured second-level cache entries: disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Query cache factory: org.hibernate.cache.StandardQueryCacheFactory 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Echoing all SQL to stdout 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Statistics: disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Deleted entity synthetic identifier rollback: disabled 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Default entity-mode: pojo 2012-05-15 12:24:11 [org.hibernate.cfg.SettingsFactory]-[INFO] Named query checking : enabled 2012-05-15 12:24:11 [org.hibernate.impl.SessionFactoryImpl]-[INFO] building session factory 2012-05-15 12:24:12 [org.hibernate.cache.CacheFactory]-[DEBUG] instantiating cache region: org.abin.lee.entity.Employee usage strategy: read-only 2012-05-15 12:24:12 [org.hibernate.cache.CacheFactory]-[WARN] read-only cache configured for mutable class: org.abin.lee.entity.Employee 2012-05-15 12:24:12 [org.hibernate.cache.CacheFactory]-[DEBUG] instantiating cache region: org.abin.lee.entity.Department usage strategy: read-only 2012-05-15 12:24:12 [org.hibernate.cache.CacheFactory]-[WARN] read-only cache configured for mutable class: org.abin.lee.entity.Department 2012-05-15 12:24:12 [org.hibernate.impl.SessionFactoryObjectFactory]-[INFO] Not binding factory to JNDI, no JNDI name configured 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.SchemaUpdate]-[INFO] Running hbm2ddl schema update 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.SchemaUpdate]-[INFO] fetching database metadata 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.SchemaUpdate]-[INFO] updating schema 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.TableMetadata]-[INFO] table found: abin.department 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.TableMetadata]-[INFO] columns: [dname, did] 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.TableMetadata]-[INFO] foreign keys: [] 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.TableMetadata]-[INFO] indexes: [primary] 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.TableMetadata]-[INFO] table found: abin.employee 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.TableMetadata]-[INFO] columns: [ename, did, eid] 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.TableMetadata]-[INFO] foreign keys: [fdid, fk4722e6aefea415dc] 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.TableMetadata]-[INFO] indexes: [primary, fk4722e6aefea415dc] 2012-05-15 12:24:12 [org.hibernate.tool.hbm2ddl.SchemaUpdate]-[INFO] schema update complete 2012-05-15 12:24:12 [org.hibernate.cache.UpdateTimestampsCache]-[INFO] starting update timestamps cache at region: org.hibernate.cache.UpdateTimestampsCache 2012-05-15 12:24:12 [org.hibernate.cache.StandardQueryCache]-[INFO] starting query cache at region: org.hibernate.cache.StandardQueryCache 2012-05-15 12:24:12 [org.springframework.orm.hibernate3.HibernateTransactionManager]-[INFO] Using DataSource [org.apache.commons.dbcp.BasicDataSource@1fa39bb] of Hibernate SessionFactory for HibernateTransactionManager 下面是执行第一次查询 2012-05-15 12:24:13 [org.hibernate.cache.StandardQueryCache]-[DEBUG] checking cached query results in region: org.hibernate.cache.StandardQueryCache 2012-05-15 12:24:13 [org.hibernate.cache.EhCache]-[DEBUG] key: sql: select department0_.did as did0_, department0_.dname as dname0_ from abin.department department0_ order by department0_.did desc; parameters: ; named parameters: {} 2012-05-15 12:24:13 [org.hibernate.cache.EhCache]-[DEBUG] Element for sql: select department0_.did as did0_, department0_.dname as dname0_ from abin.department department0_ order by department0_.did desc; parameters: ; named parameters: {} is null 2012-05-15 12:24:13 [org.hibernate.cache.StandardQueryCache]-[DEBUG] query results were not found in cache Hibernate: select department0_.did as did0_, department0_.dname as dname0_ from abin.department department0_ order by department0_.did desc 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Caching: org.abin.lee.entity.Department#fde9fe25-ea81-4168-b9bc-422858128358 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Caching: org.abin.lee.entity.Department#15d95f71-f41b-4369-a1ae-441366f57318 Hibernate: select employee0_.did as did1_, employee0_.eid as eid1_, employee0_.eid as eid1_0_, employee0_.ename as ename1_0_, employee0_.did as did1_0_ from abin.employee employee0_ where employee0_.did=? 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Caching: org.abin.lee.entity.Employee#788d9a5a-9085-4df9-a058-8027469a1bac 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Caching: org.abin.lee.entity.Employee#924fba4c-3a9c-4f33-9e09-63e49663f9a1 Hibernate: select employee0_.did as did1_, employee0_.eid as eid1_, employee0_.eid as eid1_0_, employee0_.ename as ename1_0_, employee0_.did as did1_0_ from abin.employee employee0_ where employee0_.did=? 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Caching: org.abin.lee.entity.Employee#291e9165-dcc2-4648-bb05-47056ba8f354 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Caching: org.abin.lee.entity.Employee#e789a510-2f80-4b4b-b25e-e7e48e4869da 2012-05-15 12:24:13 [org.hibernate.cache.StandardQueryCache]-[DEBUG] caching query results in region: org.hibernate.cache.StandardQueryCache; timestamp=5476580773695488 did=fde9fe25-ea81-4168-b9bc-422858128358,dname=department2,employee=[org.abin.lee.entity.Employee@5c98f3, org.abin.lee.entity.Employee@bef361] did=15d95f71-f41b-4369-a1ae-441366f57318,dname=department1,employee=[org.abin.lee.entity.Employee@e0e515, org.abin.lee.entity.Employee@10dc656] 下面是执行第二次查询 2012-05-15 12:24:13 [org.hibernate.cache.StandardQueryCache]-[DEBUG] checking cached query results in region: org.hibernate.cache.StandardQueryCache 2012-05-15 12:24:13 [org.hibernate.cache.EhCache]-[DEBUG] key: sql: select department0_.did as did0_, department0_.dname as dname0_ from abin.department department0_ order by department0_.did desc; parameters: ; named parameters: {} 2012-05-15 12:24:13 [org.hibernate.cache.StandardQueryCache]-[DEBUG] Checking query spaces for up-to-dateness: [abin.department] 2012-05-15 12:24:13 [org.hibernate.cache.EhCache]-[DEBUG] key: abin.department 2012-05-15 12:24:13 [org.hibernate.cache.EhCache]-[DEBUG] Element for abin.department is null 2012-05-15 12:24:13 [org.hibernate.cache.StandardQueryCache]-[DEBUG] returning cached query results 2012-05-15 12:24:13 [org.hibernate.cache.EhCache]-[DEBUG] key: org.abin.lee.entity.Department#fde9fe25-ea81-4168-b9bc-422858128358 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Cache hit: org.abin.lee.entity.Department#fde9fe25-ea81-4168-b9bc-422858128358 Hibernate: select employee0_.did as did1_, employee0_.eid as eid1_, employee0_.eid as eid1_0_, employee0_.ename as ename1_0_, employee0_.did as did1_0_ from abin.employee employee0_ where employee0_.did=? 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Caching: org.abin.lee.entity.Employee#291e9165-dcc2-4648-bb05-47056ba8f354 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Caching: org.abin.lee.entity.Employee#e789a510-2f80-4b4b-b25e-e7e48e4869da 2012-05-15 12:24:13 [org.hibernate.cache.EhCache]-[DEBUG] key: org.abin.lee.entity.Department#15d95f71-f41b-4369-a1ae-441366f57318 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Cache hit: org.abin.lee.entity.Department#15d95f71-f41b-4369-a1ae-441366f57318 Hibernate: select employee0_.did as did1_, employee0_.eid as eid1_, employee0_.eid as eid1_0_, employee0_.ename as ename1_0_, employee0_.did as did1_0_ from abin.employee employee0_ where employee0_.did=? 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Caching: org.abin.lee.entity.Employee#788d9a5a-9085-4df9-a058-8027469a1bac 2012-05-15 12:24:13 [org.hibernate.cache.ReadOnlyCache]-[DEBUG] Caching: org.abin.lee.entity.Employee#924fba4c-3a9c-4f33-9e09-63e49663f9a1 did=fde9fe25-ea81-4168-b9bc-422858128358,dname=department2,employee=[org.abin.lee.entity.Employee@ff9053, org.abin.lee.entity.Employee@5c7734] did=15d95f71-f41b-4369-a1ae-441366f57318,dname=department1,employee=[org.abin.lee.entity.Employee@1000bcf, org.abin.lee.entity.Employee@754fc] 我想知道一下,第二次查询是不是使用了hibernate的ehcache查询了? 这里的Department和Employee是一对多的关系。
hibernate 连接数据库报错 获取xml失败 求大佬帮忙看一下
## 这是 hibernate.cfg.xml <?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> <property name="connection.url">jdbc:oracle:thin:@localhost:1521:ORCL</property> <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="connection.username">Reust</property> <property name="connection.password">kingstar</property> <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property> <property name="show_sql">true</property> <property name="format_sql">true</property> <property name="hbm2ddl.auto">update</property><!-- create --> <mapping resource="cd/entity/Igendpd.hbm.xml"/> <mapping resource="cd/entity/Iguser.hbm.xml"/> </session-factory> </hibernate-configuration> ## ## 这是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="cd.entity.Igendpd" table="ig_end_pd" ><!-- schema="数据库对象集合名称" --><!-- dynamic-update="true" --><!-- select-before-update="true" --> <id name="igendId" type="Integer"> <column name="ig_end_id" /> <generator class="sequence"> <param name="sequence">SEQ_IG_END_PD</param> </generator> </id> <property name="igendSex" type="string"> <column name="ig_end_sex"> <comment>性别</comment> </column> </property> </class> </hibernate-mapping> <?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="cd.entity.Iguser" table="ig_user" ><!-- schema="数据库对象集合名称" --><!-- dynamic-update="true" --><!-- select-before-update="true" --> <id name="igId" type="Integer"> <column name="ig_id" /> <generator class="sequence"> <param name="sequence">SEQ_IG_USER</param> </generator> </id> <property name="igtrueNmae" type="string"> <column name="ig_true_name"> <comment>真实姓名</comment> </column> </property> <property name="iglogName" type="string"> <column name="ig_log_name"> <comment>登陆姓名</comment> </column> </property> <property name="igAge" type="Integer"> <column name="ig_age"> <comment>年龄</comment> </column> </property> <property name="igendID" type="Integer"> <column name="ig_end_id"> <comment>性别ID</comment> </column> </property> <property name="igPwassd" type="string"> <column name="ig_pwassd"> <comment>密码</comment> </column> </property> </class> </hibernate-mapping> 这是 Configuration conf = new Configuration().configure(); 获取seesion 并测试** package meg; import java.util.List; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import cd.dao.ResultDao; import cd.entity.Iguser; public class Test { // 会话工厂 protected static SessionFactory sessionFactory = null; // 绑定到线程的集合 protected static ThreadLocal<Session> sessionThreadLocal = new ThreadLocal<Session>(); public static Session getSession() { Session session = null; if (sessionThreadLocal != null) { session = sessionThreadLocal.get(); } if (session == null) { if (sessionFactory == null) { Configuration conf = new Configuration(); conf.configure(); sessionFactory = conf.buildSessionFactory(); } session = sessionFactory.openSession(); if (sessionThreadLocal == null) { sessionThreadLocal = new ThreadLocal<Session>(); } sessionThreadLocal.set(session); } return session; } public static void main(String[] args) { Test ts=new Test(); ts.getSession(); System.out.print("连接成功"); } } ** 最后这是报错啊 ** 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration boolean -> org.hibernate.type.BooleanType@ba2e48 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration boolean -> org.hibernate.type.BooleanType@ba2e48 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Boolean -> org.hibernate.type.BooleanType@ba2e48 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration numeric_boolean -> org.hibernate.type.NumericBooleanType@130c8e9 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration true_false -> org.hibernate.type.TrueFalseType@9ed91f 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration yes_no -> org.hibernate.type.YesNoType@11a59ce 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration byte -> org.hibernate.type.ByteType@85a863 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration byte -> org.hibernate.type.ByteType@85a863 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Byte -> org.hibernate.type.ByteType@85a863 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration character -> org.hibernate.type.CharacterType@33aa9b 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration char -> org.hibernate.type.CharacterType@33aa9b 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Character -> org.hibernate.type.CharacterType@33aa9b 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration short -> org.hibernate.type.ShortType@1f920cf 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration short -> org.hibernate.type.ShortType@1f920cf 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Short -> org.hibernate.type.ShortType@1f920cf 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration integer -> org.hibernate.type.IntegerType@1773a14 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration int -> org.hibernate.type.IntegerType@1773a14 2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Integer -> org.hibernate.type.IntegerType@1773a14 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration long -> org.hibernate.type.LongType@a5ce92 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration long -> org.hibernate.type.LongType@a5ce92 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Long -> org.hibernate.type.LongType@a5ce92 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration float -> org.hibernate.type.FloatType@1bfefb 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration float -> org.hibernate.type.FloatType@1bfefb 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Float -> org.hibernate.type.FloatType@1bfefb 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration double -> org.hibernate.type.DoubleType@5c18ff 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration double -> org.hibernate.type.DoubleType@5c18ff 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Double -> org.hibernate.type.DoubleType@5c18ff 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration big_decimal -> org.hibernate.type.BigDecimalType@ae4f8b 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.math.BigDecimal -> org.hibernate.type.BigDecimalType@ae4f8b 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration big_integer -> org.hibernate.type.BigIntegerType@3d12a6 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.math.BigInteger -> org.hibernate.type.BigIntegerType@3d12a6 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration string -> org.hibernate.type.StringType@e8f27e 2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.String -> org.hibernate.type.StringType@e8f27e 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration url -> org.hibernate.type.UrlType@113e371 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.net.URL -> org.hibernate.type.UrlType@113e371 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration date -> org.hibernate.type.DateType@93886b 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.sql.Date -> org.hibernate.type.DateType@93886b 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration time -> org.hibernate.type.TimeType@3c0737 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.sql.Time -> org.hibernate.type.TimeType@3c0737 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration timestamp -> org.hibernate.type.TimestampType@9da1dd 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.sql.Timestamp -> org.hibernate.type.TimestampType@9da1dd 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.Date -> org.hibernate.type.TimestampType@9da1dd 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration dbtimestamp -> org.hibernate.type.DbTimestampType@9db0ad 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration calendar -> org.hibernate.type.CalendarType@1644028 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.Calendar -> org.hibernate.type.CalendarType@1644028 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.GregorianCalendar -> org.hibernate.type.CalendarType@1644028 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration calendar_date -> org.hibernate.type.CalendarDateType@15268d7 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration locale -> org.hibernate.type.LocaleType@b0a518 2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.Locale -> org.hibernate.type.LocaleType@b0a518 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration currency -> org.hibernate.type.CurrencyType@1313e0e 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.Currency -> org.hibernate.type.CurrencyType@1313e0e 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration timezone -> org.hibernate.type.TimeZoneType@2a2ae9 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.TimeZone -> org.hibernate.type.TimeZoneType@2a2ae9 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration class -> org.hibernate.type.ClassType@d4a1d3 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Class -> org.hibernate.type.ClassType@d4a1d3 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration uuid-binary -> org.hibernate.type.UUIDBinaryType@7f1228 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.UUID -> org.hibernate.type.UUIDBinaryType@7f1228 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration uuid-char -> org.hibernate.type.UUIDCharType@d200d8 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration pg-uuid -> org.hibernate.type.PostgresUUIDType@1f854bd 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration binary -> org.hibernate.type.BinaryType@1672313 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration byte[] -> org.hibernate.type.BinaryType@1672313 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration [B -> org.hibernate.type.BinaryType@1672313 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration wrapper-binary -> org.hibernate.type.WrapperBinaryType@1542cdc 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration Byte[] -> org.hibernate.type.WrapperBinaryType@1542cdc 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration [Ljava.lang.Byte; -> org.hibernate.type.WrapperBinaryType@1542cdc 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration image -> org.hibernate.type.ImageType@c2060e 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration characters -> org.hibernate.type.CharArrayType@75d174 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration char[] -> org.hibernate.type.CharArrayType@75d174 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration [C -> org.hibernate.type.CharArrayType@75d174 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration wrapper-characters -> org.hibernate.type.CharacterArrayType@13638d4 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration [Ljava.lang.Character; -> org.hibernate.type.CharacterArrayType@13638d4 2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration Character[] -> org.hibernate.type.CharacterArrayType@13638d4 2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration text -> org.hibernate.type.TextType@1b271f1 2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration blob -> org.hibernate.type.BlobType@5f00f9 2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.sql.Blob -> org.hibernate.type.BlobType@5f00f9 2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration materialized_blob -> org.hibernate.type.MaterializedBlobType@1535ac 2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration wrapper_materialized_blob -> org.hibernate.type.WrappedMaterializedBlobType@293b53 2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration clob -> org.hibernate.type.ClobType@101f287 2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.sql.Clob -> org.hibernate.type.ClobType@101f287 2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration materialized_clob -> org.hibernate.type.MaterializedClobType@d8f55c Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE at org.hibernate.type.BasicTypeRegistry.<init>(BasicTypeRegistry.java:94) at org.hibernate.type.TypeResolver.<init>(TypeResolver.java:59) at org.hibernate.cfg.Configuration.<init>(Configuration.java:250) at org.hibernate.cfg.Configuration.<init>(Configuration.java:302) at meg.Test.getSession(Test.java:30) at meg.Test.main(Test.java:45) # # 我直接写测试方法是能测试通的 但是写成hibernate.cfg.xml就不行了 下面是我直接在java中写的 public static void main(String[] args) { Connection con;//声明Connection对象 Statement sql; ResultSet res ; try { Class.forName("oracle.jdbc.driver.OracleDriver");//加载数据库驱动 // System.out.print("加载数据库驱动成功"); } catch (ClassNotFoundException e) { e.printStackTrace(); } try { con=DriverManager.getConnection("jdbc:oracle:" + "thin:@127.0.0.1:1521:ORCL","Reust","kingstar"); // System.out.print("数据库连接成功"); } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); } } }
整合SSH2的登录实例的时候总是出错
整合SSH2的登录实例的时候总是出现下面这个错 Struts2+hibernate3.2+spring2 已经搞了一整天了,快疯了,求大侠帮助,感激不尽,附上代码,哪位大侠有空帮小弟改改 HTTP Status 404 - -------------------------------------------------------------------------------- type Status report message description The requested resource () is not available. 控制台: 2010-9-18 16:28:18 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.20. 2010-9-18 16:28:18 org.apache.catalina.core.AprLifecycleListener init 信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], ra ndom [true]. 2010-9-18 16:28:19 org.apache.coyote.http11.Http11AprProtocol init 信息: Initializing Coyote HTTP/1.1 on http-8080 2010-9-18 16:28:19 org.apache.coyote.ajp.AjpAprProtocol init 信息: Initializing Coyote AJP/1.3 on ajp-8009 2010-9-18 16:28:19 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 1487 ms 2010-9-18 16:28:19 org.apache.catalina.core.StandardService start 信息: Starting service Catalina 2010-9-18 16:28:19 org.apache.catalina.core.StandardEngine start 信息: Starting Servlet Engine: Apache Tomcat/6.0.29 (0 ms) [Thread-2] INFO : org.springframework.web.context.ContextLoader#initWebAp plicationContext : Root WebApplicationContext: initialization started (60 ms) [Thread-2] INFO : org.springframework.web.context.support.XmlWebApplicat ionContext#prepareRefresh : Refreshing org.springframework.web.context.support.X mlWebApplicationContext@ff2413: display name [Root WebApplicationContext]; start up date [Sat Sep 18 16:28:20 CST 2010]; root of context hierarchy (180 ms) [Thread-2] INFO : org.springframework.beans.factory.xml.XmlBeanDefiniti onReader#loadBeanDefinitions : Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml] (2880 ms) [Thread-2] INFO : org.springframework.web.context.support.XmlWebApplic ationContext#obtainFreshBeanFactory : Bean factory for application context [org. springframework.web.context.support.XmlWebApplicationContext@ff2413]: org.spring framework.beans.factory.support.DefaultListableBeanFactory@17a1767 (2990 ms) [Thread-2] INFO : org.springframework.beans.factory.support.DefaultLis tableBeanFactory#preInstantiateSingletons : Pre-instantiating singletons in org. springframework.beans.factory.support.DefaultListableBeanFactory@17a1767: defini ng beans [dataSource,sessionFactory,userDao,userService,saveUserAction]; root of factory hierarchy (3195 ms) [Thread-2] INFO : org.hibernate.cfg.Environment#<clinit> : Hibernate 3 .2.5 (3200 ms) [Thread-2] INFO : org.hibernate.cfg.Environment#<clinit> : hibernate.p roperties not found (3205 ms) [Thread-2] INFO : org.hibernate.cfg.Environment#buildBytecodeProvider : Bytecode provider name : cglib (3215 ms) [Thread-2] INFO : org.hibernate.cfg.Environment#<clinit> : using JDK 1 .4 java.sql.Timestamp handling (3705 ms) [Thread-2] INFO : org.hibernate.cfg.HbmBinder#bindRootPersistentClassC ommonValues : Mapping class: com.test.bean.User -> user (3750 ms) [Thread-2] INFO : org.springframework.orm.hibernate3.LocalSessionFacto ryBean#buildSessionFactory : Building new Hibernate SessionFactory (3875 ms) [Thread-2] INFO : org.hibernate.connection.ConnectionProviderFactory#n ewConnectionProvider : Initializing connection provider: org.springframework.orm .hibernate3.LocalDataSourceConnectionProvider (4300 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : RD BMS: MySQL, version: 5.1.40-community (4300 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : JD BC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.8 ( Revision: ${svn.Revision} ) (4335 ms) [Thread-2] INFO : org.hibernate.dialect.Dialect#<init> : Using dialect : org.hibernate.dialect.MySQLDialect (4350 ms) [Thread-2] INFO : org.hibernate.transaction.TransactionFactoryFactory# buildTransactionFactory : Using default transaction strategy (direct JDBC transa ctions) (4355 ms) [Thread-2] INFO : org.hibernate.transaction.TransactionManagerLookupFa ctory#getTransactionManagerLookup : No TransactionManagerLookup configured (in J TA environment, use of read-write or transactional second-level cache is not rec ommended) (4355 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Au tomatic flush during beforeCompletion(): disabled (4355 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Au tomatic session close at end of transaction: disabled (4355 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : JD BC batch size: 15 (4360 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : JD BC batch updates for versioned data: disabled (4365 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Sc rollable result sets: enabled (4365 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : JD BC3 getGeneratedKeys(): enabled (4365 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Co nnection release mode: on_close (4370 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Ma ximum outer join fetch depth: 2 (4370 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : De fault batch fetch size: 1 (4370 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Ge nerate SQL with comments: disabled (4375 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Or der SQL updates by primary key: disabled (4375 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Or der SQL inserts for batching: disabled (4375 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#createQueryTransla torFactory : Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory (4385 ms) [Thread-2] INFO : org.hibernate.hql.ast.ASTQueryTranslatorFactory#<ini t> : Using ASTQueryTranslatorFactory (4385 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Qu ery language substitutions: {} (4385 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : JP A-QL strict compliance: disabled (4385 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Se cond-level cache: enabled (4385 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Qu ery cache: disabled (4390 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#createCacheProvide r : Cache provider: org.hibernate.cache.NoCacheProvider (4390 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Op timize cache for minimal puts: disabled (4390 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : St ructured second-level cache entries: disabled (4400 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : St atistics: disabled (4405 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : De leted entity synthetic identifier rollback: disabled (4405 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : De fault entity-mode: pojo (4405 ms) [Thread-2] INFO : org.hibernate.cfg.SettingsFactory#buildSettings : Na med query checking : enabled (4460 ms) [Thread-2] INFO : org.hibernate.impl.SessionFactoryImpl#<init> : build ing session factory (4970 ms) [Thread-2] INFO : org.hibernate.impl.SessionFactoryObjectFactory#addIn stance : Not binding factory to JNDI, no JNDI name configured (5045 ms) [Thread-2] INFO : org.springframework.web.context.ContextLoader#initWe bApplicationContext : Root WebApplicationContext: initialization completed in 50 35 ms 2010-9-18 16:28:25 org.apache.catalina.core.StandardContext start 严重: Error filterStart 2010-9-18 16:28:25 org.apache.catalina.core.StandardContext start 严重: Context [/ssh] startup failed due to previous errors (5060 ms) [Thread-2] INFO : org.springframework.web.context.support.XmlWebApplic ationContext#doClose : Closing org.springframework.web.context.support.XmlWebApp licationContext@ff2413: display name [Root WebApplicationContext]; startup date [Sat Sep 18 16:28:20 CST 2010]; root of context hierarchy (5060 ms) [Thread-2] INFO : org.springframework.beans.factory.support.DefaultLis tableBeanFactory#destroySingletons : Destroying singletons in org.springframewor k.beans.factory.support.DefaultListableBeanFactory@17a1767: defining beans [data Source,sessionFactory,userDao,userService,saveUserAction]; root of factory hiera rchy (5060 ms) [Thread-2] INFO : org.springframework.orm.hibernate3.LocalSessionFacto ryBean#destroy : Closing Hibernate SessionFactory (5065 ms) [Thread-2] INFO : org.hibernate.impl.SessionFactoryImpl#close : closin g 2010-9-18 16:28:25 org.apache.catalina.loader.WebappClassLoader clearReferencesJ dbc 严重: The web application [/ssh] registered the JBDC driver [com.mysql.jdbc.Driv er] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 2010-9-18 16:28:25 org.apache.catalina.loader.WebappClassLoader clearReferencesT hreads 严重: The web application [/ssh] appears to have started a thread named [Timer-0 ] but has failed to stop it. This is very likely to create a memory leak. 2010-9-18 16:28:25 org.apache.catalina.loader.WebappClassLoader clearReferencesT hreads 严重: The web application [/ssh] appears to have started a thread named [MySQL S tatement Cancellation Timer] but has failed to stop it. This is very likely to c reate a memory leak. 2010-9-18 16:28:25 org.apache.catalina.startup.HostConfig deployDescriptor 信息: Deploying configuration descriptor manager.xml 2010-9-18 16:28:25 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory ROOT 2010-9-18 16:28:25 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory docs 2010-9-18 16:28:25 org.apache.coyote.http11.Http11AprProtocol start 信息: Starting Coyote HTTP/1.1 on http-8080 2010-9-18 16:28:25 org.apache.coyote.ajp.AjpAprProtocol start 信息: Starting Coyote AJP/1.3 on ajp-8009 2010-9-18 16:28:25 org.apache.catalina.startup.Catalina start 信息: Server startup in 6626 ms
Spring整合hibernate4时出现no session错误
首先将eclipse抛出的错误贴出来: ``` 严重: Servlet.service() for servlet [springDispatcherServlet] in context with path [/VideoMngSys] threw exception [Request processing failed; nested exception is org.hibernate.HibernateException: No Session found for current thread] with root cause org.hibernate.HibernateException: No Session found for current thread at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:106) at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:988) at com.vincent.videosys.dao.BaseDao.getSession(BaseDao.java:17) at com.vincent.videosys.dao.UserDao.usernameExist(UserDao.java:29) at com.vincent.videosys.service.UserService.usernameExistService(UserService.java:19) at com.vincent.videosys.controller.home.UserController.usernameExist(UserController.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle (ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod (RequestMappingHandlerAdapter.java:748) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal (RequestMappingHandlerAdapter.java:689) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle (AbstractHandlerMethodAdapter.java:83) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931) .... ``` ![项目工程结构如下:](https://img-ask.csdn.net/upload/201601/02/1451707793_69876.png) 下面依次贴出我的相关文件代码: 1.web.xml ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <!-- 加载Spring配置文件,Spring应用上下文,理解层次化的ApplicationContext --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 可以将POST请求转为PUT请求和DELETE请求 --> <filter> <filter-name>HiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>HiddenHttpMethodFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- The front controller of this Spring Web application, responsible for handling all application requests --> <servlet> <servlet-name>springDispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- Map all requests to the DispatcherServlet for handling --> <servlet-mapping> <servlet-name>springDispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> </web-app> ``` 2.spring-mvc.xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" ......> <!-- 向Spring容器注册AutowiredAnnotationBeanPostProcessor、 CommonAnnotationBeanPostProcessor、 PersistenceAnnotationBeanPostProcessor、 RequiredAnnotationBeanPostProcessor,使系统能识别注解 --> <context:annotation-config /> <!-- 使用annotation自动注册bean,并检查@Controller、@Service、@Repository --> <context:component-scan base-package="com.vincent.videosys"></context:component-scan> <!-- 导入资源文件 --> <context:property-placeholder location="classpath:db.properties"/> <!-- 配置C3P0数据源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="user" value="${jdbc.user}"></property> <property name="password" value="${jdbc.password}"></property> <property name="driverClass" value="${jdbc.driverClass}"></property> <property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property> <property name="initialPoolSize" value="${jdbc.initPoolSize}"></property> <property name="maxPoolSize" value="${jdbc.maxPoolSize}"></property> </bean> <!-- 配置SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> <property name="packagesToScan"> <list> <value>com.vincent.videosys.*</value> </list> </property> </bean> <!-- 配置hibernate的事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- 定义AutoWired自动注入bean --> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"></bean> <!-- 用注解来实现事务管理 --> <tx:annotation-driven transaction-manager="transactionManager"/> <!-- 3. 配置事务切入点, 再把事务属性和事务切入点关联起来 --> <aop:config> <aop:pointcut expression="execution(* com.vincent.videosys.service.*.*(..))" id="txPointcut"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/> </aop:config> </beans> ``` 4.hibernate.cfg.xml ``` <?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 --> <!-- JDBC connection pool (use the built-in) --> <!-- <property name="connection.pool_size">1</property>--> <!-- 数据库使用的方言 --> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <!-- Echo all executed SQL to stdout --> <!-- 设置 打印输出 sql 语句 为真 --> <property name="hibernate.show_sql">true</property> <!-- 设置格式为 sql --> <property name="hibernate.format_sql">true</property> <!-- 第一次加载 hibernate 时根据实体类自动建立表结构,以后自动更新表结构 --> <property name="hibernate.hbm2ddl.auto">update</property> <property name="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</property> </session-factory> </hibernate-configuration> ``` 5.db.properties jdbc.user=root jdbc.password=root jdbc.driverClass=com.mysql.jdbc.Driver jdbc.jdbcUrl=jdbc:mysql://localhost:3306/videomngsys jdbc.initPoolSize=5 jdbc.maxPoolSize=10 6. BaseDao.java ``` package com.vincent.videosys.dao; import javax.annotation.Resource; ..... @Repository("baseDao") public class BaseDao{ @Autowired protected SessionFactory sessionFactory; public Session getSession(){ return this.sessionFactory.getCurrentSession(); } } ``` 7.UserDao.java ``` package com.vincent.videosys.dao; import org.hibernate.Query; import org.hibernate.Session; .... @Repository("userDao") public class UserDao extends BaseDao{ protected SessionFactory sessionFactory; /** * 查看该用户名在数据库中是否存在 * 存在返回true * 不存在返回false * 默认返回true * @param username * @return */ public boolean usernameExist(String username){ boolean exist = true; String hqlString = "from user where username = :username"; Session session = super.getSession(); Query query = session.createQuery(hqlString); query.setParameter("username", username); List<User> list = query.list(); if(list.size() > 0) { exist = false; } return exist; } } ``` 8 UserService.java ``` package com.vincent.videosys.service; import javax.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; ... @Transactional @Service("userService") public class UserService { @Autowired private UserDao userDao; public boolean usernameExistService(String username){ return userDao.usernameExist(username); } } ``` 9. UserController.java ``` package com.vincent.videosys.controller.home; import java.util.HashMap; import java.util.Map; import javax.annotation.Resource; ..... @RequestMapping("/user") @Controller public class UserController { @Autowired private UserService userService; @ResponseBody @RequestMapping(value="/usernameExist",method=RequestMethod.POST) public Map<String, String> usernameExist(@RequestParam("username")String usernameString ){ Map<String, String> resultMap = new HashMap<String, String>(); System.out.println("username: "+usernameString); if(userService.usernameExistService(usernameString)){ resultMap.put("status", "1");//exits } else{ resultMap.put("status", "0");//not exist } return resultMap; } } ``` 每次程序执行到UserController类中的userNameExist方法时,开始调用userService中的方法时,便开始抛出错误.....
hibernate 异常求解决
11:07:37,716 INFO Version:37 - Hibernate Commons Annotations 3.2.0.Final 11:07:37,723 INFO Environment:603 - Hibernate 3.6.10.Final 11:07:37,724 INFO Environment:636 - hibernate.properties not found 11:07:37,727 INFO Environment:814 - Bytecode provider name : javassist 11:07:37,729 INFO Environment:695 - using JDK 1.4 java.sql.Timestamp handling 11:07:37,771 INFO Configuration:2156 - configuring from resource: /hibernate.cfg.xml 11:07:37,771 INFO Configuration:2175 - Configuration resource: /hibernate.cfg.xml 11:07:37,826 INFO Configuration:789 - Reading mappings from resource : cn/wyz/domain/Customer.hbm.xml 11:07:37,891 INFO Configuration:2297 - Configured SessionFactory: null 11:07:37,923 INFO HbmBinder:353 - Mapping class: cn.wyz.domain.Customer -> customer 11:07:37,936 INFO Configuration:1676 - Hibernate Validator not found: ignoring 11:07:37,940 INFO HibernateSearchEventListenerRegister:75 - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled. Customer.hbm.xml文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="cn.wyz.domain.Customer" table="customer" catalog="customer"> <id name="id" column="id" type="int"> <generator class="native"></generator> </id> <property name="name" column="name" type="java.long.String"></property> <property name="age" column="age" type="int"></property> <property name="city" column="city" type="java.long.String"></property> </class> </hibernate-mapping> hibernate.cfg.xml文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql:///customer</property> <property name="hibernate.connection.username">wyz</property> <property name="hibernate.connection.password">123456</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.format_sql">true</property> <property name="hibernate.hbm2ddl.auto">update</property> <mapping resource="cn/wyz/domain/Customer.hbm.xml"/> </session-factory> </hibernate-configuration> 测试类 public class HibernateTest1 { @Test public void testAdd() { // 实例化配置对象,加载配置文件 hibernate.cfg.xml Configuration configuration = new Configuration().configure(); // 创建会话连接工厂 SessionFactory sessionFactory = configuration.buildSessionFactory(); // 创建会话 Session session = sessionFactory.openSession(); // 开启事务 Transaction transaction = session.beginTransaction(); // 这里可以编写hibernate操作代码逻辑 Customer customer=new Customer(); customer.setName("张三"); customer.setAge(18); customer.setCity("河北"); session.save(customer); // 提交事务,释放资源 transaction.commit(); session.close(); sessionFactory.close(); } }
SSH集成后,测试DAO,发出hibernate的insert,就是不保存到数据库
1.UserDAOImplTest [code="java"] public class UserDAOImplTest extends TestCase { private BeanFactory factory = new FileSystemXmlApplicationContext("WebRoot/WEB-INF/applicationContext-*.xml"); private UserDAO userDAO = (UserDAOImpl)factory.getBean("userDAO"); @Override protected void setUp() throws Exception { } public void testAddUser() { User user = new User(); user.setUserId("d3e3"); user.setUserName("张三"); user.setEmail("ddf@134.com"); user.setContactTel("324e32r4"); user.setCreateDate(new Date()); user.setPassword("java"); userDAO.addUser(user); } } [/code] 2.consle的信息: [code="java"] 2009-06-13 21:19:58,343 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] - Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@1b9240e: display name [org.springframework.context.support.FileSystemXmlApplicationContext@1b9240e]; startup date [Sat Jun 13 21:19:58 CST 2009]; root of context hierarchy 2009-06-13 21:19:58,437 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from file [D:\Struts2_CSincity\DRP_SSH_1.0\WebRoot\WEB-INF\applicationContext-actions.xml] 2009-06-13 21:19:59,109 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from file [D:\Struts2_CSincity\DRP_SSH_1.0\WebRoot\WEB-INF\applicationContext-beans.xml] 2009-06-13 21:19:59,187 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from file [D:\Struts2_CSincity\DRP_SSH_1.0\WebRoot\WEB-INF\applicationContext-common.xml] 2009-06-13 21:19:59,296 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] - Bean factory for application context [org.springframework.context.support.FileSystemXmlApplicationContext@1b9240e]: org.springframework.beans.factory.support.DefaultListableBeanFactory@f6ac0b 2009-06-13 21:19:59,390 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] - Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2009-06-13 21:19:59,390 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@f6ac0b: defining beans [/user,userDAO,userManager,sessionFactory,transactionManager,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,allManagerMethod,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor]; root of factory hierarchy 2009-06-13 21:19:59,500 INFO [org.hibernate.cfg.Environment] - Hibernate 3.1.3 2009-06-13 21:19:59,500 INFO [org.hibernate.cfg.Environment] - hibernate.properties not found 2009-06-13 21:19:59,515 INFO [org.hibernate.cfg.Environment] - using CGLIB reflection optimizer 2009-06-13 21:19:59,515 INFO [org.hibernate.cfg.Environment] - using JDK 1.4 java.sql.Timestamp handling 2009-06-13 21:19:59,625 INFO [org.hibernate.cfg.Configuration] - configuring from url: file:/D:/Struts2_CSincity/DRP_SSH_1.0/WebRoot/WEB-INF/classes/hibernate.cfg.xml 2009-06-13 21:19:59,734 INFO [org.hibernate.cfg.Configuration] - Reading mappings from resource: com/drp/model/User.hbm.xml 2009-06-13 21:19:59,859 INFO [org.hibernate.cfg.HbmBinder] - Mapping class: com.drp.model.User -> t_user 2009-06-13 21:19:59,890 INFO [org.hibernate.cfg.Configuration] - Configured SessionFactory: null 2009-06-13 21:19:59,890 INFO [org.springframework.orm.hibernate3.LocalSessionFactoryBean] - Building new Hibernate SessionFactory 2009-06-13 21:19:59,968 INFO [org.hibernate.connection.DriverManagerConnectionProvider] - Using Hibernate built-in connection pool (not for production use!) 2009-06-13 21:19:59,968 INFO [org.hibernate.connection.DriverManagerConnectionProvider] - Hibernate connection pool size: 20 2009-06-13 21:19:59,968 INFO [org.hibernate.connection.DriverManagerConnectionProvider] - autocommit mode: false 2009-06-13 21:19:59,984 INFO [org.hibernate.connection.DriverManagerConnectionProvider] - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/mydrp 2009-06-13 21:19:59,984 INFO [org.hibernate.connection.DriverManagerConnectionProvider] - connection properties: {user=root, password=****, release_mode=on_close} 2009-06-13 21:20:00,312 INFO [org.hibernate.cfg.SettingsFactory] - RDBMS: MySQL, version: 5.0.45-community-nt 2009-06-13 21:20:00,312 INFO [org.hibernate.cfg.SettingsFactory] - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.5 ( Revision: ${svn.Revision} ) 2009-06-13 21:20:00,343 INFO [org.hibernate.dialect.Dialect] - Using dialect: org.hibernate.dialect.MySQLDialect 2009-06-13 21:20:00,343 INFO [org.hibernate.transaction.TransactionFactoryFactory] - Using default transaction strategy (direct JDBC transactions) 2009-06-13 21:20:00,343 INFO [org.hibernate.transaction.TransactionManagerLookupFactory] - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2009-06-13 21:20:00,343 INFO [org.hibernate.cfg.SettingsFactory] - Automatic flush during beforeCompletion(): disabled 2009-06-13 21:20:00,343 INFO [org.hibernate.cfg.SettingsFactory] - Automatic session close at end of transaction: disabled 2009-06-13 21:20:00,343 INFO [org.hibernate.cfg.SettingsFactory] - JDBC batch size: 15 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - JDBC batch updates for versioned data: disabled 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Scrollable result sets: enabled 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - JDBC3 getGeneratedKeys(): enabled 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Connection release mode: on_close 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Maximum outer join fetch depth: 2 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Default batch fetch size: 1 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Generate SQL with comments: disabled 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Order SQL updates by primary key: disabled 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2009-06-13 21:20:00,359 INFO [org.hibernate.hql.ast.ASTQueryTranslatorFactory] - Using ASTQueryTranslatorFactory 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Query language substitutions: {} 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Second-level cache: enabled 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Query cache: disabled 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Cache provider: org.hibernate.cache.EhCacheProvider 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Optimize cache for minimal puts: disabled 2009-06-13 21:20:00,359 INFO [org.hibernate.cfg.SettingsFactory] - Structured second-level cache entries: disabled 2009-06-13 21:20:00,375 INFO [org.hibernate.cfg.SettingsFactory] - Echoing all SQL to stdout 2009-06-13 21:20:00,375 INFO [org.hibernate.cfg.SettingsFactory] - Statistics: disabled 2009-06-13 21:20:00,375 INFO [org.hibernate.cfg.SettingsFactory] - Deleted entity synthetic identifier rollback: disabled 2009-06-13 21:20:00,375 INFO [org.hibernate.cfg.SettingsFactory] - Default entity-mode: pojo 2009-06-13 21:20:00,406 INFO [org.hibernate.impl.SessionFactoryImpl] - building session factory 2009-06-13 21:20:00,875 INFO [org.hibernate.impl.SessionFactoryObjectFactory] - Not binding factory to JNDI, no JNDI name configured 2009-06-13 21:20:00,890 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - Running hbm2ddl schema update 2009-06-13 21:20:00,890 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - fetching database metadata 2009-06-13 21:20:00,890 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - updating schema 2009-06-13 21:20:00,921 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - table found: mydrp.t_user 2009-06-13 21:20:00,921 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - columns: [password, contacttel, userid, createdate, username, email, id] 2009-06-13 21:20:00,921 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - foreign keys: [] 2009-06-13 21:20:00,921 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - indexes: [primary] 2009-06-13 21:20:00,921 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - schema update complete Hibernate: insert into t_user (userId, userName, password, email, createDate, contactTel) values (?, ?, ?, ?, ?, ?) [/code] 最后发出insert了,数据库里就是没有数据,那位高人知道原因, 项目里添加用户完全没问题,就是测试没行,郁闷,请问的我的错误在哪里? [b]问题补充:[/b] 谢谢各位热心帮忙 我加入了事务管理,获得dao对象时,报 java.lang.ClassCastException: $Proxy1 我的事务管理如下: [code="java"] <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- 配置事务的传播特性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="del*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="test*" propagation="REQUIRED"/> <!-- 只读事务不进行脏数据检查,可提高性能 --> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> <!-- 哪些类那些方法是用事务,事务的边界定位的业务逻辑层 --> <aop:config> <aop:pointcut id="allManagerMethod" expression="execution(* com.drp.manager.*.*(..))"/> <aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/> </aop:config> <aop:config> <aop:pointcut id="allDaoMethod" expression="execution(* com.drp.dao.*.*(..))"/> <aop:advisor pointcut-ref="allDaoMethod" advice-ref="txAdvice"/> </aop:config> [/code] 加上最后一句aop:config后 private UserDAO userDAO = (UserDAOImpl)factory.getBean("userDAO"); 说这行,发生java.lang.ClassCastException: $Proxy1 怎么回事?? [b]问题补充:[/b] 用aop已经生成了动态代理对象,factory.getBean("userDAO")已经不是UserDAOImpl类型了 是代理对象,通过getClass,返回的是$Proxy,那我怎么取得UserDAOImpl对象呢? 是不是没有引入对应的包啊?CGLIB.JAR,ASM-.*.JAR 这两个都加了。
SSH整合:No bean named 'TestService' is defined
最近刚刚开始做SSH三大框架整合,搭建了好几天的开发环境,就卡在了Spring与Hibernate 整合上, ![图片说明](https://img-ask.csdn.net/upload/201505/17/1431793030_317551.png) TestService.java package com.zyf.test; import javax.annotation.Resource; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.springframework.stereotype.Controller; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import cn.zyf.pj.domain.User; @Service public class TestService { @Resource private SessionFactory sessionFactory; @Transactional public void saveTwoUsers() { Session session = sessionFactory.getCurrentSession(); session.save(new User()); session.save(new User()); } } TestSpring.java package com.zyf.test; import org.hibernate.SessionFactory; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class TestSpring { private ApplicationContext ac= new ClassPathXmlApplicationContext("applicationContext.xml"); //测试sessionFactory @Test public void testSessionFactory() throws Exception{ SessionFactory sessionFactory =(SessionFactory)ac.getBean("sessionFactory"); System.out.println(sessionFactory.openSession()); } //测试事物 @Test public void testSaveUsers(){ TestService ts=(TestService) ac.getBean("TestService"); ts.saveTwoUsers(); } } Hibernate.cfg.xml <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 数据连接信息 <property name="hibernate.connection.url">jdbc:mysql:///pj</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">abc123</property> --> <property name="hibernate.dialect"> org.hibernate.dialect.MySQL5InnoDBDialect </property> <!-- 其他配置信息 --> <property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <mapping resource="cn/zyf/pj/domain/User.hbm.xml" /> </session-factory> </hibernate-configuration> applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 自动扫描与装配bean --> <context:component-scan base-package="cn.zyf.pj" annotation-config="true"></context:component-scan> <!-- 导入外部的properties配置文件 --> <context:property-placeholder location="classpath:jdbc.properties"/> <!-- 配置数据库连接池 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <!-- =========== 数据库连接信息 =========== --> <property name="jdbcUrl" value="${jdbcUrl}"></property> <property name="driverClass" value="${driverClass}"></property> <property name="user" value="${username}"></property> <property name="password" value="${password}"></property> <!-- =========== 连接池的管理配置 =========== --> <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 --> <property name="initialPoolSize" value="3"></property> <!--连接池中保留的最小连接数。Default: 3 --> <property name="minPoolSize" value="3"></property> <!--连接池中保留的最大连接数。Default: 15 --> <property name="maxPoolSize" value="5"></property> <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 --> <property name="acquireIncrement" value="3"></property> <!-- 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 --> <property name="maxStatements" value="8"></property> <!--maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 --> <property name="maxStatementsPerConnection" value="5"></property> <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 --> <property name="maxIdleTime" value="1800"></property> </bean> <!-- 配置SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> </bean> <!-- 配置声明式的事务管理(采用基于注解的方式) --> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:annotation-driven transaction-manager="txManager"/> </beans> TestSpring.java package com.zyf.test; import org.hibernate.SessionFactory; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class TestSpring { private ApplicationContext ac= new ClassPathXmlApplicationContext("applicationContext.xml"); //测试sessionFactory @Test public void testSessionFactory() throws Exception{ SessionFactory sessionFactory =(SessionFactory)ac.getBean("sessionFactory"); System.out.println(sessionFactory.openSession()); } //测试事物 @Test public void testSaveUsers(){ TestService ts=(TestService) ac.getBean("TestService"); ts.saveTwoUsers(); } } 对TestSpring进行单元测试,第一个方法正常执行,第二个方法报错No bean named 'TestService' is defined,并且在数据库中自动生成test_users表,困扰了好久了,麻烦大神指点一下!!!!
纠结的了一上午ssh的问题
2010-6-6 11:05:07 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.19. 2010-6-6 11:05:07 org.apache.catalina.core.AprLifecycleListener init 信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], rand om [true]. 2010-6-6 11:05:08 org.apache.coyote.http11.Http11AprProtocol init 信息: Initializing Coyote HTTP/1.1 on http-8080 2010-6-6 11:05:08 org.apache.coyote.ajp.AjpAprProtocol init 信息: Initializing Coyote AJP/1.3 on ajp-8009 2010-6-6 11:05:08 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 1494 ms 2010-6-6 11:05:08 org.apache.catalina.core.StandardService start 信息: Starting service Catalina 2010-6-6 11:05:08 org.apache.catalina.core.StandardEngine start 信息: Starting Servlet Engine: Apache Tomcat/6.0.24 2010-6-6 11:05:08 org.apache.catalina.startup.HostConfig deployDescriptor 信息: Deploying configuration descriptor host-manager.xml 2010-6-6 11:05:09 org.apache.catalina.startup.HostConfig deployDescriptor 信息: Deploying configuration descriptor manager.xml 2010-6-6 11:05:09 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory docs 2010-6-6 11:05:09 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory examples 2010-6-6 11:05:09 org.apache.catalina.core.ApplicationContext log 信息: ContextListener: contextInitialized() 2010-6-6 11:05:09 org.apache.catalina.core.ApplicationContext log 信息: SessionListener: contextInitialized() 2010-6-6 11:05:09 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory ROOT 2010-6-6 11:05:09 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory test_online 2010-6-6 11:05:11 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext 2010-06-06 11:05:11 Root WebApplicationContext: initialization started 2010-06-06 11:05:12 Refreshing org.springframework.web.context.support.XmlWebApp licationContext@8cd4db: display name [Root WebApplicationContext]; startup date [Sun Jun 06 11:05:12 CST 2010]; root of context hierarchy 2010-06-06 11:05:12 Looking for matching resources in directory tree [C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\test_online\WEB-INF\classes ] 2010-06-06 11:05:12 Searching directory [C:\Program Files\Apache Software Founda tion\Tomcat 6.0\webapps\test_online\WEB-INF\classes] for files matching pattern [C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/test_online/WEB- INF/classes/bean-*.xml] 2010-06-06 11:05:12 Resolved location pattern [classpath:bean-*.xml] to resource s [file [C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\test_onl ine\WEB-INF\classes\bean-action.xml], file [C:\Program Files\Apache Software Fou ndation\Tomcat 6.0\webapps\test_online\WEB-INF\classes\bean-hibernate.xml], file [C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\test_online\WEB -INF\classes\bean-service.xml]] 2010-06-06 11:05:12 Loading XML bean definitions from file [C:\Program Files\Apa che Software Foundation\Tomcat 6.0\webapps\test_online\WEB-INF\classes\bean-acti on.xml] 2010-06-06 11:05:13 Using JAXP provider [org.apache.xerces.jaxp.DocumentBuilderF actoryImpl] 2010-06-06 11:05:14 Loading schema mappings from [META-INF/spring.schemas] 2010-06-06 11:05:14 Loaded schema mappings: {http://www.springframework.org/sche ma/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd , http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframe work/scripting/config/spring-lang-2.5.xsd, http://www.springframework.org/schema /context/spring-context-2.5.xsd=org/springframework/context/config/spring-contex t-2.5.xsd, http://www.springframework.org/schema/context/spring-context.xsd=org/ springframework/context/config/spring-context-2.5.xsd, http://www.springframewor k.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.5.xs d, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springfram ework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/sche ma/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2. 5.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springfram ework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schem a/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0 .xsd, http://www.springframework.org/schema/tx/spring-tx-2.5.xsd=org/springframe work/transaction/config/spring-tx-2.5.xsd, http://www.springframework.org/schema /beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2 .0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/sprin gframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org /schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring- beans-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/ springframework/beans/factory/xml/spring-beans-2.5.xsd, http://www.springframewo rk.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-2.5.x sd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframewo rk/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/ tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd, http: //www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/ config/spring-jee-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop- 2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springfram ework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-ao p-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/spri ngframework/ejb/config/spring-jee-2.5.xsd, http://www.springframework.org/schema /lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.x sd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframewo rk/beans/factory/xml/spring-util-2.5.xsd} 2010-06-06 11:05:14 Found XML schema [http://www.springframework.org/schema/bean s/spring-beans-2.0.xsd] in classpath: org/springframework/beans/factory/xml/spri ng-beans-2.0.xsd 2010-06-06 11:05:14 Loading bean definitions 2010-06-06 11:05:14 No XML 'id' specified - using 'LoginAction' as bean name and [] as aliases 2010-06-06 11:05:14 No XML 'id' specified - using 'CheckAction' as bean name and [] as aliases 2010-06-06 11:05:14 Loading XML bean definitions from file [C:\Program Files\Apa che Software Foundation\Tomcat 6.0\webapps\test_online\WEB-INF\classes\bean-hibe rnate.xml] 2010-06-06 11:05:14 Using JAXP provider [org.apache.xerces.jaxp.DocumentBuilderF actoryImpl] 2010-06-06 11:05:14 Found XML schema [http://www.springframework.org/schema/bean s/spring-beans-2.5.xsd] in classpath: org/springframework/beans/factory/xml/spri ng-beans-2.5.xsd 2010-06-06 11:05:14 Loading bean definitions 2010-06-06 11:05:14 Loading XML bean definitions from file [C:\Program Files\Apa che Software Foundation\Tomcat 6.0\webapps\test_online\WEB-INF\classes\bean-serv ice.xml] 2010-06-06 11:05:14 Using JAXP provider [org.apache.xerces.jaxp.DocumentBuilderF actoryImpl] 2010-06-06 11:05:14 Found XML schema [http://www.springframework.org/schema/bean s/spring-beans-2.0.xsd] in classpath: org/springframework/beans/factory/xml/spri ng-beans-2.0.xsd 2010-06-06 11:05:14 Loading bean definitions 2010-06-06 11:05:14 No XML 'id' specified - using 'UserCheckService' as bean nam e and [] as aliases 2010-06-06 11:05:14 No XML 'id' specified - using 'build' as bean name and [] as aliases 2010-06-06 11:05:14 Loaded 9 bean definitions from location pattern [classpath:b ean-*.xml] 2010-06-06 11:05:14 Bean factory for application context [org.springframework.we b.context.support.XmlWebApplicationContext@8cd4db]: org.springframework.beans.fa ctory.support.DefaultListableBeanFactory@3087f9 2010-06-06 11:05:14 9 beans defined in org.springframework.web.context.support.X mlWebApplicationContext@8cd4db: display name [Root WebApplicationContext]; start up date [Sun Jun 06 11:05:12 CST 2010]; root of context hierarchy 2010-06-06 11:05:15 Unable to locate MessageSource with name 'messageSource': us ing default [org.springframework.context.support.DelegatingMessageSource@137e2dc ] 2010-06-06 11:05:15 Unable to locate ApplicationEventMulticaster with name 'appl icationEventMulticaster': using default [org.springframework.context.event.Simpl eApplicationEventMulticaster@16e1111] 2010-06-06 11:05:15 Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.ResourceBundleThemeSource@5b5df0 ] 2010-06-06 11:05:15 Pre-instantiating singletons in org.springframework.beans.fa ctory.support.DefaultListableBeanFactory@3087f9: defining beans [LoginAction,Che ckAction,dataSource,sessionFactory,TestDAO,StudentsDAO,QuesttionDAO,UserCheckSer vice,build]; root of factory hierarchy 2010-06-06 11:05:15 Creating shared instance of singleton bean 'dataSource' 2010-06-06 11:05:15 Creating instance of bean 'dataSource' 2010-06-06 11:05:15 Eagerly caching bean 'dataSource' to allow for resolving pot ential circular references 2010-06-06 11:05:15 Finished creating instance of bean 'dataSource' 2010-06-06 11:05:15 Creating shared instance of singleton bean 'sessionFactory' 2010-06-06 11:05:15 Creating instance of bean 'sessionFactory' 2010-06-06 11:05:15 Eagerly caching bean 'sessionFactory' to allow for resolving potential circular references 2010-06-06 11:05:15 Returning cached instance of singleton bean 'dataSource' 2010-06-06 11:05:15 Invoking afterPropertiesSet() on bean with name 'sessionFact ory' 2010-06-06 11:05:15 Hibernate 3.2.7 2010-06-06 11:05:15 hibernate.properties not found 2010-06-06 11:05:15 Bytecode provider name : cglib 2010-06-06 11:05:15 using JDK 1.4 java.sql.Timestamp handling 2010-06-06 11:05:16 trying to resolve system-id [http://hibernate.sourceforge.ne t/hibernate-mapping-3.0.dtd] 2010-06-06 11:05:16 recognized hibernate namespace; attempting to resolve on cla sspath under org/hibernate/ 2010-06-06 11:05:16 located [http://hibernate.sourceforge.net/hibernate-mapping- 3.0.dtd] in classpath 2010-06-06 11:05:17 Mapping class: pro.ncbuct.bean.Questtion -> questtion 2010-06-06 11:05:17 Mapped property: id -> id 2010-06-06 11:05:17 Mapped property: title -> title 2010-06-06 11:05:17 Mapped property: score -> score 2010-06-06 11:05:17 Mapped property: answer -> answer 2010-06-06 11:05:17 Mapped property: option1 -> option1 2010-06-06 11:05:17 Mapped property: option2 -> option2 2010-06-06 11:05:17 Mapped property: option3 -> option3 2010-06-06 11:05:17 Mapped property: option4 -> option4 2010-06-06 11:05:17 trying to resolve system-id [http://hibernate.sourceforge.ne t/hibernate-mapping-3.0.dtd] 2010-06-06 11:05:17 recognized hibernate namespace; attempting to resolve on cla sspath under org/hibernate/ 2010-06-06 11:05:17 located [http://hibernate.sourceforge.net/hibernate-mapping- 3.0.dtd] in classpath 2010-06-06 11:05:17 Mapping class: pro.ncbuct.bean.Students -> students 2010-06-06 11:05:17 Mapped property: id -> id 2010-06-06 11:05:17 Mapped property: name -> name 2010-06-06 11:05:17 Mapped property: loginNum -> login_num 2010-06-06 11:05:17 Mapped property: num -> num 2010-06-06 11:05:17 trying to resolve system-id [http://hibernate.sourceforge.ne t/hibernate-mapping-3.0.dtd] 2010-06-06 11:05:17 recognized hibernate namespace; attempting to resolve on cla sspath under org/hibernate/ 2010-06-06 11:05:17 located [http://hibernate.sourceforge.net/hibernate-mapping- 3.0.dtd] in classpath 2010-06-06 11:05:17 Mapping class: pro.ncbuct.bean.Test -> test 2010-06-06 11:05:17 Mapped property: id -> id 2010-06-06 11:05:17 Mapped property: userId -> user_id 2010-06-06 11:05:17 Mapped property: questId -> quest_id 2010-06-06 11:05:17 Mapped property: SAns -> s_ans 2010-06-06 11:05:17 Mapped property: testScore -> test_score 2010-06-06 11:05:17 processing extends queue 2010-06-06 11:05:17 processing collection mappings 2010-06-06 11:05:17 processing native query and ResultSetMapping mappings 2010-06-06 11:05:17 processing association property references 2010-06-06 11:05:17 processing foreign key constraints 2010-06-06 11:05:17 Building new Hibernate SessionFactory 2010-06-06 11:05:17 Preparing to build session factory with filters : {} 2010-06-06 11:05:17 processing extends queue 2010-06-06 11:05:17 processing collection mappings 2010-06-06 11:05:17 processing native query and ResultSetMapping mappings 2010-06-06 11:05:17 processing association property references 2010-06-06 11:05:17 processing foreign key constraints 2010-06-06 11:05:17 Initializing connection provider: org.springframework.orm.hi bernate3.LocalDataSourceConnectionProvider 2010-06-06 11:05:18 RDBMS: MySQL, version: 5.1.45-community 2010-06-06 11:05:18 JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector- java-5.0.8 ( Revision: ${svn.Revision} ) 2010-06-06 11:05:18 Using dialect: org.hibernate.dialect.MySQLDialect 2010-06-06 11:05:18 Transaction strategy: org.springframework.orm.hibernate3.Spr ingTransactionFactory 2010-06-06 11:05:18 No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2010-06-06 11:05:18 Automatic flush during beforeCompletion(): disabled 2010-06-06 11:05:18 Automatic session close at end of transaction: disabled 2010-06-06 11:05:18 JDBC batch size: 15 2010-06-06 11:05:18 JDBC batch updates for versioned data: disabled 2010-06-06 11:05:18 Scrollable result sets: enabled 2010-06-06 11:05:18 Wrap result sets: disabled 2010-06-06 11:05:18 JDBC3 getGeneratedKeys(): enabled 2010-06-06 11:05:18 Connection release mode: auto 2010-06-06 11:05:18 Maximum outer join fetch depth: 2 2010-06-06 11:05:18 Default batch fetch size: 1 2010-06-06 11:05:18 Generate SQL with comments: disabled 2010-06-06 11:05:18 Order SQL updates by primary key: disabled 2010-06-06 11:05:18 Order SQL inserts for batching: disabled 2010-06-06 11:05:18 Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFa ctory 2010-06-06 11:05:18 Using ASTQueryTranslatorFactory 2010-06-06 11:05:18 Query language substitutions: {} 2010-06-06 11:05:18 JPA-QL strict compliance: disabled 2010-06-06 11:05:18 Second-level cache: enabled 2010-06-06 11:05:18 Query cache: disabled 2010-06-06 11:05:18 Cache provider: org.hibernate.cache.NoCacheProvider 2010-06-06 11:05:18 Optimize cache for minimal puts: disabled 2010-06-06 11:05:18 Structured second-level cache entries: disabled 2010-06-06 11:05:18 Statistics: disabled 2010-06-06 11:05:18 Deleted entity synthetic identifier rollback: disabled 2010-06-06 11:05:18 Default entity-mode: pojo 2010-06-06 11:05:18 Named query checking : enabled 2010-06-06 11:05:18 building session factory 2010-06-06 11:05:18 Session factory constructed with filter configurations : {} 2010-06-06 11:05:18 instantiating session factory with properties: {java.runtime .name=Java(TM) SE Runtime Environment, sun.boot.library.path=C:\Program Files\Ja va\jdk1.6.0_18\jre\bin, java.vm.version=16.0-b13, shared.loader=, java.vm.vendor =Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, tomcat.util.buf.StringCache.byte.enable d=true, file.encoding.pkg=sun.io, user.country=CN, sun.java.launcher=SUN_STANDAR D, sun.os.patch.level=, java.vm.specification.name=Java Virtual Machine Specific ation, user.dir=C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin, java .runtime.version=1.6.0_18-b07, java.awt.graphicsenv=sun.awt.Win32GraphicsEnviron ment, hibernate.current_session_context_class=org.springframework.orm.hibernate3 .SpringSessionContext, java.endorsed.dirs=C:\Program Files\Apache Software Found ation\Tomcat 6.0/common/endorsed, os.arch=x86, java.io.tmpdir=C:\Program Files\A pache Software Foundation\Tomcat 6.0\temp, line.separator= , java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, java.naming .factory.url.pkgs=org.apache.naming, os.name=Windows 7, sun.jnu.encoding=GBK, ja va.library.path=C:\Program Files\Java\jdk1.6.0_18\bin;C:\Program Files\Apache So ftware Foundation\Tomcat 6.0\bin, java.specification.name=Java Platform API Spec ification, java.class.version=50.0, sun.management.compiler=HotSpot Client Compi ler, hibernate.transaction.factory_class=org.springframework.orm.hibernate3.Spri ngTransactionFactory, os.version=6.1, sun.io.useCanonCaches=false, user.home=C:\ Documents and Settings\Administrator, catalina.useNaming=true, user.timezone=Asi a/Shanghai, java.awt.printerjob=sun.awt.windows.WPrinterJob, java.specification. version=1.6, file.encoding=GBK, catalina.home=C:\Program Files\Apache Software F oundation\Tomcat 6.0, user.name=Administrator, java.class.path=C:\Program Files\ Apache Software Foundation\Tomcat 6.0/bin/bootstrap.jar;C:\Program Files\Java\jd k1.6.0_18/lib/tools.jar, hibernate.bytecode.use_reflection_optimizer=false, java .naming.factory.initial=org.apache.naming.java.javaURLContextFactory, package.de finition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,o rg.apache.jasper., java.vm.specification.version=1.0, sun.arch.data.model=32, ja va.home=C:\Program Files\Java\jdk1.6.0_18\jre, hibernate.dialect=org.hibernate.d ialect.MySQLDialect, java.specification.vendor=Sun Microsystems Inc., user.langu age=zh, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.vers ion=1.6.0_18, java.ext.dirs=C:\Program Files\Java\jdk1.6.0_18\jre\lib\ext;C:\Win dows\Sun\Java\lib\ext, sun.boot.class.path=C:\Program Files\Java\jdk1.6.0_18\jre \lib\resources.jar;C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar;C:\Program F iles\Java\jdk1.6.0_18\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_18\j re\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_18\jre\lib\jce.jar;C:\Program Fil es\Java\jdk1.6.0_18\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_18\jre\c lasses, java.vendor=Sun Microsystems Inc., server.loader=, catalina.base=C:\Prog ram Files\Apache Software Foundation\Tomcat 6.0, file.separator=\, java.vendor.u rl.bug=http://java.sun.com/cgi-bin/bugreport.cgi, hibernate.connection.provider_ class=org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider, comm on.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,$ {catalina.home}/lib/*.jar, sun.cpu.endian=little, sun.io.unicode.encoding=Unicod eLittle, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache. tomcat.,org.apache.jasper.,sun.beans., sun.desktop=windows, sun.cpu.isalist=pent ium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86} 2010-06-06 11:05:19 Destroying singletons in org.springframework.beans.factory.s upport.DefaultListableBeanFactory@3087f9: defining beans [LoginAction,CheckActio n,dataSource,sessionFactory,TestDAO,StudentsDAO,QuesttionDAO,UserCheckService,bu ild]; root of factory hierarchy 2010-06-06 11:05:19 Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean wit h name 'sessionFactory' defined in file [C:\Program Files\Apache Software Founda tion\Tomcat 6.0\webapps\test_online\WEB-INF\classes\bean-hibernate.xml]: Invocat ion of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTu plizer] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory $1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Ab stractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSi ngleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Abst ractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra ctBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra ctBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInst antiateSingletons(DefaultListableBeanFactory.java:423) at org.springframework.context.support.AbstractApplicationContext.finishBeanFac toryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(Abstr actApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(Co ntextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(Cont extLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(Con textLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java: 3972) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:7 91) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964 ) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppor t.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:722) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:593) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: org.hibernate.HibernateException: Unable to instantiate default tupli zer [org.hibernate.tuple.entity.PojoEntityTuplizer] at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTup lizerFactory.java:110) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(En tityTuplizerFactory.java:135) at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEn tityModeToTuplizerMapping.java:56) at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:323) at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntity Persister.java:433) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTable EntityPersister.java:109) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFacto ry.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:231) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1313) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory (LocalSessionFactoryBean.java:814) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFacto ry(LocalSessionFactoryBean.java:732) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertie sSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .initializeBean(AbstractAutowireCapableBeanFactory.java:1335) ... 39 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces sorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc torAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTup lizerFactory.java:107) ... 52 more Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:165) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy .java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java: 216) at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104) at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLaz yInitializer.java:117) at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyF actory.java:43) at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTu plizer.java:188) at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTupli zer.java:128) at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java :78) ... 57 more Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.CodeVisitor at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav a:1484) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav a:1329) ... 70 more 2010-6-6 11:05:19 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class or g.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean wit h name 'sessionFactory' defined in file [C:\Program Files\Apache Software Founda tion\Tomcat 6.0\webapps\test_online\WEB-INF\classes\bean-hibernate.xml]: Invocat ion of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTu plizer] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory $1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Ab stractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSi ngleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Abst ractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra ctBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra ctBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInst antiateSingletons(DefaultListableBeanFactory.java:423) at org.springframework.context.support.AbstractApplicationContext.finishBeanFac toryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(Abstr actApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(Co ntextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(Cont extLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(Con textLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java: 3972) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:7 91) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964 ) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppor t.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:722) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:593) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: org.hibernate.HibernateException: Unable to instantiate default tupli zer [org.hibernate.tuple.entity.PojoEntityTuplizer] at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTup lizerFactory.java:110) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(En tityTuplizerFactory.java:135) at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEn tityModeToTuplizerMapping.java:56) at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:323) at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntity Persister.java:433) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTable EntityPersister.java:109) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFacto ry.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:231) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1313) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory (LocalSessionFactoryBean.java:814) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFacto ry(LocalSessionFactoryBean.java:732) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertie sSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .initializeBean(AbstractAutowireCapableBeanFactory.java:1335) ... 39 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces sorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc torAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTup lizerFactory.java:107) ... 52 more Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:165) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy .java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java: 216) at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104) at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLaz yInitializer.java:117) at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyF actory.java:43) at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTu plizer.java:188) at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTupli zer.java:128) at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java :78) ... 57 more Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.CodeVisitor at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav a:1484) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav a:1329) ... 70 more 2010-6-6 11:05:19 org.apache.catalina.core.StandardContext start 严重: Error listenerStart 2010-6-6 11:05:19 org.apache.catalina.core.StandardContext start 严重: Context [/test_online] startup failed due to previous errors 2010-6-6 11:05:19 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext 2010-6-6 11:05:19 org.apache.catalina.loader.WebappClassLoader clearReferencesJd bc 严重: A web application registered the JBDC driver [com.mysql.jdbc.Driver] but fai led to unregister it when the web application was stopped. To prevent a memory l eak, the JDBC Driver has been forcibly unregistered. 2010-6-6 11:05:19 org.apache.catalina.loader.WebappClassLoader clearReferencesTh reads 严重: A web application appears to have started a thread named [Timer-0] but has f ailed to stop it. This is very likely to create a memory leak. 2010-6-6 11:05:19 org.apache.catalina.loader.WebappClassLoader clearReferencesTh reads 严重: A web application appears to have started a thread named [MySQL Statement Ca ncellation Timer] but has failed to stop it. This is very likely to create a mem ory leak. 2010-6-6 11:05:19 org.apache.catalina.loader.WebappClassLoader clearThreadLocalM ap 严重: A web application created a ThreadLocal with key of type [null] (value [com. sun.faces.config.ConfigureListener$1@18c4d8e]) and a value of type [null] (value [null]) but failed to remove it when the web application was stopped. To preven t a memory leak, the ThreadLocal has been forcibly removed. 2010-6-6 11:05:19 org.apache.catalina.loader.WebappClassLoader clearThreadLocalM ap 严重: A web application created a ThreadLocal with key of type [org.springframewor k.core.NamedThreadLocal] (value [Prototype beans currently in creation]) and a v alue of type [null] (value [null]) but failed to remove it when the web applicat ion was stopped. To prevent a memory leak, the ThreadLocal has been forcibly rem oved.
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私...
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小人工智障。 思路可以运用在不同地方,主要介绍的是思路。
面试官问我:什么是消息队列?什么场景需要他?用了会出现什么问题?
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式和人才交流群,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸...
8年经验面试官详解 Java 面试秘诀
作者 |胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。 Java程序员准备和投递简历的实...
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观...
MyBatis研习录(01)——MyBatis概述与入门
MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射。MyBatis原本是apache的一个开源项目iBatis, 2010年该项目由apache software foundation 迁移到了google code并改名为MyBatis 。2013年11月MyBatis又迁移到Github。
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip installselenium -ihttps://pypi.tuna.tsinghua.edu.cn/simple/ ...
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca...
Python爬虫精简步骤1 获取数据
爬虫,从本质上来说,就是利用程序在网上拿到对我们有价值的数据。 爬虫能做很多事,能做商业分析,也能做生活助手,比如:分析北京近两年二手房成交均价是多少?广州的Python工程师平均薪资是多少?北京哪家餐厅粤菜最好吃?等等。 这是个人利用爬虫所做到的事情,而公司,同样可以利用爬虫来实现巨大的商业价值。比如你所熟悉的搜索引擎——百度和谷歌,它们的核心技术之一也是爬虫,而且是超级爬虫。 从搜索巨头到人工...
Python绘图,圣诞树,花,爱心 | Turtle篇
每周每日,分享Python实战代码,入门资料,进阶资料,基础语法,爬虫,数据分析,web网站,机器学习,深度学习等等。 公众号回复【进群】沟通交流吧,QQ扫码进群学习吧 微信群 QQ群 1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle()...
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东...
破14亿,Python分析我国存在哪些人口危机!
一、背景 二、爬取数据 三、数据分析 1、总人口 2、男女人口比例 3、人口城镇化 4、人口增长率 5、人口老化(抚养比) 6、各省人口 7、世界人口 四、遇到的问题 遇到的问题 1、数据分页,需要获取从1949-2018年数据,观察到有近20年参数:LAST20,由此推测获取近70年的参数可设置为:LAST70 2、2019年数据没有放上去,可以手动添加上去 3、将数据进行 行列转换 4、列名...
web前端javascript+jquery知识点总结
1.Javascript 语法.用途 javascript 在前端网页中占有非常重要的地位,可以用于验证表单,制作特效等功能,它是一种描述语言,也是一种基于对象(Object)和事件驱动并具有安全性的脚本语言 ...
Python实战:抓肺炎疫情实时数据,画2019-nCoV疫情地图
今天,群里白垩老师问如何用python画武汉肺炎疫情地图。白垩老师是研究海洋生态与地球生物的学者,国家重点实验室成员,于不惑之年学习python,实为我等学习楷模。先前我并没有关注武汉肺炎的具体数据,也没有画过类似的数据分布图。于是就拿了两个小时,专门研究了一下,遂成此文。
听说想当黑客的都玩过这个Monyer游戏(1~14攻略)
第零关 进入传送门开始第0关(游戏链接) 请点击链接进入第1关: 连接在左边→ ←连接在右边 看不到啊。。。。(只能看到一堆大佬做完的留名,也能看到菜鸡的我,在后面~~) 直接fn+f12吧 &lt;span&gt;连接在左边→&lt;/span&gt; &lt;a href="first.php"&gt;&lt;/a&gt; &lt;span&gt;←连接在右边&lt;/span&gt; o...
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ...... ...
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!...
渗透测试-灰鸽子远控木马
木马概述 灰鸽子( Huigezi),原本该软件适用于公司和家庭管理,其功能十分强大,不但能监视摄像头、键盘记录、监控桌面、文件操作等。还提供了黑客专用功能,如:伪装系统图标、随意更换启动项名称和表述、随意更换端口、运行后自删除、毫无提示安装等,并采用反弹链接这种缺陷设计,使得使用者拥有最高权限,一经破解即无法控制。最终导致被黑客恶意使用。原作者的灰鸽子被定义为是一款集多种控制方式于一体的木马程序...
Python:爬取疫情每日数据
前言 目前每天各大平台,如腾讯、今日头条都会更新疫情每日数据,他们的数据源都是一样的,主要都是通过各地的卫健委官网通报。 以全国、湖北和上海为例,分别为以下三个网站: 国家卫健委官网:http://www.nhc.gov.cn/xcs/yqtb/list_gzbd.shtml 湖北卫健委官网:http://wjw.hubei.gov.cn/bmdt/ztzl/fkxxgzbdgrfyyq/xxfb...
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。 再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。 下文是原回答,希望能对你能有所启发。 如果我说,这个世界上人真的分三六九等,...
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合...
雷火神山直播超两亿,Web播放器事件监听是怎么实现的?
Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题,让视音频内容可以不依赖用户安装App,就能进行播放以及在社交平台进行传播。在视频业务大数据平台中,播放数据的统计分析非常重要,所以Web播放器在使用过程中,需要对其内部的数据进行收集并上报至服务端,此时,就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢? 01 监听事件明细表 名...
3万字总结,Mysql优化之精髓
本文知识点较多,篇幅较长,请耐心学习 MySQL已经成为时下关系型数据库产品的中坚力量,备受互联网大厂的青睐,出门面试想进BAT,想拿高工资,不会点MySQL优化知识,拿offer的成功率会大大下降。 为什么要优化 系统的吞吐量瓶颈往往出现在数据库的访问速度上 随着应用程序的运行,数据库的中的数据会越来越多,处理时间会相应变慢 数据是存放在磁盘上的,读写速度无法和内存相比 如何优化 设计...
Python新型冠状病毒疫情数据自动爬取+统计+发送报告+数据屏幕(三)发送篇
今天介绍的项目是使用 Itchat 发送统计报告 项目功能设计: 定时爬取疫情数据存入Mysql 进行数据分析制作疫情报告 使用itchat给亲人朋友发送分析报告 基于Django做数据屏幕 使用Tableau做数据分析 来看看最终效果 目前已经完成,预计2月12日前更新 使用 itchat 发送数据统计报告 itchat 是一个基于 web微信的一个框架,但微信官方并不允许使用这...
作为程序员的我,大学四年一直自学,全靠这些实用工具和学习网站!
我本人因为高中沉迷于爱情,导致学业荒废,后来高考,毫无疑问进入了一所普普通通的大学,实在惭愧???? 我又是那么好强,现在学历不行,没办法改变的事情了,所以,进入大学开始,我就下定决心,一定要让自己掌握更多的技能,尤其选择了计算机这个行业,一定要多学习技术。 在进入大学学习不久后,我就认清了一个现实:我这个大学的整体教学质量和学习风气,真的一言难尽,懂的人自然知道怎么回事? 怎么办?我该如何更好的提升自...
粒子群算法求解物流配送路线问题(python)
1.Matlab实现粒子群算法的程序代码:https://www.cnblogs.com/kexinxin/p/9858664.html matlab代码求解函数最优值:https://blog.csdn.net/zyqblog/article/details/80829043 讲解通俗易懂,有数学实例的博文:https://blog.csdn.net/daaikuaichuan/article/...
教你如何编写第一个简单的爬虫
很多人知道爬虫,也很想利用爬虫去爬取自己想要的数据,那么爬虫到底怎么用呢?今天就教大家编写一个简单的爬虫。 下面以爬取笔者的个人博客网站为例获取第一篇文章的标题名称,教大家学会一个简单的爬虫。 第一步:获取页面 #!/usr/bin/python # coding: utf-8 import requests #引入包requests link = "http://www.santostang....
前端JS初级面试题二 (。•ˇ‸ˇ•。)老铁们!快来瞧瞧自己都会了么
1. 传统事件绑定和符合W3C标准的事件绑定有什么区别? 传统事件绑定 &lt;div onclick=""&gt;123&lt;/div&gt; div1.onclick = function(){}; &lt;button onmouseover=""&gt;&lt;/button&gt; 注意: 如果给同一个元素绑定了两次或多次相同类型的事件,那么后面的绑定会覆盖前面的绑定 (不支持DOM事...
相关热词 c# 数组类型 泛型约束 c#的赛狗日程序 c# 传递数组 可变参数 c# 生成存储过程 c# list 补集 c#获得所有窗体 c# 当前秒数转成年月日 c#中的枚举 c# 计算校验和 连续随机数不重复c#
立即提问