记录一个实体类加注释 给字段加密解密的方法

记录一个实体类加注释 给字段加密解密的方法,第1张

记录一个实体类加注释 给字段加密解密的方法

hibernate的方法
实体类
package cn.com.doone.sc.tx.cloud.ap.core.auth.common.entity;

import cn.com.doone.sc.tx.cloud.ap.dependencies.uid.intf.UidGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnTransformer;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

@Getter
@Setter
@Entity
@Table(name = “tf_ap_account”)
public class AccountEntity extends baseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = “uid-id”)
@GenericGenerator(name = “uid-id”, strategy = UidGenerator.JPA_ID)
private Long accountId;

@Column(name = "user_id", columnDefinition = "bigint(20) comment '用户表(tf_ap_user)主键'")
private Long userId;

@Basic
@Column(name = "account_num",nullable=false ,length=64)
@ColumnTransformer(
        read = "AES_DECRYPT(UNHEx(account_num),'scyd')",
        write = "HEx(AES_ENCRYPT(?, 'scyd'))"
)
private String accountNum;

@Column(name = "phone", columnDefinition = "varchar(20) comment '手机号码'")
@ColumnTransformer(
        read = "AES_DECRYPT(UNHEx(phone),'scyd')",
        write = "HEx(AES_ENCRYPT(?, 'scyd'))"
)
private String phone;

@Column(length = 100)
private String password;


@Column(length = 20)
private String accountType;

@Column(name = "bossjob_Num",nullable=false ,length=64)
private String bossJobNum;

@Column(name = "hall_no",nullable=false ,length=64)
private String hallNo;

@Column(name = "nick_name",length=64)
@ColumnTransformer(
        read = "AES_DECRYPT(UNHEx(nick_name),'scyd')",
        write = "HEx(AES_ENCRYPT(?, 'scyd'))"
)
private String nickName;

}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5609429.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存