hibernate配置模板

<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- local connection properties --> <property name="hibernate.connection.url"> jdbc:mysql://localhost:3306/ssh?useUnicode=true&characterEncoding=UTF-8 </property> <property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver </property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">root</property> <!-- property name="hibernate.connection.pool_size"></property --> <!-- dialect for MySQL --> <property name="dialect"> org.hibernate.dialect.MySQLDialect </property> <property name="hibernate.show_sql">false</property> <property name="hibernate.transaction.factory_class"> org.hibernate.transaction.JDBCTransactionFactory </property> <mapping resource="classpath:com/hibernate/chapterSixteen/Synchronizer/xml/Customer.hbm.xml" /> <mapping resource="classpath:com/hibernate/chapterSixteen/Synchronizer/xml/Suggestionpad.hbm.xml" /> </session-factory> </hibernate-configuration>

加载映射文件

public static void main(String[] args) { /** * 三种加载方法 * addClass(Class class) * addFile(File file) * addFile(String str) */ Configuration configuration = new Configuration().configure(); }

你可能感兴趣的:(Hibernate,mysql,properties,String,Class,encoding)