Package org.springmodules.prevayler.callback

Examples of org.springmodules.prevayler.callback.PrevaylerCallback


    public Object execute(PrevaylerCallback callback) {
        if (this.flushed) {
            throw new PrevaylerTransactionException("Error: session already flushed and closed.");
        } else {
            // Enqueue a copy of the callback for later execution through prevayler at commit time:
            PrevaylerCallback copiedCallback = (PrevaylerCallback) this.deepCopy(callback);
            this.executionQueue.add(copiedCallback);
            // Locally execute the callback:
            return callback.doInTransaction(this.system);
        }
    }
View Full Code Here


   
    public Object save(Object entity) {
        Session session = null;
        try {
            session = PersistenceManagerUtils.getSession(this.getPersistenceManager(), true);
            PrevaylerCallback callback = new SaveCallback(entity);
            Object saved = session.execute(callback);
            if (entity != saved) {
                session.execute(new MergeCallback(saved, entity));
            }
            return saved;
View Full Code Here

   
    public Object update(Object entity) {
        Session session = null;
        try {
            session = PersistenceManagerUtils.getSession(this.getPersistenceManager(), true);
            PrevaylerCallback callback = new UpdateCallback(entity);
            Object saved = session.execute(callback);
            if (entity != saved) {
                session.execute(new MergeCallback(saved, entity));
            }
            return saved;
View Full Code Here

   
    public void delete(Object entity) {
        Session session = null;
        try {
            session = PersistenceManagerUtils.getSession(this.getPersistenceManager(), true);
            PrevaylerCallback callback = new DeleteByEntityCallback(entity);
            session.execute(callback);
        } catch(DataAccessException ex) {
            throw ex;
        } catch(Exception ex) {
            throw new PrevaylerOperationException("Exception occured while executing Prevayler operation: " + ex.getMessage(), ex);
View Full Code Here

   
    public void delete(Class entityClass) {
        Session session = null;
        try {
            session = PersistenceManagerUtils.getSession(this.getPersistenceManager(), true);
            PrevaylerCallback callback = new DeleteByEntityClassCallback(entityClass);
            session.execute(callback);
        } catch(DataAccessException ex) {
            throw ex;
        } catch(Exception ex) {
            throw new PrevaylerOperationException("Exception occured while executing Prevayler operation: " + ex.getMessage(), ex);
View Full Code Here

   
    public Object get(Class entityClass, Object id) {
        Session session = null;
        try {
            session = PersistenceManagerUtils.getSession(this.getPersistenceManager(), true);
            PrevaylerCallback callback = new GetByIdCallback(entityClass, id);
            return session.execute(callback);
        } catch(DataAccessException ex) {
            throw ex;
        } catch(Exception ex) {
            throw new PrevaylerOperationException("Exception occured while executing Prevayler operation: " + ex.getMessage(), ex);
View Full Code Here

   
    public List get(Class entityClass) {
        Session session = null;
        try {
            session = PersistenceManagerUtils.getSession(this.getPersistenceManager(), true);
            PrevaylerCallback callback = new GetByClassCallback(entityClass);
            return (List) session.execute(callback);
        } catch(DataAccessException ex) {
            throw ex;
        } catch(Exception ex) {
            throw new PrevaylerOperationException("Exception occured while executing Prevayler operation: " + ex.getMessage(), ex);
View Full Code Here

       
        assertNull(emp1.getFirstname());
        assertNull(emp1.getSurname());
       
        // Execute a callback which looks for a1 and update it:
        PrevaylerCallback callback = new SimpleSearchAndUpdatePrevaylerCallback();
        // The callback execution returns a list of one employee:
        List result = (List) this.template.execute(callback);
        assertEquals(1, result.size());
        // Get it:
        emp1 = (EmployeeImpl) result.get(0);
View Full Code Here

   
    public void executeOn(Object object, Date date) {
        PrevalentSystem system= (PrevalentSystem) object;
        Iterator it = this.callbacks.iterator();
        while (it.hasNext()) {
            PrevaylerCallback callback = (PrevaylerCallback) it.next();
            callback.doInTransaction(system);
        }
    }
View Full Code Here

TOP

Related Classes of org.springmodules.prevayler.callback.PrevaylerCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.