Git Product home page Git Product logo

mybatis-playground's Introduction

MyBatis Playground


Configuration

1. create test scope application.yml file

test scope application.yml

spring:
  h2:
    console:
      enabled: true
  datasource:
    driver-class-name: org.h2.Driver
    url:  jdbc:h2:mem:toast_bread;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;DEFAULT_NULL_ORDERING=HIGH
    username: sa
    password: 1111
    ### do you want to use your own local h2 db? use the following configuration ###
    #url:  jdbc:h2:tcp://localhost/~/toast_bread;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE
  sql:
    init:
      mode: always
      platform: h2

mybatis:
  # mapper.xml location
  mapper-locations: classpath:mappers/**/*.xml
  # @Alias Class package location
  type-aliases-package: coding.toast.playground
  configuration:
    # db: snake_case => java: camelCase
    map-underscore-to-camel-case: true
    default-fetch-size: 10
    default-statement-timeout: 5
    jdbc-type-for-null: null

logging:
  level:
    root: info
    coding:
      toast:
        playground: debug
    org.springframework.jdbc.core.JdbcTemplate: debug
    org.springframework.jdbc.core.StatementCreatorUtils: trace
  pattern:
    console: "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
  • some test won't work because of postgresql specific methods.
  • change 'platform' to 'postgres' and change database connection config to postgres!



2. create sql script for startup initialize

create schema IF NOT EXISTS coding_toast;

drop table if exists coding_toast.address;
create table if not exists coding_toast.address
(
    city_name varchar(50) not null,
    zipcode   varchar(50) not null
);

drop table if exists coding_toast."user";
create table if not exists  coding_toast."user"
(
    id           serial
        constraint user_pk
            primary key,
    name         varchar(50) not null,
    phone_number varchar(50)
);

insert into coding_toast.address (city_name, zipcode)
values  ('New York', '00000'),
        ('California', '11111'),
        ('Texas', '22222'),
        ('Arizona', '33333'),
        ('Indiana', '44444'),
        ('Washington', '55555'),
        ('Oklahoma', '66666');

insert into coding_toast."user" (id, name, phone_number)
values  (default, 'Charlie Puth', '010-0000-0001'),
        (default, 'Brad Pitt', '010-0002-0003'),
        (default, 'Daniel Radcliffe', '010-0004-0005'),
        (default, 'Freddie Highmore', '010-0006-0007'),
        (default, 'Gary Oldman', '010-0000-0001');




see also

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.