codecamp

内外数据源同时使用

前面讲过如果是使用外部的数据源时,则需要在jfaster.properties中做如下配置

org.myhibernate.db.DBHelper.thirdPartyConnector=demo.third.db.DemoThirdConnnector

此时在获取数据库连接时,就会调用DemoThirdConnector中的getConnection()方法来获取连接

如果是在配置了外部连接时,但是有些实体又需要使用的是本地的数据源连接的情况下,那么只要把DataSource注解里面的local属性设置为true即可,如下

package test.entity;

import org.jfaster.annotation.DataSource;

@DataSource(name="mysqlTest",local=true)
public class User 
{
	//TODO
}

由上可知local默认为false,在配置了外部数据源实现类时,默认是访问的外部数据源


存储库模板
多数据源的使用-注解方式
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }