Search code examples
sqljpaeclipselinkjpql

Are EclipseLink's COLUMN and TABLE functions DBMS independent?


If you read this EclipseLink's User-/Developer Guide it doesn't mention whether the TABLE and COLUMN functions are database independent and I'm not sure at all if i should use them considering that i'm working with some oracle, postgres and sqlserver databases.

Question

Are these functions DBMS independent?


Solution

  • The very first sentence of that UserGuide gives a an important piece of information:

    The Java Persistence Query Language (JPQL) is the query language defined by JPA. JPQL is similar to SQL, but operates on objects, attributes and relationships instead of tables and columns.

    That is, JPQL != SQL in a strict sense. JPQL is a query language for the purpose to query object in an environment of an object relational mapper (ORM). In this context, an ORM abstracts the actual DBMS ("the SQL world"). EclipseLink fully implements standard JPQL as defined in the JPA specification documents (versions 1, 2.0, 2.1, 2.2).

    Moreover, EclipseLink

    provides many extensions to the standard JPA JPQL. These extensions provide access to additional database features many of which are part of the SQL standard, provide access to native database features and functions, and provide access to EclipseLink specific features. EclipseLink JPQL extensions are referred to as the EclipseLink Query Language (EQL).

    What does this mean for

    • COLUMN operation to allow querying on non mapped columns, and
    • TABLE operation to allow querying on non mapped tables?

    EQL is an extension of the basic ORM implementation of EclipseLink to provide you an enhanced way of querying objects and meta-information of their corresponding database columns. This is implemented specific for each vendor - depending on the configured JPA dialect - OR as vendor-neutral as possible.

    In essence, it should be safe to use these functions as far as different DBM systems are concerned. Still, you will bind your application to EclipseLink once and for all, robbing yourself the possibility to switch to different JPA providers, e.g. Hibernate, in case you want to experiment or for reasons of performance.

    Hope it helps.