Skip to content

Commit

Permalink
Merge pull request #1464 from DependencyTrack/revert-1452-issue-1417-…
Browse files Browse the repository at this point in the history
…replace-uuid-columns-with-native-type

Revert "Use native `UUID` type for UUID colums"
  • Loading branch information
nscuro committed Aug 23, 2024
2 parents 3b632c1 + 337c232 commit 930e2d2
Show file tree
Hide file tree
Showing 11 changed files with 1,549 additions and 2,520 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* This file is part of Dependency-Track.
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) OWASP Foundation. All Rights Reserved.
*/
package org.dependencytrack.persistence.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

import java.util.UUID;

import static java.util.Optional.ofNullable;

@Converter(autoApply = true)
public class UUIDConverter implements AttributeConverter<UUID, String> {

@Override
public String convertToDatabaseColumn(final UUID entityValue) {
return ofNullable(entityValue)
.map(UUID::toString)
.orElse(null);
}

@Override
public UUID convertToEntityAttribute(final String databaseValue) {
return ofNullable(databaseValue)
.map(UUID::fromString)
.orElse(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.annotations.JdbcType;
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;

import java.util.UUID;

Expand Down Expand Up @@ -90,7 +88,6 @@ public class Component extends PanacheEntityBase {
private Project project;

@Column(name = "UUID")
@JdbcType(UUIDJdbcType.class)
private UUID uuid;

@Column(name = "MD5", columnDefinition = "VARCHAR")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.annotations.JdbcType;
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;

import java.util.UUID;

Expand Down Expand Up @@ -57,7 +55,6 @@ public class NotificationPublisher extends PanacheEntityBase {
private boolean defaultPublisher;

@Column(name = "UUID")
@JdbcType(UUIDJdbcType.class)
private UUID uuid;

public long getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import jakarta.persistence.Table;
import org.dependencytrack.persistence.converter.NotificationLevelConverter;
import org.dependencytrack.persistence.converter.NotificationScopeConverter;
import org.hibernate.annotations.JdbcType;
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -98,7 +96,6 @@ public class NotificationRule extends PanacheEntityBase {
private String publisherConfig;

@Column(name = "UUID")
@JdbcType(UUIDJdbcType.class)
private UUID uuid;

@Column(name = "NOTIFY_CHILDREN")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.github.packageurl.MalformedPackageURLException;
import com.github.packageurl.PackageURL;
import io.quarkus.runtime.annotations.RegisterForReflection;
import org.dependencytrack.persistence.converter.ClassifierToStringConverter;

import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
Expand All @@ -31,9 +33,6 @@
import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderBy;
import jakarta.persistence.Table;
import org.dependencytrack.persistence.converter.ClassifierToStringConverter;
import org.hibernate.annotations.JdbcType;
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;

import java.io.Serializable;
import java.util.Collection;
Expand Down Expand Up @@ -101,7 +100,6 @@ public class Project implements Serializable {
private String directDependencies;

@Column(name = "UUID")
@JdbcType(UUIDJdbcType.class)
private UUID uuid;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.dependencytrack.persistence.converter.RepositoryTypeConverter;
import org.hibernate.annotations.JdbcType;
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;

import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -68,7 +66,6 @@ public class Repository {
private String password;

@Column(name = "UUID")
@JdbcType(UUIDJdbcType.class)
private UUID uuid;

public long getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
import org.dependencytrack.common.model.Severity;
import org.dependencytrack.commonutil.VulnerabilityUtil;
import org.dependencytrack.persistence.converter.CollectionIntegerConverter;
import org.hibernate.annotations.JdbcType;
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;

import java.math.BigDecimal;
import java.util.ArrayList;
Expand Down Expand Up @@ -167,7 +165,6 @@ public enum Source {
private List<Component> components;

@Column(name = "UUID")
@JdbcType(UUIDJdbcType.class)
private UUID uuid;

@OneToMany
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.apache.commons.lang3.tuple.Pair;
import org.hibernate.annotations.JdbcType;
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Map;
Expand Down Expand Up @@ -73,7 +70,6 @@ public class VulnerabilityAlias implements Serializable {
private String vulnDbId;

@Column(name = "UUID")
@JdbcType(UUIDJdbcType.class)
private UUID uuid;

public long getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import jakarta.persistence.ManyToMany;
import jakarta.persistence.OrderBy;
import jakarta.persistence.Table;
import org.hibernate.annotations.JdbcType;
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -136,7 +134,6 @@ public class VulnerableSoftware extends PanacheEntityBase implements ICpe {
private List<Vulnerability> vulnerabilities;

@Column(name = "UUID")
@JdbcType(UUIDJdbcType.class)
private UUID uuid;

public long getId() {
Expand Down
Loading

0 comments on commit 930e2d2

Please sign in to comment.