Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15x] Remove Named queries, ANTLR, Query language parser #3198

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions ebean-api/src/main/java/io/ebean/BeanFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,4 @@ protected Query<T> nativeSql(String nativeSql) {
return db().findNative(type, nativeSql);
}

/**
* Creates a query using the ORM query language.
*/
protected Query<T> query(String ormQuery) {
return db().createQuery(type, ormQuery);
}
}
52 changes: 0 additions & 52 deletions ebean-api/src/main/java/io/ebean/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,21 +790,6 @@ public static <T> Update<T> createUpdate(Class<T> beanType, String ormUpdate) {
return getDefault().createUpdate(beanType, ormUpdate);
}


/**
* Create a named query.
* <p>
* For RawSql the named query is expected to be in ebean.xml.
*
* @param beanType The type of entity bean
* @param namedQuery The name of the query
* @param <T> The type of entity bean
* @return The query
*/
public static <T> Query<T> createNamedQuery(Class<T> beanType, String namedQuery) {
return getDefault().createNamedQuery(beanType, namedQuery);
}

/**
* Create a query for a type of entity bean.
* <p>
Expand All @@ -824,43 +809,6 @@ public static <T> Query<T> createQuery(Class<T> beanType) {
return getDefault().createQuery(beanType);
}

/**
* Parse the Ebean query language statement returning the query which can then
* be modified (add expressions, change order by clause, change maxRows, change
* fetch and select paths etc).
* <p>
* <h3>Example</h3>
* <pre>{@code
*
* // Find order additionally fetching the customer, details and details.product name.
*
* String eql = "fetch customer fetch details fetch details.product (name) where id = :orderId ";
*
* Query<Order> query = DB.createQuery(Order.class, eql);
* query.setParameter("orderId", 2);
*
* Order order = query.findOne();
*
* // This is the same as:
*
* Order order = DB.find(Order.class)
* .fetch("customer")
* .fetch("details")
* .fetch("detail.product", "name")
* .setId(2)
* .findOne();
*
* }</pre>
*
* @param beanType The type of bean to fetch
* @param eql The Ebean query
* @param <T> The type of the entity bean
* @return The query with expressions defined as per the parsed query statement
*/
public static <T> Query<T> createQuery(Class<T> beanType, String eql) {
return getDefault().createQuery(beanType, eql);
}

/**
* Create a query for a type of entity bean.
* <p>
Expand Down
47 changes: 0 additions & 47 deletions ebean-api/src/main/java/io/ebean/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,60 +225,13 @@ public interface Database {
*/
<T> UpdateQuery<T> update(Class<T> beanType);

/**
* Create a named query.
* <p>
* For RawSql the named query is expected to be in ebean.xml.
*
* @param beanType The type of entity bean
* @param namedQuery The name of the query
* @param <T> The type of entity bean
* @return The query
*/
<T> Query<T> createNamedQuery(Class<T> beanType, String namedQuery);

/**
* Create a query for an entity bean and synonym for {@link #find(Class)}.
*
* @see #find(Class)
*/
<T> Query<T> createQuery(Class<T> beanType);

/**
* Parse the Ebean query language statement returning the query which can then
* be modified (add expressions, change order by clause, change maxRows, change
* fetch and select paths etc).
* <p>
* <h3>Example</h3>
* <pre>{@code
*
* // Find order additionally fetching the customer, details and details.product name.
*
* String ormQuery = "fetch customer fetch details fetch details.product (name) where id = :orderId ";
*
* Query<Order> query = DB.createQuery(Order.class, ormQuery);
* query.setParameter("orderId", 2);
*
* Order order = query.findOne();
*
* // This is the same as:
*
* Order order = DB.find(Order.class)
* .fetch("customer")
* .fetch("details")
* .fetch("detail.product", "name")
* .setId(2)
* .findOne();
*
* }</pre>
*
* @param beanType The type of bean to fetch
* @param ormQuery The Ebean ORM query
* @param <T> The type of the entity bean
* @return The query with expressions defined as per the parsed query statement
*/
<T> Query<T> createQuery(Class<T> beanType, String ormQuery);

/**
* Create a query for a type of entity bean.
* <p>
Expand Down
8 changes: 0 additions & 8 deletions ebean-api/src/main/java/io/ebean/ExpressionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -693,12 +693,4 @@ public interface ExpressionFactory {
*/
<T> Junction<T> junction(Junction.Type type, Query<T> query, ExpressionList<T> parent);

/**
* Add the expressions to the given expression list.
*
* @param where The expression list to add the expressions to
* @param expressions The expressions that are parsed
* @param params Bind parameters to match ? or ?1 bind positions.
*/
<T> void where(ExpressionList<T> where, String expressions, Object[] params);
}
30 changes: 0 additions & 30 deletions ebean-api/src/main/java/io/ebean/ExpressionList.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,28 +507,6 @@ default <A> A findSingleAttribute() {
*/
ExpressionList<T> filterMany(String manyProperty);

/**
* Deprecated for removal - migrate to filterManyRaw()
* <p>
* Add filter expressions to the many property.
*
* <pre>{@code
*
* DB.find(Customer.class)
* .where()
* .eq("name", "Rob")
* .filterMany("orders", "status = ?", Status.NEW)
* .findList();
*
* }</pre>
*
* @param manyProperty The many property
* @param expressions Filter expressions with and, or and ? or ?1 type bind parameters
* @param params Bind parameters used in the expressions
*/
@Deprecated(forRemoval = true)
ExpressionList<T> filterMany(String manyProperty, String expressions, Object... params);

/**
* Add filter expressions for the many path. The expressions can include SQL functions if
* desired and the property names are translated to column names.
Expand Down Expand Up @@ -721,14 +699,6 @@ default Query<T> setUseQueryCache(boolean enabled) {
*/
ExpressionList<T> where();

/**
* Add the expressions to this expression list.
*
* @param expressions The expressions that are parsed and added to this expression list
* @param params Bind parameters to match ? or ?1 bind positions.
*/
ExpressionList<T> where(String expressions, Object... params);

/**
* Path exists - for the given path in a JSON document.
* <pre>{@code
Expand Down
7 changes: 0 additions & 7 deletions ebean-api/src/main/java/io/ebean/Finder.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,4 @@ public Query<T> nativeSql(String nativeSql) {
return db().findNative(type, nativeSql);
}

/**
* Creates a query using the ORM query language.
*/
public Query<T> query(String ormQuery) {
return db().createQuery(type, ormQuery);
}

}
6 changes: 0 additions & 6 deletions ebean-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@
<version>13.18.0</version>
</dependency>

<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.8-1</version>
</dependency>

<!--
Class retention Nonnull and Nullable annotations
to assist with IDE auto-completion with Ebean API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import io.ebeaninternal.server.dto.DtoBeanDescriptor;
import io.ebeaninternal.server.dto.DtoBeanManager;
import io.ebeaninternal.server.el.ElFilter;
import io.ebeaninternal.server.grammer.EqlParser;
import io.ebeaninternal.server.query.*;
import io.ebeaninternal.server.querydefn.*;
import io.ebeaninternal.server.rawsql.SpiRawSql;
Expand Down Expand Up @@ -848,29 +847,6 @@ public <T> Query<T> findNative(Class<T> beanType, String nativeSql) {
return query;
}

@Override
public <T> Query<T> createNamedQuery(Class<T> beanType, String namedQuery) {
BeanDescriptor<T> desc = desc(beanType);
String named = desc.namedQuery(namedQuery);
if (named != null) {
return createQuery(beanType, named);
}
SpiRawSql rawSql = desc.namedRawSql(namedQuery);
if (rawSql != null) {
DefaultOrmQuery<T> query = createQuery(beanType);
query.setRawSql(rawSql);
return query;
}
throw new PersistenceException("No named query called " + namedQuery + " for bean:" + beanType.getName());
}

@Override
public <T> DefaultOrmQuery<T> createQuery(Class<T> beanType, String eql) {
DefaultOrmQuery<T> query = createQuery(beanType);
EqlParser.parse(eql, query);
return query;
}

@Override
public <T> DefaultOrmQuery<T> createQuery(Class<T> beanType) {
return new DefaultOrmQuery<>(desc(beanType), this, expressionFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.ebean.search.*;
import io.ebeaninternal.api.SpiExpressionFactory;
import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.server.grammer.EqlParser;

import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -146,11 +145,6 @@ public Expression bitwiseAnd(String propertyName, long flags, long match) {
return new BitwiseExpression(propertyName, BitwiseOp.AND, flags, "=", match);
}

@Override
public <T> void where(ExpressionList<T> list, String expressions, Object[] params) {
EqlParser.parseWhere(expressions, list, this, params);
}

@Override
public Expression eq(String propertyName, Query<?> subQuery) {
return new SubQueryExpression(SubQueryOp.EQ, propertyName, (SpiQuery<?>) subQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,6 @@ public ExpressionList<T> filterMany(String manyProperty) {
return query.filterMany(manyProperty);
}

@Override
public ExpressionList<T> filterMany(String manyProperty, String expressions, Object... params) {
return query.filterMany(manyProperty).where(expressions, params);
}

@Override
public ExpressionList<T> filterManyRaw(String manyProperty, String rawExpression, Object... params) {
return query.filterMany(manyProperty).raw(rawExpression, params);
Expand Down Expand Up @@ -718,12 +713,6 @@ public ExpressionList<T> jsonBetween(String propertyName, String path, Object lo
return add(expr.jsonBetween(propertyName, path, lowerValue, upperValue));
}

@Override
public ExpressionList<T> where(String expressions, Object... params) {
expr.where(this, expressions, params);
return this;
}

@Override
public ExpressionList<T> bitwiseAny(String propertyName, long flags) {
return add(expr.bitwiseAny(propertyName, flags));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,11 @@ public ExpressionList<T> exampleLike(Object example) {
return exprList.exampleLike(example);
}

@Override
public ExpressionList<T> where(String expressions, Object... params) {
throw new IllegalStateException("where not allowed on Junction expression list");
}

@Override
public ExpressionList<T> filterMany(String prop) {
throw new IllegalStateException("filterMany not allowed on Junction expression list");
}

@Override
public ExpressionList<T> filterMany(String manyProperty, String expressions, Object... params) {
throw new IllegalStateException("filterMany not allowed on Junction expression list");
}

@Override
public ExpressionList<T> filterManyRaw(String manyProperty, String rawExpression, Object... params) {
throw new IllegalStateException("filterMany not allowed on Junction expression list");
Expand Down
Loading