Hi Laird,
I'm not much better than a cricket with this particular question, but I have
a couple of observations...

Since you are attempting to affect the execution of the ReverseMappingTool,
you may be a little beyond basic usage questions.  Thus, I'm going to
cross-copy this question over the dev mailing list.  Not guaranteeing
activity because of this since most of us monitor both mailing lists.  But,
it won't hurt in this case...

One thing to keep in mind is that the ReverseMappingTool is not meant to be
the end-all tool for generating the Entity classes.  It is expected that
tweaking of the generated code will be necessary to make your Entities
"production ready".  Now, if the generated code is not syntactically correct
or complete, then that's another issue.  But, personally, I wouldn't expect
the generated code to be "complete".

If you continue to only get crickets responding to the request, then this
may indicate a lack of resource or even a lack of expertise on your
particular question.  It may also be an excellent opportunity for you to
roll up your sleeves, debug the problem, and contribute a solution back to
the community.  We are always looking for new blood.  :-)

Good luck,
Kevin


On Mon, Dec 7, 2009 at 10:29 AM, Laird Nelson <[email protected]> wrote:

> Hello; I asked this question before and got crickets.
>
> What is the best way to customize a ReverseMappingTool run such that for
> every table mapped I create a MappedSuperclass that it inherits from?
>
> I am using OpenJPA 1.2.1 and generating annotations, not XML.
>
> So if I have a database table named Person, then I want a
> PersonMappedSuperclass.java and a Person.java class that inherits from it.
>
> I am so close it is maddening, but cannot cross the final chasm.
>
> The first thing I do is to set my ReverseCustomizer to change the incoming
> ClassMapping to setEmbeddedOnly(true), and rename it to
> xyzMappedSuperclass.  Then I generate a new class, set the MappedSuperclass
> as its parent, and install the new mapping directly into the repository,
> like so (inside customize(ClassMapping)):
>
>    mapping.setEmbeddedOnly(true);
>
>    final Class<?> mappingClass = mapping.getDescribedType();
>    final String mappingClassName = mappingClass.getName();
>
>    final String newClassName = mappingClassName.substring(0,
> mappingClassName.length() - "MappedSuperclass".length());
>    final Class<?> newClass = this.tool.generateClass(newClassName,
> mappingClass);
>
>    final MappingRepository mappingRepository = this.tool.getRepository();
>
>    final ClassMapping newMapping =
> (ClassMapping)mappingRepository.addMetaData(newClass);
>    newMapping.setPCSuperclass(mappingClass);
>    newMapping.setTable(mapping.getTable()); // ? maybe?
>    newMapping.setEmbeddedOnly(false);
>
> This does more or less what I want: at the end of this run, I get a mapped
> superclass and an entity class that extends from it.  However, none of the
> mapped superclass field information is filled in.  That is, I get things
> like:
>
>    @Basic
>
> Instead of
>
>    @Basic
>    @Column(name="pmt_no", length=16)
>
> Bug 1360 seems to be related to this (
> http://issues.apache.org/jira/browse/OPENJPA-1360).  It would appear that
> in
> the 1.2.x line, anyhow, it is impossible to create a MappedSuperclass whose
> field annotations are properly filled in, thus of course defeating the
> entire purpose of a MappedSuperclass.  I would be interested to learn if
> ANYONE has ever generated MappedSuperclasses using this tool.
>
> Best,
> Laird
>

Reply via email to