Day extraction from table field

36 views
Skip to first unread message

YANA

unread,
Feb 8, 2024, 2:05:10 PMFeb 8
to jOOQ User Group
Hi! After refreshing jooq to 3.19.3  faced with problem with day extraction from table field, like this:
dslContext.select(table.name,day(table.date).as("day").from(table)
.fetchInto(FetchObject.class);
FetchObject  => day field is Integer type;
table => date field is TableField<Record, LocalDateTime>  type;
As result FetchObject.day value is always null after fetchInto
Also I tried such syntax: extract(table.DATE, DatePart.DAY) , but result was the same.

Can somebody clarify, if it really jooq release related problem? Looks like this... (but maybe also my mistake somewhere)

Lukas Eder

unread,
Feb 9, 2024, 2:14:41 AMFeb 9
to jooq...@googlegroups.com
Thanks for your message.

Can you show the FetchObject class? You did describe it, but perhaps you omitted some important information. Also, your query doesn't compile, so it seems you may have simplified it a bit too much. Can you show a complete example that doesn't work for you, which can be reproduced?

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/5db1e6fe-178b-4390-b8f7-8db250e85fcbn%40googlegroups.com.

YANA

unread,
Feb 9, 2024, 2:40:47 AMFeb 9
to jOOQ User Group
Okay
Generally in my code it looks very close to this query (I tried to simplify query to show the main idea):
jooq.select(TRANSACTIONS.ID_ACQUIRER.as("nam"), TRANSACTIONS.AMOUNT, day(TRANSACTIONS.TRANSACTION_DATE).as("day"))
.from(TRANSACTIONS)
.fetchInto(NgxChartSeries.class);
Fetch object below:
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class NgxChartSeries {

@Column(name="nam")
@JsonProperty("nam")
private String name;

@Column(name="val")
@JsonProperty("val")
private BigDecimal value;

@JsonProperty("day")
private Integer day;
}

I hope it will help you, but If I have to add some info - please, give me know.
Thanks in advance!

пятница, 9 февраля 2024 г. в 08:14:41 UTC+1, lukas...@gmail.com:

YANA

unread,
Feb 9, 2024, 2:51:33 AMFeb 9
to jOOQ User Group
Maybe better was to write it with obtaining list value like this  (just put result to list value nothing changed)
List<NgxChartSeries> list = jooq.select(TRANSACTIONS.ID_ACQUIRER.as("nam"), TRANSACTIONS.AMOUNT, day(TRANSACTIONS.TRANSACTION_DATE).as("day")).from(TRANSACTIONS)
.fetchInto(NgxChartSeries.class);
пятница, 9 февраля 2024 г. в 08:40:47 UTC+1, YANA:

Lukas Eder

unread,
Feb 9, 2024, 5:03:02 AMFeb 9
to jooq...@googlegroups.com
I see now. I'm assuming the @Column annotation is the JPA @Column annotation? The DefaultRecordMapper rule is that if JPA annotations are present, then *only* annotated columns are mapped. There's a feature request to make these annotations optional:

I hope this helps
Lukas

YANA

unread,
Feb 9, 2024, 5:21:22 AMFeb 9
to jOOQ User Group
oh...my mistake. Thanks for quick answer and patience :)

пятница, 9 февраля 2024 г. в 11:03:02 UTC+1, lukas...@gmail.com:
Reply all
Reply to author
Forward
0 new messages