use of gov.ca.cwds.data.DaoException in project api-core by ca-cwds.
the class SystemCodeDao method findByForeignKeyMetaTable.
/**
* @param foreignKeyMetaTable meta group
* @return all keys by meta table
*/
@SuppressWarnings("unchecked")
public SystemCode[] findByForeignKeyMetaTable(String foreignKeyMetaTable) {
final String namedQueryName = SystemCode.class.getName() + ".findByForeignKeyMetaTable";
final Session session = getCurrentSession();
Transaction txn = session.getTransaction();
boolean transactionExists = txn != null && txn.isActive();
txn = transactionExists ? txn : session.beginTransaction();
try {
final Query query = session.getNamedQuery(namedQueryName).setString("foreignKeyMetaTable", foreignKeyMetaTable);
final SystemCode[] systemCodes = (SystemCode[]) query.list().toArray(new SystemCode[0]);
if (!transactionExists)
txn.commit();
return systemCodes;
} catch (HibernateException h) {
txn.rollback();
throw new DaoException(h);
}
}
Aggregations