<!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="hibernate.connection.driver_class">
org.postgresql.Driver
</property>
<property name="hibernate.connection.url">
jdbc:postgresql://localhost:5432/myspace
</property>
<property name="hibernate.connection.username">postgres</property>
<property name="connection.password">123456</property>
<property name="hibernate.dialect">
org.hibernate.dialect.PostgreSQLDialect
</property>
<property name="show_sql">true</property>
<mapping resource="com/java/hibernate/User.hbm.xml" />
</session-factory>
</hibernate-configuration>
User影射文件
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"
http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd
"><hibernate-mapping>
<class name="User">
<id name="id">
<generator class="native"/>
</id>
<property name="name"/>
<property name="password"/>
<property name="regDate"/>
<property name="loginTimes"/>
</class>
</hibernate-mapping>
User类文件
package com.java.hibernate;
import java.util.Date;
public class User {
private long id;
private String name;
private String password;
private Date regDate;
private int loginTimes;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Date getRegDate() {
return regDate;
}
public void setRegDate(Date regDate) {
this.regDate = regDate;
}
public int getLoginTimes() {
return loginTimes;
}
public void setLoginTimes(int loginTimes) {
this.loginTimes = loginTimes;
}
}