You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Scott Morgan <sc...@adligo.com> on 2010/01/29 05:32:53 UTC

Intermittent ResultPacker issue with db2

Hi,

   We think we are seeing a intermittent issue during the pack of a
java object with db2 and Open JPA 1.2.0.  We upgraded to JPA 1.2.2 and
modified the source code to attempt to determine which field, method,
cell exc was causing the issue.  Here are our modifications, they
should help others diagnose issues as well.

Cheers,
Scott

Re: Intermittent ResultPacker issue with db2

Posted by Scott Morgan <sc...@adligo.com>.
Hi Rick,

   My google apps email says its attached?

Anyway heres the change in text

    /**
     * Pack the given result into the user-defined result class.
     */
    private Object packUserType(Object[] result) {

        Method meth = null;
        Object resultObj = null;
        String alias = null;
        Field field = null;

    	try {
            // use the constructor first, if we have one
            if (_constructor != null)
                return _constructor.newInstance(result);

            Object user = AccessController.doPrivileged(
                J2DoPrivHelper.newInstanceAction(_resultClass));
            for (int i = 0; i < _aliases.length; i++) {
            	
            	meth = null;
                resultObj = result[i];
                alias = null;
                field = null;

                if (_sets[i] instanceof Method) {
                    meth = (Method) _sets[i];
                    meth.invoke(user, new Object[]{ Filters.convert
                        (resultObj, meth.getParameterTypes()[0]) });
                } else if (_sets[i] instanceof Field) {
                    field = (Field) _sets[i];
                    field.set(user, Filters.convert(resultObj,
                        field.getType()));
                } else if (_put != null) {
                	alias = _aliases[i];
                    _put.invoke(user, new Object[]{ alias, resultObj });
                }
            }
            return user;
        } catch (OpenJPAException ke) {
        	UserException ex = new UserException(
        			getAdditionalError(meth, resultObj, alias, field));
        	ex.initCause(ke);
            throw ex;
        } catch (PrivilegedActionException pae) {
            throw new UserException(_loc.get("pack-instantiation-err" +
            		getAdditionalError(meth, resultObj, alias, field),
                _resultClass), pae.getException());
        } catch (InstantiationException ie) {
            throw new UserException(_loc.get("pack-instantiation-err" +
            		getAdditionalError(meth, resultObj, alias, field),
                _resultClass), ie);
        } catch (Exception e) {
            throw new UserException(_loc.get("pack-err" +
            		getAdditionalError(meth, resultObj, alias, field)
            		, _resultClass), e);
        }
    }

    private static String getAdditionalError(Method meth,Object
resultObj,String alias,Field field) {
    	StringBuilder sb = new StringBuilder();
    	sb.append(" accenture error putting result set cell value in java
object method ");
    	sb.append(meth);
    	sb.append(" resultObject = ");
    	sb.append(resultObj);
    	sb.append(" alias = ");
    	sb.append(alias);
    	sb.append(" field = ");
    	sb.append(field);
    	return sb.toString();
    }


Thanks,
Scott

On Fri, Jan 29, 2010 at 7:11 AM, Rick Curtis <cu...@gmail.com> wrote:
> Scott -
>
> Perhaps you missed attaching something to this email?
>
> --
> Thanks,
> Rick
>
> On Thu, Jan 28, 2010 at 10:32 PM, Scott Morgan <sc...@adligo.com> wrote:
>
>> Hi,
>>
>>   We think we are seeing a intermittent issue during the pack of a
>> java object with db2 and Open JPA 1.2.0.  We upgraded to JPA 1.2.2 and
>> modified the source code to attempt to determine which field, method,
>> cell exc was causing the issue.  Here are our modifications, they
>> should help others diagnose issues as well.
>>
>> Cheers,
>> Scott
>>
>

Re: Intermittent ResultPacker issue with db2

Posted by Rick Curtis <cu...@gmail.com>.
Scott -

Perhaps you missed attaching something to this email?

-- 
Thanks,
Rick

On Thu, Jan 28, 2010 at 10:32 PM, Scott Morgan <sc...@adligo.com> wrote:

> Hi,
>
>   We think we are seeing a intermittent issue during the pack of a
> java object with db2 and Open JPA 1.2.0.  We upgraded to JPA 1.2.2 and
> modified the source code to attempt to determine which field, method,
> cell exc was causing the issue.  Here are our modifications, they
> should help others diagnose issues as well.
>
> Cheers,
> Scott
>