ddal-spring

DDAL(Distributed Data Access Layer) is a simple solution to access database shard.

License

License

GroupId

GroupId

org.hellojavaer.ddal
ArtifactId

ArtifactId

ddal-spring
Last Version

Last Version

1.1.1-RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

ddal-spring
DDAL(Distributed Data Access Layer) is a simple solution to access database shard.
Project URL

Project URL

https://github.com/hellojavaer/ddal
Source Code Management

Source Code Management

https://github.com/hellojavaer/ddal.git

Download ddal-spring

How to add to project

<!-- https://jarcasting.com/artifacts/org.hellojavaer.ddal/ddal-spring/ -->
<dependency>
    <groupId>org.hellojavaer.ddal</groupId>
    <artifactId>ddal-spring</artifactId>
    <version>1.1.1-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/org.hellojavaer.ddal/ddal-spring/
implementation 'org.hellojavaer.ddal:ddal-spring:1.1.1-RELEASE'
// https://jarcasting.com/artifacts/org.hellojavaer.ddal/ddal-spring/
implementation ("org.hellojavaer.ddal:ddal-spring:1.1.1-RELEASE")
'org.hellojavaer.ddal:ddal-spring:jar:1.1.1-RELEASE'
<dependency org="org.hellojavaer.ddal" name="ddal-spring" rev="1.1.1-RELEASE">
  <artifact name="ddal-spring" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.hellojavaer.ddal', module='ddal-spring', version='1.1.1-RELEASE')
)
libraryDependencies += "org.hellojavaer.ddal" % "ddal-spring" % "1.1.1-RELEASE"
[org.hellojavaer.ddal/ddal-spring "1.1.1-RELEASE"]

Dependencies

compile (5)

Group / Artifact Type Version
org.hellojavaer.ddal : ddal-core jar 1.1.1-RELEASE
org.hellojavaer.ddal : ddal-ddr jar 1.1.1-RELEASE
org.springframework : spring-aop jar 4.2.5.RELEASE
org.springframework : spring-context jar 4.2.5.RELEASE
org.aspectj : aspectjweaver jar 1.8.9

test (2)

Group / Artifact Type Version
junit : junit Optional jar 4.11
org.springframework : spring-test Optional jar 4.2.5.RELEASE

Project Modules

There are no modules declared in this project.

DDAL

Build Status GitHub release Maven Central

DDAL(Distributed Data Access Layer) is a simple solution to access database shard.

design

License

DDAL is dual licensed under LGPL V2.1 and Apache Software License, Version 2.0.

Quick start

  • add the following dependency in your pom.xml
<dependency>
    <groupId>org.hellojavaer.ddal</groupId>
    <artifactId>ddal-datasource</artifactId>
    <version>1.1.1-RELEASE</version>
</dependency>
  • use DefaultDDALDataSource to proxy the orginal dataSource
<bean name="dataSource" class="org.hellojavaer.ddal.datasource.DefaultDDALDataSource">
    <constructor-arg index="0" value="jdbc:ddal:thick:classpath:/datasource.xml"/>
    <!-- <constructor-arg index="0" value="jdbc:ddal:thick:http://{host}:{port}/{appName}"/> -->
</bean>

Features

  • Only need to proxy the original datasources for business
  • Fully support ACID
  • Support insert, select, update and delete expression
  • Support join(inner join,left join,right join,full jion), sub-select, union all and exists expression
  • Support table alias
  • Support no shard-key schema/table routing
  • Support '=', in' and 'between' operation to route schema/table and support mixed sql parameter and jdbc parameter in routing values
    • eg: 'select * from tb where id in(1,?,3)'
    • eg: 'select * from tb where id between 1 and ?'
  • Support Date, Timestamp, Byte, Short, Integer, Long, String, Character, Hex value type for shard-value
  • Support annotation routing
  • Support custom route rule (eg: '{scName}_{format('%02d', sdValue % 4)}')
  • Support route rule binding on a schema (instead of a table)
  • Support scan all schemas and tables
  • Support limit check
  • Support read-write splitting
  • Support load balance of read
  • Support config at server-side
  • Support db cluster route
  • Provide multiple sequence implements

Download

http://repo1.maven.org/maven2/org/hellojavaer/ddal/

Documentation

Release Notes

Extensions in the latest version 1.1.0-RELEASE

  • support DB cluster route
  • enhance ShardRouteUtils

Extensions in version 1.0.1-RELEASE

  • Support route rule binding on a schema (instead of a table)
<bean class="org.hellojavaer.ddal.ddr.shard.simple.SimpleShardRouteRuleBinding">
    <property name="scName" value="base"/>
    <property name="rule">
        <bean class="org.hellojavaer.ddal.ddr.shard.rule.SpelShardRouteRule">
            <property name="scRouteRule" value="{scName}_{format('%02d', sdValue % 2)}"/>
            <property name="tbRouteRule" value="{tbName}_{format('%04d', sdValue % 8)}"/>
        </bean>
    </property>
    <property name="sdKey" value="id"/>
    <property name="sdValues" value="[0..7]"/>
</bean>

Extensions in version 1.0.0-RELEASE

  • upgrade jsqlparser's version to 1.2 to support more sql features
  • optimize JSQLParserAdapter

Extensions in version 1.0.0.M7

  • support custom protocol jdbc:ddal:

Extensions in version 1.0.0.M6

  • implement DefaultDDALDataSource in ddal-datasource module
<bean name="dataSource" class="org.hellojavaer.ddal.datasource.DefaultDDALDataSource">
    <constructor-arg index="0" value="jdbc:ddal:thick:classpath:/datasource.xml"/>
</bean>
  • implement DivideShardRouteRule for range route

Extensions in version 1.0.0.M5

  • optimize route rule expression parser
// older
SpelShardRouteRule rule = new SpelShardRouteRule();
rule.setScRouteRule("{#scName}_{#format('%02d', #sdValue % 4)}");
rule.setTbRouteRule("{#tbName}_{#format('%04d', #sdValue % 8)}");

// newer
SpelShardRouteRule rule = new SpelShardRouteRule();
rule.setScRouteRule("{scName}_{format('%02d', sdValue % 4)}");
rule.setTbRouteRule("{tbName}_{format('%04d', sdValue % 8)}");
  • optimize range expression parser
"1,2,3"  => 1,2,3
"[1..3]" => 1,2,3
"['A'..'C','X']" => A,B,C,X
"[0..1][0..1]" => 00,01,10,11
"Hi![' Allen',' Bob']" => Hi! Allen,Hi! Bob

Versions

Version
1.1.1-RELEASE
1.1.0-RELEASE
1.0.1-RELEASE
1.0.0-RELEASE
1.0.0.M7
1.0.0.M6
1.0.0.M5
1.0.0.M4
1.0.0.M3
1.0.0.M2
1.0.0.M1