You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by mysakjs <my...@us.ibm.com> on 2013/04/01 22:57:26 UTC
generate jpa entities without schema name included in @Table
annotation
Is there an option for org.apache.openjpa.jdbc.meta.ReverseMappingTool that
will effectively avoid adding the schema name for the @Table annotation on
generated entities?
I want to remove the schema name so the jpa entities don't have to be
updated in order to target an alternate set of schemas. (instead we'll use
openjpa.jdbc.Schema to set the default schema in persistence.xml ).
-useSchemaName=false doesn't seem to help, as it only affects whether or not
the schema name is included in the generated class name.
Is there another property I can set for this, e.g. to avoid having to
post-process the entities to remove the schema name from the @Table
annotation?
--
View this message in context: http://openjpa.208410.n2.nabble.com/generate-jpa-entities-without-schema-name-included-in-Table-annotation-tp7583310.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: generate jpa entities without schema name included in @Table
annotation
Posted by mysakjs <my...@us.ibm.com>.
Thanks Jeremy.
I opened https://issues.apache.org/jira/browse/OPENJPA-2366 for the feature
request.
--
View this message in context: http://openjpa.208410.n2.nabble.com/generate-jpa-entities-without-schema-name-included-in-Table-annotation-tp7583310p7583397.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: generate jpa entities without schema name included in @Table annotation
Posted by Jeremy Bauer <te...@gmail.com>.
Hi,
The reverse mapping tool can operate over multiple schemas so the table
annotation includes the schema name to ensure that the mappings match. I
checked the code and config and didn't spot any way to change this behavior
with the existing configuration options.
The only option that came to mind is to write a custom MetaDataFactory
plugin that supplies a custom AnnotationPersistenceMappingSerializer. Your
custom serializer would then need to override the
serializeClassMappingContent method. This method calls the (private)
serializeTable method to create the @Table annotation that is used in the
generated Java source. You could easily write your own version of
serializeTable to eliminate the schema name from the annotation. A little
tedious and a little extra configuration, but doable...
This seems like a useful general feature for the reverse mapping tool,
though. A switch to disable adding the schema name to the mapping should
be fairly simple to add. You could open a JIRA for the feature request -
https://issues.apache.org/jira/browse/OPENJPA. If you come up with a patch
you could contribute it to the project or someone else in the community may
pick up the JIRA and code up the feature.
-Jeremy
On Mon, Apr 1, 2013 at 3:57 PM, mysakjs <my...@us.ibm.com> wrote:
> Is there an option for org.apache.openjpa.jdbc.meta.ReverseMappingTool that
> will effectively avoid adding the schema name for the @Table annotation on
> generated entities?
>
> I want to remove the schema name so the jpa entities don't have to be
> updated in order to target an alternate set of schemas. (instead we'll use
> openjpa.jdbc.Schema to set the default schema in persistence.xml ).
>
> -useSchemaName=false doesn't seem to help, as it only affects whether or
> not
> the schema name is included in the generated class name.
>
> Is there another property I can set for this, e.g. to avoid having to
> post-process the entities to remove the schema name from the @Table
> annotation?
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/generate-jpa-entities-without-schema-name-included-in-Table-annotation-tp7583310.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>