Hello. I've been thinking about possible support for @Table 
and @Column(table = "") annotations in jOOQ. At my work we could use this 
feature since it's often necessary to join many tables in a query and fetch 
several fields from different tables with the same naming. Currently we 
name conflicting columns in a query with different aliases, but for me it's 
a quite dirty solution (personally I don't like aliases :) ). 

I've written some code in my fork and made use for @Column(table = 
"tableName", name = "id"), but I've faced with a problem that if developer 
doesn't specify table property for one of conflicting fields in POJO, then 
the result of mapping is kinda unpredictable. It's not a problem in JPA 
implementations because there is always 'default' table - a table of the 
entity. But it's not a case for jOOQ where there is no any 'default' tables 
for POJOs.

Some examples:

public class User {
    @Column(name = "id", table = "user")
    private Long id;
    @Column(name = "id", table = "category")
    private Long secondId;
}
In this example mapping is good - id will be from USER table and secondId 
from CATEGORY table.

But in this example (developer accidentally forgot to specify table for the 
first conflicting field) mapping result is kinda unpredictable for the ID 
field:
public class User {
    @Column(name = "id")
    private Long id;
    @Column(name = "id", table = "category")
    private Long secondId;
}
Behavior in this example will be just like in current version of jOOQ with 
conflicting column names. 

So here is a question: is correct using of @Table and @Column(table = "") 
annotations even possible in jOOQ since there is no mandatory entities with 
default tables? 

-- 
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.

Reply via email to