Issue Details (XML | Word | Printable)

Key: OPENJPA-239
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Marc Prud'hommeaux
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenJPA

Option for the reverse mapping tool to generate mapping annotations

Created: 16/May/07 10:45 PM   Updated: 01/Jul/07 07:39 PM
Return to search
Component/s: jdbc, jpa
Affects Version/s: 0.9.0, 0.9.6, 0.9.7
Fix Version/s: 1.0.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works openjpa-revtool-ann-doc.patch 2007-06-28 08:43 PM Gokhan Ergul 4 kB
Text File Licensed for inclusion in ASF works openjpa-revtool-ann.patch 2007-06-26 01:26 PM Gokhan Ergul 117 kB

Resolution Date: 01/Jul/07 07:39 PM


 Description  « Hide
The reverse mapping tool currently only generates mappings in a separate orm.xml file. It would be useful if there was an option to instead generate annotations in the generated .java files.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Gokhan Ergul added a comment - 26/Jun/07 01:26 PM
Attached patch adds generating EJB 3.0 annotations feature to reverse mapping tool, enabled by -annotations flag.

Few implementation notes:
- The mechanism with which annotations are built follows xml metadata serialization scheme, in particular AnnotationPersistenceMetaDataSerializer and AnnotationPersistenceMappingSerializer closely resemble XMLPersistenceMetaDataSerializer and XMLPersistenceMappingSerializer. There's also a fair bit of code duplication among those classes, we might consider doing some refactoring there if you think it's worthwhile.
- I've tried to limit the number and impact of the changes on internal interfaces, which led to some rather awkward code at times --in particular how the annotation serializer gets invoked and its results are passed back to revmap tool. Any suggestions are welcome.
- I'm not sure about how to update the documentation, if anyone can point me in the right direction I can get it done.

Marc Prud'hommeaux added a comment - 26/Jun/07 07:36 PM
I tried this out on the examples/reversemapping/ example (after building it with "mvn package" and then modifying examples/reversemapping/build.xml to have GenerateAnnotations="true" and chaning examples/META-INF/persistence.xml to not list the orm.xml file and instead enumerate all the persistent classes), and it appears to work. Great job!

I haven't had a chance to review the patch in detail yet, but the annotations in the generated code look good to me. One thing I notice is that when I run against the aforementioned example, a "orm.xml" file is till generated. Do you know why this is?

Gokhan Ergul added a comment - 27/Jun/07 03:06 AM
I haven't disabled orm.xml generation on purpose when annotations are enabled --iirc Patrick suggested that disabling it would be an option while we were discussing the feature. It can be disabled by setting metadata="none".

Marc Prud'hommeaux added a comment - 27/Jun/07 07:32 PM
Sounds good. The only thing that is left is that we need documentation of the new arguments and their meanings in openjpa-project/src/doc/manual/ref_guide_mapping.xml . Once there is a patch in place, I don't see any reason not to commit it.

Gokhan Ergul added a comment - 28/Jun/07 08:43 PM
Doc update attached. I wasn't able to run docbook locally, so couldn't test the output.

Additional note: while updating the docs I realized there're quite a few options (not related to annotations) documented in ReverseMappingTool javadoc but did not make it to the manual. Oversight?

Marc Prud'hommeaux added a comment - 29/Jun/07 10:53 PM
I like it. Anyone have any issues with committing this patch?

Marc Prud'hommeaux added a comment - 01/Jul/07 07:39 PM
I've gone ahead and committed the patch. Thanks for the feature imeplementation!