本文整理汇总了Java中org.hibernate.HibernateException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java HibernateException.getMessage方法的具体用法?Java HibernateException.getMessage怎么用?Java HibernateException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.HibernateException
的用法示例。
在下文中一共展示了HibernateException.getMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKeys
import org.hibernate.HibernateException; //导入方法依赖的package包/类
public Collection<String> getKeys(Long piid, String prefix, Type type) {
if( piid == null)
throw new PersistentVarsException("Could not find keys for 'null' piid");
Session session = null;
Transaction transaction = null;
Collection<String> list = null;
try {
session = sessionFactory.openSession();
transaction = session.beginTransaction();
list = getKeysImpl(session, piid, prefix, type);
transaction.commit();
} catch (HibernateException hibernateException) {
throw new PersistentVarsException("HibernatePropertySet.getKeys: " + hibernateException.getMessage());
} finally {
if (transaction != null && transaction.isActive())
transaction.rollback();
if (session != null)
session.close();
}
return list;
}
示例2: save
import org.hibernate.HibernateException; //导入方法依赖的package包/类
public void save(HibernatePersistentVarsItem item) {
if( item == null)
throw new PersistentVarsException("Could not save 'null' PropertyItem");
Session session = null;
Transaction transaction = null;
try {
session = this.sessionFactory.openSession();
transaction = session.beginTransaction();
session.saveOrUpdate(item);
session.flush();
transaction.commit();
} catch (HibernateException hibernateException) {
throw new PersistentVarsException("Could not save key '" + item.getKey() + "':" + hibernateException.getMessage());
} finally {
if (transaction != null && transaction.isActive())
transaction.rollback();
if (session != null)
session.close();
}
}
示例3: findByKey
import org.hibernate.HibernateException; //导入方法依赖的package包/类
public HibernatePersistentVarsItem findByKey(Long piid, String key) {
if( piid == null)
throw new PersistentVarsException("Could not find property for 'null' piid");
if( key == null)
throw new PersistentVarsException("Could not find property for 'null' key");
Session session = null;
Transaction transaction = null;
HibernatePersistentVarsItem item = null;
try {
session = sessionFactory.openSession();
transaction = session.beginTransaction();
item = getItem(session, piid, key);
session.flush();
transaction.commit();
} catch (HibernateException hibernateException) {
throw new PersistentVarsException("Could not find key '" + key + "': " + hibernateException.getMessage());
} finally {
if (transaction != null && transaction.isActive())
transaction.rollback();
if (session != null)
session.close();
}
return item;
}
示例4: remove
import org.hibernate.HibernateException; //导入方法依赖的package包/类
public void remove(Long piid, String key) {
if( piid == null)
throw new PersistentVarsException("Could not remove property for 'null' piid");
if( key == null)
throw new PersistentVarsException("Could not remove property with 'null' key");
Session session = null;
Transaction transaction = null;
try {
session = this.sessionFactory.openSession();
transaction = session.beginTransaction();
session.delete(getItem(session, piid, key));
session.flush();
transaction.commit();
} catch (HibernateException hibernateException) {
throw new PersistentVarsException("Could not remove key '" + key + "': " + hibernateException.getMessage());
} finally {
if (transaction != null && transaction.isActive())
transaction.rollback();
if (session != null)
session.close();
}
}
示例5: create
import org.hibernate.HibernateException; //导入方法依赖的package包/类
public HibernatePersistentVarsItem create(Long piid, String key) {
if( piid == null)
throw new PersistentVarsException("Could not create property with 'null' piid");
if( key == null)
throw new PersistentVarsException("Could not create property with 'null' key");
Session session = null;
Transaction transaction = null;
HibernatePersistentVarsItem item = new HibernatePersistentVarsItem(piid, key);
try {
session = this.sessionFactory.openSession();
transaction = session.beginTransaction();
session.save(item);
transaction.commit();
} catch (HibernateException hibernateException) {
throw new PersistentVarsException("Could not save key '" + key + "': " + hibernateException.getMessage());
} finally {
if (transaction != null && transaction.isActive())
transaction.rollback();
if (session != null)
session.close();
}
return item;
}
示例6: HibernateSystemException
import org.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Create a new HibernateSystemException,
* wrapping an arbitrary HibernateException.
* @param cause the HibernateException thrown
*/
public HibernateSystemException(HibernateException cause) {
super(cause != null ? cause.getMessage() : null, cause);
}