app.datos.servicios.implementacion.HistorialServiceImpl.java Source code

Java tutorial

Introduction

Here is the source code for app.datos.servicios.implementacion.HistorialServiceImpl.java

Source

/**
 * Copyright (C) 2016 Fernando Berti - Daniel Campodonico - Emiliano Gioria - Lucas Moretti - Esteban Rebechi - Andres Leonel Rico
 * This file is part of Olimpo.
 *
 * Olimpo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Olimpo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Olimpo. If not, see <http://www.gnu.org/licenses/>.
 */
package app.datos.servicios.implementacion;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import app.datos.entidades.HistorialInmueble;
import app.datos.servicios.HistorialService;
import app.excepciones.PersistenciaException;
import app.excepciones.SaveUpdateException;

@Repository
public class HistorialServiceImpl implements HistorialService {

    private SessionFactory sessionFactory;

    @Autowired
    public HistorialServiceImpl(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

    public SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    @Override
    @Transactional(rollbackFor = PersistenciaException.class)
    public void guardarHistorialInmueble(HistorialInmueble historialInmueble) throws PersistenciaException {
        Session session = getSessionFactory().getCurrentSession();
        try {
            session.save(historialInmueble);
        } catch (Exception e) {
            throw new SaveUpdateException(e);
        }
    }

}