Skip to content

Commit

Permalink
Exception Resources should take vars from resources
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Aug 21, 2023
1 parent 2b8dd8d commit d10676f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ public static QueryException namedArgumentNotFoundInQueryParameters(String argum
return queryException;
}

public static QueryException nativeSQLQueriesAreDisabled(DatabaseQuery query) {
Object[] args = {};
public static QueryException nativeSQLQueriesAreDisabled(DatabaseQuery query, String prop, String nativeProp) {
Object[] args = { prop, nativeProp };
QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, NATIVE_SQL_QUERIES_ARE_DISABLED, args), query);
queryException.setErrorCode(NATIVE_SQL_QUERIES_ARE_DISABLED);
return queryException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1906,8 +1906,8 @@ public static ValidationException multipleVPDIdentifiersSpecified(String identif
return validationException;
}

public static ValidationException multitenantContextPropertyForNonSharedEMFNotSpecified(String contextProperty) {
Object[] args = { contextProperty };
public static ValidationException multitenantContextPropertyForNonSharedEMFNotSpecified(String contextProperty, String key) {
Object[] args = { contextProperty, key };
ValidationException validationException = new ValidationException(ExceptionMessageGenerator.buildMessage(ValidationException.class, MULTITENANT_PROPERTY_FOR_NON_SHARED_EMF_NOT_SPECIFIED, args));
validationException.setErrorCode(MULTITENANT_PROPERTY_FOR_NON_SHARED_EMF_NOT_SPECIFIED);
return validationException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
// - 454189 : Misc message cleanup.#2
package org.eclipse.persistence.exceptions.i18n;

import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.persistence.config.QueryHints;

import java.util.ListResourceBundle;

/**
Expand Down Expand Up @@ -209,7 +206,7 @@ public final class QueryExceptionResource extends ListResourceBundle {
{ "6172", "Missing connection pool for partitioning [{0}]."},
{ "6173", "Connection pool [{0}] failed to fail-over, all servers are dead."},
{ "6174", "No value was provided for the session property [{0}]. This exception is possible when using additional criteria or tenant discriminator columns without specifying the associated contextual property. These properties must be set through EntityManager, EntityManagerFactory or persistence unit properties. If using native EclipseLink, these properties should be set directly on the session."},
{ "6175", "Native SQL queries have been disabled. This is done either by setting the persistence unit property \"" + PersistenceUnitProperties.ALLOW_NATIVE_SQL_QUERIES + "\" to false or having at least one multitenant entity defined in your persistence unit. Check your persistence unit specification. To allow native sql queries, set this property to true. Alternatively, individual queries may bypass this setting by setting the \"" + QueryHints.ALLOW_NATIVE_SQL_QUERY + "\" query hint to true."},
{ "6175", "Native SQL queries have been disabled. This is done either by setting the persistence unit property \"{0}\" to false or having at least one multitenant entity defined in your persistence unit. Check your persistence unit specification. To allow native sql queries, set this property to true. Alternatively, individual queries may bypass this setting by setting the \"{1}\" query hint to true."},
{ "6176", "An exception was thrown while initializing the constructor from the class [{0}]: [{1}]"},
{ "6177", "The column result [{0}] was not found in the results of the query."},
{ "6178", "isResultSetAccessOptimizedQuery set to true conflicts with other query settings."},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
// - 326728: Fix persistence root calculation for WAR files
package org.eclipse.persistence.exceptions.i18n;

import org.eclipse.persistence.config.PersistenceUnitProperties;

import java.util.ListResourceBundle;

/**
Expand Down Expand Up @@ -360,7 +358,7 @@ public final class ValidationExceptionResource extends ListResourceBundle {
{ "7343", "Multiple VPD identifiers (tenant discriminator context property) have been specified. Entity [{1}] uses [{0}] and Entity [{3}] uses [{2}]. The Multitenant VPD strategy allows only one tenant discriminator column for each entity and its context property must be consistent across all the Multitenant VPD entities."},
{ "7344", "VPD (connections and DDL generation) is not supported for the platform: [{0}]."},
{ "7345", "{0} file specified for XMLMetadataSource is not found"},
{ "7346", "The multitenant context property [{0}] has not been provided. When the persistence unit property (" + PersistenceUnitProperties.MULTITENANT_SHARED_EMF + ") is set to false, all multitenant context properties must be provided up front. This can be done through the persistence unit definition directly or by passing a properties map containing all the multitenant context properties on the create EntityManagerFactory call."},
{ "7346", "The multitenant context property [{0}] has not been provided. When the persistence unit property ({1}) is set to false, all multitenant context properties must be provided up front. This can be done through the persistence unit definition directly or by passing a properties map containing all the multitenant context properties on the create EntityManagerFactory call."},
{ "7347", "The class [{0}] specifies type level convert metadata without specifying an attribute name for each. An attribute name must be provided for all type level convert metadata to ensure the correct application to a super class attribute."},
{ "7348", "The embedded mapping [{1}] from [{0}] does not specify an attribute name to which the convert is to be applied. You must specify an attribute name on the Embeddable."},
{ "7350", "The convert attribute name [{3}] from the mapping [{1}] from the class [{0}] was not found on the embeddable class [{2}]. Please ensure the attribute exists and is correctly named." },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
package org.eclipse.persistence.internal.sessions;

import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.persistence.config.QueryHints;
import org.eclipse.persistence.config.ReferenceMode;
import org.eclipse.persistence.descriptors.ClassDescriptor;
import org.eclipse.persistence.descriptors.DescriptorEvent;
Expand Down Expand Up @@ -1809,7 +1810,7 @@ public Object executeQuery(DatabaseQuery query, AbstractRecord row) throws Datab
if (! query.shouldAllowNativeSQLQuery(getProject().allowNativeSQLQueries())) {
// If the session/project says no to SQL queries and the database
// query doesn't ask to bypass this decision then throw an exception.
throw QueryException.nativeSQLQueriesAreDisabled(query);
throw QueryException.nativeSQLQueriesAreDisabled(query, PersistenceUnitProperties.ALLOW_NATIVE_SQL_QUERIES, QueryHints.ALLOW_NATIVE_SQL_QUERY);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ protected void postConnectDatasource(){
if (!Boolean.parseBoolean(value)) {
for (String property : getMultitenantContextProperties()) {
if (! getProperties().containsKey(property)) {
throw ValidationException.multitenantContextPropertyForNonSharedEMFNotSpecified(property);
throw ValidationException.multitenantContextPropertyForNonSharedEMFNotSpecified(property, PersistenceUnitProperties.MULTITENANT_SHARED_EMF);
}
}

Expand Down

0 comments on commit d10676f

Please sign in to comment.