[ 
https://issues.apache.org/jira/browse/JENA-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14047107#comment-14047107
 ] 

Benno Willoweit edited comment on JENA-733 at 6/29/14 12:02 PM:
----------------------------------------------------------------

Hi,

I did a bit of debugging with attached sources (sorry, should have done this 
straightaway) and found that this is not an ARQ problem. Actually, when 
creating a typed long literal in Jena you end up with an Integer object in the 
model if the number fits in the integer range. At line 467 in 
{{com.hp.hpl.jena.datatypes.xsd.XSDDatatype}} there is a static function 
{{suitableInteger(long number)}} which casts the value to an int if it fits 
into a 4 bytes and returns the integer wrapper class. So this is obviously done 
on purpose but it's not consistent with what {{literal.getDatatype()}} returns. 
And I honestly think it's a bad feature :)

For the record, my testing sample (eclipse project) is on bitbucket: 
https://[email protected]/kolchose0711/jenalongint.git


was (Author: willow):
Hi,

I did a bit of debugging with attached sources (sorry, should have done this 
straightaway) and found that this is not an ARQ problem. Actually, when 
creating a typed long literal in Jena you end up with an Integer object in the 
model if the number fits in the integer range. At line 467 in 
{{com.hp.hpl.jena.datatypes.xsd.XSDDatatype}} there is a static function 
{{suitableInteger(long number)}} which casts the value to an int if it fits 
into a 4 byte signed value and returns the Integer wrapper class. So this 
obviously done on purpose but it's not consistent with what 
{{literal.getDatatype()}} returns. And I honestly think it's a bad feature :)

For the record, my testing sample (eclipse project) is on bitbucket: 
https://[email protected]/kolchose0711/jenalongint.git

> Long typed literals in query results are returned as integers 
> --------------------------------------------------------------
>
>                 Key: JENA-733
>                 URL: https://issues.apache.org/jira/browse/JENA-733
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: ARQ
>    Affects Versions: Jena 2.11.2
>            Reporter: Benno Willoweit
>            Priority: Minor
>
> This is my first bug report ever so I hope I get this right. When retrieving 
> query results with ARQ, long values are returned as Integers:
> {{QuerySulution qs;}}
> {{Literal l = qs.getLiteral("myVar");}}
> {{l.getDatatype().getJavaClass(); //returns java.lang.Long which is correct}}
> {{l.getValue(); //returns a java.lang.Integer object but it should return a 
> java.lang.Long object according to the docs}}
> I have this problem with ARQ 2.11.2 which does not exist in the "affects 
> version" drop down.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to