嗨,我收到此错误..尝试了很多,但未能找到解决方案。谁能帮我....你可以从这个链接找到错误https://drive.google.com/file/d/0BxEeexgXf53PQ1JqZWQ4SEloSjg/view?usp=sharing
休眠.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 catalog="user" name="beans.UserDetail" table="USERS"/>
<id column="ID" name="id" type="java.lang.Integer">
<generator class="assigned"/>
</id>
<property column="UNAME" name="uname" type="string"/>
<property column="PWORD" name="pword" type="string"/>
</hibernate-mapping>
休眠.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="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
<property name="hibernate.connection.url">jdbc:derby://localhost:1527/dbtest </property>
<property name="hibernate.connection.username">root</property>
<property name="connection.password">pass</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="current_session_context_class">thread</property>
<property name = "show_sql">true</property>
<property name = "format_sql">true</property>
<property name = "hibernate.transaction.factory_class">org.hibernate.testing.cache.CachingRegionFactory
</property>
<property name = "hibernate.hbm2ddl.auto">create</property>
<mapping resource="config/hibernate.hbm.xml"></mapping>
<mapping class = "beans/insert"></mapping>
</session-factory>
</hibernate-configuration>
用户详细信息.java
package beans;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class UserDetail {
@Id private int id;
String uname;
String pword;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getPword() {
return pword;
}
public void setPword(String pword) {
this.pword = pword;
}
}
插入.java
package beans;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class insert {
public static void main(String[] args){
SessionFactory sf = (SessionFactory) new Configuration().configure("config/hibernate.cfg.xml").buildSessionFactory();
Session session = sf.openSession();
session.beginTransaction();
UserDetail user1 = new UserDetail();
user1.setId(7);
user1.setUname("testUser");
user1.setPword("testPassword");
session.save(user1);
session.getTransaction().commit();
}
}