hxe-hibernate-google-app-engine
A Java demo application that runs Spring and Hibernate against a SAP HANASAP HANASAP’s relational database platform, which stores application data and executes SQL and SQLScript in the database, available on-premise and as the managed service SAP HANA Cloud.sap official, btp database, including geospatial queries through the HANA Hibernate Spatial dialect, locally or on Google App Engine.
Connecting a Java application to SAP HANASAP HANASAP’s relational database platform, which stores application data and executes SQL and SQLScript in the database, available on-premise and as the managed service SAP HANA Cloud.sap official, btp through Hibernate for more than standard SQL, such as geospatial data, means working out which dialect handles it. This demo loads a San Francisco police-incident dataset and an address dataset into HANA, then runs geospatial queries through the HANA Hibernate Spatial dialect executed by SAP HANA's geospatial engine, and can be run locally with Maven or deployed to Google App Engine. It can serve as a starting point for developing other Java applications, or to see how the connection and the queries are set up.
Facts
Where it sits
Who is behind it
In the atlas: maintains 222@SAP-samplesmaintainerAjinkya PatilContributes to this
In the atlas: contributes to 112@ajinkyapatil8190Jonathan BreglerContributes to this
In the atlas: contributes to 3@breglerjBrian BernardContributes to this
In the atlas: contributes to 64@btbernardJonathan BakerContributes to this
In the atlas: contributes to 9@jonathanbaker74 contributors
What it declares
Every artifact
- Type
- Sample
- Origin
- By SAP
As a sample
- Form
- A reference application
Connections
Connecting a data model and its queries to a database
SAP's relational database platform, on-premise and in HANA Cloud
SAP's relational database platform, on-premise and in HANA Cloud
Download
README
quoted from SAP-samples/hxe-hibernate-google-app-engine under Apache-2.0, readDescription
This project is a demo application illustrating how to build Java applications with Spring and Hibernate on SAP HANA. It can serve as a starting point for developing other Java applications or simply provide insights on how to set up an application and how to run queries against the database.
In addition to standard SQL queries this application also contains examples for geospatial queries. The geospatial queries are sent to the database via the HANA Hibernate Spatial dialect and executed by SAP HANA's geospatial engine.
Requirements
Hardware
- A computer that meets the Machine Requirements for SAP HANA, Express Edition
Software
- A Java runtime environment for Java 8 or greater
- Apache Maven
- A SAP HANA database instance, for example, a SAP HANA, Express Edition instance which can be obtained via the SAP HANA, Express Edition download page
- A Google Cloud Platform account for deploying the application to the cloud.
- A Google Cloud Platform API key for using the Google Maps Javascript API and the Google Cloud Translation API.
- The San Francisco Police Department Incidents data set as CSV
- The San Francisco Addresses data set as CSV
Download and Installation
Download
Clone this repository to your local computer.
Installation
NOTE: all relative paths are relative to the project root directory. All commands are expected to be run from the project root directory.
Copy the data sets
Place the incidents and addresses data sets into the src/main/resources/csv directory as incidents.csv and addresses.csv, respectively. If you prefer a different location or different file names you can adjust the configuration properties csv.incidents.file.location and csv.addresses.file.location in the file src/main/resources/application.properties.
Add the API key
Edit the file pom.xml and add your Google Cloud Platform API key as the value of the property google.api.key.
...
<properties>
...
<google.api.key>REPLACE_WITH_YOUR_API_KEY</google.api.key>
...
</properties>
...
Database setup
The database tables used for storing the application data are automatically created by the application using the SQL script located at src/main/resources/db/migration/V1__CreateSchema.sql.
Adjust the JDBC connection data
Edit the file pom.xml and adjust the properties jdbc.username, jdbc.password, jdbc.host, and jdbc.port to match the connection data of your SAP HANA instance.
...
<properties>
...
<jdbc.username>DEMO_USER</jdbc.username>
<jdbc.password>D3m0-U$eR</jdbc.password>
<jdbc.host>HOSTNAME OR IP</jdbc.host>
<jdbc.port>SQL PORT</jdbc.port>
...
</properties>
...
For local testing make sure to also adjust these properties in the m2e profile.
...
<profiles>
<profile>
<id>m2e</id>
...
<properties>
...
<jdbc.username>DEMO_USER</jdbc.username>
<jdbc.password>D3m0-U$eR</jdbc.password>
<jdbc.host>HOSTNAME OR IP</jdbc.host>
<jdbc.port>SQL PORT</jdbc.port>
...
</properties>
</profile>
</profiles>
...
Run the application locally
You can run the application by executing the following Maven command from the application's root directory:
> mvn spring-boot:run
If you have separated the configuration into a default cloud configuration and a local configuration using the m2e profile, you have to specify the profile ID when running the Maven command:
> mvn spring-boot:run -P m2e
NOTE: the first startup of the application can take a while, because the applications needs to load all the data from the CSV files. Subsequent startups will be much faster.
Once the application has started you can access it by navigating to http://localhost:8080 in a web browser.
Deploy the application to the Google Cloud Platform
Deploying the application to the cloud can be done using the configured Google App Engine Maven Plugin.
Before the application can be deployed to the cloud you must create a GCP project and add it's ID to the Maven build descriptor. To do this, edit the file pom.xml and replace the value of the property google.project.id with your actual project ID.
...
<properties>
...
<google.project.id>REPLACE_WITH_YOUR_PROJECT_ID</google.project.id>
...
</properties>
...
After that you can deploy the application to the cloud by running the following Maven command:
> mvn appengine:update
Once the application has been deployed you can access it by navigating to http://<your-project-id>.appspot.com in a web browser.
Configuration
The application can be configured using the properties in the file src/main/resources/application.properties.
Google Cloud Translation API
Translating the application UI using the Google Cloud Translation API is disabled by default. It can be enabled by setting the property translation.enabled to true.
translation.enabled=true
CSV file locations
The locations and names of the CSV files containing the incident and address data can be configured by setting the properties csv.incidents.file.location and csv.addresses.file.location, respectively.
csv.incidents.file.location=/csv/incidents.csv
csv.addresses.file.location=/csv/addresses.csv
JDBC batch size
If the database tables are empty, the application tries to load the data from the specified CSV files. Since there are many records to be imported, the import can be significantly sped up by using batch inserts. The size of a batch can be controlled by setting the property spring.jpa.properties.hibernate.jdbc.batch_size.
spring.jpa.properties.hibernate.jdbc.batch_size=50
The default batch size is 50, but you may want to experiment with larger values for the initial load.
Debugging SQL statements
If you want to debug the SQL statements that are sent to the database you can set the property spring.jpa.show-sql to true. Then the SQL statements are logged to the configured logger. If you also want to see the values of the statement parameters that are sent to or retrieved from the database you can set the logging level of org.hibernate.type.descriptor.sql.BasicBinder and org.hibernate.type.descriptor.sql.BasicExtractor to info.
spring.jpa.show-sql=true
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=info
logging.level.org.hibernate.type.descriptor.sql.BasicExtractor=info
Limitations
There are currently no limitations
Known Issues
There are currently no known issues
How to obtain support
This project is provided as-is. New features may be added occasionally.
There is no support for this project. You may raise issues via the issue tracker, but there is no guarantee they will be processed.
To-Do (upcoming changes)
Address search using SAP HANA full-text search
Currently the address search implementation uses standard SQL LIKE queries. This has several drawbacks:
- No ordering of results
- Only exact matches
These drawbacks can be addressed by using SAP HANA fuzzy text search.
License
Copyright (c) 2018-2026 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
History in the atlas
- First seen.
For your agent
- Ref
artifact:sap-samples-hxe-hibernate-google-app-engine- JSON
- /artifacts/sap-samples-hxe-hibernate-google-app-engine.json
- MCP
- Connecting an agent