AsyncMsgRecordDao { public boolean insertRecords(List<AsyncMsgRecord> asyncMsgRecs) { LOG.debug("AsyncMsgRecordDao.insertRecords() - Begin"); Session session = null; Transaction tx = null; boolean result = true; if (NullChecker.isNotNullish(asyncMsgRecs)) { int size = asyncMsgRecs.size(); AsyncMsgRecord dbRecord; try { session = getSession(); tx = session.beginTransaction(); LOG.info("Inserting Record..."); for (int i = 0; i < size; i++) { dbRecord = asyncMsgRecs.get(i); session.persist(dbRecord); } tx.commit(); LOG.info("AsyncMsgRecord List Inserted successfully..."); } catch (HibernateException he) { result = false; if (tx != null) { tx.rollback(); } LOG.error("Error during insertion caused by: {}", he.getLocalizedMessage(), he); } finally { if (session != null) { try { session.close(); } catch (HibernateException he) { LOG.error("Failed to close session: {}", he.getLocalizedMessage(), he); } } } } LOG.debug("AsyncMsgRecordDao.insertRecords() - End"); return result; } AsyncMsgRecordDao();  AsyncMsgRecordDao(PropertyAccessor accessor); List<AsyncMsgRecord> queryByMessageIdAndDirection(String messageId, String direction); List<AsyncMsgRecord> queryByMessageIdAndServiceName(String messageId, String serviceName); List<AsyncMsgRecord> queryByTime(Date timestamp); List<AsyncMsgRecord> queryForExpired(Date timestamp); List<AsyncMsgRecord> queryForDeferredQueueProcessing(); List<AsyncMsgRecord> queryForDeferredQueueSelected(); List<AsyncMsgRecord> queryByCriteria(QueryDeferredQueueRequestType queryCriteria); boolean insertRecords(List<AsyncMsgRecord> asyncMsgRecs); void save(AsyncMsgRecord asyncMsgRecord); void save(List<AsyncMsgRecord> asyncMsgRecs); void delete(AsyncMsgRecord asyncMsgRecord); void checkExpiration(); static final String QUEUE_DIRECTION_INBOUND; static final String QUEUE_DIRECTION_OUTBOUND; static final String QUEUE_RESPONSE_TYPE_AUTO; static final String QUEUE_RESPONSE_TYPE_EXTERNAL; static final String QUEUE_STATUS_EXPIRED; static final String QUEUE_STATUS_REQPROCESS; static final String QUEUE_STATUS_REQRCVD; static final String QUEUE_STATUS_REQRCVDACK; static final String QUEUE_STATUS_REQRCVDERR; static final String QUEUE_STATUS_REQSENT; static final String QUEUE_STATUS_REQSENTACK; static final String QUEUE_STATUS_REQSENTERR; static final String QUEUE_STATUS_RSPSELECT; static final String QUEUE_STATUS_RSPPROCESS; static final String QUEUE_STATUS_RSPRCVD; static final String QUEUE_STATUS_RSPRCVDACK; static final String QUEUE_STATUS_RSPRCVDERR; static final String QUEUE_STATUS_RSPSENT; static final String QUEUE_STATUS_RSPSENTACK; static final String QUEUE_STATUS_RSPSENTERR; }
@Test public void testInsertRecords() { System.out.println("insertRecords"); AsyncMsgRecord asyncMsgRecord1 = new AsyncMsgRecord(); AsyncMsgRecord asyncMsgRecord2 = new AsyncMsgRecord(); List<AsyncMsgRecord> asyncMsgRecs = new ArrayList<>(); asyncMsgRecs.add(asyncMsgRecord1); asyncMsgRecs.add(asyncMsgRecord2); boolean result = asyncMsgRecordDao.insertRecords(asyncMsgRecs); assertEquals(true, result); }