Hibernate SVN: r19711 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-10 12:21:22 -0400 (Thu, 10 Jun 2010)
New Revision: 19711
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
HHH-5149 Add documentation for to one associations with foreign key
Describe foreign key and association table options.
Describe various configurations like fetch lazy and co.
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-06-10 16:20:43 UTC (rev 19710)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-06-10 16:21:22 UTC (rev 19711)
@@ -2323,7 +2323,7 @@
exhausted your in-memory value group. This is the role of the
pluggable optimizers. Currently only the two enhanced generators
(<xref linkend="mapping-declaration-id-enhanced" /> support this
- operation. </para>
+ operation.</para>
<itemizedlist spacing="compact">
<listitem>
@@ -4182,52 +4182,300 @@
</section>
</section>
- <section id="mapping-declaration-manytoone" revision="5">
- <title>Many-to-one</title>
+ <section>
+ <title>Mapping a to-one association</title>
- <para>An ordinary association to another persistent class is declared
- using a <literal>many-to-one</literal> element. The relational model is
- a many-to-one association; a foreign key in one table is referencing the
- primary key column(s) of the target table.</para>
+ <para>To link one entity to an other, you need to map the association
+ property as a to one association. In the relational model, you can
+ either use a foreign key or an association table, or (a bit less common)
+ share the same primary key value between the two entities.</para>
- <programlistingco role="XML">
- <areaspec>
- <area coords="2" id="manytoone1" />
+ <para>To mark an association, use either
+ <classname>@ManyToOne</classname> or
+ <classname>@OnetoOne</classname>.</para>
- <area coords="3" id="manytoone2" />
+ <section id="mapping-declaration-manytoone" revision="5">
+ <title>Using a foreign key or an association table</title>
- <area coords="4" id="manytoone3" />
+ <para>An ordinary association to another persistent class is declared
+ using a</para>
- <area coords="5" id="manytoone4" />
+ <itemizedlist>
+ <listitem>
+ <para><classname>@ManyToOne</classname> if several entities can
+ point to the the target entity</para>
+ </listitem>
- <area coords="6" id="manytoone5" />
+ <listitem>
+ <para><classname>@OneToOne</classname> if only a single entity can
+ point to the the target entity</para>
+ </listitem>
+ </itemizedlist>
- <areaset coords="" id="manytoone6-7">
- <area coords="7" id="manytoone6" />
+ <para>and a foreign key in one table is referencing the primary key
+ column(s) of the target table.</para>
- <area coords="8" id="manytoone7" />
- </areaset>
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class Flight implements Serializable {
+ @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
+ @JoinColumn(name="COMP_ID")
+ public Company getCompany() {
+ return company;
+ }
+ ...
+} </programlisting>
- <area coords="9" id="manytoone8" />
+ <para>The <literal>@JoinColumn</literal> attribute is optional, the
+ default value(s) is the concatenation of the name of the relationship
+ in the owner side, <keycap>_</keycap> (underscore), and the name of
+ the primary key column in the owned side. In this example
+ <literal>company_id</literal> because the property name is
+ <literal>company</literal> and the column id of Company is
+ <literal>id</literal>.</para>
- <area coords="10" id="manytoone9" />
+ <para><literal>@ManyToOne</literal> has a parameter named
+ <literal>targetEntity</literal> which describes the target entity
+ name. You usually don't need this parameter since the default value
+ (the type of the property that stores the association) is good in
+ almost all cases. However this is useful when you want to use
+ interfaces as the return type instead of the regular entity.</para>
- <area coords="11" id="manytoone10" />
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class Flight implements Serializable {
+ @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE}, targetEntity=CompanyImpl.class )
+ @JoinColumn(name="COMP_ID")
+ public Company getCompany() {
+ return company;
+ }
+ ...
+}
- <area coords="12" id="manytoone11" />
+public interface Company {
+ ...
+}</programlisting>
- <area coords="13" id="manytoone12" />
+ <para>You can also map a to one association through an association
+ table. This association table described by the
+ <literal>@JoinTable</literal> annotation will contains a foreign key
+ referencing back the entity table (through
+ <literal>@JoinTable.joinColumns</literal>) and a a foreign key
+ referencing the target entity table (through
+ <literal>@JoinTable.inverseJoinColumns</literal>).</para>
- <area coords="14" id="manytoone13" />
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class Flight implements Serializable {
+ @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
+ @JoinTable(name="Flight_Company",
+ joinColumns = @JoinColumn(name="FLIGHT_ID"),
+ inverseJoinColumns = @JoinColumn(name="COMP_ID")
+ )
+ public Company getCompany() {
+ return company;
+ }
+ ...
+} </programlisting>
- <area coords="15" id="manytoone14" />
+ <note>
+ <para>You can use a SQL fragment to simulate a physical join column
+ using the <classname>@JoinColumnOrFormula</classname> /
+ <classname>@JoinColumnOrformulas</classname> annotations (just like
+ you can use a SQL fragment to simulate a property column via the
+ <classname>@Formula</classname> annotation).</para>
- <area coords="16" id="manytoone15" />
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class Ticket implements Serializable {
+ @ManyToOne
+ @JoinColumnOrFormula(formula="(firstname + ' ' + lastname)")
+ public Person getOwner() {
+ return person;
+ }
+ ...
+} </programlisting>
+ </note>
- <area coords="17" id="manytoone16" />
- </areaspec>
+ <para>You can mark an association as mandatory by using the
+ <literal>optional=false</literal> attribute. We recommend to use Bean
+ Validation's <classname>@NotNull</classname> annotation as a better
+ alternative however. As a consequence, the foreign key column(s) will
+ be marked as not nullable (if possible).</para>
- <programlisting><many-to-one
+ <para>Setting a value of the <literal>cascade</literal> attribute to
+ any meaningful value other than nothing will propagate certain
+ operations to the associated object. The meaningful values are divided
+ into three categories.</para>
+
+ <orderedlist>
+ <listitem>
+ <para>basic operations, which include: <literal>persist, merge,
+ delete, save-update, evict, replicate, lock and
+ refresh</literal>;</para>
+ </listitem>
+
+ <listitem>
+ <para>special values: <literal>delete-orphan</literal> or
+ <literal>all</literal> ; </para>
+ </listitem>
+
+ <listitem>
+ <para>comma-separated combinations of operation names:
+ <literal>cascade="persist,merge,evict"</literal> or
+ <literal>cascade="all,delete-orphan"</literal>. See <xref
+ linkend="objectstate-transitive" /> for a full explanation. Note
+ that single valued many-to-one associations do not support orphan
+ delete.</para>
+ </listitem>
+ </orderedlist>
+
+ <para>By default, single point associations are eagerly fetched in JPA
+ 2. You can mark it as lazily fetched by using
+ <classname>@ManyToOne(fetch=FetchType.LAZY) </classname>in which case
+ Hibernate will proxy the association and load it when the state of the
+ associated entity is reached. You can force Hibernate not to use a
+ proxy by using <classname>@LazyToOne(NO_PROXY)</classname>. In this
+ case, the property is fetched lazily when the instance variable is
+ first accessed. This requires build-time bytecode instrumentation.
+ lazy="false" specifies that the association will always be eagerly
+ fetched.</para>
+
+ <para>With the default JPA options, single-ended associations are
+ loaded with a subsequent select if set to <literal>LAZY</literal>, or
+ a SQL JOIN is used for <literal>EAGER</literal> associations. You can
+ however adjust the fetching strategy, ie how data is fetched by using
+ <literal>@Fetch</literal>. <literal>FetchMode</literal> can be
+ <literal>SELECT</literal> (a select is triggered when the association
+ needs to be loaded) or <literal>JOIN</literal> (use a SQL JOIN to load
+ the association while loading the owner entity).
+ <literal>JOIN</literal> overrides any lazy attribute (an association
+ loaded through a <literal>JOIN</literal> strategy cannot be
+ lazy).</para>
+
+ <para>When Hibernate cannot resolve the association because the
+ expected associated element is not in database (wrong id on the
+ association column), an exception is raised. This might be
+ inconvenient for legacy and badly maintained schemas. You can ask
+ Hibernate to ignore such elements instead of raising an exception
+ using the <literal>@NotFound</literal> annotation.</para>
+
+ <example>
+ <title>@NotFound annotation</title>
+
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class Child {
+ ...
+ @ManyToOne
+ @NotFound(action=NotFoundAction.IGNORE)
+ public Parent getParent() { ... }
+ ...
+}</programlisting>
+ </example>
+
+ <para>Sometimes you want to delegate to your database the deletion of
+ cascade when a given entity is deleted. In this case Hibernate
+ generates a cascade delete constraint at the database level.</para>
+
+ <example>
+ <title>@OnDelete annotation</title>
+
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class Child {
+ ...
+ @ManyToOne
+ @OnDelete(action=OnDeleteAction.CASCADE)
+ public Parent getParent() { ... }
+ ...
+}</programlisting>
+ </example>
+
+ <para>Foreign key constraints, while generated by Hibernate, have a
+ fairly unreadable name. You can override the constraint name using
+ <literal>@ForeignKey</literal>.</para>
+
+ <example>
+ <title>@ForeignKey annotation</title>
+
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class Child {
+ ...
+ @ManyToOne
+ @ForeignKey(name="FK_PARENT")
+ public Parent getParent() { ... }
+ ...
+}
+
+alter table Child add constraint FK_PARENT foreign key (parent_id) references Parent</programlisting>
+ </example>
+
+ <para>Sometimes, you want to link one entity to an other not by the
+ target entity primary key but by a different unique key. You can
+ achieve that by referencing the unique key column(s) in
+ <methodname>@JoinColumn.referenceColumnName</methodname>.</para>
+
+ <programlisting role="JAVA">@Entity
+class Person {
+ @Id Integer personNumber;
+ String firstName;
+ @Column(name="I")
+ String initial;
+ String lastName;
+}
+
+@Entity
+class Home {
+ @ManyToOne
+ @JoinColumns({
+ @JoinColumn(name="first_name", referencedColumnName="firstName"),
+ @JoinColumn(name="init", referencedColumnName="I"),
+ @JoinColumn(name="last_name", referencedColumnName="lastName"),
+ })
+ Person owner
+}</programlisting>
+
+ <para>This is not encouraged however and should be reserved to legacy
+ mappings.</para>
+
+ <para>In hbm.xml, mapping an association is similar. The main
+ difference is that a <classname>@OneToOne</classname> is mapped as
+ <literal><many-to-one unique="true"/></literal>, let's dive into
+ the subject.</para>
+
+ <programlistingco role="XML">
+ <areaspec>
+ <area coords="2" id="manytoone1" />
+
+ <area coords="3" id="manytoone2" />
+
+ <area coords="4" id="manytoone3" />
+
+ <area coords="5" id="manytoone4" />
+
+ <area coords="6" id="manytoone5" />
+
+ <areaset coords="" id="manytoone6-7">
+ <area coords="7" id="manytoone6" />
+
+ <area coords="8" id="manytoone7" />
+ </areaset>
+
+ <area coords="9" id="manytoone8" />
+
+ <area coords="10" id="manytoone9" />
+
+ <area coords="11" id="manytoone10" />
+
+ <area coords="12" id="manytoone11" />
+
+ <area coords="13" id="manytoone12" />
+
+ <area coords="14" id="manytoone13" />
+
+ <area coords="15" id="manytoone14" />
+
+ <area coords="16" id="manytoone15" />
+
+ <area coords="17" id="manytoone16" />
+ </areaspec>
+
+ <programlisting><many-to-one
name="propertyName"
column="column_name"
class="ClassName"
@@ -4251,186 +4499,187 @@
foreign-key="foreign_key_name"
/></programlisting>
- <calloutlist>
- <callout arearefs="manytoone1">
- <para><literal>name</literal>: the name of the property.</para>
- </callout>
+ <calloutlist>
+ <callout arearefs="manytoone1">
+ <para><literal>name</literal>: the name of the property.</para>
+ </callout>
- <callout arearefs="manytoone2">
- <para><literal>column</literal> (optional): the name of the
- foreign key column. This can also be specified by nested
- <literal><column></literal> element(s).</para>
- </callout>
+ <callout arearefs="manytoone2">
+ <para><literal>column</literal> (optional): the name of the
+ foreign key column. This can also be specified by nested
+ <literal><column></literal> element(s).</para>
+ </callout>
- <callout arearefs="manytoone3">
- <para><literal>class</literal> (optional - defaults to the
- property type determined by reflection): the name of the
- associated class.</para>
- </callout>
+ <callout arearefs="manytoone3">
+ <para><literal>class</literal> (optional - defaults to the
+ property type determined by reflection): the name of the
+ associated class.</para>
+ </callout>
- <callout arearefs="manytoone4">
- <para><literal>cascade</literal> (optional): specifies which
- operations should be cascaded from the parent object to the
- associated object.</para>
- </callout>
+ <callout arearefs="manytoone4">
+ <para><literal>cascade</literal> (optional): specifies which
+ operations should be cascaded from the parent object to the
+ associated object.</para>
+ </callout>
- <callout arearefs="manytoone5">
- <para><literal>fetch</literal> (optional - defaults to
- <literal>select</literal>): chooses between outer-join fetching or
- sequential select fetching.</para>
- </callout>
+ <callout arearefs="manytoone5">
+ <para><literal>fetch</literal> (optional - defaults to
+ <literal>select</literal>): chooses between outer-join fetching
+ or sequential select fetching.</para>
+ </callout>
- <callout arearefs="manytoone6-7">
- <para><literal>update, insert</literal> (optional - defaults to
- <literal>true</literal>): specifies that the mapped columns should
- be included in SQL <literal>UPDATE</literal> and/or
- <literal>INSERT</literal> statements. Setting both to
- <literal>false</literal> allows a pure "derived" association whose
- value is initialized from another property that maps to the same
- column(s), or by a trigger or other application.</para>
- </callout>
+ <callout arearefs="manytoone6-7">
+ <para><literal>update, insert</literal> (optional - defaults to
+ <literal>true</literal>): specifies that the mapped columns
+ should be included in SQL <literal>UPDATE</literal> and/or
+ <literal>INSERT</literal> statements. Setting both to
+ <literal>false</literal> allows a pure "derived" association
+ whose value is initialized from another property that maps to
+ the same column(s), or by a trigger or other application.</para>
+ </callout>
- <callout arearefs="manytoone8">
- <para><literal>property-ref</literal> (optional): the name of a
- property of the associated class that is joined to this foreign
- key. If not specified, the primary key of the associated class is
- used.</para>
- </callout>
+ <callout arearefs="manytoone8">
+ <para><literal>property-ref</literal> (optional): the name of a
+ property of the associated class that is joined to this foreign
+ key. If not specified, the primary key of the associated class
+ is used.</para>
+ </callout>
- <callout arearefs="manytoone9">
- <para><literal>access</literal> (optional - defaults to
- <literal>property</literal>): the strategy Hibernate uses for
- accessing the property value.</para>
- </callout>
+ <callout arearefs="manytoone9">
+ <para><literal>access</literal> (optional - defaults to
+ <literal>property</literal>): the strategy Hibernate uses for
+ accessing the property value.</para>
+ </callout>
- <callout arearefs="manytoone10">
- <para><literal>unique</literal> (optional): enables the DDL
- generation of a unique constraint for the foreign-key column. By
- allowing this to be the target of a
- <literal>property-ref</literal>, you can make the association
- multiplicity one-to-one.</para>
- </callout>
+ <callout arearefs="manytoone10">
+ <para><literal>unique</literal> (optional): enables the DDL
+ generation of a unique constraint for the foreign-key column. By
+ allowing this to be the target of a
+ <literal>property-ref</literal>, you can make the association
+ multiplicity one-to-one.</para>
+ </callout>
- <callout arearefs="manytoone11">
- <para><literal>not-null</literal> (optional): enables the DDL
- generation of a nullability constraint for the foreign key
- columns.</para>
- </callout>
+ <callout arearefs="manytoone11">
+ <para><literal>not-null</literal> (optional): enables the DDL
+ generation of a nullability constraint for the foreign key
+ columns.</para>
+ </callout>
- <callout arearefs="manytoone12">
- <para><literal>optimistic-lock</literal> (optional - defaults to
- <literal>true</literal>): specifies that updates to this property
- do or do not require acquisition of the optimistic lock. In other
- words, it determines if a version increment should occur when this
- property is dirty.</para>
- </callout>
+ <callout arearefs="manytoone12">
+ <para><literal>optimistic-lock</literal> (optional - defaults to
+ <literal>true</literal>): specifies that updates to this
+ property do or do not require acquisition of the optimistic
+ lock. In other words, it determines if a version increment
+ should occur when this property is dirty.</para>
+ </callout>
- <callout arearefs="manytoone13">
- <para><literal>lazy</literal> (optional - defaults to
- <literal>proxy</literal>): by default, single point associations
- are proxied. <literal>lazy="no-proxy"</literal> specifies that the
- property should be fetched lazily when the instance variable is
- first accessed. This requires build-time bytecode instrumentation.
- <literal>lazy="false"</literal> specifies that the association
- will always be eagerly fetched.</para>
- </callout>
+ <callout arearefs="manytoone13">
+ <para><literal>lazy</literal> (optional - defaults to
+ <literal>proxy</literal>): by default, single point associations
+ are proxied. <literal>lazy="no-proxy"</literal> specifies that
+ the property should be fetched lazily when the instance variable
+ is first accessed. This requires build-time bytecode
+ instrumentation. <literal>lazy="false"</literal> specifies that
+ the association will always be eagerly fetched.</para>
+ </callout>
- <callout arearefs="manytoone14">
- <para><literal>not-found</literal> (optional - defaults to
- <literal>exception</literal>): specifies how foreign keys that
- reference missing rows will be handled. <literal>ignore</literal>
- will treat a missing row as a null association.</para>
- </callout>
+ <callout arearefs="manytoone14">
+ <para><literal>not-found</literal> (optional - defaults to
+ <literal>exception</literal>): specifies how foreign keys that
+ reference missing rows will be handled.
+ <literal>ignore</literal> will treat a missing row as a null
+ association.</para>
+ </callout>
- <callout arearefs="manytoone15">
- <para><literal>entity-name</literal> (optional): the entity name
- of the associated class.</para>
- </callout>
+ <callout arearefs="manytoone15">
+ <para><literal>entity-name</literal> (optional): the entity name
+ of the associated class.</para>
+ </callout>
- <callout arearefs="manytoone16">
- <para><literal>formula</literal> (optional): an SQL expression
- that defines the value for a <emphasis>computed</emphasis> foreign
- key.</para>
- </callout>
- </calloutlist>
- </programlistingco>
+ <callout arearefs="manytoone16">
+ <para><literal>formula</literal> (optional): an SQL expression
+ that defines the value for a <emphasis>computed</emphasis>
+ foreign key.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
- <para>Setting a value of the <literal>cascade</literal> attribute to any
- meaningful value other than <literal>none</literal> will propagate
- certain operations to the associated object. The meaningful values are
- divided into three categories. First, basic operations, which include:
- <literal>persist, merge, delete, save-update, evict, replicate, lock and
- refresh</literal>; second, special values:
- <literal>delete-orphan</literal>; and third,<literal>all</literal>
- comma-separated combinations of operation names:
- <literal>cascade="persist,merge,evict"</literal> or
- <literal>cascade="all,delete-orphan"</literal>. See <xref
- linkend="objectstate-transitive" /> for a full explanation. Note that
- single valued, many-to-one and one-to-one, associations do not support
- orphan delete.</para>
+ <para>Setting a value of the <literal>cascade</literal> attribute to
+ any meaningful value other than <literal>none</literal> will propagate
+ certain operations to the associated object. The meaningful values are
+ divided into three categories. First, basic operations, which include:
+ <literal>persist, merge, delete, save-update, evict, replicate, lock
+ and refresh</literal>; second, special values:
+ <literal>delete-orphan</literal>; and third,<literal>all</literal>
+ comma-separated combinations of operation names:
+ <literal>cascade="persist,merge,evict"</literal> or
+ <literal>cascade="all,delete-orphan"</literal>. See <xref
+ linkend="objectstate-transitive" /> for a full explanation. Note that
+ single valued, many-to-one and one-to-one, associations do not support
+ orphan delete.</para>
- <para>Here is an example of a typical <literal>many-to-one</literal>
- declaration:</para>
+ <para>Here is an example of a typical <literal>many-to-one</literal>
+ declaration:</para>
- <programlisting role="XML"><many-to-one name="product" class="Product" column="PRODUCT_ID"/></programlisting>
+ <programlisting role="XML"><many-to-one name="product" class="Product" column="PRODUCT_ID"/></programlisting>
- <para>The <literal>property-ref</literal> attribute should only be used
- for mapping legacy data where a foreign key refers to a unique key of
- the associated table other than the primary key. This is a complicated
- and confusing relational model. For example, if the
- <literal>Product</literal> class had a unique serial number that is not
- the primary key. The <literal>unique</literal> attribute controls
- Hibernate's DDL generation with the SchemaExport tool.</para>
+ <para>The <literal>property-ref</literal> attribute should only be
+ used for mapping legacy data where a foreign key refers to a unique
+ key of the associated table other than the primary key. This is a
+ complicated and confusing relational model. For example, if the
+ <literal>Product</literal> class had a unique serial number that is
+ not the primary key. The <literal>unique</literal> attribute controls
+ Hibernate's DDL generation with the SchemaExport tool.</para>
- <programlisting role="XML"><property name="serialNumber" unique="true" type="string" column="SERIAL_NUMBER"/></programlisting>
+ <programlisting role="XML"><property name="serialNumber" unique="true" type="string" column="SERIAL_NUMBER"/></programlisting>
- <para>Then the mapping for <literal>OrderItem</literal> might
- use:</para>
+ <para>Then the mapping for <literal>OrderItem</literal> might
+ use:</para>
- <programlisting role="XML"><many-to-one name="product" property-ref="serialNumber" column="PRODUCT_SERIAL_NUMBER"/></programlisting>
+ <programlisting role="XML"><many-to-one name="product" property-ref="serialNumber" column="PRODUCT_SERIAL_NUMBER"/></programlisting>
- <para>This is not encouraged, however.</para>
+ <para>This is not encouraged, however.</para>
- <para>If the referenced unique key comprises multiple properties of the
- associated entity, you should map the referenced properties inside a
- named <literal><properties></literal> element.</para>
+ <para>If the referenced unique key comprises multiple properties of
+ the associated entity, you should map the referenced properties inside
+ a named <literal><properties></literal> element.</para>
- <para>If the referenced unique key is the property of a component, you
- can specify a property path:</para>
+ <para>If the referenced unique key is the property of a component, you
+ can specify a property path:</para>
- <programlisting role="XML"><many-to-one name="owner" property-ref="identity.ssn" column="OWNER_SSN"/></programlisting>
- </section>
+ <programlisting role="XML"><many-to-one name="owner" property-ref="identity.ssn" column="OWNER_SSN"/></programlisting>
+ </section>
- <section id="mapping-declaration-onetoone" revision="3">
- <title>One-to-one</title>
+ <section id="mapping-declaration-onetoone" revision="3">
+ <title>One-to-one</title>
- <para>A one-to-one association to another persistent class is declared
- using a <literal>one-to-one</literal> element.</para>
+ <para>A one-to-one association to another persistent class is declared
+ using a <literal>one-to-one</literal> element.</para>
- <programlistingco role="XML">
- <areaspec>
- <area coords="2" id="onetoone1" />
+ <programlistingco role="XML">
+ <areaspec>
+ <area coords="2" id="onetoone1" />
- <area coords="3" id="onetoone2" />
+ <area coords="3" id="onetoone2" />
- <area coords="4" id="onetoone3" />
+ <area coords="4" id="onetoone3" />
- <area coords="5" id="onetoone4" />
+ <area coords="5" id="onetoone4" />
- <area coords="6" id="onetoone5" />
+ <area coords="6" id="onetoone5" />
- <area coords="7" id="onetoone6" />
+ <area coords="7" id="onetoone6" />
- <area coords="8" id="onetoone7" />
+ <area coords="8" id="onetoone7" />
- <area coords="9" id="onetoone8" />
+ <area coords="9" id="onetoone8" />
- <area coords="10" id="onetoone9" />
+ <area coords="10" id="onetoone9" />
- <area coords="11" id="onetoone10" />
- </areaspec>
+ <area coords="11" id="onetoone10" />
+ </areaspec>
- <programlisting><one-to-one
+ <programlisting><one-to-one
name="propertyName"
class="ClassName"
cascade="cascade_style"
@@ -4446,111 +4695,112 @@
foreign-key="foreign_key_name"
/></programlisting>
- <calloutlist>
- <callout arearefs="onetoone1">
- <para><literal>name</literal>: the name of the property.</para>
- </callout>
+ <calloutlist>
+ <callout arearefs="onetoone1">
+ <para><literal>name</literal>: the name of the property.</para>
+ </callout>
- <callout arearefs="onetoone2">
- <para><literal>class</literal> (optional - defaults to the
- property type determined by reflection): the name of the
- associated class.</para>
- </callout>
+ <callout arearefs="onetoone2">
+ <para><literal>class</literal> (optional - defaults to the
+ property type determined by reflection): the name of the
+ associated class.</para>
+ </callout>
- <callout arearefs="onetoone3">
- <para><literal>cascade</literal> (optional): specifies which
- operations should be cascaded from the parent object to the
- associated object.</para>
- </callout>
+ <callout arearefs="onetoone3">
+ <para><literal>cascade</literal> (optional): specifies which
+ operations should be cascaded from the parent object to the
+ associated object.</para>
+ </callout>
- <callout arearefs="onetoone4">
- <para><literal>constrained</literal> (optional): specifies that a
- foreign key constraint on the primary key of the mapped table and
- references the table of the associated class. This option affects
- the order in which <literal>save()</literal> and
- <literal>delete()</literal> are cascaded, and determines whether
- the association can be proxied. It is also used by the schema
- export tool.</para>
- </callout>
+ <callout arearefs="onetoone4">
+ <para><literal>constrained</literal> (optional): specifies that
+ a foreign key constraint on the primary key of the mapped table
+ and references the table of the associated class. This option
+ affects the order in which <literal>save()</literal> and
+ <literal>delete()</literal> are cascaded, and determines whether
+ the association can be proxied. It is also used by the schema
+ export tool.</para>
+ </callout>
- <callout arearefs="onetoone5">
- <para><literal>fetch</literal> (optional - defaults to
- <literal>select</literal>): chooses between outer-join fetching or
- sequential select fetching.</para>
- </callout>
+ <callout arearefs="onetoone5">
+ <para><literal>fetch</literal> (optional - defaults to
+ <literal>select</literal>): chooses between outer-join fetching
+ or sequential select fetching.</para>
+ </callout>
- <callout arearefs="onetoone6">
- <para><literal>property-ref</literal> (optional): the name of a
- property of the associated class that is joined to the primary key
- of this class. If not specified, the primary key of the associated
- class is used.</para>
- </callout>
+ <callout arearefs="onetoone6">
+ <para><literal>property-ref</literal> (optional): the name of a
+ property of the associated class that is joined to the primary
+ key of this class. If not specified, the primary key of the
+ associated class is used.</para>
+ </callout>
- <callout arearefs="onetoone7">
- <para><literal>access</literal> (optional - defaults to
- <literal>property</literal>): the strategy Hibernate uses for
- accessing the property value.</para>
- </callout>
+ <callout arearefs="onetoone7">
+ <para><literal>access</literal> (optional - defaults to
+ <literal>property</literal>): the strategy Hibernate uses for
+ accessing the property value.</para>
+ </callout>
- <callout arearefs="onetoone8">
- <para><literal>formula</literal> (optional): almost all one-to-one
- associations map to the primary key of the owning entity. If this
- is not the case, you can specify another column, columns or
- expression to join on using an SQL formula. See
- <literal>org.hibernate.test.onetooneformula</literal> for an
- example.</para>
- </callout>
+ <callout arearefs="onetoone8">
+ <para><literal>formula</literal> (optional): almost all
+ one-to-one associations map to the primary key of the owning
+ entity. If this is not the case, you can specify another column,
+ columns or expression to join on using an SQL formula. See
+ <literal>org.hibernate.test.onetooneformula</literal> for an
+ example.</para>
+ </callout>
- <callout arearefs="onetoone9">
- <para><literal>lazy</literal> (optional - defaults to
- <literal>proxy</literal>): by default, single point associations
- are proxied. <literal>lazy="no-proxy"</literal> specifies that the
- property should be fetched lazily when the instance variable is
- first accessed. It requires build-time bytecode instrumentation.
- <literal>lazy="false"</literal> specifies that the association
- will always be eagerly fetched. <emphasis>Note that if
- <literal>constrained="false"</literal>, proxying is impossible and
- Hibernate will eagerly fetch the association</emphasis>.</para>
- </callout>
+ <callout arearefs="onetoone9">
+ <para><literal>lazy</literal> (optional - defaults to
+ <literal>proxy</literal>): by default, single point associations
+ are proxied. <literal>lazy="no-proxy"</literal> specifies that
+ the property should be fetched lazily when the instance variable
+ is first accessed. It requires build-time bytecode
+ instrumentation. <literal>lazy="false"</literal> specifies that
+ the association will always be eagerly fetched. <emphasis>Note
+ that if <literal>constrained="false"</literal>, proxying is
+ impossible and Hibernate will eagerly fetch the
+ association</emphasis>.</para>
+ </callout>
- <callout arearefs="onetoone10">
- <para><literal>entity-name</literal> (optional): the entity name
- of the associated class.</para>
- </callout>
- </calloutlist>
- </programlistingco>
+ <callout arearefs="onetoone10">
+ <para><literal>entity-name</literal> (optional): the entity name
+ of the associated class.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
- <para>There are two varieties of one-to-one associations:</para>
+ <para>There are two varieties of one-to-one associations:</para>
- <itemizedlist>
- <listitem>
- <para>primary key associations</para>
- </listitem>
+ <itemizedlist>
+ <listitem>
+ <para>primary key associations</para>
+ </listitem>
- <listitem>
- <para>unique foreign key associations</para>
- </listitem>
- </itemizedlist>
+ <listitem>
+ <para>unique foreign key associations</para>
+ </listitem>
+ </itemizedlist>
- <para>Primary key associations do not need an extra table column. If two
- rows are related by the association, then the two table rows share the
- same primary key value. To relate two objects by a primary key
- association, ensure that they are assigned the same identifier
- value.</para>
+ <para>Primary key associations do not need an extra table column. If
+ two rows are related by the association, then the two table rows share
+ the same primary key value. To relate two objects by a primary key
+ association, ensure that they are assigned the same identifier
+ value.</para>
- <para>For a primary key association, add the following mappings to
- <literal>Employee</literal> and <literal>Person</literal>
- respectively:</para>
+ <para>For a primary key association, add the following mappings to
+ <literal>Employee</literal> and <literal>Person</literal>
+ respectively:</para>
- <programlisting role="XML"><one-to-one name="person" class="Person"/></programlisting>
+ <programlisting role="XML"><one-to-one name="person" class="Person"/></programlisting>
- <programlisting role="XML"><one-to-one name="employee" class="Employee" constrained="true"/></programlisting>
+ <programlisting role="XML"><one-to-one name="employee" class="Employee" constrained="true"/></programlisting>
- <para>Ensure that the primary keys of the related rows in the PERSON and
- EMPLOYEE tables are equal. You use a special Hibernate identifier
- generation strategy called <literal>foreign</literal>:</para>
+ <para>Ensure that the primary keys of the related rows in the PERSON
+ and EMPLOYEE tables are equal. You use a special Hibernate identifier
+ generation strategy called <literal>foreign</literal>:</para>
- <programlisting role="XML"><class name="person" table="PERSON">
+ <programlisting role="XML"><class name="person" table="PERSON">
<id name="id" column="PERSON_ID">
<generator class="foreign">
<param name="property">employee</param>
@@ -4562,21 +4812,22 @@
constrained="true"/>
</class></programlisting>
- <para>A newly saved instance of <literal>Person</literal> is assigned
- the same primary key value as the <literal>Employee</literal> instance
- referred with the <literal>employee</literal> property of that
- <literal>Person</literal>.</para>
+ <para>A newly saved instance of <literal>Person</literal> is assigned
+ the same primary key value as the <literal>Employee</literal> instance
+ referred with the <literal>employee</literal> property of that
+ <literal>Person</literal>.</para>
- <para>Alternatively, a foreign key with a unique constraint, from
- <literal>Employee</literal> to <literal>Person</literal>, can be
- expressed as:</para>
+ <para>Alternatively, a foreign key with a unique constraint, from
+ <literal>Employee</literal> to <literal>Person</literal>, can be
+ expressed as:</para>
- <programlisting role="XML"><many-to-one name="person" class="Person" column="PERSON_ID" unique="true"/></programlisting>
+ <programlisting role="XML"><many-to-one name="person" class="Person" column="PERSON_ID" unique="true"/></programlisting>
- <para>This association can be made bidirectional by adding the following
- to the <literal>Person</literal> mapping:</para>
+ <para>This association can be made bidirectional by adding the
+ following to the <literal>Person</literal> mapping:</para>
- <programlisting role="XML"><one-to-one name="employee" class="Employee" property-ref="person"/></programlisting>
+ <programlisting role="XML"><one-to-one name="employee" class="Employee" property-ref="person"/></programlisting>
+ </section>
</section>
<section id="mapping-declaration-naturalid">
13 years, 11 months
Hibernate SVN: r19710 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-10 12:20:43 -0400 (Thu, 10 Jun 2010)
New Revision: 19710
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
HHH-5149 fix text not wrapping up in html rendering
Was due to a itemizedlist embedded in a para
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-06-10 16:13:06 UTC (rev 19709)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-06-10 16:20:43 UTC (rev 19710)
@@ -2308,8 +2308,8 @@
<listitem>
<para><literal>optimizer</literal> (optional - defaults to
- <literal></literal>): See <xref
- linkend="mapping-declaration-id-enhanced-optimizers" /></para>
+ <literal>??</literal>): See <xref
+ linkend="mapping-declaration-id-enhanced-optimizers" />.</para>
</listitem>
</itemizedlist></para>
@@ -2323,35 +2323,37 @@
exhausted your in-memory value group. This is the role of the
pluggable optimizers. Currently only the two enhanced generators
(<xref linkend="mapping-declaration-id-enhanced" /> support this
- operation. <itemizedlist spacing="compact">
- <listitem>
- <para><literal>none</literal> (generally this is the default
- if no optimizer was specified): this will not perform any
- optimizations and hit the database for each and every
- request.</para>
- </listitem>
+ operation. </para>
- <listitem>
- <para><literal>hilo</literal>: applies a hi/lo algorithm
- around the database retrieved values. The values from the
- database for this optimizer are expected to be sequential. The
- values retrieved from the database structure for this
- optimizer indicates the "group number". The
- <literal>increment_size</literal> is multiplied by that value
- in memory to define a group "hi value".</para>
- </listitem>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para><literal>none</literal> (generally this is the default if
+ no optimizer was specified): this will not perform any
+ optimizations and hit the database for each and every
+ request.</para>
+ </listitem>
- <listitem>
- <para><literal>pooled</literal>: as with the case of
- <literal>hilo</literal>, this optimizer attempts to minimize
- the number of hits to the database. Here, however, we simply
- store the starting value for the "next group" into the
- database structure rather than a sequential value in
- combination with an in-memory grouping algorithm. Here,
- <literal>increment_size</literal> refers to the values coming
- from the database.</para>
- </listitem>
- </itemizedlist></para>
+ <listitem>
+ <para><literal>hilo</literal>: applies a hi/lo algorithm around
+ the database retrieved values. The values from the database for
+ this optimizer are expected to be sequential. The values
+ retrieved from the database structure for this optimizer
+ indicates the "group number". The
+ <literal>increment_size</literal> is multiplied by that value in
+ memory to define a group "hi value".</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>pooled</literal>: as with the case of
+ <literal>hilo</literal>, this optimizer attempts to minimize the
+ number of hits to the database. Here, however, we simply store
+ the starting value for the "next group" into the database
+ structure rather than a sequential value in combination with an
+ in-memory grouping algorithm. Here,
+ <literal>increment_size</literal> refers to the values coming
+ from the database.</para>
+ </listitem>
+ </itemizedlist>
</section>
</section>
13 years, 11 months
Hibernate SVN: r19709 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-10 12:13:06 -0400 (Thu, 10 Jun 2010)
New Revision: 19709
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
HHH-5148 add JAVA role to a programlisting
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-06-10 16:12:27 UTC (rev 19708)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-06-10 16:13:06 UTC (rev 19709)
@@ -4945,7 +4945,7 @@
not necessary as the binding between a column and its related column
on the associated table is done directly</para>
- <programlisting>@Entity
+ <programlisting role="JAVA">@Entity
class Person {
@Id Integer personNumber;
String firstName;
13 years, 11 months
Hibernate SVN: r19708 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-10 12:12:27 -0400 (Thu, 10 Jun 2010)
New Revision: 19708
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
HHH-5149 remove typo
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-06-10 07:18:57 UTC (rev 19707)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-06-10 16:12:27 UTC (rev 19708)
@@ -3522,8 +3522,6 @@
annotation as shown in the <literal>note</literal> property
example.</para>
- <para></para>
-
<para>In plain Java APIs, the temporal precision of time is not
defined. When dealing with temporal data you might want to describe
the expected precision in database. Temporal data can have
13 years, 11 months
Hibernate SVN: r19707 - in annotations/branches/v3_4_0_GA_CP/src: test/java/org/hibernate/test/annotations/any and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-06-10 03:18:57 -0400 (Thu, 10 Jun 2010)
New Revision: 19707
Modified:
annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/ByteArrayBlobType.java
annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/SerializableToBlobType.java
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/any/package-info.java
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/join/SysGroupsOrm.java
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/join/SysUserOrm.java
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/lob/LobTest.java
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/onetomany/OneToManyTest.java
Log:
cleanup unused imports
Modified: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/ByteArrayBlobType.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/ByteArrayBlobType.java 2010-06-10 07:16:30 UTC (rev 19706)
+++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/ByteArrayBlobType.java 2010-06-10 07:18:57 UTC (rev 19707)
@@ -11,8 +11,8 @@
import org.dom4j.Node;
import org.hibernate.EntityMode;
+import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
-import org.hibernate.Hibernate;
import org.hibernate.engine.Mapping;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
Modified: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/SerializableToBlobType.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/SerializableToBlobType.java 2010-06-10 07:16:30 UTC (rev 19706)
+++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/SerializableToBlobType.java 2010-06-10 07:18:57 UTC (rev 19707)
@@ -13,9 +13,9 @@
import org.dom4j.Node;
import org.hibernate.EntityMode;
+import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
-import org.hibernate.Hibernate;
import org.hibernate.engine.Mapping;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
Modified: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/any/package-info.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/any/package-info.java 2010-06-10 07:16:30 UTC (rev 19706)
+++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/any/package-info.java 2010-06-10 07:18:57 UTC (rev 19707)
@@ -14,3 +14,4 @@
import org.hibernate.annotations.AnyMetaDef;
import org.hibernate.annotations.AnyMetaDefs;
import org.hibernate.annotations.MetaValue;
+
Modified: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/join/SysGroupsOrm.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/join/SysGroupsOrm.java 2010-06-10 07:16:30 UTC (rev 19706)
+++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/join/SysGroupsOrm.java 2010-06-10 07:18:57 UTC (rev 19707)
@@ -3,7 +3,6 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
Modified: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/join/SysUserOrm.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/join/SysUserOrm.java 2010-06-10 07:16:30 UTC (rev 19706)
+++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/join/SysUserOrm.java 2010-06-10 07:18:57 UTC (rev 19707)
@@ -6,7 +6,6 @@
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
Modified: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/lob/LobTest.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/lob/LobTest.java 2010-06-10 07:16:30 UTC (rev 19706)
+++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/lob/LobTest.java 2010-06-10 07:18:57 UTC (rev 19707)
@@ -4,8 +4,6 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.junit.SkipForDialect;
import org.hibernate.test.annotations.TestCase;
/**
Modified: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/onetomany/OneToManyTest.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/onetomany/OneToManyTest.java 2010-06-10 07:16:30 UTC (rev 19706)
+++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/onetomany/OneToManyTest.java 2010-06-10 07:18:57 UTC (rev 19707)
@@ -13,7 +13,6 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.HSQLDialect;
-import org.hibernate.junit.FailureExpected;
import org.hibernate.junit.RequiresDialect;
import org.hibernate.test.annotations.Customer;
import org.hibernate.test.annotations.Discount;
13 years, 11 months
Hibernate SVN: r19706 - core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-06-10 03:16:30 -0400 (Thu, 10 Jun 2010)
New Revision: 19706
Modified:
core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util/SerializationHelper.java
Log:
correct javadoc typo
Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util/SerializationHelper.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util/SerializationHelper.java 2010-06-10 05:06:54 UTC (rev 19705)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util/SerializationHelper.java 2010-06-10 07:16:30 UTC (rev 19706)
@@ -51,7 +51,7 @@
* </ul>
*
* <p>This class throws exceptions for invalid <code>null</code> inputs.
- * Each method documents its behaviour in more detail.</p>
+ * Each method documents its behavior in more detail.</p>
*
* @author <a href="mailto:nissim@nksystems.com">Nissim Karpenstein</a>
* @author <a href="mailto:janekdb@yahoo.co.uk">Janek Bogucki</a>
13 years, 11 months
Hibernate SVN: r19705 - in core/branches/gradle2: buildSrc and 8 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-06-10 01:06:54 -0400 (Thu, 10 Jun 2010)
New Revision: 19705
Added:
core/branches/gradle2/buildSrc/
core/branches/gradle2/buildSrc/build.gradle
core/branches/gradle2/buildSrc/src/
core/branches/gradle2/buildSrc/src/main/
core/branches/gradle2/buildSrc/src/main/groovy/
core/branches/gradle2/buildSrc/src/main/groovy/org/
core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/
core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/gradle/
core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/gradle/javadoc/
core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/gradle/javadoc/Aggregator.groovy
core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/gradle/javadoc/Javadoc.groovy
Modified:
core/branches/gradle2/build.gradle
core/branches/gradle2/hibernate-release/hibernate-release.gradle
Log:
mostly fleshed out release tasks
Modified: core/branches/gradle2/build.gradle
===================================================================
--- core/branches/gradle2/build.gradle 2010-06-09 13:36:38 UTC (rev 19704)
+++ core/branches/gradle2/build.gradle 2010-06-10 05:06:54 UTC (rev 19705)
@@ -15,13 +15,12 @@
javaVersion = "1.5"
}
-subprojects {
- apply plugin: 'java'
-
+subprojects { subProject ->
group = 'org.hibernate.gradlePoC'
version = '1.0.0-SNAPSHOT'
- defaultTasks 'classes'
+ // minimize changes, at least for now (gradle uses 'build' by default)..
+ buildDirName = "target"
repositories {
mavenCentral()
@@ -30,79 +29,84 @@
mavenRepo urls: "file://" + System.getProperty('user.home') + "/.m2/repository/"
}
- configurations {
- provided {
- // todo : need to make sure these are non-exported
- description = 'Non-exported compile-time dependencies.'
- }
+ if ( 'hibernate-release' == subProject.name ) {
+ apply plugin : 'base'
}
+ else {
+ apply plugin: 'java'
+ defaultTasks 'classes'
- ideaModule {
- downloadJavadoc = false
- scopes.COMPILE.plus.add(configurations.provided)
- }
+ configurations {
+ provided {
+ // todo : need to make sure these are non-exported
+ description = 'Non-exported compile-time dependencies.'
+ }
+ }
- dependencies {
- slf4jVersion = '1.5.8'
- dom4jVersion = '1.6.1'
- antlrVersion = '2.7.7'
- annotationsCommonsVersion = '3.2.0.Final'
- jpaVersion = '1.0.0.Final'
- jtaVersion = '1.1'
- javassistVersion = '3.12.0.GA'
- cglibVersion = '2.2'
- javaxValidationVersion = '1.0.0.GA'
- hibernateValidatorVersion = '4.0.2.GA'
+ dependencies {
+ slf4jVersion = '1.5.8'
+ dom4jVersion = '1.6.1'
+ antlrVersion = '2.7.7'
+ annotationsCommonsVersion = '3.2.0.Final'
+ jpaVersion = '1.0.0.Final'
+ jtaVersion = '1.1'
+ javassistVersion = '3.12.0.GA'
+ cglibVersion = '2.2'
+ javaxValidationVersion = '1.0.0.GA'
+ hibernateValidatorVersion = '4.0.2.GA'
- junitVersion = '3.8.2'
- testngVersion = '5.8'
+ junitVersion = '3.8.2'
+ testngVersion = '5.8'
- h2Version = '1.2.134'
+ h2Version = '1.2.134'
- compile(
- group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
- )
- testCompile(
- [group: 'junit', name: 'junit', version: junitVersion]
- )
- testRuntime(
- [group: 'org.slf4j', name: 'jcl-over-slf4j', version: slf4jVersion],
- [group: 'org.slf4j', name: 'slf4j-log4j12', version: slf4jVersion],
- [group: 'com.h2database', name: 'h2', version: h2Version]
- )
- }
+ compile(
+ group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+ )
+ testCompile(
+ [group: 'junit', name: 'junit', version: junitVersion]
+ )
+ testRuntime(
+ [group: 'org.slf4j', name: 'jcl-over-slf4j', version: slf4jVersion],
+ [group: 'org.slf4j', name: 'slf4j-log4j12', version: slf4jVersion],
+ [group: 'com.h2database', name: 'h2', version: h2Version]
+ )
+ }
- sourceSets {
- main {
- compileClasspath = compileClasspath + configurations.provided
+ sourceSets {
+ main {
+ compileClasspath = compileClasspath + configurations.provided
+ }
}
- }
- manifest.mainAttributes(
- provider: 'gradle',
- 'Implementation-Url': 'http://hibernate.org',
- 'Implementation-Version': version,
- 'Implementation-Vendor': 'Hibernate.org',
- 'Implementation-Vendor-Id': 'org.hibernate'
- )
+ manifest.mainAttributes(
+ provider: 'gradle',
+ 'Implementation-Url': 'http://hibernate.org',
+ 'Implementation-Version': version,
+ 'Implementation-Vendor': 'Hibernate.org',
+ 'Implementation-Vendor-Id': 'org.hibernate'
+ )
- // minimize changes, at least for now..
- buildDirName = "target"
+ compileJava {
+ if (hasProperty('jdk15_home')) { options.fork(executable: "$jdk15_home/bin/javac") }
+ }
- // by default, compile to 1.5 compatibility
- targetCompatibility = "1.5"
- sourceCompatibility = "1.5"
+ compileTestJava {
+ if (hasProperty('jdk15_home')) { options.fork(executable: "$jdk15_home/bin/javac") }
+ }
- compileJava {
- if (hasProperty('jdk15_home')) { options.fork(executable: "$jdk15_home/bin/javac") }
- }
+ test {
+ ignoreFailures = true
+ }
- compileTestJava {
- if (hasProperty('jdk15_home')) { options.fork(executable: "$jdk15_home/bin/javac") }
- }
+ // by default, compile to 1.5 compatibility
+ targetCompatibility = "1.5"
+ sourceCompatibility = "1.5"
- test {
- ignoreFailures = true
+ ideaModule {
+ downloadJavadoc = false
+ scopes.COMPILE.plus.add(configurations.provided)
+ }
}
}
Property changes on: core/branches/gradle2/buildSrc
___________________________________________________________________
Name: svn:ignore
+ target
build
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
.*
Added: core/branches/gradle2/buildSrc/build.gradle
===================================================================
--- core/branches/gradle2/buildSrc/build.gradle (rev 0)
+++ core/branches/gradle2/buildSrc/build.gradle 2010-06-10 05:06:54 UTC (rev 19705)
@@ -0,0 +1,18 @@
+buildscript {
+ repositories {
+ mavenRepo urls: 'http://gradle.artifactoryonline.com/gradle/plugins'
+ }
+ dependencies {
+ classpath "org.gradle.plugins:gradle-idea-plugin:0.3"
+ }
+}
+
+apply plugin: 'groovy'
+
+dependencies {
+ compile gradleApi()
+ compile localGroovy()
+ compile 'org.apache.ant:ant:1.7.0'
+
+ groovy localGroovy()
+}
\ No newline at end of file
Added: core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/gradle/javadoc/Aggregator.groovy
===================================================================
--- core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/gradle/javadoc/Aggregator.groovy (rev 0)
+++ core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/gradle/javadoc/Aggregator.groovy 2010-06-10 05:06:54 UTC (rev 19705)
@@ -0,0 +1,70 @@
+package org.hibernate.gradle.javadoc
+
+import org.gradle.api.Project
+import org.gradle.api.tasks.SourceSet
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+class Aggregator {
+ private final Javadoc javadocTask;
+ private Set<String> excludedSourceSetNames;
+
+ public Aggregator(Javadoc javadocTask) {
+ this.javadocTask = javadocTask;
+ }
+
+ private Set<String> getExcludedSourceSetNames() {
+ if ( excludedSourceSetNames == null ) {
+ excludedSourceSetNames = new HashSet<String>();
+ }
+ return excludedSourceSetNames;
+ }
+
+ /**
+ * Allow adding them one by one
+ *
+ */
+ public void excludeSourceSetName(String name) {
+ getExcludedSourceSetNames().add( name );
+ }
+
+ /**
+ * Also, allow adding them all at once
+ */
+ public void excludeSourceSetNames(String[] names) {
+ getExcludedSourceSetNames().addAll( Arrays.asList( names ) );
+ }
+
+ public void project(Project project) {
+ project.sourceSets.each { SourceSet sourceSet ->
+ if ( excludedSourceSetNames == null || !excludedSourceSetNames.contains( sourceSet.name ) ) {
+ javadocTask.source sourceSet.allJava
+ if( javadocTask.classpath ) {
+ javadocTask.classpath += sourceSet.classes + sourceSet.compileClasspath
+ }
+ else {
+ javadocTask.classpath = sourceSet.classes + sourceSet.compileClasspath
+ }
+ }
+ }
+// project.sourceSets.each { SourceSet sourceSet ->
+// // we skip test sources. Would rather this be configurable, like I'd see a syntax like:
+// // task javadoc(type: Javadoc) {
+// // ...
+// // aggregator {
+// // skipSourceSet 'test'
+// // }
+// // }
+// if ( !SourceSet.TEST_SOURCE_SET_NAME.equals(sourceSet.getName()) ) {
+// source(sourceSet.allJava);
+// (sourceSet.classes + sourceSet.compileClasspath).each { File classPathElement ->
+// getJavadocOptions().classpath(classPathElement);
+// }
+// }
+// }
+
+ }
+}
Added: core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/gradle/javadoc/Javadoc.groovy
===================================================================
--- core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/gradle/javadoc/Javadoc.groovy (rev 0)
+++ core/branches/gradle2/buildSrc/src/main/groovy/org/hibernate/gradle/javadoc/Javadoc.groovy 2010-06-10 05:06:54 UTC (rev 19705)
@@ -0,0 +1,234 @@
+package org.hibernate.gradle.javadoc
+
+import org.gradle.external.javadoc.JavadocMemberLevel
+import org.gradle.external.javadoc.StandardJavadocDocletOptions
+import org.gradle.external.javadoc.JavadocOutputLevel
+import org.gradle.process.ExecSpec
+import org.gradle.api.tasks.TaskAction
+import org.gradle.process.internal.ExecAction
+import org.gradle.process.internal.ExecException
+import org.gradle.api.GradleException
+import org.gradle.util.GUtil
+import org.gradle.api.Project
+import org.gradle.api.tasks.SourceSet
+import org.gradle.api.tasks.SourceTask
+import org.gradle.external.javadoc.MinimalJavadocOptions
+import org.gradle.api.file.FileCollection
+import org.gradle.api.tasks.InputFiles
+import org.gradle.external.javadoc.JavadocExecHandleBuilder
+import org.gradle.api.tasks.OutputDirectory
+import org.gradle.util.ConfigureUtil
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+class Javadoc extends SourceTask {
+ private JavadocExecHandleBuilder javadocExecHandleBuilder = new JavadocExecHandleBuilder();
+
+ private File destinationDir;
+
+ private boolean failOnError = true;
+
+ private String title;
+
+ private String maxMemory;
+
+ private MinimalJavadocOptions options = new StandardJavadocDocletOptions();
+
+// EmptyFileCollection not available in my project as is
+// private FileCollection classpath = new EmptyFileCollection();
+ private FileCollection classpath;
+
+ private String executable;
+
+ @TaskAction
+ protected void generate() {
+ final File destinationDir = getDestinationDir();
+
+ if (options.getDestinationDirectory() == null) {
+ options.destinationDirectory(destinationDir);
+ }
+
+ options.classpath(new ArrayList<File>(getClasspath().getFiles()));
+
+ if (!GUtil.isTrue(options.getWindowTitle()) && GUtil.isTrue(getTitle())) {
+ options.windowTitle(getTitle());
+ }
+ if (options instanceof StandardJavadocDocletOptions) {
+ StandardJavadocDocletOptions docletOptions = (StandardJavadocDocletOptions) options;
+ if (!GUtil.isTrue(docletOptions.getDocTitle()) && GUtil.isTrue(getTitle())) {
+ docletOptions.setDocTitle(getTitle());
+ }
+ }
+
+ if (maxMemory != null) {
+ final List<String> jFlags = options.getJFlags();
+ final Iterator<String> jFlagsIt = jFlags.iterator();
+ boolean containsXmx = false;
+ while (!containsXmx && jFlagsIt.hasNext()) {
+ final String jFlag = jFlagsIt.next();
+ if (jFlag.startsWith("-Xmx")) {
+ containsXmx = true;
+ }
+ }
+ if (!containsXmx) {
+ options.jFlags("-Xmx" + maxMemory);
+ }
+ }
+
+ List<String> sourceNames = new ArrayList<String>();
+ for (File sourceFile : getSource()) {
+ sourceNames.add(sourceFile.getAbsolutePath());
+ }
+ options.setSourceNames(sourceNames);
+
+ executeExternalJavadoc();
+ }
+
+ private void executeExternalJavadoc() {
+ javadocExecHandleBuilder.execDirectory( getProject().getRootDir() )
+ .options( options )
+ .optionsFile( getOptionsFile() );
+
+ ExecAction execAction = javadocExecHandleBuilder.getExecHandle();
+ if ( executable != null && executable.length() > 0 ) {
+ execAction.setExecutable( executable );
+ }
+
+ if (!failOnError) {
+ execAction.setIgnoreExitValue(true);
+ }
+
+ try {
+ execAction.execute();
+ } catch (ExecException e) {
+ throw new GradleException("Javadoc generation failed.", e);
+ }
+ }
+
+ void setJavadocExecHandleBuilder(JavadocExecHandleBuilder javadocExecHandleBuilder) {
+ if (javadocExecHandleBuilder == null) {
+ throw new IllegalArgumentException("javadocExecHandleBuilder == null!");
+ }
+ this.javadocExecHandleBuilder = javadocExecHandleBuilder;
+ }
+
+ /**
+* <p>Returns the directory to generate the documentation into.</p>
+*
+* @return The directory.
+*/
+ @OutputDirectory
+ public File getDestinationDir() {
+ return destinationDir;
+ }
+
+ /**
+* <p>Sets the directory to generate the documentation into.</p>
+*/
+ public void setDestinationDir(File destinationDir) {
+ this.destinationDir = destinationDir;
+ }
+
+ /**
+* Returns the amount of memory allocated to this task.
+*/
+ public String getMaxMemory() {
+ return maxMemory;
+ }
+
+ /**
+* Sets the amount of memory allocated to this task.
+*
+* @param maxMemory The amount of memory
+*/
+ public void setMaxMemory(String maxMemory) {
+ this.maxMemory = maxMemory;
+ }
+
+ /**
+* <p>Returns the title for the generated documentation.</p>
+*
+* @return The title, possibly null.
+*/
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+* <p>Sets the title for the generated documentation.</p>
+*/
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+* Returns whether javadoc generation is accompanied by verbose output.
+*
+* @see #setVerbose(boolean)
+*/
+ public boolean isVerbose() {
+ return options.isVerbose();
+ }
+
+ /**
+* Sets whether javadoc generation is accompanied by verbose output or not. The verbose output is done via println
+* (by the underlying ant task). Thus it is not catched by our logging.
+*
+* @param verbose Whether the output should be verbose.
+*/
+ public void setVerbose(boolean verbose) {
+ if (verbose) {
+ options.verbose();
+ }
+ }
+
+ @InputFiles
+ public FileCollection getClasspath() {
+ return classpath;
+ }
+
+ public void setClasspath(FileCollection configuration) {
+ this.classpath = configuration;
+ }
+
+ public MinimalJavadocOptions getOptions() {
+ return options;
+ }
+
+ public void setOptions(MinimalJavadocOptions options) {
+ this.options = options;
+ }
+
+ public boolean isFailOnError() {
+ return failOnError;
+ }
+
+ public void setFailOnError(boolean failOnError) {
+ this.failOnError = failOnError;
+ }
+
+ public File getOptionsFile() {
+ return new File(getTemporaryDir(), "javadoc.options");
+ }
+
+ public String getExecutable() {
+ return executable;
+ }
+
+ public void setExecutable(String executable) {
+ this.executable = executable;
+ }
+
+ private Aggregator aggregator;
+
+ public void aggregator(Closure closure) {
+ if ( aggregator == null ) {
+ aggregator = new Aggregator( this );
+ }
+ ConfigureUtil.configure( closure, aggregator );
+ }
+
+}
Modified: core/branches/gradle2/hibernate-release/hibernate-release.gradle
===================================================================
--- core/branches/gradle2/hibernate-release/hibernate-release.gradle 2010-06-09 13:36:38 UTC (rev 19704)
+++ core/branches/gradle2/hibernate-release/hibernate-release.gradle 2010-06-10 05:06:54 UTC (rev 19705)
@@ -55,19 +55,21 @@
javadocBuildDir = dir( buildDirName + "/javadocs" )
-def List subProjectsToSkipForJavadoc = ["testsuite"];
+def List subProjectsToSkipForJavadoc = ["testsuite", 'hibernate-release'];
-task aggregateJavadocs(type: Javadoc) {
-// executable: '${jdk16_home}/bin/javadoc'
- maxmemory = '512m'
+task aggregateJavadocs(type: org.hibernate.gradle.javadoc.Javadoc) {
+ description = "Build the aggregated JavaDocs for all modules"
+ executable = "$jdk16_home/bin/javadoc"
+ maxMemory = '512m'
destinationDir = javadocBuildDir.dir
configure( options ) {
overview = new File( projectDir, 'src/javadoc/package.html' )
- stylesheetfile = new File( projectDir, 'src/javadoc/stylesheet.css' )
- windowtitle = 'Hibernate JavaDocs'
- doctitle = "Hibernate JavaDoc ($version)"
+ stylesheetFile = new File( projectDir, 'src/javadoc/stylesheet.css' )
+ windowTitle = 'Hibernate JavaDocs'
+ docTitle = "Hibernate JavaDoc ($project.version)"
bottom = 'Copyright © 2001-2010 <a href="http://redhat.com">Red Hat, Inc.</a> All Rights Reserved.'
use = true
+ links = [ 'http://java.sun.com/j2se/1.5.0/docs/api', 'http://java.sun.com/javaee/5/docs/api/' ]
group(
'Core API', [
'org.hibernate',
@@ -91,7 +93,7 @@
'org.hibernate.property',
'org.hibernate.loader*',
'org.hibernate.persister*',
- ':org.hibernate.proxy',
+ 'org.hibernate.proxy',
'org.hibernate.tuple',
'org.hibernate.transform',
'org.hibernate.collection',
@@ -114,55 +116,61 @@
group (
'Testing Support', ['org.hibernate.junit*']
)
- setJavadocExecHandleBuilder(
- new org.gradle.external.javadoc.JavadocExecHandleBuilder() {
- public ExecAction getExecHandle() {
- try {
- options.write(optionsFile);
- } catch (IOException e) {
- throw new GradleException("Faild to store javadoc options.", e);
- }
-
- ExecAction execAction = new DefaultExecAction();
- execAction.workingDir(execDirectory);
- execAction.executable( "$jdk16_home/bin/javadoc" );
- execAction.args("@" + optionsFile.getAbsolutePath());
-
- options.contributeCommandLineOptions(execAction);
-
- return execAction;
- }
- }
- )
}
- parent.subprojects.each{ subproject->
- if ( !subProjectsToSkipForJavadoc.contains( subproject.name ) ) {
- subproject.sourceSets.each { set ->
- if ( !"test".equals( set.name ) ) {
- source set.java
-
- if( classpath ) {
- classpath += set.classes + set.compileClasspath
- }
- else {
- classpath = set.classes + set.compileClasspath
- }
- }
+// parent.subprojects.each{ subProject->
+// if ( !subProjectsToSkipForJavadoc.contains( subProject.name ) ) {
+// subProject.sourceSets.each { set ->
+// if ( !"test".equals( set.name ) ) {
+// source set.java
+//
+// if( classpath ) {
+// classpath += set.classes + set.compileClasspath
+// }
+// else {
+// classpath = set.classes + set.compileClasspath
+// }
+// }
+// }
+// }
+// }
+ aggregator {
+ excludeSourceSetName 'test'
+ parent.subprojects.each{ subProject->
+ if ( ! subProjectsToSkipForJavadoc.contains( subProject.name ) ) {
+ project subProject
}
}
}
}
+aggregateJavadocs.doLast {
+ copy {
+ from new File( projectDir, 'src/javadoc/images' )
+ into new File( javadocBuildDir.dir, "/images" )
+ }
+}
+
+
// uber-jar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-def List subProjectsToSkipForUberJar = ['testsuite','hibernate-testing'];
+def List subProjectsToSkipForUberJar = ['testsuite','hibernate-testing', 'hibernate-release'];
releaseBuildDir = dir( buildDirName )
task uberJar(type: Jar, dependsOn: [releaseBuildDir, needs16]) {
+ description = "Builds the hibernate3.jar 'uber-jar'"
destinationDir = releaseBuildDir.dir
- customName = 'hibernate3.jar'
+ archiveName = 'hibernate3.jar'
+
+ manifest.mainAttributes(
+ provider: 'gradle',
+ 'Implementation-Url': 'http://hibernate.org',
+ 'Implementation-Version': version,
+ 'Implementation-Vendor': 'Hibernate.org',
+ 'Implementation-Vendor-Id': 'org.hibernate'
+ )
+
parent.subprojects.each { subproject->
if ( !subProjectsToSkipForUberJar.contains( subproject.name ) ) {
subproject.sourceSets.each { set ->
@@ -172,6 +180,15 @@
}
}
}
+
+ from zipTree(
+ parent.project( 'hibernate-annotations' )
+ .configurations
+ .runtime
+ .fileCollection { dep -> dep.name == 'hibernate-commons-annotations' }
+ .filter { file -> file.name.startsWith( 'hibernate-commons-annotations' ) }
+ .singleFile
+ )
}
parent.subprojects.each { subproject ->
@@ -207,33 +224,71 @@
}
['hibernate-c3p0', 'hibernate-proxool', 'hibernate-ehcache', 'hibernate-infinispan',
- 'hibernate-jbosscache', 'hibernate-oscache', 'hibernate-swarmcache',
- 'hibernate-entitymanager', 'hibernate-envers'].each { feature ->
+ 'hibernate-jbosscache', 'hibernate-oscache', 'hibernate-swarmcache'].each { feature ->
final String shortName = feature.substring( 'hibernate-'.length() );
into('lib/optional/' + shortName) {
- from ( parent.project( feature ).configurations.runtime
+ from (
+ parent.project( feature ).configurations.runtime
- parent.project( 'hibernate-core' ).configurations.runtime
- - parent.project( 'hibernate-core' ).configurations.provided )
+ - parent.project( 'hibernate-core' ).configurations.provided
+ - parent.project( 'hibernate-annotations' ).configurations.runtime
+ - parent.project( 'hibernate-annotations' ).configurations.provided
+ )
}
}
+ into( 'lib/jpa' ) {
+ from parent.project( 'hibernate-entitymanager' )
+ .configurations
+ .runtime
+ .fileCollection { dep -> dep.name == 'hibernate-jpa-2.0-api' }
+ .filter { file -> file.name.startsWith( 'hibernate-jpa-2.0-api' ) }
+ }
+
into('documentation/manual') {
from new File( project.buildDir, 'docbook/publish' )
}
into('documentation/javadocs') {
- from javadocBuildDir
+ from javadocBuildDir.dir
}
+
+ into( 'project' ) {
+ from ( rootProject.projectDir ) {
+ exclude( '**/target/**' )
+ exclude( '**/local/**' )
+ exclude( '**/build/**' )
+ exclude( '**/*.ipr' )
+ exclude( '**/*.iml' )
+ exclude( '**/*.iws' )
+ exclude( '**/atlassian-ide-plugin.xml' )
+ exclude( '**/.idea' )
+ exclude( '**/.classpath' )
+ exclude( '**/.project' )
+ exclude( '**/.settings' )
+ exclude( '**/.nbattrs' )
+ exclude( '**/*.log' )
+ exclude( '**/.svn' )
+ exclude( '**/.gradle/**' )
+ }
+ }
}
task buildReleaseZip( type: Zip, dependsOn: [prepareReleaseBundles] ) {
+ description = "Build release bundle in ZIP format"
baseName = 'hibernate-release'
+ destinationDir = releaseBuildDir.dir
with project.releaseCopySpec
}
task buildReleaseTgz( type: Tar, dependsOn: [prepareReleaseBundles] ) {
+ description = "Build release bundle in GZIP format"
baseName = 'hibernate-release'
+ destinationDir = releaseBuildDir.dir
compression = Compression.GZIP
with project.releaseCopySpec
}
+task buildReleaseBundles( dependsOn: [buildReleaseZip,buildReleaseTgz] ) {
+ description = "Build release bundle in all formats"
+}
13 years, 11 months
Hibernate SVN: r19704 - search/trunk/hibernate-search/src/test/resources.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-09 09:36:38 -0400 (Wed, 09 Jun 2010)
New Revision: 19704
Modified:
search/trunk/hibernate-search/src/test/resources/log4j.properties
Log:
increase the log threshold from debug to info for search categories
Modified: search/trunk/hibernate-search/src/test/resources/log4j.properties
===================================================================
--- search/trunk/hibernate-search/src/test/resources/log4j.properties 2010-06-09 08:52:22 UTC (rev 19703)
+++ search/trunk/hibernate-search/src/test/resources/log4j.properties 2010-06-09 13:36:38 UTC (rev 19704)
@@ -16,8 +16,6 @@
log4j.appender.socket.port=4560
log4j.appender.socket.locationInfo=true
-log4j.logger.org.hibernate.search.backend=debug
-
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout
@@ -27,8 +25,8 @@
log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate.search=debug
+#log4j.logger.org.hibernate.search.backend=debug
-
### log just the SQL
#log4j.logger.org.hibernate.SQL=debug
13 years, 11 months
Hibernate SVN: r19703 - core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2010-06-09 04:52:22 -0400 (Wed, 09 Jun 2010)
New Revision: 19703
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java
Log:
* always adding a nested type mapping, if there are type properties; not only in case of instances of CustomType
* simplifying the basic generator because of the new type hierarchy
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java 2010-06-09 05:44:32 UTC (rev 19702)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java 2010-06-09 08:52:22 UTC (rev 19703)
@@ -34,8 +34,6 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value;
import org.hibernate.type.BasicType;
-import org.hibernate.type.CompositeCustomType;
-import org.hibernate.type.CustomType;
import org.hibernate.type.Type;
/**
@@ -43,66 +41,40 @@
* @author Adam Warski (adam at warski dot org)
*/
public final class BasicMetadataGenerator {
+ @SuppressWarnings({"unchecked"})
boolean addBasic(Element parent, PropertyAuditingData propertyAuditingData,
Value value, SimpleMapperBuilder mapper, boolean insertable, boolean key) {
Type type = value.getType();
- if ( type instanceof BasicType ) {
- addSimpleValue(parent, propertyAuditingData, value, mapper, insertable, key);
- } else if (type instanceof CustomType || type instanceof CompositeCustomType) {
- addCustomValue(parent, propertyAuditingData, value, mapper, insertable, key);
- } else if ("org.hibernate.type.PrimitiveByteArrayBlobType".equals(type.getClass().getName())) {
- addSimpleValue(parent, propertyAuditingData, value, mapper, insertable, key);
- } else {
- return false;
- }
+ if (type instanceof BasicType || "org.hibernate.type.PrimitiveByteArrayBlobType".equals(type.getClass().getName())) {
+ if (parent != null) {
+ boolean addNestedType = (value instanceof SimpleValue) && ((SimpleValue) value).getTypeParameters() != null;
- return true;
- }
+ Element prop_mapping = MetadataTools.addProperty(parent, propertyAuditingData.getName(),
+ addNestedType ? null : value.getType().getName(), propertyAuditingData.isForceInsertable() || insertable, key);
+ MetadataTools.addColumns(prop_mapping, (Iterator<Column>) value.getColumnIterator());
- @SuppressWarnings({"unchecked"})
- private void addSimpleValue(Element parent, PropertyAuditingData propertyAuditingData,
- Value value, SimpleMapperBuilder mapper, boolean insertable, boolean key) {
- if (parent != null) {
- Element prop_mapping = MetadataTools.addProperty(parent, propertyAuditingData.getName(),
- value.getType().getName(), propertyAuditingData.isForceInsertable() || insertable, key);
- MetadataTools.addColumns(prop_mapping, (Iterator<Column>) value.getColumnIterator());
- }
+ if (addNestedType) {
+ Properties typeParameters = ((SimpleValue) value).getTypeParameters();
+ Element type_mapping = prop_mapping.addElement("type");
+ type_mapping.addAttribute("name", value.getType().getName());
- // A null mapper means that we only want to add xml mappings
- if (mapper != null) {
- mapper.add(propertyAuditingData.getPropertyData());
- }
- }
+ for (java.util.Map.Entry paramKeyValue : typeParameters.entrySet()) {
+ Element type_param = type_mapping.addElement("param");
+ type_param.addAttribute("name", (String) paramKeyValue.getKey());
+ type_param.setText((String) paramKeyValue.getValue());
+ }
+ }
+ }
- @SuppressWarnings({"unchecked"})
- private void addCustomValue(Element parent, PropertyAuditingData propertyAuditingData,
- Value value, SimpleMapperBuilder mapper, boolean insertable, boolean key) {
- if (parent != null) {
- Element prop_mapping = MetadataTools.addProperty(parent, propertyAuditingData.getName(),
- null, insertable, key);
-
- //CustomType propertyType = (CustomType) value.getType();
-
- Element type_mapping = prop_mapping.addElement("type");
- type_mapping.addAttribute("name", value.getType().getName());
-
- if (value instanceof SimpleValue) {
- Properties typeParameters = ((SimpleValue) value).getTypeParameters();
- if (typeParameters != null) {
- for (java.util.Map.Entry paramKeyValue : typeParameters.entrySet()) {
- Element type_param = type_mapping.addElement("param");
- type_param.addAttribute("name", (String) paramKeyValue.getKey());
- type_param.setText((String) paramKeyValue.getValue());
- }
- }
- }
-
- MetadataTools.addColumns(prop_mapping, (Iterator<Column>) value.getColumnIterator());
+ // A null mapper means that we only want to add xml mappings
+ if (mapper != null) {
+ mapper.add(propertyAuditingData.getPropertyData());
+ }
+ } else {
+ return false;
}
- if (mapper != null) {
- mapper.add(propertyAuditingData.getPropertyData());
- }
+ return true;
}
}
13 years, 11 months
Hibernate SVN: r19702 - in core/branches/Branch_3_5/envers/src: main/java/org/hibernate/envers/event and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2010-06-09 01:44:32 -0400 (Wed, 09 Jun 2010)
New Revision: 19702
Added:
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ChildIndexedListJoinColumnBidirectionalRefIngEntity.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentIndexedListJoinColumnBidirectionalRefIngEntity.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/InheritanceIndexedJoinColumnBidirectionalList.java
Removed:
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ChildIndexedListJoinColumnBidirectionalRefIngEntity.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentIndexedListJoinColumnBidirectionalRefIngEntity.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.java
Modified:
core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/entities/EntityConfiguration.java
core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/event/AuditEventListener.java
Log:
svn merge -r 19697:19698 https://svn.jboss.org/repos/hibernate/core/branches/envers-hibernate-3.3 .
Modified: core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/entities/EntityConfiguration.java
===================================================================
--- core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/entities/EntityConfiguration.java 2010-06-08 19:16:21 UTC (rev 19701)
+++ core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/entities/EntityConfiguration.java 2010-06-09 05:44:32 UTC (rev 19702)
@@ -100,12 +100,12 @@
return propertyMapper;
}
- // For use by EntitiesConfigurations
-
- String getParentEntityName() {
+ public String getParentEntityName() {
return parentEntityName;
}
+ // For use by EntitiesConfigurations
+
String getVersionsEntityName() {
return versionsEntityName;
}
Modified: core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/event/AuditEventListener.java
===================================================================
--- core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/event/AuditEventListener.java 2010-06-08 19:16:21 UTC (rev 19701)
+++ core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/event/AuditEventListener.java 2010-06-09 05:44:32 UTC (rev 19702)
@@ -27,6 +27,7 @@
import java.util.List;
import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.entities.EntityConfiguration;
import org.hibernate.envers.entities.RelationDescription;
import org.hibernate.envers.entities.RelationType;
import org.hibernate.envers.entities.mapper.PersistentCollectionChangeData;
@@ -264,7 +265,7 @@
// Checking if this is not a "fake" many-to-one bidirectional relation. The relation description may be
// null in case of collections of non-entities.
- RelationDescription rd = verCfg.getEntCfg().get(entityName).getRelationDescription(referencingPropertyName);
+ RelationDescription rd = searchForRelationDescription(entityName, referencingPropertyName);
if (rd != null && rd.getMappedByPropertyName() != null) {
generateFakeBidirecationalRelationWorkUnits(auditProcess, newColl, oldColl, entityName,
referencingPropertyName, event, rd);
@@ -285,6 +286,24 @@
}
}
+ /**
+ * Looks up a relation description corresponding to the given property in the given entity. If no description is
+ * found in the given entity, the parent entity is checked (so that inherited relations work).
+ * @param entityName Name of the entity, in which to start looking.
+ * @param referencingPropertyName The name of the property.
+ * @return A found relation description corresponding to the given entity or {@code null}, if no description can
+ * be found.
+ */
+ private RelationDescription searchForRelationDescription(String entityName, String referencingPropertyName) {
+ EntityConfiguration configuration = verCfg.getEntCfg().get(entityName);
+ RelationDescription rd = configuration.getRelationDescription(referencingPropertyName);
+ if (rd == null && configuration.getParentEntityName() != null) {
+ return searchForRelationDescription(configuration.getParentEntityName(), referencingPropertyName);
+ }
+
+ return rd;
+ }
+
private CollectionEntry getCollectionEntry(AbstractCollectionEvent event) {
return event.getSession().getPersistenceContext().getCollectionEntry(event.getCollection());
}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance (from rev 19698, core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance)
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ChildIndexedListJoinColumnBidirectionalRefIngEntity.java
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ChildIndexedListJoinColumnBidirectionalRefIngEntity.java 2010-06-08 06:31:02 UTC (rev 19698)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ChildIndexedListJoinColumnBidirectionalRefIngEntity.java 2010-06-09 05:44:32 UTC (rev 19702)
@@ -1,61 +0,0 @@
-package org.hibernate.envers.test.entities.onetomany.detached.inheritance;
-
-import org.hibernate.envers.Audited;
-
-import javax.persistence.Entity;
-
-/**
- * Entity for {@link org.hibernate.envers.test.integration.onetomany.detached.InheritanceIndexedJoinColumnBidirectionalList} test.
- * Child, owning side of the relation.
- * @author Adam Warski (adam at warski dot org)
- */
-@Entity
-@Audited
-public class ChildIndexedListJoinColumnBidirectionalRefIngEntity extends ParentIndexedListJoinColumnBidirectionalRefIngEntity {
- private String data2;
-
- public ChildIndexedListJoinColumnBidirectionalRefIngEntity() {
- }
-
- public ChildIndexedListJoinColumnBidirectionalRefIngEntity(Integer id, String data, String data2, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
- super(id, data, references);
- this.data2 = data2;
- }
-
- public ChildIndexedListJoinColumnBidirectionalRefIngEntity(String data, String data2, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
- super(data, references);
- this.data2 = data2;
- }
-
- public String getData2() {
- return data2;
- }
-
- public void setData2(String data2) {
- this.data2 = data2;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ChildIndexedListJoinColumnBidirectionalRefIngEntity)) return false;
- if (!super.equals(o)) return false;
-
- ChildIndexedListJoinColumnBidirectionalRefIngEntity that = (ChildIndexedListJoinColumnBidirectionalRefIngEntity) o;
-
- if (data2 != null ? !data2.equals(that.data2) : that.data2 != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = super.hashCode();
- result = 31 * result + (data2 != null ? data2.hashCode() : 0);
- return result;
- }
-
- public String toString() {
- return "ChildIndexedListJoinColumnBidirectionalRefIngEntity(id = " + getId() + ", data = " + getData() + ", data2 = " + data2 + ")";
- }
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ChildIndexedListJoinColumnBidirectionalRefIngEntity.java (from rev 19698, core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ChildIndexedListJoinColumnBidirectionalRefIngEntity.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ChildIndexedListJoinColumnBidirectionalRefIngEntity.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ChildIndexedListJoinColumnBidirectionalRefIngEntity.java 2010-06-09 05:44:32 UTC (rev 19702)
@@ -0,0 +1,61 @@
+package org.hibernate.envers.test.entities.onetomany.detached.inheritance;
+
+import org.hibernate.envers.Audited;
+
+import javax.persistence.Entity;
+
+/**
+ * Entity for {@link org.hibernate.envers.test.integration.onetomany.detached.InheritanceIndexedJoinColumnBidirectionalList} test.
+ * Child, owning side of the relation.
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Audited
+public class ChildIndexedListJoinColumnBidirectionalRefIngEntity extends ParentIndexedListJoinColumnBidirectionalRefIngEntity {
+ private String data2;
+
+ public ChildIndexedListJoinColumnBidirectionalRefIngEntity() {
+ }
+
+ public ChildIndexedListJoinColumnBidirectionalRefIngEntity(Integer id, String data, String data2, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
+ super(id, data, references);
+ this.data2 = data2;
+ }
+
+ public ChildIndexedListJoinColumnBidirectionalRefIngEntity(String data, String data2, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
+ super(data, references);
+ this.data2 = data2;
+ }
+
+ public String getData2() {
+ return data2;
+ }
+
+ public void setData2(String data2) {
+ this.data2 = data2;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ChildIndexedListJoinColumnBidirectionalRefIngEntity)) return false;
+ if (!super.equals(o)) return false;
+
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity that = (ChildIndexedListJoinColumnBidirectionalRefIngEntity) o;
+
+ if (data2 != null ? !data2.equals(that.data2) : that.data2 != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = super.hashCode();
+ result = 31 * result + (data2 != null ? data2.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "ChildIndexedListJoinColumnBidirectionalRefIngEntity(id = " + getId() + ", data = " + getData() + ", data2 = " + data2 + ")";
+ }
+}
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentIndexedListJoinColumnBidirectionalRefIngEntity.java
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentIndexedListJoinColumnBidirectionalRefIngEntity.java 2010-06-08 06:31:02 UTC (rev 19698)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentIndexedListJoinColumnBidirectionalRefIngEntity.java 2010-06-09 05:44:32 UTC (rev 19702)
@@ -1,93 +0,0 @@
-package org.hibernate.envers.test.entities.onetomany.detached.inheritance;
-
-import org.hibernate.annotations.IndexColumn;
-import org.hibernate.envers.AuditMappedBy;
-import org.hibernate.envers.Audited;
-
-import javax.persistence.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Entity for {@link org.hibernate.envers.test.integration.onetomany.detached.InheritanceIndexedJoinColumnBidirectionalList} test.
- * Parent, owning side of the relation.
- * @author Adam Warski (adam at warski dot org)
- */
-@Entity
-@Audited
-@Inheritance(strategy = InheritanceType.JOINED)
-public abstract class ParentIndexedListJoinColumnBidirectionalRefIngEntity {
- @Id
- @GeneratedValue
- private Integer id;
-
- private String data;
-
- @OneToMany
- @JoinColumn(name = "indexed_join_column")
- @IndexColumn(name = "indexed_index")
- @AuditMappedBy(mappedBy = "owner", positionMappedBy = "position")
- private List<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity> references;
-
- public ParentIndexedListJoinColumnBidirectionalRefIngEntity() { }
-
- public ParentIndexedListJoinColumnBidirectionalRefIngEntity(Integer id, String data, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
- this.id = id;
- this.data = data;
- this.references = new ArrayList<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity>();
- this.references.addAll(Arrays.asList(references));
- }
-
- public ParentIndexedListJoinColumnBidirectionalRefIngEntity(String data, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
- this(null, data, references);
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getData() {
- return data;
- }
-
- public void setData(String data) {
- this.data = data;
- }
-
- public List<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity> getReferences() {
- return references;
- }
-
- public void setReferences(List<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity> references) {
- this.references = references;
- }
-
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ParentIndexedListJoinColumnBidirectionalRefIngEntity)) return false;
-
- ParentIndexedListJoinColumnBidirectionalRefIngEntity that = (ParentIndexedListJoinColumnBidirectionalRefIngEntity) o;
-
- if (data != null ? !data.equals(that.data) : that.data != null) return false;
- //noinspection RedundantIfStatement
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result;
- result = (id != null ? id.hashCode() : 0);
- result = 31 * result + (data != null ? data.hashCode() : 0);
- return result;
- }
-
- public String toString() {
- return "ParentIndexedListJoinColumnBidirectionalRefIngEntity(id = " + id + ", data = " + data + ")";
- }
-}
\ No newline at end of file
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentIndexedListJoinColumnBidirectionalRefIngEntity.java (from rev 19698, core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentIndexedListJoinColumnBidirectionalRefIngEntity.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentIndexedListJoinColumnBidirectionalRefIngEntity.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentIndexedListJoinColumnBidirectionalRefIngEntity.java 2010-06-09 05:44:32 UTC (rev 19702)
@@ -0,0 +1,93 @@
+package org.hibernate.envers.test.entities.onetomany.detached.inheritance;
+
+import org.hibernate.annotations.IndexColumn;
+import org.hibernate.envers.AuditMappedBy;
+import org.hibernate.envers.Audited;
+
+import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Entity for {@link org.hibernate.envers.test.integration.onetomany.detached.InheritanceIndexedJoinColumnBidirectionalList} test.
+ * Parent, owning side of the relation.
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Audited
+@Inheritance(strategy = InheritanceType.JOINED)
+public abstract class ParentIndexedListJoinColumnBidirectionalRefIngEntity {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ private String data;
+
+ @OneToMany
+ @JoinColumn(name = "indexed_join_column")
+ @IndexColumn(name = "indexed_index")
+ @AuditMappedBy(mappedBy = "owner", positionMappedBy = "position")
+ private List<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity> references;
+
+ public ParentIndexedListJoinColumnBidirectionalRefIngEntity() { }
+
+ public ParentIndexedListJoinColumnBidirectionalRefIngEntity(Integer id, String data, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
+ this.id = id;
+ this.data = data;
+ this.references = new ArrayList<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity>();
+ this.references.addAll(Arrays.asList(references));
+ }
+
+ public ParentIndexedListJoinColumnBidirectionalRefIngEntity(String data, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
+ this(null, data, references);
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public List<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity> getReferences() {
+ return references;
+ }
+
+ public void setReferences(List<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity> references) {
+ this.references = references;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ParentIndexedListJoinColumnBidirectionalRefIngEntity)) return false;
+
+ ParentIndexedListJoinColumnBidirectionalRefIngEntity that = (ParentIndexedListJoinColumnBidirectionalRefIngEntity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ //noinspection RedundantIfStatement
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "ParentIndexedListJoinColumnBidirectionalRefIngEntity(id = " + id + ", data = " + data + ")";
+ }
+}
\ No newline at end of file
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.java
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.java 2010-06-08 06:31:02 UTC (rev 19698)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.java 2010-06-09 05:44:32 UTC (rev 19702)
@@ -1,96 +0,0 @@
-package org.hibernate.envers.test.entities.onetomany.detached.inheritance;
-
-import org.hibernate.envers.Audited;
-
-import javax.persistence.*;
-
-/**
- * Entity for {@link org.hibernate.envers.test.integration.onetomany.detached.InheritanceIndexedJoinColumnBidirectionalList} test.
- * Owned side of the relation.
- * @author Adam Warski (adam at warski dot org)
- */
-@Entity
-@Audited
-public class ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity {
- @Id
- @GeneratedValue
- private Integer id;
-
- private String data;
-
- @Column(name = "indexed_index", insertable = false, updatable = false)
- private Integer position;
-
- @ManyToOne
- @JoinColumn(name = "indexed_join_column", insertable = false, updatable = false)
- private ParentIndexedListJoinColumnBidirectionalRefIngEntity owner;
-
- public ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity() { }
-
- public ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity(Integer id, String data, ParentIndexedListJoinColumnBidirectionalRefIngEntity owner) {
- this.id = id;
- this.data = data;
- this.owner = owner;
- }
-
- public ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity(String data, ParentIndexedListJoinColumnBidirectionalRefIngEntity owner) {
- this.data = data;
- this.owner = owner;
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getData() {
- return data;
- }
-
- public void setData(String data) {
- this.data = data;
- }
-
- public ParentIndexedListJoinColumnBidirectionalRefIngEntity getOwner() {
- return owner;
- }
-
- public void setOwner(ParentIndexedListJoinColumnBidirectionalRefIngEntity owner) {
- this.owner = owner;
- }
-
- public Integer getPosition() {
- return position;
- }
-
- public void setPosition(Integer position) {
- this.position = position;
- }
-
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity)) return false;
-
- ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity that = (ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity) o;
-
- if (data != null ? !data.equals(that.data) : that.data != null) return false;
- //noinspection RedundantIfStatement
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result;
- result = (id != null ? id.hashCode() : 0);
- result = 31 * result + (data != null ? data.hashCode() : 0);
- return result;
- }
-
- public String toString() {
- return "ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity(id = " + id + ", data = " + data + ")";
- }
-}
\ No newline at end of file
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.java (from rev 19698, core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/onetomany/detached/inheritance/ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.java 2010-06-09 05:44:32 UTC (rev 19702)
@@ -0,0 +1,96 @@
+package org.hibernate.envers.test.entities.onetomany.detached.inheritance;
+
+import org.hibernate.envers.Audited;
+
+import javax.persistence.*;
+
+/**
+ * Entity for {@link org.hibernate.envers.test.integration.onetomany.detached.InheritanceIndexedJoinColumnBidirectionalList} test.
+ * Owned side of the relation.
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Audited
+public class ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ private String data;
+
+ @Column(name = "indexed_index", insertable = false, updatable = false)
+ private Integer position;
+
+ @ManyToOne
+ @JoinColumn(name = "indexed_join_column", insertable = false, updatable = false)
+ private ParentIndexedListJoinColumnBidirectionalRefIngEntity owner;
+
+ public ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity() { }
+
+ public ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity(Integer id, String data, ParentIndexedListJoinColumnBidirectionalRefIngEntity owner) {
+ this.id = id;
+ this.data = data;
+ this.owner = owner;
+ }
+
+ public ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity(String data, ParentIndexedListJoinColumnBidirectionalRefIngEntity owner) {
+ this.data = data;
+ this.owner = owner;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public ParentIndexedListJoinColumnBidirectionalRefIngEntity getOwner() {
+ return owner;
+ }
+
+ public void setOwner(ParentIndexedListJoinColumnBidirectionalRefIngEntity owner) {
+ this.owner = owner;
+ }
+
+ public Integer getPosition() {
+ return position;
+ }
+
+ public void setPosition(Integer position) {
+ this.position = position;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity)) return false;
+
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity that = (ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ //noinspection RedundantIfStatement
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity(id = " + id + ", data = " + data + ")";
+ }
+}
\ No newline at end of file
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/InheritanceIndexedJoinColumnBidirectionalList.java (from rev 19698, core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/InheritanceIndexedJoinColumnBidirectionalList.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/InheritanceIndexedJoinColumnBidirectionalList.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/InheritanceIndexedJoinColumnBidirectionalList.java 2010-06-09 05:44:32 UTC (rev 19702)
@@ -0,0 +1,253 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.test.integration.onetomany.detached;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.hibernate.envers.test.entities.onetomany.detached.inheritance.ChildIndexedListJoinColumnBidirectionalRefIngEntity;
+import org.hibernate.envers.test.entities.onetomany.detached.inheritance.ParentIndexedListJoinColumnBidirectionalRefIngEntity;
+import org.hibernate.envers.test.entities.onetomany.detached.inheritance.ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * Test for a "fake" bidirectional mapping where one side uses @OneToMany+@JoinColumn (and thus owns the relation),
+ * in the parent entity, and the other uses a @ManyToOne(insertable=false, updatable=false).
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class InheritanceIndexedJoinColumnBidirectionalList extends AbstractEntityTest {
+ private Integer ed1_id;
+ private Integer ed2_id;
+ private Integer ed3_id;
+
+ private Integer ing1_id;
+ private Integer ing2_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(ParentIndexedListJoinColumnBidirectionalRefIngEntity.class);
+ cfg.addAnnotatedClass(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class);
+ cfg.addAnnotatedClass(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class);
+ }
+
+ @Test(enabled = true)
+ public void createData() {
+ EntityManager em = getEntityManager();
+
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed1 = new ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity("ed1", null);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed2 = new ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity("ed2", null);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed3 = new ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity("ed3", null);
+
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity ing1 = new ChildIndexedListJoinColumnBidirectionalRefIngEntity("coll1", "coll1bis", ed1, ed2, ed3);
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity ing2 = new ChildIndexedListJoinColumnBidirectionalRefIngEntity("coll1", "coll1bis");
+
+ // Revision 1 (ing1: ed1, ed2, ed3)
+ em.getTransaction().begin();
+
+ em.persist(ed1);
+ em.persist(ed2);
+ em.persist(ed3);
+ em.persist(ing1);
+ em.persist(ing2);
+
+ em.getTransaction().commit();
+
+ // Revision 2 (ing1: ed1, ed3, ing2: ed2)
+ em.getTransaction().begin();
+
+ ing1 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
+ ing2 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
+ ed2 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());
+
+ ing1.getReferences().remove(ed2);
+ ing2.getReferences().add(ed2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 3 (ing1: ed3, ed1, ing2: ed2)
+ em.getTransaction().begin();
+
+ ing1 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
+ ing2 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
+ ed1 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
+ ed2 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());
+ ed3 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3.getId());
+
+ ing1.getReferences().remove(ed3);
+ ing1.getReferences().add(0, ed3);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 4 (ing1: ed2, ed3, ed1)
+ em.getTransaction().begin();
+
+ ing1 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
+ ing2 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
+ ed1 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
+ ed2 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());
+ ed3 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3.getId());
+
+ ing2.getReferences().remove(ed2);
+ ing1.getReferences().add(0, ed2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ //
+
+ ing1_id = ing1.getId();
+ ing2_id = ing2.getId();
+
+ ed1_id = ed1.getId();
+ ed2_id = ed2.getId();
+ ed3_id = ed3.getId();
+ }
+
+ @Test(enabled = true, dependsOnMethods = "createData")
+ public void testRevisionsCounts() {
+ assertEquals(Arrays.asList(1, 2, 3, 4), getAuditReader().getRevisions(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id));
+ assertEquals(Arrays.asList(1, 2, 4), getAuditReader().getRevisions(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id));
+
+ assertEquals(Arrays.asList(1, 3, 4), getAuditReader().getRevisions(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id));
+ assertEquals(Arrays.asList(1, 2, 4), getAuditReader().getRevisions(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id));
+ assertEquals(Arrays.asList(1, 2, 3, 4), getAuditReader().getRevisions(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id));
+ }
+
+ @Test(enabled = true, dependsOnMethods = "createData")
+ public void testHistoryOfIng1() {
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed1 = getEntityManager().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed2 = getEntityManager().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed3 = getEntityManager().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id);
+
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity rev1 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 1);
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity rev2 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 2);
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity rev3 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 3);
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity rev4 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 4);
+
+ assertEquals(rev1.getReferences().size(), 3);
+ assertEquals(rev1.getReferences().get(0), ed1);
+ assertEquals(rev1.getReferences().get(1), ed2);
+ assertEquals(rev1.getReferences().get(2), ed3);
+
+ assertEquals(rev2.getReferences().size(), 2);
+ assertEquals(rev2.getReferences().get(0), ed1);
+ assertEquals(rev2.getReferences().get(1), ed3);
+
+ assertEquals(rev3.getReferences().size(), 2);
+ assertEquals(rev3.getReferences().get(0), ed3);
+ assertEquals(rev3.getReferences().get(1), ed1);
+
+ assertEquals(rev4.getReferences().size(), 3);
+ assertEquals(rev4.getReferences().get(0), ed2);
+ assertEquals(rev4.getReferences().get(1), ed3);
+ assertEquals(rev4.getReferences().get(2), ed1);
+ }
+
+ @Test(enabled = true, dependsOnMethods = "createData")
+ public void testHistoryOfIng2() {
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed2 = getEntityManager().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id);
+
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity rev1 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 1);
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity rev2 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 2);
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity rev3 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 3);
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity rev4 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 4);
+
+ assertEquals(rev1.getReferences().size(), 0);
+
+ assertEquals(rev2.getReferences().size(), 1);
+ assertEquals(rev2.getReferences().get(0), ed2);
+
+ assertEquals(rev3.getReferences().size(), 1);
+ assertEquals(rev3.getReferences().get(0), ed2);
+
+ assertEquals(rev4.getReferences().size(), 0);
+ }
+
+ @Test(enabled = true, dependsOnMethods = "createData")
+ public void testHistoryOfEd1() {
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity ing1 = getEntityManager().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id);
+
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev1 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 1);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev2 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 2);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev3 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 3);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev4 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 4);
+
+ assertTrue(rev1.getOwner().equals(ing1));
+ assertTrue(rev2.getOwner().equals(ing1));
+ assertTrue(rev3.getOwner().equals(ing1));
+ assertTrue(rev4.getOwner().equals(ing1));
+
+ assertEquals(rev1.getPosition(), new Integer(0));
+ assertEquals(rev2.getPosition(), new Integer(0));
+ assertEquals(rev3.getPosition(), new Integer(1));
+ assertEquals(rev4.getPosition(), new Integer(2));
+ }
+
+ @Test(enabled = true, dependsOnMethods = "createData")
+ public void testHistoryOfEd2() {
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity ing1 = getEntityManager().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id);
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity ing2 = getEntityManager().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id);
+
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev1 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 1);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev2 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 2);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev3 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 3);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev4 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 4);
+
+ assertTrue(rev1.getOwner().equals(ing1));
+ assertTrue(rev2.getOwner().equals(ing2));
+ assertTrue(rev3.getOwner().equals(ing2));
+ assertTrue(rev4.getOwner().equals(ing1));
+
+ assertEquals(rev1.getPosition(), new Integer(1));
+ assertEquals(rev2.getPosition(), new Integer(0));
+ assertEquals(rev3.getPosition(), new Integer(0));
+ assertEquals(rev4.getPosition(), new Integer(0));
+ }
+
+ @Test(enabled = true, dependsOnMethods = "createData")
+ public void testHistoryOfEd3() {
+ ChildIndexedListJoinColumnBidirectionalRefIngEntity ing1 = getEntityManager().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id);
+
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev1 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id, 1);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev2 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id, 2);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev3 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id, 3);
+ ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev4 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id, 4);
+
+ assertTrue(rev1.getOwner().equals(ing1));
+ assertTrue(rev2.getOwner().equals(ing1));
+ assertTrue(rev3.getOwner().equals(ing1));
+ assertTrue(rev4.getOwner().equals(ing1));
+
+ assertEquals(rev1.getPosition(), new Integer(2));
+ assertEquals(rev2.getPosition(), new Integer(1));
+ assertEquals(rev3.getPosition(), new Integer(0));
+ assertEquals(rev4.getPosition(), new Integer(1));
+ }
+}
\ No newline at end of file
13 years, 11 months