hibernate dao 公共方法
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 公共方法的更多相关文章
- 转:HIBERNATE一些_方法_@注解_代码示例---写的非常好
HIBERNATE一些_方法_@注解_代码示例操作数据库7步骤 : 1 创建一个SessionFactory对象 2 创建Session对象 3 开启事务Transaction : hibernate ...
- 【hibernate 执行方法未插入数据库】hibernate的save方法成功执行,但是未插入到数据库
今天做项目,碰上这个问题: hibernate的save方法成功执行,但是未插入到数据库. Dao层代码: @Override public void save(T t) { this.getSess ...
- J2EE进阶(十六)Hibernate 中getHibernateTemplate()方法使用
J2EE进阶(十六)Hibernate 中getHibernateTemplate()方法使用 spring 中获得由spring所配置的hibernate的操作对象,然后利用此对象进行,保存,修 ...
- Mybatis 原始dao CRUD方法
用到的相关jar包及所用版本如下: 其中的Mybatis可以到github.com的网站下载 <project xmlns="http://maven.apache.org/POM/4 ...
- J2EE项目开发中常用到的公共方法
在项目IDCM中涉及到多种工单,包括有:服务器|网络设备上下架工单.服务器|网络设备重启工单.服务器光纤网线更换工单.网络设备撤线布线工单.服务器|网络设备替换工单.服务器|网络设备RMA工单.通用原 ...
- php 图片上传的公共方法(按图片宽高缩放或原图)
写的用于图片上传的公共方法类调用方法: $upload_name='pic';$type = 'logo_val';$file_name = 'logo_' . $user_id .create_st ...
- web开发过程中经常用到的一些公共方法及操作
进化成为程序猿也有段岁月了,所谓的经验,广度还是依旧,只不过是对于某种功能有了多种实现方式的想法.每天依旧不厌其烦的敲打着代码,每一行代码的回车似乎都有一种似曾相识的感觉.于是乎:粘贴复制,再粘贴再复 ...
- iOS常用公共方法
iOS常用公共方法 字数2917 阅读3070 评论45 喜欢236 1. 获取磁盘总空间大小 //磁盘总空间 + (CGFloat)diskOfAllSizeMBytes{ CGFloat si ...
- MyBatis学习--mybatis开发dao的方法
简介 使用Mybatis开发Dao,通常有两个方法,即原始Dao开发方法和Mapper接口开发方法. 主要概念介绍: MyBatis中进行Dao开发时候有几个重要的类,它们是SqlSessionFac ...
随机推荐
- 怎么在阿里云搭建一个WordPress博客(超详细教程)
想以正确的方式启动一个 WordPress 博客吗?我知道,这可能是一个令人恐惧的想法 -- 其实你并不孤单.但是,在帮助很多用户创建博客之后,我决定编写一份详细的指南,让任何没有技术知识的人都能拥有 ...
- 微信小程序swiper bindChange重复执行
swiper是微信小程序的一个滑动组件,非常重要.如果只是做简单的轮播图而不进行复杂的逻辑,直接可以使用,甚至不需要知道组件的方法.今天在做一个如下的页面时,快速滑动swiper出现了问题: 控制台打 ...
- python tips:最内嵌套作用域规则,闭包与装饰器
在作用域与名字空间提到,python是静态作用域,变量定义的位置决定了变量作用的范围.变量沿着local,global,builtins的路径搜索,直觉上就是从里到外搜索变量,这称为最内嵌套作用域规则 ...
- eas之创建一个UI界面并对其操作
private void BranchAddNew(ActionEvent e) { UIContext uiContext = new UIContext(this); ui ...
- vfs:结构体对象
VFS结构体 super_block 存储一个已安装的文件系统的控制信息,代表一个已安装的文件系统:每次一个实际的文件系统被安装时, 内核会从磁盘的特定位置读取一些控制信息来填充内存中的超级块对象.一 ...
- laravel中ubuntu下执行php artisan migrate总是报错
ubuntu14.0 + xampp + laravel5下 laravel中ubuntu下执行php artisan migrate总是报错: [PDOException] could not fi ...
- js声明变量作用域会提前
var s = 1; function test() { console.info(s); var s = 2; console.info(s); } test(); >>>unde ...
- [luogu1155 NOIP2008] 双栈排序 (二分图染色)
传送门 Description Input 第一行是一个整数 n . 第二行有 n 个用空格隔开的正整数,构成一个 1−n 的排列. Output 共一行,如果输入的排列不是"可双栈排序排列 ...
- 使用Vue CLI 3将基于element-ui二次封装的组件发布到npm
前言:之前在网上找的好多都是基于vue-cli 2.x的,而使用vue-cli 3的文章比较少,Vue CLI 3 中文文档,所以我在自己尝试的时候把几篇文章结合了一下,调出来了我想要的模式,也就是V ...
- vue实现双向绑定mvvm
剖析Vue实现原理 - 如何实现双向绑定mvvm 本文能帮你做什么?1.了解vue的双向数据绑定原理以及核心代码模块2.缓解好奇心的同时了解如何实现双向绑定为了便于说明原理与实现,本文相关代码主要摘自 ...