⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 embeddedcomponenttype.java

📁 hibernate-3.1.3-all-src.zip 面向对象的访问数据库工具
💻 JAVA
字号:
//$Id: EmbeddedComponentType.java 7670 2005-07-29 05:36:14Z oneovthafew $
package org.hibernate.type;

import java.lang.reflect.Method;

import org.hibernate.EntityMode;
import org.hibernate.FetchMode;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.engine.CascadeStyle;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.tuple.ComponentTuplizer;
import org.hibernate.tuple.TuplizerLookup;

/**
 * @author Gavin King
 */
public class EmbeddedComponentType extends ComponentType {

	public boolean isEmbedded() {
		return true;
	}
	
	public EmbeddedComponentType(
			String[] propertyNames,
			Type[] propertyTypes,
			boolean[] nullabilities, 
			FetchMode[] joinedFetch,
			CascadeStyle[] cascade,
			boolean key,
			TuplizerLookup tuplizers)
	throws MappingException {
		super(
				propertyNames, 
				propertyTypes, 
				nullabilities, 
				joinedFetch,
				cascade,
				key,
				tuplizers
			);
	}
	
	public boolean isMethodOf(Method method) {
		return ( (ComponentTuplizer) tuplizers.getTuplizer(EntityMode.POJO) ).isMethodOf(method);
	}
	
	public Object instantiate(Object parent, SessionImplementor session)
	throws HibernateException {
		final boolean useParent = parent!=null && 
			//TODO: Yuck! This is not quite good enough, it's a quick 
			//hack around the problem of having a to-one association
			//that refers to an embedded component:
			super.getReturnedClass().isInstance(parent);
		
		return useParent ? parent : super.instantiate(parent, session);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -