hibernate.cfg.xml配置文件如下:
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 数据库连接 -->
<property name="connection.url">jdbc:mysql://localhost:3306/db_database14</property>
<!-- 数据库连接用户名 -->
<property name="connection.username">root</property>
<!-- 数据库连接密码 -->
<property name="connection.password">root</property>
<!-- 数据库驱动 -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- 打印SQL语句 -->
<property name="show_sql">true</property>
<!-- 自动建表 -->
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="org/hibernate/tutorial/hbm/Event.hbm.xml"/>
</session-factory>
</hibernate-configuration>
测试的时候包以下异常:
引用
2012-5-23 23:01:53 org.hibernate.annotations.common.Version <clinit>
信息: Hibernate Commons Annotations 3.2.0.Final
2012-5-23 23:01:53 org.hibernate.cfg.Environment <clinit>
信息: Hibernate 3.6.10.Final
2012-5-23 23:01:53 org.hibernate.cfg.Environment <clinit>
信息: hibernate.properties not found
2012-5-23 23:01:53 org.hibernate.cfg.Environment buildBytecodeProvider
信息: Bytecode provider name : javassist
2012-5-23 23:01:53 org.hibernate.cfg.Environment <clinit>
信息: using JDK 1.4 java.sql.Timestamp handling
2012-5-23 23:01:53 org.hibernate.cfg.Configuration configure
信息: configuring from resource: /hibernate.cfg.xml
2012-5-23 23:01:53 org.hibernate.cfg.Configuration getConfigurationInputStream
信息: Configuration resource: /hibernate.cfg.xml
2012-5-23 23:01:53 org.hibernate.cfg.Configuration addResource
信息: Reading mappings from resource : org/hibernate/tutorial/hbm/Event.hbm.xml
2012-5-23 23:01:53 org.hibernate.cfg.Configuration doConfigure
信息: Configured SessionFactory: null
2012-5-23 23:01:53 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
信息: Mapping class: org.hibernate.tutorial.hbm.Event -> EVENTS
2012-5-23 23:01:53 org.hibernate.cfg.Configuration applyHibernateValidatorLegacyConstraintsOnDDL
信息: Hibernate Validator not found: ignoring
2012-5-23 23:01:53 org.hibernate.validator.util.Version <clinit>
信息: Hibernate Validator bean-validator-3.0-JBoss-4.0.2
解决方案,在配置文件中加上下面一句既可:
<property name="javax.persistence.validation.mode">none</property>
分享到:
相关推荐
java运行依赖jar包
官方版本,亲测可用
官方版本,亲测可用
官方版本,亲测可用
本教程翻译自Hibernate Validator 4.0 GA指南,并参考JSR 303的规范,本着尽量不用JSR规范之外的特性,文档在编写时尽量不提及底层实现Hibernate Validator,而是关注Bean Validation规范本身。如果有不对之处,请...
hibernate-validator-4.0.2.GA.jar httpclient-4.1.2.jar httpcore-4.1.2.jar jackson-core-asl-1.7.2.jar jackson-core-asl-1.9.9.jar jackson-jaxrs-1.7.2.jar jackson-jaxrs-1.9.9.jar jackson-mapper-asl-1.7.2....