Hibernate使用二级缓存时,createSQLQuery需要注意的问题

Hibernate使用二级缓存时,createSQLQuery需要注意的问题

添加缓存之后不能返还个别属性,需返回整个实体。Java.lang.IllegalStateException: aliases expected length is 0; actual length is 1

Ubuntu部署项目部分命令

1、Ubuntu 16.04 设置MySQL远程访问权限

2、登录数据库:mysql -u root -p

3、SSH登录:ssh root@地址

4、查看防火墙状态:sudo ufw status

5、查看相关进程:ps -ef|grep java

6、关闭进程:kill -9 进程号

7、运行项目指令:nohup java -jar com-fangshuoit-gzf-api-0.0.1-SNAPSHOT.jar >gzf-9900.log &
首先需要进到自己springboot项目的根目录,然后执行如下linux命令
nohup java -jar 自己的springboot项目.jar >日志文件名.log 2>&1 &
命令详解:
nohup:不挂断地运行命令,退出帐户之后继续运行相应的进程。
日志文件名.log:是nohup把command的输出重定向到当前目录的指定的“日志文件名.log”文件中,即输出内容不打印到屏幕上,而是输出到”日志文件名.log”文件中。不指定文件名会在当前目录创建nohup.out,如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中。如果没有文件能创建或打开以用于追加,那么 Command 参数指定的命令不可调用。
2>&1:2就是标准错误,1是标准输出,该命令相当于把标准错误重定向到标准输出么。这里&相当于标准错误等效于标准输出,即把标准错误和标准输出同时输出到指定的“日志文件名.log”文件中。
java -jar 自己的springboot项目.jar:执行springboot的项目,如果单单只执行该命令,linux只会短暂的运行该项目,当退出控制台后会自动关闭该项目。
最后的&:让改作业在后台运行。

做简单轮播图以及悬浮广告总结

一、轮播图

1.布局及实现思路

我用的是叠加的方式

<div  id="long" >
  <div id="long1"><img src="http://a.hiphotos.baidu.com/image/h%3D300/sign=194caab2b50e7bec3cda05e11f2fb9fa/960a304e251f95caf1852c0bc4177f3e6709521e.jpg" width="300px" height="260px" /></div>
  <div id="long2">
    <img src="http://b.hiphotos.baidu.com/image/h%3D300/sign=d33763aa6fd0f703f9b293dc38fb5148/faf2b2119313b07e93a465b501d7912397dd8c75.jpg" width="300px" height="260px" />
  </div>
  <div id="long3">
    <img src="http://d.hiphotos.baidu.com/image/h%3D300/sign=d58f6cac5e43fbf2da2ca023807fca1e/9825bc315c6034a84d0cf125c6134954082376a3.jpg" width="300px" height="260px" />
  </div>

起初给他们的style中全部display:none;当哪张照片显示时哪个div的display:block;三个子容器的宽高都是一样的,然后每个子容器都相对父容器绝对定位,都是left:0;top:0;以达到重叠效果。

<style>
  *{
    margin: 0;padding:0;
  }
  #long{
    width: 300px;
    height: 260px;
    margin: 0 auto;
    position: relative;


  }
  #long1{
    width: 300px;
    height: 260px;
    position: absolute;
    left: 0;
    top:0;
    display: none;
  }
  #long2{
    width: 300px;
    height: 260px;
    left: 0;
    top:0;
  position: absolute;
    display: none;

  }
  #long3{
    width: 300px;
    height: 260px;
    left: 0;
    top:0;
    position: absolute;
    display: none;
  }

</style>

继续阅读“做简单轮播图以及悬浮广告总结”

前后端分离框架表单时间验证问题

1.表单提交信息

<i-col span="10">
 <i-form-item label="开始时间: " prop="startDate" required>
 <i-date-picker style="width: 100%" :clearable="false"
 v-model="formItem.startDate" type="date"
 format="yyyy-MM-dd"
 placeholder="选择活动时间"></i-date-picker>
 </i-form-item>
</i-col>

2.导入验证日期格式

import {validateDate} from '../../../../utils/validators'

3.验证信息

VO中对应字段可以是“”或null

ruleValidate: {
 'startDate': [
 {required: true, message: '请选择开始时间', validator: validateDate, trigger: 'change'},
 ],
 'endDate': [
 {required: true, message: '请选择接结束时间', validator: validateDate, trigger: 'change'},
 ],
},

4.其他情况说明

若VO中存在多层封装,类似于中宁水务系统中的教育培训,则无需上面2、3步骤,
<i-col span="20">
  <i-form-item label="培训时间: " prop="education.eduTime" required>
    <i-date-picker style="width: 100%" :clearable="false"
                   v-model="formItem.education.eduTime" type="date"
                   placeholder="选择活动时间"></i-date-picker>
  </i-form-item>
</i-col>
ruleValidate: {
 'education.eduTime': [
 {required: true, message: '请选择培训时间', type: 'date', triggers: ['blur', 'change']}
 ],
},

moment.js轻松管理日期和时间

https://blog.csdn.net/wulex/article/details/80402036

http://momentjs.cn/docs/

IntelliJ系列软件激活方法

1、安装好相关开发软件(IDEA或者WebStorm)。

2、打开http://idea.lanyus.com

3、添加hosts映射地址(0.0.0.0 account.jetbrains.com)。

4、打开软件获取激活码粘贴进去激活即可。

jpa查询学习实例

//模糊条件查询
@Query("select a.id from Room a where a.fullName like CONCAT('%',?1,'%')")
@QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
Set<Long> findIdByFullName(String name);

@Query("select a from Room a where a.name = ?1 and a.fullName like CONCAT('%',?2,'%')")
@QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
List<Room> findByNameAndPName(String name, String fullName);
//条件查询排序
@Query("select a from Room a where a.parentId = ?1 order by a.id")
@QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
List<Room> findByPidOrderName(Long pid);
//多数据更新
@Query("update GZFUser set pIdCard = ?2, holderName = ?3, type='other' where id in (?1)")
@Modifying
void updateOtherTypeByIds(Set<Long> ids, String pIdCard, String holderName);
//根据日期查询当年当月数据按照部门分组统计
@Query("select a.organization.id,count (a) from Education a where month(a.dateCreated) = month(?1) and year(a.dateCreated) = year(?1) group by a.organization.id")
List<Object[]> findHomeStateResult(String date);
//按名称分组排序
@Query("select a.name,a.spec,a.munit,sum(a.number),a.month from FireEquipment a group by a.name")
List<Object[]> findByNameAndMonth();
//删除
@Modifying
@Query("delete from OtherDocumentState where organization.id in (?1)")
int deleteIdIn(Long[] longs);

@Modifying
@Query("delete from OtherDocumentState where document.id=1")
int deleteByOtherDocumentId(Long id);
//简写方式
@QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
User findByUsername(String username);

@QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
User findByEmail(String email);

@QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
User findByUsernameAndIdIsNot(String username, Long id);

@QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
User findByEmailAndIdIsNot(String username, Long id);

 

jpa左连接查询写法实例

@Query(value = "SELECT a.id,a.user_name,a.room_type,a.rent_type,b.name,b.id AS room_id,b.cell,b.floor,b.type,b.sorter  FROM gzf_room b LEFT JOIN gzf_rent_info a ON a.room_id = b.id WHERE b.parent_id = ?1", nativeQuery = true)
@QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
List<Object[]> findByRoomHome(Long id);

关于vue数字的处理(四舍五入、向上取整、向下取整)

1、向下取整的函数
Math.floor();
例如:Math.floor( 23.2222222); // 23

2、向上取整
Math.ceil();
例如: Math.ceil(23.333333); // 24

3、四舍五入
Math.round();
例如:Math.round(23.33333); // 23

4、四舍五入取n位小数,运算后得到的是字符串
().toFixed(n); // 取小数点后n位
例如:(36.36498524).toFixed(3); // 36.365

字符串转数组的几种方法和字符串的截取

一:带[]的字符串如下处理

var str="[2,34,3.4]"; 
var strNew=eval(str); 
console.log(strNew[0]+"--"+strNew[1]+"--"+strNew[2]);
//2--34--3.4

二:正常字符串如下处理

var str2="2,34,3.4";
var str2New=str2.split(",");
console.log(str2New[0]+"++"+str2New[1]+"++"+str2New[2]);
//2++34++3.4

三:带()字符串如下处理

var str="合适dsw(18701200120)";
var strNew =str.replace("(","").replace(")","");
var strNewIphone=strNew.substr(strNew.length-11);
var strNewName=strNew.substring(0,strNew.length-11);
console.log(strNewName+"---"+strNewIphone);
//合适dsw---18701200120