openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: Automatically removing member variable prefix when naming columns.
Date Tue, 30 Oct 2007 14:55:47 GMT
Best thing to do is create a JIRA and attach the diff (svn diff >
openjpa-<jiranumber>.patch). If you don't have a JIRA account, let me
know; I'll create an issue for you.

-Patrick

On Oct 30, 2007 2:07 AM, ben short <jamin.short@gmail.com> wrote:
> OK I'll give it ago. I assume that you'll need a patch of the changes
> I make. Where is the best place to send it once I'm done?
>
>
> On 10/29/07, Patrick Linskey <plinskey@gmail.com> wrote:
> > Hi,
> >
> > You can do this by providing your own MappingDefaults implementation
> > (via the openjpa.MappingDefaults property). You'll probably want to
> > extend PersistenceMappingDefaults and override correctName(), to stay
> > in line with the rest of the JPA defaulting rules and to simplify the
> > implementation.
> >
> > Alternately, you could improve MappingDefaultsImpl and contribute the
> > change to OpenJPA. Such an improvement might look like so:
> >
> > 1. add a new setter/getter pair called 'removeHungarianNotation' (a
> > boolean) or 'removeLeadingPrefixes' (a list of strings).
> >
> > 2. implement logic in MappingDefaultsImpl.correctName() to either
> > guess about hungarian-notation trimming or to remove the prefixes
> > identified in 'removeLeadingPrefixes'.
> >
> > 3. write a test case that that extends SingleEMFTestCase and looks
> > something like so:
> >
> > public TestColumnNameTruncation extends SingleEMFTestCase {
> >     public void setUp() {
> >         setUp(HungarianNotationFields.class, CLEAR_TABLES,
> >             "openjpa.MappingDefaults", "RemoveLeadingPrefixes=\"m,_\"");
> >     }
> >
> >     public void testColumnNameTruncation() {
> >         ClassMapping cm = (ClassMapping) JPAFacadeHelper.getMetaData(emf,
> >             HungarianNotationFields.class);
> >         // check that the associated FieldMappings in cm have the
> > right column names
> >     }
> > }
> >
> > -Patrick
> >
> > On 10/25/07, ben short <jamin.short@gmail.com> wrote:
> > > Hi,
> > >
> > > I name my class member variables (fields) with the prefix m, such as
> > > mId. Is it possible to tell OpenJPA to create the table columns
> > > without the m prefix?
> > >
> > > I know this can be done using the @Column annotation, but it would be
> > > nice to be able to set a global flag, like I think you can with
> > > hibernate.
> > >
> > > Regards
> > >
> > > Ben
> > >
> >
> >
> > --
> > Patrick Linskey
> > 202 669 5907
> >
>



-- 
Patrick Linskey
202 669 5907

Mime
View raw message