SAP / olingo-jpa-processor-v4

The JPA Processor fills the gap between Olingo V4 and the database, by providing a mapping between JPA metadata and OData metadata, generating queries and supporting the entity manipulations.
Apache License 2.0
122 stars 76 forks source link

Type cast error: Can't convert 'class java.math.BigInteger' to 'class java.lang.Long' #171

Closed alvachien closed 1 year ago

alvachien commented 1 year ago

Create a very simply model class:

@Entity
@Table(name = "book_ctgy_def")
public class BookCategory {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY) 
    @Column(name = "id")
    private Long id;

...
}

The database column created as

id bigint,

Access it via http://[localhost:9010/apis/v1/BookCategories, the error thrown:

{"error":{"code":null,"message":"Type cast error: Can't convert 'class java.math.BigInteger' to 'class java.lang.Long'. @Convert required"}}

The same model works with Olingo itself without 'olingo-jpa-processor-v4'.

wog48 commented 1 year ago

The TypeConverter currently not supporting this conversion. I like to point out that it is usually it is risky to map a data type that can take lager number than the data type it shall be mappped to.

wog48 commented 1 year ago

Additional mappings have been added to TypeConverter