| Author |
Hibernate
|
Reshma Reddy
Ranch Hand
Joined: Dec 21, 2006
Posts: 197
|
|
Hi to All, i am doing simple hibernate applications when i run my application in eclipse it is not recognising my cfg.xml file i think my application context root is not correct please tell me where i have to keep my xml files and where i have to keep java files tell me that context root for any hibernate application, thanks in advance Thanks, vishnu.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
hibernate.cfg.xml should be in the root directory of your class files (unless you configure it otherwise). Where have you put it? Can you show us the code you use to create your SessionFactory?
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Reshma Reddy
Ranch Hand
Joined: Dec 21, 2006
Posts: 197
|
|
hi this my SessonFactory class package src.example; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class FirstExample { /** * @param args */ public static void main(String[] args) { /** * TODO Auto-generated method stub * Simple Hibernate Example */ Session session = null; try{ Configuration configaration = new Configuration(); Configuration config = configaration.configure(); //SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); SessionFactory sessionFactory = config.buildSessionFactory(); session = sessionFactory.openSession(); //opening session System.out.println("insert values in to table"); Honey honey= new Honey(); honey.setId(2); honey.setName("abc"); honey.setTaste("ok"); session.save(honey); System.out.println("insertion is over"); } catch(Exception e) { e.printStackTrace(); } finally { //session.flush(); //session.close(); } } }
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Ok, so you are just using the default configuration in which case hibernate.cfg.xml should be at the root directory where your classes are. Is it?
|
 |
 |
|
|
subject: Hibernate
|
|
|