这个问题似乎重复了,但我尝试了所有可能但我无法解决此错误。请帮助我,我是Hibernate的初学者
我正在创建一个简单的应用程序来学习Hibernate。我正在使用Eclipes IDE,我在com.hibernate包中创建了一个类。该类定义为:
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
/**
* @author Deepak Kumar
*
* http://www.roseindia.net
* Hibernate example to inset data into Contact table
*/
public class FirstExample {
public static void main(String[] args) {
//Session session = null;
Configuration cfg=new Configuration();
cfg.configure("hibernate.cfg.xml");//populates the data of the configuration file
//creating seession factory object
SessionFactory factory=cfg.buildSessionFactory();
//creating session object
Session session=factory.openSession();
//creating transaction object
Transaction t=session.beginTransaction();
try{
// This step will read hibernate.cfg.xml
System.out.println("Inserting Record");
Contact contact = new Contact();
contact.setId(3);
contact.setFirstName("Deepak");
contact.setLastName("Kumar");
contact.setEmail("deepak_38@yahoo.com");
session.save(contact);
System.out.println("Done");
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
// Actual contact insertion will happen at this step
session.flush();
session.close();
}
}
}
我已经在src文件夹中定义了一个hibernate.cfg.xml文件(默认包) 我希望我能在这里得到我的答案
由于