当前位置:网站首页>常用技术注解
常用技术注解
2022-06-22 18:00:00 【阿国GG在学习】
一、JPA实体注解
- @Entity - 这是一个标记注释,表明这个类是一个实体,这个注释必须放在类名称上。
- @Table - 当实体类与其映射的数据库表名不同时需要使用@Table,该标注常用的属性是 name,用于指明数据库的表名。
- @Id - 位于持有持久标识属性地特定字段上。该字段被视为数据库中地主键。
- @Column - 用来标识实体类中属性与数据表中字段的对应关系
- @GeneratedValue - 为实体类生成一个唯一标识的主键,提供了主键的生成策略。

其中包含:
- strategy:主键生成策略
- generator:主键生成器
二、Jackson
简介
Jackson 是当前用的比较广泛的,用来序列化和反序列化 json 的 Java 的开源框架。
Jackson 社区相对比较活跃,更新速度也比较快, 从 Github 中的统计来看,Jackson 是最流行的 json 解析器之一 。
Spring MVC 的默认 json 解析器便是 Jackson。 Jackson 优点很多。
Jackson 所依赖的 jar 包较少 ,简单易用。
与其他 Java 的 json 的框架 Gson 等相比, Jackson 解析大的 json 文件速度比较快;Jackson 运行时占用内存比较低,性能比较好;
Jackson 有灵活的 API,可以很容易进行扩展和定制。
常用注解
- @JsonFormat - 从数据库获取数据到前段进行展示时,使用该注解
- @DataTimeFormat - 前台传递数据到后台时,使用该注解
- @JsonInclude - 指定实体类在序列化时的策略
常用的属性值:
- JsonJsonInclude.Include.ALWAYS :这个是默认策略,任何情况下都序列化该字段,和不写这个注解是一样的效果。
- JsonJsonInclude.Include.NON_NULL:这个最常用,即如果加该注解的字段为null,那么就不序列化这个字段了。
- JsonJsonInclude.Include.NON_ABSENT:java中有些复杂的数据结构,比如AtomicReference或是Optional,如果某个属性是这个类型,虽然此属性不为null,但是其包装的内容是null的,此注解的作用是,只有此属性不为null,且其包装的内容是有值的才会被序列化
- JsonJsonInclude.Include.NON_EMPTY:这个属性包含NON_NULL,NON_ABSENT之后还包含如果字段为空也不序列化。这个也比较常用
- JsonJsonInclude.Include.NON_DEFAULT:这个也好理解,如果字段是默认值的话就不序列化。
三、Mybatis
- @Param - 基础类型有参数必须要添加@Param注解(只有一个可以忽略不加但是建议加上),其中 value 属性值与配置文件参数要一致。
边栏推荐
- Detailed explanation of session mechanism and related applications of session
- Vs Code suddenly fails to jump
- std::enable_ shared_ from_ This error: error: expected template name before '<' token
- Typescript (7) generic
- 数商云:解析B2B2C多用户商城系统架构设计思路,开启智能商城新时代
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- 函数的导数与微分的关系
- Thread pool: reading the source code of threadpoolexcutor
- 5G 短消息解决方案
- wpa_ State machine migration of supplicant
猜你喜欢

Interview MySQL

3GPP 5G R17标准冻结,RedCap作为重要特性值得关注!

数字赋能机械制造业,供应链协同管理系统解决方案助力企业供应链再升级

Play typical usage scenarios of kubernetes | dashboard for 5 minutes every day

Flutter series - build a flutter development environment

新人报道的笔记

Exness sorted out three problems to be solved in Musk's acquisition of Twitter

Problems of different renderers running on the web with flutter2.0

C#,入门教程——关于函数参数ref的一点知识与源程序

2022 t elevator repair recurrent training question bank and answers
随机推荐
shell脚本详解(二)——条件测试、if语句和case分支语句
shell脚本详解(四)——循环语句之while循环和until循环(附加例题及解析)
PLSQL variable assignment
机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效
STM32 control matrix key, Hal library, cubemx configuration
shell脚本(五)——函数
Flutter系列-搭建Flutter开发环境
消息中间件(一)MQ详解及四大MQ比较
3GPP 5g R17 standard is frozen, and redcap as an important feature deserves attention!
How MySQL deletes a column in a database table
助力客户数字化转型,构建全新的运维体系
泡泡玛特:空洞的灵魂需要故事
Active directory user logon Report
Shell script explanation (IV) -- while loop and until loop of loop statements (additional examples and analysis)
Shell script (V) -- function
Dynamically changing the style of label elements in a loop
2022 R2 mobile pressure vessel filling test question simulation test platform operation
Play typical usage scenarios of kubernetes | dashboard for 5 minutes every day
如何更改Apple Watch上的表盘
Shell script explanation (II) -- conditional test, if statement and case branch statement