charliem / OCM

An ORM layer for the Apache Cassandra web scale database
Apache License 2.0
20 stars 0 forks source link

Doubles as properties throw java.nio.BufferOverflowException when saving #6

Open beacon50 opened 14 years ago

beacon50 commented 14 years ago

I have a simple Loan object:

[Comment="Loan"] ColumnFamily Loan { [Index] String loanID;

SuperFamily info
{
    String address;
    String city;
    String state;
    String zip;

    Double unpaidBalance;
    Int payoffDate;
    Int accountingPeriod;
}

Yet, when I try and set the unpaidBalance

ln.setUnpaidBalance(150000);

I get

Exception in thread "main" java.nio.BufferOverflowException at java.nio.Buffer.nextPutIndex(Unknown Source) at java.nio.HeapByteBuffer.putDouble(Unknown Source) at com.kissintelligentsystems.ocm.java.BaseTable.fromDouble(BaseTable.java:78) at com.b50.Loan.save(Loan.java:330) at com.b50.LoanInAction.main(LoanInAction.java:41)

It even happens if I set the value to 5 or 5d or new Double(5). I'm not sure why this happens as I see that you've allocated the size to 4.

beacon50 commented 14 years ago

It appears to happen for Longs as well (as I updated my spec to use Long). But it worked for Int (that is, ln.setUnpaidBalance(150000); worked when unpaidBalance is defined as an Int).