All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jfireframework.jfireSqlStarter.SqlSessionProxy Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
package com.jfireframework.jfireSqlStarter;

import java.sql.Connection;
import java.util.List;
import com.jfireframework.sql.dao.LockMode;
import com.jfireframework.sql.page.Page;
import com.jfireframework.sql.resultsettransfer.ResultSetTransfer;
import com.jfireframework.sql.session.SessionFactory;
import com.jfireframework.sql.session.SqlSession;

public class SqlSessionProxy implements SqlSession
{
    private SessionFactory sessionFactory;
    
    public void setSessionFactory(SessionFactory sessionFactory)
    {
        this.sessionFactory = sessionFactory;
    }
    
    @Override
    public  T get(Class entityClass, Object pk)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.get(entityClass, pk);
    }
    
    @Override
    public  T get(Class entityClass, Object pk, LockMode mode)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.get(entityClass, pk, mode);
    }
    
    @Override
    public  void save(T entity)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        session.save(entity);
    }
    
    @Override
    public  void batchInsert(List entitys)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        session.batchInsert(entitys);
    }
    
    @Override
    public  void insert(T entity)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        session.insert(entity);
    }
    
    @Override
    public  int delete(T entity)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.delete(entity);
    }
    
    @Override
    public  T query(ResultSetTransfer transfer, String sql, Object... params)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.query(transfer, sql, params);
    }
    
    @Override
    public  List queryList(ResultSetTransfer transfer, String sql, Object... params)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.queryList(transfer, sql, params);
    }
    
    @Override
    public  List queryList(ResultSetTransfer transfer, String sql, Page page, Object... params)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.queryList(transfer, sql, page, params);
    }
    
    @Override
    public int update(String sql, Object... params)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.update(sql, params);
    }
    
    @Override
    public void close()
    {
        SqlSession session = sessionFactory.getCurrentSession();
        session.close();
    }
    
    @Override
    public void beginTransAction(int isolate)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        session.beginTransAction(isolate);
    }
    
    @Override
    public void commit()
    {
        SqlSession session = sessionFactory.getCurrentSession();
        session.commit();
    }
    
    @Override
    public void flush()
    {
        SqlSession session = sessionFactory.getCurrentSession();
        session.flush();
    }
    
    @Override
    public void rollback()
    {
        SqlSession session = sessionFactory.getCurrentSession();
        session.rollback();
    }
    
    @Override
    public Connection getConnection()
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.getConnection();
    }
    
    @Override
    public  T findOne(Class entityClass, String strategy, Object... params)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.findOne(entityClass, strategy, params);
    }
    
    @Override
    public  List findAll(Class entityClass, String strategy, Object... params)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.findAll(entityClass, strategy, params);
    }
    
    @Override
    public  List findPage(Class entityClass, Page page, String strategy, Object... params)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.findPage(entityClass, page, strategy, params);
    }
    
    @Override
    public int update(Class ckass, String sql, Object... params)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.update(ckass, sql, params);
    }
    
    @Override
    public int delete(Class ckass, String strategy, Object... params)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.delete(ckass, strategy, params);
    }
    
    @Override
    public int count(Class ckass, String strategy, Object... params)
    {
        SqlSession session = sessionFactory.getCurrentSession();
        return session.count(ckass, strategy, params);
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy