Skip to content

Enforcing_top level_classes

Alexey Valikov edited this page Aug 31, 2017 · 1 revision

Enforcing top-level classes

Enforcing top-level classes

According to the Java Persistence API specification, section 2.1, entities must be top-level classes:

The entity class must be a top-level class.

Hyperjaxb3 on its own does not (and technically cannot) enforce top-level class generation. You will need to use a JAXB customization to allow this:

schema.xsd

<?xml version="1.0"?>
<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">

    <xs:annotation>
        <xs:appinfo>
            <jaxb:globalBindings generateIsSetMethod="true" localScoping="toplevel">
                <jaxb:serializable/>
            </jaxb:globalBindings>
        </xs:appinfo>
    </xs:annotation>

    <!-- ... -->
</xs:schema>
Clone this wiki locally