Commit a6108dec authored by Matija Obreza's avatar Matija Obreza
Browse files

Using Hibernate's @Type uuid-binary for UUID

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