Java Code Examples for org.hibernate.HibernateException#getMessage()

The following examples show how to use org.hibernate.HibernateException#getMessage() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Remove bookmarks by parent node
 */
public static void purgeBookmarksByNode(String nodeUuid) throws DatabaseException {
	log.debug("purgeBookmarksByNode({})", nodeUuid);
	String qs = "delete from Bookmark bm where bm.node=:uuid";
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();

		Query q = session.createQuery(qs);
		q.setString("uuid", nodeUuid);
		q.executeUpdate();

		HibernateUtil.commit(tx);
		log.debug("purgeBookmarksByNode: void");
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 2
/**
 * Delete
 */
public static void deleteType(long dmtId) throws DatabaseException {
	log.debug("deleteType({})", dmtId);
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		DatabaseMetadataType emt = (DatabaseMetadataType) session.load(DatabaseMetadataType.class, dmtId);
		session.delete(emt);
		HibernateUtil.commit(tx);
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}

	log.debug("deleteType: void");
}
 
Example 3
/**
 * Find all forums
 */
@SuppressWarnings("unchecked")
public static List<Forum> findAll() throws DatabaseException {
	log.debug("findAll({})");
	String qs = "from Forum frm order by frm.date asc";
	Session session = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		Query q = session.createQuery(qs);
		List<Forum> ret = q.list();

		log.debug("findAll: {}", ret);
		return ret;
	} catch (HibernateException e) {
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 4
/**
 * Mark proposed as accepted
 */
public static void markAccepted(long pqId) throws DatabaseException {
	log.debug("markAccepted({})", pqId);
	String qs = "update ProposedQueryReceived ps set ps.accepted=:accepted where ps.id=:id";
	Session session = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		Query q = session.createQuery(qs);
		q.setLong("id", pqId);
		q.setBoolean("accepted", true);
		q.executeUpdate();
		log.debug("markAccepted: void");
	} catch (HibernateException e) {
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 5
/**
 * Set begin time
 */
public static void setLastBegin(long ctId) throws DatabaseException {
	log.debug("setLastBegin({})", ctId);
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		CronTab ct = (CronTab) session.load(CronTab.class, ctId);
		ct.setLastBegin(Calendar.getInstance());
		session.update(ct);
		HibernateUtil.commit(tx);
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}

	log.debug("setLastBegin: void");
}
 
Example 6
/**
 * Find all wiki pages
 */
@SuppressWarnings("unchecked")
public static List<DatabaseMetadataType> findAllTypes(String table) throws DatabaseException {
	log.debug("findAllTypes({})", table);
	String qs = "from DatabaseMetadataType dmt where dmt.table=:table order by dmt.id asc";
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		Query q = session.createQuery(qs);
		q.setString("table", table);
		List<DatabaseMetadataType> ret = q.list();
		HibernateUtil.commit(tx);
		log.debug("findAllTypes: {}", ret);
		return ret;
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 7
/**
 * Delete
 */
public static void delete(long qpId) throws DatabaseException {
	log.debug("delete({})", qpId);
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		QueryParams qp = (QueryParams) session.load(QueryParams.class, qpId);
		session.delete(qp);
		HibernateUtil.commit(tx);
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}

	log.debug("delete: void");
}
 
Example 8
@Override
public BIMetaModelParameter loadBIMetaModelParameterById(Integer id) {
	BIMetaModelParameter metaModel = null;
	Session session = null;
	Transaction transaction = null;
	try {
		session = getSession();
		transaction = session.beginTransaction();
		SbiMetaModelParameter sbiMetaModel = (SbiMetaModelParameter) session.load(SbiMetaModelParameter.class, id);
		if (sbiMetaModel != null)
			metaModel = toBIMetaModelParameter(sbiMetaModel);
		transaction.commit();
	} catch (HibernateException he) {
		logException(he);
		if (transaction != null)
			transaction.rollback();
		throw new SpagoBIRuntimeException(he.getMessage(), he);
	} finally {
		if (session != null) {
			if (session.isOpen())
				session.close();
		}
	}
	return metaModel;
}
 
Example 9
/**
 * Execute update
 */
public static int executeValueUpdate(String query) throws DatabaseException {
	log.debug("executeValueUpdate({})", query);
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		Query q = session.createQuery(query);
		int ret = q.executeUpdate();
		HibernateUtil.commit(tx);
		log.debug("executeValueUpdate: {}", ret);
		return ret;
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 10
/**
 * Execute query
 */
public static DatabaseMetadataValue executeValueQueryUnique(String query) throws DatabaseException {
	log.debug("executeValueQueryUnique({})", query);
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		Query q = session.createQuery(query);
		DatabaseMetadataValue ret = (DatabaseMetadataValue) q.uniqueResult();
		HibernateUtil.commit(tx);
		log.debug("executeValueQueryUnique: {}", ret);
		return ret;
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 11
/**
 * Find by pk
 */
public static ForumTopic findTopicByPk(long id) throws DatabaseException {
	log.debug("findTopicByPk({})");
	Session session = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		ForumTopic ret = (ForumTopic) session.get(ForumTopic.class, id);
		log.debug("findTopicByPk: {}", ret);
		return ret;
	} catch (HibernateException e) {
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 12
/**
 * Delete action
 */
public void deleteAction(long aaId) throws DatabaseException {
	log.debug("deleteAction({})", aaId);
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		AutomationAction aa = (AutomationAction) session.load(AutomationAction.class, aaId);
		session.delete(aa);
		HibernateUtil.commit(tx);
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}

	log.debug("deleteAction: void");
}
 
Example 13
/**
 * Create
 */
public static long create(Report rp) throws DatabaseException {
	log.debug("create({})", rp);
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		Long id = (Long) session.save(rp);
		HibernateUtil.commit(tx);
		log.debug("create: {}", id);
		return id;
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 14
/**
 * find filtered riles
 */
@SuppressWarnings("unchecked")
public List<AutomationRule> findByEvent(String event, String at) throws DatabaseException {
	log.debug("findByEvent({}, {})", event, at);
	String qs = "from AutomationRule ar where ar.event=:event and ar.at=:at order by ar.order";
	Session session = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		Query q = session.createQuery(qs);
		q.setString("event", event);
		q.setString("at", at);
		List<AutomationRule> ret = q.list();
		initializeRules(ret);
		log.debug("findByEvent: {}", ret);
		return ret;
	} catch (HibernateException e) {
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 15
/**
 * Find by user source
 */
@SuppressWarnings("unchecked")
public static List<Dashboard> findByUserSource(String user, String source) throws
		DatabaseException {
	log.debug("findByUserSource({}, {})", user, source);
	String qs = "from Dashboard db where db.user=:user and db.source=:source";
	Session session = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		Query q = session.createQuery(qs);
		q.setString("user", user);
		q.setString("source", source);
		List<Dashboard> ret = q.list();
		log.debug("findByUserSource: " + ret);
		return ret;
	} catch (HibernateException e) {
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 16
/**
 * Delete received proposed subscription
 */
public static void deleteReceived(int psId) throws DatabaseException {
	log.debug("deleteReceived({})", psId);
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		ProposedSubscriptionReceived ps = (ProposedSubscriptionReceived) session.load(ProposedSubscriptionReceived.class, psId);
		session.delete(ps);
		HibernateUtil.commit(tx);
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}

	log.debug("delete: void");
}
 
Example 17
/**
 * Remove forum topics by parent node 
 */
@SuppressWarnings("unchecked")
public static void purgeTopicsByNode(String nodeUuid) throws DatabaseException {
	log.debug("purgeTopicsByNode({})", nodeUuid);
	String qs = "from ForumTopic ft where ft.node=:uuid";
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();

		Query q = session.createQuery(qs);
		q.setString("uuid", nodeUuid);

		for (ForumTopic ft : (List<ForumTopic>) q.list()) {
			session.delete(ft);
		}

		HibernateUtil.commit(tx);
		log.debug("purgeTopicsByNode: void");
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}
}
 
Example 18
/**
 * Group List
 */
@SuppressWarnings("unchecked")
private void groupList(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, DatabaseException,
		PrincipalAdapterException {
	log.debug("groupList({}, {})", new Object[]{request, response});
	ServletContext sc = getServletContext();
	String qs = "select distinct (dmv.col00) from DatabaseMetadataValue dmv where dmv.table='group' order by dmv.col00";
	org.hibernate.Session dbSession = null;
	Transaction tx = null;

	try {
		dbSession = HibernateUtil.getSessionFactory().openSession();
		tx = dbSession.beginTransaction();
		Query q = dbSession.createQuery(qs);
		List<String> groups = q.list();
		sc.setAttribute("groups", groups);
		HibernateUtil.commit(tx);
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(dbSession);
	}

	sc.getRequestDispatcher("/admin/document_expiration_group_list.jsp").forward(request, response);
	log.debug("groupList: void");
}
 
Example 19
protected int executeCountQuery(String query) {
    Long count;
    try {
        count = (Long) sessionFactory.getCurrentSession().createQuery(query).uniqueResult();
    } catch (HibernateException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    return count.intValue();
}
 
Example 20
/**
 * Create a new HibernateSystemException,
 * wrapping an arbitrary HibernateException.
 * @param cause the HibernateException thrown
 */
public HibernateSystemException(HibernateException cause) {
	super(cause != null ? cause.getMessage() : null, cause);
}