Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0635abd
Update net.sourceforge.pmd to v7.4.0
xdev-renovate Jul 27, 2024
8a03acb
Merge pull request #87 from xdev-software/renovate/net.sourceforge.pmd
AB-xdev Jul 29, 2024
0e9e707
Merge pull request #133 from xdev-software/master
JohannesRabauer Aug 1, 2024
d994a2d
Update antora.yml
JohannesRabauer Aug 1, 2024
5c841fc
Update antora.yml
JohannesRabauer Aug 1, 2024
78d8d68
Updated version
JohannesRabauer Aug 1, 2024
851ff87
Added Auto UUID
JohannesRabauer Aug 1, 2024
ee3d3ee
Simplest test with Custom Class as id
JohannesRabauer Aug 1, 2024
54745dd
Tests with EmbeddedIds and CustomId-classes
JohannesRabauer Aug 1, 2024
eebf560
Updated docs and implemented check for multiple versions and ids
JohannesRabauer Aug 1, 2024
b8d9d55
Added JavaDoc
JohannesRabauer Aug 1, 2024
9de24c4
Update .gitignore
JohannesRabauer Aug 1, 2024
1acd1b0
Fixed tests
JohannesRabauer Aug 1, 2024
522804b
Merge pull request #134 from xdev-software/composite-primary-keys
JohannesRabauer Aug 1, 2024
7370106
Restructured query tests
JohannesRabauer Aug 1, 2024
53b3423
Added plenty more tests for queries
JohannesRabauer Aug 1, 2024
2d4b3d4
Added Ignore Case keyword for queries
JohannesRabauer Aug 1, 2024
7bb00cc
Update CHANGELOG.md
JohannesRabauer Aug 1, 2024
45ac7db
Update User.java
JohannesRabauer Aug 1, 2024
f4b3710
Merge pull request #135 from xdev-software/query-keywords
JohannesRabauer Aug 1, 2024
d573021
Added ANTLR Support and basic queryProvider
JohannesRabauer Aug 2, 2024
0ad7f77
Create Test infrastructure for HsqlTests
JohannesRabauer Aug 2, 2024
f122366
Merge branch 'develop' into update-from-template-merged
xdev-gh-bot Aug 5, 2024
512d03e
Finished creating tests for HSQL
JohannesRabauer Aug 5, 2024
eb84f3b
Update HSqlQueryProvider.java
JohannesRabauer Aug 5, 2024
1fc4c0f
Switching from Antlr to CQEngine for SQL-Interpretation
JohannesRabauer Aug 5, 2024
9b88b08
Added basic working sql queries
JohannesRabauer Aug 6, 2024
64ce9da
Merge branch 'develop' into HSQL-support
JohannesRabauer Aug 6, 2024
bc4d869
Updated version and docs
JohannesRabauer Aug 6, 2024
453cab1
Refactoring
JohannesRabauer Aug 6, 2024
47dc3fc
Refactor
JohannesRabauer Aug 6, 2024
716e75b
Merge pull request #137 from xdev-software/HSQL-support
JohannesRabauer Aug 6, 2024
c3d8396
Changed version
JohannesRabauer Aug 6, 2024
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
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ hs_err_pid*
.tern-project

# EclipseStore
storage
storage-person
storage-invoice
storage-complex
storage-eclipsestore
spring-data-eclipse-store/storage
spring-data-eclipse-store-demo/storage
spring-data-eclipse-store-demo/storage-person
spring-data-eclipse-store-demo/storage-invoice
spring-data-eclipse-store-demo/storage-complex
spring-data-eclipse-store-jpa/storage-eclipsestore
spring-data-eclipse-store-jpa/storage-h2.mv.db
spring-data-eclipse-store-jpa/storage-h2.trace.db

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 2.1.0

* Implemented auto-id-generation for UUIDs.
* Implemented composite primary keys.
* Keyword "ignoreCase" now available for queries.
* Implemented ``@Query`` annotation with simple SQL-Selects

# 2.0.1

* Fix for Issue [#131](https://github.com/xdev-software/spring-data-eclipse-store/issues/131)
Expand Down
6 changes: 3 additions & 3 deletions docs/antora.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: ROOT
title: Spring-Data-Eclipse-Store
version: master
display_version: '2.0.0'
display_version: '2.1.0'
start_page: index.adoc
nav:
- modules/ROOT/nav.adoc
asciidoc:
attributes:
product-name: 'Spring-Data-Eclipse-Store'
display-version: '2.0.0'
maven-version: '2.0.0'
display-version: '2.1.0'
maven-version: '2.1.0'
page-editable: false
page-out-of-support: false
4 changes: 3 additions & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
* xref:configuration.adoc[Configuration]
* xref:working-copies.adoc[Working Copies]
* xref:features/features.adoc[Features]
** xref:features/ids.adoc[IDs]
** xref:features/lazies.adoc[Lazy References]
** xref:features/queries.adoc[Queries]
** xref:features/transactions.adoc[Transactions]
** xref:features/versions.adoc[Versions]
* xref:migration.adoc[Migration]
* xref:migration.adoc[Migration from JPA]
* xref:known-issues.adoc[Known issues]
2 changes: 2 additions & 0 deletions docs/modules/ROOT/pages/features/features.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
= Features

* xref:features/ids.adoc[IDs]
* xref:features/lazies.adoc[Lazy References]
* xref:features/queries.adoc[Queries]
* xref:features/transactions.adoc[Transactions]
* xref:features/versions.adoc[Versions]
19 changes: 19 additions & 0 deletions docs/modules/ROOT/pages/features/ids.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
= IDs

{product-name} supports the following types with auto generating (``GenerationType.AUTO``) values:

* ``int`` / ``Integer``
* ``long`` / ``Long``
* ``String``
* ``UUID``

Other generation types are currently not supported.

== Composite keys

It is possible to use **any class as https://jakarta.ee/specifications/persistence/3.2/apidocs/jakarta.persistence/jakarta/persistence/id[``@Id``]** but without any auto generation.
Most importantly the used class **must have a valid ``hashCode``** since a ``HashMap`` is used to store and manage entities.

{product-name} can also handle https://jakarta.ee/specifications/persistence/3.2/apidocs/jakarta.persistence/jakarta/persistence/embeddedid[``@EmbeddedId``] which results in the same behavior as ``@Id`` but the id-class must then implement ``Serializable``.

Multiple Ids for a single entity and https://jakarta.ee/specifications/persistence/3.2/apidocs/jakarta.persistence/jakarta/persistence/idclass[``@IdClass``] are **not** supported.
73 changes: 73 additions & 0 deletions docs/modules/ROOT/pages/features/queries.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
= Queries

== Keywords

It is possible to use **most of the standard query keywords** for repositories defined in Spring Data JPA: https://docs.spring.io/spring-data/jpa/reference/repositories/query-keywords-reference.html[Spring Data JPA - Repository query keywords].

Here are a few examples:

[source,java]
----
@Repository
public interface UserRepository extends EclipseStoreRepository<User, Long>
{
List<User> findByFirstName(String firstName, String lastName);
List<User> findByFirstNameAndLastName(String firstName, String lastName);
List<User> findByDateOfBirthBefore(LocalDate date);
List<User> findByAgeIn(List<Integer> ages);
List<User> findByIsActiveFalse();
}
----

More examples are in the https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/query/by/string/UserRepository.java[test-cases].

== Query by Example

Developers can also use https://docs.spring.io/spring-data/jpa/reference/repositories/query-by-example.html[Query by Example] if preferred.

An example:

[source,java]
----
public List<User> findAllUsersNamedMick()
{
final User probe = new User(1, "Mick", BigDecimal.TEN);
return userRepository.findAll(Example.of(probe));
}
----

More examples are in the https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/query/by/example/QueryByExampleTest.java[test-cases].

== @Query annotation

The support for a ``@Query``-Annotation is currently quite limited, but useful nonetheless.

To keep parse and execute SQL-Queries we use the https://github.com/npgall/cqengine[cqengine] by https://github.com/npgall[Niall Gallagher].
It offers rudimentary support of some SQL-Queries, but not all.

[NOTE]
====
https://github.com/npgall/cqengine[cqengine] parses the SQL String as a SQLite-SQL-String and is therefore different from the https://docs.spring.io/spring-data/jpa/reference/jpa/query-methods.html#jpa.query-methods.at-query[HQL or JPQL] of Spring Data JPA.
====

Here are some working examples:

[source,java]
----
public interface MyEntityRepository extends ListCrudRepository<MyEntity, Long>
{
@Query("SELECT * FROM MyEntity WHERE name = '?1'")
List<MyEntity> findByName(String name);

@Query("SELECT * FROM MyEntity WHERE (name = '?1' AND age > ?2)")
List<MyEntity> findByNameAndAgeGreaterThan(String name, int age);

@Query("SELECT * FROM MyEntity WHERE 'name' LIKE '%?1%'")
List<MyEntity> findByNameContaining(String keyword);

@Query("SELECT * FROM MyEntity WHERE otherEntity IS NOT NULL")
List<MyEntity> findWhereOtherEntityIsNotNull();
}
----

More examples are in the https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/query/hsql/MyEntityRepository.java[test-cases].
12 changes: 0 additions & 12 deletions docs/modules/ROOT/pages/known-issues.adoc
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
= Known issues

== Query annotations

In Spring-Data-JPA you can write a Query over methods of repositories like this:

[source,java,title="From https://github.com/spring-projects/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/owner/OwnerRepository.java[spring-petclinic]"]
----
@Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name")
List<PetType> findPetTypes();
----

We created https://github.com/xdev-software/spring-data-eclipse-store/issues/32[an issue] for that but right now we *do not support Query annotations*.

== Data changes

There are two basic ways to keep your data up to date.
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/migration.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= Migration
= Migration from JPA

Migrating from Spring Data JPA is very easy.
We implemented a https://github.com/xdev-software/spring-data-eclipse-store-migration[OpenRewrite recipe] for that.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>software.xdev</groupId>
<artifactId>spring-data-eclipse-store-root</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>
<packaging>pom</packaging>

<organization>
Expand Down
4 changes: 2 additions & 2 deletions spring-data-eclipse-store-benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>software.xdev</groupId>
<artifactId>spring-data-eclipse-store-root</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>
</parent>

<artifactId>spring-data-eclipse-store-benchmark</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<inceptionYear>2023</inceptionYear>
Expand Down
4 changes: 2 additions & 2 deletions spring-data-eclipse-store-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>software.xdev</groupId>
<artifactId>spring-data-eclipse-store-root</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>
</parent>

<artifactId>spring-data-eclipse-store-demo</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<organization>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package software.xdev.spring.data.eclipse.store.demo.dual.storage;

import java.io.File;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import software.xdev.spring.data.eclipse.store.demo.TestUtil;
import software.xdev.spring.data.eclipse.store.demo.dual.storage.invoice.PersistenceInvoiceConfiguration;
import software.xdev.spring.data.eclipse.store.demo.dual.storage.person.PersistencePersonConfiguration;


@SpringBootTest(classes = DualStorageDemoApplication.class)
class DualStorageDemoApplicationTest
{
private final PersistenceInvoiceConfiguration invoiceConfiguration;
private final PersistencePersonConfiguration personConfiguration;

@Autowired
public DualStorageDemoApplicationTest(
final PersistenceInvoiceConfiguration invoiceConfiguration,
final PersistencePersonConfiguration personConfiguration)
{
this.invoiceConfiguration = invoiceConfiguration;
this.personConfiguration = personConfiguration;
}

@BeforeAll
static void clearPreviousData()
{
TestUtil.deleteDirectory(new File("./" + PersistenceInvoiceConfiguration.STORAGE_PATH));
TestUtil.deleteDirectory(new File("./" + PersistencePersonConfiguration.STORAGE_PATH));
}

@Test
void checkPossibilityToSimplyStartAndRestartApplication()
{
this.invoiceConfiguration.getStorageInstance().stop();
this.personConfiguration.getStorageInstance().stop();
DualStorageDemoApplication.main(new String[]{});
}
}
4 changes: 2 additions & 2 deletions spring-data-eclipse-store-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>software.xdev</groupId>
<artifactId>spring-data-eclipse-store-root</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>
</parent>

<artifactId>spring-data-eclipse-store-jpa</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<inceptionYear>2023</inceptionYear>
Expand Down
23 changes: 22 additions & 1 deletion spring-data-eclipse-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>software.xdev</groupId>
<artifactId>spring-data-eclipse-store</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>spring-data-eclipse-store</name>
Expand Down Expand Up @@ -47,6 +47,7 @@
<maven.compiler.release>${javaVersion}</maven.compiler.release>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- Should be in sync with org.eclipse.store:integrations-spring-boot3 -->
Expand Down Expand Up @@ -163,6 +164,26 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.googlecode.cqengine</groupId>
<artifactId>cqengine</artifactId>
<version>3.6.0</version>
<exclusions>
<exclusion>
<artifactId>kryo</artifactId>
<groupId>com.esotericsoftware</groupId>
</exclusion>
<exclusion>
<artifactId>kryo-serializers</artifactId>
<groupId>de.javakaffee</groupId>
</exclusion>
<exclusion>
<artifactId>sqlite-jdbc</artifactId>
<groupId>org.xerial</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package software.xdev.spring.data.eclipse.store.exceptions;

public class IdFieldFinalException extends RuntimeException
public class IdFieldException extends RuntimeException
{
public IdFieldFinalException(final String message)
public IdFieldException(final String message)
{
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
@QueryAnnotation
public @interface Query
{
@SuppressWarnings("unused") String value() default "";
String value() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ private AbstractCriteriaNode<T> from(
{
Objects.requireNonNull(criteria);
final Part.Type type = Objects.requireNonNull(part).getType();
final Part.IgnoreCaseType ignoreCaseType = part.shouldIgnoreCase();
final boolean doIgnoreCase =
ignoreCaseType == Part.IgnoreCaseType.ALWAYS || ignoreCaseType == Part.IgnoreCaseType.WHEN_POSSIBLE;

switch(type)
{
Expand Down Expand Up @@ -169,27 +172,27 @@ private AbstractCriteriaNode<T> from(
}
case LIKE ->
{
return criteria.like((String)Objects.requireNonNull(parameters).next());
return criteria.like((String)Objects.requireNonNull(parameters).next(), doIgnoreCase);
}
case STARTING_WITH ->
{
return criteria.startWith((String)Objects.requireNonNull(parameters).next());
return criteria.startWith((String)Objects.requireNonNull(parameters).next(), doIgnoreCase);
}
case ENDING_WITH ->
{
return criteria.endWith((String)Objects.requireNonNull(parameters).next());
return criteria.endWith((String)Objects.requireNonNull(parameters).next(), doIgnoreCase);
}
case CONTAINING ->
{
return criteria.containing((String)Objects.requireNonNull(parameters).next());
return criteria.containing((String)Objects.requireNonNull(parameters).next(), doIgnoreCase);
}
case NOT_LIKE ->
{
return criteria.notLike((String)Objects.requireNonNull(parameters).next());
return criteria.notLike((String)Objects.requireNonNull(parameters).next(), doIgnoreCase);
}
case NOT_CONTAINING ->
{
return criteria.notContaining((String)Objects.requireNonNull(parameters).next());
return criteria.notContaining((String)Objects.requireNonNull(parameters).next(), doIgnoreCase);
}
case EXISTS ->
{
Expand Down
Loading