openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laird Nelson (JIRA)" <>
Subject [jira] Commented: (OPENJPA-1360) ReverseMappingTool omits nullable, length, etc. when ClassMapping.setEmbedded(true) is called
Date Mon, 26 Oct 2009 22:10:59 GMT


Laird Nelson commented on OPENJPA-1360:

It looks like, at least for the annotations path, AnnotationPersistenceMetaDataSerializer
is the culprit.  At line 202 or thereabouts, in the isMappingMode(ClassMetaData meta) method,
it includes a check to see if the supplied meta isEmbeddedOnly().  If it is, then there is
nothing else you can do from the standpoint of your ReverseCustomizer: that metdata is deemed
to NOT be in mapping mode.  That of course means that when the Java code is written out, all
fields are output with only a @Basic annotation and nothing else.

The (rather cumbersome) workaround is to subclass both this serializer and PersistenceMappingFactory
and supply a PersistenceMappingFactory implementation that returns new instances of an AnnotationPersistenceMetaDataSerializer
that is capable of omitting this isEmbeddedOnly() check from its own implementation of the
isMappingMode(ClassMetaData meta) method.

> ReverseMappingTool omits nullable, length, etc. when ClassMapping.setEmbedded(true) is
> ---------------------------------------------------------------------------------------------
>                 Key: OPENJPA-1360
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: tooling
>    Affects Versions: 1.3.0, 2.0.0
>            Reporter: Laird Nelson
> In my ReverseCustomizer, I call classMapping.setEmbedded(true).  This is because for
a variety of reasons I need the code that is generated by the ReverseMappingTool to be @MappedSuperclasses,
not @Entities.
> Indeed when I do this, the resulting class is a @MappedSuperclass (great!) BUT all of
the length and nullable and other @Column attributes are missing.  In other words, all simple
fields receive only a @Basic annotation, with no attributes, and nothing else.  In addition,
the class declaration receives a @Table annotation with no attributes.  (I'm using the command
line flag that instructs the ReverseMappingTool to generate annotations.)
> Ideally I'd like the generated source code to look identical to the source code that
would be generated for a ClassMapping where setEmbedded(true) was never called, except of
course that I want the @Entity annotation to be replaced with @MappedSuperclass.
> Obviously if there is a better way from within a ReverseCustomizer for me to accomplish
my (very odd) goals (mandated by a strange development process and a 30-year-old database),
I am all ears.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message