Skip to content

Commit

Permalink
Merge pull request #1309 from beikov/jpa-632
Browse files Browse the repository at this point in the history
Fix jakartaee/persistence#632, Don't assume persist cascading for associations part of the id
  • Loading branch information
scottmarlow committed Jun 19, 2024
2 parents 0fd15ff + 65a7237 commit f7e9f81
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit f7e9f81

Please sign in to comment.