Skip to end of metadata
Go to start of metadata

JPA 2 support

Hyperjaxb3 supports JPA 2 since version 0.5.6.

Generating JPA 2 metadata

Use the jpa2 variant to generate JPA 2 annotations:

Maven:

Ant:

Icon

Hyperjaxb3 can generate JPA 2 annotations as well as XML mapping files according to the JPA 2 according to the JPA 2 orm_2_0.xsd XML schema. Use <result>mappingFiles</result> or -Xhyperjaxb3-jpa2-result=mappingFiles configuration items accordingly.

Supported JPA 2 features

Collections of simple types

JPA 2 supports collections of simple types using the @ElementCollection annotation.
Hyperjaxb3 uses this feature to improve mapping of the repeatable simple type elements.

Example:

Generates:

Improved embedding

In JPA 2, @Embeddable mechanism is much more powerful when compared to to JPA 1. Embeddable classes can now have complex properties, associations, collections - and even nested embeddables.
Hyperjaxb3 now supportes @Embeddable features.

Example:

Note that both PersonType as well as AddressType are embeddable. Moreover, PersonType has a nested embeddable (address).

Generates:

Here's how it looks like in the database:

Note that column names for both embeddable AddressType fields do not collide.

  • No labels