here is my own solution
maybe useful for someone beginning with hibernate and struts:
Action class
Code:
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException, HibernateException {
String target = null;
Collection liste_update = HibernateQueryUtil.getUpdateCollection();
if (liste_update != null) {
request.setAttribute("liste_update", liste_update);
target = "success";
} else {
System.err.println(
"Fehler beim Auslesen einer oder mehrerer Tabellen der Datenbank !");
target = "failure";
}
return (mapping.findForward(target));
}
helper classCode:
public static Collection getUpdateCollection()
throws IOException, ServletException, HibernateException {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
List results = null;
Collection updates = new Vector();
try {
tx = session.beginTransaction();
results =
session.find(
" from Bean_Update up" + " order by up.id_Update_ISB desc");
if (results.size() == 0) {
System.out.println("Keine Werte gefunden! \n");
}
Iterator iter = results.iterator();
while (iter.hasNext()) {
Bean_Update update = (Bean_Update) iter.next();
updates.add(update);
}
tx.commit();
} catch (Exception e) {
e.printStackTrace(System.err);
if (tx != null)
tx.rollback();
} finally {
HibernateUtil.closeSession();
}
return updates;
}
jsp[code]
<html:form action="/new_update_insert" focus="id_update">
<html:errors />
<table align="center" cellspacing="0">
<tr>
<td class="header">
<html:img page="/gui/pics/small_logo.gif"/>
</td>
<td class="header" colspan="3">
<b>Bitte ein (Teil-) Update ausw