67,515
社区成员
发帖
与我相关
我的任务
分享
package myFamily;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class Explorer {
public static void main(String[] args) {
Configuration conf=new Configuration().configure();
SessionFactory sf=conf.buildSessionFactory();
Session se=null;
User u=new User();
u.setName("xuxiao");
try{
se=sf.openSession();
se.beginTransaction();
se.getTransaction().begin();
se.save(u);
se.getTransaction().commit();
}catch(Exception e){
e.printStackTrace();
}finally{
se.close();
}
}
}
public class AbstractMethodError
extends IncompatibleClassChangeError
当应用程序试图调用一个抽象方法时,抛出此错误。
通常由编译器捕获此错误;如果某个类的定义自当前执行方法最后一次编译以后作了不兼容的更改,
则此错误只可能在运行时发生。
<!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.url">
jdbc:oracle:thin:@192.168.5.160:1521:my0id
</property>
<property name="hibernate.connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="hibernate.connection.username">xuxiao</property>
<property name="hibernate.connection.password">0000</property>
<property name="hibernate.dialect">
org.hibernate.dialect.Oracle9iDialect
</property>
<mapping resource="myFamily/User.hbm.xml" />
</session-factory>
</hibernate-configuration>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="myFamily.User" table="person">
<id name="num">
<generator class="uuid"></generator>
</id>
<property name="name" />
</class>
</hibernate-mapping>