You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Craig L Russell <Cr...@Sun.COM> on 2009/07/03 21:09:16 UTC
Bug in AbstractResult with long data types?
I've been looking at the result handling and ran across this code in
org.apache.openjpa.jdbc.sql.AbstractResult.
public long getLong(Object obj)
throws SQLException {
return getLongInternal(translate(obj, null), null);
}
public long getLong(Column col, Joins joins)
throws SQLException {
return getLongInternal(translate(col, joins), joins);
}
protected long getLongInternal(Object obj, Joins joins)
throws SQLException {
Number val = (Number) checkNull(getObjectInternal(obj,
JavaTypes.INT, null, joins));
return (val == null) ? 0 : val.intValue();
}
It seems like it's an obvious bug; using intValue and JavaTypes.INT in
getLongInternal should use longValue and JavaTypes.LONG.
1. Is this as obvious an error as it seems to me?
2. If it is an error, why don't we see it in all of our tests that
have long types in the domain model?
Thanks,
Craig
Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
Re: Bug in AbstractResult with long data types?
Posted by Craig L Russell <Cr...@Sun.COM>.
On Jul 3, 2009, at 12:09 PM, Craig L Russell wrote:
> I've been looking at the result handling and ran across this code in
> org.apache.openjpa.jdbc.sql.AbstractResult.
>
> public long getLong(Object obj)
> throws SQLException {
> return getLongInternal(translate(obj, null), null);
> }
>
> public long getLong(Column col, Joins joins)
> throws SQLException {
> return getLongInternal(translate(col, joins), joins);
> }
>
> protected long getLongInternal(Object obj, Joins joins)
> throws SQLException {
> Number val = (Number) checkNull(getObjectInternal(obj,
> JavaTypes.INT, null, joins));
> return (val == null) ? 0 : val.intValue();
> }
>
> It seems like it's an obvious bug; using intValue and JavaTypes.INT
> in getLongInternal should use longValue and JavaTypes.LONG.
>
> 1. Is this as obvious an error as it seems to me?
>
> 2. If it is an error, why don't we see it in all of our tests that
> have long types in the domain model?
Because the JDBC classes override the getXXXInternal methods. This
method is never called.
I'll file a JIRA and fix it.
Craig
>
> Thanks,
>
> Craig
>
> Craig L Russell
> Architect, Sun Java Enterprise System http://db.apache.org/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
>
Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!