natjohns wrote:
Since
we are on the topic, do you know if other JPA implementations have
similar proprietary hooks?
Most are focused on the spec but they probably have some means of
customizing. The issue will be if they have the right hooks.
EclipseLink is *very* customizable. You have lots of life cycle hooks
for transactions, domain objects, query execution, etc. along with
hooks for customizing metadata. Underneath EclipseLink JPA is the full
"native" EclipseLink API which supports a number of features that are
not included in the JPA spec. Many of these have been exposed through
annotations and, soon, orm.xml for ease of configuration. But if you
ever need to drop down to the native API, as in this case, the option
is always there.
Shaun
Nate
Shaun Smith wrote:
Hi Nate,
EclipseLink implements the defaults according to the JPA spec but
you can use a customizer to override those defaults. I've attached a
quickly thrown together example. It doesn't cover all the cases but
should give you an idea of what you can do. In my example I prefixed
all table names with "T_" but you can do the camel to underscore
conversion instead.
The essential idea is to use a session customizer to change the
default table names after EclipseLink has set them. The customerizer
is "model.MyCustomizer" and it's enabled by adding
<property name="eclipselink.session.customizer"
value="model.MyCustomizer"/>
to the persistence.xml.
I'm not sure if the JPA 2.0 spec will support a pluggable or
configurable Java name/Database naming strategy but I've passed your
email on to Mike Kieth who's on the JPA expert group.
Shaun
natjohns wrote:
Hello,
Does anyone know if there is a way to change the way that JPA (or the
eclipselink implemenation) generates default names for tables and
columns when using the @Table and @Column annotations? Or if this is
being talked about for version 2 of the JPA spec?
What I'd like is something similar to what Grails does, where they
change the camel capped Java names to underscores. Here's an example:
Say you have an EmployeeInfo class and one of the members is
defaultHomePhoneNumber.
Current Default in JPA:
Table name: EMPLOYEEINFO
Column name: DEFAULTHOMEPHONENUMBER
It's kind of hard to read. If we could specify a policy, say the camel
caps to underscore policy, it would look like this:
Table name: EMPLOYEE_INFO
Column name: DEFAULT_HOME_PHONE_NUMBER
Thanks all! And I apoligize if this has been talked about already... I
couldn't find anything in the searches.
Best,
Nate
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
--
Oracle <http://www.oracle.com>
Shaun Smith | Principal Product Manager, TopLink | +1.905.502.3094
Oracle Fusion Middleware
110 Matheson Boulevard West, Suite 100
Mississauga, Ontario, Canada L5R 3P4
--
Shaun Smith | Principal Product Manager, TopLink |
+1.905.502.3094
Oracle Fusion Middleware
110 Matheson Boulevard West, Suite 100
Mississauga, Ontario, Canada L5R 3P4
|