Skip to content

Commit

Permalink
Review notes and some discussed changes applied.
Browse files Browse the repository at this point in the history
Signed-off-by: Tomáš Kraus <[email protected]>
  • Loading branch information
Tomas-Kraus committed Jul 17, 2024
1 parent 527501c commit 4966381
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 26 deletions.
2 changes: 2 additions & 0 deletions foundation/org.eclipse.persistence.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@
<arg>org.eclipse.persistence.core/org.eclipse.persistence.internal.oxm.conversion=org.eclipse.persistence.core.test</arg>
<arg>--add-exports</arg>
<arg>org.eclipse.persistence.core/org.eclipse.persistence.internal.oxm.schema.model=org.eclipse.persistence.core.test</arg>
<arg>--add-exports</arg>
<arg>org.eclipse.persistence.core/org.eclipse.persistence.internal.jpa.jpql=org.eclipse.persistence.core.test</arg>
</compilerArgs>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@
exports org.eclipse.persistence.internal.sessions.factories.model.transport.naming;

//INTERNAL ONLY exports
exports org.eclipse.persistence.internal.jpa.jpql to
org.eclipse.persistence.jpa,
org.eclipse.persistence.core.test;
exports org.eclipse.persistence.internal.jpa.jpql to org.eclipse.persistence.jpa;
exports org.eclipse.persistence.internal.localization to
org.eclipse.persistence.dbws,
org.eclipse.persistence.jpa,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ public class ExceptionLocalizationResource extends ListResourceBundle {
{ "find_option_class_unknown", "The FindOption implementing the {0} class is not supported"},
{ "refresh_option_class_unknown", "The RefreshOption implementing class {0} is not supported"},
{ "lock_option_class_unknown", "The LockOption implementing class {0} is not supported"},
{ "typed_query_reference_is_null", "Reference to a named query is null"}
{ "typed_query_reference_is_null", "Reference to a named query is null"},
{ "missing_jpql_parser_class", "Could not load the JPQL parser class."}
};
/**
* Return the lookup table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,11 @@ public JPAQueryBuilder getQueryBuilder() {
if (parent != null) {
this.queryBuilder = parent.getQueryBuilder();
} else {
this.queryBuilder = getProject().getQueryBuilder();
// Project may not be set
Project project = getProject();
if (project != null) {
this.queryBuilder = project.getQueryBuilder();
}
if (this.queryBuilder == null) {
this.queryBuilder = buildDefaultQueryBuilder();
}
Expand Down Expand Up @@ -471,7 +475,7 @@ protected JPAQueryBuilder buildDefaultQueryBuilder() {
builder = PrivilegedAccessHelper.newInstanceFromClass(parserClass);
}
} catch (Exception e) {
throw new IllegalStateException("Could not load the JPQL parser class." /* TODO: Localize string */, e);
throw new IllegalStateException(ExceptionLocalization.buildMessage("missing_jpql_parser_class"), e);
}
if (validation != null) {
builder.setValidationLevel(validation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@
import org.eclipse.persistence.internal.helper.ConcurrentFixedCache;
import org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap;
import org.eclipse.persistence.internal.identitymaps.IdentityMap;
import org.eclipse.persistence.internal.jpa.jpql.HermesParser;
import org.eclipse.persistence.internal.localization.ExceptionLocalization;
import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
import org.eclipse.persistence.internal.security.PrivilegedClassForName;
import org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass;
import org.eclipse.persistence.internal.sessions.AbstractSession;
import org.eclipse.persistence.internal.sessions.DatabaseSessionImpl;
import org.eclipse.persistence.queries.AttributeGroup;
Expand All @@ -65,7 +63,6 @@
import org.eclipse.persistence.sessions.server.ServerSession;

import java.io.Serializable;
import java.security.AccessController;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
Expand Down Expand Up @@ -214,9 +211,6 @@ public class Project extends CoreProject<ClassDescriptor, Login, DatabaseSession
/** {@link JPAQueryBuilder} instance factory. */
private Supplier<? extends JPAQueryBuilder> queryBuilderSupplier;

// /** JPA query builder. Default value is {@link HermesParser}. */
// private JPAQueryBuilder queryBuilder;

/**
* PUBLIC:
* Create a new project.
Expand All @@ -235,7 +229,6 @@ public Project() {
this.metamodelIdClassMap = new HashMap<>();
this.attributeGroups = new HashMap<>();
this.queryBuilderSupplier = new DefaultQueryBuilderSupplier<>();
// this.queryBuilder = null;
}

/**
Expand Down Expand Up @@ -1649,10 +1642,7 @@ public void setQueryBuilderSupplier(Supplier<? extends JPAQueryBuilder> queryBui
}

/**
* Get JPA query builder.
* Returned {@link JPAQueryBuilder} instance is initialized with 1st call of this method. Returned value depends
* on instance factory, which may be set using {@link #setQueryBuilderSupplier(java.util.function.Supplier)} before
* this 1st method call happens. Default instance factory value is {@link HermesParser}.
* Create new instance of {@link JPAQueryBuilder}.
*
* @return the JPA query builder
*/
Expand All @@ -1671,17 +1661,13 @@ private DefaultQueryBuilderSupplier() {
}

@Override
@SuppressWarnings({"unchecked", "deprecation"})
public T get() {
try {
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
Class<T> parserClass = AccessController.doPrivileged(new PrivilegedClassForName<>(DEFAULT_BUILDER_CLASS_NAME));
return AccessController.doPrivileged(new PrivilegedNewInstanceFromClass<>(parserClass));
} else {
Class<T> parserClass = PrivilegedAccessHelper.getClassForName(DEFAULT_BUILDER_CLASS_NAME);
return PrivilegedAccessHelper.newInstanceFromClass(parserClass);
}
Class<T> parserClass = (Class<T>) Class.forName(DEFAULT_BUILDER_CLASS_NAME);
return parserClass.newInstance();
} catch (Exception e) {
throw new IllegalStateException("Could not load the JPQL parser class." /* TODO: Localize string */, e);
throw new IllegalStateException(ExceptionLocalization.buildMessage("missing_jpql_parser_class"), e);
}
}

Expand Down

0 comments on commit 4966381

Please sign in to comment.