1
沒有反映我使用的Weblogic 10.3.6 + Hibernate的3和EJB 3.0Hibernate的Session更新數據庫
我試圖更新的實體,但它不是在數據庫中獲取更新。 沒有例外
請找到休眠的配置文件,如下
<property name="hibernate.connection.datasource">jdbc/wfAR_ConnectionDS</property>
<property name="hibernate.generate_statistics">true</property>
<property name="hibernate.hibernate.session_factory_name">wfAR_ConnectionDS</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="hibernate.transaction.factory.class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="hibernate.transaction.auto_close_session">false</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>
<property name="hibernate.format_sql">true</property>
,我使用下面的代碼在我的EJB
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public long updateCustomerData(ArCatCustomer customer){
long id=-1;
Session session = sessionFactory.openSession();
try{
System.out.println("**************Trying to Update***********");
session.update(customer);
//session.evict(customer);
session.flush();
System.out.println("***********Update Finished***********");
}catch(RuntimeException runExp){
runExp.printStackTrace();
throw runExp;
} finally{
session.close();
}
return id;
}
更新實體,我可以看到在下面控制檯:
**************Trying to Update***********
Hibernate:
/* update
com.ar.flextronics.model.ArCatCustomer */ update
AR_catCustomer
set
SegmentID=?,
MepID=?,
ParentCustomerID=?,
CustomerNumber=?,
CustomerName=?,
VendorID=?,
LocalVATID=?,
[FlexCustomer-Supplier]=?,
VMI=?,
TypeOfBilling=?,
CreditTerms=?,
CustomerCurrencyID=?,
CreditRate=?,
CreditLimit=?,
ParentBPNumInsideCompany=?,
LegalEntityname=?,
Region=?,
Active=?,
ERPName=?,
ERPServer=?,
ERPFinanceCompanyNumber=?,
ERPLogisticCompanyNumber=?,
LastUpdate=?,
UpdatedBy=?,
CustomerTypeID=?
where
CustomerID=?
***********Update Finished***********
但是數據沒有保存在數據庫。
請幫我解決。由於
由於其開始工作。我用autocommit屬性。 –