Is there a way to automatically alias all columns in a table to have some 
kind of prefix when doing query generation? I am trying to prevent issues 
with column name collisions.

For example, imagine I have a users table, and a orders table. Both have a 
'id' column. The orders table has a 'user_id' which is a foreign key to the 
users.id column. When I do a query (SQL or Jooq) I have a problem of column 
name collisions. In SQL I would specify each column and use an alias. In my 
case I have other abstractions in my domain model so in my custom pojo 
classes I want to keep a base object that has just an 'id' attribute.

It would be nice if a prefix could automatically be added to all columns in 
the SQL statement. Even nicer if this was entirely abstracted so that the 
Jooq query would just work. Example
SELECT u.id as users_id, u.name as users_name, o.id as orders_id, o.date as 
orders_date
FROM users u
JOIN orders o ON (u.id = o.user_id);

Ideally my Jooq query can be:
dsl
  .select()    <-- don't want to have to specify columns
  .from(USERS)
  .join(ORDERS).on(USERS.ID.equal(ORDERS.USER_ID))

Right now I am having issues when I map this as I am using Jooq only for 
query generation, and then passing it off to a mapper.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to