我是靠谱客的博主 动听柜子,最近开发中收集的这篇文章主要介绍ssh mysql视屏,ssh+MySQL开发VOD视频点播系统,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

package com.yanhui.base;

import java.io.Serializable;

import java.util.List;

import java.util.Map;

import org.hibernate.Query;

import org.hibernate.Session;

import org.hibernate.SessionFactory;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Repository;

@Repository

public class BaseDaoImpl implements BaseDao {

protected SessionFactory sessionFactory;

public SessionFactory getSessionFactory() {

return sessionFactory;

}

@Autowired

public void setSessionFactory(SessionFactory sessionFactory) {

this.sessionFactory = sessionFactory;

}

//@Resource

//public void setSessionFactory0(SessionFactory sessionFactory) {

//super.setSessionFactory(sessionFactory);

//

//

//}

private Session getCurrentSession() {

return this.sessionFactory.getCurrentSession();

}

public Serializable save(T o) {

return this.getCurrentSession().save(o);

}

public T get(Class c, Serializable id) {

return (T) this.getCurrentSession().get(c, id);

}

public T get(String hql) {

Query q = this.getCurrentSession().createQuery(hql);

List l = q.list();

if (l != null && l.size() > 0) {

return l.get(0);

}

return null;

}

public T get(String hql, Map params) {

Query q = this.getCurrentSession().createQuery(hql);

if (params != null && !params.isEmpty()) {

for (String key : params.keySet()) {

q.setParameter(key, params.get(key));

}

}

List l = q.list();

if (l != null && l.size() > 0) {

return l.get(0);

}

return null;

}

public void delete(T o) {

this.getCurrentSession().delete(o);

}

public void update(T o) {

this.getCurrentSession().update(o);

}

public void saveOrUpdate(T o) {

this.getCurrentSession().saveOrUpdate(o);

}

public List find(String hql) {

Query q = this.getCurrentSession().createQuery(hql);

return q.list();

}

public List find(String hql, Map params) {

Query q = this.getCurrentSession().createQuery(hql);

if (params != null && !params.isEmpty()) {

for (String key : params.keySet()) {

q.setParameter(key, params.get(key));

}

}

return q.list();

}

public List find(String hql, Map params, int page, int rows) {

Query q = this.getCurrentSession().createQuery(hql);

if (params != null && !params.isEmpty()) {

for (String key : params.keySet()) {

q.setParameter(key, params.get(key));

}

}

return q.setFirstResult((page - 1) * rows).setMaxResults(rows).list();

}

public List find(String hql, int page, int rows) {

Query q = this.getCurrentSession().createQuery(hql);

return q.setFirstResult((page - 1) * rows).setMaxResults(rows).list();

}

public Long count(String hql) {

Query q = this.getCurrentSession().createQuery(hql);

return (Long) q.uniqueResult();

}

public Long count(String hql, Map params) {

Query q = this.getCurrentSession().createQuery(hql);

if (params != null && !params.isEmpty()) {

for (String key : params.keySet()) {

q.setParameter(key, params.get(key));

}

}

return (Long) q.uniqueResult();

}

public int executeHql(String hql) {

Query q = this.getCurrentSession().createQuery(hql);

return q.executeUpdate();

}

public int executeHql(String hql, Map params) {

Query q = this.getCurrentSession().createQuery(hql);

if (params != null && !params.isEmpty()) {

for (String key : params.keySet()) {

q.setParameter(key, params.get(key));

}

}

return q.executeUpdate();

}

}

最后

以上就是动听柜子为你收集整理的ssh mysql视屏,ssh+MySQL开发VOD视频点播系统的全部内容,希望文章能够帮你解决ssh mysql视屏,ssh+MySQL开发VOD视频点播系统所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部