org.hibernate.property.Getter类的使用及代码示例

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

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

Getter介绍

[英]Gets values of a particular property
[中]获取特定属性的值

代码示例

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

public Object getPropertyValue(Object component, int i)
throws HibernateException {
  return getters[i].get( component );
}

代码示例来源: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: org.hibernate/com.springsource.org.hibernate.core

public boolean isMethodOf(Method method) {
  for ( int i = 0; i < propertySpan; i++ ) {
    final Method getterMethod = getters[i].getMethod();
    if ( getterMethod != null && getterMethod.equals( method ) ) {
      return true;
    }
  }
  return false;
}

代码示例来源: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: 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.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());
}

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

@Ignore("need to convert, was originally written for the old value holder design (TextString, etc)")
@Test
public void testGetter() {
  obj.setString(expected);
  NakedPropertyAccessor accessor = new NakedPropertyAccessor();
  Getter getter = accessor.getGetter(SimpleObject.class, "string");
  assertEquals("string", expected, getter.get(obj));
  assertEquals("string", expected, getter.getForInsert(obj, null, null));
}

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

@Test
public void happyCase() {
  final UserAccessor accessor = new UserAccessor();
  final Getter getter = accessor.getGetter(TestObject.class, PropertyHelper.MODIFIED_BY);
  assertNotNull(getter);
  assertNull("getMethod", getter.getMethod());
  assertNull("getMethodName", getter.getMethodName());
}

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

public Object[] getPropertyValuesToInsert(Object entity, SessionImplementor session) 
throws HibernateException {
  final int span = entityMetamodel.getPropertySpan();
  final Object[] result = new Object[span];
  for ( int j = 0; j < span; j++ ) {
    result[j] = getters[j].getForInsert( entity, session );
  }
  return result;
}

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

Class[] propTypes = new Class[propertySpan];
for ( int i = 0; i < propertySpan; i++ ) {
  getterNames[i] = getters[i].getMethodName();
  setterNames[i] = setters[i].getMethodName();
  propTypes[i] = getters[i].getReturnType();

代码示例来源: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: org.hibernate/com.springsource.org.hibernate

public Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session)
throws HibernateException {
  final int span = entityMetamodel.getPropertySpan();
  final Object[] result = new Object[span];
  for ( int j = 0; j < span; j++ ) {
    result[j] = getters[j].getForInsert( entity, mergeMap, session );
  }
  return result;
}

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

public Object getPropertyValue(Object entity, int i) throws HibernateException {
  return getters[i].get( entity );
}

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

Class[] propTypes = new Class[propertySpan];
for ( int i = 0; i < propertySpan; i++ ) {
  getterNames[i] = getters[i].getMethodName();
  setterNames[i] = setters[i].getMethodName();
  propTypes[i] = getters[i].getReturnType();

代码示例来源: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 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 isMethodOf(Method method) {
  for ( int i=0; i<propertySpan; i++ ) {
    final Method getterMethod = getters[i].getMethod();
    if ( getterMethod!=null && getterMethod.equals(method) ) return true;
  }
  return false;
}

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

public Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session)
throws HibernateException {
  final int span = entityMetamodel.getPropertySpan();
  final Object[] result = new Object[span];
  for ( int j = 0; j < span; j++ ) {
    result[j] = getters[j].getForInsert( entity, mergeMap, session );
  }
  return result;
}

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

public Object getParent(Object component) {
  return parentGetter.get( component );
}

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

Class[] propTypes = new Class[propertySpan];
for ( int i = 0; i < propertySpan; i++ ) {
  getterNames[i] = getters[i].getMethodName();
  setterNames[i] = setters[i].getMethodName();
  propTypes[i] = getters[i].getReturnType();

相关文章