package com.dao.impl;

 import java.lang.reflect.ParameterizedType;
import java.util.Collection;
import java.util.List; import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository; import com.dao.IBaseDao;
import com.exception.CustomException;
import com.utils.BeanUtil;
import com.utils.Page;
import com.utils.QueryObject;
import com.utils.QueryParam; @SuppressWarnings("unchecked")
@Repository
public class BaseDao<T> implements IBaseDao<T>{ @Autowired(required = true)
@Qualifier("sessionFactory")
private SessionFactory sessionFactory; protected Session getCurrentSession() {
return this.sessionFactory.getCurrentSession();
} /**
* @Description: 根据ID获取对象
* @param id ID
* @return T
* @throws Exception
*/
public T get(String id) throws CustomException
{
List<T> objects = this.getAllByProperty("objId", id);
if (!objects.isEmpty())
{
return objects.get(0);
}
return null;
} /**
* @Description: 根据ID获取对象
* @param id ID
* @param c
* @return T
* @throws Exception
*/
public Object get(String id,Class c) throws CustomException
{
List<T> objects = (List<T>)this.getAllByProperty("objId", id,c);
if (!objects.isEmpty())
{
return objects.get(0);
}
return null;
} /**
* @Description: 根据属性获取对象
* @param propertyName 属性
* @param value 值
* @return T
* @throws Exception
*/
public T getObjectByProperty(String propertyName,Object value) throws CustomException
{
List<T> objects = this.getAllByProperty(propertyName, value);
if (!objects.isEmpty())
{
return objects.get(0);
}
return null;
} /**
* @Description: 根据属性获取对象
* @param propertyName 属性
* @param value 值
* @param c
* @return T
* @throws Exception
*/
public T getObjectByProperty(String propertyName,Object value,Class c) throws CustomException
{
List<T> objects = (List<T>)this.getAllByProperty(propertyName, value, c);
if (!objects.isEmpty())
{
return objects.get(0);
}
return null;
} /**
* @Description: 获取所有对象
* @return List<T>
* @throws Exception
*/
public List<T> getAll() throws CustomException
{
Class baseClass;
try
{
baseClass = Class.forName(BeanUtil.getParamType(this.getClass()).replace("class ", ""));
} catch (ClassNotFoundException e)
{
throw new CustomException(this.getClass()+"没有泛型! 或者没有重写 getBaseClass() method");
}
return this.getAll(baseClass);
} /**
* @Description: 获取所有对象
* @param c
* @return List<T>
* @throws Exception
*/
public List<T> getAll(Class c) throws CustomException
{
String hql = " from "+c.getSimpleName();
List<T> objects = this.getCurrentSession().createQuery(hql).list();
return objects;
} /**
* @Description: 根据属性获取所有对象
* @param propertyName 属性
* @param value 值
* @return List<T>
* @throws Exception
*/
public List<T> getAllByProperty(String propertyName,Object value) throws CustomException
{
Class baseClass;
try
{
baseClass = Class.forName(BeanUtil.getParamType(this.getClass()).replace("class ", ""));
} catch (ClassNotFoundException e)
{
throw new CustomException(this.getClass()+"没有泛型! 或者没有重写 getBaseClass() method");
}
return (List<T>)this.getAllByProperty(propertyName, value, baseClass);
} /**
* @Description: 根据属性获取所有对象
* @param propertyName 属性
* @param value 值
* @param c
* @return List<T>
* @throws Exception
*/
public List<Object> getAllByProperty(String propertyName,Object value,Class c) throws CustomException
{
StringBuffer hql = new StringBuffer();
hql.append(" from "+c.getSimpleName()+" where "+propertyName+" = '"+value+"'");
List<Object> objects = this.getCurrentSession().createQuery(hql.toString()).list();
return objects;
} /**
* @Description: 保存Object
* @param object 实体
* @return void
* @throws Exception
*/
public void save(T object)throws CustomException
{
this.getCurrentSession().saveOrUpdate(object);
} /**
* @Description: 保存Object
* @param object 实体
* @param c
* @return void
* @throws Exception
*/
public void save(Object object,Class c)throws CustomException
{
this.getCurrentSession().saveOrUpdate(object);
} /**
* @Description: 保存Object
* @param objects 实体
* @return void
* @throws Exception
*/
public void saveCollections(Collection<T> objects) throws CustomException
{
for (Object object:objects)
{
this.save((T)object);
}
} /**
* @Description: 保存Object
* @param objects 实体
* @param c
* @return void
* @throws Exception
*/
public void saveCollections(Collection<T> objects,Class c) throws CustomException
{
for (Object object:objects)
{
this.save((T)object);
}
} /**
* @Description: 删除对象
* @param id
* @return void
* @throws Exception
*/
public void remove(String id)
{
Class baseClass;
try
{
baseClass = Class.forName(BeanUtil.getParamType(this.getClass()).replace("class ", ""));
} catch (ClassNotFoundException e)
{
throw new CustomException(this.getClass()+"没有泛型! 或者没有重写 getBaseClass() method");
}
this.remove(id, baseClass);
} /**
* @Description: 删除对象
* @param ids
* @param c
* @return void
* @throws Exception
*/
public void remove(String[] ids,Class c)
{
for (String id:ids)
{
this.remove(id, c);
}
} /**
* @Description: 删除对象
* @param id
* @param c
* @return void
* @throws Exception
*/
public void remove(String id,Class c)
{
this.removeObjectByProperty("objId", id, c);
} /**
* @Description: 删除对象
* @param object 实体
* @return void
* @throws Exception
*/
public void remove(T object)
{
this.getCurrentSession().delete(object);
} /**
* @Description: 删除对象
* @param objects
* @return void
* @throws Exception
*/
public void removeCollections(Collection<T> objects) throws CustomException
{
for (Object object:objects)
{
this.remove((T)object);
}
} /**
* @Description: 删除对象
* @param propertyName 属性名
* @param value 值
* @return void
* @throws Exception
*/
public void removeObjectByProperty(String propertyName,Object value)throws CustomException
{
Class baseClass;
try
{
baseClass = Class.forName(BeanUtil.getParamType(this.getClass()).replace("class ", ""));
}
catch (ClassNotFoundException e)
{
throw new CustomException(this.getClass()+"没有泛型! 或者没有重写 getBaseClass() method");
}
this.removeObjectByProperty(propertyName, value, baseClass);
} /**
* @Description: 删除对象
* @param propertyName 属性名
* @param value 值
* @param c
* @return void
* @throws Exception
*/
public void removeObjectByProperty(String propertyName,Object value,Class c)throws CustomException
{
StringBuffer hql = new StringBuffer();
hql.append(" delete ").append(c.getSimpleName()).append(" ");
hql.append(" where ").append(propertyName).append(" = ? ");
this.getCurrentSession().createQuery(hql.toString()).setParameter(0, value).executeUpdate();
} /**
* @Description: 分页查询
* @param queryObject
* @param page
* @return void
* @throws Exception
*/
public void findByQueryObject(QueryObject queryObject,Page page)
{
StringBuffer hql = new StringBuffer();//hql语句
hql.append(" from ").append(queryObject.getEntityClass().getSimpleName()).append(" where 1=1 ");
String bieming = "bm";
for (QueryParam param:queryObject.getQueryParam().getAndParams()) //循环参数集合,拼接查询条件
{
if(!QueryParam.OPERATOR_IS.equals(param.getOperator())){
hql.append(" and ").append(param.getName()).append(" ").append(param.getOperator()).append(" ").append(":").append(bieming).append(" ");
}else{
hql.append(" and ").append(param.getName()).append(" ").append(param.getOperator()).append(" ").append("null");
}
bieming += bieming;
}
String sql = " ";
if(queryObject.getQueryProjections().getOrderProperty()!=null)//拼接排序条件
{
for(String s :queryObject.getQueryProjections().getOrderProperty())
{
sql = "order by "+ s ;
if(queryObject.getQueryProjections().getDescFlag()!=null &&queryObject.getQueryProjections().getDescFlag()[0])
{
sql = sql +" desc";
}
else
{
sql = sql + " asc";
}
}
}
Query query = this.getCurrentSession().createQuery(hql.toString()+sql);//查询结果集 bieming = "bm";
for (QueryParam param:queryObject.getQueryParam().getAndParams())
{
if( QueryParam.OPERATOR_IN.equals(param.getOperator()) || QueryParam.OPERATOR_NIN.equals(param.getOperator()) || QueryParam.OPERATOR_NOTIN.equals(param.getOperator())){
query.setParameterList(bieming, param.getValue().toString().split(","));
}else{
if(!QueryParam.OPERATOR_IS.equals(param.getOperator())){
query.setParameter(bieming, param.getValue());
}
}
bieming += bieming;
}
query.setFirstResult(page.getFirstResultNum());//设置分页显示的记录数
query.setMaxResults((int)page.getPageSize());
page.setData(query.setCacheable(true).list()); //查询总记录数
String hql_1 = "select count(*) " + hql.toString();
query = this.getCurrentSession().createQuery(hql_1);
bieming = "bm";
for (QueryParam param:queryObject.getQueryParam().getAndParams())
{
if( QueryParam.OPERATOR_IN.equals(param.getOperator())|| QueryParam.OPERATOR_NIN.equals(param.getOperator()) || QueryParam.OPERATOR_NOTIN.equals(param.getOperator())){
query.setParameterList(bieming, param.getValue().toString().split(","));
}else{
if(!QueryParam.OPERATOR_IS.equals(param.getOperator())){
query.setParameter(bieming, param.getValue());
}
}
bieming += bieming;
}
page.setTotal((Long)(query.setCacheable(true).list().get(0)));
} /**
* @Description: 公共查询
* @param queryObject
* @return List<T>
* @throws Exception
*/
public List<T> findByQueryObject(QueryObject queryObject)
{
StringBuffer hql = new StringBuffer();
hql.append(" from ").append(queryObject.getEntityClass().getSimpleName()).append(" where 1=1 ");
String bieming = "bm";
for (QueryParam param:queryObject.getQueryParam().getAndParams())
{
hql.append(" and ").append(param.getName()).append(" ").append(param.getOperator()).append(" ").append(":").append(bieming).append(" ");
bieming += bieming;
}
Query query = this.getCurrentSession().createQuery(hql.toString());
bieming = "bm";
for (QueryParam param:queryObject.getQueryParam().getAndParams())
{
if( QueryParam.OPERATOR_IN.equals(param.getOperator())|| QueryParam.OPERATOR_NIN.equals(param.getOperator()) || QueryParam.OPERATOR_NOTIN.equals(param.getOperator())){
query.setParameterList(bieming, param.getValue().toString().split(","));
}else{
query.setParameter(bieming, param.getValue());
}
bieming += bieming;
}
return query.list();
} /**
*
* @Description: sql+条件查询
* @param @param queryObject
* @param @return
* @return List<String>
* @throws
* @author ningpeng
* @date 2016年10月21日
*/
public List<Object[]> findDomainByQueryObject(QueryObject queryObject)
{
StringBuffer SQL = new StringBuffer();
String sql = queryObject.getQuerySql();
SQL.append(sql); for (QueryParam param:queryObject.getQueryParam().getAndParams())
{
SQL.append(" and ").append(param.getName()).append(" ").append(param.getOperator()).append(" ").append(" ? ");
}
Query query = this.getCurrentSession().createSQLQuery(sql.toString());
for (int i=0;i<queryObject.getQueryParam().getAndParams().size();i++)
{
query.setParameter(i, queryObject.getQueryParam().getAndParams().get(i).getValue());
}
return query.list();
} /**
* @Description: 修改
* @param 修改字段,修改值,条件字段,条件值
* @return void
* @throws Exception
*/
public void update(String propertyName,Object value,String conditionName,Object conditionValue)throws CustomException
{
Class baseClass;
try
{
baseClass = Class.forName(BeanUtil.getParamType(this.getClass()).replace("class ", ""));
}
catch (ClassNotFoundException e)
{
throw new CustomException(this.getClass()+"没有泛型! 或者没有重写 getBaseClass() method");
}
this.update(propertyName, value,conditionName,conditionValue,baseClass);
} /**
* @Description: 修改 修改字段,修改值,条件字段,条件值
* @param 修改字段,修改值,条件字段,条件值
* @param c
* @return void
* @throws Exception
*/
public void update(String propertyName,Object value,String conditionName,Object conditionValue,Class c)throws CustomException
{
StringBuffer hql = new StringBuffer();
hql.append(" update ").append(c.getSimpleName()).append(" ");
hql.append(" set ").append(propertyName).append(" = ? ");
hql.append(" where 1=1 and ").append(conditionName).append(" = ? ");
this.getCurrentSession().createQuery(hql.toString()).setParameter(0, value).setParameter(1, conditionValue).executeUpdate();
} /**
* @Description: 批量修改 修改字段,修改值,条件字段,条件值
* @param 修改字段,修改值,条件字段,条件值
* @param c
* @return void
* @throws Exception
*/
public void update(String propertyName,Object value,String conditionName,Object[] conditionValue,Class c)
{
for (Object id:conditionValue)
{
this.update(propertyName, value, conditionName, id);
}
} @Override
public String saveObjId(T object) throws CustomException {
// TODO Auto-generated method stub
return (String)this.getCurrentSession().save(object);
} public static String getParamType(Class c){
if (null != c ) {
ParameterizedType type = (ParameterizedType)c.getGenericSuperclass();
if (null != type.getActualTypeArguments() && type.getActualTypeArguments().length>0) {
return BeanUtil.toString(type.getActualTypeArguments());
}
}
return "";
} }
  package com.utils;

 import java.util.ArrayList;
import java.util.List; /**
* 查询参数对象
* @ClassName QueryParam
* @Description:TODO(这里用一句话描述这个类的作用)
*/
public final class QueryParam { public final static String AND = "and"; public final static String OR = "or"; public final static String NOT = "not"; public final static String OPERATOR_EQ = "="; public final static String OPERATOR_BT = "bt"; public final static String OPERATOR_NE = "!="; public final static String OPERATOR_NE_ANSINULL_OFF = "!=%"; public final static String OPERATOR_GE = ">="; public final static String OPERATOR_GT = ">"; public final static String OPERATOR_NGE = "!>="; public final static String OPERATOR_NGT = "!>"; public final static String OPERATOR_LE = "<="; public final static String OPERATOR_LT = "<"; public final static String OPERATOR_NLE = "!<="; public final static String OPERATOR_NLT = "!<"; public final static String OPERATOR_LIKE = "like"; public final static String OPERATOR_LEFTLIKE = "llike"; public final static String OPERATOR_RIGHTLIKE = "rlike"; public final static String OPERATOR_NLIKE = "!like"; public final static String OPERATOR_NLEFTLIKE = "!llike"; public final static String OPERATOR_NRIGHTLIKE = "!rlike"; public final static String OPERATOR_INCLUDE = "include"; public final static String OPERATOR_NINCLUDE = "!include"; public final static String OPERATOR_ILIKE = "ilike"; public final static String OPERATOR_NILIKE = "!ilike"; public final static String OPERATOR_IINCLUDE = "iinclude"; public final static String OPERATOR_NIINCLUDE = "!iinclude"; public final static String OPERATOR_IS = "is"; public final static String OPERATOR_NIS = "!is"; public final static String OPERATOR_IN = "in"; public final static String OPERATOR_NIN = "!in"; public final static String OPERATOR_NOTIN = "not in"; public final static String OPERATOR_EXIST = "exists"; public final static String OPERATOR_NEXIST = "not exists"; public final static String FETCH = "fetch"; private String name; //实体属性名,对应请求的键 private Object value; //查询参数,对应请求的值 private String operator = OPERATOR_EQ;//操作符,对应包含“_op”键的值 private List<QueryParam> andParams = new ArrayList<QueryParam>(0);
private List<QueryParam> orParams = new ArrayList<QueryParam>(0);
private List<QueryParam> notParams = new ArrayList<QueryParam>(0); public QueryParam() { } /**
*
* @Title QueryParam
* @Description TODO(这里用一句话描述这个方法的作用)
* @param name 查询实体的属性名
* @param operator 操作符,从请求包含“_op”的键中获取的值
* @param value 查询实体属性名所对应的键值
* @throws
*/
public QueryParam(String name, String operator, Object value) {
if (OPERATOR_LIKE.equals(operator)||OPERATOR_NLIKE.equals(operator)) {
value = "%"+value+"%";
}
if(OPERATOR_IS.equals(operator) || OPERATOR_NIS.equals(operator)) {
value=null;
}
if (null == value || "".equals(value)) {
if (OPERATOR_EQ.equals(operator)) {
operator = OPERATOR_IS;
} else if (OPERATOR_NE.equals(operator)) {
operator = OPERATOR_NIS;
}
} else {
if (OPERATOR_IS.equals(operator)) {
operator = OPERATOR_EQ;
} else if (OPERATOR_NIS.equals(operator)) {
operator = OPERATOR_NE;
}
}
if (OPERATOR_IN.equals(operator) || OPERATOR_NIN.equals(operator)) {
//value = value.toString().replaceAll(",", "','");
}
if (OPERATOR_EXIST.equals(operator) || OPERATOR_NEXIST.equals(operator)) {
value = value.toString().replaceAll(",", "','");
}
this.name = name;
this.value = value;
this.operator = operator;
this.validateOperator();
} public void and(QueryParam queryParam) {
andParams.add(queryParam);
} public void or(QueryParam queryParam) {
orParams.add(queryParam);
} public void not(QueryParam queryParam) {
notParams.add(queryParam);
} public String getName() {
return name;
} public String getOperator() {
return operator;
} public Object getValue() {
return value;
} //检查操作符是否有效
private void validateOperator() {
if(this.operator.startsWith("not")){
if(OPERATOR_NEXIST.equals(this.operator))
return;
if(OPERATOR_NOTIN.equals(this.operator))
return;
}else if (this.operator.startsWith("!")) {
if (this.operator.endsWith("%"))
return;
if (OPERATOR_NE.equals(this.operator))
return;
if (OPERATOR_NGE.equals(this.operator))
return;
if (OPERATOR_NGT.equals(this.operator))
return;
if (OPERATOR_NLE.equals(this.operator))
return;
if (OPERATOR_NLT.equals(this.operator))
return;
if (OPERATOR_NLIKE.equals(this.operator))
return;
if (OPERATOR_NLEFTLIKE.equals(this.operator))
return;
if (OPERATOR_NRIGHTLIKE.equals(this.operator))
return;
if (OPERATOR_NINCLUDE.equals(this.operator))
return;
if (OPERATOR_NILIKE.equals(this.operator))
return;
if (OPERATOR_NIINCLUDE.equals(this.operator))
return;
if (OPERATOR_NIS.equals(this.operator))
return;
if (OPERATOR_NIN.equals(this.operator))
return;
} else {
if (OPERATOR_EQ.equals(this.operator))
return;
if (OPERATOR_GE.equals(this.operator))
return;
if (OPERATOR_GT.equals(this.operator))
return;
if (OPERATOR_LE.equals(this.operator))
return;
if (OPERATOR_LT.equals(this.operator))
return;
if (OPERATOR_LIKE.equals(this.operator))
return;
if (OPERATOR_LEFTLIKE.equals(this.operator))
return;
if (OPERATOR_RIGHTLIKE.equals(this.operator))
return;
if (OPERATOR_INCLUDE.equals(this.operator))
return;
if (OPERATOR_ILIKE.equals(this.operator))
return;
if (OPERATOR_IINCLUDE.equals(this.operator))
return;
if (OPERATOR_IS.equals(this.operator))
return;
if (OPERATOR_IN.equals(this.operator))
return;
if (FETCH.equals(this.operator))
return;
if (OPERATOR_BT.equals(this.operator))
return;
if(OPERATOR_EXIST.equals(this.operator))
return;
}
throw new RuntimeException ("The operator " + this.operator + " could be incorrect!");
} public List<QueryParam> getAndParams() {
return andParams;
} public List<QueryParam> getNotParams() {
return notParams;
} public List<QueryParam> getOrParams() {
return orParams;
} }
 package com.utils;
import java.lang.reflect.ParameterizedType; /**
* @Description: 查询对象实现
* @param <T>
* @version V1.0
*/
public class QueryObjectBase<T> implements QueryObject<T> {
/**
* 泛型类参数类型
*/
private Class<T> entityClass; private QueryProjections queryProjections=new QueryProjections(); private String sql; /**
* 查询参数
*/
private QueryParam queryParam=new QueryParam(); @SuppressWarnings("unchecked")
public Class<T> getEntityClass() {
if(this.entityClass==null)
return (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
return this.entityClass;
}
public void setEntityClass(Class<T> entityClass) {
this.entityClass = entityClass;
}
public QueryProjections getQueryProjections() {
return queryProjections;
}
public void setQueryProjections(QueryProjections queryProjections) {
this.queryProjections = queryProjections;
}
public QueryParam getQueryParam() {
return queryParam;
}
public void setQueryParam(QueryParam queryParam) {
this.queryParam = queryParam;
}
public void setQuerySql(String sql) {
this.sql = sql;
}
public String getQuerySql() {
return sql;
}
}

hibernate dao 公共方法的更多相关文章

  1. 转:HIBERNATE一些_方法_@注解_代码示例---写的非常好

    HIBERNATE一些_方法_@注解_代码示例操作数据库7步骤 : 1 创建一个SessionFactory对象 2 创建Session对象 3 开启事务Transaction : hibernate ...

  2. 【hibernate 执行方法未插入数据库】hibernate的save方法成功执行,但是未插入到数据库

    今天做项目,碰上这个问题: hibernate的save方法成功执行,但是未插入到数据库. Dao层代码: @Override public void save(T t) { this.getSess ...

  3. J2EE进阶(十六)Hibernate 中getHibernateTemplate()方法使用

    J2EE进阶(十六)Hibernate 中getHibernateTemplate()方法使用   spring 中获得由spring所配置的hibernate的操作对象,然后利用此对象进行,保存,修 ...

  4. Mybatis 原始dao CRUD方法

    用到的相关jar包及所用版本如下: 其中的Mybatis可以到github.com的网站下载 <project xmlns="http://maven.apache.org/POM/4 ...

  5. J2EE项目开发中常用到的公共方法

    在项目IDCM中涉及到多种工单,包括有:服务器|网络设备上下架工单.服务器|网络设备重启工单.服务器光纤网线更换工单.网络设备撤线布线工单.服务器|网络设备替换工单.服务器|网络设备RMA工单.通用原 ...

  6. php 图片上传的公共方法(按图片宽高缩放或原图)

    写的用于图片上传的公共方法类调用方法: $upload_name='pic';$type = 'logo_val';$file_name = 'logo_' . $user_id .create_st ...

  7. web开发过程中经常用到的一些公共方法及操作

    进化成为程序猿也有段岁月了,所谓的经验,广度还是依旧,只不过是对于某种功能有了多种实现方式的想法.每天依旧不厌其烦的敲打着代码,每一行代码的回车似乎都有一种似曾相识的感觉.于是乎:粘贴复制,再粘贴再复 ...

  8. iOS常用公共方法

      iOS常用公共方法 字数2917 阅读3070 评论45 喜欢236 1. 获取磁盘总空间大小 //磁盘总空间 + (CGFloat)diskOfAllSizeMBytes{ CGFloat si ...

  9. MyBatis学习--mybatis开发dao的方法

    简介 使用Mybatis开发Dao,通常有两个方法,即原始Dao开发方法和Mapper接口开发方法. 主要概念介绍: MyBatis中进行Dao开发时候有几个重要的类,它们是SqlSessionFac ...

随机推荐

  1. vue 上滑加载更多

    移动端网页的上滑加载更多,其实就是滑动+分页的实现. <template> <div> <p class="footer-text">--{{f ...

  2. 【转载】java文件路径问题及getResource和getClassLoader().getResource的区别

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u012572955/article/details/52880520我们经常在java的io操作中读 ...

  3. iterm2 快捷键设置

    单词跳转 设置option+ 左右键

  4. php第三节课

    正则表达式 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...

  5. NOIp2016-NOIp2011解题报告(骗分)

    zxl钦点.让我练暴力骗分. 那就把2016-2011年的题目搞一搞. NOIp2016 Day1 T1 AC 100pts. (妈呀,这么水的一道题竟然还要调试,一遍过不了样例,果然是要退役的节奏啊 ...

  6. php中的empty()方法

    empty() 判断一个变量是否为“空”,isset() 判断一个变量是否已经设置.empty还会检测变量是否为空.为零.当一个变量值为0,empty() 认为这个变量同等于空,即相当于没有设置.例如 ...

  7. kotlin来了!!

    小编前端时间由于工作比较繁忙,没有更新帖子... 最近又再技术博客上逛时发现了 “Kotlin”, 1.据听说挺厉害的,该语言是由战斗民族俄罗斯人发明的!! 2.据听说前后端都可以做 3.据听说安卓大 ...

  8. Spring Boot-整合redis(六)

    redis安装 参考:https://www.cnblogs.com/LQBlog/p/9214517.html 单机版 1.添加pom依赖 <!-- Spring Boot Reids 依赖 ...

  9. System v和posix的IPC对比

    之前有一篇关于共享内存的System V和Posix的对比: http://www.cnblogs.com/charlesblc/p/6261469.html POSIX(Portable Opera ...

  10. HDU 2912

    直线关于球的多次反射,求最后一次反射点 #include <iostream> #include <cstdio> #include <cstring> #incl ...