Migration problem

#1

Will this code work on objectdb ?

I was using it on mariadb , i need to inject GenericEntity to many tables to watch user activities.

If this wont work , does objectdb has any other solution to this ?

do i need to use jakarta objectdb or standard ?

package com.manage.jpa;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

@Getter
@Setter
@EntityListeners({AuditingEntityListener.class,GenericEntityListener.class})
@MappedSuperclass
public abstract class GenericEntity extends BaseEntity {

    @LastModifiedDate
    @Column(columnDefinition = "timestamp default '2020-04-10 20:47:05.967394'")
    protected LocalDateTime lastModifiedDate;

    @CreatedDate
    @Column(columnDefinition = "timestamp default '2020-04-10 20:47:05.967394'", updatable = false)
    protected LocalDateTime createdDate;


    @CreatedBy
    @Column( updatable = false)
    protected Integer createSicil;

    @LastModifiedBy
    protected Integer modifierSicil;

    //TODO: Implement Conditional Indexing
    @NotNull
    //https://gauthier-cassany.com/posts/spring-boot-hibernate-search-conditional-indexing
    @Basic(fetch = FetchType.EAGER)
    @Column(name = "isEnabled", unique = false, nullable = false)
//    @Column(columnDefinition="tinyint(1) default 1")
//    @Column(columnDefinition="BOOLEAN DEFAULT true")
    @ColumnDefault(value = "true")
    protected boolean enabled;

}

 

 

 

package com.manage.jpa;

import org.springframework.beans.factory.aspectj.ConfigurableObject;

import javax.persistence.PostPersist;
import javax.persistence.PostUpdate;
import javax.persistence.PrePersist;

public class GenericEntityListener implements ConfigurableObject {


    @PostPersist
    public void onPostPersist(GenericEntity entity) {
        System.out.println(entity);
    }

    @PostUpdate
    public void onPostUpdate(GenericEntity entity) {

    }

    @PrePersist
    public void onPrePersist(GenericEntity entity) {

    }
}

 

 

#2

Basically it should work, although ObjectDB ignores most mapping annotations.

ObjectDB supports callbacks and listeners. Is there anything specific in this code that you want to check?

ObjectDB Support
#3

so

@LastModifiedDate
@CreatedDate
@CreatedBy
@LastModifiedBy

 

These annotations work on objectdb ?

 

#4

These are not ObjectDB or JPA annotations, but Spring Framework annotations. You will have to check with Spring Framework, which defines them, when they work and when they do not work.

ObjectDB Support

Reply