Warning Messages when overriding metadata in XML

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Warning Messages when overriding metadata in XML

Steve Ramage
Hello, I'm trying to override some mapping metadata in XML, specifically change the allocation size used in tests to something larger since it improves performance significantly. My read of the JPA Spec says that I can do this
If the xml-mapping-metadata-complete subelement is not specified, the XML descriptor overrides the values set or defaulted by the use of annotations, as described below. (p 514).
It specifically says on (p.517) with respect to the table-generator tag:
The generator defined by the table-generator subelement applies to the persistence unit. It is undefined if multiple mapping files for the persistence unit contain generators of the same name. The generator defined is added to any generators defined in annotations. If a generator of the same name is defined in annotations, the generator defined by this subelement overrides that definition.
So my read of the above says that if I have some entity, like:
@Table(name="SomeEntity", catalog="OpenJPATest")
public class SomeEntity {

	@GeneratedValue(strategy= GenerationType.TABLE, generator="SomeEntity")
	@TableGenerator(name="SomeEntity", catalog="OpenJPATest", table="JPA_GENERATED_KEYS", pkColumnName="ID", valueColumnName="LAST_VALUE", pkColumnValue="SomeEntity")
	private long id;

	private String attr;

	public SomeEntity(final String attr) {
		this.attr = attr;
And a entity-mapping like this:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
				 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd" version="2.0">
	<table-generator name="SomeEntity" table="JPA_GENERATED_KEYS" pk-column-name="ID"  value-column-name="LAST_VALUE" pk-column-value="SomeEntity" allocation-size="10000"/>
Then the allocation size should be 10,000. This works, properly. However I get the following warning when doing this:
722  base-persistence-unit  WARN   [main] openjpa.MetaData - Found duplicate generator "SomeEntity" in "private long test.SomeEntity.id".  Ignoring.
This warning is annoying and problematic. I would rather not suppress warnings, and I do not believe this case should be a warning, since it is specifically allowed by the spec. Am I doing something wrong, or is this a bug?