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.
|