Search in sources :

Example 26 with OSchemaException

use of com.orientechnologies.orient.core.exception.OSchemaException in project orientdb by orientechnologies.

the class OObjectSerializerHelper method setFieldValue.

public static void setFieldValue(final Object iPojo, final String iProperty, final Object iValue) {
    final Class<?> c = iPojo.getClass();
    final String className = c.getName();
    getClassFields(c);
    try {
        Object o = setters.get(className + "." + iProperty);
        if (o instanceof Method) {
            ((Method) o).invoke(iPojo, OObjectSerializerHelper.convertInObject(iPojo, iProperty, iValue, ((Method) o).getParameterTypes()[0]));
        } else if (o instanceof Field) {
            ((Field) o).set(iPojo, OType.convert(iValue, ((Field) o).getType()));
        }
    } catch (Exception e) {
        throw OException.wrapException(new OSchemaException("Cannot set the value '" + iValue + "' to the property '" + iProperty + "' for the pojo: " + iPojo), e);
    }
}
Also used : Field(java.lang.reflect.Field) ODatabaseObject(com.orientechnologies.orient.core.db.object.ODatabaseObject) Method(java.lang.reflect.Method) OSchemaException(com.orientechnologies.orient.core.exception.OSchemaException) OException(com.orientechnologies.common.exception.OException) OSchemaException(com.orientechnologies.orient.core.exception.OSchemaException) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OTransactionException(com.orientechnologies.orient.core.exception.OTransactionException) OObjectNotDetachedException(com.orientechnologies.orient.object.db.OObjectNotDetachedException) OSerializationException(com.orientechnologies.orient.core.exception.OSerializationException)

Aggregations

OSchemaException (com.orientechnologies.orient.core.exception.OSchemaException)26 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)10 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)10 OException (com.orientechnologies.common.exception.OException)7 OConfigurationException (com.orientechnologies.orient.core.exception.OConfigurationException)5 OStorage (com.orientechnologies.orient.core.storage.OStorage)5 OSerializationException (com.orientechnologies.orient.core.exception.OSerializationException)4 ODatabaseLifecycleListener (com.orientechnologies.orient.core.db.ODatabaseLifecycleListener)3 ODatabaseObject (com.orientechnologies.orient.core.db.object.ODatabaseObject)3 OTransactionException (com.orientechnologies.orient.core.exception.OTransactionException)3 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)3 OAutoshardedStorage (com.orientechnologies.orient.core.storage.OAutoshardedStorage)3 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)3 OObjectNotDetachedException (com.orientechnologies.orient.object.db.OObjectNotDetachedException)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 Field (java.lang.reflect.Field)3 Method (java.lang.reflect.Method)3 OConcurrentModificationException (com.orientechnologies.orient.core.exception.OConcurrentModificationException)2 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)2 OSecurityAccessException (com.orientechnologies.orient.core.exception.OSecurityAccessException)2