Making classes serializable

Making schema-derived classes serializable

According to the Java Persistence API specification, section 2.1, entities must implement the serializable interface:

If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the Serializable interface.

Hyperjaxb2 itself does not enforce serializable classes generation, you should use the jaxb:serializable global bindings customization element to make your model serializable:

bindings.xjb
<jaxb:bindings version="1.0"
	xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	
	<jaxb:bindings schemaLocation="schema.xsd" node="/xsd:schema">
		<jaxb:globalBindings localScoping="toplevel">
			<jaxb:serializable/>
		</jaxb:globalBindings>
	</jaxb:bindings>
</jaxb:bindings>

Browse Space

- Pages
- News
- Labels
- Attachments
- Bookmarks
- Mail
- Activity
- Advanced

Explore Confluence

- Popular Labels
- Notation Guide
- Impressum

Your Account

Log In

 

Other Features

Add Content