This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git


The following commit(s) were added to refs/heads/master by this push:
     new c489001ce [OPENJPA- 2939] Fixed UUID handling (#134)
c489001ce is described below

commit c489001ce3afd978f2f504a19a8ef466e69654e6
Author: Paulo Cristovão de Araújo Silva Filho <pcris...@gmail.com>
AuthorDate: Fri Jul 4 09:06:54 2025 -0300

    [OPENJPA- 2939] Fixed UUID handling (#134)
    
    * [OPENJPA-2939] Fixed handling of UUID in metamodel export and XML/json 
conversion
    
    * Added UUID property to entity
    * Allows metadata model export by handling UUID types
    * Allows XML/json conversion by handling UUID types
    
    * [OPENJPA-2939] Added missing line break
---
 .../apache/openjpa/persistence/jest/JSONObjectFormatter.java  |  1 +
 .../org/apache/openjpa/persistence/jest/XMLFormatter.java     |  1 +
 openjpa-jest/src/test/java/demo/Actor.java                    | 11 +++++++++++
 openjpa-jest/src/test/resources/META-INF/persistence.xml      |  7 ++++---
 .../apache/openjpa/persistence/meta/AbstractManagedType.java  |  4 ++++
 5 files changed, 21 insertions(+), 3 deletions(-)

diff --git 
a/openjpa-jest/src/main/java/org/apache/openjpa/persistence/jest/JSONObjectFormatter.java
 
b/openjpa-jest/src/main/java/org/apache/openjpa/persistence/jest/JSONObjectFormatter.java
index 5a50d0ade..681bc35ac 100644
--- 
a/openjpa-jest/src/main/java/org/apache/openjpa/persistence/jest/JSONObjectFormatter.java
+++ 
b/openjpa-jest/src/main/java/org/apache/openjpa/persistence/jest/JSONObjectFormatter.java
@@ -172,6 +172,7 @@ public class JSONObjectFormatter implements 
ObjectFormatter<JSON> {
                 case JavaTypes.LOCALE:
                 case JavaTypes.STRING:
                 case JavaTypes.ENUM:
+                case JavaTypes.UUID_OBJ:
                     root.set(fmd.getName(), value);
                     break;
 
diff --git 
a/openjpa-jest/src/main/java/org/apache/openjpa/persistence/jest/XMLFormatter.java
 
b/openjpa-jest/src/main/java/org/apache/openjpa/persistence/jest/XMLFormatter.java
index 6cce9739f..51530f421 100644
--- 
a/openjpa-jest/src/main/java/org/apache/openjpa/persistence/jest/XMLFormatter.java
+++ 
b/openjpa-jest/src/main/java/org/apache/openjpa/persistence/jest/XMLFormatter.java
@@ -287,6 +287,7 @@ public class XMLFormatter implements 
ObjectFormatter<Document> {
                 case JavaTypes.DATE:
                 case JavaTypes.NUMBER:
                 case JavaTypes.CALENDAR:
+                case JavaTypes.UUID_OBJ:
                 case JavaTypes.LOCALE:
                 case JavaTypes.STRING:
                 case JavaTypes.ENUM:
diff --git a/openjpa-jest/src/test/java/demo/Actor.java 
b/openjpa-jest/src/test/java/demo/Actor.java
index 6a7c3c33d..3d663cc10 100644
--- a/openjpa-jest/src/test/java/demo/Actor.java
+++ b/openjpa-jest/src/test/java/demo/Actor.java
@@ -22,6 +22,7 @@ package demo;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.UUID;
 
 import jakarta.persistence.Entity;
 import jakarta.persistence.Id;
@@ -58,6 +59,7 @@ public class Actor {
     private Actor partner;
     @OneToMany
     private Set<Movie> movies;
+    private UUID randomId;
 
     protected Actor() {
 
@@ -70,6 +72,7 @@ public class Actor {
         this.lastName = lastName;
         this.gender = gender;
         this.dob = dob;
+        this.randomId = java.util.UUID.randomUUID();
     }
 
     public String getId() {
@@ -102,6 +105,14 @@ public class Actor {
     public Set<Movie> getMovies() {
         return movies;
     }
+    
+    public void setRandomId(UUID uuid) {
+        this.randomId = uuid;
+    }
+
+    public UUID getRandomId() {
+        return randomId;
+    }
 
     public void addMovie(Movie movie) {
         if (movies == null)
diff --git a/openjpa-jest/src/test/resources/META-INF/persistence.xml 
b/openjpa-jest/src/test/resources/META-INF/persistence.xml
index 207220cda..3417a1801 100644
--- a/openjpa-jest/src/test/resources/META-INF/persistence.xml
+++ b/openjpa-jest/src/test/resources/META-INF/persistence.xml
@@ -17,9 +17,10 @@
  specific language governing permissions and limitations
  under the License.
 -->
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-    version="1.0">
-
+<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence";
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence 
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd";
+             version="2.1">
     <persistence-unit name="test-jest">
 
        
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
diff --git 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AbstractManagedType.java
 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AbstractManagedType.java
index f64fd8f71..4246de156 100644
--- 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AbstractManagedType.java
+++ 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AbstractManagedType.java
@@ -33,6 +33,7 @@ import java.util.Date;
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.TreeSet;
+import java.util.UUID;
 
 import jakarta.persistence.metamodel.Attribute;
 import jakarta.persistence.metamodel.CollectionAttribute;
@@ -169,6 +170,9 @@ public abstract class AbstractManagedType<X> extends 
Types.BaseType<X>
             case JavaTypes.LOCALE:
                 attrs.add(new Members.SingularAttributeImpl<X, Locale>(this, 
f));
                 break;
+            case JavaTypes.UUID_OBJ:
+                attrs.add(new Members.SingularAttributeImpl<X, UUID>(this, f));
+                break;
             case JavaTypes.OBJECT:
             case JavaTypes.OID:
             case JavaTypes.PC:

Reply via email to