Commit a6108dec authored by Matija Obreza's avatar Matija Obreza

Using Hibernate's @Type uuid-binary for UUID

parent 1e35ebdd
......@@ -11,16 +11,15 @@ import javax.persistence.PrePersist;
import javax.persistence.Table;
import org.genesys.blocks.model.BasicModel;
import org.hibernate.annotations.Type;
@Entity
@Table(name = "ds2")
public class DS extends BasicModel {
/**
*
*/
private static final long serialVersionUID = -8152480522578736947L;
@Column(columnDefinition = "binary(16)", unique = true, nullable=false, updatable = false)
@Column(unique = true, nullable = false, updatable = false)
@Type(type = "uuid-binary")
private UUID uuid;
@OrderBy("index")
......
......@@ -36,9 +36,11 @@ import javax.persistence.Table;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.model.IdUUID;
import org.genesys2.server.model.impl.AccessionList;
import org.hibernate.annotations.Type;
/**
* Entity holds the assigned accession identifiers regardless of active or historic records.
* Entity holds the assigned accession identifiers regardless of active or
* historic records.
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
......@@ -50,7 +52,8 @@ public class AccessionId extends AuditedVersionedModel implements IdUUID {
*/
private static final long serialVersionUID = -6224417080504343264L;
@Column(columnDefinition = "binary(16)")
@Column(updatable = false)
@Type(type = "uuid-binary")
protected UUID uuid;
@OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = "accession", orphanRemoval = false)
......
/**
* Copyright 2015 Global Crop Diversity Trust
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......@@ -31,6 +31,7 @@ import javax.persistence.Table;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.security.model.AclAwareModel;
import org.genesys2.server.model.genesys.AccessionId;
import org.hibernate.annotations.Type;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldIndex;
import org.springframework.data.elasticsearch.annotations.FieldType;
......@@ -41,11 +42,12 @@ public class AccessionList extends AuditedVersionedModel implements AclAwareMode
private static final long serialVersionUID = 991886970995006680L;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
@Column(name = "uuid", unique = true, nullable = false, updatable = false, columnDefinition = "binary(16)")
@Column(name = "uuid", unique = true, nullable = false, updatable = false)
@Type(type = "uuid-binary")
protected UUID uuid;
@ManyToMany(cascade = {}, fetch = FetchType.LAZY)
@JoinTable(name = "accelistitems", joinColumns = @JoinColumn(name = "listid") , inverseJoinColumns = @JoinColumn(name = "acceid") )
@JoinTable(name = "accelistitems", joinColumns = @JoinColumn(name = "listid"), inverseJoinColumns = @JoinColumn(name = "acceid"))
private Set<AccessionId> accessionIds;
@Column(name = "title", nullable = false)
......@@ -61,7 +63,7 @@ public class AccessionList extends AuditedVersionedModel implements AclAwareMode
return uuid;
}
protected void setUuid(UUID uuid) {
protected void setUuid(final UUID uuid) {
this.uuid = uuid;
}
......@@ -79,7 +81,7 @@ public class AccessionList extends AuditedVersionedModel implements AclAwareMode
return accessionIds;
}
protected void setAccessionIds(Set<AccessionId> accessionIds) {
protected void setAccessionIds(final Set<AccessionId> accessionIds) {
this.accessionIds = accessionIds;
}
......@@ -91,22 +93,22 @@ public class AccessionList extends AuditedVersionedModel implements AclAwareMode
return title;
}
public void setDescription(String description) {
public void setDescription(final String description) {
this.description = description;
}
public void setTitle(String title) {
public void setTitle(final String title) {
this.title = title;
}
public void setShared(boolean shared) {
public void setShared(final boolean shared) {
this.shared = shared;
}
public boolean isShared() {
return shared;
}
public boolean getShared() {
return shared;
}
......
......@@ -38,7 +38,8 @@ import org.hibernate.annotations.Type;
public class Descriptor extends BasicModel {
private static final long serialVersionUID = 3832200593904442940L;
@Column(columnDefinition = "binary(16)", unique = true, nullable=false, updatable = false)
@Column(unique = true, nullable=false, updatable = false)
@Type(type = "uuid-binary")
private UUID uuid;
@Lob
......
......@@ -18,6 +18,7 @@ package org.genesys2.server.model.impl;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.security.model.AclAwareModel;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.List;
......@@ -39,6 +40,7 @@ public class Project extends AuditedVersionedModel implements AclAwareModel {
private String code;
@Column(name = "uuid", nullable = false)
@Type(type = "uuid-binary")
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "project_accelist", joinColumns = @JoinColumn(name = "projectId", referencedColumnName = "id"))
private List<UUID> accessionLists;
......
......@@ -31,7 +31,7 @@ db.username = sa
db.password =
db.showSql=false
db.hbm2ddl=true
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.dialect=org.genesys.blocks.util.BetterHSQLDialect
# reCAPTCHA API
captcha.privateKey=A
......
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