Search in sources :

Example 16 with UpdateAllQuery

use of org.eclipse.persistence.queries.UpdateAllQuery in project eclipselink by eclipse-ee4j.

the class UpdateAllQueryAdvancedJunitTest method testFirstNamePrefixBLADoubleSalaryForSalary.

public static void testFirstNamePrefixBLADoubleSalaryForSalary() {
    ExpressionBuilder builder = new ExpressionBuilder();
    Expression selectionExpression = builder.get("salary").lessThan(20000);
    UpdateAllQuery updateQuery = new UpdateAllQuery(Employee.class, selectionExpression);
    updateQuery.addUpdate("firstName", Expression.fromLiteral("'BLA'", null).concat(builder.get("firstName")));
    updateQuery.addUpdate("salary", ExpressionMath.multiply(builder.get("salary"), Integer.valueOf(2)));
    updateAllQueryInternal(updateQuery);
}
Also used : Expression(org.eclipse.persistence.expressions.Expression) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) UpdateAllQuery(org.eclipse.persistence.queries.UpdateAllQuery)

Example 17 with UpdateAllQuery

use of org.eclipse.persistence.queries.UpdateAllQuery in project eclipselink by eclipse-ee4j.

the class UpdateAllQueryAdvancedJunitTest method testAssignNullToAddress.

public static void testAssignNullToAddress() {
    UpdateAllQuery updateQuery = new UpdateAllQuery(Employee.class);
    updateQuery.addUpdate("address", null);
    updateAllQueryInternal(updateQuery);
}
Also used : UpdateAllQuery(org.eclipse.persistence.queries.UpdateAllQuery)

Example 18 with UpdateAllQuery

use of org.eclipse.persistence.queries.UpdateAllQuery in project eclipselink by eclipse-ee4j.

the class UpdateAllQueryAdvancedJunitTest method testFirstNamePrefixBLAForAll.

public static void testFirstNamePrefixBLAForAll() {
    ExpressionBuilder builder = new ExpressionBuilder();
    UpdateAllQuery updateQuery = new UpdateAllQuery(Employee.class);
    updateQuery.addUpdate("firstName", Expression.fromLiteral("'BLA'", null).concat(builder.get("firstName")));
    updateAllQueryInternal(updateQuery);
}
Also used : ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) UpdateAllQuery(org.eclipse.persistence.queries.UpdateAllQuery)

Example 19 with UpdateAllQuery

use of org.eclipse.persistence.queries.UpdateAllQuery in project eclipselink by eclipse-ee4j.

the class UpdateAllQueryAdvancedJunitTest method testFirstNamePrefixBLADoubleSalaryForAll.

public static void testFirstNamePrefixBLADoubleSalaryForAll() {
    ExpressionBuilder builder = new ExpressionBuilder();
    UpdateAllQuery updateQuery = new UpdateAllQuery(Employee.class);
    updateQuery.addUpdate("firstName", Expression.fromLiteral("'BLA'", null).concat(builder.get("firstName")));
    updateQuery.addUpdate("salary", ExpressionMath.multiply(builder.get("salary"), Integer.valueOf(2)));
    updateAllQueryInternal(updateQuery);
}
Also used : ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) UpdateAllQuery(org.eclipse.persistence.queries.UpdateAllQuery)

Example 20 with UpdateAllQuery

use of org.eclipse.persistence.queries.UpdateAllQuery in project eclipselink by eclipse-ee4j.

the class UpdateAllQueryAdvancedJunitTest method testFirstNamePrefixBLADoubleSalaryForSalaryForFirstName.

public static void testFirstNamePrefixBLADoubleSalaryForSalaryForFirstName() {
    ExpressionBuilder builder = new ExpressionBuilder();
    Expression selectionExpression = builder.get("salary").lessThan(20000).and(builder.get("firstName").like("J%"));
    UpdateAllQuery updateQuery = new UpdateAllQuery(Employee.class, selectionExpression);
    updateQuery.addUpdate("firstName", Expression.fromLiteral("'BLA'", null).concat(builder.get("firstName")));
    updateQuery.addUpdate("salary", ExpressionMath.multiply(builder.get("salary"), Integer.valueOf(2)));
    updateAllQueryInternal(updateQuery);
}
Also used : Expression(org.eclipse.persistence.expressions.Expression) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) UpdateAllQuery(org.eclipse.persistence.queries.UpdateAllQuery)

Aggregations

UpdateAllQuery (org.eclipse.persistence.queries.UpdateAllQuery)57 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)36 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)22 Expression (org.eclipse.persistence.expressions.Expression)19 EntityManager (jakarta.persistence.EntityManager)13 DeleteAllQuery (org.eclipse.persistence.queries.DeleteAllQuery)12 ReportQuery (org.eclipse.persistence.queries.ReportQuery)10 ArrayList (java.util.ArrayList)9 List (java.util.List)9 Vector (java.util.Vector)9 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)8 Iterator (java.util.Iterator)7 HashMap (java.util.HashMap)5 Map (java.util.Map)4 IdentityHashMap (java.util.IdentityHashMap)3 DataExpression (org.eclipse.persistence.internal.expressions.DataExpression)3 ExpressionIterator (org.eclipse.persistence.internal.expressions.ExpressionIterator)3 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)3 ConstantExpression (org.eclipse.persistence.internal.expressions.ConstantExpression)2 FieldExpression (org.eclipse.persistence.internal.expressions.FieldExpression)2