Skip to content

Commit 92932e8

Browse files
Merge pull request #138 from xdev-software/develop
v2.1.0
2 parents f7263f4 + c3d8396 commit 92932e8

File tree

62 files changed

+3616
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3616
-622
lines changed

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ hs_err_pid*
6262
.tern-project
6363

6464
# EclipseStore
65-
storage
66-
storage-person
67-
storage-invoice
68-
storage-complex
69-
storage-eclipsestore
65+
spring-data-eclipse-store/storage
66+
spring-data-eclipse-store-demo/storage
67+
spring-data-eclipse-store-demo/storage-person
68+
spring-data-eclipse-store-demo/storage-invoice
69+
spring-data-eclipse-store-demo/storage-complex
70+
spring-data-eclipse-store-jpa/storage-eclipsestore
7071
spring-data-eclipse-store-jpa/storage-h2.mv.db
7172
spring-data-eclipse-store-jpa/storage-h2.trace.db
7273

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 2.1.0
2+
3+
* Implemented auto-id-generation for UUIDs.
4+
* Implemented composite primary keys.
5+
* Keyword "ignoreCase" now available for queries.
6+
* Implemented ``@Query`` annotation with simple SQL-Selects
7+
18
# 2.0.1
29

310
* Fix for Issue [#131](https://github.com/xdev-software/spring-data-eclipse-store/issues/131)

docs/antora.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: ROOT
22
title: Spring-Data-Eclipse-Store
33
version: master
4-
display_version: '2.0.0'
4+
display_version: '2.1.0'
55
start_page: index.adoc
66
nav:
77
- modules/ROOT/nav.adoc
88
asciidoc:
99
attributes:
1010
product-name: 'Spring-Data-Eclipse-Store'
11-
display-version: '2.0.0'
12-
maven-version: '2.0.0'
11+
display-version: '2.1.0'
12+
maven-version: '2.1.0'
1313
page-editable: false
1414
page-out-of-support: false

docs/modules/ROOT/nav.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
* xref:configuration.adoc[Configuration]
44
* xref:working-copies.adoc[Working Copies]
55
* xref:features/features.adoc[Features]
6+
** xref:features/ids.adoc[IDs]
67
** xref:features/lazies.adoc[Lazy References]
8+
** xref:features/queries.adoc[Queries]
79
** xref:features/transactions.adoc[Transactions]
810
** xref:features/versions.adoc[Versions]
9-
* xref:migration.adoc[Migration]
11+
* xref:migration.adoc[Migration from JPA]
1012
* xref:known-issues.adoc[Known issues]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
= Features
22

3+
* xref:features/ids.adoc[IDs]
34
* xref:features/lazies.adoc[Lazy References]
5+
* xref:features/queries.adoc[Queries]
46
* xref:features/transactions.adoc[Transactions]
57
* xref:features/versions.adoc[Versions]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
= IDs
2+
3+
{product-name} supports the following types with auto generating (``GenerationType.AUTO``) values:
4+
5+
* ``int`` / ``Integer``
6+
* ``long`` / ``Long``
7+
* ``String``
8+
* ``UUID``
9+
10+
Other generation types are currently not supported.
11+
12+
== Composite keys
13+
14+
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.
15+
Most importantly the used class **must have a valid ``hashCode``** since a ``HashMap`` is used to store and manage entities.
16+
17+
{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``.
18+
19+
Multiple Ids for a single entity and https://jakarta.ee/specifications/persistence/3.2/apidocs/jakarta.persistence/jakarta/persistence/idclass[``@IdClass``] are **not** supported.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
= Queries
2+
3+
== Keywords
4+
5+
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].
6+
7+
Here are a few examples:
8+
9+
[source,java]
10+
----
11+
@Repository
12+
public interface UserRepository extends EclipseStoreRepository<User, Long>
13+
{
14+
List<User> findByFirstName(String firstName, String lastName);
15+
List<User> findByFirstNameAndLastName(String firstName, String lastName);
16+
List<User> findByDateOfBirthBefore(LocalDate date);
17+
List<User> findByAgeIn(List<Integer> ages);
18+
List<User> findByIsActiveFalse();
19+
}
20+
----
21+
22+
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].
23+
24+
== Query by Example
25+
26+
Developers can also use https://docs.spring.io/spring-data/jpa/reference/repositories/query-by-example.html[Query by Example] if preferred.
27+
28+
An example:
29+
30+
[source,java]
31+
----
32+
public List<User> findAllUsersNamedMick()
33+
{
34+
final User probe = new User(1, "Mick", BigDecimal.TEN);
35+
return userRepository.findAll(Example.of(probe));
36+
}
37+
----
38+
39+
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].
40+
41+
== @Query annotation
42+
43+
The support for a ``@Query``-Annotation is currently quite limited, but useful nonetheless.
44+
45+
To keep parse and execute SQL-Queries we use the https://github.com/npgall/cqengine[cqengine] by https://github.com/npgall[Niall Gallagher].
46+
It offers rudimentary support of some SQL-Queries, but not all.
47+
48+
[NOTE]
49+
====
50+
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.
51+
====
52+
53+
Here are some working examples:
54+
55+
[source,java]
56+
----
57+
public interface MyEntityRepository extends ListCrudRepository<MyEntity, Long>
58+
{
59+
@Query("SELECT * FROM MyEntity WHERE name = '?1'")
60+
List<MyEntity> findByName(String name);
61+
62+
@Query("SELECT * FROM MyEntity WHERE (name = '?1' AND age > ?2)")
63+
List<MyEntity> findByNameAndAgeGreaterThan(String name, int age);
64+
65+
@Query("SELECT * FROM MyEntity WHERE 'name' LIKE '%?1%'")
66+
List<MyEntity> findByNameContaining(String keyword);
67+
68+
@Query("SELECT * FROM MyEntity WHERE otherEntity IS NOT NULL")
69+
List<MyEntity> findWhereOtherEntityIsNotNull();
70+
}
71+
----
72+
73+
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].

docs/modules/ROOT/pages/known-issues.adoc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
= Known issues
22

3-
== Query annotations
4-
5-
In Spring-Data-JPA you can write a Query over methods of repositories like this:
6-
7-
[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]"]
8-
----
9-
@Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name")
10-
List<PetType> findPetTypes();
11-
----
12-
13-
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*.
14-
153
== Data changes
164

175
There are two basic ways to keep your data up to date.

docs/modules/ROOT/pages/migration.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Migration
1+
= Migration from JPA
22

33
Migrating from Spring Data JPA is very easy.
44
We implemented a https://github.com/xdev-software/spring-data-eclipse-store-migration[OpenRewrite recipe] for that.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>spring-data-eclipse-store-root</artifactId>
9-
<version>2.0.2-SNAPSHOT</version>
9+
<version>2.2.0-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111

1212
<organization>

0 commit comments

Comments
 (0)