Hibernate version:
2.1.8
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<!-- $Id: OrderVO.hbm.xml,v 1.10 2005/05/02 17:00:24 st_lim Exp $ -->
<hibernate-mapping package="sc.eCatalogue.OrderMgt.integration">
<!-- OrderVO -->
<class name="OrderVO"
table="ECAT.ECAT_ORDER">
<!-- id -->
<id name="id"
type="long"
unsaved-value="0">
<column name="ORDER_ID"
not-null="true"
sql-type="NUMBER(9)"/>
<generator class="sc.eCatalogue.common.hibernate.DateSequenceGenerator">
<param name="sequence">ECAT.SEQ_ECAT_ORDER_ORDER_ID</param>
<param name="date_format">yyyyMM</param>
<param name="no_of_digits">3</param>
</generator>
</id>
<!-- orderDate -->
<property name="orderDate"
column="DTE_ORDER"
not-null="true"
type="timestamp" />
<!-- expectDate -->
<property name="expectedDate"
column="DTE_EXPECT"
not-null="true"
type="timestamp" />
<!-- acctMgr -->
<component name="acctMgr"
class="sc.eCatalogue.UserMgt.integration.AcctMgrVO">
<!-- acctMgrNric -->
<property name="nric"
type="string">
<column name="ACCT_MGR_NRIC"
length="9"
not-null="true" />
</property>
<!-- acctMgrName -->
<property name="name"
type="string">
<column name="ACCT_MGR_NAME"
length="66"
not-null="true" />
</property>
</component>
<!-- customer -->
<component name="customer"
class="sc.eCatalogue.UserMgt.integration.UserVO">
<!-- user.dept-->
<property name="dept"
type="string">
<column name="CUST_DEPT"
length="80"
not-null="true" />
</property>
<!-- user.email -->
<property name="email"
type="string">
<column name="CUST_EMAIL_ADDR"
length="80"
not-null="true" />
</property>
<!-- user.name -->
<property name="name"
type="string">
<column name="CUST_NAME"
length="66"
not-null="true" />
</property>
<!-- custPhone -->
<property name="phone"
type="string">
<column name="CUST_PHONE"
length="15"
not-null="true" />
</property>
</component>
<!-- status -->
<many-to-one name="status"
class="OrderStatusVO"
foreign-key="FK_ECAT_ORDER_ORDER_ST"
cascade="none">
<column name="ORDER_STATUS_ID"
not-null="true"
sql-type="NUMBER(2)"/>
</many-to-one>
<!-- purpose -->
<property name="purpose"
type="string">
<column name="PURPOSE"
length="1000"
not-null="true" />
</property>
<!-- eventOrg -->
<property name="evtOrg"
type="string">
<column name="EVT_ORG"
length="600"
not-null="false" />
</property>
<!-- remarks -->
<property name="remarks"
type="string">
<column name="REM"
length="1000" />
</property>
<!-- items -->
<set name="orderedItems"
inverse="true"
lazy="false"
cascade="all-delete-orphan">
<key column="ORDER_ID"/>
<one-to-many class="OrderedItemVO"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public OrderVO createOrder(OrderVO order)
throws RemoteException, OrderBizException, TxBizException, DAOException,
ItemBizException {
OrderVO result = null;
if (order == null) {
throw new OrderBizException(OrderBizException.EXCEPTION_REQUIRED_ORDER);
}
_log.info("createOrder(" + order.getOrderDate() + ")");
if (order.getAcctMgr() == null) {
throw new OrderBizException(OrderBizException.EXCEPTION_REQUIRED_ACCTMGR);
}
// Perform operation on order
OrderDAO dao = null;
try {
dao = new OrderDAO();
ItemMgrEJB itemEJB = new ItemMgrEJB();
ItemDAO itemDAO = new ItemDAO(dao);
List qtyItems = new ArrayList();
// check if there is enough items to be ordered
if ((order.getOrderedItems() == null) ||
order.getOrderedItems().isEmpty()) {
throw new OrderBizException(OrderBizException.EXCEPTION_REQUIRED_ORDEREDITEM);
} else {
for (Iterator i = order.getOrderedItems().iterator(); i.hasNext();) {
Object o = i.next();
if ((o == null) || !(o instanceof OrderedItemVO)) {
throw new OrderBizException(OrderBizException.EXCEPTION_REQUIRED_ORDEREDITEM);
} else {
OrderedItemVO item = (OrderedItemVO) o;
if (item.getQty() > 0) {
SubItemVO subitem = itemEJB.checkEnoughQty(itemDAO,
item.getSubitem().getId(), (-1 * item.getQty()));
if (subitem != null) {
qtyItems.add(subitem);
} else {
subitem = itemDAO.selectSubitemBySubitemId(item.getSubitem()
.getId());
if (subitem.getItem() != null) {
item.setSubitem(subitem);
}
}
}
}
}
}
// Return the errors
_log.debug("qtyItems size = (" + qtyItems.size() + ")");
if ((qtyItems != null) && !qtyItems.isEmpty()) {
ItemBizException e = new ItemBizException(ItemBizException.EXCEPTION_NOTENOUGH_SUBITEM);
e.setItems(qtyItems);
throw e;
}
result = dao.insertOrder(order);
_log.info("Order #(" + result.getId() + ") was inserted.");
// Add Tx
TxMgrEJB txMgr = new TxMgrEJB();
TxLogVO tx = txMgr.createTxLogForOrder(dao, order, "New Request",
order.getAcctMgr());
_log.info("Tx #(" + tx.toString() + ") was created for order.");
dao.flush();
dao.end();
} catch (DAOException e) {
_log.error(e);
this._sessionContext.setRollbackOnly();
throw e;
} catch (RemoteException e) {
_log.error(e);
this._sessionContext.setRollbackOnly();
throw e;
} catch (ItemBizException e) {
_log.error(e);
this._sessionContext.setRollbackOnly();
throw e;
} catch (TxBizException e) {
_log.error(e);
this._sessionContext.setRollbackOnly();
throw e;
} finally {
if (dao != null) {
dao.end();
}
}
return result;
}
Full stack trace of any exception that occurs:
None
Name and version of the database you are using:
Oracle 9.1.2
The user has keyed in a remark of at least 500 odd characters, but only 300 odd characters are found to be stored in the oracle database.
|