Skip to content

Commit 716e75b

Browse files
Merge pull request #137 from xdev-software/HSQL-support
Hsql support
2 parents f122366 + 47dc3fc commit 716e75b

23 files changed

Lines changed: 970 additions & 160 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.2.0
2+
3+
* Implemented ``@Query`` annotation with simple SQL-Selects
4+
15
# 2.1.0
26

37
* Implemented auto-id-generation for UUIDs.

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.1.0'
4+
display_version: '2.2.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.1.0'
12-
maven-version: '2.1.0'
11+
display-version: '2.2.0'
12+
maven-version: '2.2.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: 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.1.0-SNAPSHOT</version>
9+
<version>2.2.0-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111

1212
<organization>

spring-data-eclipse-store-benchmark/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>software.xdev</groupId>
77
<artifactId>spring-data-eclipse-store-root</artifactId>
8-
<version>2.1.0-SNAPSHOT</version>
8+
<version>2.2.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>spring-data-eclipse-store-benchmark</artifactId>

spring-data-eclipse-store-demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>software.xdev</groupId>
99
<artifactId>spring-data-eclipse-store-root</artifactId>
10-
<version>2.1.0-SNAPSHOT</version>
10+
<version>2.2.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>spring-data-eclipse-store-demo</artifactId>

0 commit comments

Comments
 (0)