Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
Query q = session.createQuery(hql);
List resultList = q.list();
displayResult(resultList);
session.getTransaction().commit();
private void displayResult(List resultList) {
Vector<String> tableHeaders = new Vector<String>();
Vector tableData = new Vector();
tableHeaders.add("Id");
tableHeaders.add("Category Name");
tableHeaders.add("Status");
tableHeaders.add("LastUpdate Date");
for (Object o : resultList) {
InvDclStockCategory Cat = (InvDclStockCategory) o;
Vector<Object> oneRow = new Vector<Object>();
oneRow.add(Cat.getId());
oneRow.add(Cat.getDescription());
oneRow.add(Cat.getInactive());
oneRow.add(Cat.getLastUpdateDate());
tableData.add(oneRow);
}
resultTable.setModel(new DefaultTableModel(tableData, tableHeaders));
}
session.beginTransaction();
Query q = session.createQuery(hql);
List resultList = q.list();
displayResult(resultList);
session.getTransaction().commit();
private void displayResult(List resultList) {
Vector<String> tableHeaders = new Vector<String>();
Vector tableData = new Vector();
tableHeaders.add("Id");
tableHeaders.add("Category Name");
tableHeaders.add("Status");
tableHeaders.add("LastUpdate Date");
for (Object o : resultList) {
InvDclStockCategory Cat = (InvDclStockCategory) o;
Vector<Object> oneRow = new Vector<Object>();
oneRow.add(Cat.getId());
oneRow.add(Cat.getDescription());
oneRow.add(Cat.getInactive());
oneRow.add(Cat.getLastUpdateDate());
tableData.add(oneRow);
}
resultTable.setModel(new DefaultTableModel(tableData, tableHeaders));
}
No comments:
Post a Comment