Hibernate version: 3.2.4.sp1.cp04
Seam version: 2.0.2
Plz explain what's going on here in terms of the exceptions in the latter two cases. thx.
Code:
@Begin(join=true)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void searchSerialNumbers()
{
topOneWorkOrdersList = storedProcedureDAO.getTopOneWorkOrdersBySerialNumber(serialNumber, siteId);
if (topOneWorkOrdersList != null && topOneWorkOrdersList.size() > 0)
{
NewWorkOrdersBean newWorkOrdersBean = (NewWorkOrdersBean)topOneWorkOrdersList.get(0);
persist(newWorkOrdersBean);
entityManager.flush();
}
}
result: no problem, SMPC flushed, tx's commit, etc.
/**********************************************************************************************************************************************/
Code:
@Begin(join=true, flushMode=FlushModeType.MANUAL)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void searchSerialNumbers()
{
topOneWorkOrdersList = storedProcedureDAO.getTopOneWorkOrdersBySerialNumber(serialNumber, siteId);
if (topOneWorkOrdersList != null && topOneWorkOrdersList.size() > 0)
{
NewWorkOrdersBean newWorkOrdersBean = (NewWorkOrdersBean)topOneWorkOrdersList.get(0);
persist(newWorkOrdersBean);
entityManager.flush();
}
}
result on flush(): Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:301)
at org.jboss.seam.persistence.EntityManagerProxy.flush(EntityManagerProxy.java:90)
at com.cox.bets.session.BulkCreateRepairCaseAction.searchSerialNumbers(BulkCreateRepairCaseAction.java:148)
/**********************************************************************************************************************************************/
Code:
@Begin(join=true, flushMode=FlushModeType.MANUAL)
public void searchSerialNumbers()
{
topOneWorkOrdersList = storedProcedureDAO.getTopOneWorkOrdersBySerialNumber(serialNumber, siteId);
if (topOneWorkOrdersList != null && topOneWorkOrdersList.size() > 0)
{
NewWorkOrdersBean newWorkOrdersBean = (NewWorkOrdersBean)topOneWorkOrdersList.get(0);
persist(newWorkOrdersBean);
entityManager.flush();
}
}
The following exception occurs when a method is called after the flush().
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:140)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:65)
... 139 more
Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a2e052a:a73:49c12c15:3c5 status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a2e052a:a73:49c12c15:3c5 status: ActionStatus.ABORT_ONLY >)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:96)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:47)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
... 152 more
Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a2e052a:a73:49c12c15:3c5 status: ActionStatus.ABORT_ONLY >
at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:319)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:402)
at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:90)
... 154 more
this is the method exec'd after the flush():
Code:
private void loadRepairHistory()
{
String query = " select er.equipmentRepairId, "+
" e.serialNumber, "+
" ddv.description, "+
" sum(erc.cost) as Cost "+
" from Equipment e "+
" inner join EquipmentRepair er on er.equipmentId = e.equipmentId "+
" left outer join EquipmentRepairCost erc on er.equipmentRepairId = erc.equipmentRepairId "+
" left outer join ListValue ddv on er.equipmentRepairTypeCode = ddv.code "+
" left outer join List dd on dd.listId = ddv.listId "+
" where e.serialNumber = :serialNumber and "+
" dd.listName = :repairTypeDropDown "+
" group by er.equipmentRepairId, "+
" e.serialNumber, "+
" ddv.description ";
repairHistoryList = entityManager.createNativeQuery(query)
.setParameter("serialNumber", serialNumber)
.setParameter("repairTypeDropDown", REPAIR_TYPE_DROP_DOWN)
.getResultList();
if (repairHistoryList != null)
log.info("loadRepairHistory(): repairHistoryList.size() = " + repairHistoryList.size());
}