generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 139
Describe usage of H2 in Java #2207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eugene-andreev
wants to merge
20
commits into
main
Choose a base branch
from
h2-in-java
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+108
−24
Open
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fa93774
H2 in Java
eugene-andreev 57e6207
wip
eugene-andreev 4efb33c
wip
eugene-andreev 95a58d4
Inspecting H2 in-memory database on the fly
eugene-andreev 3ccf4c3
typos
eugene-andreev af64834
Merge branch 'main' into h2-in-java
eugene-andreev 1e1ed26
Merge branch 'main' into h2-in-java
eugene-andreev 61246b1
dev tools
eugene-andreev 0a0a109
Merge remote-tracking branch 'origin/h2-in-java' into h2-in-java
eugene-andreev 442b09e
Merge branch 'main' into h2-in-java
eugene-andreev dc001a4
improve
eugene-andreev 0be9942
Merge remote-tracking branch 'origin/h2-in-java' into h2-in-java
eugene-andreev f9b9d9d
Merge remote-tracking branch 'origin/main' into h2-in-java
eugene-andreev 45fd77f
address comments 1
eugene-andreev 35114d6
Merge remote-tracking branch 'origin/main' into h2-in-java
eugene-andreev 05ec1ba
yamls
eugene-andreev f680ada
address comments 2
eugene-andreev 6484a5d
fix dead link
eugene-andreev d26bd84
fix punctuation
renejeglinsky b1d69cc
edit
renejeglinsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,77 @@ | ||
| --- | ||
| synopsis: > | ||
| This section shows the DB of choice for CAP Java. | ||
| status: released | ||
| --- | ||
|
|
||
| # H2 configuration and usage in CAP Java | ||
eugene-andreev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <style scoped> | ||
| h1:before { | ||
| content: "Java"; display: block; font-size: 60%; margin: 0 0 .2em; | ||
| } | ||
| </style> | ||
|
|
||
| {{ $frontmatter.synopsis }} | ||
|
|
||
|
|
||
| This section describes the H2 configuration and usage in CAP Java projects. It also provides links and further information on Development and Inspection Tools. | ||
|
|
||
| ## Why use H2 | ||
|
|
||
| H2 is the preffered database for CAP Java applications. It offers a combination of features making it the best candidate for local development and testing. | ||
eugene-andreev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| * **Easy Configuration and Spring Boot Integration** | ||
| H2 is easy to configure, with minimal setup required to get started. Its seamless integration with Spring Boot applications means you can focus on building features rather than wrestling with complex database configurations. | ||
|
|
||
| * **Enterprise-Grade Security** | ||
| Security is built into H2's core, featuring authentication mechanisms, encryption functions, and other security features that protect your data and ensure compliance with security standards. | ||
eugene-andreev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| * **Transaction Management** | ||
| H2 implements robust transaction support including two-phase commit capabilities, enabling reliable data consistency and coordination across multiple resources in distributed systems. | ||
eugene-andreev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| * **Concurrent Access and Locking** | ||
| The database supports multiple concurrent connections and implements row-level locking, allowing safe parallel data access without data corruption or race conditions. | ||
|
|
||
| * **Open Source and Java Native** | ||
| As an open-source database written entirely in Java, H2 offers transparency, flexibility, and the benefit of being maintained by an active community. Its Java implementation ensures optimal integration with Java-based applications and platforms. | ||
|
|
||
| * **Administrative Tools** | ||
| H2 includes a built-in web console application, providing a user-friendly interface for database administration, query execution, and data inspection without requiring external tools. | ||
eugene-andreev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## How to configure H2 | ||
|
|
||
| The section [Using H2 for Development in CAP Java](../guides/databases-h2.md) describes how to set-up and configure the H2 via Maven Archetype and manually. | ||
eugene-andreev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ## H2 limitations | ||
eugene-andreev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The [Limitations](../java/cqn-services/persistence-services#h2-database) section describes the known limitation of H2. | ||
|
|
||
| ### Overcome the limitations with Hybrid Tests | ||
|
|
||
| Although CAP Java enables running and testing applications with a local H2 database, still there could be cases when this is not possible due to some limitations, mentioned above. In that case hybrid testing capabilities help you stay in a local development environment and avoid long turnaround times of cloud deployments, by selectively connecting to services in the cloud. | ||
|
|
||
| The section [Hybrid Testing](../advanced/hybrid-testing#run-cap-java-apps-with-service-bindings) describes the steps on how to configure and consume the remote services, including SAP HANA, in local environment. | ||
|
|
||
| ## H2 and Srping Dev Tools | ||
eugene-andreev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| [TODO] describe and link | ||
| [Spring Dev Tools](https://docs.spring.io/spring-boot/reference/using/devtools.html) | ||
|
|
||
|
|
||
| ## Logging SQL to console | ||
| To view the generated SQL, which will be executed against the database in your local environment, it is also possible to enable `DEBUG` log output by adding the certain log levels in `application.yaml` | ||
|
|
||
| ```yml | ||
| logging: | ||
| level: | ||
| com.sap.cds.persistence.sql: DEBUG | ||
| ``` | ||
| This comes handy especially in situations, when the CAP Java developers needs to track runtime or a Java Application behavior. | ||
| To learn more about loggers, refer to [Predefined Loggers](https://cap.cloud.sap/docs/java/operating-applications/observability#predefined-loggers) | ||
| ## Inspecting with CDS Tools | ||
eugene-andreev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [TODO] what exactly we can inspect with Tools? | ||
eugene-andreev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.