I have a problem that, I think, can be easily solved, but I cannot do it.
I have class A and B, and class A is saved in postgres db:
public class A() {
private B b;
...
}
public class B() {
private String firstName;
private String lastName;
private String personId;
private String userName;
}
In the database, an object of class b is stored as a string userName in entity A. So, to have an object of class A from db in the application, I have to read A record and create an object of class B. I want to create a query with jooq, but jooq does not know how convert this string name to an instance of class B. How to tell jooq how it should map the database Object to an object of class A.
The class is equivalent to Person and B is equivalent to Executor.
My request
return jooq.select()
.from(PERSON)
.where(PERSON.ID.eq(id))
.fetchOneInto(Person.class);
This is an exception caused by my request.
Caused by: org.jooq.exception.DataTypeException: Cannot convert from superadmin (class java.lang.String) to class fi.ssm.oksa.domain.person.Executor
at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:1118) ~[jooq-3.8.5.jar:na]
...
, http://www.jooq.org/doc/3.8/manual/code-generation/custom-data-type-bindings/, .