Tags » Hibernate

Hibernate Auditing - Base Entity and Example Entity

Add Hibernate envers dependency to your pom.xml file :

<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-envers</artifactId>
   <version>${hibernate.version}</version>
</dependency>

This is base entity class for enabling auditing :

@MappedSuperclass
@Audited
@Data
public class BaseEntity implements Serializable{

    private static final long serialVersionUID = -1591130256151148932L;

    @CreatedBy
    @Column(nullable = false,length = 50,updatable = false)
    private String createdBy;

    @CreatedDate
    @Column(nullable = false)
    private Instant createdDate = Instant.now();

    @LastModifiedBy
    @Column(length = 50)
    private String updatedBy;

    @LastModifiedDate
    private Instant updatedDate = Instant.now();
} 114 more words
Audit

Hibernate exception: duplicate association path

Hibernate doesn’t provide function to check existing alias. If you try to add the same alias to the criteria, you will get exception: duplicate association path. 46 more words

JPA

How to map a @ManyToOne association using a non-Primary Key column with JPA and Hibernate

Follow @vlad_mihalcea

Introduction

While answering questions on the Hibernate forum, I stumbled on the following question about using the @ManyToOne annotation when the Foreign Key column on the client side references a non-Primary Key column on the parent side. 615 more words

Hibernate

How to store schema-less EAV (Entity-Attribute-Value) data using JSON and Hibernate

Follow @vlad_mihalcea

Introduction

One of my Twitter followers has recently asked me about a way of storing EAV (Entity-Attribute-Value) data using JPA and Hibernate, and, because this is a very good question, I decided to turn answer it using a blog post. 954 more words

Hibernate

Hibernate Proxies And Lazy Loading

NOTE: If you don’t know basics of hibernate, please read my another blog Here.


Introduction: Database access is very costly for an application in the terms of performance. 658 more words

Hibernate