-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate java app connection
PostPosted: Sat Dec 20, 2008 7:42 am 
Newbie

Joined: Sat Dec 20, 2008 5:59 am
Posts: 1
Can anyone help me on how to connect hibernate and java app? I don't know what codes to put on the java app classes so that the java app can connect to the hibernate DB. i tried putting this code:

ItemDao itemDao = new ItemDaoImpl();


item1 = new Item();
item1.setItemName("fries");
item1.setPrice(120.00);
itemDao.save(item1);

i get this error:
Exception in thread "main" java.lang.NullPointerException
at dao.impl.ItemDaoImpl.save(ItemDaoImpl.java:100)
at FastFoodModel.initializeModelFromFile(FastFoodModel.java:159)
at FastFoodFrame.main(FastFoodFrame.java:220)

the line java 100 is this:

session.close(); of public void save(Item c)

the line java 159 is this:

itemDao.save(item1); of

and the line java 220 is:

model.initializeModelFromFile("data.txt"); of public static void main(String[] args) throws Exception

Another question, when i tried putting this set of codes to the fastfood model:

*Session session = SessionFactorySingleton.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
String hqlQuery = "select id, orderCompleted, orderCancelled, totalPrice from Counter counter ";


List allCounters = session.createQuery(hqlQuery).list();

tx.commit();
session.close();*/
an error would occur on the first line saying that it's unreachable. :(

hope someone would reply me asap because i have a deadline to catch for my project tomorrow tnx.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.