Jpa的@Id和@GeneratedValue的使用

Jpa的@Id和@GeneratedValue的使用

import lombok.Data;
import javax.persistence.*;
import java.math.BigInteger;@Entity//将实体类首字母小写
@Table(name = "user")//要连接的数据库表名
@Data
public class UserCopy {@Id@GeneratedValue(strategy= GenerationType.IDENTITY)//    @GeneratedValue 用于标注主键的生成策略,通过strategy 属性指定。默认情况下,JPA 自动选择一个最适合底层数据库的主键生成策略:SqlServer对应identity
//    IDENTITY:采用数据库ID自增长的方式来自增主键字段,Oracle 不支持这种方式;private Integer id;private String userId;private String password;private String userName;private String userType;private BigInteger createTime;private BigInteger updateTime;}

SpringDataJPA之Repository接口


import com.hebutgo.refund.sampleUser.dto.UserListDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;import javax.transaction.Transactional;
import java.util.List;public interface UserCopyRepository extends JpaRepository<UserCopy,Integer> {//<表名,id(主键)属性类型是Integer>@Transactionalvoid deleteByUserId(String userId);UserCopy findByUserId(String userId);UserCopy findByUserIdAndPassword(String userId, String password);UserCopy findByUserName(String userName);//    @Transactional
//    @Modifying
//    @Query(value = "update users set user_name=:userName where user_id=:userId ", nativeQuery = true)
//    void updateNameByUserIdNative(String userId, String userName);
//
//    List<User> findByUserIdIn(List<String> userIds);
//
//    User findByToken(String token);
//
//    @Query(value = "select new com.hebutgo.refund.sampleUser.dto.UserListDTO(t1.id, t1.userId, t1.userName, t1.userType, t1.gender, t1.mobile, t1.community, t1.doorNum, t1.birthday,t1.serviceHours,t1.token) from User t1 where t1.userId = :userId and t1.password = :password")
//    List<UserListDTO> login(@Param(value = "userId")String userId, @Param(value = "password") String password);}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/545240.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

基于Python的应用程序的虚拟环境

什么是虚拟环境&#xff1f; (What is Virtual Environment?) Virtual environments are very useful when the application requires a separate environment, each using its version of python and libraries for execution. Similar to virtual environment, there are pa…

隐式转换

2019独角兽企业重金招聘Python工程师标准>>> 1&#xff1a;隐式转换应用 1.1 隐式转换为期望类型 隐式转换为期望类型是编译器会使用隐式操作的第一个地方。一旦编译器看到了X&#xff0c;但是需要Y&#xff0c;就会检查从X到Y的隐式转换函数。例如&#xff1a; val…

双“11”搞促销?用贪心算法来盘他!

作者 | 王磊来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;这几年商家为了刺激消费是变着花样的推出各种各样的活动&#xff0c;以某多多为首的运营式电商更是让我们看到了营销的无限“…

java保留两位小数4种方法

转自&#xff1a; http://blog.csdn.net/ming1683/article/details/31950584种方法&#xff0c;都是四舍五入&#xff0c;例&#xff1a;import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; public class format {double f 111231…

AndroidStudio使用入门

AndroidStudio使用入门1_AndroidStudio activity的基本使用1.1_MainActivity和activity_main的初识1.2_Activity的清单文件简介1.3_几种重要文件的介绍1.4_基本布局的认识与使用1.4.1_RelativeLayout(相对布局)1.4.2_线性布局2_访问资源的方式2.1_java访问资源的方式2.2_xml访问…

java计算时间差距_硬计算和软计算之间的差异

java计算时间差距什么是计算&#xff1f; (What is Computing?) The process of accomplishing a particular task with the help of a computer or a computing device is known as computing. It should provide precise and accurate solutions, also it makes easy to fin…

主键字母自动生成函数

-- 动态生成字母方式主键&#xff0c;A-Z 大于Z自动进位【26进制数值表示】-- 参数&#xff1a;动态查询表和主键列 create or replace function charkey (tabName char, pkName char) return char asv_key varchar2(4); -- 表中查询出当前主键列最大值v_char varchar2(…

26.颜色值缩写

关于颜色的css样式也是可以缩写的&#xff0c;当你设置的颜色是16进制的色彩值时&#xff0c;如果每两位的值相同&#xff0c;可以缩写一半。 例子1&#xff1a; p{color:#000000;} 可以缩写为&#xff1a; p{color: #000;} 例子2&#xff1a; p{color: #336699;} 可以缩写为&a…

面试官:你说说互斥锁、自旋锁、读写锁、悲观锁、乐观锁的应用场景?

前言生活中用到的锁&#xff0c;用途都比较简单粗暴&#xff0c;上锁基本是为了防止外人进来、电动车被偷等等。但生活中也不是没有 BUG 的&#xff0c;比如加锁的电动车在「广西 - 窃格瓦拉」面前&#xff0c;锁就是形同虚设&#xff0c;只要他愿意&#xff0c;他就可以轻轻松…

计算机操作系统原理教程与实训(目录)

计算机操作系统原理教程与实训 第一章 计算机操作系统概论 1.1 操作系统的形成与发展 1.1.1 人工操作方式 1.1.2 脱机输入/输出技术 1.1.3 批处理技术 1.1.4 多道程序设计技术 1.2 操作系统的基本概念 1.2.1 操作系统的定义 1.2.2 操作系统的地位 1.2.3 操作系统的特征 1.2…

2万字,看完这篇才敢说自己真的懂线程池!

前言 线程池可以说是 Java 进阶必备的知识点了&#xff0c;也是面试中必备的考点&#xff0c;可能不少人看了一些文章后能对线程池工作原理说上一二&#xff0c;但这还远远不够&#xff0c;如果碰到比较有经验的面试官再继续追问&#xff0c;很可能会被吊打&#xff0c;考虑如下…

西南大学校园GIS平台

原文:西南大学校园GIS平台系统架构是B/S,开发语言是C#、silverlight&#xff0c;开发平台是.NET&#xff0c;数据库为sqlserver&#xff0c;这是我读研究生时候自己做的作品&#xff0c;以自己的母校为地图&#xff0c;进行GIS相关的功能分析&#xff0c;核心的模块有&#xff…

Android studio小问题解决

1_代码识别不出来问题 2_项目SDK与本地不匹配 先查看项目的SDK 增加本地SDK

使用类的银行管理系统的C ++程序

In this program, we are using the concept of C class and object, following basic operations are being performed here, 在此程序中&#xff0c;我们使用C 类和对象的概念&#xff0c;在此执行以下基本操作&#xff0c; Opening an account 开户 Show account info 显示…

2万字长文包教包会 JVM 内存结构

点击蓝色“Java中文社群”关注我哟加个“星标”&#xff0c;一起成长&#xff0c;做牛逼闪闪的技术人JVM ≠ Japanese Videos Man写这篇的主要原因呢&#xff0c;就是为了能在简历上写个“熟悉JVM底层结构”&#xff0c;另一个原因就是能让读我文章的大家也写上这句话&#xf…

vb.net 读写文件

读取和写入文件 以下示例将一行文本写入文件。 Write text to a file Sub WriteTextToFile() Dim file As New System.IO.StreamWriter("c:test.txt") file.WriteLine("Here is the first line.") file.Close() End Sub 以下示例将文件中的文本读取到…

Oracle 10g、11g :RAC关闭、启动、重启步骤

关闭顺序&#xff1a;【其他节点】-> [第一个节点]操作&#xff1a;step 1&#xff1a;{以grid用户或关闭监听&#xff1a; { crs_stop 监听器资源名 | srvctl stop listener } --全局|oracle用户关闭监听&#xff1a;{ lsnrctl stop } --单个节点}step 2&#xff1a;以orac…

虹软安卓人脸识别初学

1_下载SDK 进入虹软官网&#xff1a; 点击人脸识别SDK 进入开发者中心&#xff08;注册登录&#xff09; 新建应用并添加SDK 输入相应信息&#xff0c;确认 下载sdk 2_run示例代码注意事项 跑不起来的解决方法&#xff08;SDK版本不一致&#xff09; 3_激活并使用

css圆在中心根据宽度缩放_根据CSS中的容器宽度重新缩放字体

css圆在中心根据宽度缩放Introduction: 介绍&#xff1a; Dealing with fonts is a very interesting thing to do as fonts bring out the appearance of your website or a web page so you must choose the ideal fonts for your website or web page that helps in making…

vb.net 的 openFileDialog 控件文件筛选器使用

Filter 属性设置当前文件名筛选字符串&#xff0c;该字符串确定出现在对话框的“文件类型”框中的选项。 openFileDialog1.InitialDirectory "c:\\" ; openFileDialog1.Filter "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; openFileDialog1.Filter…