org.hibernate.property.Getter.getReturnType()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中org.hibernate.property.Getter.getReturnType()方法的一些代码示例,展示了Getter.getReturnType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Getter.getReturnType()方法的具体详情如下:
包路径:org.hibernate.property.Getter
类名称:Getter
方法名:getReturnType

Getter.getReturnType介绍

[英]Retrieve the declared Java type
[中]检索声明的Java类型

代码示例

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

/**
 * Attempt to resolve the specified property type through reflection.
 *
 * @param clazz The class owning the property.
 * @param name The name of the property.
 * @return The type of the property.
 * @throws MappingException Indicates we were unable to locate the property.
 */
public static Class reflectedPropertyClass(Class clazz, String name) throws MappingException {
  return getter( clazz, name ).getReturnType();
}

代码示例来源:origin: sk.seges.corpis/corpis-dao-impl

@Override
  protected Class<?> executeForIntermediateField(String field, Class<?> result) {
    // get chained field class
    Getter getter = propertyAccessor.getGetter(result, field);
    return getter.getReturnType();
  }
}.resolve(alias, i);

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

/**
 * Attempt to resolve the specified property type through reflection.
 *
 * @param clazz The class owning the property.
 * @param name The name of the property.
 * @return The type of the property.
 * @throws MappingException Indicates we were unable to locate the property.
 */
public static Class reflectedPropertyClass(Class clazz, String name) throws MappingException {
  return getter( clazz, name ).getReturnType();
}

代码示例来源:origin: hibernate/hibernate

public boolean isPrimitive(Class clazz) {
  return getGetter(clazz).getReturnType().isPrimitive();
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

public boolean isPrimitive(Class clazz) {
  return getGetter(clazz).getReturnType().isPrimitive();
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

public boolean isPrimitive(Class clazz) {
  return getGetter(clazz).getReturnType().isPrimitive();
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

public boolean isPrimitive(Class clazz) {
  return getGetter(clazz).getReturnType().isPrimitive();
}

代码示例来源:origin: sk.seges.corpis/corpis-dao-impl

fieldName = property.substring(0, fieldIndex);
getter = propertyAccessor.getGetter(clazz, fieldName);
clazz = getter.getReturnType();

代码示例来源:origin: sk.seges.corpis/corpis-dao-impl

@Override
  protected Object executeForIntermediateField(String field, Object result)
      throws InstantiationException, IllegalAccessException {
    // set intermediate object association
    Getter getter = propertyAccessor.getGetter(result.getClass(), field);
    Setter setter = propertyAccessor.getSetter(result.getClass(), field);
    Object associate = getter.get(result);
    if (associate == null) {
      // there is no instance yet in referenced field
      associate = getter.getReturnType().newInstance();
    }
    setter.set(result, associate, null);
    return associate;
  }
}.resolve(alias, i);

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

public Query setProperties(Object bean) throws HibernateException {
  Class clazz = bean.getClass();
  String[] params = getNamedParameters();
  for (int i = 0; i < params.length; i++) {
    String namedParam = params[i];
    try {
      Getter getter = ReflectHelper.getGetter( clazz, namedParam );
      Class retType = getter.getReturnType();
      final Object object = getter.get( bean );
      if ( Collection.class.isAssignableFrom( retType ) ) {
        setParameterList( namedParam, ( Collection ) object );
      }
      else if ( retType.isArray() ) {
         setParameterList( namedParam, ( Object[] ) object );
      }
      else {
        setParameter( namedParam, object, determineType( namedParam, retType ) );
      }
    }
    catch (PropertyNotFoundException pnfe) {
      // ignore
    }
  }
  return this;
}

代码示例来源:origin: hibernate/hibernate

public static Class reflectedPropertyClass(String className, String name) throws MappingException {
  try {
    Class clazz = ReflectHelper.classForName(className);
    return getter(clazz, name).getReturnType();
  }
  catch (ClassNotFoundException cnfe) {
    throw new MappingException("class " + className + " not found while looking for property: " + name, cnfe);
  }
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

public static Class reflectedPropertyClass(String className, String name) throws MappingException {
  try {
    Class clazz = ReflectHelper.classForName(className);
    return getter(clazz, name).getReturnType();
  }
  catch (ClassNotFoundException cnfe) {
    throw new MappingException("class " + className + " not found while looking for property: " + name, cnfe);
  }
}

代码示例来源:origin: hibernate/hibernate

public Query setProperties(Object bean) throws HibernateException {
  Class clazz = bean.getClass();
  String[] params = getNamedParameters();
  for (int i = 0; i < params.length; i++) {
    String namedParam = params[i];
    try {
      Getter getter = ReflectHelper.getGetter(clazz, namedParam);
      Class retType = getter.getReturnType();
      final Object object = getter.get( bean );
      if ( Collection.class.isAssignableFrom(retType) ) {
        setParameterList( namedParam, (Collection) object );
      }
      else if ( retType.isArray() ) {
         setParameterList( namedParam, (Object[]) object );
      }
      else {
        setParameter( namedParam, object, guessType( getter.getReturnType() ) );
      }
    }
    catch (PropertyNotFoundException pnfe) {}
  }
  return this;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

/**
 * Attempt to resolve the specified property type through reflection.
 *
 * @param className The name of the class owning the property.
 * @param name The name of the property.
 * @return The type of the property.
 * @throws MappingException Indicates we were unable to locate the property.
 */
public static Class reflectedPropertyClass(String className, String name) throws MappingException {
  try {
    Class clazz = ReflectHelper.classForName( className );
    return getter( clazz, name ).getReturnType();
  }
  catch ( ClassNotFoundException cnfe ) {
    throw new MappingException( "class " + className + " not found while looking for property: " + name, cnfe );
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

/**
 * Attempt to resolve the specified property type through reflection.
 *
 * @param className The name of the class owning the property.
 * @param name The name of the property.
 * @return The type of the property.
 * @throws MappingException Indicates we were unable to locate the property.
 */
public static Class reflectedPropertyClass(String className, String name) throws MappingException {
  try {
    Class clazz = ReflectHelper.classForName( className );
    return getter( clazz, name ).getReturnType();
  }
  catch ( ClassNotFoundException cnfe ) {
    throw new MappingException( "class " + className + " not found while looking for property: " + name, cnfe );
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

public Query setProperties(Object bean) throws HibernateException {
  Class clazz = bean.getClass();
  String[] params = getNamedParameters();
  for (int i = 0; i < params.length; i++) {
    String namedParam = params[i];
    try {
      Getter getter = ReflectHelper.getGetter( clazz, namedParam );
      Class retType = getter.getReturnType();
      final Object object = getter.get( bean );
      if ( Collection.class.isAssignableFrom( retType ) ) {
        setParameterList( namedParam, ( Collection ) object );
      }
      else if ( retType.isArray() ) {
         setParameterList( namedParam, ( Object[] ) object );
      }
      else {
        setParameter( namedParam, object, determineType( namedParam, retType ) );
      }
    }
    catch (PropertyNotFoundException pnfe) {
      // ignore
    }
  }
  return this;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

public Query setProperties(Object bean) throws HibernateException {
  Class clazz = bean.getClass();
  String[] params = getNamedParameters();
  for (int i = 0; i < params.length; i++) {
    String namedParam = params[i];
    try {
      Getter getter = ReflectHelper.getGetter( clazz, namedParam );
      Class retType = getter.getReturnType();
      final Object object = getter.get( bean );
      if ( Collection.class.isAssignableFrom( retType ) ) {
        setParameterList( namedParam, ( Collection ) object );
      }
      else if ( retType.isArray() ) {
         setParameterList( namedParam, ( Object[] ) object );
      }
      else {
        setParameter( namedParam, object, determineType( namedParam, retType ) );
      }
    }
    catch (PropertyNotFoundException pnfe) {
      // ignore
    }
  }
  return this;
}

代码示例来源:origin: org.hibernate/hibernate-validator-legacy

@SuppressWarnings( "unchecked" )
private void addSubElement(Property property, ValidatableElement element) {
  if ( property != null && property.isComposite() && !property.isBackRef() ) {
    Component component = (Component) property.getValue();
    if ( component.isEmbedded() ) return;
    PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.POJO );
    Getter getter = accessor.getGetter( element.clazz, property.getName() );
    ClassValidator validator = new ClassValidator( getter.getReturnType() );
    ValidatableElement subElement = new ValidatableElement( getter.getReturnType(), validator, getter );
    Iterator properties = component.getPropertyIterator();
    while ( properties.hasNext() ) {
      addSubElement( (Property) properties.next(), subElement );
    }
    if ( subElement.getSubElements().size() != 0 || subElement.validator.hasValidationRules() ) {
      element.addSubElement( subElement );
    }
  }
}

代码示例来源:origin: hibernate/hibernate

protected AbstractComponentTuplizer(Component component) {
  
  propertySpan = component.getPropertySpan();
  
  getters = new Getter[propertySpan];
  setters = new Setter[propertySpan];
  Iterator iter = component.getPropertyIterator();
  boolean foundCustomAccessor=false;
  int i=0;
  while ( iter.hasNext() ) {
    Property prop = (Property) iter.next();
    getters[i] = buildGetter(component, prop);
    setters[i] = buildSetter(component, prop);
    if ( !prop.isBasicPropertyAccessor() ) foundCustomAccessor = true;
    i++;
  }
  hasCustomAccessors = foundCustomAccessor;
  
  String[] getterNames = new String[propertySpan];
  String[] setterNames = new String[propertySpan];
  Class[] propTypes = new Class[propertySpan];
  for ( int j = 0; j < propertySpan; j++ ) {
    getterNames[j] = getters[j].getMethodName();
    setterNames[j] = setters[j].getMethodName();
    propTypes[j] = getters[j].getReturnType();
  }
  instantiator = buildInstantiator(component);
}

代码示例来源:origin: org.nakedobjects.plugins/hibernate-hibernate

@Ignore("need to convert, was originally written for the old value holder design (TextString, etc)")
@Test
public void happyCase() {
  obj.setString(expected);
  NakedPropertyAccessor accessor = new NakedPropertyAccessor();
  Getter getter = accessor.getGetter(SimpleObject.class, "string");
  assertNotNull(getter);
  assertNull("getMethod", getter.getMethod());
  assertNull("getMethodName", getter.getMethodName());
  assertEquals("return type", String.class, getter.getReturnType());
}

相关文章