Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
badge

Celesta Demo

This project demonstrates the simple RESTful service based on relational DB using Celesta and Spring Boot.

Build and Test

To build the project, run mvn verify: code for cursor classes will be generated in target\generated-sources\celesta... folder. Then you may run the Spring Boot application in App class.

This application exports two REST handlers.

{
	"id": "no1",
	"date": "2017-01-02",
	"customerId": "CUST1",
	"customerName": "John Doe",
	"lines": [{
			"itemId": "A",
			"qty": 5
		},
		{
			"itemId": "B",
			"qty": 4
		}
	]
}
{
   "A": 10,
   "B": 8
}

Database Structure

Database definition file is demo.sql.

You can try to modify it and re-run the application on non-empty database (see below how to connect to PostgreSQL) to test the automatic migration facility.

Unit tests

See how service layer is tested in DocumentServiceTest.

The test class is annotated with @CelestaTest, and each test method has CallContext parameter. Behind the scenes Celesta runs with in-memory H2 database and the correct CallContext is provided for your tests.

Using 'real' database connection

This application by default runs on H2-in-memory DB.

You may try to use any other RDBMS supported by Celesta, e. g. PostgreSQL. In order to do this, first create an empty database on your server (e. g. named celesta).

Database connection is set in application.yml file. Instead of

celesta:
  h2:
    inMemory: true

you may write

celesta:
  jdbc:
    url: jdbc:postgresql://127.0.0.1:5432/celesta
    username: <your_username>
    password: <your_password>

(see Celesta documentation for complete Celesta options reference).

To start the application with connection to PostgreSQL you will also need PostgreSQL JDBC driver, which you can simply add to dependencies:

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.2.4</version>
</dependency>

About

Demo for Celesta 7.x usage

Resources

Releases

No releases published

Packages

No packages published

Languages