On Monday, May 14, 2018 at 9:15:03 AM UTC+2, Lukas Eder wrote: > > > > 2018-05-13 10:53 GMT+02:00 Simon Niederberger <[email protected] > <javascript:>>: > >> Given a SelectQuery<? extends Record>, I'm struggling with the effects >> from basically an empty field list. >> >> >> 1. The query is created with jooq.selectQuery(getTable()); >> 2. Later, some joins might be added >> >> When fetching from the query, the issue is that multiple tables with >> identical field names lead to wrong data when fetching into a POJO. >> > > I'm assuming that by this, you mean using your query as a derived table. > Then, yes, you're not allowed to have ambiguous column names. Only top > level SELECT statements may expose ambiguous column names in SQL. > > However, I'm not 100% certain what you're trying to do. Would you mind > explaining your use case a bit more? >
I need a Select implementation to which I can later add conditions and joins (not fluently, more like the Criteria builder of Hibernate), I came across SelectQuery which fits perfectly. To create such a SelectQuery, I find final SelectQuery<CustomfieldRecord> baseQuery = jooq.selectQuery(getTable ()) whereas jooq.select(getTable().fields()).from(getTable()); returns a SelectJoinStep (for fluent queries). Adding a join later baseQuery.addJoin(BillingAccount.BILLING_ACCOUNT, Customfield.CUSTOMFIELD. ACCOUNT_UUID.eq(BillingAccount.BILLING_ACCOUNT.UUID)); baseQuery.addConditions(BillingAccount.BILLING_ACCOUNT.COMMUNITY.eq( principal.getCommunity())); results in selecting fields of both tables, as the internal projection is on '*'. Adding baseQuery.fields(getTable().fields()); doesn't have the desired effect. > > >> How can I change the field list of the SelectQuery? Or would that be part >> of https://github.com/jOOQ/jOOQ/issues/1492 ? >> > > #1492 has been rejected, and there won't be anything similar to replace it. > > >> Current workaround (note the placement in the org.jooq.impl package in >> order to access package-private methods): >> > > Don't do that! :-) > > 1. From JDK 9 onwards (at least when you move to the module path), you > won't be able to have your own org.jooq.impl package > 2. We'll change internal API in pretty much every minor release, so your > code will break very certainly > I'm with you, I'd rather not do that. So how do I tell a SelectQuery to only select certain fields? -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
