VextoR
VextoR

Reputation: 5165

Hibernate newbie help in netbeans

I study hibernate, AFAIK you can use xml or annotation, I like annotation more so trying this method.

  1. Automatically created hibernate.cfg.xml (Netbeans wizard)
  2. Automatically created reverse engineering xml
  3. Automatically created HibernateUtil.java
  4. Automatically created POJO class with annotations

enter image description here

then code:

    SessionFactory session = HibernateUtil.getSessionFactory();
    CallInfo ci = new CallInfo(1234567); //POJO class
    session.getCurrentSession().save(ci);

and hibernate still wants the xml, why?

Exception in thread "main" java.lang.ExceptionInInitializerError
at ru.asteros.sochi.feedback.util.HibernateUtil.<clinit>(HibernateUtil.java:28)
at ru.asteros.sochi.feedback.SochiFeedback.main(SochiFeedback.java:52)
Caused by: org.hibernate.MappingNotFoundException: resource: ru/asteros/sochi/feedback/CallInfo.hbm.xml not found
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:563)

Upvotes: 1

Views: 517

Answers (1)

Nirmal- thInk beYond
Nirmal- thInk beYond

Reputation: 12054

probably CallInfo.hbm.xml is referenced in hibernate.cfg.hbm and its not in valid class path

Upvotes: 1

Related Questions