[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| 
Re: [eclipselink-users] Defaults for @Table and @Column names
 | 
Thanks Shaun.  This is pretty much exactly what I need.  It would be 
great if this type of thing were introduced into the spec -- thanks for 
passing it along to Mike.
Since we are on the topic, do you know if other JPA implementations have 
similar proprietary hooks?
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
--
Nathaniel A. Johnson                           Voice: 812.855.9905
Principal Systems Analyst                        Fax: 812.856.9046
Systems Integration Team, Enterprise Software   Indiana University