Reputation: 13
I am using Weblogic 10.3.6 + Hibernate 3 and EJB 3.0
I am trying the update the entity but the its not getting updated in Database. No exceptions
Please find the hibernate config file as below
<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>
and I am using the below code to update the entity in my 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;
}
I could see the below in the console:
**************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***********
But the data is not getting saved in database.
Please help me to resolve. Thanks
Upvotes: 1
Views: 5139
Reputation: 3046
I dont see in your hibernate configuration property:
<property name="hibernate.connection.autocommit">true</property>
Since default configuration = false. Set this and check the results.
But if you want to do this manually you need to:
Transaction tx = session.beginTransaction();
//your code
tx.commit();
session.close();
Upvotes: 8