Id column isn't mapped to POJO

48 views
Skip to first unread message

Juan Jose

unread,
Sep 3, 2023, 5:04:15 AM9/3/23
to jOOQ User Group
Hey, 

I am new to JOOQ and I love it so far. I plan to migrate a quarkus hibernate application to JOOQ to get more control over the queries executed against my postgres database.

I however don't know what happens in the following example with my generated ID field. It doesn't get mapped into my POJOS:

This is my user table:
create table if not exists "user"
(
id bigint primary key generated always as identity,
created_at timestamp with time zone default now() not null,
keycloak_id varchar(36) not null unique,
username varchar(255) not null unique
);

And this is my POJO:

data class User(
val id: Long? = null,
var keycloakId: String = "",
var createdAt: OffsetDateTime? = null,
var username: String = "",
)

And I have some logic to get a user by id:
fun loadUserById(id: Long): User {
with(db.dslContext) {
return select()
.from(USER).where(USER.ID.eq(id))
.fetchOne()?.into(User::class.java)
?: throw RuntimeException("User with $id not found")
}
}

This fetches the user and i can see that the id is being set in the record. But it doesn't get mapped to my User POJO, all other columns are mapped properly:

pojo_mapping.png

Any ideas what I am doing wrong? 


Lukas Eder

unread,
Sep 4, 2023, 3:03:05 AM9/4/23
to jooq...@googlegroups.com
Hi Juan,

Thanks for your message. I don't see anything wrong in your example code. You might have omitted some additional detail that is relevant here? For example, why is your data class property "id" highlighted in red, and not written in italics?

If you think this is a bug, maybe our MCVE template could help reproduce this easily in a "mimimal, complete, verifiable example" (MCVE): https://github.com/jOOQ/jOOQ-mcve. If it's not a bug, this might also help you track down the problem on your end.

Best Regards,
Lukas

--
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/31df1045-f6e9-49a2-9aa0-63a23b8bd218n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages