Hello,
I got these exception from hibernate version 3.0 can any one help me
figure this out
Code:
12:04:47,287 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.HibernateException: Not able to obtain connection
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:113)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:76)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:69)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:150)
at org.hibernate.persister.entity.BasicEntityPersister.delete(BasicEntityPersister.java:2049)
at org.hibernate.persister.entity.BasicEntityPersister.delete(BasicEntityPersister.java:2213)
at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:59)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at com.intelligentbrain.bizCommerce.main.salesMgmt.hibernate.service.PromotionManager.editPromotion(Unknown Source)
at com.intelligentbrain.bizCommerce.main.salesMgmt.web.action.PromotionEditAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:150)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:80)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:54)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.tc5.sso.ClusteredSingleSignOn.invoke(ClusteredSingleSignOn.java:389)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
here is the code
Code:
public PromotionValue editPromotion(PromotionWriteValue writeValue,PromotionProductItemWriteValue[] itemValues,PromotionCategoryWriteValue[] categoryValues, PromotionCategorySubcategoryWriteValue[] categorySubcategoryValues, PromotionCategorySubcategoryBrandWriteValue[] categorySubcategoryBrandValues, PromotionCategoryBrandWriteValue[] categoryBrandValues,PromotionProductWriteValue[] productValues)
throws PromotionServiceException, DuplicatedObjectException {
if(writeValue == null) {
throw new IllegalArgumentException("Value cannot be null.");
}//if
try {
PromotionValue value = viewPromotion(writeValue.getPrimaryKey());
PromotionValue currentValue = viewPromotion(writeValue.getPrimaryKey());
if(value==null){
PromotionServiceException e1 = new PromotionServiceException("Cannot find "+writeValue.getPrimaryKey().toString()+" PK.");
throw e1;
}//if
try {
PromotionValue[] values = listPromotionsByName(writeValue.getName());
for (int i=0;i<values.length;i++) {
if (!values[i].getPrimaryKey().equals(value.getPrimaryKey())) {
throw new DuplicatedObjectException("salesMgmt.promotion.edit.error");
}//if
}//for
}//try
catch (HibernateException e) {
throw new PromotionServiceException(e);
}//catch
String promotionID = value.getPromotionID();
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
value.setName(writeValue.getName());
value.setStartDate(writeValue.getStartDate());
value.setEndDate(writeValue.getEndDate());
value.setDefaultAmount(writeValue.getDefaultAmount());
value.setDefaultPercentAmount(writeValue.getDefaultPercentAmount());
value.setEndDate(writeValue.getEndDate());
value.setCreateID(currentValue.getEditID());
value.setCreateTime(currentValue.getCreateTime());
value.setEditID(getCurrentUserID());
value.setEditTime(getCurrentTimestamp());
//promotion productItem
PromotionProductItemValue[] promotionProductItemValues = listPromotionProductItemsByPromotionID(promotionID);
for(int i=0;i<promotionProductItemValues.length;i++){
PromotionProductItemValue _value = promotionProductItemValues[i];
Hibernate.initialize(_value);
value.removePromotionProductItem(_value);
session.delete(_value);
session.flush();
}//for
for(int i=0;i<itemValues.length;i++){
PromotionProductItemValue _value = (PromotionProductItemValue) getEntityObject(itemValues[i]);
_value.setPromotionID(value.getPromotionID());
value.addPromotionProductItem(_value);
session.save(_value);
session.flush();
}//for
//promotion category
PromotionCategoryValue[] promotionCategoryValues = listPromotionCategoriesByPromotionID(promotionID);
for(int i=0;i<promotionCategoryValues.length;i++){
PromotionCategoryValue _value = promotionCategoryValues[i];
Hibernate.initialize(_value);
value.removePromotionCategory(_value);
session.delete(_value);
session.flush();//error here
}//for
for(int i=0;i<categoryValues.length;i++){
PromotionCategoryValue _value = (PromotionCategoryValue) getEntityObject(categoryValues[i]);
_value.setPromotionID(value.getPromotionID());
value.addPromotionCategory(_value);
session.save(_value);
session.flush();//error here
}//for
//category subcategory
PromotionCategorySubcategoryValue[] promotionCategorySubcategoryValues = listPromotionCategorySubcategoriesByPromotionID(promotionID);
for(int i=0;i<promotionCategorySubcategoryValues.length;i++){
Hibernate.initialize(promotionCategorySubcategoryValues[i]);
value.removePromotionCategorySubcategory(promotionCategorySubcategoryValues[i]);
session.delete(promotionCategorySubcategoryValues[i]);
session.flush();
}//for
for(int i=0;i<categorySubcategoryValues.length;i++){
PromotionCategorySubcategoryValue _value = (PromotionCategorySubcategoryValue) getEntityObject(categorySubcategoryValues[i]);
value.addPromotionCategorySubcategory(_value);
_value.setPromotionID(value.getPromotionID());
session.save(_value);
session.flush();
}//for
//category subcategory brand
PromotionCategorySubcategoryBrandValue []promotionCategorySubcategoryBrandValues = listPromotionCategorySubcategoryBrandsByPromotionID(promotionID);
for(int i=0;i<promotionCategorySubcategoryBrandValues.length;i++){
Hibernate.initialize(promotionCategorySubcategoryBrandValues[i]);
value.removePromotionCategorySubcategoryBrand(promotionCategorySubcategoryBrandValues[i]);
session.delete(promotionCategorySubcategoryBrandValues[i]);
session.flush();
}//for
for(int i=0;i<categorySubcategoryBrandValues.length;i++){
PromotionCategorySubcategoryBrandValue _value = (PromotionCategorySubcategoryBrandValue) getEntityObject(categorySubcategoryBrandValues[i]);
value.addPromotionCategorySubcategoryBrand(_value);
_value.setPromotionID(value.getPromotionID());
session.save(_value);
session.flush();
}//for
System.out.println("service 008");
//promotion category brand
PromotionCategoryBrandValue[] promotionCategoryBrandValues = listPromotionCategoryBrandsByPromotionID(promotionID);
for(int i=0;i<promotionCategoryBrandValues.length;i++){
Hibernate.initialize(promotionCategoryBrandValues[i]);
value.removePromotionCategoryBrand(promotionCategoryBrandValues[i]);
session.delete(promotionCategoryBrandValues[i]);
session.flush();
}//for
for(int i=0;i<categoryBrandValues.length;i++){
PromotionCategoryBrandValue _value = (PromotionCategoryBrandValue) getEntityObject(categoryBrandValues[i]);
value.addPromotionCategoryBrand(_value);
_value.setPromotionID(value.getPromotionID());
session.save(_value);
session.flush();
}//for
//promotion product
PromotionProductValue[] promotionProductValues = listPromotionProductsByPromotionID(promotionID);
for(int i=0;i<promotionProductValues.length;i++){
Hibernate.initialize(promotionProductValues[i]);
value.removePromotionProduct(promotionProductValues[i]);
session.delete(promotionProductValues[i]);
session.flush();
}//for
for(int i=0;i<productValues.length;i++){
PromotionProductValue _value = (PromotionProductValue) getEntityObject(productValues[i]);
value.addPromotionProduct(_value);
_value.setPromotionID(value.getPromotionID());
session.save(_value);
session.flush();
}//for
session.update(value);
session.flush();
tx.commit();
HibernateUtil.closeSession();
return value;
}//try
catch (HibernateException e) {
//logger.severe(e.getMessage());
throw new PromotionServiceException(e);
}//catch
}
and these are mapping file
Mapping file for promotion value
Code:
<class
name="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionValue"
table="promotion"
>
<id
name="promotionID"
column="promotionID"
type="java.lang.String"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-PromotionValue.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
.
.
.
<set
name="promotionCategorySubcategories"
lazy="true"
inverse="true"
cascade="all"
sort="unsorted"
>
<key
column="promotionID"
>
</key>
<one-to-many
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionCategorySubcategoryValue"
/>
</set>
<set
name="promotionCategorySubcategoryBrands"
lazy="true"
inverse="true"
cascade="all"
sort="unsorted"
>
<key
column="promotionID"
>
</key>
<one-to-many
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionCategorySubcategoryBrandValue"
/>
</set>
Mapping file for Promotion Product Value
Code:
<class name="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionProductValue"
table="promotionproduct"
>
<composite-id
name="primaryKey"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionProductPK"
>
<key-property
name="promotionID"
type="java.lang.String"
column="promotionID"
/>
<key-property
name="productID"
type="java.lang.String"
column="productID"
/>
</composite-id>
.
.
.
<many-to-one
name="productValue"
class="com.intelligentbrain.bizCommerce.main.productMgmt.model.ProductValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="productID"
not-null="true"
/>
Mapping file for promotion product item value
Code:
<class
name="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionProductItemValue"
table="promotionproductitem"
>
<composite-id
name="primaryKey"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionProductItemPK"
>
<key-property
name="promotionID"
type="java.lang.String"
column="promotionID"
/>
<key-property
name="upc"
type="java.lang.String"
column="upc"
/>
</composite-id>
.
.
.
<many-to-one
name="promotionValue"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="promotionID"
not-null="true"
/>
<many-to-one
name="productItemValue"
class="com.intelligentbrain.bizCommerce.main.productMgmt.model.ProductItemValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="upc"
not-null="true"
/>
Mapping file for promotion category value
Code:
<class
name="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionCategoryValue"
table="promotioncategory"
>
<composite-id
name="primaryKey"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionCategoryPK"
>
<key-property
name="promotionID"
type="java.lang.String"
column="promotionID"
/>
<key-property
name="categoryID"
type="java.lang.String"
column="categoryID"
/>
</composite-id>
.
.
.
<many-to-one
name="promotionValue"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="promotionID"
not-null="true"
/>
<many-to-one
name="categoryValue"
class="com.intelligentbrain.bizCommerce.main.productMgmt.model.CategoryValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="categoryID"
not-null="true"
/>
Mapping file for promotion category subcategory
Code:
<class
name="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionCategorySubcategoryValue"
table="promotioncategorysubcategory"
>
<composite-id
name="primaryKey"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionCategorySubcategoryPK"
>
<key-property
name="promotionID"
type="java.lang.String"
column="promotionID"
/>
<key-property
name="categoryID"
type="java.lang.String"
column="categoryID"
/>
<key-property
name="subcategoryID"
type="java.lang.String"
column="subcategoryID"
/>
</composite-id>
.
.
.
<many-to-one
name="subcategoryValue"
class="com.intelligentbrain.bizCommerce.main.productMgmt.model.SubcategoryValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
>
<column
name="categoryID"
/>
<column
name="subcategoryID"
/>
</many-to-one>
<many-to-one
name="promotionValue"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="promotionID"
not-null="true"
/>
Mapping file for Promotion Category Subcategory Brand
Code:
<class
name="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionCategorySubcategoryBrandValue"
table="promotioncategorysubcategorybrand"
>
<composite-id
name="primaryKey"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionCategorySubcategoryBrandPK"
>
<key-property
name="promotionID"
type="java.lang.String"
column="promotionID"
/>
<key-property
name="categoryID"
type="java.lang.String"
column="categoryID"
/>
<key-property
name="subcategoryID"
type="java.lang.String"
column="subcategoryID"
/>
<key-property
name="brandID"
type="java.lang.String"
column="brandID"
/>
</composite-id>
.
.
.
<many-to-one
name="subcategoryValue"
class="com.intelligentbrain.bizCommerce.main.productMgmt.model.SubcategoryValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
>
<column
name="categoryID"
/>
<column
name="subcategoryID"
/>
</many-to-one>
<many-to-one
name="promotionValue"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="promotionID"
not-null="true"
/>
<many-to-one
name="brandValue"
class="com.intelligentbrain.bizCommerce.main.productMgmt.model.BrandValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="brandID"
not-null="true"
/>
Mapping file for Promotion brand
Code:
<class
name="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionCategoryBrandValue"
table="promotioncategorybrand"
>
<composite-id
name="primaryKey"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionCategoryBrandPK"
>
<key-property
name="promotionID"
type="java.lang.String"
column="promotionID"
/>
<key-property
name="categoryID"
type="java.lang.String"
column="categoryID"
/>
<key-property
name="brandID"
type="java.lang.String"
column="brandID"
/>
</composite-id>
.
.
.
<many-to-one
name="promotionValue"
class="com.intelligentbrain.bizCommerce.main.salesMgmt.model.PromotionValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="promotionID"
not-null="true"
/>
<many-to-one
name="categoryValue"
class="com.intelligentbrain.bizCommerce.main.productMgmt.model.CategoryValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="categoryID"
not-null="true"
/>
<many-to-one
name="brandValue"
class="com.intelligentbrain.bizCommerce.main.productMgmt.model.BrandValue"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="brandID"
not-null="true"
/>
Thank you