• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HibernateException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.sf.hibernate.HibernateException的典型用法代码示例。如果您正苦于以下问题:Java HibernateException类的具体用法?Java HibernateException怎么用?Java HibernateException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HibernateException类属于net.sf.hibernate包,在下文中一共展示了HibernateException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
public void execute() throws HibernateException {
	ClassPersister persister = getPersister();
	SessionImplementor session = getSession();
	Object object = getInstance();

	// Don't need to lock the cache here, since if someone
	// else inserted the same pk first, the insert would fail

	generatedId = persister.insert(state, object, session);

	//TODO: this bit actually has to be called after all cascades!
	/*if ( persister.hasCache() && !persister.isCacheInvalidationRequired() ) {
		cacheEntry = new CacheEntry(object, persister, session);
		persister.getCache().insert(generatedId, cacheEntry);
	}*/
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:ScheduledIdentityInsertion.java


示例2: update

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
/**
 * Update an object
 */
public void update(Serializable id, Object[] fields, int[] dirtyFields, Object[] oldFields, Object oldVersion, Object object, SessionImplementor session) 
throws HibernateException {
	//note: dirtyFields==null means we had no snapshot, and we couldn't get one using select-before-update
	//      oldFields==null just means we had no snapshot to begin with (we might have used select-before-update to get the dirtyFields)
	final boolean[] propsToUpdate;
	final String updateString;
	if ( useDynamicUpdate() && dirtyFields!=null ) {
		propsToUpdate = getPropertiesToUpdate(dirtyFields);
		updateString = generateUpdateString(propsToUpdate, oldFields);
		//don't need to check property updatability (dirty checking algorithm handles that)
	}
	else {
		propsToUpdate = getPropertyUpdateability();
		updateString = getSQLUpdateString();
	}

	update(id, fields, oldFields, propsToUpdate, oldVersion, object, updateString, session);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:EntityPersister.java


示例3: bindNamedParameters

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
protected int bindNamedParameters(PreparedStatement ps, Map namedParams, int start, SessionImplementor session) 
throws SQLException, HibernateException {
	if (namedParams != null) {
		// assumes that types are all of span 1
		Iterator iter = namedParams.entrySet().iterator();
		int result = 0;
		while ( iter.hasNext() ) {
			Map.Entry e = (Map.Entry) iter.next();
			String name = (String) e.getKey();
			TypedValue typedval = (TypedValue) e.getValue();
			int[] locs = getNamedParameterLocs(name);
			for (int i = 0; i < locs.length; i++) {
				typedval.getType().nullSafeSet(ps, typedval.getValue(), locs[i] + start, session);
			}
			result += locs.length;
		}
		return result;
	}
	else {
		return 0;
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:SQLLoader.java


示例4: getEntityIdentifierIfNotUnsaved

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
/**
 * Used by OneToOneType and ManyToOneType to determine what id value should be used for an
 * object that may or may not be associated with the session. This does a "best guess" using
 * any/all info available to use (not just the EntityEntry).
 */
public Serializable getEntityIdentifierIfNotUnsaved(Object object) throws HibernateException {
	if (object == null) {
		return null;
	}
	else {
		if (object instanceof HibernateProxy) {
			return HibernateProxyHelper.getLazyInitializer( (HibernateProxy) object ).getIdentifier();
		}
		else {

			EntityEntry entry = getEntry(object);
			if (entry!=null) {
				return entry.id;
			}
			else {
				Boolean isUnsaved = interceptor.isUnsaved(object);
				if ( isUnsaved!=null && isUnsaved.booleanValue() ) throwTransientObjectException(object);
				ClassPersister persister = getPersister(object);
				if ( persister.isUnsaved(object) ) throwTransientObjectException(object);
				return persister.getIdentifier(object);
			}
		}
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:SessionImpl.java


示例5: getTypedValues

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
public TypedValue[] getTypedValues(SessionFactoryImplementor sessionFactory, Class persistentClass, Map aliasClasses) 
throws HibernateException {
	ArrayList list = new ArrayList();
	Type type = getType(sessionFactory, persistentClass, propertyName, aliasClasses);
	if ( type.isComponentType() ) {
		AbstractComponentType actype = (AbstractComponentType) type;
		Type[] types = actype.getSubtypes();
		for ( int i=0; i<types.length; i++ ) {
			for ( int j=0; j<values.length; j++ ) {
				Object subval = values[j]==null ? 
					null : 
					actype.getPropertyValues( values[j] )[i];
				list.add( new TypedValue( types[i], subval ) );
			}
		}
	}
	else {
		for ( int j=0; j<values.length; j++ ) {
			list.add( new TypedValue( type, values[j] ) );
		}
	}
	return (TypedValue[]) list.toArray( new TypedValue[ list.size() ] );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:InExpression.java


示例6: hydrate

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
/**
 * Unmarshall the fields of a persistent instance from a result set,
 * without resolving associations or collections
 */
private Object[] hydrate(
	final ResultSet rs, 
	final Serializable id, 
	final Object object, 
	final Loadable persister, 
	final SessionImplementor session, 
	final String[][] suffixedPropertyColumns)
throws SQLException, HibernateException {

	if ( log.isTraceEnabled() ) log.trace("Hydrating entity: " + persister.getClassName() + '#' + id);

	Type[] types = persister.getPropertyTypes();
	Object[] values = new Object[ types.length ];

	for (int i=0; i<types.length; i++) {
		values[i] = types[i].hydrate(rs, suffixedPropertyColumns[i], session, object);
	}
	return values;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:Loader.java


示例7: saveChangeList

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
private int saveChangeList(final ChangeList chl, final Session session) throws HibernateException {
  session.saveOrUpdate(chl);
  // set synthetic change list number if necessary
  final int changeListID = chl.getChangeListID();
  if (StringUtils.isBlank(chl.getNumber())) {
    chl.setNumber(Integer.toString(changeListID));
    session.saveOrUpdate(chl);
  }
  for (final Iterator iter = chl.getChanges().iterator(); iter.hasNext(); ) {
    final Change ch = (Change) iter.next();
    if (ch.getChangeListID() == ChangeList.UNSAVED_ID) {
      ch.setChangeListID(changeListID);
    }
    session.saveOrUpdate(ch);
  }
  return changeListID;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:ConfigurationManager.java


示例8: initializeNonLazyCollections

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
public void initializeNonLazyCollections() throws HibernateException {
	if (loadCounter==0) {
		log.debug( "initializing non-lazy collections");
		//do this work only at the very highest level of the load
		loadCounter++; //don't let this method be called recursively
		try {
			int size;
			while( ( size=nonlazyCollections.size() ) > 0 ) {
				//note that each iteration of the loop may add new elements
				( (PersistentCollection) nonlazyCollections.remove(size-1) ).forceInitialization();
			}
		}
		finally {
			loadCounter--;
		}
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:SessionImpl.java


示例9: getType

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
protected static Type getType(
		SessionFactoryImplementor sessionFactory,
		Class persistentClass,
		String property,
		Map aliasClasses)
throws HibernateException {
	if ( property.indexOf('.')>0 ) {
		String root = StringHelper.root(property);
		Class clazz = (Class) aliasClasses.get(root);
		if (clazz!=null) {
			persistentClass = clazz;
			property = property.substring( root.length()+1 );
		}
	}
	return getPropertyMapping(persistentClass, sessionFactory).toType(property);
	
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:AbstractCriterion.java


示例10: identityRemove

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
static void identityRemove(Collection list, Object object, SessionImplementor session) 
throws HibernateException {
	
	if ( object!=null && session.isSaved(object) ) {
	
		Serializable idOfCurrent = session.getEntityIdentifierIfNotUnsaved(object);
		Iterator iter = list.iterator();
		while ( iter.hasNext() ) {
			Serializable idOfOld = session.getEntityIdentifierIfNotUnsaved( iter.next() );
			if ( idOfCurrent.equals(idOfOld) ) {
				iter.remove();
				break;
			}
		}
		
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:PersistentCollection.java


示例11: buildSQLExceptionConverter

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
/**
 * Build a SQLExceptionConverter instance.
 * <p/>
 * First, looks for a {@link Environment.SQL_EXCEPTION_CONVERTER} property to see
 * if the configuration specified the class of a specific converter to use.  If this
 * property is set, attempt to construct an instance of that class.  If not set, or
 * if construction fails, the converter specific to the dialect will be used.
 *
 * @param dialect The defined dialect.
 * @param properties The configuration properties.
 * @return An appropriate SQLExceptionConverter instance.
 * @throws HibernateException There was an error building the SQLExceptionConverter.
 */
public static SQLExceptionConverter buildSQLExceptionConverter(Dialect dialect, Properties properties) throws HibernateException {
	SQLExceptionConverter converter = null;

	String converterClassName = (String) properties.get(Environment.SQL_EXCEPTION_CONVERTER);
	if (StringHelper.isNotEmpty(converterClassName)) {
		converter = constructConverter(converterClassName, dialect.getViolatedConstraintNameExtracter());
	}

	if (converter == null) {
		log.trace("Using dialect defined converter");
		converter = dialect.buildSQLExceptionConverter();
	}

	if (converter instanceof Configurable) {
		try {
			((Configurable) converter).configure(properties);
		} catch (HibernateException e) {
			log.warn("Unable to configure SQLExceptionConverter", e);
			throw e;
		}
	}

	return converter;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:38,代码来源:SQLExceptionConverterFactory.java


示例12: doUpdate

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
private void doUpdate(Object object, Serializable id, ClassPersister persister) throws HibernateException {

		if ( !persister.isMutable() ) {
			log.trace("immutable instance passed to doUpdate(), locking");
			reassociate(object, id, persister);
		}
		else {
			doUpdateMutable(object, id, persister);
		}

		cascading++;
		try {
			Cascades.cascade(this, persister, object, Cascades.ACTION_SAVE_UPDATE, Cascades.CASCADE_ON_UPDATE);  // do cascade
		}
		finally {
			cascading--;
		}

	}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:SessionImpl.java


示例13: update

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
/**
 * Update an object
 */
public void update(Serializable id, Object[] fields, int[] dirtyFields, Object[] oldFields, Object oldVersion, Object object, SessionImplementor session) throws HibernateException {

	final boolean[] tableUpdateNeeded = getTableUpdateNeeded(dirtyFields);
	
	final String[] updateStrings;
	final boolean[] propsToUpdate;
	if ( useDynamicUpdate() && dirtyFields!=null ) {
		// decide which columns we really need to update
		propsToUpdate = getPropertiesToUpdate(dirtyFields);
		updateStrings = generateUpdateStrings(propsToUpdate);
	}
	else {
		// just update them all
		propsToUpdate = getPropertyUpdateability();
		updateStrings = getSQLUpdateStrings();
	}
	
	update(id, fields, propsToUpdate, tableUpdateNeeded, oldVersion, object, updateStrings, session);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:NormalizedEntityPersister.java


示例14: toString

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
/**
 * @param entity an actual entity object, not a proxy!
 */
public String toString(Object entity) throws HibernateException {
	
	ClassMetadata cm = factory.getClassMetadata( entity.getClass() );
	if ( cm==null ) return entity.getClass().getName();
	
	Map result = new HashMap();
	
	if ( cm.hasIdentifierProperty() ) {
		result.put( 
			cm.getIdentifierPropertyName(), 
			cm.getIdentifierType().toString( cm.getIdentifier(entity), factory ) 
		);
	}
	
	Type[] types = cm.getPropertyTypes();
	String[] names = cm.getPropertyNames();
	Object[] values = cm.getPropertyValues(entity);
	for ( int i=0; i<types.length; i++ ) {
		result.put( names[i], types[i].toString( values[i], factory ) );
	}
	return cm.getMappedClass().getName() + result.toString();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:Printer.java


示例15: iterateFilter

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException {

		String[] concreteFilters = QueryTranslator.concreteQueries(filter, factory);
		FilterTranslator[] filters = new FilterTranslator[ concreteFilters.length ];

		for ( int i=0; i<concreteFilters.length; i++ ) {
			filters[i] = getFilterTranslator(collection, concreteFilters[i], queryParameters, true);
		}

		if (filters.length==0) return Collections.EMPTY_LIST.iterator();

		Iterator result = null;
		Iterator[] results = null;
		boolean many = filters.length>1;
		if (many) results = new Iterator[filters.length];

		//execute the queries and return all results as a single iterator
		for ( int i=0; i<filters.length; i++ ) {

			try {
				result = filters[i].iterate(queryParameters, this);
			}
			catch (SQLException sqle) {
				throw convert( sqle, "Could not execute query" );
			}
			if ( many ) {
				results[i] = result;
			}

		}

		return many ? new JoinedIterator(results) : result;

	}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:SessionImpl.java


示例16: put

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
public void put(QueryKey key, Type[] returnTypes, List result, SessionImplementor session) throws HibernateException {
	if ( log.isDebugEnabled() ) log.debug("caching query results in region: " + regionName);
	List cacheable = new ArrayList( result.size()+1 );
	cacheable.add( new Long( session.getTimestamp() ) );
	for ( int i=0; i<result.size(); i++ ) {
		if ( returnTypes.length==1 ) {
			cacheable.add( returnTypes[0].disassemble( result.get(i), session ) );
		}
		else {
			cacheable.add( TypeFactory.disassemble( (Object[]) result.get(i), returnTypes, session ) );
		}
	}
	queryCache.put(key, cacheable);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:StandardQueryCache.java


示例17: 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() );
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:OQLQuery.java


示例18: getDialect

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
/**
 * Get the <tt>Dialect</tt> specified by the given properties or system properties.
 * @param props
 * @return Dialect
 * @throws HibernateException
 */
public static Dialect getDialect(Properties props) throws HibernateException {
	String dialectName = props.getProperty(Environment.DIALECT);
	if (dialectName== null) return getDialect();
	try {
		return (Dialect) ReflectHelper.classForName(dialectName).newInstance();
	}
	catch (ClassNotFoundException cnfe) {
		throw new HibernateException("Dialect class not found: " + dialectName);
	}
	catch (Exception e) {
		throw new HibernateException( "Could not instantiate dialect class", e );
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:Dialect.java


示例19: writeIndex

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
/**
 * Write the index to a JDBC <tt>PreparedStatement</tt>
 */
public void writeIndex(
	PreparedStatement st,
	Object idx,
	boolean writeOrder,
	SessionImplementor session)
	throws HibernateException, SQLException;
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:CollectionPersister.java


示例20: setTypeByReflection

import net.sf.hibernate.HibernateException; //导入依赖的package包/类
public void setTypeByReflection(Class propertyClass, String propertyName) throws MappingException {
	try {
		if (getType()==null) setType( TypeFactory.manyToOne(
			ReflectHelper.reflectedPropertyClass(propertyClass, propertyName),
			referencedPropertyName
		) );
	}
	catch (HibernateException he) {
		throw new MappingException( "Problem trying to set association type by reflection", he );
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:12,代码来源:ManyToOne.java



注:本文中的net.sf.hibernate.HibernateException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ObjectIdDigestUtils类代码示例发布时间:2022-05-22
下一篇:
Java Vectors类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap