/[volute]/trunk/projects/theory/snapdm/res/jpa.xsl
ViewVC logotype

Diff of /trunk/projects/theory/snapdm/res/jpa.xsl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 689 by bourges.laurent, Mon May 26 16:41:58 2008 UTC revision 690 by bourges.laurent, Thu Jul 10 15:27:40 2008 UTC
# Line 63  Line 63 
63    
64    @NamedQueries( {    @NamedQueries( {
65      @NamedQuery( name = "<xsl:value-of select="$className"/>.findById", query = "SELECT o FROM <xsl:value-of select="$className"/> o WHERE o.id = :id"),      @NamedQuery( name = "<xsl:value-of select="$className"/>.findById", query = "SELECT o FROM <xsl:value-of select="$className"/> o WHERE o.id = :id"),
66      @NamedQuery(name = "<xsl:value-of select="$className"/>.findByXmlId", query = "SELECT o FROM <xsl:value-of select="$className"/> o WHERE o.identity.xmlId = :xmlId"),      @NamedQuery( name = "<xsl:value-of select="$className"/>.findByXmlId", query = "SELECT o FROM <xsl:value-of select="$className"/> o WHERE o.identity.xmlId = :xmlId"),
67      @NamedQuery(name = "<xsl:value-of select="$className"/>.findByIvoId", query = "SELECT o FROM <xsl:value-of select="$className"/> o WHERE o.identity.ivoId = :ivoId")      @NamedQuery( name = "<xsl:value-of select="$className"/>.findByIvoId", query = "SELECT o FROM <xsl:value-of select="$className"/> o WHERE o.identity.ivoId = :ivoId")
68    
69    <xsl:if test="$hasName = 1">    <xsl:if test="$hasName = 1">
70  ,     @NamedQuery( name = "<xsl:value-of select="$className"/>.findByName", query = "SELECT o FROM <xsl:value-of select="$className"/> o WHERE o.name = :name")  ,     @NamedQuery( name = "<xsl:value-of select="$className"/>.findByName", query = "SELECT o FROM <xsl:value-of select="$className"/> o WHERE o.name = :name")
# Line 81  Line 81 
81      <xsl:param name="hasExtends"/>      <xsl:param name="hasExtends"/>
82    
83      <xsl:if test="name() = 'objectType' and $hasExtends = 0 and $hasChild = 1">      <xsl:if test="name() = 'objectType' and $hasExtends = 0 and $hasChild = 1">
84      @Column(name = "<xsl:value-of select="$discriminatorColumnName"/>", insertable = false, updatable = false, nullable = false)      /** classType gives the discriminator value stored in the database for an inheritance hierarchy */
85        @Column( name = "<xsl:value-of select="$discriminatorColumnName"/>", insertable = false, updatable = false, nullable = false )
86      protected String classType;      protected String classType;
87      </xsl:if>      </xsl:if>
88    
89      <xsl:if test="name() = 'objectType' and $hasExtends = 0">      <xsl:if test="name() = 'objectType' and $hasExtends = 0">
90      @Version      /** jpaVersion gives the current version number for that entity (used by pessimistic / optimistic locking in JPA) */
91        @Version()
92      @Column( name = "OPTLOCK" )      @Column( name = "OPTLOCK" )
93      protected Integer jpaVersion;      protected int jpaVersion;
94      </xsl:if>      </xsl:if>
95    
96      <xsl:if test="container">      <xsl:if test="container">
97        <xsl:variable name="type"><xsl:call-template name="JavaType"><xsl:with-param name="xmiid" select="container/@xmiidref"/></xsl:call-template></xsl:variable>        <xsl:variable name="type"><xsl:call-template name="JavaType"><xsl:with-param name="xmiid" select="container/@xmiidref"/></xsl:call-template></xsl:variable>
98        /** container gives the parent entity which owns a collection containing instances of this class */
99      @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH } )      @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH } )
100      @JoinColumn(name = "containerId", referencedColumnName = "id", nullable = false )      @JoinColumn( name = "containerId", referencedColumnName = "id", nullable = false )
101      protected <xsl:value-of select="$type"/> container;      protected <xsl:value-of select="$type"/> container;
102    
103        /** rank : position in the container collection  */
104        @Basic( optional = false )
105        @Column( name = "rank", nullable = false )
106        protected int rank = 0;
107      </xsl:if>      </xsl:if>
108    </xsl:template>    </xsl:template>
109    
# Line 117  Line 125 
125        <xsl:when test="name($type) = 'primitiveType'">        <xsl:when test="name($type) = 'primitiveType'">
126          <xsl:choose>          <xsl:choose>
127            <xsl:when test="number(constraints/maxLength) = -1">            <xsl:when test="number(constraints/maxLength) = -1">
128      @Basic(fetch = FetchType.LAZY, optional = <xsl:apply-templates select="." mode="nullable"/>)      @Basic( fetch = FetchType.LAZY, optional = <xsl:apply-templates select="." mode="nullable"/> )
129      @Lob      @Lob
130      @Column( name = "<xsl:apply-templates select="." mode="columnName"/>", nullable = <xsl:apply-templates select="." mode="nullable"/> )      @Column( name = "<xsl:apply-templates select="." mode="columnName"/>", nullable = <xsl:apply-templates select="." mode="nullable"/> )
131            </xsl:when>            </xsl:when>
# Line 182  Line 190 
190        <xsl:otherwise>        <xsl:otherwise>
191      <!-- do not remove referenced entity : do not cascade delete -->      <!-- do not remove referenced entity : do not cascade delete -->
192      @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH } )      @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH } )
193      @JoinColumn(name = "<xsl:apply-templates select="." mode="columnName"/>", referencedColumnName = "id", nullable = <xsl:apply-templates select="." mode="nullable"/> )      @JoinColumn( name = "<xsl:apply-templates select="." mode="columnName"/>", referencedColumnName = "id", nullable = <xsl:apply-templates select="." mode="nullable"/> )
194        </xsl:otherwise>        </xsl:otherwise>
195      </xsl:choose>      </xsl:choose>
196    </xsl:template>    </xsl:template>
# Line 205  Line 213 
213      [NOT_SUPPORTED_COLLECTION]      [NOT_SUPPORTED_COLLECTION]
214        </xsl:when>        </xsl:when>
215        <xsl:otherwise>        <xsl:otherwise>
216      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy="container")      @OrderBy( value = "rank" )
217        @OneToMany( cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy="container" )
218        </xsl:otherwise>        </xsl:otherwise>
219      </xsl:choose>      </xsl:choose>
220    </xsl:template>    </xsl:template>
# Line 216  Line 225 
225    <xsl:template name="enumPattern">    <xsl:template name="enumPattern">
226      <xsl:param name="columnName"/>      <xsl:param name="columnName"/>
227    
228      @Basic(optional=<xsl:apply-templates select="." mode="nullable"/>)      @Basic( optional=<xsl:apply-templates select="." mode="nullable"/> )
229      @Enumerated(EnumType.STRING)      @Enumerated( EnumType.STRING )
230      @Column( name = "<xsl:apply-templates select="." mode="columnName"/>", nullable = <xsl:apply-templates select="." mode="nullable"/> )      @Column( name = "<xsl:apply-templates select="." mode="columnName"/>", nullable = <xsl:apply-templates select="." mode="nullable"/> )
231    </xsl:template>    </xsl:template>
232    

Legend:
Removed from v.689  
changed lines
  Added in v.690

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26