GithubHelp home page GithubHelp logo

spring-doma-sample's Introduction

Spring Doma Sample

Run

  • run app
docker-compose up -d
gradle bootRun

Check examples

Pick up piyo group people.

pick up 'person' record by group name

curl http://localhost:8080/demo/test?groupName=piyo

rollback check

Register 10 valid record into person, then fail to add illegal group_id record. All 10 valid record will be rollback.

curl http://localhost:8080/demo/rollback

commit work

curl http://localhost:8080/demo/commit?

CRUD

  • get
curl http://localhost:8080/person/2
  • create
curl -X POST http://localhost:8080/person \
-H 'Content-type: application/json' \
-d '{ "firstName": "user", "lastName": "rest"} '
  • update
curl -X PUT http://localhost:8080/person \
-H 'Content-type: application/json' \
-d '{ "id":"3", "firstName": "guy", "lastName": "updated"} '
  • delete
curl -X DELETE http://localhost:8080/person/62

Validation

  • on-Request (Spring standard like struts)
curl -X POST http://localhost:8080/validate/request \
 -H 'Content-type: application/json' \
 -d '{ "firstName":"hoge","lastName": "rest", "groupId": 5} ' | jq .
  • on service (Intercept on service)
curl -X POST http://localhost:8080/validate/service \
 -H 'Content-type: application/json' \
 -d '{ "firstName":"hoge","lastName": "rest", "groupId": 5} ' | jq .

  • on dao (Intercept on dao)
curl -X POST http://localhost:8080/validate/dao \
 -H 'Content-type: application/json' \
 -d '{ "firstName":"hoge","lastName": "rest", "groupId": 5} ' | jq .

Datasource switch

The groupDao uses slave config. so, group api returns slave connection values. Especially, master database has 3 groups. There ids are 1 to 3. But dummy slave database has only 2record. There ids are 1 and 2.

So creating person record with group_id 3 will fail with validation error. That's not a database rejection.

  • The data-source switching check
curl http://localhost:8080/ds-demo/slave/2

spring-doma-sample's People

Stargazers

Roman avatar

Watchers

James Cloos avatar tchibana avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.