Experts,
I am doing this in NETBEANS ,ORACLE
I have created bean with fields id and name.
I have created a Facade file that is for session.My facade file is listed below.
My table is create table TEST (id varchar2(255) not null, name varchar2(255), primary key (id));
Problem is table gets created but when I try to see that data in netbeans console it doesnt work.
My question is How can I view the table data in netbeans console window?
Can someone suggest me on this.
My Facade file:-
Code:
public class TestFacade {
public void saveTest(Test test) {
Session session = hibdemo.TestHibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.save(test);
tx.commit();
hibdemo.TestHibernateUtil.closeSession();
}
public void generate()
{
Test test = new Test();
test.setId("AA");
test.setName("Tom");
test.setAge(15);
saveTest(test);
test = new Test();
test.setId("BB");
test.setName("Hary");
test.setAge(16);
saveTest(test);
}
public void query()
{
Session querySession =
hibdemo.TestHibernateUtil.getSessionFactory().openSession();
Transaction tx = querySession.beginTransaction();
hibdemo.TestHibernateUtil.closeSession();
Query query = querySession.createQuery("select hibdemo.name
from Test hibdemo");
for(Iterator itr=query.iterate();itr.hasNext();){
Object[] row = (Object[]) itr.next();
System.out.println("ID is : " + row[1]);
}
tx.commit();
querySession.close();
}
}
David