我正在开发一个使用spring + hibernate + mysql和c3p0进行连接池的项目.
目前,连接池的属性是通过src外部定义的属性加载的.(例如:$ {db_uname})
当我们创造春豆时,一切都开始了.
由于某种原因,我们连接的数据库可能无法访问,我们希望切换主机.
需要实现回调,它应该连接到新主机并重新初始化池
有关如何优雅地覆盖现有数据源/连接池的任何指针都会有很大帮助.
这是我的spring配置文件的样子
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<!-- Component scans -->
<import resource="component-scans-1.xml" />
<import resource="component-scans-2.xml" />
<util:properties id="serviceManagerProperties"
location="classpath:servicemanagers.properties" />
<!-- Properties file -->
<context:property-placeholder location="classpath:database.config.properties,classpath:framework.properties" />
<!-- context:annotation-config / -->
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<context:mbean-server id="mbeanServer" />
<context:mbean-export server="mbeanServer" default-domain="a.b.c" />
<bean id="cacheManager" factory-method="getInstance" …Run Code Online (Sandbox Code Playgroud) 我们正在合并从主干到分支的变化.在我们执行此操作时,会记录合并信息.
由于分支中可能存在其他更改,是否有一种安全的方法只提交由于合并而受影响的文件(假设没有其他更改)以及合并属性/信息?
"假设我想从主干到分支合并修订版'r1'.我从主干到分支合并'r1'.现在为'r1',在分支文件夹中,记录合并信息.如果我做了在分支中的svn diff,它显示'.' 已修改,并显示'r1'是合并属性的一部分.现在我如何提交由于'r1'仅被合并而修改的文件,以及合并属性,其中显示'r1'."
我想对延迟加载和会话边界等做一些澄清.
我的代码结构如下
@Entity
class A {
....
@OneToOne(fetch=LAZY)
private B b;
..
}
@Entity
class B {
private id;
private name;
}
@Transactional(SUPPORTS)
ADao {
A findById(int id);
}
@Transactional(SUPPORTS)
LayerDB {
A getAForId(int i) {
return adao.findById(i);
}
}
//Note that there is no transactional attribute here
LayerB {
public boolean doSomethingWithAandB(int aId) {
A a = LayerDB.getAForId(aId);
if(a.getB().getName().equals("HIGH"))
return true;
return false;
}
}
//start transaction here
@Transaction(REQUIRED)
LayerC {
LayerB layerb;
private handleRequest(int id) {
layerb.doSomethingWithAandB(id);
} …Run Code Online (Sandbox Code Playgroud) spring ×2
datasource ×1
exception ×1
hibernate ×1
jpa ×1
lazy-loading ×1
merge ×1
mergeinfo ×1
svn ×1