# HG changeset patch # User Raimund Renkert # Date 1371198959 -7200 # Node ID 738c139b65260f1e3a2997d045a6e37b52348c82 # Parent 462db3ebf80f7a68ae2b73b4e559be234a87cc17 New manager for LMesswert objects. diff -r 462db3ebf80f -r 738c139b6526 src/main/java/de/intevation/lada/manage/LMesswertManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/manage/LMesswertManager.java Fri Jun 14 10:35:59 2013 +0200 @@ -0,0 +1,72 @@ +package de.intevation.lada.manage; + +import javax.ejb.EJBTransactionRolledbackException; +import javax.ejb.Stateless; +import javax.ejb.TransactionAttribute; +import javax.ejb.TransactionAttributeType; +import javax.inject.Inject; +import javax.persistence.EntityExistsException; +import javax.persistence.EntityManager; +import javax.persistence.TransactionRequiredException; + +import de.intevation.lada.model.LMesswert; + +/** + * This Manager provides databse operations for LMesswert objects. + * + * @author Raimund Renkert + */ +@Stateless +public class LMesswertManager +{ + @Inject + private EntityManager em; + + /** + * Delete a LProbe object by id. + * + * @param id + * @throws Exception + */ + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void delete(String id) throws Exception { + LMesswert messwert = em.find(LMesswert.class, id); + em.remove(messwert); + } + + /** + * Persist a new LMesswert object in the database. + * + * @param messwert The new LMesswert object. + * + * @throws EntityExistsException + * @throws IllegalArgumentException + * @throws TransactionRequiredException + */ + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void create(LMesswert messwert) + throws EntityExistsException, + IllegalArgumentException, + EJBTransactionRolledbackException, + TransactionRequiredException { + em.persist(messwert); + } + + /** + * Updates a LMesswert object in the database. + * + * @param messwert The new LMesswert object. + * + * @throws EntityExistsException + * @throws IllegalArgumentException + * @throws TransactionRequiredException + */ + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void update(LMesswert messwert) + throws EntityExistsException, + IllegalArgumentException, + EJBTransactionRolledbackException, + TransactionRequiredException { + em.merge(messwert); + } +}