Skip to content

Commit

Permalink
Merge branch 'eclipse-ee4j:2.7' into 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
igormukhin authored Sep 4, 2024
2 parents ef63c0e + 6de65af commit c265d10
Show file tree
Hide file tree
Showing 12 changed files with 547 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 IBM Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -17,6 +17,7 @@

import org.junit.Assert;
import org.junit.Test;
import org.eclipse.persistence.internal.localization.EclipseLinkLocalization;
import org.eclipse.persistence.internal.localization.LoggingLocalization;

public class LocalizationTest {
Expand All @@ -27,5 +28,7 @@ public void test() {
"EclipseLink, version: EXAMPLE", LoggingLocalization.buildMessage("topLink_version", new Object[] { "EXAMPLE" }));
Assert.assertEquals("LoggingLocalization.buildMessage could not find the correct translation.",
"message_not_exist (There is no English translation for this message.)", LoggingLocalization.buildMessage("message_not_exist"));
Assert.assertEquals("EclipseLinkLocalization.buildMessage could not find the correct translation.",
"somekey1 (There is no English translation for this message.)", EclipseLinkLocalization.buildMessage("AAAAUnknownClass", "somekey1", null, true));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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 @@ -29,6 +29,9 @@
*/
public abstract class EclipseLinkLocalization {

// Get the current language's NoTranslationForThisLocale message.
private static final String NO_TRANSLATION_MESSAGE = ResourceBundle.getBundle("org.eclipse.persistence.internal.localization.i18n.EclipseLinkLocalizationResource", Locale.getDefault()).getString("NoTranslationForThisLocale");

/**
* Return the message for the given exception class and error number.
*/
Expand Down Expand Up @@ -65,13 +68,18 @@ public static String buildMessage(String localizationClassName, String key, Obje
} catch (java.util.MissingResourceException mre) {
if (translate) {
// Found bundle, but couldn't find translation.
// Get the current language's NoTranslationForThisLocale message.
bundle = ResourceBundle.getBundle("org.eclipse.persistence.internal.localization.i18n.EclipseLinkLocalizationResource", Locale.getDefault());
String noTranslationMessage = bundle.getString("NoTranslationForThisLocale");
return MessageFormat.format(message, arguments) + noTranslationMessage;
}
// Use the current language's NoTranslationForThisLocale message.
if (arguments == null) {
return message + NO_TRANSLATION_MESSAGE;
} else {
return MessageFormat.format(message, arguments) + NO_TRANSLATION_MESSAGE;
} }
}
if (arguments == null) {
return message;
} else {
return MessageFormat.format(message, arguments);
}
return MessageFormat.format(message, arguments);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019 IBM Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -1078,6 +1078,9 @@ public Object cloneAndRegisterObject(Object original, CacheKey parentCacheKey, C
}
}
try {
if (isConsideredInvalid(original, parentCacheKey, descriptor) && unitOfWorkCacheKey.getObject() != null) {
original = unitOfWorkCacheKey.getObject();
}
// bug:6167576 Must acquire the lock before cloning.
workingClone = builder.instantiateWorkingCopyClone(original, this);
// PERF: Cache the primary key if implements PersistenceEntity.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019 IBM Corporation. All rights reserved.
This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -177,4 +177,17 @@
</properties>
</persistence-unit>

<persistence-unit name="pu-with-dynamic-weaving" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.eclipse.persistence.testing.models.jpa.weave.IsolatedEntity</class>
<class>org.eclipse.persistence.testing.models.jpa.weave.Location</class>
<class>org.eclipse.persistence.testing.models.jpa.weave.Node</class>
<class>org.eclipse.persistence.testing.models.jpa.weave.Order</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<shared-cache-mode>DISABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="eclipselink.weaving" value="true"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019, 2024 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019 IBM Corporation. All rights reserved.
This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -607,4 +607,17 @@
</properties>
</persistence-unit>

<persistence-unit name="pu-with-dynamic-weaving" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.eclipse.persistence.testing.models.jpa.weave.IsolatedEntity</class>
<class>org.eclipse.persistence.testing.models.jpa.weave.Location</class>
<class>org.eclipse.persistence.testing.models.jpa.weave.Node</class>
<class>org.eclipse.persistence.testing.models.jpa.weave.Order</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<shared-cache-mode>DISABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="eclipselink.weaving" value="true"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2018, 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 @@ -250,4 +250,17 @@
</properties>
</persistence-unit>

<persistence-unit name="pu-with-dynamic-weaving" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.eclipse.persistence.testing.models.jpa.weave.IsolatedEntity</class>
<class>org.eclipse.persistence.testing.models.jpa.weave.Location</class>
<class>org.eclipse.persistence.testing.models.jpa.weave.Node</class>
<class>org.eclipse.persistence.testing.models.jpa.weave.Order</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<shared-cache-mode>DISABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="eclipselink.weaving" value="true"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 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
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
package org.eclipse.persistence.testing.models.jpa.weave;

import java.util.Objects;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

@Entity
@Table(name="JPA21_ISOLATED_ENTITY")
public class IsolatedEntity {

@Id
protected String id;

@Version
protected Integer version;

public IsolatedEntity() {
super();
}

public IsolatedEntity(String id) {
this.id = id;
}

public String getId() {
return id;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IsolatedEntity that = (IsolatedEntity) o;
return Objects.equals(id, that.id) && Objects.equals(version, that.version);
}

@Override
public int hashCode() {
return Objects.hash(id, version);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 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
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
package org.eclipse.persistence.testing.models.jpa.weave;

import java.util.Objects;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;

@Entity
@Table(name="JPA21_LOCATION")
public class Location {

@Id
protected Long id;

protected String locationId;

@ManyToOne(fetch = FetchType.LAZY)
protected Node node;

@Version
protected Integer version;

public Location(long id, String locationId) {
this.id = id;
this.locationId = locationId;
}

protected Location() {
}

public Long getId() {
return this.id;
}

public String getLocationId() {
return this.locationId;
}

public Node getNode() {
return node;
}

public void setNode(Node node) {
this.node = node;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Location location = (Location) o;
return Objects.equals(id, location.id) && Objects.equals(locationId, location.locationId) && Objects.equals(node, location.node) && Objects.equals(version, location.version);
}

@Override
public int hashCode() {
return Objects.hash(id, locationId, node, version);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 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
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
package org.eclipse.persistence.testing.models.jpa.weave;

import java.util.Objects;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

@Entity
@Table(name="JPA21_NODE")
public class Node {

@Id
protected String id;

protected int availableBufferCapacity = 10;

@Version
protected Integer version;

public Node(String id) {
this.id = id;
}

protected Node() {
}

public String getId() {
return id;
}

public int getAvailableBufferCapacity() {
return availableBufferCapacity;
}

public void reserveBufferCapacity() {
availableBufferCapacity--;
}

public Integer getVersion() {
return version;
}

/*
public void setVersion(Integer version) {
this.version = version;
}
*/

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Node node = (Node) o;
return availableBufferCapacity == node.availableBufferCapacity && Objects.equals(id, node.id) && Objects.equals(version, node.version);
}

@Override
public int hashCode() {
return Objects.hash(id, availableBufferCapacity, version);
}
}
Loading

0 comments on commit c265d10

Please sign in to comment.