Skip to content

Commit

Permalink
Updated project to Java 21, migrated to Jakarta namespace and updated…
Browse files Browse the repository at this point in the history
… dependencies to latest version.
  • Loading branch information
divjad--- committed Nov 29, 2023
1 parent 54bb123 commit 74e3e36
Show file tree
Hide file tree
Showing 33 changed files with 115 additions and 93 deletions.
6 changes: 3 additions & 3 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>kumuluzee-rest</artifactId>
<groupId>com.kumuluz.ee.rest</groupId>
<version>2.1.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<name>KumuluzEE REST Core</name>
Expand All @@ -17,8 +17,8 @@

<dependencies>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>
<dependency>
<groupId>org.parboiled</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
*/
package com.kumuluz.ee.rest.beans;

import javax.persistence.criteria.Path;
import jakarta.persistence.criteria.Path;

import java.io.Serializable;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
*/
package com.kumuluz.ee.rest.beans;

import javax.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Predicate;

import java.io.Serializable;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void setFields(List<String> fields) {
* {@link #addFilterExpression(FilterExpressionOperation, QueryFilterExpression)} ()} instead.
*/
public void addFilter(QueryFilter filter) {
if(filter != null) {
if (filter != null) {
getFilters().add(filter);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*/
package com.kumuluz.ee.rest.interfaces;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;

/**
* @author Tilen Faganel
Expand Down
41 changes: 21 additions & 20 deletions core/src/main/java/com/kumuluz/ee/rest/utils/JPAUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
import com.kumuluz.ee.rest.exceptions.NoSuchEntityFieldException;
import com.kumuluz.ee.rest.exceptions.QueryFormatException;
import com.kumuluz.ee.rest.interfaces.CriteriaFilter;
import jakarta.persistence.EntityManager;
import jakarta.persistence.Tuple;
import jakarta.persistence.TupleElement;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.*;
import jakarta.persistence.metamodel.*;

import javax.persistence.EntityManager;
import javax.persistence.Tuple;
import javax.persistence.TupleElement;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.*;
import javax.persistence.metamodel.*;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -194,7 +194,7 @@ public static <T> List<T> queryEntities(EntityManager em, Class<T> entity, Query
}

private static <T> Optional<TypedQuery<T>> buildQuery(EntityManager em, Class<T> entity, QueryParameters q, CriteriaFilter<T> customFilter,
List<QueryHintPair> queryHints, String rootAlias, boolean forceDistinct) {
List<QueryHintPair> queryHints, String rootAlias, boolean forceDistinct) {
if (em == null || entity == null)
throw new IllegalArgumentException("The entity manager and the entity cannot be null.");

Expand Down Expand Up @@ -384,17 +384,17 @@ public static List<Selection<?>> createFieldsSelect(Root<?> r, QueryParameters q
// Temporary methods to not break the public API

private static <T> Optional<TypedQuery<T>> buildQuerySimple(EntityManager em, Class<T> entity, QueryParameters q,
CriteriaFilter<T> customFilter,
List<QueryHintPair> queryHints, String rootAlias,
boolean forceDistinct) {
CriteriaFilter<T> customFilter,
List<QueryHintPair> queryHints, String rootAlias,
boolean forceDistinct) {
return buildQuerySimple(em, entity, q, customFilter, queryHints, rootAlias, forceDistinct, false);
}

@SuppressWarnings("unchecked")
private static <T> Optional<TypedQuery<T>> buildQuerySimple(EntityManager em, Class<T> entity, QueryParameters q,
CriteriaFilter<T> customFilter,
List<QueryHintPair> queryHints, String rootAlias,
boolean forceDistinct, boolean ignorePaging) {
CriteriaFilter<T> customFilter,
List<QueryHintPair> queryHints, String rootAlias,
boolean forceDistinct, boolean ignorePaging) {

LOG.finest("Querying entity: '" + entity.getSimpleName() + "' with parameters: " + q + "(simple)");

Expand Down Expand Up @@ -478,9 +478,9 @@ private static <T> Optional<TypedQuery<T>> buildQuerySimple(EntityManager em, Cl

@SuppressWarnings("unchecked")
private static <T> Optional<TypedQuery<T>> buildQueryAdvanced(EntityManager em, Class<T> entity, QueryParameters q,
CriteriaFilter<T> customFilter,
List<QueryHintPair> queryHints, String rootAlias,
boolean forceDistinct) {
CriteriaFilter<T> customFilter,
List<QueryHintPair> queryHints, String rootAlias,
boolean forceDistinct) {

LOG.finest("Querying entity: '" + entity.getSimpleName() + "' with parameters: " + q + "(advanced)");

Expand Down Expand Up @@ -778,7 +778,7 @@ private static Predicate createWhereQueryInternal(EntityManager em, CriteriaBuil
);
}
}
} else if (isCollection) {
} else if (isCollection) {

String idField;

Expand Down Expand Up @@ -840,7 +840,7 @@ private static <T> Stream<T> createEntitiesFromTuples(List<Tuple> tuples, Class<
try {
el = entity.getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException |
NoSuchMethodException | InvocationTargetException e) {
NoSuchMethodException | InvocationTargetException e) {

throw new AssertionError();
}
Expand All @@ -864,7 +864,8 @@ private static <T> Stream<T> createEntitiesFromTuples(List<Tuple> tuples, Class<
String[] fName = te.getAlias().split("\\.");

createEntityFromTuple(fName, entity, el, o, i);
} catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException | InstantiationException e) {
} catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException |
InvocationTargetException | InstantiationException e) {

throw new NoSuchEntityFieldException(e.getMessage(), te.getAlias(), entity.getSimpleName());
}
Expand Down Expand Up @@ -1135,7 +1136,7 @@ private static CriteriaField getCriteriaField(String fieldName, Root<?> r, Map<S
String mappedFieldName = mappedFieldOptional.get();

String[] mappedFields = mappedFieldName.split("\\.");
for (String mappedField: mappedFields) {
for (String mappedField : mappedFields) {
fieldPath = fieldPath == null ? mappedField : fieldPath + "." + mappedField;

if (fieldJoins.containsKey(fieldPath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ private static StreamCriteriaWhereQuery createWhereQueryInternal(Class<?> clazz,

private static StreamCriteriaField getStreamCriteriaField(Class<?> clazz, String fieldName) {

if (fieldName == null) throw new NoSuchEntityFieldException("No such entity field", fieldName, clazz.getSimpleName());
if (fieldName == null)
throw new NoSuchEntityFieldException("No such entity field", fieldName, clazz.getSimpleName());

String[] fields = fieldName.split("\\.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.JPAUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.JPAUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.JPAUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.JPAUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.JPAUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.JPAUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.JPAUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
Expand Down
3 changes: 2 additions & 1 deletion core/src/test/java/com/kumuluz/ee/rest/test/QueriedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import jakarta.persistence.EntityManager;

import java.util.Arrays;
import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.JPAUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.StreamUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -72,7 +72,7 @@ public void testQueryCount() {
Long count = StreamUtils.queryEntitiesCount(users, q);

Assert.assertNotNull(count);
Assert.assertEquals( 2L, count.longValue());
Assert.assertEquals(2L, count.longValue());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.StreamUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.StreamUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import jakarta.persistence.EntityManager;

import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import com.kumuluz.ee.rest.test.entities.User;
import com.kumuluz.ee.rest.test.utils.JpaUtil;
import com.kumuluz.ee.rest.utils.StreamUtils;
import jakarta.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.kumuluz.ee.rest.test.entities;

import javax.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.kumuluz.ee.rest.test.entities;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;

/**
* @author gpor0
Expand Down
Loading

0 comments on commit 74e3e36

Please sign in to comment.