Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Conditional LEFT JOIN in JPQL

The additional fields can also be mapped by a java.util.Map-structure, i.e.

public class Country {
  private Map<String, String> extChatFields;

In this case, no column "id" would be required for table ExtCharFields.

With this mapping, you would even have transparent "write access" to

-- Frank

vide wrote:
> Hi, Tom,
> [...]
>   Say application has the ability to dynamicaly extend table structure,
> i.e.
> virtualy describe additional columns in a table. For example we have a
> table:
> [Country]
> String name
> Integer id
> Customer wants to extend this table to add some extra fields, say
> "language"
> and "nationality". Such extra data is stored in a table:
> [ExtCharFields]
> Integer country_id
> String fieldName
> String fieldValue
> Integer id
> So, to present a table for viewing/editing, native SQL would look like
> this:
> SELECT, e1.fieldValue AS language, e2.fieldValue AS nationality
>   FROM Country c
>   LEFT JOIN ExtCharFields e1 ON  AND e1.fieldName =
> "language"
>   LEFT JOIN ExtCharFields e2 ON  AND e2.fieldName =
> "nationality"
> With this single SQL I get all I need and also can do any kind of sorting,
> paging, filtering results and etc., but I don't have any object/relational
> mapping, even can't use @SqlResultSetMapping, because query is dynamic. I
> could do this in JPQL, if it will support "ON" clause.
> Hope I was clear enough to illustrate the problem ;-)
> -- 
> Sincerely,
> Vidas
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx

View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top