entity

springdataJpa对无主键表或视图查询的支持

大憨熊 提交于 2020-08-08 19:11:04
因为jpa在映射实体是需要一个id,所以我们的实体类必须至少需要一个id字段, 当对无主键表或视图查询时,我们可以定义一个空的@id即可。 示例如下 实体: @Data @Entity @Table(name="Student") public class Student {    @Id // 添加一个空的id标识,因为jpa在映射实体是需要一个id,这个必须    @Column(name = "shool") private Long shool; private String name; private int age; private String address; } 接口:   @Query(value = "select s from Student s where age in (?1) )   public List<Student > findByIdToIn( List<Integer> sysage); 来源: oschina 链接: https://my.oschina.net/u/4405841/blog/4290323

Reface.AppStarter 类型扫描 —— 获得系统中所有的实体类型

女生的网名这么多〃 提交于 2020-08-08 18:19:55
类型扫描 是 Reface.AppStarter 提供的最基本、最核心的功能。 AutoConfig , ComponentScan 等功能都是基于该功能完成的。 每一个使用 Reface.AppStarter 的人都可以订制自己的扫描类型扫描逻辑。 例如 收集系统中所有的 实体 类型,并在系统启动后执行 Code-First 的相关操作。 我们现在就以该示例为需求,开发一个能够 扫描实体 ,并借助第三方框架实现 CodeFirst 的示例程序。 1. 创建程序 创建一个名为 Reface.AppStarter.Demos.ScanEntities 的控制台项目用于承载我们的示例程序。 2. 添加 Reface.AppStarter 的 nuget 依赖 点击访问 Reface.AppStarter @ nuget 可以复制最新版本的 Reface.AppStarter 的命令行到 Package Manager 中。 3. 创建专属的 Attribute 在 Reface.AppStarter 对类型的扫描是通过 Attribute 识别的。 Reface.AppStarter.Attributes.ScannableAttribute 表示该特征允许被 AppSetup 扫描并记录。 因此只要将我们的 Attribute 继承于 ScannableAttribute 就可以被

ElasticSearch搜索引擎在JavaWeb项目中的应用

拜拜、爱过 提交于 2020-08-08 16:28:08
近几篇ElasticSearch系列: 1、 阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2、 Linux系统中ElasticSearch搜索引擎安装配置Head插件 3、 ElasticSearch搜索引擎安装配置中文分词器IK插件 4、 ElasticSearch搜索引擎安装配置拼音插件pinyin 5、 ElasticSearch搜索引擎在JavaWeb项目中的应用 一、前言 前四篇简单介绍了ElasticSearch(以下简称ES)在阿里云服务器Linux系统上的部署配置等。本篇将简述一下ES在JavaWeb项目中的应用。本项目前端框架是Vue.js,前后端数据交互采用是常用的SSM框架,项目管理工具为Maven,ES为6.3.2版本。 二、正文 1、ES在Maven中添加相应依赖,如下所示: 1 < dependency > 2 < groupId > org.elasticsearch </ groupId > 3 < artifactId > elasticsearch </ artifactId > 4 < version > 6.3.2 </ version > 5 </ dependency > 6 < dependency > 7 < groupId > org.elasticsearch.client </ groupId > 8

java后台树形结构展示---懒加载

北慕城南 提交于 2020-08-08 15:45:00
一、数据库设计 二、实体类:entity import com.joyoung.cloud.security.common.validatedGroup.Add; import com.joyoung.cloud.security.common.validatedGroup.Modify; import io.swagger.annotations. ApiModel; import io.swagger.annotations. ApiModelProperty; import lombok. Data; import lombok.experimental. Accessors; import javax.persistence. Id; import javax.persistence. Transient; import javax.validation.constraints. NotBlank; import javax.validation.constraints. NotNull; import javax.validation.constraints. Null; import javax.validation.constraints. Pattern; import java.io.Serializable; import java.util.Date;

springboot jpa 多数据源 的案例

雨燕双飞 提交于 2020-08-08 15:10:46
一、先来个application.properties文件 spring.profiles.active=@package.environment@ spring.mvc.favicon.enable=false #thymelea模板配置 spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix=.html spring.thymeleaf.mode=HTML spring.thymeleaf.encoding=UTF-8 #热部署文件,页面不产生缓存,及时更新 spring.thymeleaf.cache=false spring.resources.chain.strategy.content.enabled=true spring.resources.chain.strategy.content.paths=/** #server.port=8080 #server.session.timeout=28800 server.servlet.session.timeout=3600s #server.servlet.context-path=/shiro #spring.main.allow-bean-definition-overriding=true #spring.datasource

死磕了关于MyBatis10种超好用的写法

无人久伴 提交于 2020-08-08 10:38:54
用来循环容器的标签forEach,查看例子 foreach元素的属性主要有item,index,collection,open,separator,close。 item:集合中元素迭代时的别名 index:集合中元素迭代时的索引 open:常用语where语句中,表示以什么开始,比如以'('开始 separator:表示在每次进行迭代时的分隔符 close 常用语where语句中,表示以什么结束 在使用foreach的时候最关键的也是最容易出错的就是collection属性,该属性是必须指定的,但是在不同情况下,该属性的值是不一样的,主要有一下3种情况: 如果传入的是单参数且参数类型是一个List的时候,collection属性值为list . 如果传入的是单参数且参数类型是一个array数组的时候,collection的属性值为array . 如果传入的参数是多个的时候,我们就需要把它们封装成一个Map了,当然单参数也可以封装成map,实际上如果你在传入参数的时候,在MyBatis里面也是会把它封装成一个Map的,map的key就是参数名,所以这个时候collection属性值就是传入的List或array对象在自己封装的map里面的key. 针对最后一条,我们来看一下官方说法: 注意 你可以将一个 List 实例或者数组作为参数对象传给 MyBatis,当你这么做的时候

论文浅尝 | AAAI2020

做~自己de王妃 提交于 2020-08-08 05:16:28
论文笔记整理:耿玉霞,浙江大学直博生。研究方向:知识图谱,零样本学习等。 来源:AAAI2020 论文链接: https://arxiv.org/pdf/2001.02332.pdf 本文是发表在AAAI2020上的一篇基于生成对抗网络进行知识图谱零样本关系学习的文章。在知识图谱表示学习(KG Embedding)的相关工作中,会出现一些未在训练数据集中出现过的关系(即 zero-shot relations),由于relation及其相关的三元组没有在训练数据集中出现过,则无法获得该relation训练好的向量表示,从而无法进行链接预测等下游任务。在这篇文章中,作者提出利用这些relations的文本描述信息以及生成对抗网络,为这些zero-shot relations学习到有语义意义的向量表示,从而避免KG中存在新出现的关系时,表示学习模型需要重新训练的问题。 1. 相关背景 1.1 基于生成对抗网络的零样本学习 零样本学习,即处理那些未在训练集中出现过的类别的分类问题。在训练集中出现过的类别(即seen classes),有训练数据,此类classes经训练具备一定分类该类测试样本的能力;而未在训练集中出现过的类别(即unseen classes),无训练数据,此类classes测试样本的分类/预测依赖与seen classes建立一定的语义联系(如文本描述、属性描述等)

Kotlin+Vue+Spring Data JPA+MySQL 增查改删

半腔热情 提交于 2020-08-08 00:52:49
概述: Kotlin为后端开发语言,持久层是Spring Data JPA 前后端分离,进行简单增查改删(CRUD) 前端使用VUE 数据库使用MySQL 往期内容 # 内容 01 React+Spring Boot JPA+MySQL 增查改删 02 Vue+Spring Boot JPA+MySQL 增查改删 增查改删 03 Vue+Spring Boot 文件操作,上传、预览和删除 04 Thymeleaf+Spring Boot 文件操作,上传、预览和删除 Vue前端代码,不再重复。以下是Kotlin后台代码 #EmployeeController.kt package com.example.kotlinjpacrud.controller import com.example.kotlinjpacrud.entity.Employee import com.example.kotlinjpacrud.repositories.EmployeeRepository import org.springframework. data .domain.Page import org.springframework. data .domain.Pageable import org.springframework. data .domain.Sort import org

Spring8——Bean的生命周期、自动装配

谁说我不能喝 提交于 2020-08-07 21:43:46
Bean的生命周期 创建、初始化(赋初值)、使用、销毁。 方法一:@Bean+返回值方式 init destory <bean id="student" class="org.ghl.entity.Student" scope="singleton" init-method="myInit" destroy-method="myDestory"> <property name="stuNo" value="4"></property> <property name="stuName" value="df"></property> <property name="stuAge" value="34"></property> </bean> 注解方式: @Bean(value = "stu",initMethod = "myInit",destroyMethod = "myDestory") 总结:IOC容器在初始化时,会自动创建对象(即生成构造方法),再初始化init,当容器关闭时调用destory。   方法二: 三层注解(包括功能性注解,eg:转换器,使用@Component):@Controller,@Service,@Dao,@ Component; 三层组件:扫描器+三层注解; JAVA规范:JSR250。 @PostConstruct:相当于init

spring cache 查出来的数据转换报错 (java.util.LinkedHashMap cannot be cast to xxx)

百般思念 提交于 2020-08-07 21:15:39
在service层能正常查询出来 service 方法: @Cacheable(value="org", key="#code", condition="#code != null") public List<OrgEntity> findOrgByCode(String code) { List<OrgEntity> orgList = orgDao.findByCode(code); } controller方法: @Mapping("/findOrg") public void findOrg(Org org) { // 这一步都正常,能拿出来放到listOrg List<OrgEntity> listOrg = orgService.findByCode(org.getCode); // 这一步就报错了,java.util.LinkedHashMap cannot be cast to com.zhoulp.entity.OrgEntity for(OrgEntity orgEntity : listOrg) { orgEntity.getName(); } } 解决方法,调整controller方法,先序列化成jsonString,再转化成bean(应该不是最好方案,最好方案是查出来,直接能用) controller方法: @Mapping("/findOrg")