error is : log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
/hibernate.cfg.xml not found
Exception in thread “main” java.lang.NullPointerException
at dto.working.main(working.java:28)
code:
package dto;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class working {
public static void main(String[] args) {
Session session = null;
try{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
Addresses obj1 = new Addresses();
obj1.setAddressid(1);
obj1.setChangedate(null);
obj1.setChangeuserid(null);
obj1.setCity(“delhi”);
obj1.setHouseno(“187”);
obj1.setStreet(“rohini”);
obj1.setZip(“110085”);
obj1.setCountries(“India”);
obj1.setCreationdate(null);
session.save(obj1);
} catch(Exception e){
System.out.println(e.getMessage());
}finally{
session.flush();
session.close();
}
}
}