[
https://issues.apache.org/jira/browse/IGNITE-22181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17850638#comment-17850638
]
Vadim Kolodin commented on IGNITE-22181:
----------------------------------------
To specify precision and scale in POJO, use
`@Column(precision = 5, scale = 2)`
or
`@Column(columnDefinition = "decimal(5,2)")`
With TableDefinition builders this is also possible with
`.addColumn("col1", decimal(5,2))`
> BigDecimal scale is lost during create table
> --------------------------------------------
>
> Key: IGNITE-22181
> URL: https://issues.apache.org/jira/browse/IGNITE-22181
> Project: Ignite
> Issue Type: Bug
> Reporter: Aleksandr
> Priority: Major
> Labels: ignite-3
>
> Given a pojo
> {code:java}
> @Table
> public static class PojoClass {
> @Id
> private Integer i;
> private BigDecimal b;
> public Integer getI() {
> return i;
> }
> public void setI(int i) {
> this.i = i;
> }
> public BigDecimal getB() {
> return b;
> }
> public void setB(BigDecimal b) {
> this.b = b;
> }
> {code}
> I create a table from it with this call:
> {code:java}
> client.catalog().create(PojoClass.class).execute();
> {code}
> Then I insert one record and read it:
> {code:java}
> var table = client.tables().table(PojoClass.class.getSimpleName());
> var pojo = new PojoClass();
> pojo.setI(44);
> pojo.setB(new BigDecimal("123.45")); // <-- NOTE
> var pojoRecordView = table.recordView(PojoClass.class);
> pojoRecordView.insert(null, pojo);
> var keyPojo = new PojoClass();
> keyPojo.setI(44);
> assertThat(pojoRecordView.get(null, keyPojo), equalTo(pojo)); <-- THIS FAILS
> {code}
> The assertion is failed due the scale (2) is lost for the BigDecimal field
> during the table creation.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)