0
votes

I am working on a project where I need to store an Entity, which is unmodifiable (from library), so I am using XML entity mappings entity object is like:

public abstract class BaseModel{
    Long uid;
    //getters/setters
}

public abstract class LocaleBaseModel{
    String locale;
    //Other properties, getter/setters
} 

public class Article extends LocaleBaseModel{
    private Long authorId;
    privaet String text;
    //Other properties        
}

<mapped-superclass class="package.BaseModel">
    <attributes>
        <id name="uid">
            <column name="UID" nullable="false" />
            <generated-value strategy="AUTO" />
        </id>
    </attributes>
</mapped-superclass>
<mapped-superclass class="package.LocaleBaseModel">
    <secondary-table name="STableName">
        <primary-key-join-column name="MID" referenced-column-name="UID" />
    </secondary-table>
    <attributes>
        <basic name="locale">
            <column name="LOCALE" updatable="false" nullable="false" />
        </basic>
        <basic name="text">
            <column name="Text" updatable="false" nullable="false" table="STableName" />
        </basic>
    </attributes>
</mapped-superclass>

<entity class="package.child.Article" name="Hadith">
    <table name="TableName" />
    <attributes>

    </attributes>
</entity>

but as soon as I add <secondarytable> I get an error which is quiet explanatory in itself:

  • 14:58:47,379 ERROR ErrorLogger:57 - Error parsing XML (2) : cvc-complex-type.3.1: Value '2.0' of attribute 'version' of element 'entity-mappings' is not valid with respect to the corresponding attribute use. Attribute 'version' has a fixed value of '1.0'.
  • 14:58:47,379 ERROR ErrorLogger:57 - Error parsing XML (2) : cvc-complex-type.2.4.a: Invalid content was found starting with element 'element-collection'. One of '{"http://java.sun.com/xml/ns/persistence/orm":basic, "http://java.sun.com/xml/ns/persistence/orm":version, "http://java.sun.com/xml/ns/persistence/orm":many-to-one, "http://java.sun.com/xml/ns/persistence/orm":one-to-many, "http://java.sun.com/xml/ns/persistence/orm":one-to-one, "http://java.sun.com/xml/ns/persistence/orm":many-to-many, "http://java.sun.com/xml/ns/persistence/orm":embedded, "http://java.sun.com/xml/ns/persistence/orm":transient}' is expected.
  • 14:58:47,379 ERROR ErrorLogger:57 - Error parsing XML (2) : cvc-complex-type.2.4.a: Invalid content was found starting with element 'secondary-table'. One of '{"http://java.sun.com/xml/ns/persistence/orm":description, "http://java.sun.com/xml/ns/persistence/orm":id-class, "http://java.sun.com/xml/ns/persistence/orm":exclude-default-listeners, "http://java.sun.com/xml/ns/persistence/orm":exclude-superclass-listeners, "http://java.sun.com/xml/ns/persistence/orm":entity-listeners, "http://java.sun.com/xml/ns/persistence/orm":pre-persist, "http://java.sun.com/xml/ns/persistence/orm":post-persist, "http://java.sun.com/xml/ns/persistence/orm":pre-remove, "http://java.sun.com/xml/ns/persistence/orm":post-remove, "http://java.sun.com/xml/ns/persistence/orm":pre-update, "http://java.sun.com/xml/ns/persistence/orm":post-update, "http://java.sun.com/xml/ns/persistence/orm":post-load, "http://java.sun.com/xml/ns/persistence/orm":attributes}' is expected.

I have following on path, with others from spring 3.0.5

  • hibernate-entitymanager-3.6.2
  • hibernate-jpa-2.0-api
  • hibernate-core-3.6.2.Final
1

1 Answers

0
votes

according to the orm-schema

the secondary-table elements likes to be placed withing the

entity element after the table tag

<pre> alike &lt;entity>
        &lt;table/>
        &lt;secondary-table/>
        ...

agreed the error message is noisy but that is the glorious schema spec.

ys.