<?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">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.url">
jdbc:mysql://localhost/myuser
</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="myeclipse.connection.profile">
MySqL JDBC Driver
</property>
<mapping resource="domain/News.hbm.xml" />
</session-factory> </hibernate-configuration>
将
SessionFactory sf = cfg.buildSessionFactory( new ServiceRegistryBuilder().buildServiceRegistry());
|
替换成
SessionFactory sf = cfg.buildSessionFactory(new ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry());
还需要在hibernate.cfg.xml中加入一条配置:
<property name="javax.persistence.validation.mode">none</property>