hyperjaxb2
  1. hyperjaxb2
  2. HYPERJAXB2-6

Schema does not make the roundTripTest becaus Hibernate complains about "Unkown entity java.lang.String"

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      6

      Description

      I am trying to map a rather complex schema and wanted to see whether it can be
      handeled via HyperJaxb so I used the example and just copied the Schema.xsd.
      Mostly it seems to be fine, there is (so far) one problem with one xml Element
      which is mapped as a String and Hibernate complains about it when the save()
      cascades.

      Is that a bug in JAXB ? Or are there some situations where you simply HAVE to
      use coustomizations ?

      Otherwise, HyperJaxB is really cool. Thank you for making it available.

      /Rudi

      1. schema.xsd
        110 kB
        benevolent_dictator
      2. us-patent-grant-sample.xml
        18 kB
        benevolent_dictator
      3. xml.xsd
        0.4 kB
        benevolent_dictator

        Activity

        Hide
        benevolent_dictator added a comment -

        Created an attachment (id=1)
        Original DTD Schema

        Show
        benevolent_dictator added a comment - Created an attachment (id=1) Original DTD Schema
        Hide
        benevolent_dictator added a comment -

        Created an attachment (id=2)
        XSD Version of original DTD (created using Trang)

        Show
        benevolent_dictator added a comment - Created an attachment (id=2) XSD Version of original DTD (created using Trang)
        Hide
        benevolent_dictator added a comment -

        Created an attachment (id=3)
        another file generated by Trang

        Show
        benevolent_dictator added a comment - Created an attachment (id=3) another file generated by Trang
        Hide
        benevolent_dictator added a comment -

        Created an attachment (id=4)
        Sample Data File provided by the US Patents & Trademark Office

        Show
        benevolent_dictator added a comment - Created an attachment (id=4) Sample Data File provided by the US Patents & Trademark Office
        Hide
        benevolent_dictator added a comment -

        I did some homework and realized that the problem comes from JAXB.

        The problematic item is "invention-title" as described below. It uses mixed
        content. From the definition of the XmlMixedContent class, it becomes clear why
        java.lang.String appears in the JAXB DOM Tree and cannot be digested by HIBERNATE.

        <xs:element name="invention-title">
        <xs:complexType mixed="true">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="b"/>
        <xs:element ref="i"/>
        <xs:element ref="o"/>
        <xs:element ref="u"/>
        <xs:element ref="sup"/>
        <xs:element ref="sub"/>
        </xs:choice>
        <xs:attribute name="id" type="xs:ID"/>
        <xs:attribute name="lang"/>
        </xs:complexType>
        </xs:element>

        The XML fragment which causes the problem is the following:

        <invention-title id="d0e53">Ice confection</invention-title>

        That appear pretty trivial but apparently needs some tricks to get around – if
        possible at all.

        The following is from the JAXB documentation
        (http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlMixed.html):

        javax.xml.bind.annotation
        Annotation Type XmlMixed

        @Retention(value=RUNTIME)
        @Target(value=

        {FIELD,METHOD}

        )
        public @interface XmlMixed

        Annotate a JavaBean multi-valued property to support mixed content.

        The usage is subject to the following constraints:

        • can be used with @XmlElementRef, @XmlElementRefs or @XmlAnyElement

        The following can be inserted into @XmlMixed annotated multi-valued property

        • XML text information items are added as values of java.lang.String.
        • Children element information items are added as instances of JAXBElement
          or instances with a class that is annotated with @XmlRootElement.
        • Unknown content that is not be bound to a JAXB mapped class is inserted as
          Element. (Assumes property annotated with @XmlAnyElement)
        Show
        benevolent_dictator added a comment - I did some homework and realized that the problem comes from JAXB. The problematic item is "invention-title" as described below. It uses mixed content. From the definition of the XmlMixedContent class, it becomes clear why java.lang.String appears in the JAXB DOM Tree and cannot be digested by HIBERNATE. <xs:element name="invention-title"> <xs:complexType mixed="true"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="b"/> <xs:element ref="i"/> <xs:element ref="o"/> <xs:element ref="u"/> <xs:element ref="sup"/> <xs:element ref="sub"/> </xs:choice> <xs:attribute name="id" type="xs:ID"/> <xs:attribute name="lang"/> </xs:complexType> </xs:element> The XML fragment which causes the problem is the following: <invention-title id="d0e53">Ice confection</invention-title> That appear pretty trivial but apparently needs some tricks to get around – if possible at all. The following is from the JAXB documentation ( http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlMixed.html): javax.xml.bind.annotation Annotation Type XmlMixed @Retention(value=RUNTIME) @Target(value= {FIELD,METHOD} ) public @interface XmlMixed Annotate a JavaBean multi-valued property to support mixed content. The usage is subject to the following constraints: can be used with @XmlElementRef, @XmlElementRefs or @XmlAnyElement The following can be inserted into @XmlMixed annotated multi-valued property XML text information items are added as values of java.lang.String. Children element information items are added as instances of JAXBElement or instances with a class that is annotated with @XmlRootElement. Unknown content that is not be bound to a JAXB mapped class is inserted as Element. (Assumes property annotated with @XmlAnyElement)

          People

          • Assignee:
            hyperjaxb2-issues
            Reporter:
            benevolent_dictator
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: