openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Westhead, Martin (Martin)" <westh...@avaya.com>
Subject RE: Access to persistence metadata from datastore API
Date Tue, 28 Oct 2008 00:09:11 GMT
Thanks much Michael.  A small modification to your (remarkably
memorized) code in case anyone else is interested. There is another cast
required on this line:

Column[] cols = ((FieldMapping)
mapping.getField(fieldName)).getColumns();
                  ^^^^^^^^^^^^^

Thanks again,

Martin

-----Original Message-----
From: Michael Dick [mailto:michael.d.dick@gmail.com] 
Sent: Monday, October 27, 2008 1:08 PM
To: dev@openjpa.apache.org
Subject: Re: Access to persistence metadata from datastore API

Hi Martin,

The table and column annotations are processed by
AnnotationPersistenceMappingParser.java and are then stored in the
MappingRepository. You can get the MappingRepository from
JDBCConfigurationImpl by calling getMappingRepositoryInstance().

>From there you can query the ClassMapping and get the table / column
information from there.

>From my head the code would look something like this :

ClassMapping mapping = (ClassMapping) ((JDBCConfiguration)conf)
 
.getMetaDataRepositoryInstance().getMetaData(entityClass,
                        getClass().getClassLoader(), true);

Table table = mapping.getTable().getName();
Column[] cols = mapping.getField(fieldName).getColumns();
Column col = cols[0];

>From there you have the results of applying the annotations and any xml
overrides.

Hope this helps,
-mike

On Mon, Oct 27, 2008 at 2:10 PM, Westhead, Martin (Martin) <
westhead@avaya.com> wrote:

> Hi,
>
>
> I am investigating implementing an LDAP data store for Open JPA. I
have
> some basic storage and retrieval capabilities working in a proof of
> concept implementation. I was hoping to find some help accessing the
> persistence metadata, particularly things like the contents of @Table
> and @Column annotations. I was expecting this to be possible from the
> OpenJPAConfigurationImpl object but I haven't been able to see how to
do
> it. Any hints and especially code snippets would be very gratefully
> received.
>
>
>
> Thanks,
>
>
>
> Martin
>
>

Mime
View raw message