`
sctom123
  • 浏览: 110052 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

defalut entityname

 
阅读更多
		String entityName = node.attributeValue( "entity-name" );
		if ( entityName == null ) entityName = getClassName( node.attribute("name"), mappings );
		if ( entityName==null ) {
			throw new MappingException( "Unable to determine entity name" );
		}
		persistentClass.setEntityName( entityName );


	private static String getClassName(String unqualifiedName, Mappings model) {
		if ( unqualifiedName == null ) return null;
		if ( unqualifiedName.indexOf( '.' ) < 0 && model.getDefaultPackage() != null ) {
			return model.getDefaultPackage() + '.' + unqualifiedName;
		}
		return unqualifiedName;
	}


	public String guessEntityName(Object object) throws HibernateException {
		errorIfClosed();
		String entity = interceptor.getEntityName( object );
		if ( entity == null ) {
			if ( object instanceof Map ) {
				entity = (String) ( (Map) object ).get( DynamicMapInstantiator.KEY );
				if ( entity == null ) {
					throw new HibernateException( "could not determine type of dynamic entity" );
				}
			}
			else if ( object instanceof Element ) {
				// TODO : really need to keep a map of nodeName -> entityName, but that would mean nodeName being distinct
				entity = ( (Element) object ).getName();
			}
			else {
				entity = object.getClass().getName();
			}
		}
		return entity;
	}

	/**
	 * Return the names of all persistent (mapped) classes that extend or implement the
	 * given class or interface, accounting for implicit/explicit polymorphism settings
	 * and excluding mapped subclasses/joined-subclasses of other classes in the result.
	 */
	public String[] getImplementors(String className) throws MappingException {

		final Class clazz;
		try {
			clazz = ReflectHelper.classForName(className);
		}
		catch (ClassNotFoundException cnfe) {
			return new String[] { className }; //for a dynamic-class
		}

		ArrayList results = new ArrayList();
		Iterator iter = entityPersisters.values().iterator();
		while ( iter.hasNext() ) {
			//test this entity to see if we must query it
			EntityPersister testPersister = (EntityPersister) iter.next();
			if ( testPersister instanceof Queryable ) {
				Queryable testQueryable = (Queryable) testPersister;
				String testClassName = testQueryable.getEntityName();
				boolean isMappedClass = className.equals(testClassName);
				if ( testQueryable.isExplicitPolymorphism() ) {
					if ( isMappedClass ) {
						return new String[] {className}; //NOTE EARLY EXIT
					}
				}
				else {
					if (isMappedClass) {
						results.add(testClassName);
					}
					else {
						final Class mappedClass = testQueryable.getMappedClass( EntityMode.POJO );
						if ( mappedClass!=null && clazz.isAssignableFrom( mappedClass ) ) {
							final boolean assignableSuperclass;
							if ( testQueryable.isInherited() ) {
								Class mappedSuperclass = getEntityPersister( testQueryable.getMappedSuperclass() ).getMappedClass( EntityMode.POJO);
								assignableSuperclass = clazz.isAssignableFrom(mappedSuperclass);
							}
							else {
								assignableSuperclass = false;
							}
							if ( !assignableSuperclass ) {
								results.add( testClassName );
							}
						}
					}
				}
			}
		}
		return (String[]) results.toArray( new String[ results.size() ] );
	}

	/**
	 * 这个方法实际上并不是getClassName,而是getAdaptEntityName
	 * 它是为了那种偷懒的写法 from A
	 * 如果都写成from com.A,应该是就不会用到这个方法了。
	 */
	public String getImportedClassName(String className) {
		String result = (String) imports.get(className);
		if (result==null) {
			try {
				ReflectHelper.classForName(className);
				return className;
			}
			catch (ClassNotFoundException cnfe) {
				return null;
			}
		}
		else {
			return result;
		}
	}
分享到:
评论
1 楼 ruruhuang 2006-11-10  
buaawhl 写道
吵架的声音都听得到,楼距应该不远。不一定是自己跳的。
也许会作为目击证人受到警察的盘问?

---------------------------

如果是自杀,为什么要选择跳楼呢?
自杀真的很难。最好的自杀方法应该是杜冷丁安乐死,在欲仙浴死的幻觉中死去。可惜成本太高,一般人负担不起。
武林高手也可以自断经脉而死。藏密高手可以虹化而去。
普通人自杀都这么难。




不知道警察会不会来,不过我觉得不会是自杀。因为那个门楼下是台阶,如果真的自杀,跳下去会摔很难看的。

我觉得,女人一般不会选择这么难看的自杀的。

相关推荐

Global site tag (gtag.js) - Google Analytics