本文整理汇总了Java中org.hibernate.property.Getter.getMethod方法的典型用法代码示例。如果您正苦于以下问题:Java Getter.getMethod方法的具体用法?Java Getter.getMethod怎么用?Java Getter.getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.property.Getter
的用法示例。
在下文中一共展示了Getter.getMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildProxyFactory
import org.hibernate.property.Getter; //导入方法依赖的package包/类
@Override
protected ProxyFactory buildProxyFactory(EntityBinding entityBinding, Getter idGetter, Setter idSetter) {
// determine the id getter and setter methods from the proxy interface (if any)
// determine all interfaces needed by the resulting proxy
HashSet<Class> proxyInterfaces = new HashSet<Class>();
proxyInterfaces.add( HibernateProxy.class );
Class mappedClass = entityBinding.getEntity().getClassReference();
Class proxyInterface = entityBinding.getProxyInterfaceType().getValue();
if ( proxyInterface!=null && !mappedClass.equals( proxyInterface ) ) {
if ( ! proxyInterface.isInterface() ) {
throw new MappingException(
"proxy must be either an interface, or the class itself: " + getEntityName()
);
}
proxyInterfaces.add( proxyInterface );
}
if ( mappedClass.isInterface() ) {
proxyInterfaces.add( mappedClass );
}
for ( EntityBinding subEntityBinding : entityBinding.getPostOrderSubEntityBindingClosure() ) {
final Class subclassProxy = subEntityBinding.getProxyInterfaceType().getValue();
final Class subclassClass = subEntityBinding.getClassReference();
if ( subclassProxy!=null && !subclassClass.equals( subclassProxy ) ) {
if ( ! subclassProxy.isInterface() ) {
throw new MappingException(
"proxy must be either an interface, or the class itself: " + subEntityBinding.getEntity().getName()
);
}
proxyInterfaces.add( subclassProxy );
}
}
for ( AttributeBinding property : entityBinding.attributeBindings() ) {
Method method = getGetter( property ).getMethod();
if ( method != null && Modifier.isFinal( method.getModifiers() ) ) {
LOG.gettersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName());
}
method = getSetter( property ).getMethod();
if ( method != null && Modifier.isFinal( method.getModifiers() ) ) {
LOG.settersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName());
}
}
Method idGetterMethod = idGetter==null ? null : idGetter.getMethod();
Method idSetterMethod = idSetter==null ? null : idSetter.getMethod();
Method proxyGetIdentifierMethod = idGetterMethod==null || proxyInterface==null ?
null :
ReflectHelper.getMethod(proxyInterface, idGetterMethod);
Method proxySetIdentifierMethod = idSetterMethod==null || proxyInterface==null ?
null :
ReflectHelper.getMethod(proxyInterface, idSetterMethod);
ProxyFactory pf = buildProxyFactoryInternal( entityBinding, idGetter, idSetter );
try {
pf.postInstantiate(
getEntityName(),
mappedClass,
proxyInterfaces,
proxyGetIdentifierMethod,
proxySetIdentifierMethod,
entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded()
? ( CompositeType ) entityBinding
.getHierarchyDetails()
.getEntityIdentifier()
.getValueBinding()
.getHibernateTypeDescriptor()
.getResolvedTypeMapping()
: null
);
}
catch ( HibernateException he ) {
LOG.unableToCreateProxyFactory(getEntityName(), he);
pf = null;
}
return pf;
}
示例2: buildProxyFactory
import org.hibernate.property.Getter; //导入方法依赖的package包/类
@Override
protected ProxyFactory buildProxyFactory(PersistentClass thePersistentClass, Getter idGetter,
Setter idSetter) {
final Class<?> mappedClass = thePersistentClass.getMappedClass();
Check.isNotNull(mappedClass, "Mapped class of entity " + thePersistentClass.getEntityName()
+ " is null");
// determine the id getter and setter methods from the proxy interface
// (if
// any)
// determine all interfaces needed by the resulting proxy
final HashSet<Object> proxyInterfaces = new HashSet<Object>();
proxyInterfaces.add(HibernateProxy.class);
final Class<?> proxyInterface = thePersistentClass.getProxyInterface();
if (proxyInterface != null && !mappedClass.equals(proxyInterface)) {
if (!proxyInterface.isInterface()) {
throw new MappingException("proxy must be either an interface, or the class itself: "
+ getEntityName());
}
proxyInterfaces.add(proxyInterface);
}
if (mappedClass.isInterface()) {
proxyInterfaces.add(mappedClass);
}
final Iterator<?> iter = thePersistentClass.getSubclassIterator();
while (iter.hasNext()) {
final Subclass subclass = (Subclass) iter.next();
final Class<?> subclassProxy = subclass.getProxyInterface();
final Class<?> subclassClass = subclass.getMappedClass();
if (subclassProxy != null && !subclassClass.equals(subclassProxy)) {
if (proxyInterface == null || !proxyInterface.isInterface()) {
throw new MappingException("proxy must be either an interface, or the class itself: "
+ subclass.getEntityName());
}
proxyInterfaces.add(subclassProxy);
}
}
final Method idGetterMethod = idGetter == null ? null : idGetter.getMethod();
final Method idSetterMethod = idSetter == null ? null : idSetter.getMethod();
final Method proxyGetIdentifierMethod = idGetterMethod == null || proxyInterface == null ? null
: ReflectHelper.getMethod(proxyInterface, idGetterMethod);
final Method proxySetIdentifierMethod = idSetterMethod == null || proxyInterface == null ? null
: ReflectHelper.getMethod(proxyInterface, idSetterMethod);
ProxyFactory pf = buildProxyFactoryInternal(thePersistentClass, idGetter, idSetter);
try {
pf.postInstantiate(getEntityName(), mappedClass, proxyInterfaces, proxyGetIdentifierMethod,
proxySetIdentifierMethod,
thePersistentClass.hasEmbeddedIdentifier() ? (CompositeType) thePersistentClass
.getIdentifier().getType() : null);
} catch (final HibernateException he) {
log.warn("could not create proxy factory for:" + getEntityName(), he);
pf = null;
}
return pf;
}