From 05a724d757a97148cb360aabc043f70c2b05ebdb Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 5 Oct 2023 15:23:48 +0300 Subject: [PATCH] Fix type definition issues --- .../configurations/typedefinition/PostgreSQLEnumType.java | 5 +++++ .../eu/eudat/configurations/typedefinition/UUIDType.java | 7 ++++++- .../eu/eudat/configurations/typedefinition/XMLType.java | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/PostgreSQLEnumType.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/PostgreSQLEnumType.java index 26f6ebcc2..20be832a8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/PostgreSQLEnumType.java +++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/PostgreSQLEnumType.java @@ -7,6 +7,11 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Types; +/** + * @deprecated hibernate's abstract class is depricated and those type of conversions and checks + * are done by hibernate itself + */ +@Deprecated public class PostgreSQLEnumType extends org.hibernate.type.EnumType { public void nullSafeSet( diff --git a/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/UUIDType.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/UUIDType.java index 2a1fb5cbe..042fed955 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/UUIDType.java +++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/UUIDType.java @@ -42,7 +42,12 @@ public class UUIDType implements UserType { @Override public UUID nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { - return null; + assert (position >= 0); + Object value = rs.getObject(position); + if (value == null) return null; + + UUID uuid = UUID.fromString(rs.getString(position)); + return rs.wasNull() ? null : uuid; } public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { diff --git a/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/XMLType.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/XMLType.java index bd825ae3c..ea4b1f9d0 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/XMLType.java +++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/typedefinition/XMLType.java @@ -44,7 +44,9 @@ public class XMLType implements UserType { @Override public String nullSafeGet(ResultSet resultSet, int i, SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws SQLException { - return null; + assert (i >= 0); + String xmldoc = resultSet.getString(i); + return resultSet.wasNull() ? null : xmldoc; } public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {