Thanks for your message and for your crosspost here:
https://stackoverflow.com/q/78909241/521799

I'll reply directly on Stack Overflow

On Sat, Aug 24, 2024 at 5:58 PM Nakshatra Gupta <naxs...@gmail.com> wrote:

> I'm new to jOOQ and I'm trying to use jOOQ's CLI tool to translate my
> SQLite queries into Java code. The tool works well, but I noticed it uses
> table and column names as strings in the generated queries. I found that
> there's an option to provide a database schema, which allows the tool to
> generate POJOs for the tables and columns, and then uses those classes in
> the generated Java code.
>
> However, instead of using the generated POJOs, I want to use my own custom
> POJOs that I've already created for the tables and columns. Is there a way
> to instruct jOOQ's CLI tool to use my custom POJOs instead of generating
> new ones?
>
> Example Scenario: Assume I have an SQLite query like this:
> FROM users u
> JOIN orders o ON u.id = o.user_id
> WHERE u.active = 1;
>
> When I use jOOQ's CLI tool without a schema, it generates something like:
> DSL.select(field("u.name"), field("o.order_date"))
>    .from(table("users").as("u"))
>    .join(table("orders").as("o")).on(field("u.id").eq(field("o.user_id")))
>    .where(field("u.active").eq(1))
>    .fetch();
>
> By providing the schema, jOOQ generates POJOs like 'Users' and 'Orders'
> and the code becomes:
> DSL.select(USERS.NAME, ORDERS.ORDER_DATE)
>    .from(USERS.as("u"))
>    .join(ORDERS.as("o")).on(USERS.ID.eq(ORDERS.USER_ID))
>    .where(USERS.ACTIVE.eq(1))
>    .fetch();
>
> But I want to use my custom POJOs, such as 'MyUsers' and 'MyOrders', which
> are defined as follows:
> public class MyUsers {
>     public static final Table<MyUsers> TABLE = ...
>     public static final Field<String> NAME = ...
>     public static final Field<Integer> ID = ...
>     public static final Field<Boolean> ACTIVE = ...
> }
>
> public class MyOrders {
>     public static final Table<MyOrders> TABLE = ...
>     public static final Field<Integer> USER_ID = ...
>     public static final Field<Date> ORDER_DATE = ...
> }
>
> I would like the generated code to look like this:
> DSL.select(MyUsers.NAME, MyOrders.ORDER_DATE)
>    .from(MyUsers.TABLE.as("u"))
>    .join(MyOrders.TABLE.as("o")).on(MyUsers.ID.eq(MyOrders.USER_ID))
>    .where(MyUsers.ACTIVE.eq(true))
>    .fetch();
>
> My Questions:
>
>    1. CLI Tool Configuration: Is there a way to configure jOOQ's CLI tool
>    to use my custom POJOs instead of generating new ones?
>    2. jOOQ API: If the CLI tool doesn't support this, is it possible to
>    achieve this using jOOQ's API programmatically? If so, could you provide an
>    example or point me in the right direction?
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jooq-user/9f7874a2-eea2-4340-8c4d-22f152e09029n%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/9f7874a2-eea2-4340-8c4d-22f152e09029n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO5ayeCZsGRPE1UKVC-mMh0RFgK%3DoTLpaM5sMUgCig%3DihQ%40mail.gmail.com.

Reply via email to