zhys513 / jenabean

Automatically exported from code.google.com/p/jenabean
0 stars 0 forks source link

Datatype Property: binding of BigDecimal to xsd:decimal is faulty #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create class that has BigDecimal datatype property 
2. write a concrete instance, is written as xsd:double instead of xsd:decimal 
3. reading the class leads to the return of a null value.

sample code:

controller:
    public void performTest()
    {

        RDF2Bean modelReader;
        Bean2RDF modelWriter;
        Test newTest = null;
        int idNumber = 0;

        OntModel m = ModelFactory.createOntologyModel();

        modelReader = new RDF2Bean(m);
        modelWriter = new Bean2RDF(m);
        modelReader.bind(Test.class);
        idNumber = getRandom();

        newTest = new Test();
        newTest.setId(idNumber);
        newTest.setValue(new BigDecimal(666.0));

        modelWriter.save(newTest);

        Test returnTest = (Test) modelReader.load(Test.class,idNumber);

        System.out.println(returnTest.getValue());
    }

testclass:

import thewebsemantic.Id;
import thewebsemantic.Namespace;
import java.math.*;

public class Test {

    @Id
    private int id;

    private BigDecimal value;

    public int getId() { return this.id; }

    public BigDecimal getValue() { return this.value;}

    public void setValue(BigDecimal pHasNativeValue) { this.value = pHasNativeValue;}

    public void setId(int pId) {this.id = pId;}
}

What is the expected output? What do you see instead?
The expected output is the stored BigDecimal value. It should be stored as 
xsd:decimal according to jena mapping.
Instead, it is stored as xsd:double value by jenabeans. therefore a 
java.lang.Double class is returned which leads to a "null" value when querying 
for the datatype property.

What version of the product are you using? On what operating system?
Version: jenabean-1.0.6.jar,
OS: Eclipse platform

Please provide any additional information below.
the property value is stored as xsd:double while xsd:decimal would be required.

Original issue reported on code.google.com by mario.ko...@gmail.com on 3 Feb 2011 at 10:15