openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Bauer <techhu...@gmail.com>
Subject Re: Attribute 'pk-column-value' is not allowed to appear in element 'generated-value'
Date Wed, 09 Jun 2010 16:57:29 GMT
Hi Gilberto,

The generated-value element does not provide an attribute named
"pk-column-value", thus, the schema validator validating your orm.xml file
is throwing an exception.

This line is the culprit:

<generated-value strategy="TABLE" generator="table_generator"
pk-column-value="person"/>

The schema definition for generated-value is as follows:

<xsd:complexType name="generated-value">
  <xsd:annotation>
    <xsd:documentation>
        @Target({METHOD, FIELD}) @Retention(RUNTIME)
        public @interface GeneratedValue {
           GenerationType strategy() default AUTO;
           String generator() default "";
        }
    </xsd:documentation>
  </xsd:annotation>
  <xsd:attribute name="strategy" type="orm:generation-type"/>
  <xsd:attribute name="generator" type="xsd:string"/>
</xsd:complexType>

The pk-column-name can only be specified on the table generator itself.  I
don't think it is possible to override the pk-column-name at an attribute
level - certainly not via generated-value.  According to the JPA 2.0 spec:

<spec>
3. The sequence-generator, table-generator, named-query,
named-native-query and sql-result-set-mapping elements are global
to the persistence unit. It is undefined to have more than one
sequence-generator or table-generator of the same name in the same
or different mapping files in a persistence unit.
</spec>

Once a table generator is defined, there can/should only be one definition
for the persistence unit.  You can define multiples with a different
pk-column-name values, but the table-generator name needs to be unique.

hth,
-Jeremy

On Wed, Jun 9, 2010 at 9:29 AM, gilbertoca <gilbertoca@gmail.com> wrote:

>
> Hi, hope everyone is well!
>
> Can anyone help me understand the following exception (
>
> http://code.google.com/p/construtor/source/browse/trunk/park-jpa/core/src/main/resources/META-INF/orm.xml
> my orm.xml file ):
> [CODE]
> [INFO] [compiler:compile {execution: default-compile}]
> [INFO] Compiling 13 source files to
> /home/gilberto/dev/netbeans-config/park-jpa/core/target/classes
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
> 216  parkPU  INFO   [main] openjpa.Tool - No targets were given.  Running
> on
> all classes in your persistent classes list, or all metadata files in
> classpath directories if you have not listed your persistent classes.  Use
> -help to display tool usage information.
> <openjpa-2.0.0-r422266:935683 nonfatal general error>
> org.apache.openjpa.util.GeneralException: org.xml.sax.SAXException:
>
> file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml
> [Location: Line: 30, C: 105]: org.xml.sax.SAXParseException:
> cvc-complex-type.3.2.2: Attribute 'pk-column-value' is not allowed to
> appear
> in element 'generated-value'.
>        at
>
> org.apache.openjpa.persistence.PersistenceMetaDataFactory.parseXML(PersistenceMetaDataFactory.java:295)
>        at
>
> org.apache.openjpa.persistence.PersistenceMetaDataFactory.load(PersistenceMetaDataFactory.java:228)
>        at
>
> org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:554)
>        at
>
> org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:374)
>        at
>
> org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:358)
>        at org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java:256)
>        at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4653)
>        at
> org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTask.java:89)
>        at
> org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:171)
>        at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>        at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>        at java.lang.reflect.Method.invoke(Method.java:616)
>        at
> org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
>        at org.apache.tools.ant.Task.perform(Task.java:348)
>        at org.apache.tools.ant.Target.execute(Target.java:357)
>        at
>
> org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:118)
>        at
> org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:98)
>        at
>
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
>        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
>        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>        at
> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>        at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>        at java.lang.reflect.Method.invoke(Method.java:616)
>        at
> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>        at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> Caused by: java.io.IOException: org.xml.sax.SAXException:
>
> file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml
> [Location: Line: 30, C: 105]: org.xml.sax.SAXParseException:
> cvc-complex-type.3.2.2: Attribute 'pk-column-value' is not allowed to
> appear
> in element 'generated-value'.
>        at
>
> org.apache.openjpa.lib.meta.XMLMetaDataParser.parseNewResource(XMLMetaDataParser.java:396)
>        at
>
> org.apache.openjpa.lib.meta.XMLMetaDataParser.parse(XMLMetaDataParser.java:334)
>        at
>
> org.apache.openjpa.lib.meta.XMLMetaDataParser.parse(XMLMetaDataParser.java:311)
>        at
>
> org.apache.openjpa.lib.meta.XMLMetaDataParser.parse(XMLMetaDataParser.java:284)
>        at
>
> org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.parse(XMLPersistenceMetaDataParser.java:364)
>        at
>
> org.apache.openjpa.persistence.PersistenceMetaDataFactory.parseXML(PersistenceMetaDataFactory.java:293)
>        ... 37 more
> Caused by: org.xml.sax.SAXException:
>
> file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml
> [Location: Line: 30, C: 105]: org.xml.sax.SAXParseException:
> cvc-complex-type.3.2.2: Attribute 'pk-column-value' is not allowed to
> appear
> in element 'generated-value'.
>        at
>
> org.apache.openjpa.lib.meta.XMLMetaDataParser.getException(XMLMetaDataParser.java:675)
>        at
>
> org.apache.openjpa.lib.meta.XMLMetaDataParser.error(XMLMetaDataParser.java:434)
>        at
>
> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:137)
>        at
>
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:387)
>        at
>
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:321)
>        at
>
> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:413)
>        at
>
> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3168)
>        at
>
> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(XMLSchemaValidator.java:2633)
>        at
>
> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2040)
>        at
>
> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:708)
>        at
>
> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:353)
>        at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2723)
>        at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:624)
>        at
>
> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
>        at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:486)
>        at
>
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:810)
>        at
>
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:740)
>        at
>
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:110)
>        at
>
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1208)
>        at
>
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:525)
>        at javax.xml.parsers.SAXParser.parse(SAXParser.java:392)
>        at
>
> org.apache.openjpa.lib.meta.XMLMetaDataParser.parseNewResource(XMLMetaDataParser.java:393)
>        ... 42 more
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] An Ant BuildException has occured: <openjpa-2.0.0-r422266:935683
> nonfatal general error> org.apache.openjpa.util.GeneralException:
> org.xml.sax.SAXException:
>
> file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml
> [Location: Line: 30, C: 105]: org.xml.sax.SAXParseException:
> cvc-complex-type.3.2.2: Attribute 'pk-column-value' is not allowed to
> appear
> in element 'generated-value'.
>
> [INFO]
> ------------------------------------------------------------------------
> [INFO] For more information, run Maven with the -e switch
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 9 seconds
> [INFO] Finished at: Wed Jun 09 10:51:26 BRT 2010
> [INFO] Final Memory: 17M/67M
> [INFO]
> ------------------------------------------------------------------------
> gilberto@SUGEP-DMASI:~/dev/netbeans-config/park-jpa/core>
> [/CODE]
>
> I've defined a per persistent unit table-generator element with default
> pk-column-value="DEFAULT" and in the entity definition I override it like
> so: pk-column-value="parking".
>
> Regards,
>
> Gilberto
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Attribute-pk-column-value-is-not-allowed-to-appear-in-element-generated-value-tp5158720p5158720.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message