本文整理汇总了Java中net.sf.hibernate.HibernateException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java HibernateException.getMessage方法的具体用法?Java HibernateException.getMessage怎么用?Java HibernateException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.hibernate.HibernateException
的用法示例。
在下文中一共展示了HibernateException.getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Specify the underlying <tt>SessionFactory</tt>, by passing a JNDI name.
* The <tt>accessMode</tt> is ignored by Hibernate.
* @see org.odmg.Database#open(String, int)
*/
public void open(String name, int accessMode) throws ODMGException {
try {
new Configuration().configure();
}
catch (HibernateException he) {
throw new ODMGException( he.getMessage() );
}
sessionFactory = (SessionFactory) SessionFactoryObjectFactory.getNamedInstance(name);
if (sessionFactory==null) throw new ODMGException("No SessionFactory was associated with the given JDNI name");
/*try {
sessionFactory = (SessionFactory) NamingHelper.getInitialContext( Environment.getProperties() ).lookup(name);
}
catch (NamingException ne) {
throw new ODMGException( ne.getMessage() );
}*/
}
示例2: lookup
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Retrieve the persistent object bound to the given name.
* @see org.odmg.Database#lookup(String)
*/
public Object lookup(String name) throws ObjectNameNotFoundException {
try {
Session s = getSession();
Name nameObj;
try {
nameObj = (Name) s.load(Name.class, name);
}
catch (ObjectNotFoundException onfe) {
throw new ObjectNameNotFoundException();
}
return s.load( nameObj.getPersistentClass(), nameObj.getId() );
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例3: unbind
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Unbind the given name.
* @see org.odmg.Database#unbind(String)
*/
public void unbind(String name) throws ObjectNameNotFoundException {
try {
Session s = getSession();
Name nameObj;
try {
nameObj = (Name) s.load(Name.class, name);
}
catch (ObjectNotFoundException onfe) {
throw new ObjectNameNotFoundException();
}
s.delete(nameObj);
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例4: Transaction
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Instantiate a <tt>Transaction</tt> for the given <tt>Database</tt>.
*/
public Transaction(org.odmg.Database database) throws ODMGException {
this.database = (Database) database;
try {
this.session = this.database.getSessionFactory().openSession();
}
catch (HibernateException he) {
throw new ODMGException( he.getMessage() );
}
this.database.associateThread(this);
}
示例5: begin
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Begin the transaction. JavaDoc requires a second sentence.
*
* @see org.odmg.Transaction#begin()
*/
public void begin() {
try {
tx = session.beginTransaction();
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例6: checkpoint
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Commit the changes, but leave the transaction open. This implementation
* does not have quite the same semantics os ODMG (locks are not retained).
* So you should only use this with versioned data.
*
* @see org.odmg.Transaction#checkpoint()
*/
public void checkpoint() {
try {
tx.commit();
tx = session.beginTransaction();
}
catch (HibernateException he)
{
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例7: lock
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Obtain a lock upon the given object. In the present implementation,
* <tt>READ</tt> lock mode is ignored while <tt>UPGRADE</tt> and
* <tt>WRITE</tt> lock modes obtain an <tt>UPGRADE</tt> lock for databases
* which support <tt>for update</tt>. We should improve this eventually....
*
* @see org.odmg.Transaction#lock(Object, int)
*/
public void lock(Object obj, int lockMode) throws LockNotGrantedException {
//TODO: check the semantics of this...
try {
if ( lockMode==org.odmg.Transaction.READ ) {
session.lock(obj, LockMode.READ);
}
else {
session.lock(obj, LockMode.UPGRADE);
}
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例8: getObjectId
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Get the stringified identifier of the given object.
* @see org.odmg.Implementation#getObjectId(Object)
*/
public String getObjectId(Object obj) {
try {
return database.getSession().getIdentifier(obj).toString();
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例9: create
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Set the Hibernate query string. Scalar return values are not supported.
* @see org.odmg.OQLQuery#create(String)
*/
public void create(String queryString) throws QueryInvalidException {
//TODO: the right exception
try {
this.query = tx.getSession().createQuery(queryString);
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例10: bind
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Bind a value to the next enumerated parameter. JavaDoc requires a second sentence.
*
* @see org.odmg.OQLQuery#bind(Object)
*/
public void bind(Object parameter) throws QueryParameterCountInvalidException, QueryParameterTypeInvalidException {
//TODO: the right exception
try {
query.setParameter(param++, parameter);
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例11: execute
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Get the query results as a collection. JavaDoc requires a second sentence.
* @see org.odmg.OQLQuery#execute()
*/
public Object execute() throws QueryException {
//TODO: how are results meant to be returned in ODMG?
try {
return query.list();
}
catch (HibernateException he)
{
throw new QueryException( he.getMessage() );
}
}
示例12: bind
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Bind a name to a persistent object, making the object persistent if necessary.
* @see org.odmg.Database#bind(Object, String)
*/
public void bind(Object object, String name) throws ObjectNameNotUniqueException {
try {
Session s = getSession();
Name nameObj = new Name( name, object.getClass(), s.save(object) );
s.save(nameObj);
//TODO: handle ObjectNameNotUniqueException properly
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例13: makePersistent
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Make the given object persistent.
* @see org.odmg.Database#makePersistent(Object)
*/
public void makePersistent(Object object) {
try {
getSession().save(object);
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例14: deletePersistent
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* Delete the given object from the database.
* @see org.odmg.Database#deletePersistent(Object)
*/
public void deletePersistent(Object object) {
try {
getSession().delete(object);
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
示例15: existsElement
import net.sf.hibernate.HibernateException; //导入方法依赖的package包/类
/**
* @see org.odmg.DCollection#existsElement(String)
*/
public boolean existsElement(String queryString) throws QueryInvalidException {
//return select(queryString).hasNext();
try {
return ( (Integer) getSession().filter( this, "select count(*) " + queryString ).iterator().next() ).intValue() > 0;
}
catch (HibernateException he) {
throw new QueryInvalidException( he.getMessage() );
}
}