Author: epbernard Date: 2006-03-16 17:19:13 -0500 (Thu, 16 Mar 2006) New Revision: 9641 Modified: trunk/HibernateExt/metadata/ trunk/HibernateExt/metadata/doc/reference/en/master.xml trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml trunk/HibernateExt/metadata/doc/reference/en/modules/setup.xml trunk/HibernateExt/metadata/doc/reference/en/modules/validator.xml trunk/HibernateExt/metadata/lib/ejb3-persistence.jar trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazin.java trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazinPk.java trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java Log: Documentation tests and ejb3 persistence api sync Property changes on: trunk/HibernateExt/metadata ___________________________________________________________________ Name: svn:ignore - target build build.properties test_output testout common-build.xml javadoc.bat build.properties instrumenttestout + target build build.properties test_output testout common-build.xml javadoc.bat build.properties instrumenttestout classes Modified: trunk/HibernateExt/metadata/doc/reference/en/master.xml =================================================================== --- trunk/HibernateExt/metadata/doc/reference/en/master.xml 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/doc/reference/en/master.xml 2006-03-16 22:19:13 UTC (rev 9641) @@ -12,7 +12,7 @@ <subtitle>Reference Guide</subtitle> - <releaseinfo>3.1 beta 8</releaseinfo> + <releaseinfo>3.1 beta 9</releaseinfo> <mediaobject> <imageobject> @@ -59,12 +59,11 @@ complete set of ORM annotations, including EJB3 standard annotations as well as Hibernate3 extensions for cases not covered by the specification. Eventually you will be able to create all possible mappings with - annotations. See the <xref linkend="compliance" /> section for more - information.</para> + annotations. See the JIRA road mapsection for more information.</para> <para>The EJB3 Public final draft has change some annotations, please - refer to http://www.hibernate.org/371.html as a migration guide between Hibernate Annotations 3.1beta7 - and 3.1beta8.</para> + refer to http://www.hibernate.org/371.html as a migration guide between + Hibernate Annotations 3.1beta7 and 3.1beta8.</para> </preface> &setup; @@ -75,299 +74,4 @@ &lucene; - <appendix> - <title id="compliance">Compliance and limitations</title> - - <para>Issue tracking numbers can be looked up in JIRA on - http://www.hibernate.org/ if you want to verify the current state.</para> - - <synopsis>3.1beta8 Preview (20-01-2006) ------------------------------ -** Bug - * [ANN-132] - transient fields are considered to be persistent when not annotated with @Transient - * [ANN-162] - OneToMany mapping from annotated to hbm loaded class fails with infinite loop - * [ANN-175] - extractType executed on @Transient and fail when the return type is <T extends MembershipData> T - * [ANN-176] - Endless loop when annotated class references by ManyToOne class mapped in .hbm.xml - * [ANN-177] - unable to use referencedColumnName = joined subclass primary column name - * [ANN-178] - Different handling column naming with @JoinColumn between 3.1beta5 and 3.1beta7 - * [ANN-180] - Indexed collection, field access, onetomany+mappedby seems to fail - * [ANN-187] - Unable to referenceColumnName a column (property) of the super class - * [ANN-193] - @IdClass should work on @MappedSuperclass - * [ANN-199] - NPE when mappedBy property is wrong on a @OneToOne - * [ANN-214] - Annotation website documentation syntax error - -** New Feature - * [ANN-147] - Allow embeddable subclasses in the middle of a class hierarchy - * [ANN-172] - Delegates the SQL type of enum to @Enumerated - * [ANN-188] - @Email for validator - * [ANN-190] - @TableGenerator as per the pfd instead of @GeneratorIdTable & co - * [ANN-191] - Non entity classes in between entity classes in the hierarchy - * [ANN-200] - Support of @Basic, @Lob, @Enumerated, @Temporal as per the PFD - * [ANN-209] - @Named(Native)Query(hints=...) - - -** Improvement - * [ANN-17] - Support dotted annotation when declaring resultsets - * [ANN-56] - @AccessType: Support mixed field/property access strategies for an Entity - * [ANN-192] - Access type guessed from position of @Id or @EmbeddedId - * [ANN-194] - Access type guessed from owner entity for Embeddable objects - * [ANN-198] - Better error message when @ManyToOne references an unknown entity - * [ANN-201] - Rename @EmbeddableSuperclass into @MappedSuperclass - * [ANN-203] - Move to @Id @GeneratedValue(strategy=AUTO, generator="blah") - * [ANN-204] - @TableGenerator instead of @TableGenerator and @GeneratedIdTable - * [ANN-205] - @NamedQuery(query=...) instead of @NamedQuery(queryString=...) same for @NamedNativeQuery - * [ANN-215] - Support SqlResutSetMapping with dotted notation in arbitrary order - * [ANN-216] - Support scalar queries through @ColumnResult - * [ANN-218] - @SecondaryTable(PrimaryKeyJoinColumn[] pkJoinColumns) instead of @SecondaryTable(JoinColumn[] joins() ) - * [ANN-219] - @JoinTable(name, catalog, schema, uniqueConstraints) instead of @JoinTable(table=@Table()) - * [ANN-220] - @Column(table=) and @JoinColumn(table=) instead of @Column(secondaryTable=) - * [ANN-221] - @Inheritance(strategy), @DiscriminatorColumn(discriminatorType), @DiscriminatorValue instead of @Inheritance - * [ANN-225] - @EntityListeners replace @EntityListener - -3.1beta7 Preview (13-12-2005) ------------------------------ - -** Bug - * [ANN-114] - NPE when SecondaryTable uses a non pk reference column in @JoinColumn - * [ANN-115] - @Index does not work on joincolumns - * [ANN-117] - setOrphanDelete not set causing some delete-orphan .clear() to fail - * [ANN-123] - Support for Generics superclass - * [ANN-124] - FIELD constant thing is wrong in the doc - * [ANN-133] - Bytecode enhancement process adds non-transient properties to beans - * [ANN-135] - Inconsistent range check between Range Validator class and generated DDL. - * [ANN-136] - Validator annotations not applied to the hibernate metamodel for id properties - * [ANN-139] - SINGLE_TABLE inheritance raise an WrongClassException under certain circumstances - * [ANN-142] - Automatic Generation of Composite IDs - Annonation declaration fails - * [ANN-151] - <subclass extends= broken when using AnnotationConfiguration - * [ANN-152] - Indexes generated by the LuceneEventListener are deleted at startup (Mattias Arbin) - * [ANN-156] - MapKey Cannot Map @Id when using @IdClass - * [ANN-165] - @Length(min=4) ie wo max generate a varchar(Integer.MAX_VALUE) - * [ANN-171] - Class cast exception during processing of non getter generic methods - * [ANN-173] - ClassValidator.getInvalidValues should not depend on equals() for circularity check - -** New Feature - * [ANN-111] - add function for validating properties before bean creation - * [ANN-116] - fetch validators from implemented interfaces - * [ANN-125] - Validator does not preserve method hierarchy in InvalidValue[] - * [ANN-127] - Add @Future - * [ANN-128] - Externalize EJB3 namings to NamingStrategy - - -** Improvement - * [ANN-119] - Embedded international error messages - * [ANN-121] - Named Queries should be package level visible - * [ANN-126] - mention usage of columnDefinition as part of @Column in docs - * [ANN-138] - Support collections of value types with separate annotation - * [ANN-148] - EnumType should be aware of DababaseMetadata.storesUpperCaseIdentifiers() and co (Tim Fennell) - * [ANN-149] - Do not check lazy/uninitialized fields in Validator - * [ANN-153] - Customize the parent directory for indexes generated by LuceneEventListener (Mattias Arbin) - * [ANN-154] - Customize Analyzer subclass for the LuceneEventListener (Mattias Arbin) - * [ANN-168] - @FilterDef should support condition - * [ANN-170] - Keep user order of hbm files (to ease the typedef usage) - - -3.1beta6 Preview (06-10-2005) ------------------------------ - * ANN-105 More exception handling in AnnotationConfiguration - * ANN-109 @Index does not support join columns references - * ANN-93 Make Hibernate Validator Serializable Friendly - -3.1beta5 Preview (14-09-2005) ------------------------------ - * ANN-70 Lucene integration - * ANN-13 Support for referencedColumnName referencing non PK columns for @ManyToMany - * ANN-63 Use metadata.getUserName() when guessing Enum backing type (Scott Haug) - * ANN-38 Finish the optional=false support - * ANN-69 Expand the resource bundle message itself in the Validator framework - * ANN-68 Apply validator on a particular property (Jesus Marin) - * ANN-41 Allow field validations and validate private method (Chris Wood) - * ANN-75 Support named (native) query parameters (from Carlos Gonzalez) - * ANN-73 Use an eager strategy for the second join of a ManyToMany - * ANN-74 Allow configuration artefacts (hbm, classes) loading precedence - * ANN-79 Support collection of composite elements - * ANN-19 Annotations should support collections of primitive and core types - * ANN-77 Support primitive arrays - * ANN-20 Support dotted annotation when using overriding (Alexei Akhounov) - * ANN-55 @Proxy annotation should take proxyClass argument - * ANN-2 Bidirectional true @OneToOne - * ANN-80 @NotFound(action=NotFoundAction.IGNORE) - * ANN-57 @Table ignores unique contraint in association table - * ANN-3 Support of component inside SecondaryTable - * ANN-87 @InheritanceJoinColumn rename is incomplete - * ANN-81 ColumnDefinition not assigned when using @Column and @JoinColumn - * ANN-34 Second passes binded to HbmBinder.SecondPass - * NPE on Index and Unique constrains when column name has case inconsistency - * ANN-86 @Index not used on properties having no @Column - * ANN-49 Super class of Embeddable not mapped correctly (Alexei Akhounov) - * ANN-66 Null enums don't store to database correctly - * ANN-65 Validator ignores components (the DDL still ignores it) - * ANN-60 NPE when @EmbeddableSuperclass has a superclass @Entity - * ANN-90 mention usage of @Column together with @Id explicitly - * ANN-18 Document bean-level validator mecanism - -3.1beta4 Preview (04-08-2005) ------------------------------ - * ANN-54 EnumType fails to find the Enum in setParameterValues(Properties) - * ANN-32 Support index creation - * ANN-22 Hibernate 3 Annotations should support all Id generators - * ANN-51 redeclaring id in entity subclass raises ClassCastException - * ANN-43 @MapKey throw exception if key is id or a component subproperty - * ANN-52 Exception when @OrderBy contains the id property or a component subproperty - * ANN-13 Support for referencedColumnName referencing non PK columns for @ManyToOne, @OneToOne and @OneToMany - * ANN-46 Raise a warning on @Filter on subclasses - * ANN-48 @UniqueConstraint reorders columns (Chris Wood) - * ANN-6 enum did not worked for enums persisted in string based columns (MySql and Oracle) - * ANN-8 array of primitive no longer create a non null column - * ANN-45 Proper support for @Basic byte[] - * ANN-44 Don't mandate to list embedded superclasses - * ANN-42 Don't mandate resultset to be defined before named native queries - * ANN-11 More robust support for enum persistence (wider range of SQL types) - * HBX-307 Remove @Serialized and support @Lob tagging of a serializable type - -3.1beta3 (24-06-2005) ------------------------------ - * Rename @AssociationTable to @JoinTable - * HBX-213 support of @IdClass - * change targetEntity from String to Class - * HBX-305 Support Java5 Enums - * Add @Basic(optional=false) and Lob(optional=false) - * HBX-284 AnnotationOverride in inheritance in conjunction with @EmbeddedSuperclass - * HBX-304 @AttributeOverride instead of @Embedded(override=@AttributeOverride) or @EmbeddedId(...) - * HBX-290 All collection binder exception now show the collection role - * HBX-299 Fix test suite error on MySql - * HBX-302 @MapKey(name="propertyName") to map a map using a property of the associated class as a map key - * HBX-201 @Formula on properties or fields. - * Support @EntityResult(discriminatorColumn) - * Relax List usage as per the spec (non indexed list are defaulted to bag semantic) - * HBX-300 enable HQL order by fragment using @javax.persistence.OrderBy - * HBX-298 FKs on association tables are forced not null - * HBX-297 Primitive types creates a non null constrained column if defaulted and not SINGLE_TABLE (HBX-301) - * HBX-287 @DiscriminatorFormula - * HBX-205 @OnDelete(action=OnDeleteAction.CASCADE) for joined subclasses and collections - * Change @OneToOne(usePkasFk=true) into @PrimaryKeyJoinColumn - * Rename @InheritanceJoinColumn/@InheritanceJoinColumns to @PrimaryKeyJoinColumn/@PrimaryKeyJoinColumns - * Support @Basic(temporalType=...) - * HBX-282 protect @ManyToMany from abusive not joined filters - * Align with @NamedNativeQuery/@NamedNativeQueries - * HBX-283 Better getter resolution - * HBX-75 Implicit inheritance join columns declaration in composite PK - * HBX-54 Explicit exception when @Id is missing - * HBX-210 Fix NPE when the @Id was on the superclass of the root entity in conjonction with @OneToOne use - * HBX-280/HBX-157 Support @EmbeddabledSuperclass - -3.0beta2 Preview (26-05-2005) ------------------------------ - * Add the validate framework and bind it to the annotation binder. - * HBX-199 Support @Columns and thus multi-column properties (ie composite user types) - * HBX-206 Support @OrderBy and @Sort - * HBX-203/HBX-81 Support Hibernate cascade strategies through @Cascade (Pablo Nussembaum) - * HBX-47 Persist is cascaded on flush operation when using the EJB3 event listeners - * HBX-125 Support for named native SQL queries (not Scalar results) - * HBX-225 @Type annotation now work for @Id and @Version (Pablo Nussembaum, Emmanuel Bernard) - * HBX-248 TABLE_PER_CLASS no longer limited to leaf entities and use union-subclass as its strategy - * HBX-186 inheritance strategy no longer have to be defined on every entity (only on root entry) - * HBX-53 Annotated classes can be defined in any arbitrary order - * Support Array through @IndexColumn (Anthony Patricio) - * HBX-216 Ignore static fields and properties - * HBX-229/HBX-134 Filter javac generated methods that compensate type erasure aka bridge method (Rogo Gatto) - * HBX-184 Support List mappings through @IndexColumn (Matthiew Inger, Emmanuel Bernard) - * HBX-187 Move to a CollectionBinder structure (Matthiew Inger, Emmanuel Bernard) - * Fix of CascadeType.REMOVE - -3.0beta1 Preview (07-04-2005) based on the EJB3 Early Draft 2 -------------------------------------------------------------- - * support parameters in @Type (HBX-197) - * support @TypeDef at package and class level - * HBX-166 support @Lob for Character[],char[], String, byte[] and Byte[] (experimental) - * HBX-159/HBX-140 add @Filter(s) and @FilterDef(s) (Matthew Inger, Magnus Sandberg) - * HBX-44 @OneToOne support composite PK - * @OneToOne is supported except for true bidirectional @OneToOne - * Add @Cache annotation: allow to define caching on root entities and on collections (,eg @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL, region="specificCacheRegion") ) - * Support @OneToMany default (ie using an association table) - * HBX-164 insertable/updatable of @JoinColumn now work in @ManyToOne processing (Mario Ivankovits, Emmanuel Bernard) - * HBX-153 @Id(generate=GeneratorType.AUTO, generator="my_potential_sequence") now work (Pablo Nussembaum) - * Support @ManyToMany wo @AssociationTable (ie defaults) - * Support @ManyToMany(mappedBy) - * Support @OneToMany(mappedBy) (no JoinColumn needed on the @OneToMany side) - * Appropriate default value when no @JoinColumn is defined in a ManyToOne - * rename @GeneratorTable to @GeneratedIdTable - * rename CREATE to PERSIST, add REFRESH cascade style - * support Mapping Defaults for Non-Relationship Fields or Properties algorithm as defined in the EJB3 spec - * support @Serialized - * support @Lob for java.sql.Clob and java.sql.Blob - * allow embedded object declaration wo @Embeddable (if @Embedded or @EmbeddedId is present in the property) - * support for @EmbeddedId - * rename DependentAttribute to AttributeOverride, Dependent to Embedded and DependentObject to Embeddable - * support @ManyToOne in embedded objects - * support for @NamedQuery and @NamedQueries (EJBQL) - * move javax.ejb.* into javax.persistence.* and update copyright header - -3.0alpha3 (28-02-2005) ----------------------- -* HBX-116 Support for Where clause in classes and collections @Where(clause="") -* HBX-115 Support for class proxying configuration: @Proxy(lazy=false, proxyClassName="my.Interface") -* HBX-88 Support for hibernate type abstraction through @Type (only on basic properties for now) -* HBX-108 Support @BatchSize(size=n) for entities and collections -* HBX-107 implements @org.hibernate.annotations.Entity -* HBX-103 handle abstract classes -* HBX-83 precision & scale support for column (Bogdan Ghidireac) - -3.0alpha2 (25-01-2005) ----------------------- -* HBX-61 Support for @UniqueConstraint (except primaryKey=true) -* HBX-60 Support for a proper @TableGenerator (using MultipleHiLoPerTableGenerator) -* HBX-63 Support @GeneratorTable -* HBX-68 Add declarative configuration of annotated classes -* HBX-74 Rollback the HB-1315 fix: dialect no longer have to be set in hibernate.properties - - -Hibernate-annotations-3.0alpha1 based on the EJB3 Early Draft 1 (6.01.2005) ---------------------------------------------------------------------------- -* Support for EJB3 annotations: - - @Transient - - @Column (not primaryKey) - - @JoinColumn (referencedColumnName - only for a reference to a PK, not primaryKey) - - @Version - - @Basic - - @Entity - - @Table (not uniqueConstraints) - - @AccessType - - @Id - - @CascadeType - - @FetchType - - @GeneratorType (NONE, IDENTITY, TABLE, SEQUENCE) - - @TableGenerator (with scope visibility) - - @SequenceGenerator (with scope visibility, does not support initialValue() and allocationSize()) - - *not* @GeneratorTable (will have to write a new TableHiloGenerator, but it can wait) - - @ManyToOne (not optional) - - @OneToMany (Set and Collection, generics version or not, JoinColumn not guessed) - - @OneToOne - but not optional - no composite PK/FK - - @ManyToMany - - @AssociationTable (Has to be on both sides) - - @Inheritance - - @InheritanceType (has to be defined on every classes of the hierarchy for JOINED strategy, - not very clear about the TABLE_PER_CLASS strategy) - - @DiscriminatorColumn - - @DiscriminatorType - - @InheritanceJoinColumn - - @InheritanceJoinColumns - this annotation for Composite PK Entities has to be explicit, I do not respect the implicit semantic of the EJB3 spec - - @SecondaryTable (@OneToMany @JoinColumn(secondaryTable="..." does not work yet due to H3 core issue HHH-36 - - @SecondaryTables - this annotation for Composite PK Entities has to be explicit, I do not respect the implicit semantic of the EJB3 spec - - @DependentObject - - @Dependent - - @DependentAttribute (only for basic properties as per the spec) - - @Id in conjunction with @DependentObject (composite primary keys) - - @JoinColumns in conjunction with @ManytoOne, @OneToMany, @ManytoMany - - note that the composite FK columns have to be in the same table (no != secondary tables). This is probably a weird case and certainly a not recommanded one. - - -Still missing or incomplete features compared to the EJB3 spec --------------------------------------------------------------- - - support for initialValue and allocationSize in @SequenceGenerator (HBX-59) -</synopsis> - </appendix> </book> \ No newline at end of file Modified: trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml =================================================================== --- trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml 2006-03-16 22:19:13 UTC (rev 9641) @@ -262,7 +262,7 @@ </listitem> <listitem> - <para>annotated with <literal>@Temporal</literal></para> + <para>annotated with <literal>@Temporal</literal></para> </listitem> <listitem> @@ -440,12 +440,11 @@ <para>The <literal>Person</literal> entity bean has two component properties, <literal>homeAddress</literal> and - <literal>bornIn</literal>. Note that the - <literal>homeAddress</literal> property has not been annotated. - Hibernate will guess that it is a persistent component by looking for - the <literal>@Embeddable</literal> annotation in the Address class. We - also override the mapping of a column name (to - <literal>bornCountryName</literal>) with the + <literal>bornIn</literal>. <literal>homeAddress</literal> property has + not been annotated, but Hibernate will guess that it is a persistent + component by looking for the <literal>@Embeddable</literal> annotation + in the Address class. We also override the mapping of a column name + (to <literal>bornCountryName</literal>) with the <literal>@Embedded</literal> and <literal>@AttributeOverride </literal>annotations for each mapped attribute of <literal>Country</literal>. As you can see, <literal>Country @@ -469,10 +468,11 @@ properties persistent (see <literal>@MappedSuperclass</literal> for more informations).</para> - <para>You cannot use association annotations in an embeddable object - (ie no <literal>@*ToOne</literal> nor <literal>@*ToMany</literal>). - This is disallowed by the spec, and not yet supported in Hibernate - Annotations.</para> + <para>While not supported by the EJB3 specification, Hibernate + Annotations allows you to use association annotations in an embeddable + object (ie <literal>@*ToOne</literal> nor + <literal>@*ToMany</literal>). To override the association columns you + can use <literal>@AssociationOverride</literal>.</para> <para>If you want to have the same embeddable object type twice in the same entity, the column name defaulting will not work: at least one of @@ -706,6 +706,27 @@ <para>As you may have seen, <literal>@IdClass</literal> points to the corresponding primary key class.</para> + + <para>While not supported by the EJB3 specification, Hibernate allows + you to define associations inside a composite identifier. Simply use the + regular annotations for that</para> + + <programlisting>@Entity +@AssociationOverride( name="id.channel", joinColumns = @JoinColumn(name="chan_id") ) +public class TvMagazin { + @EmbeddedId public TvMagazinPk id; + @Temporal(TemporalType.TIME) Date time; +} + +@Embeddable +public class TvMagazinPk implements Serializable { + @ManyToOne + public Channel channel; + public String name; + @ManyToOne + public Presenter presenter; +} +</programlisting> </sect2> <sect2> @@ -789,11 +810,12 @@ <literal>@DiscriminatorValue</literal> annotation defines the value used to differentiate a class in the hierarchy. All of these attributes have sensible default values. The default name of the - discriminator column is <literal>TYPE</literal>, and (for Hibernate) - the default discriminator value is the fully qualified class name. + discriminator column is <literal>DTYPE</literal>. The default + discriminator value is the entity name (as defined in + <literal>@Entity.name</literal>) for DiscriminatorType.STRING. <classname>A320</classname> is a subclass; you only have to define discriminator value if you don't want to use the default value. The - strategy and the discriminator type is implicit.</para> + strategy and the discriminator type are implicit.</para> <para><literal>@Inheritance</literal> and <literal>@DiscriminatorColumn</literal> should only be defined at the @@ -903,18 +925,32 @@ public int getMetricAltitude() { return metricAltitude; } + + @ManyToOne + public PropulsionType getPropulsion() { + return metricAltitude; + } ... } @Entity @AttributeOverride( name="altitude", column = @Column(name="fld_altitude") ) +@AssociationOverride( name="propulsion", joinColumns = @JoinColumn(name="fld_propulsion_fk") ) public class Plane extends FlyingObject { ... }</programlisting> <para>The <literal>altitude</literal> property will be persisted in an <literal>fld_altitude</literal> column of table - <literal>Plane</literal>.</para> + <literal>Plane</literal> and the propulsion association will be + materialized in a <literal>fld_propulsion_fk</literal> foreign key + column.</para> + + <para>You can define <literal>@AttributeOverride</literal>(s) and + <literal>@AssociationOverride</literal>(s) on + <literal>@Entity</literal> classes, + <literal>@MappedSuperclass</literal> classes and properties pointing + to an <literal>@Embeddable</literal> object.</para> </sect3> </sect2> @@ -1026,7 +1062,7 @@ <programlisting> @Entity() public class Flight implements Serializable { - <emphasis role="bold">@ManyToOne</emphasis>( cascade = {CascadeType.CREATE, CascadeType.MERGE} ) + <emphasis role="bold">@ManyToOne</emphasis>( cascade = {CascadeType.PERSIST, CascadeType.MERGE} ) @JoinColumn(name="COMP_ID") public Company getCompany() { return company; @@ -1053,7 +1089,7 @@ <programlisting> @Entity() public class Flight implements Serializable { - @ManyToOne( cascade = {CascadeType.CREATE, CascadeType.MERGE}, <emphasis + @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE}, <emphasis role="bold">targetEntity=CompanyImpl.class</emphasis> ) @JoinColumn(name="COMP_ID") public Company getCompany() { @@ -1406,7 +1442,7 @@ public class Employer implements Serializable { @ManyToMany( targetEntity=org.hibernate.test.metadata.manytomany.Employee.class, - cascade={CascadeType.CREATE, CascadeType.MERGE} + cascade={CascadeType.PERSIST, CascadeType.MERGE} ) @JoinTable( name="EMPLOYER_EMPLOYEE", @@ -1424,7 +1460,7 @@ @Entity public class Employee implements Serializable { @ManyToMany( - cascade={CascadeType.CREATE, CascadeType.MERGE}, + cascade={CascadeType.PERSIST, CascadeType.MERGE}, mappedBy="employees" targetEntity=Employer.class ) @@ -1851,8 +1887,9 @@ <para>You can also map a native query (ie a plain SQL query). To achieve that, you need to describe the SQL resultset structure using - <literal>@SqlResultSetMapping</literal>. Like - <literal>@NamedQuery</literal>, a + <literal>@SqlResultSetMapping</literal> (or + <literal>@SqlResultSetMappings</literal> if you plan to define several + resulset mappings). Like <literal>@NamedQuery</literal>, a <literal>@SqlResultSetMapping</literal> can be defined at both package level or class level. However its scope is global to the application. As we will see, a <literal>resultSetMapping</literal> parameter is defined @@ -1870,14 +1907,14 @@ + "from Night night, Area area where night.area_id = area.id", <emphasis role="bold">resultSetMapping="joinMapping"</emphasis>) @SqlResultSetMapping(name="joinMapping", entities={ - @EntityResult(name="org.hibernate.test.annotations.query.Night", fields = { + @EntityResult(entityClass=org.hibernate.test.annotations.query.Night.class, fields = { @FieldResult(name="id", column="nid"), @FieldResult(name="duration", column="night_duration"), @FieldResult(name="date", column="night_date"), @FieldResult(name="area", column="area_id"), discriminatorColumn="disc" }), - @EntityResult(name="org.hibernate.test.annotations.query.Area", fields = { + @EntityResult(entityClass=org.hibernate.test.annotations.query.Area.class, fields = { @FieldResult(name="id", column="aid"), @FieldResult(name="name", column="name") }) @@ -1892,7 +1929,7 @@ see an implicit declaration of the property / column.</para> <programlisting>@Entity -<emphasis role="bold">@SqlResultSetMapping(name="implicit", entities=@EntityResult(name="org.hibernate.test.annotations.query.SpaceShip")) +<emphasis role="bold">@SqlResultSetMapping(name="implicit", entities=@EntityResult(entityClass=org.hibernate.test.annotations.query.SpaceShip.class)) @NamedNativeQuery(name="implicitSample", query="select * from SpaceShip", resultSetMapping="implicit")</emphasis> public class SpaceShip { private String name; @@ -1938,7 +1975,7 @@ <programlisting>@Entity @SqlResultSetMapping(name="compositekey", - entities=@EntityResult(name="org.hibernate.test.annotations.query.SpaceShip", + entities=@EntityResult(entityClass=org.hibernate.test.annotations.query.SpaceShip.class, fields = { @FieldResult(name="name", column = "name"), @FieldResult(name="model", column = "model"), @@ -1955,7 +1992,6 @@ query="select name, model, speed, lname as lastn, fname as firstn, length, width, length * width as surface from SpaceShip", resultSetMapping="compositekey") } ) -//we're missins @SqlREsultSetMappings so look at Captain public class SpaceShip { private String name; private String model; @@ -2147,17 +2183,24 @@ joined subclasses: use a SQL cascade delete on deletion instead of the regular Hibernate mechanism.</para> - <para><literal>@Table(name="tableName", indexes = { + <para><literal>@Table(appliesTo="tableName", indexes = { @Index(name="index1", columnNames={"column1", "column2"} ) } )</literal> - creates the defined indexes on the columns of table tableName. This can - be applied on the primary table or any secondary table. The - <literal>@Tables</literal> annotation allows your to apply indexes on - different tables. This annotation is expected where - <literal>@javax.persistence.Table</literal> or - <literal>@javax.persistence.SecondaryTable</literal>(s) occurs. - <literal>@org.hibernate.annotations.Table</literal> is a complement, not - a replacement to <literal>@javax.persistence.Table</literal></para> + creates the defined indexes on the columns of table + <literal>tableName</literal>. This can be applied on the primary table + or any secondary table. The <literal>@Tables</literal> annotation allows + your to apply indexes on different tables. This annotation is expected + where <literal>@javax.persistence.Table</literal> or + <literal>@javax.persistence.SecondaryTable</literal>(s) occurs. </para> + <note> + <para><literal>@org.hibernate.annotations.Table</literal> is a + complement, not a replacement to + <literal>@javax.persistence.Table</literal>. Especially, if you want + to change the default name of a table, you must use + <literal>@javax.persistence.Table</literal>, not + <literal>@org.hibernate.annotations.Table</literal>. </para> + </note> + <para><programlisting>@Entity @BatchSize(size=5) @org.hibernate.annotations.Entity( @@ -2418,7 +2461,7 @@ </sect2> <sect2> - <title>Association related annotations</title> + <title>Single Association related annotations</title> <para>By default, when Hibernate cannot resolve the association because the expected associated element is not in database (wrong id on the @@ -2438,6 +2481,21 @@ public Parent getParent() { ... } ... }</programlisting> + + <para>Sometimes you want to delegate to your database the deletion of + cascade when a given entity is deleted.</para> + + <programlisting>@Entity +public class Child { + ... + @ManyToOne + @OnDelete(action=OnDeleteAction.CASCADE) + public Parent getParent() { ... } + ... +}</programlisting> + + <para>In this case Hibernate generates a cascade delete constraint at + the database level.</para> </sect2> <sect2 id="entity-hibspec-collection" revision="2"> Modified: trunk/HibernateExt/metadata/doc/reference/en/modules/setup.xml =================================================================== --- trunk/HibernateExt/metadata/doc/reference/en/modules/setup.xml 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/doc/reference/en/modules/setup.xml 2006-03-16 22:19:13 UTC (rev 9641) @@ -12,13 +12,13 @@ </listitem> <listitem> - <para><emphasis>This preview release requires Hibernate 3.1.1 and + <para><emphasis>This preview release requires Hibernate 3.2alpha2 and above. Do not use this release of Hibernate Annotations with an older version of Hibernate 3.x!</emphasis></para> </listitem> <listitem> - <para>This release is known to work on Hibernate core 3.1.1</para> + <para>This release is known to work on Hibernate core 3.2alpha2</para> </listitem> <listitem> Modified: trunk/HibernateExt/metadata/doc/reference/en/modules/validator.xml =================================================================== --- trunk/HibernateExt/metadata/doc/reference/en/modules/validator.xml 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/doc/reference/en/modules/validator.xml 2006-03-16 22:19:13 UTC (rev 9641) @@ -52,8 +52,6 @@ covers most basic data checks. As we'll see later, you're not limited to them, you can in a minute write your own constraints.</para> - <para></para> - <table> <title>Built-in constraints</title> @@ -197,11 +195,24 @@ <entry>property (object)</entry> - <entry>Perform validation recursively on the associated - object</entry> + <entry>perform validation recursively on the associated object. + If the object is a Collection or an array, the elements are + validated recursively. If the object is a Map, the value + elements are validated recursively.</entry> <entry>none</entry> </row> + + <row> + <entry>@Email</entry> + + <entry>property (String)</entry> + + <entry>check whether the string is conform to the email address + specification</entry> + + <entry>none</entry> + </row> </tbody> </tgroup> </table> @@ -238,7 +249,7 @@ @Retention(RUNTIME) @Documented public @interface Capitalized { - CapitalizeType type default Capitalize.FIRST; + CapitalizeType type() default Capitalize.FIRST; String message() default "has incorrect capitalization"; }</programlisting> @@ -262,7 +273,7 @@ @Retention(RUNTIME) @Documented public @interface Capitalized { - CapitalizeType type default Capitalize.FIRST; + CapitalizeType type() default Capitalize.FIRST; String message() default "{validator.capitalized}"; } @@ -284,7 +295,7 @@ constraint at the database level (by implementing <literal>PersistentClassConstraint</literal>).</para> - <programlisting>public class LengthValidator + <programlisting>public class CapitalizedValidator implements Validator<Capitalized>, PropertyConstraint { private CapitalizeType type; @@ -510,14 +521,14 @@ individual issues.</para> <para><methodname>getBeanClass()</methodname> retrieves the failing bean - type </para> + type</para> <para><methodname>getBean()</methodname>retrieves the failing instance (if any ie not when using - <methodname>getPotentianInvalidValues()</methodname>) </para> + <methodname>getPotentianInvalidValues()</methodname>)</para> - <para><methodname>getValue()</methodname> retrieves the failing value - </para> + <para><methodname>getValue()</methodname> retrieves the failing + value</para> <para><methodname>getMessage()</methodname> retrieves the proper internationalized error message</para> Modified: trunk/HibernateExt/metadata/lib/ejb3-persistence.jar =================================================================== (Binary files differ) Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazin.java =================================================================== --- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazin.java 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazin.java 2006-03-16 22:19:13 UTC (rev 9641) @@ -6,11 +6,14 @@ import javax.persistence.EmbeddedId; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import javax.persistence.AssociationOverride; +import javax.persistence.JoinColumn; /** * @author Emmanuel Bernard */ @Entity +@AssociationOverride( name="id.channel", joinColumns = @JoinColumn(name="chan_id") ) public class TvMagazin { @EmbeddedId public TvMagazinPk id; @Temporal(TemporalType.TIME) Date time; Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazinPk.java =================================================================== --- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazinPk.java 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazinPk.java 2006-03-16 22:19:13 UTC (rev 9641) @@ -4,7 +4,6 @@ import java.io.Serializable; import javax.persistence.Embeddable; import javax.persistence.ManyToOne; -import javax.persistence.JoinColumn; /** * @author Emmanuel Bernard @@ -12,7 +11,6 @@ @Embeddable public class TvMagazinPk implements Serializable { @ManyToOne - @JoinColumn(name="chan_id") public Channel channel; public String name; @ManyToOne Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java =================================================================== --- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java 2006-03-16 22:19:13 UTC (rev 9641) @@ -14,7 +14,8 @@ Transaction tx = s.beginTransaction(); Gene item = new Gene(); s.persist( item ); - tx.commit(); + s.flush(); + tx.rollback(); s.close(); } |