xml-doclet icon indicating copy to clipboard operation
xml-doclet copied to clipboard

Support nested annotations

Open G-Ork opened this issue 6 years ago • 2 comments

Problem

Currently the value node for annotations contains a simple string representation of the values. This makes it hard to parse where annotations are nested. It would be nice to handle annotations recursive to be able to extract the desired information more easy.

Example usage of nested annotations

@Entity
@Table(name="VCUST")
@DiscriminatorValue("VCUST")
@PrimaryKeyJoinColumns({
    @PrimaryKeyJoinColumn(name="CUST_ID",referencedColumnName="ID"),
    @PrimaryKeyJoinColumn(name="CUST_TYPE",referencedColumnName="TYPE")
})
public class ValuedCustomer extends Customer { 
    // body
}

Expected Output

In respect to XSD i would not change the value type to mixed content and prefer a more typed way with a new node.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
    <package name="com.github.markusbernhardt.xmldoclet.simpledata">
        <class name="ClassJPA" qualified="com.github.markusbernhardt.xmldoclet.simpledata.ClassJPA" scope="public" abstract="false" error="false" exception="false" externalizable="false" included="true" serializable="false">
            <class qualified="java.lang.Object"/>
            <constructor name="ClassJPA" signature="()" qualified="com.github.markusbernhardt.xmldoclet.simpledata.ClassJPA" scope="public" final="false" included="true" native="false" synchronized="false" static="false" varArgs="false"/>
            <annotation name="Entity" qualified="javax.persistence.Entity"/>
            <annotation name="Table" qualified="javax.persistence.Table">
                <argument name="name" primitive="false" array="false">
                    <type qualified="java.lang.String"/>
                    <value>VCUST</value>
                </argument>
            </annotation>
            <annotation name="DiscriminatorValue" qualified="javax.persistence.DiscriminatorValue">
                <argument name="value" primitive="false" array="false">
                    <type qualified="java.lang.String"/>
                    <value>VCUST</value>
                </argument>
            </annotation>
            <annotation name="PrimaryKeyJoinColumns" qualified="javax.persistence.PrimaryKeyJoinColumns">
                <argument name="value" primitive="false" array="true">
                    <type qualified="javax.persistence.PrimaryKeyJoinColumn" dimension="[]"/>
                    <annotation name="PrimaryKeyJoinColumn" qualified="javax.persistence.PrimaryKeyJoinColumn">
                        <argument name="name" primitive="false" array="false">
                            <type qualified="java.lang.String"/>
                            <value>CUST_ID</value>
                        </argument>
                        <argument name="referencedColumnName" primitive="false" array="false">
                            <type qualified="java.lang.String"/>
                            <value>ID</value>
                        </argument>
                    </annotation>
                    <annotation name="PrimaryKeyJoinColumn" qualified="javax.persistence.PrimaryKeyJoinColumn">
                        <argument name="name" primitive="false" array="false">
                            <type qualified="java.lang.String"/>
                            <value>CUST_TYPE</value>
                        </argument>
                        <argument name="referencedColumnName" primitive="false" array="false">
                            <type qualified="java.lang.String"/>
                            <value>TYPE</value>
                        </argument>
                    </annotation>
                </argument>
            </annotation>
        </class>
    </package>
</root>

G-Ork avatar May 22 '18 21:05 G-Ork

What is the fixed on this? I have a ValuedCustomer and Orders and I want to do a bidirectional relationship in hibernate. How do I do this? Thanks

ancgate avatar Jun 06 '19 22:06 ancgate

Hi, thank you for merging. Would you mind to release the version?

Recently our artifact repo killed the snapshot. Would be nice to have the fix available in central as an release.

Best regards G"

G-Ork avatar Mar 09 '20 10:03 G-Ork