本文整理匯總了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);
}