GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — hsweb-framework/hsweb-datasource at master · HelloJavaWorld123/hsweb-framework

Expand file tree

/

hsweb-datasource

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

hsweb-datasource

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
hsweb-datasource-api
hsweb-datasource-api
 
 
hsweb-datasource-jta
hsweb-datasource-jta
 
 
hsweb-datasource-web
hsweb-datasource-web
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

README.md

Outline

动态数据源模块

提供动态数据源支持功能,支持注解方式,编程方式动态切换数据源,支持事务中切换数据源,支持跨数据库事务

目前提供JTA实现,请看:hsweb-datasource-jta

example

编程方式:

  //切换到 id为mysql_read_01的数据源
  DataSourceHolder.switcher().use("mysql_read_01");
  // ....
  //切换到 id为mysql_write_01的数据源
  DataSourceHolder.switcher().use("mysql_write_01");
  // ....
  // 切换到上一次使用的数据源 (mysql_read_01)
   DataSourceHolder.switcher().useLast();
  // ...
  // 切换到默认的数据源
  DataSourceHolder.switcher().useDefault();

注解方式:

@UseDataSource("mysql_write_01")
String insert(MyEntity);
 
@UseDataSource("mysql_read_01")
MyEntity selectByPk(String id);
 
@UseDefaultDataSource()
MyEntity selectByPk(String id);
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.