From 65a7237a4a19b307277a2cad0312158c640dcf42 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Tue, 21 May 2024 12:14:41 +0200 Subject: [PATCH] [jakartaee/persistence#632] Don't assume persist cascading for associations part of the id --- .../tck/persistence/core/annotations/mapsid/Client.java | 6 +++--- .../tck/persistence/core/derivedid/ex1a/Client.java | 6 +++--- .../tck/persistence/core/derivedid/ex1b/Client.java | 6 +++--- .../tck/persistence/core/derivedid/ex2b/Client.java | 6 +++--- .../tck/persistence/core/derivedid/ex3a/Client.java | 7 +++---- .../tck/persistence/core/derivedid/ex3b/Client.java | 7 +++---- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/annotations/mapsid/Client.java b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/annotations/mapsid/Client.java index 23b29ce5b1..947914ab9f 100644 --- a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/annotations/mapsid/Client.java +++ b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/annotations/mapsid/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -95,11 +95,11 @@ public void persistMX1Test1() throws Exception { final DID1bDependent dep2 = new DID1bDependent(new DID1bDependentId("Michelle", 1L), employee1); final DID1bDependent dep3 = new DID1bDependent(new DID1bDependentId("John", 2L), employee2); + em.persist(employee1); + em.persist(employee2); em.persist(dep1); em.persist(dep2); em.persist(dep3); - em.persist(employee1); - em.persist(employee2); logger.log(Logger.Level.TRACE, "persisted Employees and Dependents"); em.flush(); diff --git a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex1a/Client.java b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex1a/Client.java index 12f7f8017f..b3babbaa33 100644 --- a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex1a/Client.java +++ b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex1a/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -80,11 +80,11 @@ public void DIDTest() throws Exception { final DID1Dependent dep2 = new DID1Dependent("Michelle", employee1); final DID1Dependent dep3 = new DID1Dependent("John", employee2); + getEntityManager().persist(employee1); + getEntityManager().persist(employee2); getEntityManager().persist(dep1); getEntityManager().persist(dep2); getEntityManager().persist(dep3); - getEntityManager().persist(employee1); - getEntityManager().persist(employee2); logger.log(Logger.Level.TRACE, "persisted Employees and Dependents"); getEntityManager().flush(); diff --git a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex1b/Client.java b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex1b/Client.java index 2a4b21b06c..6c79c49640 100644 --- a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex1b/Client.java +++ b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex1b/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -83,11 +83,11 @@ public void DIDTest() throws Exception { final DID1bDependent dep2 = new DID1bDependent(depId2, employee1); final DID1bDependent dep3 = new DID1bDependent(depId3, employee2); + getEntityManager().persist(employee1); + getEntityManager().persist(employee2); getEntityManager().persist(dep1); getEntityManager().persist(dep2); getEntityManager().persist(dep3); - getEntityManager().persist(employee1); - getEntityManager().persist(employee2); logger.log(Logger.Level.TRACE, "persisted Employees and Dependents"); getEntityManager().flush(); diff --git a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex2b/Client.java b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex2b/Client.java index ed42deb850..afdec34edb 100644 --- a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex2b/Client.java +++ b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex2b/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -82,12 +82,12 @@ public void DIDTest() throws Exception { final DID2bDependent dep2 = new DID2bDependent(new DID2bDependentId("Michelle", eId1), employee1); final DID2bDependent dep3 = new DID2bDependent(new DID2bDependentId("John", eId2), employee2); + getEntityManager().persist(employee1); + getEntityManager().persist(employee2); getEntityManager().persist(dep1); getEntityManager().persist(dep2); getEntityManager().persist(dep3); - getEntityManager().persist(employee1); - getEntityManager().persist(employee2); getEntityManager().flush(); logger.log(Logger.Level.TRACE, "persisted Employees and Dependents"); diff --git a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex3a/Client.java b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex3a/Client.java index 98987409ed..36b8f935cd 100644 --- a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex3a/Client.java +++ b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex3a/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -86,13 +86,12 @@ public void DIDTest() throws Exception { final DID3Dependent dep2 = new DID3Dependent(depId2, employee1); final DID3Dependent dep3 = new DID3Dependent(depId3, employee2); + getEntityManager().persist(employee1); + getEntityManager().persist(employee2); getEntityManager().persist(dep1); getEntityManager().persist(dep2); getEntityManager().persist(dep3); - getEntityManager().persist(employee1); - getEntityManager().persist(employee2); - getEntityManager().flush(); logger.log(Logger.Level.TRACE, "persisted Employees and Dependents"); diff --git a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex3b/Client.java b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex3b/Client.java index 7d2f63b0db..04d1d83199 100644 --- a/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex3b/Client.java +++ b/jpa/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/derivedid/ex3b/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -87,13 +87,12 @@ public void DIDTest() throws Exception { final DID3bDependent dep2 = new DID3bDependent(depId2, employee1); final DID3bDependent dep3 = new DID3bDependent(depId3, employee2); + getEntityManager().persist(employee1); + getEntityManager().persist(employee2); getEntityManager().persist(dep1); getEntityManager().persist(dep2); getEntityManager().persist(dep3); - getEntityManager().persist(employee1); - getEntityManager().persist(employee2); - logger.log(Logger.Level.TRACE, "persisted Employees and Dependents"); getEntityManager().flush();