Java 类org.hibernate.PropertyNotFoundException 实例源码

项目:lams    文件:PojoInstantiator.java   
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
    this.mappedClass = component.getComponentClass();
    this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
    this.optimizer = optimizer;

    this.proxyInterface = null;
    this.embeddedIdentifier = false;

    try {
        constructor = ReflectHelper.getDefaultConstructor(mappedClass);
    }
    catch ( PropertyNotFoundException pnfe ) {
        LOG.noDefaultConstructor(mappedClass.getName());
        constructor = null;
    }
}
项目:lams    文件:AbstractQueryImpl.java   
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;
}
项目:lams    文件:ReflectHelper.java   
/**
 * Retrieve the default (no arg) constructor from the given class.
 *
 * @param clazz The class for which to retrieve the default ctor.
 * @return The default constructor.
 * @throws PropertyNotFoundException Indicates there was not publicly accessible, no-arg constructor (todo : why PropertyNotFoundException???)
 */
public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws PropertyNotFoundException {
    if ( isAbstractClass( clazz ) ) {
        return null;
    }

    try {
        Constructor<T> constructor = clazz.getDeclaredConstructor( NO_PARAM_SIGNATURE );
        constructor.setAccessible( true );
        return constructor;
    }
    catch ( NoSuchMethodException nme ) {
        throw new PropertyNotFoundException(
                "Object class [" + clazz.getName() + "] must declare a default (no-argument) constructor"
        );
    }
}
项目:lams    文件:ReflectHelper.java   
/**
 * Retrieve a constructor for the given class, with arguments matching the specified Hibernate mapping
 * {@link Type types}.
 *
 * @param clazz The class needing instantiation
 * @param types The types representing the required ctor param signature
 * @return The matching constructor.
 * @throws PropertyNotFoundException Indicates we could not locate an appropriate constructor (todo : again with PropertyNotFoundException???)
 */
public static Constructor getConstructor(Class clazz, Type[] types) throws PropertyNotFoundException {
    final Constructor[] candidates = clazz.getConstructors();
    for ( int i = 0; i < candidates.length; i++ ) {
        final Constructor constructor = candidates[i];
        final Class[] params = constructor.getParameterTypes();
        if ( params.length == types.length ) {
            boolean found = true;
            for ( int j = 0; j < params.length; j++ ) {
                final boolean ok = params[j].isAssignableFrom( types[j].getReturnedClass() ) || (
                        types[j] instanceof PrimitiveType &&
                                params[j] == ( ( PrimitiveType ) types[j] ).getPrimitiveClass()
                );
                if ( !ok ) {
                    found = false;
                    break;
                }
            }
            if ( found ) {
                constructor.setAccessible( true );
                return constructor;
            }
        }
    }
    throw new PropertyNotFoundException( "no appropriate constructor in class: " + clazz.getName() );
}
项目:helium    文件:EntityParser.java   
public String extractPrimaryKeyValue(){
    //Get pk column and value
    String pkValue = null;
    try{
        pkValue = pc.getIdentifierProperty().getGetter(entity.getClass()).get(entity).toString();
    } catch(PropertyNotFoundException pnfe) {
        logger.info("PropertyNotFoundException " + pnfe.getMessage());
    } catch(MappingException me) {
        logger.info("MappingException " + me.getMessage());
    } catch(HibernateException he) {
        logger.info("HibernateException " + he.getMessage());
    } catch(NullPointerException npe) {
        logger.info("NullPointerException " + npe.getMessage());
    }
    return pkValue;
}
项目:cacheonix-core    文件:Dom4jAccessor.java   
/**
 * Create a "getter" for the named attribute
 */
public Getter getGetter(Class theClass, String propertyName) 
throws PropertyNotFoundException {
    if (nodeName==null) {
        throw new MappingException("no node name for property: " + propertyName);
    }
    if ( ".".equals(nodeName) ) {
        return new TextGetter(propertyType, factory);
    }
    else if ( nodeName.indexOf('/')>-1 ) {
        return new ElementAttributeGetter(nodeName, propertyType, factory);
    }
    else if ( nodeName.indexOf('@')>-1 ) {
        return new AttributeGetter(nodeName, propertyType, factory);
    }
    else {
        return new ElementGetter(nodeName, propertyType, factory);
    }
}
项目:cacheonix-core    文件:Dom4jAccessor.java   
/**
 * Create a "setter" for the named attribute
 */
public Setter getSetter(Class theClass, String propertyName) 
throws PropertyNotFoundException {
    if (nodeName==null) {
        throw new MappingException("no node name for property: " + propertyName);
    }
    if ( ".".equals(nodeName) ) {
        return new TextSetter(propertyType);
    }
    else if ( nodeName.indexOf('/')>-1 ) {
        return new ElementAttributeSetter(nodeName, propertyType);
    }
    else if ( nodeName.indexOf('@')>-1 ) {
        return new AttributeSetter(nodeName, propertyType);
    }
    else {
        return new ElementSetter(nodeName, propertyType);
    }
}
项目:cacheonix-core    文件:PojoInstantiator.java   
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
    this.mappedClass = component.getComponentClass();
    this.optimizer = optimizer;

    this.proxyInterface = null;
    this.embeddedIdentifier = false;

    try {
        constructor = ReflectHelper.getDefaultConstructor(mappedClass);
    }
    catch ( PropertyNotFoundException pnfe ) {
        log.info(
                "no default (no-argument) constructor for class: " +
                mappedClass.getName() +
                " (class must be instantiated by Interceptor)"
        );
        constructor = null;
    }
}
项目:cacheonix-core    文件:PojoInstantiator.java   
public PojoInstantiator(PersistentClass persistentClass, ReflectionOptimizer.InstantiationOptimizer optimizer) {
    this.mappedClass = persistentClass.getMappedClass();
    this.proxyInterface = persistentClass.getProxyInterface();
    this.embeddedIdentifier = persistentClass.hasEmbeddedIdentifier();
    this.optimizer = optimizer;

    try {
        constructor = ReflectHelper.getDefaultConstructor( mappedClass );
    }
    catch ( PropertyNotFoundException pnfe ) {
        log.info(
                "no default (no-argument) constructor for class: " +
                mappedClass.getName() +
                " (class must be instantiated by Interceptor)"
        );
        constructor = null;
    }
}
项目:cacheonix-core    文件:ReflectHelper.java   
public static Constructor getDefaultConstructor(Class clazz) throws PropertyNotFoundException {

        if ( isAbstractClass(clazz) ) return null;

        try {
            Constructor constructor = clazz.getDeclaredConstructor(NO_CLASSES);
            if ( !isPublic(clazz, constructor) ) {
                constructor.setAccessible(true);
            }
            return constructor;
        }
        catch (NoSuchMethodException nme) {
            throw new PropertyNotFoundException(
                "Object class " + clazz.getName() +
                " must declare a default (no-argument) constructor"
            );
        }

    }
项目:cacheonix-core    文件:ReflectHelper.java   
public static Constructor getConstructor(Class clazz, Type[] types) throws PropertyNotFoundException {
    final Constructor[] candidates = clazz.getConstructors();
    for ( int i=0; i<candidates.length; i++ ) {
        final Constructor constructor = candidates[i];
        final Class[] params = constructor.getParameterTypes();
        if ( params.length==types.length ) {
            boolean found = true;
            for ( int j=0; j<params.length; j++ ) {
                final boolean ok = params[j].isAssignableFrom( types[j].getReturnedClass() ) || (
                    types[j] instanceof PrimitiveType &&
                    params[j] == ( (PrimitiveType) types[j] ).getPrimitiveClass()
                );
                if (!ok) {
                    found = false;
                    break;
                }
            }
            if (found) {
                if ( !isPublic(clazz, constructor) ) constructor.setAccessible(true);
                return constructor;
            }
        }
    }
    throw new PropertyNotFoundException( "no appropriate constructor in class: " + clazz.getName() );
}
项目:cacheonix-core    文件:AbstractQueryImpl.java   
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;
}
项目:spring-dynamic    文件:ReflectHelper.java   
/**
 * Retrieve the default (no arg) constructor from the given class.
 *
 * @param clazz The class for which to retrieve the default ctor.
 * @return The default constructor.
 * @throws PropertyNotFoundException Indicates there was not publicly accessible, no-arg constructor (todo : why PropertyNotFoundException???)
 */
public static Constructor getDefaultConstructor(Class clazz) throws PropertyNotFoundException {
    if ( isAbstractClass( clazz ) ) {
        return null;
    }

    try {
        Constructor constructor = clazz.getDeclaredConstructor( NO_PARAM_SIGNATURE );
        if ( !isPublic( clazz, constructor ) ) {
            constructor.setAccessible( true );
        }
        return constructor;
    }
    catch ( NoSuchMethodException nme ) {
        throw new PropertyNotFoundException(
                "Object class [" + clazz.getName() + "] must declare a default (no-argument) constructor"
        );
    }
}
项目:ss    文件:IraBankExceptionController.java   
@ExceptionHandler(value = 
        {
        Exception.class, 
        NullPointerException.class,
        NoSuchRequestHandlingMethodException.class, 
        RuntimeException.class,
        ResourceAccessException.class,
        AccessDeniedException.class,
        PropertyNotFoundException.class,
        ConstraintViolationException.class,
        NestedServletException.class}
        )

// Don't pass model object here. Seriously was creating issues here.
   public ModelAndView globalErrorHandler(HttpServletRequest request, Exception e) {
           System.out.println("comes in exception controller");
           ModelAndView mdlViewObj = new ModelAndView("/common/Exception");
           logger.error(e.getStackTrace());
           return mdlViewObj;
           //return new ModelAndView("common/Exception"); // Error java.lang.IllegalStateException: No suitable resolver for argument [0] [type=org.springframework.ui.ModelMap]
}
项目:lams    文件:BasicPropertyAccessor.java   
private static Setter createSetter(Class theClass, String propertyName) throws PropertyNotFoundException {
    BasicSetter result = getSetterOrNull(theClass, propertyName);
    if (result==null) {
        throw new PropertyNotFoundException(
                "Could not find a setter for property " +
                propertyName +
                " in class " +
                theClass.getName()
            );
    }
    return result;
}
项目:lams    文件:BasicPropertyAccessor.java   
public static Getter createGetter(Class theClass, String propertyName) throws PropertyNotFoundException {
    BasicGetter result = getGetterOrNull(theClass, propertyName);
    if (result==null) {
        throw new PropertyNotFoundException(
                "Could not find a getter for " +
                propertyName +
                " in class " +
                theClass.getName()
        );
    }
    return result;
}
项目:lams    文件:DirectPropertyAccessor.java   
private static Field getField(Class clazz, String name) throws PropertyNotFoundException {
    if ( clazz==null || clazz==Object.class ) {
        throw new PropertyNotFoundException("field not found: " + name); 
    }
    Field field;
    try {
        field = clazz.getDeclaredField(name);
    }
    catch (NoSuchFieldException nsfe) {
        field = getField( clazz, clazz.getSuperclass(), name );
    }
    field.setAccessible(true);
    return field;
}
项目:lams    文件:DirectPropertyAccessor.java   
private static Field getField(Class root, Class clazz, String name) throws PropertyNotFoundException {
    if ( clazz==null || clazz==Object.class ) {
        throw new PropertyNotFoundException("field [" + name + "] not found on " + root.getName()); 
    }
    Field field;
    try {
        field = clazz.getDeclaredField(name);
    }
    catch (NoSuchFieldException nsfe) {
        field = getField( root, clazz.getSuperclass(), name );
    }
    field.setAccessible(true);
    return field;
}
项目:lams    文件:ChainedPropertyAccessor.java   
public Getter getGetter(Class theClass, String propertyName)
        throws PropertyNotFoundException {
    Getter result = null;
    for (int i = 0; i < chain.length; i++) {
        PropertyAccessor candidate = chain[i];
        try {
            result = candidate.getGetter(theClass, propertyName);
            return result;
        } catch (PropertyNotFoundException pnfe) {
            // ignore
        }
    }
    throw new PropertyNotFoundException("Could not find getter for " + propertyName + " on " + theClass);
}
项目:lams    文件:ChainedPropertyAccessor.java   
public Setter getSetter(Class theClass, String propertyName)
        throws PropertyNotFoundException {
    Setter result = null;
    for (int i = 0; i < chain.length; i++) {
        PropertyAccessor candidate = chain[i];
        try {
            result = candidate.getSetter(theClass, propertyName);
            return result;
        } catch (PropertyNotFoundException pnfe) {
            //
        }
    }
    throw new PropertyNotFoundException("Could not find setter for " + propertyName + " on " + theClass);
}
项目:lams    文件:PojoInstantiator.java   
public PojoInstantiator(PersistentClass persistentClass, ReflectionOptimizer.InstantiationOptimizer optimizer) {
    this.mappedClass = persistentClass.getMappedClass();
    this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
    this.proxyInterface = persistentClass.getProxyInterface();
    this.embeddedIdentifier = persistentClass.hasEmbeddedIdentifier();
    this.optimizer = optimizer;

    try {
        constructor = ReflectHelper.getDefaultConstructor( mappedClass );
    }
    catch ( PropertyNotFoundException pnfe ) {
        LOG.noDefaultConstructor(mappedClass.getName());
        constructor = null;
    }
}
项目:lams    文件:PojoInstantiator.java   
public PojoInstantiator(EntityBinding entityBinding, ReflectionOptimizer.InstantiationOptimizer optimizer) {
    this.mappedClass = entityBinding.getEntity().getClassReference();
    this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
    this.proxyInterface = entityBinding.getProxyInterfaceType().getValue();
    this.embeddedIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded();
    this.optimizer = optimizer;

    try {
        constructor = ReflectHelper.getDefaultConstructor( mappedClass );
    }
    catch ( PropertyNotFoundException pnfe ) {
        LOG.noDefaultConstructor(mappedClass.getName());
        constructor = null;
    }
}
项目:lams    文件:ReflectHelper.java   
private static Getter getter(Class clazz, String name) throws MappingException {
    try {
        return BASIC_PROPERTY_ACCESSOR.getGetter( clazz, name );
    }
    catch ( PropertyNotFoundException pnfe ) {
        return DIRECT_PROPERTY_ACCESSOR.getGetter( clazz, name );
    }
}
项目:lams    文件:ComponentType.java   
public int getPropertyIndex(String name) {
    String[] names = getPropertyNames();
    for ( int i = 0, max = names.length; i < max; i++ ) {
        if ( names[i].equals( name ) ) {
            return i;
        }
    }
    throw new PropertyNotFoundException(
            "Unable to locate property named " + name + " on " + getReturnedClass().getName()
    );
}
项目:helium    文件:EntityParser.java   
public String extractPrimaryKeyValue(PersistentClass localPC, Object localEntity){
    String pkValue = null;
    try {
        pkValue = localPC.getIdentifierProperty().getGetter(localEntity.getClass()).get(localEntity).toString();
    } catch(PropertyNotFoundException pnfe){
        logger.error("PropertyNotFoundException " + pnfe.getMessage(),pnfe);
    } catch(MappingException me ){
        logger.error("MappingException " + me.getMessage(),me);
    } catch(HibernateException he) {
        logger.error("HibernateException " + he.getMessage(),he);
    } catch(NullPointerException npe) {
        logger.error("NullPointerException " + npe.getMessage(),npe);
    }
    return pkValue;
}
项目:cacheonix-core    文件:BasicPropertyAccessor.java   
private static Setter createSetter(Class theClass, String propertyName) 
throws PropertyNotFoundException {
    BasicSetter result = getSetterOrNull(theClass, propertyName);
    if (result==null) {
        throw new PropertyNotFoundException( 
                "Could not find a setter for property " + 
                propertyName + 
                " in class " + 
                theClass.getName() 
            );
    }
    return result;
}
项目:cacheonix-core    文件:BasicPropertyAccessor.java   
public static Getter createGetter(Class theClass, String propertyName) 
throws PropertyNotFoundException {
    BasicGetter result = getGetterOrNull(theClass, propertyName);
    if (result==null) {
        throw new PropertyNotFoundException( 
                "Could not find a getter for " + 
                propertyName + 
                " in class " + 
                theClass.getName() 
        );
    }
    return result;

}
项目:cacheonix-core    文件:DirectPropertyAccessor.java   
private static Field getField(Class clazz, String name) throws PropertyNotFoundException {
    if ( clazz==null || clazz==Object.class ) {
        throw new PropertyNotFoundException("field not found: " + name); 
    }
    Field field;
    try {
        field = clazz.getDeclaredField(name);
    }
    catch (NoSuchFieldException nsfe) {
        field = getField( clazz, clazz.getSuperclass(), name );
    }
    if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true);
    return field;
}
项目:cacheonix-core    文件:DirectPropertyAccessor.java   
private static Field getField(Class root, Class clazz, String name) throws PropertyNotFoundException {
    if ( clazz==null || clazz==Object.class ) {
        throw new PropertyNotFoundException("field [" + name + "] not found on " + root.getName()); 
    }
    Field field;
    try {
        field = clazz.getDeclaredField(name);
    }
    catch (NoSuchFieldException nsfe) {
        field = getField( root, clazz.getSuperclass(), name );
    }
    if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true);
    return field;
}
项目:cacheonix-core    文件:ChainedPropertyAccessor.java   
public Getter getGetter(Class theClass, String propertyName)
        throws PropertyNotFoundException {
    Getter result = null;
    for (int i = 0; i < chain.length; i++) {
        PropertyAccessor candidate = chain[i];
        try {
            result = candidate.getGetter(theClass, propertyName);
            return result;
        } catch (PropertyNotFoundException pnfe) {
            // ignore
        }
    }
    throw new PropertyNotFoundException("Could not find getter for " + propertyName + " on " + theClass);
}
项目:cacheonix-core    文件:ChainedPropertyAccessor.java   
public Setter getSetter(Class theClass, String propertyName)
        throws PropertyNotFoundException {
    Setter result = null;
    for (int i = 0; i < chain.length; i++) {
        PropertyAccessor candidate = chain[i];
        try {
            result = candidate.getSetter(theClass, propertyName);
            return result;
        } catch (PropertyNotFoundException pnfe) {
            //
        }
    }
    throw new PropertyNotFoundException("Could not find setter for " + propertyName + " on " + theClass);
}
项目:cacheonix-core    文件:ReflectHelper.java   
private static Getter getter(Class clazz, String name) throws MappingException {
    try {
        return BASIC_PROPERTY_ACCESSOR.getGetter(clazz, name);
    }
    catch (PropertyNotFoundException pnfe) {
        return DIRECT_PROPERTY_ACCESSOR.getGetter(clazz, name);
    }
}
项目:spring-dynamic    文件:ReflectHelper.java   
private static Getter getter(Class clazz, String name) throws MappingException {
    try {
        return BASIC_PROPERTY_ACCESSOR.getGetter( clazz, name );
    }
    catch ( PropertyNotFoundException pnfe ) {
        return DIRECT_PROPERTY_ACCESSOR.getGetter( clazz, name );
    }
}
项目:spring-dynamic    文件:ReflectHelper.java   
/**
 * Retrieve a constructor for the given class, with arguments matching the specified Hibernate mapping
 * {@link Type types}.
 *
 * @param clazz The class needing instantiation
 * @param types The types representing the required ctor param signature
 * @return The matching constructor.
 * @throws PropertyNotFoundException Indicates we could not locate an appropriate constructor (todo : again with PropertyNotFoundException???)
 */
public static Constructor getConstructor(Class clazz, Type[] types) throws PropertyNotFoundException {
    final Constructor[] candidates = clazz.getConstructors();
    for ( int i = 0; i < candidates.length; i++ ) {
        final Constructor constructor = candidates[i];
        final Class[] params = constructor.getParameterTypes();
        if ( params.length == types.length ) {
            boolean found = true;
            for ( int j = 0; j < params.length; j++ ) {
                final boolean ok = params[j].isAssignableFrom( types[j].getReturnedClass() ) || (
                        types[j] instanceof PrimitiveType &&
                                params[j] == ( ( PrimitiveType ) types[j] ).getPrimitiveClass()
                );
                if ( !ok ) {
                    found = false;
                    break;
                }
            }
            if ( found ) {
                if ( !isPublic( clazz, constructor ) ) {
                    constructor.setAccessible( true );
                }
                return constructor;
            }
        }
    }
    throw new PropertyNotFoundException( "no appropriate constructor in class: " + clazz.getName() );
}
项目:query-utils    文件:OptionAwareDirectPropertyAccessor.java   
@Override
public Setter getSetter(final Class theClass, final String propertyName) throws PropertyNotFoundException {
    final Field field = find(OptionAwareDirectPropertyAccessor_.fieldName.andThen(equalTo(propertyName)), fields(theClass)).get();
    final boolean isOption = Option.class.isAssignableFrom(field.getType());
    return new Setter() {
        @Override
        public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException {
            try {
                field.setAccessible(true);
                field.set(target, isOption ? Option.of(value) : value);
            }
            catch (Exception e) {
                throw new PropertyAccessException(e, "could not set a field value by reflection", true, theClass, propertyName);
            }
        }

        @Override
        public String getMethodName() {
            return null;
        }

        @Override
        public Method getMethod() {
            return null;
        }
    };
}
项目:iso21090    文件:CollectionPropertyAccessor.java   
/**
 * @param theClass Target class in which the value is to be set
 * @param propertyName Target property name
 * @return returns Setter class instance
 */
private static Setter createSetter(Class theClass, String propertyName) {
    CollectionPropertySetter result  =  getSetterOrNull(theClass, propertyName);
    if (result == null) {
        throw new PropertyNotFoundException(
                "Could not find a setter for property "  
                + propertyName 
                + " in class " 
                + theClass.getName());
    }
    return result;
}
项目:lams    文件:Property.java   
public Getter getGetter(Class clazz) throws PropertyNotFoundException, MappingException {
    return getPropertyAccessor(clazz).getGetter( clazz, name );
}
项目:lams    文件:Property.java   
public Setter getSetter(Class clazz) throws PropertyNotFoundException, MappingException {
    return getPropertyAccessor(clazz).getSetter(clazz, name);
}
项目:lams    文件:EmbeddedPropertyAccessor.java   
@Override
public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException {
    return new EmbeddedGetter(theClass);
}
项目:lams    文件:EmbeddedPropertyAccessor.java   
@Override
public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException {
    return new EmbeddedSetter(theClass);
}