Skip to content
Demo for Celesta 7.x usage
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


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

    inMemory: true

you may write

    url: jdbc:postgresql://
    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:

You can’t perform that action at this time.