Example usage for javax.transaction InvalidTransactionException InvalidTransactionException

List of usage examples for javax.transaction InvalidTransactionException InvalidTransactionException

Introduction

In this page you can find the example usage for javax.transaction InvalidTransactionException InvalidTransactionException.

Prototype

public InvalidTransactionException(String msg) 

Source Link

Usage

From source file:com.p5solutions.core.jpa.orm.ConversionUtilityImpl.java

/**
 * Convert complex value.//  ww  w . ja va2s  . c  o m
 * 
 * @param pb
 *          the pb
 * @param value
 *          the value
 * @param sourceType
 *          the source type
 * @param targetType
 *          the target type
 * @return the object
 * @throws TypeConversionException
 *           the type conversion exception
 */
protected Object convertComplexValue(ParameterBinder pb, Object value, Class<?> sourceType, Class<?> targetType)
        throws TypeConversionException {
    EntityDetail<?> entityDetail = getEntityUtility().getEntityDetail(sourceType);
    List<ParameterBinder> pkpbs = entityDetail.getPrimaryKeyParameterBinders();
    if (pkpbs == null) {
        throw new NullPointerException("No primary key columns defined for table-entity of type " + sourceType);
    }

    if (pkpbs.size() > 1) {
        throw new RuntimeException(new InvalidTransactionException("Only surogate keys "
                + "supported when arguments by reference, and not value. " + "Entity type " + sourceType));
    }

    ParameterBinder pkpb = pkpbs.get(0);

    // IDEALLY WE WANT TO DO THIS BY SOME SORT OF BINDING PATH.
    // ParameterBinder pb =
    // entityDetail.getParameterBinderByBindingPath(bindingPath);
    //
    if (pkpb != null) {
        Object newValue = ReflectionUtility.getValue(pkpb.getGetterMethod(), value);
        value = newValue;
    }
    return value;
}