在我的项目中,我有两个部分 UI 和 Engine。两者都在访问相同的数据库但不同的 hbm.xml 文件和休眠连接。如果我尝试从 UI 更新某些表值,引擎端查询不会返回更新的值。
这是一些普遍的问题吗?下面是我的代码。我在网上查了一下,发现了一些关于 Hibernate Cache 的东西。我不知道如何删除它。请帮忙。
public CgUssdGatewayConf getGwConfig(Long gwId)
{
logger.info("GW ID : "+gwId);
Criteria criteria = getSession().createCriteria(CgUssdGatewayConf.class);
criteria.add(Restrictions.eq("gwId", gwId));
//Now checking while cache loading time.
//criteria.add(Restrictions.eq("status", Constants.GW_STATUS_ENABLE));
List<CgUssdGatewayConf> list = (List<CgUssdGatewayConf>) criteria.list();
if(list != null && !list.isEmpty())
{
CgUssdGatewayConf cgUssdGatewayConf = list.get(0);
logger.info("GW ID : "+cgUssdGatewayConf.getGwId()+ " :: Name : "+cgUssdGatewayConf.getGwName() + " :: Status : "+cgUssdGatewayConf.getStatus());
return cgUssdGatewayConf;
}
return null;
}
我的休眠配置是-
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="hibernateProperties">
<props>
<!-- Mysql Config -->
<prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
<prop key="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/consentgateway</prop>
<prop key="hibernate.connection.username">cg</prop>
<prop key="hibernate.connection.password">cg123</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.connection.autoReconnect">true</prop>
<prop key="hibernate.connection.autoReconnectForPools">true</prop>
<prop key="hibernate.connection.is-connection-validation-required">true</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
<prop key="hibernate.c3p0.min_size">4</prop>
<prop key="hibernate.c3p0.max_size">50</prop>
<prop key="hibernate.c3p0.timeout">0</prop>
<prop key="hibernate.c3p0.max_statements">0</prop>
<prop key="hibernate.c3p0.idle_test_period">10800</prop>
<prop key="hibernate.c3p0.acquire_increment">3</prop>
<prop key="hibernate.connection.useUnicode">true</prop>
<prop key="hibernate.connection.characterEncoding">UTF-8</prop>
<prop key="hibernate.c3p0.maxAdministrativeTaskTime">0</prop>
<prop key="hibernate.c3p0.acquireRetryAttempts">5</prop>
<prop key="hibernate.connection.useUnicode">true</prop>
<prop key="hibernate.connection.characterEncoding">UTF-8</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>CgUssdGatewayConf.hbm.xml</value>
</list>
</property>
</bean>