Commit ca66883c authored by Matija Obreza's avatar Matija Obreza

Use database-generated primary key

Liquibase:
    - addAutoIncrement:
        columnName:      id
        tableName:       repository_file
        columnDataType:  bigint
parent e0b5fc69
Pipeline #13744 passed with stage
in 3 minutes and 7 seconds
......@@ -24,9 +24,6 @@ import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
......@@ -40,9 +37,8 @@ import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.model.AuditedVersionedModelWithoutId;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.model.Copyable;
import org.genesys.blocks.model.InMemoryIdGenerator;
import org.genesys.blocks.model.SelfCleaning;
import org.genesys.blocks.security.model.AclAwareModel;
import org.genesys.filerepository.metadata.BaseMetadata;
......@@ -67,19 +63,13 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
// unique
, uniqueConstraints = { @UniqueConstraint(columnNames = { "folder_id", "originalFilename" }) })
@Inheritance(strategy = InheritanceType.JOINED)
public class RepositoryFile extends AuditedVersionedModelWithoutId implements AclAwareModel, BaseMetadata, Copyable<RepositoryFile>, SelfCleaning {
public class RepositoryFile extends AuditedVersionedModel implements AclAwareModel, BaseMetadata, Copyable<RepositoryFile>, SelfCleaning {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -4816923593950502695L;
public static final Sort DEFAULT_SORT = Sort.by("originalFilename");
/** The id. */
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(unique = true, nullable = false, length = 20)
private Long id = InMemoryIdGenerator.nextId();
/** The uuid. */
@Column(unique = true, nullable = false, updatable = false)
@Type(type = "uuid-binary")
......@@ -291,24 +281,6 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements Ac
return Paths.get(getStorageFolder());
}
/*
* (non-Javadoc)
* @see org.genesys.blocks.model.EntityId#getId()
*/
@Override
public Long getId() {
return id;
}
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(final Long id) {
this.id = id;
}
/**
* Gets the uuid.
*
......@@ -769,37 +741,4 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements Ac
return copy;
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = (prime * result) + ((id == null) ? 0 : id.hashCode());
return result;
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
final RepositoryFile other = (RepositoryFile) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment