Skip to content

Commit

Permalink
fix: use varbinary instead of lob to avoid orhpaned oids in postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-s committed Dec 17, 2024
1 parent 4d05f9d commit ced0154
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.MappedSuperclass;
import java.sql.Types;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.JdbcTypeCode;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
Expand Down Expand Up @@ -56,7 +57,7 @@ public abstract class AbstractEntity implements BaseEntity {
@Column(name = "updated_by")
protected String updatedBy;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] metadata;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import java.sql.Types;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.JdbcTypeCode;

@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -31,11 +32,11 @@ public class ArtifactEntity extends AbstractEntity implements SpecEntity, Status

private Boolean embedded;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] spec;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import java.sql.Types;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.JdbcTypeCode;

@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -31,11 +32,11 @@ public class DataItemEntity extends AbstractEntity implements SpecEntity, Status

private Boolean embedded;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] spec;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Index;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import java.io.Serializable;
import java.sql.Types;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.JdbcTypeCode;

@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -37,7 +38,7 @@ public class FilesInfoEntity implements Serializable {
@Column(nullable = false)
private String entityId;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
private byte[] files;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import java.sql.Types;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.JdbcTypeCode;

@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -31,11 +32,11 @@ public class FunctionEntity extends AbstractEntity implements SpecEntity, Status

private Boolean embedded;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] spec;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
import it.smartcommunitylabdhub.core.models.base.StatusEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import java.sql.Types;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.JdbcTypeCode;

@AllArgsConstructor
@NoArgsConstructor
Expand All @@ -26,15 +27,15 @@ public class LogEntity extends AbstractEntity implements SpecEntity, StatusEntit
@Column(nullable = false)
private String run;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
private byte[] content;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] spec;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import java.sql.Types;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.JdbcTypeCode;

@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -31,11 +32,11 @@ public class ModelEntity extends AbstractEntity implements SpecEntity, StatusEnt

private Boolean embedded;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] spec;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.PrePersist;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import java.sql.Types;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.JdbcTypeCode;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
Expand Down Expand Up @@ -52,15 +53,15 @@ public class ProjectEntity implements BaseEntity, SpecEntity, StatusEntity {

private String source;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
private byte[] metadata;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
private byte[] spec;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
private byte[] status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import java.sql.Types;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.JdbcTypeCode;

@AllArgsConstructor
@NoArgsConstructor
Expand All @@ -30,11 +31,11 @@ public class RunEntity extends AbstractEntity implements SpecEntity, StatusEntit
@Column(nullable = false)
private String task;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] spec;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import java.sql.Types;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.JdbcTypeCode;

@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -32,11 +33,11 @@ public class SecretEntity extends AbstractEntity implements SpecEntity, StatusEn

private Boolean embedded;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] spec;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
import it.smartcommunitylabdhub.core.models.base.SpecEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.constraints.NotNull;
import java.sql.Types;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.JdbcTypeCode;

@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -36,7 +37,7 @@ public class TaskEntity extends AbstractEntity implements SpecEntity {
@Column(nullable = true)
private String workflow;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] spec;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import java.sql.Types;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.JdbcTypeCode;

@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -29,11 +30,11 @@ public class WorkflowEntity extends AbstractEntity {

private Boolean embedded;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] spec;

@Lob
@JdbcTypeCode(Types.LONGVARBINARY)
@ToString.Exclude
protected byte[] status;

Expand Down
Loading

0 comments on commit ced0154

Please sign in to comment.