Package org.jrest4guice.dao.hibernate

Source Code of org.jrest4guice.dao.hibernate.HibernateContext

package org.jrest4guice.dao.hibernate;

import java.lang.reflect.Method;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.jrest4guice.dao.actions.Action;
import org.jrest4guice.dao.actions.ActionContext;


public class HibernateContext implements ActionContext {

  private Session session;
  private Action action;
  private boolean withoutService = false;

  public Object execute(Method method, Object[] parameters) throws Throwable {
    if (!withoutService)
      return action.execute(method, parameters);
    else {
      Transaction tx = session.beginTransaction();
      try {
        Object result = action.execute(method, parameters);
        return result;
      } catch (Exception e) {
        throw e.getCause();

  public Session getSession() {
    return session;

  public void setAction(Action action) {
    this.action = action;

Related Classes of org.jrest4guice.dao.hibernate.HibernateContext

Copyright © 2018 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