Skip to content

IGNITE-20024 When H2 is used as the underlying storage, an exception is thrown "Can not set java.time.LocalDateTime field org.apache.ignite.examples.model.Person.createdTime to java.sql.Timestamp" #10773

@ZZ250-zZ

Description

@ZZ250-zZ

Question:

When I use IgniteCache.get(key) to get the corresponding entity, ignite throws the following error "Can not set java.time.LocalDateTime field org.apache.ignite.examples.model.Person.createdTime to java.sql .Timestamp"

Conditions and usage:

  1. In ignite 2.14.0, I use H2 as the underlying storage;
  2. In CacheJdbcPojoStoreFactory, I configured the mapping between the datetime type of the database and JDK8's LocalDateTime:
    new JdbcTypeField(Types.TIMESTAMP, "created_time", LocalDateTime.class, "createdTime")

Problem analysis:

By default, CacheJdbcPojoStore uses org.apache.ignite.cache.store.jdbc.JdbcTypesTransformer#getColumnValue to parse jdbc's ResultSet.
For the LocalDateTime type of JDK8, java.sql.ResultSet#getObject(int) is used to obtain the value of the specified column (here it is read as java.sql.Timestamp). When the object is finally constructed, the type is inconsistent Causes sun.reflect.FieldAccessor#set assignment to fail.

Repair suggestion:

I want to parse the value of the specified column using java.sql.ResultSet#getObject(int, java.lang.Class<T>), what do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions