@MappedSuperclass
@EntityListeners( { PersistenceObjectListener.class })
public abstract class AbstractPersistenceObject implements PersistenceObject {
private Timestamp version;
private String createdBy;
private String updatedBy;
@Column(name = "CREATED_BY", length = 20, nullable = true)
public String getCreatedBy() {
return createdBy;
}
}
public class PersistenceObjectListener {
private static final Log logger = LogFactory.getLog(PersistenceObjectListener.class);
@PrePersist
@PreUpdate
public void setUser(AbstractPersistenceObject abstractPersistenceObject) {
Map<?, ?> curSessionMap = (Map<?, ?>) ThreadLocalManager.getValue();
if (curSessionMap == null || curSessionMap.size() == 0) {
logger.debug("The current session map is null");
return;
}
Object loginName = curSessionMap.get(Constant.RETURN_MAP_LOGIN_NAME_KEY);
if (loginName != null && !"".equals(loginName)) {
String createdBy = abstractPersistenceObject.getCreatedBy();
if (createdBy == null || "".equals(createdBy)) {
abstractPersistenceObject.setCreatedBy(String.valueOf(loginName));
}
abstractPersistenceObject.setUpdatedBy(String.valueOf(loginName));
}
}
}
分享到:
相关推荐
仓库管理系统,SpringBoot+Spring Data JPA.zip仓库管理系统,SpringBoot+Spring Data JPA.zip仓库管理系统,SpringBoot+Spring Data JPA.zip仓库管理系统,SpringBoot+Spring Data JPA.zip仓库管理系统,SpringBoot...
hibernate-jpa.jar
spring-jpa.jar........................................
Apress.Pro.JPA.2.2nd.Edition.Oct.2013
01_JPA详解_全面阐释和精彩总结JPA.zip 01_JPA详解_全面阐释和精彩总结JPA.zip
hibernate jpa 用到的所有jar
这个文件在网上并不多见,我自己也是费了好大劲找到的,在eclipse中配置jpa必不可少的xsd文件
springBoot+springjpa简单教程,Thymeleaf Thymeleaf 是面向 Web 和独立环境的现代服务器端 Java 模板引擎,能够处理 HTML、XML、JavaScript、 CSS 甚⾄纯文本。 Thymeleaf 旨在提供⼀个优雅的、高度可维护的创建...
jar包,官方版本,自测可用
NULL 博文链接:https://abstractforever.iteye.com/blog/642219
Apress.Pro.JPA.2.in.Java.EE.8.An.In-Depth.Guide.to.Java.Persistence.APIs.3rd.Edition.
个人博客系统(SpringBoot+jpa).zip个人博客系统(SpringBoot+jpa).zip个人博客系统(SpringBoot+jpa).zip个人博客系统(SpringBoot+jpa).zip个人博客系统(SpringBoot+jpa).zip个人博客系统(SpringBoot+jpa)...
Apache OpenJPA.zip
springboot-jpa.zip
org.hibernate.jpa.QueryHints jar hibernate-entitymanager-4.3.0.Final.jar
Spring Data JPA系列2:SpringBoot集成JPA详细教程,快速在项目中熟练使用JPA.doc
使用Spring Boot 2.1.6轻松实现JPA操作MySQL数据库的CRUD,以及分页和排序功能。在Spring Boot 2.x版本中可以非常轻松、快速搞定持久层的开发动作,配置比SpringBoot+MyBatis还少,偶觉得它除了执行效果不如...
JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解.doc JPA注解....
This document provides an overview of the JPA standard and technical details on the use of OpenJPA.The OpenJPA Reference Guide contains detailed documentation on all aspects of OpenJPA. Browse ...
java运行依赖jar包