Hibernate 3.5中对annotation集成后在配置方面有什么变化么?

hibernate 3.5

写了个简单的测试程序

 

eclipse没提示有如何错误


运行后无如何结果  数据库也没有插入数据

 

控制台无提示 直接就是terminated

 


 

 

package annotation.model;

import javax.persistence.*;

@Entity
public class Teacher {

    private int id;
    private String name;
    private String title;
    
    @Id
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
}

 

 

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;
import annotation.model.Teacher;

public class TeacherTest {

    public static void main(String[] args) {
        Teacher t = new Teacher();  
        t.setId(1);
        t.setName("asdf");
        t.setTitle("a");    
        Configuration cfg = new AnnotationConfiguration();
        SessionFactory sf = cfg.configure().buildSessionFactory();
        Session session = sf.openSession();
        session.beginTransaction();
        session.save(t);
        session.close();
        sf.close();
    }
}

你的ejb3-persistence.jar呢?