Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem mapping TIMESTAMP WITH TIMEZONE to OffsetDateTime using SelectQueryMapper #729

Open
gilinykh opened this issue Aug 5, 2020 · 4 comments

Comments

@gilinykh
Copy link

gilinykh commented Aug 5, 2020

Having this table in database:

create table test(
    created_at timestamp with time zone default now()
);

And this JOOQ's generated field for table's column:

public final TableField<TestRecord, OffsetDateTime> CREATED_AT = createField(DSL.name("CREATED_AT"), org.jooq.impl.SQLDataType.TIMESTAMPWITHTIMEZONE.precision(6).defaultValue(org.jooq.impl.DSL.field("NOW()", org.jooq.impl.SQLDataType.TIMESTAMPWITHTIMEZONE)), this, "");

When querying that table using SelectQueryMapper:

@Getter
@AllArgsConstructor
public class TestData {
    private final OffsetDateTime createdAt;
}

List<TestData> list = SelectQueryMapperFactory.newInstance().newMapper(TestData.class).asList(dsl.select().from(TEST));

Mapping error occurs:

org.jooq.exception.MappingException: Could not find eligible property for 'CREATED_AT' on  class TestData not found  See https://github.com/arnaudroger/SimpleFlatMapper/wiki/Errors_PROPERTY_NOT_FOUND

	at org.simpleflatmapper.jooq.SelectQueryMapper.getMapper(SelectQueryMapper.java:186)
	at org.simpleflatmapper.jooq.SelectQueryMapper.asList(SelectQueryMapper.java:46)
        ...

sfm-jooq v. 8.2.3 is used

@arnaudroger
Copy link
Owner

Will have a look thanks

@arnaudroger
Copy link
Owner

Could be possible to get the post process test data bytecode?

@gilinykh
Copy link
Author

gilinykh commented Sep 2, 2020

@arnaudroger
Here's a test app
sfm-timestamptz-spring.zip

Just run mvn test to get the error (jooq model gets generated by LiquibaseGenerator):

org.jooq.exception.MappingException: Could not find eligible property for 'CREATED_AT' on  class com.example.sfmtimestamptz.TestRepository$TestData not found  See https://github.com/arnaudroger/SimpleFlatMapper/wiki/Errors_PROPERTY_
NOT_FOUND
        at com.example.sfmtimestamptz.SfmTimestamptzSpringApplicationTests.correctOffsetDateTime(SfmTimestamptzSpringApplicationTests.java:24)

@mkronberger
Copy link

I have the same issue, with LocalDateTime and Timestamp type.
The column in my postgres db has datatype timestamp and i would like to map it to Java LocalDateTime property. Here I also get eligible property for ....

Definition in JOOQ generated table for the column ist: public final TableField<UsersRecord, LocalDateTime> DELETED_DATE;

Its working, if i change the datatype in my java object to Timestamp or String.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants