2
0
Fork 0

[svn r382] hacked jsf frontend working

This commit is contained in:
willemc 2009-08-11 20:31:29 +02:00
parent 37fdf22282
commit 9a605f177a
123 changed files with 7035 additions and 2418 deletions

View file

@ -29,6 +29,7 @@ package com.idcanet.vasc.backends.jpa;
import org.hibernate.Session;
import com.idcanet.vasc.core.AbstractVascBackend;
import com.idcanet.vasc.core.VascException;
/**
*
@ -43,36 +44,52 @@ abstract public class AbstractHibernateVascBackend extends AbstractVascBackend
*/
abstract Session getHibernateSession();
public void persist(Object object) throws Exception {
public void persist(Object object) throws VascException {
Session s = getHibernateSession();
try {
s.getTransaction().begin();
s.persist(object);
s.getTransaction().commit();
} finally {
if (s!=null) {
s.close();
if (s!=null && s.isOpen()) {
if (s.getTransaction().isActive()) {
s.getTransaction().rollback();
}
//s.close();
}
}
}
public Object merge(Object object) throws Exception {
public Object merge(Object object) throws VascException {
Session s = getHibernateSession();
try {
return s.merge(object);
s.getTransaction().begin();
Object result = s.merge(object);
s.getTransaction().commit();
return result;
} finally {
if (s!=null) {
s.close();
if (s!=null && s.isOpen()) {
if (s.getTransaction().isActive()) {
s.getTransaction().rollback();
}
//s.close();
}
}
}
public void delete(Object object) throws Exception {
public void delete(Object object) throws VascException {
Session s = getHibernateSession();
try {
s.getTransaction().begin();
Object newObject = s.merge(object);
s.delete(newObject);
s.getTransaction().commit();
} finally {
if (s!=null) {
s.close();
if (s!=null && s.isOpen()) {
if (s.getTransaction().isActive()) {
s.getTransaction().rollback();
}
//s.close();
}
}
}