-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from xdev-software/develop
v2.1.0
- Loading branch information
Showing
62 changed files
with
3,616 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ware/xdev/spring/data/eclipse/store/demo/dual/storage/DualStorageDemoApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]{}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.