com.matel.pg.dao.impl.AppInfoDAOImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.matel.pg.dao.impl.AppInfoDAOImpl.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.matel.pg.dao.impl;

import com.matel.pg.dao.AppInfoDAO;
import com.matel.pg.domain.AppInfo;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Transactional
@Repository
@Component("appInfoDAO")
public class AppInfoDAOImpl implements AppInfoDAO {

    @Autowired
    SessionFactory sessionFactory;

    @Override
    public AppInfo getFirst() {

        AppInfo appInfo = null;

        try {
            Session session = sessionFactory.getCurrentSession();
            Criteria criteria = session.createCriteria(AppInfo.class);
            criteria.setMaxResults(1);
            appInfo = (AppInfo) criteria.uniqueResult();
        } catch (Exception e) {
        }
        return appInfo;
    }

}