GithubHelp home page GithubHelp logo

highsource / hyperjaxb3 Goto Github PK

View Code? Open in Web Editor NEW
34.0 7.0 33.0 14.87 MB

Hyperjaxb3 provides relational persistence for JAXB objects

License: BSD 2-Clause "Simplified" License

Java 92.05% XSLT 1.95% Batchfile 0.71% XS 4.33% HTML 0.55% Roff 0.41%

hyperjaxb3's Introduction

hyperjaxb3

Hyperjaxb3 provides relational persistence for JAXB objects

IMPORTANT NOTE

This repository has been merged in jaxb-tools repository along maven-jaxb2-plugin.
Users are encouraged to read the migration guide to get the latest version of the plugin according their JAXB version

hyperjaxb3's People

Contributors

archenroot avatar bgedik avatar dependabot[bot] avatar highsource avatar laurentschoelens avatar pethers avatar vkrishnap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hyperjaxb3's Issues

Support for jaxb2-basics version 0.11

It looks like hyperjaxb3 supports up to version 0.10 of jaxb2-basics. That is specified in the top-level pom file. Using it with 0.11 causes problems as below. Is it possible to support 0.11 series?

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customizing' defined in URL [jar:file:/<SOME_PATH_HERE>/maven/repository/org/jvnet/hyperjaxb3/hyperjaxb3-ejb-plugin/0.6.1/hyperjaxb3-ejb-plugin-0.6.1.jar!/org/jvnet/hyperjaxb3/ejb/plugin/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoSuchFieldError: INSTANCE Caused by: java.lang.NoSuchFieldError: INSTANCE

Way to disable IdClass generation ?

Hello,

When you create an entity with composite key, hyperjaxb generate an IdClass ( required by JPA ).

But some databases don't require this. ( like ObjectDb ).

Is there a way to just disable this class generation ?

Thanks

Customize element for abstract complexType

I'm converting an XSD schema to a Java annotated bean for Hibernate with HyperJaxb3.

So far I managed to generate the Java objects, but I need to customize the remark field of the OperableType because the default generated length is 255 and I need to extend it to 4000.

Here's the fragment of the relevent xsd schema:

<xs:complexType name="OperableType" abstract="true">
    <xs:annotation>
        <xs:documentation xml:lang="en">OperableType contains all the elements and attributes common to all the operables. This is an abstract type, so no element of this type will be present in the XML.
        The logical ID is a unique logical identifier of a sanctioned entity, of a regulation or of a detail of a sanction entity. This information is also provided to external actors for help, especially when entity multiple aliases make it difficult the identification task. For entities imported from previous database, the old value is retained.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
        <xs:element name="remark" type="fsdexport:UnlimitedTextType" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="additionalInformation" type="fsdexport:AdditionalInfoType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="logicalId" type="xs:long" use="required"/>
</xs:complexType>
<xs:simpleType name="UnlimitedTextType">
    <xs:restriction base="xs:string"/>
</xs:simpleType>

I can't modify the XSD schema nor the XML file I receive, so I need to customize the bindings for it to work.

I tried using this binding

   <jxb:bindings node="xs:complexType[@name='OperableType']">
        <jxb:bindings node="xs:sequence//xs:element[@name='remark']">
            <hj:basic>
                <orm:column length="4000" />
            </hj:basic>
        </jxb:bindings>
    </jxb:bindings>

but it doesn't modify the length in the generated code.

@ElementCollection
@OrderColumn(name = "HJINDEX")
@Column(name = "HJVALUE", length = 255)
@CollectionTable(name = "OPERABLE_TYPE_REMARK", joinColumns = {
    @JoinColumn(name = "HJID")
})
public List<String> getRemark() {

I also tried to use 'hj:default-single-property' to customized the UnlimitedTextType but I didn't managed to make it work either.

Tutorial

Any chance of a tutorial on how to use this utility?

How to use custom naming strategy with maven-jaxb2-plugin/hyperjaxb3-ejb-plugin combo ?

Hello.
I tried to turn on custom naming strategy as of https://stackoverflow.com/a/34096471
Maven project properties are:

 <java.version>1.8</java.version>
   <hyperjaxb3.version>0.6.3-SNAPSHOT</hyperjaxb3.version>
   <maven-jaxb2-plugin.version>0.13.3</maven-jaxb2-plugin.version>
   <jaxb.version>2.2.11</jaxb.version>

And it is working with hyperjaxb3-maven-plugin:

            <plugin>
                <groupId>org.jvnet.hyperjaxb3</groupId>
                <artifactId>hyperjaxb3-maven-plugin</artifactId>
                <version>${hyperjaxb3.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <extension>true</extension>
                    <roundtripTestClassName>RoundtripTest</roundtripTestClassName>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.jvnet.hyperjaxb3</groupId>
                        <artifactId>hyperjaxb3-ejb-extensions-custom-naming-pre_0_6_0</artifactId>
                        <version>${hyperjaxb3.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

But I can't make it working with maven-jaxb2-plugin/hyperjaxb3-ejb-plugin .
Tried like this (see comment <-- FIRST --> <-- SECOND --> <-- THIRD --> ):

            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>${maven-jaxb2-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <extension>true</extension>
                      <-- some other .... -->

                    <plugins>
                        <plugin>
                            <groupId>org.jvnet.hyperjaxb3</groupId>
                            <artifactId>hyperjaxb3-ejb-plugin</artifactId>
                            <version>${hyperjaxb3.version}</version>
                          <-- FIRST -->
                            <dependencies>
                                <dependency>
                                    <groupId>org.jvnet.hyperjaxb3</groupId>
                                    <artifactId>hyperjaxb3-ejb-extensions-custom-naming-pre_0_6_0</artifactId>
                                    <version>${hyperjaxb3.version}</version>
                                </dependency>
                            </dependencies>
<-- Gives error:  Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.3:generate (default) on project entity-gen: Unable to parse configuration of mojo org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.3:generate for parameter dependencies: Cannot find 'dependencies' in class org.apache.maven.model.Dependency -> [Help 1] -->
                        </plugin>
                        <plugin>
                            <groupId>org.jvnet.hyperjaxb3</groupId>-->
                            <artifactId>hyperjaxb3-ejb-extensions-custom-naming-pre_0_6_0</artifactId>
                            <version>${hyperjaxb3.version}</version>
                        </plugin>
                       <--    SECOND -->
                        <dependencies>
                            <dependency>
                                <groupId>org.jvnet.hyperjaxb3</groupId>
                                <artifactId>hyperjaxb3-ejb-extensions-custom-naming-pre_0_6_0</artifactId>
                                <version>${hyperjaxb3.version}</version>
                            </dependency>
                        </dependencies>
<-- Gives error:  Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.3:generate (default) on project entity-gen: Unable to parse configuration of mojo org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.3:generate for parameter dependency: Cannot find 'dependency' in class org.apache.maven.model.Dependency -> [Help 1] -->
                    </plugins>

                    <args>
                        <arg>-Xequals</arg>
                      <-- some other .... -->

                    </args>
                </configuration>
                <--    THIRD-->
                <dependencies>
                    <dependency>
                        <groupId>org.jvnet.hyperjaxb3</groupId>
                        <artifactId>hyperjaxb3-ejb-extensions-custom-naming-pre_0_6_0</artifactId>
                        <version>${hyperjaxb3.version}</version>
                    </dependency>
                </dependencies>
                <-- NO EFFECT -->
            </plugin>

hyperjaxb3-ejb-extensions-custom-naming-pre_0_6_0 is also in main pom dependencies - no effect.

Is it possible to use custom naming strategy with maven-jaxb2-plugin/hyperjaxb3-ejb-plugin combo ?

NullPointerException on DefaultGetTypes.java:42

Hi all, hi Lexicon,
I am here because on stackoverflow they're closing my post.
As said, this is the stack I am now having as an error (the complete one).
Some suggestions?

Unfortunately, I can't share xsds.

[INFO] Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@366558a2: display name [org.springframework.context.support.FileSystemXmlApplicationContext@366558a2]; startup date [Thu Jul 14 10:59:31 CEST 2016]; root of context hierarchy [INFO] Loading XML bean definitions from URL [jar:file:/home/sector/.m2/repository/org/jvnet/hyperjaxb3/hyperjaxb3-ejb-plugin/0.6.1/hyperjaxb3-ejb-plugin-0.6.1.jar!/org/jvnet/hyperjaxb3/ejb/plugin/applicationContext.xml] [INFO] Bean factory for application context [org.springframework.context.support.FileSystemXmlApplicationContext@366558a2]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1100757a [INFO] Bean 'org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) [INFO] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1100757a: defining beans [ignoring,naming,customizing,embeddableAttributesMapping,mapping,createXAnnotations,annotateOutline,org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor,wrapSingleBuiltinNonReference,wrapSingleEnumNonReference,wrapSingleHeteroElement,wrapCollectionBuiltinElement,wrapCollectionEnumElement,wrapCollectionEnumAttribute,wrapCollectionBuiltinAttribute,wrapCollectionBuiltinValue,wrapCollectionEnumValue,wrapSingleBuiltinReference,wrapSingleEnumElementReference,wrapSingleClassElementReference,wrapSingleSubstitutedElementReference,wrapSingleWildcardReference,wrapSingleHeteroReference,wrapCollectionHeteroReference,wrapCollectionWildcardReference,wrapCollectionHeteroElement,adaptBuiltinTypeUse,processModel,getTypes,processClassInfo,processPropertyInfos,createIdClass,createDefaultIdPropertyInfos,createDefaultVersionPropertyInfos,getIdPropertyInfos,getVersionPropertyInfos,reservedNames,customizationsContext,abstractCustomizationsUnmarshalledResource,persistenceFactory,persistenceMarshaller,annotationsProcessor,marshalMappings,mappingFilesProcessor,annotations,mappingFiles]; root of factory hierarchy [INFO] Loading properties file from URL [jar:file:/home/sector/.m2/repository/org/jvnet/hyperjaxb3/hyperjaxb3-ejb-plugin/0.6.1/hyperjaxb3-ejb-plugin-0.6.1.jar!/org/jvnet/hyperjaxb3/ejb/strategy/naming/impl/ReservedNames.properties] java.lang.NullPointerException at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultGetTypes.ref(DefaultGetTypes.java:42) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultGetTypes.process(DefaultGetTypes.java:29) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultGetTypes.process(DefaultGetTypes.java:25) at org.jvnet.hyperjaxb3.ejb.strategy.ignoring.impl.DefaultIgnoring.isPropertyInfoIgnored(DefaultIgnoring.java:175) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessPropertyInfos.process(DefaultProcessPropertyInfos.java:96) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessPropertyInfos.process(DefaultProcessPropertyInfos.java:28) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessClassInfo.process(DefaultProcessClassInfo.java:17) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessClassInfo.process(DefaultProcessClassInfo.java:12) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessModel.process(DefaultProcessModel.java:51) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessModel.process(DefaultProcessModel.java:32) at org.jvnet.hyperjaxb3.ejb.strategy.processor.DefaultModelAndOutlineProcessor.process(DefaultModelAndOutlineProcessor.java:43) at org.jvnet.hyperjaxb3.ejb.strategy.processor.DefaultModelAndOutlineProcessor.process(DefaultModelAndOutlineProcessor.java:16) at org.jvnet.hyperjaxb3.ejb.plugin.EjbPlugin.run(EjbPlugin.java:213) at org.jvnet.jaxb2_commons.plugin.AbstractPlugin.run(AbstractPlugin.java:52) at com.sun.tools.xjc.model.Model.generateCode(Model.java:292) at org.jvnet.mjiip.v_2_2.XJC22Mojo.generateCode(XJC22Mojo.java:66) at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:41) at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:505) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:328) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) [ERROR] Error while generating code.Location []. org.xml.sax.SAXParseException; Error during plugin execution. at org.jvnet.jaxb2_commons.plugin.AbstractPlugin.run(AbstractPlugin.java:54) at com.sun.tools.xjc.model.Model.generateCode(Model.java:292) at org.jvnet.mjiip.v_2_2.XJC22Mojo.generateCode(XJC22Mojo.java:66) at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:41) at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:505) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:328) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: java.lang.NullPointerException at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultGetTypes.ref(DefaultGetTypes.java:42) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultGetTypes.process(DefaultGetTypes.java:29) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultGetTypes.process(DefaultGetTypes.java:25) at org.jvnet.hyperjaxb3.ejb.strategy.ignoring.impl.DefaultIgnoring.isPropertyInfoIgnored(DefaultIgnoring.java:175) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessPropertyInfos.process(DefaultProcessPropertyInfos.java:96) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessPropertyInfos.process(DefaultProcessPropertyInfos.java:28) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessClassInfo.process(DefaultProcessClassInfo.java:17) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessClassInfo.process(DefaultProcessClassInfo.java:12) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessModel.process(DefaultProcessModel.java:51) at org.jvnet.hyperjaxb3.ejb.strategy.model.base.DefaultProcessModel.process(DefaultProcessModel.java:32) at org.jvnet.hyperjaxb3.ejb.strategy.processor.DefaultModelAndOutlineProcessor.process(DefaultModelAndOutlineProcessor.java:43) at org.jvnet.hyperjaxb3.ejb.strategy.processor.DefaultModelAndOutlineProcessor.process(DefaultModelAndOutlineProcessor.java:16) at org.jvnet.hyperjaxb3.ejb.plugin.EjbPlugin.run(EjbPlugin.java:213) at org.jvnet.jaxb2_commons.plugin.AbstractPlugin.run(AbstractPlugin.java:52) ... 28 more

Default entity table schema do not apply to CollectionTable

I have this rule in bindings.xjb to apply a default schema to all tables and works fine for almost all table

<hj:persistence>
	<hj:default-entity>
		<orm:table schema="europe" />
	</hj:default-entity>
</hj:persistence>

Here's the fragment of the relevent xsd schema:

<xs:complexType name="OperableType" abstract="true">
    <xs:annotation>
        <xs:documentation xml:lang="en">OperableType contains all the elements and attributes common to all the operables. This is an abstract type, so no element of this type will be present in the XML.
        The logical ID is a unique logical identifier of a sanctioned entity, of a regulation or of a detail of a sanction entity. This information is also provided to external actors for help, especially when entity multiple aliases make it difficult the identification task. For entities imported from previous database, the old value is retained.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
        <xs:element name="remark" type="fsdexport:UnlimitedTextType" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="additionalInformation" type="fsdexport:AdditionalInfoType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="logicalId" type="xs:long" use="required"/>
</xs:complexType>
<xs:simpleType name="UnlimitedTextType">
    <xs:restriction base="xs:string"/>
</xs:simpleType>

The parent class is generated with schema="europe"

@Table(name = "OPERABLE_TYPE", schema = "europe")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class OperableType

The generated portion of the CollectionTable is missing the schema="europe"

    @ElementCollection
    @OrderColumn(name = "HJINDEX")
    @Column(name = "HJVALUE", length = 4000)
    @CollectionTable(name = "OPERABLE_TYPE_REMARK", joinColumns = {
        @JoinColumn(name = "HJID")
    })
    public List<String> getRemark() {

I think it may be a bug but I hope there's just a customization rule to apply (even if I didn't find the one)

[question] Interface for custom JPA strategy generation

As we all know :-) XSD and JPA are not always friends and in some case one might need kind of override for its specific use case.

Is there any kind of interface in hyperjaxb where I could override the default JPA generation strategy or enhance it,? Imagine I would like to generate createdOn, UpdatedOn, etc. columns to every entity for example.

Background: I model XSD first for even bus. I support both XML and JSON messages (detected on the fly). Preferred is JSON, so I generate JSON schemas from XSD as well. Now I would like to first persists objects for later generation REST API, with Spring Data JPA and Spring Data REST...

Thanks for any hints.

Support for Java 11

does the project support java 11 i have a problem with configuration. I'm running Spring 5.1.3 and Hibernate 5.3.7

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 13 counts of IllegalAnnotationExceptions at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check (IllegalAnnotationsException.java:106) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet (JAXBContextImpl.java:471) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init> (JAXBContextImpl.java:303) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init> (JAXBContextImpl.java:139) at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build (JAXBContextImpl.java:1156) at com.sun.xml.bind.v2.ContextFactory.createContext (ContextFactory.java:165) at com.sun.xml.bind.v2.ContextFactory.createContext (ContextFactory.java:289) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

One of this 13 elements:

Two classes have the same XML type name "entity". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.sun.java.xml.ns.persistence.orm.Entity at protected java.util.List com.sun.java.xml.ns.persistence.orm.EntityMappings.entity at com.sun.java.xml.ns.persistence.orm.EntityMappings at public com.sun.java.xml.ns.persistence.orm.EntityMappings com.sun.java.xml.ns.persistence.orm.ObjectFactory.createEntityMappings() at com.sun.java.xml.ns.persistence.orm.ObjectFactory this problem is related to the following location: at org.jvnet.hyperjaxb3.ejb.schemas.customizations.Entity at protected org.jvnet.hyperjaxb3.ejb.schemas.customizations.Entity org.jvnet.hyperjaxb3.ejb.schemas.customizations.Persistence.defaultEntity at org.jvnet.hyperjaxb3.ejb.schemas.customizations.Persistence at public javax.xml.bind.JAXBElement org.jvnet.hyperjaxb3.ejb.schemas.customizations.ObjectFactory.createPersistence(org.jvnet.hyperjaxb3.ejb.schemas.customizations.Persistence) at org.jvnet.hyperjaxb3.ejb.schemas.customizations.ObjectFactory

I found that one of them is in package hyperjaxb3-ejb-schema-customizations and secodn in hyperjaxb3-ejb-schema-persistance. My configuration is below:

            <groupId>org.jvnet.hyperjaxb3</groupId>
            <artifactId>maven-hyperjaxb3-plugin</artifactId>
            <version>0.6.1</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-impl</artifactId>
                        <version>2.4.0-b180830.0438</version>
                    </dependency>
                <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-xjc</artifactId>
                        <version>2.4.0-b180830.0438</version>
                    </dependency>
                <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-core</artifactId>
                        <version>2.3.0.1</version>
                    </dependency>
                <dependency>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                    <version>2.4.0-b180830.0359</version>
                </dependency>
            </dependencies>
            <configuration>
                <extension>true</extension>
                <removeOldOutput>true</removeOldOutput>
                <verbose>true</verbose>
                <readOnly>true</readOnly>
            </configuration>
        </plugin>

Project does not build

mvn package:

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'parent.relativePath' of POM org.jvnet.hyperjaxb3:hyperjaxb3-maven-plugin:[unknown-version] (/home/bgedik/work/hjb-master/maven/plugin/pom.xml) points at org.jvnet.hyperjaxb3:maven-hyperjaxb3 instead of org.jvnet.hyperjaxb3:hyperjaxb3-maven, please verify your project structure @ line 9, column 10
[FATAL] Non-resolvable parent POM for org.jvnet.hyperjaxb3:hyperjaxb3-maven-plugin:[unknown-version]: Could not find artifact org.jvnet.hyperjaxb3:hyperjaxb3-maven:pom:0.6.2-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 9, column 10
[WARNING] 'parent.relativePath' of POM org.jvnet.hyperjaxb3:hyperjaxb3-maven-plugin-testing:[unknown-version] (/home/bgedik/work/hjb-master/maven/testing/pom.xml) points at org.jvnet.hyperjaxb3:maven-hyperjaxb3 instead of org.jvnet.hyperjaxb3:hyperjaxb3-maven, please verify your project structure @ line 9, column 10
[FATAL] Non-resolvable parent POM for org.jvnet.hyperjaxb3:hyperjaxb3-maven-plugin-testing:[unknown-version]: Could not find artifact org.jvnet.hyperjaxb3:hyperjaxb3-maven:pom:0.6.2-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 9, column 10

<jaxb:globalBindings> javaType causes @Transient

Firstly thank you for your hard work! :)

I want to map Joda Time classes (LocalDate, LocalDateTime etc.) to DB so I configured globalBindings:

<jaxb:globalBindings>
    <jaxb:javaType name="org.joda.time.LocalDateTime"
        xmlType="xsd:dateTime" parseMethod="org.joda.time.LocalDateTime.parse"
        printMethod="java.lang.String.valueOf" />
    <jaxb:javaType name="org.joda.time.LocalDate" xmlType="xsd:date"
        parseMethod="org.joda.time.LocalDate.parse" printMethod="java.lang.String.valueOf" />
</jaxb:globalBindings>

I've also annotated fields with Hibernate Type annotation like:

        <jaxb:bindings node="//*[@type='xsd:dateTime']"
            multiple="true">
            <annox:annotate target="getter">@org.hibernate.annotations.Type(type
                = "org.joda.time.contrib.hibernate.PersistentLocalDateTime")
            </annox:annotate>
        </jaxb:bindings>

Result is:

    @Transient
    @Type(type = "org.joda.time.contrib.hibernate.PersistentLocalDateTime")
    public LocalDateTime getDate() {
        return date;
    }

As you can see @transient is undesirable here. I've found similar bug for previous Hyperjaxb realeases: http://jira.highsource.org/browse/HJIII-97 but it's still unresolved.

How to remove default "Temporal" for xsd:date type for instance ?

<xs:element name="birthDate" type="xs:date" minOccurs="1" />

I need to map xsd:date to java.lang.String and also use custom Adapter. Fine with
<xjc:javaType name="java.lang.String" xmlType="xs:date"
adapter="soa.commons.utils.XmlDateAdapter" />

But Hyperjaxb still adds
@TeMPOraL(TemporalType.DATE)

How can I override default ?

Request for a new release 0.6.1 or 0.6.1-prerelease

I understand you are busy, but would it be possible with a release on the current state of the code.

Use hyperjaxb3 at work together with cxf, 0.6.1-SNAPSHOT contains support for xjc 2.2.11.

Can't upgrade to cxf 3.x or 3.1.x without 0.6.1-SNAPSHOT since that version of cxf-codegen-plugin uses xjc 2.2.11 and causes conflicts with 0.6.0.

Problem to release with maven with snapshots dependencies, could always change versions myself and deploy to our internal company maven repository. But would like to avoid having "fake" versions.

no default inheritance strategy annotation

Is there a way to not generate the default "@Inheritance(strategy = InheritanceType.JOINED)" annotation?
I mean not another kind of strategy, but the whole annotation.
I've not class hierarchy in my application and TABLE_PER_CLASS, which is the only one that does not generate the discrimination column DTYPE, seems not working with many-to-one relations.

Many thanks.

Enrich generated classes with schema documentation

In a project I work with hyperjaxb3 and documented schema files.

Schema sample:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
    <xs:element name="Lison" type="Lison"/>
    <xs:complexType name="Lison">
        <xs:annotation>
            <xs:documentation>My awesome complex type comment.</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="Truck" type="xs:string" minOccurs="1" maxOccurs="1">
            <xs:annotation>
                    <xs:documentation>My awesome element comment.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

I noticed that only complex type documentation will be considered during the generation process, which is as far as I know related to JAXB.
To solve the issue the idea was to use a binding file including javadoc entries. The binding.xjb could be generated based on the schema in a pre-build step.

Bindings sample:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
    version="2.1"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
    xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"

    jaxb:extensionBindingPrefixes="hj orm">

    <jaxb:bindings schemaLocation="lison.xsd" node="/xs:schema">
        <jaxb:globalBindings generateIsSetMethod="true"/>
        <jaxb:schemaBindings>
            <jaxb:package name="org.xy.luis.generated.lison"/>
        </jaxb:schemaBindings>

        <jaxb:bindings node="xs:complexType[@name='Lison']">
            <jaxb:class>
                <jaxb:javadoc>My awesome complex type comment.</jaxb:javadoc>
            </jaxb:class>
        </jaxb:bindings>

        <jaxb:bindings node="xs:complexType[@name='Lison']/xs:sequence/xs:element[@name='Truck']">
            <jaxb:property>
                <jaxb:javadoc>My awesome element comment.</jaxb:javadoc>
            </jaxb:property>
        </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

Using the aforementioned approach the get methods will be documented but not the set methods. So I wonder if there is a more elegant way to transfer schema documentation during generation. Are there further configuration possibilities related to documentation in hyperjaxb3? Are there any plans to extend hyperjaxb3 in this direction?

encoding problem with maven-jaxb2-plugin

Hi, iam testing those projects from http://confluence.highsource.org/display/HJ3/Downloads to generate some java files from xsd.

I got it working with maven-hyperjaxb3-plugin, generating UTF-8 files like i wanted, but it didnt with maven-jaxb2-plugin and hyperjaxb3-ejb-plugin . I got encoding issues with those plugins. I tried to set tag into pom.xml but didnt work.

  • Basic project template for Hibernate MAVEN (only that generated utf-8 java files)
  • Purchase order initial sample for Hibernate MAVEN (got encoding issue)
  • Purchase order build with maven-jaxb2-plugin MAVEN (got encoding issue)

Any tips about it?

Also, i realize that the source code generated with those projects are differents.
For example:

//Advogado
<xs:element name="advogado" type="nsS:Pessoa"/>

//Pessoa

<xs:complexType name="Pessoa">
        <xs:annotation>
            <xs:appinfo>
                <hj:entity xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations">
                    <orm:sequence-generator name="Generator_PESSOA" sequence-name="SEQ_PESSOA" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"/>
                </hj:entity>
            </xs:appinfo>
        </xs:annotation>
        <xs:sequence>
...

with maven-hyperjaxb3-plugin generates this:

....
@Entity(name = "Advogado")
@Table(name = "ADVOGADO")
@Inheritance(strategy = InheritanceType.JOINED)
public class Advogado
....

with maven-jaxb2-plugin and hyperjaxb3-ejb-plugin generates this:

...
@Entity(name = "Advogado")
@Table(name = "ADVOGADO",schema="selodig")
@Inheritance(strategy = InheritanceType.JOINED)
@SequenceGenerator(name = "Generator_ADVOGADO", sequenceName = "seq_advogado")
public class Advogado
...

so, whats happening?

Thanks

Not compiling under Java 10

I' tried using hyperjaxb at work where java 10 is installed.

When I try to add it to my pom file the following error appears:

[INFO] --- maven-hyperjaxb3-plugin:0.6.1:generate (default) @ my-model ---
[WARNING] The POM for org.glassfish.jaxb:jaxb-runtime:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jaxb:jaxb-xjc:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] Error injecting: org.jvnet.hyperjaxb3.maven2.Hyperjaxb3Mojo
java.lang.NoClassDefFoundError: com/sun/xml/bind/api/ErrorListener

The same error happens when I try to compile the current github master with "mvn compile".

Set a jaxb:javaType to a part of composite keys make the IdClass attribute as String

Hello,

This is a strange behaviors with Hyperjaxb ( tested with 0.5.6 and latest ).

If i specify a javaType (with parse and print method) to an attribute which is a part a composite key, then hyperjaxb create an IdClass (ok, composed with all keys attributes) but with the attribute typed as String ( and not Date as the following example ).

<jaxb:bindings node="xsd:element[@name='timestamp']" multiple="true" required="false" >
    <jaxb:javaType name="java.util.Date"
    parseMethod="com.test.RFC2282DateAdapter.parseDate"
    printMethod="com.test.RFC2282DateAdapter.printDate"/>                  
</jaxb:bindings>

Results :

     @XmlAccessorType(XmlAccessType.FIELD)
    public static class TickerId {

        @XmlSchemaType(name = "dateTime")
        protected String timestamp; // Should be a Date there !!
        protected String currency; // Other part of the composite key, that's ok
        ...
   }

If i remove the binding an XMLGregorianCalendar is generated (i don't want this), moreover a parse exception is throwed. That's normal because the string date format found is not recognized as the standard date format.

Cannot compile on mvn 3.3.9 and JDK 1.8

I tried to compile with:

zangetsu@ares ~/proj/coreso/hyperjaxb3 $ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/share/maven-bin-3.3
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /opt/oracle-jdk-bin-1.8.0.144/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.12.4-gentoo", arch: "amd64", family: "unix"

First error was to plugin not following Maven plugin naming convention, so I renamed the plugin to hyperjaxb3-maven-plugin

Then I tried to compile with result:

INFO] Hyperjaxb3 ......................................... SUCCESS [  0.587 s]
[INFO] Hyperjaxb3 EJB ..................................... SUCCESS [  0.018 s]
[INFO] Hyperjaxb3 EJB Schemas ............................. SUCCESS [  0.021 s]
[INFO] Hyperjaxb3 EJB Schemas Persistence ................. SUCCESS [  4.599 s]
[INFO] Hyperjaxb3 EJB Schemas Customizations .............. SUCCESS [  2.022 s]
[INFO] Hyperjaxb3 EJB Runtime ............................. SUCCESS [  1.260 s]
[INFO] Hyperjaxb3 EJB Roundtrip ........................... SUCCESS [  3.586 s]
[INFO] Hyperjaxb3 EJB Plugin .............................. SUCCESS [  2.505 s]
[INFO] Hyperjaxb3 EJB Extensions .......................... SUCCESS [  0.007 s]
[INFO] Hyperjaxb3 EJB Extensions Naming ................... SUCCESS [  0.011 s]
[INFO] Hyperjaxb3 EJB Extensions Naming [custom-naming-pre_0_6_0] SUCCESS [  0.137 s]
[INFO] Hyperjaxb3 Maven ................................... SUCCESS [  0.021 s]
[INFO] Hyperjaxb3 Maven Plugin ............................ FAILURE [  2.011 s]
[INFO] Hyperjaxb3 Maven Plugin Testing .................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.114 s
[INFO] Finished at: 2017-08-29T10:37:53+02:00
[INFO] Final Memory: 41M/742M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.2:helpmojo (help-goal) on project hyperjaxb3-maven-plugin: Execution help-goal of goal org.apache.maven.plugins:maven-plugin-plugin:3.2:helpmojo failed: 21774 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :hyperjaxb3-maven-plugin

Not much to see, but I just upgraded maven-plugin-plugin to version 3.5 and I can compile now. This is probably related to 1.8 JDK, but cannot confirm....

Support XmlElementWrapper annotation

Need to add support for XmlElementWrapper annotation when handling collections of types without creating an intermediate class to hold the Collection member.

Change of table name generation in version 0.6.0

I switched from version 0.5.6 to 0.6.0.

The maven plugin org.jvnet.hyperjaxb3:maven-hyperjaxb3-plugin:0.5.6 generates table names for a complexType named OperationStateType the table name OPERATIONSTATETYPE.

Plugin org.jvnet.hyperjaxb3:maven-hyperjaxb3-plugin:0.6.0 generates OPERATION_STATE_TYPE.

Could you please give an advice, how to get the old table names with version 0.6.0?

<complexType name="OperationStateType">
    <sequence>
        <element name="operationUUID" type="string" />
        <element name="state" type="string" />
    </sequence>
</complexType>

HJIII-89 and issue #95

Hi,
I am trying to compile GML schemas v3.2.1 and I am facing the following errors:

  • [ERROR] Element collections of any type is not supported. See issue #HJIII-89 (http://jira.highsource.org/browse/HJIII-89)
  • [ERROR] [net.opengis.gml._3.DictionaryTypeDictionaryEntryOrIndirectEntryItem.Item] is a single hetero reference containing element [DictionaryEntry] which is a substitution group head. See issue #95.

Compilations dies with the following error message:

[ERROR] Error while generating code.Location []. org.xml.sax.SAXParseException; Error during plugin execution. java.lang.UnsupportedOperationException: Unexpected type in property [Content] of the class [AbstractMetaDataType].

I've seen on JIRA that these are ld bugs never closed.
Are they still alive? Or There's something I can do?

As always, so many thanks in advance for you support.
Best,
m

Fix Time to Calendar conversion in AbstractXMLGregorianCalendarAdapter

AbstractXMLGregorianCalendarAdapter delegates to concrete implementations for setting varying combinations of fields of Date on an XMLGregorianCalendar.

Two implementations, namely

  • XMLGregorianCalendarAsTime and
  • XMLGregorianCalendarAsDateTime
    also set milliseconds on the target calendar.

This is done with this line of code:
calendar.setMillisecond((int) (date.getTime() % 1000));

The problem here is, that the value resulting from calling date.getTime() may be negative in cases where date is before the beginning of 1970-01-01 (possibly OS dependent).
This will leave the modulo of the negative value also negative and cause an IllegalArgumentException as setMillisecond is called with that value.

A possible fix might look as follows:

int msecs = (int) (date.getTime() % 1000); 
calendar.setMillisecond(msecs >= 0 ? msecs : msecs + 1000);

API incompatibility with jaxb2-basics-annotate 1.1.0

I needed to update to jaxb2-basics-annotate 1.1.0 in order to get support for removing annotations, however compiling my project afterwards will result in the following error

Failed to execute goal org.jvnet.hyperjaxb3:hyperjaxb3-maven-plugin:0.6.2:generate (generate-domain1) on project DREM-TPS-Backend: Execution generate-domain1 of goal org.jvnet.hyperjaxb3:hyperjaxb3-maven-plugin:0.6.2:generate failed: An API incompatibility was encountered while executing org.jvnet.hyperjaxb3:hyperjaxb3-maven-plugin:0.6.2:generate: java.lang.IllegalAccessError: tried to access field org.jvnet.jaxb2_commons.plugin.annotate.AnnotatePlugin.ANNOTATE_PACKAGE_QNAME from class org.jvnet.jaxb2_commons.plugin.AnnotationTarget

The compilation error will not occur, as long as no <annox:removeAnnotation ...> is defined in your bindings configuration. Specifically <annox:removeAnnotation class="javax.persistence.Transient" /> in my case

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.