From hibernate-commits at lists.jboss.org Sun Nov 1 03:17:27 2009 Content-Type: multipart/mixed; boundary="===============5189922184697332152==" MIME-Version: 1.0 From: boss To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] get back to my office for more details Date: Sun, 01 Nov 2009 10:16:19 +0200 Message-ID: <000d01ca5acb$975d3750$6400a8c0@gushesgv09> --===============5189922184697332152== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Please read the attached letter and get back to my office for more details = to proceed further. Thanks and have a very nice day. --===============5189922184697332152==-- From hibernate-commits at lists.jboss.org Sun Nov 1 09:31:50 2009 Content-Type: multipart/mixed; boundary="===============1580536503066567992==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17885 - search/trunk/src/main/docbook/en-US/modules. Date: Sun, 01 Nov 2009 09:31:50 -0500 Message-ID: <200911011431.nA1EVoU6008441@svn01.web.mwc.hst.phx2.redhat.com> --===============1580536503066567992== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-01 09:31:50 -0500 (Sun, 01 Nov 2009) New Revision: 17885 Modified: search/trunk/src/main/docbook/en-US/modules/mapping.xml Log: HSEARCH-324 Added documentation for dynamic boost Modified: search/trunk/src/main/docbook/en-US/modules/mapping.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/docbook/en-US/modules/mapping.xml 2009-10-30 13:5= 8:05 UTC (rev 17884) +++ search/trunk/src/main/docbook/en-US/modules/mapping.xml 2009-11-01 14:3= 1:50 UTC (rev 17885) @@ -33,9 +33,9 @@ through annotations. There is no need for xml mapping files. In fact the= re is currently no xml configuration option available (see HSEARCH-210). - You can still use hibernate mapping files for the basic Hibernate - configuration, but the Search specific configuration has to be expressed= via - annotations. + You can still use Hibernate mapping files for the basic Hibernate + configuration, but the Hibernate Search specific configuration has to be + expressed via annotations. =
Mapping an entity @@ -73,9 +73,9 @@ = For each property (or attribute) of your entity, you have the ability to describe how it will be indexed. The default (no annotati= on - present) means that the property is completely ignored by the indexi= ng - process. @Field does declare a property as indexe= d. - When indexing an element to a Lucene document you can specify how it= is + present) means that the property is ignored by the indexing process. + @Field does declare a property as indexed. When + indexing an element to a Lucene document you can specify how it is indexed: = @@ -181,9 +181,10 @@ = Whether or not you want to tokenize a property depends on whet= her you wish to search the element as is, or by the words it contains. It - make sense to tokenize a text field, but tokenizing a date field - probably not. Note that fields used for sorting must not be - tokenized. + make sense to tokenize a text field, but probably not a date field. + + Fields used for sorting must not be tokenized. + = Finally, the id property of an entity is a special property us= ed by Hibernate Search to ensure index unicity of a given entity. By @@ -193,7 +194,7 @@ can omit @DocumentId. The chosen entity id will also be used as docu= ment id. = - + Adding <classname>@DocumentId</classname> ad <classname>@Field</classname> annotations to an indexed entity</ti= tle> = @@ -215,8 +216,8 @@ }</programlisting> </example> = - <para>The above annotations define an index with three fields: - <literal>id</literal> , <literal>Abstract</literal> and + <para><xref linkend=3D"example-annotated-entity" /> define an index = with + three fields: <literal>id</literal> , <literal>Abstract</literal> and <literal>text</literal> . Note that by default the field name is decapitalized, following the JavaBean specification</para> </section> @@ -231,7 +232,7 @@ index it twice - once tokenized and once untokenized. @Fields allows= to achieve this goal.</para> = - <example> + <example id=3D"example-fields-annotation"> <title>Using @Fields to map a property multiple times = @Entity @@ -249,7 +250,8 @@ } = - The field summary is indexed twice, once as + In the field + summary is indexed twice, once as summary in a tokenized way, and once as summary_forSort in an untokenized way. @Field supports 2 attributes useful when @Fields is used: @@ -514,7 +516,7 @@
= -
+
Boost factor = Lucene has the notion of boost factor. It= 's a @@ -565,6 +567,63 @@ from Otis Gospodnetic and Erik Hatcher.
= +
+ Dynamic boost factor + + The @Boost annotation used in defines a static boost factor + which is is independent of the state of of the indexed entity at + runtime. However, there are usecases in which the boost factor may + depends on the actual state of the entity. In this case you can use = the + @DynamicBoost annotation together with an + accompanying custom BoostStrategy. + Dynamic boost examle + + public enum PersonType { + NORMAL, + VIP +} + +(a)Entity +(a)Indexed +@DynamicBoost(impl =3D VIPBoostStrategy.class) +public class Person { + private PersonType type; = + = + // .... +} + +public class VIPBoostStrategy implements BoostStrategy { + public float defineBoost(Object value) { + Person person =3D ( Person ) value; + if ( person.getType().equals( PersonType.VIP ) ) { + return 2.0f; + } + else { + return 1.0f; + } + } +} + In a dynam= ic + boost is defined on class level specifying + VIPBoostStrategy as implementation of the + BoostStrategy interface to be used at indexing + time. You can place the @DynamicBoost either at c= lass + or field level. Depending on the placement of the annotation either = the + whole entity is passed to the defineBoost + method or just the annotated field/property value. It's up to you to + cast the passed object to the correct type. In the example all index= ed + values of a VIP person would be double as important as the values of= a + normal person. + The specified BoostStrategy + implementation must define a public no-arg constructor. + Of course you can mix and match @Boost a= nd + @DynamicBoost annotations in your entity. All def= ined + boost factors are cummulative as described in . +
+
Analyzer = --===============1580536503066567992==-- From hibernate-commits at lists.jboss.org Sun Nov 1 09:51:49 2009 Content-Type: multipart/mixed; boundary="===============8256534025510646518==" MIME-Version: 1.0 From: boss To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] get back to my office for more details Date: Sun, 01 Nov 2009 09:50:42 -0500 Message-ID: <000d01ca5b02$af954ce0$6400a8c0@songsterst5> --===============8256534025510646518== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Please read the attached letter and get back to my office for more details = to proceed further. Thanks and have a very nice day. --===============8256534025510646518==-- From hibernate-commits at lists.jboss.org Mon Nov 2 04:03:09 2009 Content-Type: multipart/mixed; boundary="===============2260572830530949820==" MIME-Version: 1.0 From: boss To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] get back to my office for more details Date: Mon, 02 Nov 2009 18:02:34 +0900 Message-ID: <000d01ca5b9b$37ed5680$6400a8c0@ecclesiasticsi0> --===============2260572830530949820== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Please read the attached letter and get back to my office for more details = to proceed further. Thanks and have a very nice day. --===============2260572830530949820==-- From hibernate-commits at lists.jboss.org Mon Nov 2 11:46:19 2009 Content-Type: multipart/mixed; boundary="===============1764848336435351465==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17886 - in core/trunk/entitymanager/src: test/java/org/hibernate/ejb/test/metadata and 1 other directory. Date: Mon, 02 Nov 2009 11:46:18 -0500 Message-ID: <200911021646.nA2GkImI020483@svn01.web.mwc.hst.phx2.redhat.com> --===============1764848336435351465== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-02 11:46:17 -0500 (Mon, 02 Nov 2009) New Revision: 17886 Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/S= taticMetadataTest.java Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Abstr= actIdentifiableType.java core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Metad= ataContext.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/A= nimal.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/C= at.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/C= attish.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/D= og.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/F= eline.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/T= hing.java Log: HHH-4202 - Implement JPA 2.0 metamodel APIs Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamode= l/AbstractIdentifiableType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Abst= ractIdentifiableType.java 2009-11-01 14:31:50 UTC (rev 17885) +++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Abst= ractIdentifiableType.java 2009-11-02 16:46:17 UTC (rev 17886) @@ -189,6 +189,10 @@ return isVersioned; } = + public boolean hasDeclaredVersionAttribute() { + return isVersioned && version !=3D null; + } + /** * {@inheritDoc} */ @@ -223,6 +227,16 @@ } = /** + * For used to retrieve the declared version when populating the static m= etamodel. + * + * @return The declared + */ + public SingularAttribute getDeclaredVersion() { + checkDeclaredVersion(); + return version; + } + + /** * Centralized check to ensure the version (if one) is actually declared = on the class mapped here, as opposed to a * super class. */ Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamode= l/MetadataContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Meta= dataContext.java 2009-11-01 14:31:50 UTC (rev 17885) +++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Meta= dataContext.java 2009-11-02 16:46:17 UTC (rev 17886) @@ -29,16 +29,17 @@ import java.util.Set; import java.util.List; import java.util.ArrayList; +import java.lang.reflect.Field; import javax.persistence.metamodel.Attribute; import javax.persistence.metamodel.SingularAttribute; -import javax.swing.*; +import javax.persistence.metamodel.IdentifiableType; = import org.hibernate.mapping.MappedSuperclass; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; +import org.hibernate.mapping.Component; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.annotations.common.AssertionFailure; -import org.hibernate.AnnotationException; = /** * Defines a context for storing information during the building of the {@= link MetamodelImpl}. @@ -163,6 +164,12 @@ Iterator properties =3D ( Iterator ) safeMapping.g= etDeclaredPropertyIterator(); while ( properties.hasNext() ) { final Property property =3D properties.next(); + if ( property.getValue() =3D=3D safeMapping.getIdentifierMapper() ) { + // property represents special handling for id-class mappings but we= have already + // accounted for the embedded property mappings in #applyIdMetadata = && + // #buildIdClassAttributes + continue; + } final Attribute attribute =3D attributeFactory.buildAttribute( jpa2Ma= pping, property, true ); jpa2Mapping.getBuilder().addAttribute( attribute ); } @@ -190,8 +197,13 @@ throw new AssertionFailure( "Unexpected mapping type: " + mapping.getC= lass() ); } } + + for ( EmbeddableTypeImpl embeddable : embeddables.values() ) { + populateStaticMetamodel( embeddable ); + } } = + private void applyIdMetadata(PersistentClass persistentClass, EntityT= ypeImpl jpaEntityType) { if ( persistentClass.hasIdentifierProperty() ) { final Property declaredIdentifierProperty =3D persistentClass.getDeclar= edIdentifierProperty(); @@ -289,13 +301,57 @@ private final Set processedMetamodelClasses =3D new HashSet= (); = private void registerAttributes(Class metamodelClass, AbstractManaged= Type managedType) { - if ( processedMetamodelClasses.add( metamodelClass ) ) { + if ( ! processedMetamodelClasses.add( metamodelClass ) ) { return; } = // push the attributes on to the metamodel class... + for ( Attribute attribute : managedType.getDeclaredAttributes() ) { + registerAttribute( metamodelClass, attribute ); + } + + if ( IdentifiableType.class.isInstance( managedType ) ) { + final AbstractIdentifiableType entityType =3D ( AbstractIdentifiable= Type ) managedType; + + // handle version + if ( entityType.hasDeclaredVersionAttribute() ) { + registerAttribute( metamodelClass, entityType.getDeclaredVersion() ); + } + + // handle id-class mappings specially + if ( ! entityType.hasSingleIdAttribute() ) { + final Set> attributes =3D entityType.g= etIdClassAttributes(); + if ( attributes !=3D null ) { + for ( SingularAttribute attribute : attributes ) { + registerAttribute( metamodelClass, attribute ); + } + } + } + } } = + private void registerAttribute(Class metamodelClass, Attribute = attribute) { + final String name =3D attribute.getName(); + try { + Field field =3D metamodelClass.getDeclaredField( name ); + field.setAccessible( true ); // should be public anyway, but to be sure= ... + field.set( null, attribute ); + } + catch ( NoSuchFieldException e ) { + // todo : exception type? + throw new AssertionFailure( + "Unable to locate static metamodel field : " + metamodelClass.getName= () + '#' + name + ); + } + catch ( IllegalAccessException e ) { + // todo : exception type? + throw new AssertionFailure( + "Unable to inject static metamodel attribute : " + metamodelClass.get= Name() + '#' + name, + e + ); + } + } + public MappedSuperclassTypeImpl locateMappedSuperclassType(MappedSuper= class mappedSuperclass) { return mappedSuperclassByMappedSuperclassMapping.get(mappedSuperclass); } Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/met= adata/Animal.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Animal.java 2009-11-01 14:31:50 UTC (rev 17885) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Animal.java 2009-11-02 16:46:17 UTC (rev 17886) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.ejb.test.metadata; = import javax.persistence.MappedSuperclass; Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/met= adata/Cat.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Cat.java 2009-11-01 14:31:50 UTC (rev 17885) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Cat.java 2009-11-02 16:46:17 UTC (rev 17886) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.ejb.test.metadata; = import javax.persistence.Entity; Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/met= adata/Cattish.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Cattish.java 2009-11-01 14:31:50 UTC (rev 17885) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Cattish.java 2009-11-02 16:46:17 UTC (rev 17886) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.ejb.test.metadata; = import javax.persistence.MappedSuperclass; Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/met= adata/Dog.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Dog.java 2009-11-01 14:31:50 UTC (rev 17885) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Dog.java 2009-11-02 16:46:17 UTC (rev 17886) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.ejb.test.metadata; = import javax.persistence.Entity; Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/met= adata/Feline.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Feline.java 2009-11-01 14:31:50 UTC (rev 17885) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Feline.java 2009-11-02 16:46:17 UTC (rev 17886) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.ejb.test.metadata; = import javax.persistence.Entity; Copied: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metad= ata/StaticMetadataTest.java (from rev 17885, core/trunk/entitymanager/src/t= est/java/org/hibernate/ejb/test/metadata/MetadataTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= StaticMetadataTest.java (rev 0) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= StaticMetadataTest.java 2009-11-02 16:46:17 UTC (rev 17886) @@ -0,0 +1,134 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.ejb.test.metadata; + +import java.util.Set; +import javax.persistence.metamodel.Attribute; +import javax.persistence.metamodel.Bindable; +import javax.persistence.metamodel.EmbeddableType; +import javax.persistence.metamodel.PluralAttribute; +import javax.persistence.metamodel.Type; + +import org.hibernate.ejb.test.TestCase; + +/** + * @author Steve Ebersole + */ +public class StaticMetadataTest extends TestCase { + + public void testInjections() throws Exception { + // Address (embeddable) + assertNotNull( Address_.address1 ); + assertNotNull( Address_.address2 ); + assertNotNull( Address_.city ); + final EmbeddableType
addressType =3D (EmbeddableType
) = House_.address.getType(); + assertEquals( addressType.getDeclaredSingularAttribute( "address1" ), Ad= dress_.address1 ); + assertEquals( addressType.getDeclaredSingularAttribute( "address2" ), Ad= dress_.address2 ); + assertTrue( Address_.address1.isOptional() ); + assertFalse( Address_.address2.isOptional() ); + + // Animal (mapped superclass) + assertNotNull( Animal_.id ); + assertTrue( Animal_.id.isId() ); + assertEquals( Long.class, Animal_.id.getJavaType() ); + assertNotNull( Animal_.legNbr ); + assertEquals( Integer.class, Animal_.legNbr.getJavaType() ); + + // Cat (hierarchy) + assertNotNull( Cat_.id ); + assertNotNull( Cat_.id.isId() ); + assertEquals( Animal.class, Cat_.id.getJavaMember().getDeclaringClass() = ); + assertNotNull( Cat_.nickname ); + + // FoodItem + assertNotNull( FoodItem_.version ); + assertTrue( FoodItem_.version.isVersion() ); + + // Fridge + assertNotNull( Fridge_.id ); + assertTrue( Fridge_.id.isId() ); + assertEquals( Long.class, Fridge_.id.getJavaType() ); + assertNotNull( Fridge_.temperature ); + assertEquals( "temperature", Fridge_.temperature.getName() ); + assertEquals( Fridge.class, Fridge_.temperature.getDeclaringType().getJa= vaType() ); + assertEquals( Integer.class, Fridge_.temperature.getJavaType() ); + assertEquals( Integer.class, Fridge_.temperature.getBindableJavaType() ); + assertEquals( Integer.class, Fridge_.temperature.getType().getJavaType()= ); + assertEquals( Bindable.BindableType.SINGULAR_ATTRIBUTE, Fridge_.temperat= ure.getBindableType() ); + assertEquals( Type.PersistenceType.BASIC, Fridge_.temperature.getType().= getPersistenceType() ); + assertEquals( Attribute.PersistentAttributeType.BASIC, Fridge_.temperatu= re.getPersistentAttributeType() ); + assertFalse( Fridge_.temperature.isId() ); + assertFalse( Fridge_.temperature.isOptional() ); + assertFalse( Fridge_.temperature.isAssociation() ); + assertFalse( Fridge_.temperature.isCollection() ); + assertFalse( Fridge_.brand.isOptional() ); + + // House (embedded id) + assertNotNull( House_.key ); + assertTrue( House_.key.isId() ); + assertEquals( Attribute.PersistentAttributeType.EMBEDDED, House_.key.get= PersistentAttributeType() ); + assertNotNull( House_.address ); + assertEquals( Attribute.PersistentAttributeType.EMBEDDED, House_.address= .getPersistentAttributeType() ); + assertFalse( House_.address.isCollection() ); + assertFalse( House_.address.isAssociation() ); + assertNotNull( House_.rooms ); + assertTrue( House_.rooms.isAssociation() ); + assertTrue( House_.rooms.isCollection() ); + assertEquals( Attribute.PersistentAttributeType.ELEMENT_COLLECTION, Hous= e_.rooms.getPersistentAttributeType() ); + assertEquals( Room.class, House_.rooms.getBindableJavaType() ); + assertEquals( Bindable.BindableType.PLURAL_ATTRIBUTE, House_.rooms.getBi= ndableType() ); + assertEquals( Set.class, House_.rooms.getJavaType() ); + assertEquals( PluralAttribute.CollectionType.SET, House_.rooms.getCollec= tionType() ); + assertEquals( Type.PersistenceType.EMBEDDABLE, House_.rooms.getElementTy= pe().getPersistenceType() ); + assertNotNull( House_.roomsByName ); + assertEquals( String.class, House_.roomsByName.getKeyJavaType() ); + assertEquals( Type.PersistenceType.BASIC, House_.roomsByName.getKeyType(= ).getPersistenceType() ); + assertEquals( PluralAttribute.CollectionType.MAP, House_.roomsByName.get= CollectionType() ); + assertNotNull( House_.roomsBySize ); + assertEquals( Type.PersistenceType.EMBEDDABLE, House_.roomsBySize.getEle= mentType().getPersistenceType() ); + assertEquals( PluralAttribute.CollectionType.LIST, House_.roomsBySize.ge= tCollectionType() ); + + // Person (mapped id) + assertNotNull( Person_.firstName ); + assertNotNull( Person_.lastName ); + assertTrue( Person_.firstName.isId() ); + assertTrue( Person_.lastName.isId() ); + assertTrue( Person_.lastName.isId() ); + } + + @Override + public Class[] getAnnotatedClasses() { + return new Class[]{ + Fridge.class, + FoodItem.class, + Person.class, + House.class, + Dog.class, + Cat.class, + Cattish.class, + Feline.class + }; + } + +} \ No newline at end of file Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/met= adata/Thing.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Thing.java 2009-11-01 14:31:50 UTC (rev 17885) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Thing.java 2009-11-02 16:46:17 UTC (rev 17886) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.ejb.test.metadata; = import javax.persistence.MappedSuperclass; --===============1764848336435351465==-- From hibernate-commits at lists.jboss.org Mon Nov 2 11:49:28 2009 Content-Type: multipart/mixed; boundary="===============7537870108919463507==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17887 - core/trunk. Date: Mon, 02 Nov 2009 11:49:28 -0500 Message-ID: <200911021649.nA2GnSR1020655@svn01.web.mwc.hst.phx2.redhat.com> --===============7537870108919463507== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-02 11:49:28 -0500 (Mon, 02 Nov 2009) New Revision: 17887 Modified: core/trunk/pom.xml Log: Remove tutorials from the build for the time being Modified: core/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/pom.xml 2009-11-02 16:46:17 UTC (rev 17886) +++ core/trunk/pom.xml 2009-11-02 16:49:28 UTC (rev 17887) @@ -20,7 +20,7 @@ parent core cache-ehcache - cache-jbosscache + cache-jbosscachen cache-oscache cache-swarmcache connection-c3p0 @@ -31,7 +31,9 @@ testing testsuite jdbc3-testing + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + verify + + jar-no-fork + + + + @@ -281,6 +295,11 @@ maven-compiler-plugin 2.0.2 + + org.apache.maven.plugins + maven-source-plugin + 2.1.1 + = --===============0797273449566496480==-- From hibernate-commits at lists.jboss.org Tue Nov 3 00:11:20 2009 Content-Type: multipart/mixed; boundary="===============8613626965738277740==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17896 - core/tags/hibernate-3.5.0-Beta-2/distribution. Date: Tue, 03 Nov 2009 00:11:20 -0500 Message-ID: <200911030511.nA35BKEs020114@svn01.web.mwc.hst.phx2.redhat.com> --===============8613626965738277740== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-03 00:11:19 -0500 (Tue, 03 Nov 2009) New Revision: 17896 Modified: core/tags/hibernate-3.5.0-Beta-2/distribution/pom.xml Log: Bind assembly building to deploy phase Modified: core/tags/hibernate-3.5.0-Beta-2/distribution/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/tags/hibernate-3.5.0-Beta-2/distribution/pom.xml 2009-11-03 02:03:= 08 UTC (rev 17895) +++ core/tags/hibernate-3.5.0-Beta-2/distribution/pom.xml 2009-11-03 05:11:= 19 UTC (rev 17896) @@ -44,6 +44,20 @@ Builds the complete Hibernate distribution bundles = + + + org.apache.maven.plugins + maven-assembly-plugin + + + deploy + + single + + + + + --===============8613626965738277740==-- From hibernate-commits at lists.jboss.org Tue Nov 3 00:12:40 2009 Content-Type: multipart/mixed; boundary="===============8125915079828193190==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17897 - core/trunk/distribution. Date: Tue, 03 Nov 2009 00:12:40 -0500 Message-ID: <200911030512.nA35CeEs020249@svn01.web.mwc.hst.phx2.redhat.com> --===============8125915079828193190== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-03 00:12:40 -0500 (Tue, 03 Nov 2009) New Revision: 17897 Modified: core/trunk/distribution/pom.xml Log: Bind assembly building to deploy phase Modified: core/trunk/distribution/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/distribution/pom.xml 2009-11-03 05:11:19 UTC (rev 17896) +++ core/trunk/distribution/pom.xml 2009-11-03 05:12:40 UTC (rev 17897) @@ -44,6 +44,20 @@ Builds the complete Hibernate distribution bundles = + + + org.apache.maven.plugins + maven-assembly-plugin + + + deploy + + single + + + + + --===============8125915079828193190==-- From hibernate-commits at lists.jboss.org Tue Nov 3 00:13:24 2009 Content-Type: multipart/mixed; boundary="===============7313586926170703208==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17898 - core/trunk/parent. Date: Tue, 03 Nov 2009 00:13:24 -0500 Message-ID: <200911030513.nA35DOKR020333@svn01.web.mwc.hst.phx2.redhat.com> --===============7313586926170703208== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-03 00:13:23 -0500 (Tue, 03 Nov 2009) New Revision: 17898 Modified: core/trunk/parent/pom.xml Log: Generate and install/deploy source jars Modified: core/trunk/parent/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/parent/pom.xml 2009-11-03 05:12:40 UTC (rev 17897) +++ core/trunk/parent/pom.xml 2009-11-03 05:13:23 UTC (rev 17898) @@ -174,6 +174,20 @@ true + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + verify + + jar-no-fork + + + + @@ -281,6 +295,11 @@ maven-compiler-plugin 2.0.2 + + org.apache.maven.plugins + maven-source-plugin + 2.1.1 + = --===============7313586926170703208==-- From hibernate-commits at lists.jboss.org Tue Nov 3 09:52:07 2009 Content-Type: multipart/mixed; boundary="===============8873614491184445231==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17899 - in jpamodelgen/trunk/src: main/java/org/hibernate/jpamodelgen/annotation and 19 other directories. Date: Tue, 03 Nov 2009 09:52:07 -0500 Message-ID: <200911031452.nA3Eq7wm032121@svn01.web.mwc.hst.phx2.redhat.com> --===============8873614491184445231== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-03 09:52:05 -0500 (Tue, 03 Nov 2009) New Revision: 17899 Added: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaAttribute.= java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaCollection= .java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaEntity.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaSingleAttr= ibute.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Ann= otationMetaAttribute.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Ann= otationMetaCollection.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Ann= otationMetaEntity.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Ann= otationMetaMap.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Ann= otationMetaSingleAttribute.java jpamodelgen/trunk/src/test/java/org/ jpamodelgen/trunk/src/test/java/org/hibernate/ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTyp= eTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Inheritan= ceTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTest= .java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappin= gTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ima= ge.java jpamodelgen/trunk/src/test/resources/org/ jpamodelgen/trunk/src/test/resources/org/hibernate/ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mode= l/ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mode= l/xmlmapped/ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mode= l/xmlmapped/address.xml jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mode= l/xmlmapped/building.xml jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mode= l/xmlmapped/mammal.xml Removed: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaAttribute= .java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaCollectio= n.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.ja= va jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAtt= ribute.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Met= aAttribute.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Met= aCollection.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Met= aEntity.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Met= aMap.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Met= aSingleAttribute.java jpamodelgen/trunk/src/test/java/model/ jpamodelgen/trunk/src/test/java/test/AccessTypeTest.java jpamodelgen/trunk/src/test/java/test/InheritanceTest.java jpamodelgen/trunk/src/test/java/test/QueryTest.java jpamodelgen/trunk/src/test/java/test/XmlMappingTest.java jpamodelgen/trunk/src/test/resources/model/xmlmapped/ Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.ja= va jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEn= tityProcessor.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAtt= ribute.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCol= lection.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEnt= ity.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSin= gleAttribute.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Add= ress.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Are= a.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Bui= lding.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Cou= ntry.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Cus= tomer.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Det= ail.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hom= inidae.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hou= se.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hum= an.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Inh= abitant.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ite= m.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Liv= ingBeing.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Mam= mals.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ord= er.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pet= .java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pro= duct.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Sho= p.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Use= r.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xml= mapped/Address.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xml= mapped/Building.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xml= mapped/LivingBeing.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xml= mapped/Mammal.java jpamodelgen/trunk/src/test/resources/META-INF/dummy.xml jpamodelgen/trunk/src/test/resources/META-INF/jpa1-orm.xml jpamodelgen/trunk/src/test/resources/META-INF/malformed-mapping-xml.xml jpamodelgen/trunk/src/test/resources/META-INF/orm.xml jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml jpamodelgen/trunk/src/test/suite/unit-tests.xml Log: METAGEN-3 Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWr= iter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.j= ava 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.j= ava 2009-11-03 14:52:05 UTC (rev 17899) @@ -24,7 +24,6 @@ import java.util.List; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.FilerException; -import javax.annotation.Generated; import javax.tools.FileObject; import javax.tools.Diagnostic; import javax.lang.model.type.TypeMirror; @@ -38,7 +37,7 @@ */ public class ClassWriter { = - public static void writeFile(IMetaEntity entity, ProcessingEnvironment pr= ocessingEnv, Context context) { + public static void writeFile(MetaEntity entity, ProcessingEnvironment pro= cessingEnv, Context context) { try { String metaModelPackage =3D entity.getPackageName(); = @@ -85,7 +84,7 @@ * * @return body content */ - private static StringBuffer generateBody(IMetaEntity entity, Context cont= ext) { + private static StringBuffer generateBody(MetaEntity entity, Context conte= xt) { = StringWriter sw =3D new StringWriter(); PrintWriter pw =3D null; @@ -103,9 +102,9 @@ = pw.println(); = - List members =3D entity.getMembers(); + List members =3D entity.getMembers(); = - for ( IMetaAttribute metaMember : members ) { + for ( MetaAttribute metaMember : members ) { pw.println( " " + metaMember.getDeclarationString() ); } pw.println(); @@ -119,7 +118,7 @@ } } = - private static void printClassDeclaration(IMetaEntity entity, PrintWriter= pw, Context context) { + private static void printClassDeclaration(MetaEntity entity, PrintWriter = pw, Context context) { pw.print( "public abstract class " + entity.getSimpleName() + "_" ); = final TypeMirror superClass =3D entity.getTypeElement().getSuperclass(); Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java = 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java = 2009-11-03 14:52:05 UTC (rev 17899) @@ -26,7 +26,7 @@ import javax.annotation.processing.ProcessingEnvironment; import javax.tools.Diagnostic; = -import org.hibernate.jpamodelgen.annotation.MetaEntity; +import org.hibernate.jpamodelgen.annotation.AnnotationMetaEntity; = /** * @author Max Andersen @@ -38,8 +38,8 @@ private Map accessTypes =3D new HashMap(); private Set elementsAlreadyProcessed =3D new HashSet(); private ProcessingEnvironment pe; - private final Map metaEntitiesToProcess =3D new Hash= Map(); - private final Map metaSuperclassAndEmbeddableToProce= ss =3D new HashMap(); + private final Map metaEntitiesToProcess =3D new HashM= ap(); + private final Map metaSuperclassAndEmbeddableToProces= s =3D new HashMap(); = private static class AccessTypeHolder { public AccessType elementAccessType; @@ -50,11 +50,11 @@ this.pe =3D pe; } = - public Map getMetaEntitiesToProcess() { + public Map getMetaEntitiesToProcess() { return metaEntitiesToProcess; } = - public Map getMetaSuperclassAndEmbeddableToProcess()= { + public Map getMetaSuperclassAndEmbeddableToProcess() { return metaSuperclassAndEmbeddableToProcess; } = @@ -98,7 +98,7 @@ return; } = - ClassWriter.writeFile( new MetaEntity( pe, element, this, defaultAccessT= ypeForHierarchy ), pe, this ); + ClassWriter.writeFile( new AnnotationMetaEntity( pe, element, this, defa= ultAccessTypeForHierarchy ), pe, this ); elementsAlreadyProcessed.add( element.getQualifiedName().toString() ); } } Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaAtt= ribute.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaAttribut= e.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaAttribut= e.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -1,31 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen; - -/** - * @author Hardy Ferentschik - */ -public interface IMetaAttribute { - String getDeclarationString(); - - String getMetaType(); - - String getPropertyName(); - - String getTypeDeclaration(); = -} Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaCol= lection.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaCollecti= on.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaCollecti= on.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -1,26 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen; - -import org.hibernate.jpamodelgen.IMetaAttribute; - -/** - * @author Hardy Ferentschik - */ -public interface IMetaCollection extends IMetaAttribute { -} Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaEnt= ity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.j= ava 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.j= ava 2009-11-03 14:52:05 UTC (rev 17899) @@ -1,45 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen; - -import javax.lang.model.element.Name; -import javax.lang.model.element.TypeElement; -import java.util.List; - -/** - * @author Hardy Ferentschik - */ -public interface IMetaEntity extends ImportContext { - String getSimpleName(); - - String getQualifiedName(); - - String getPackageName(); - - List getMembers(); - - String generateImports(); - - String importType(String fqcn); - - String staticImport(String fqcn, String member); - - String importType(Name qualifiedName); - - TypeElement getTypeElement(); -} Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaSin= gleAttribute.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAt= tribute.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAt= tribute.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -1,24 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen; - -/** - * @author Hardy Ferentschik - */ -public interface IMetaSingleAttribute extends IMetaAttribute { -} Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMeta= ModelEntityProcessor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelE= ntityProcessor.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelE= ntityProcessor.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -48,7 +48,7 @@ = import org.xml.sax.SAXException; = -import org.hibernate.jpamodelgen.annotation.MetaEntity; +import org.hibernate.jpamodelgen.annotation.AnnotationMetaEntity; import org.hibernate.jpamodelgen.xml.XmlMetaEntity; import org.hibernate.jpamodelgen.xml.jaxb.Entity; import org.hibernate.jpamodelgen.xml.jaxb.EntityMappings; @@ -125,7 +125,7 @@ } = private void createMetaModelClasses() { - for ( IMetaEntity entity : context.getMetaEntitiesToProcess().values() )= { + for ( MetaEntity entity : context.getMetaEntitiesToProcess().values() ) { processingEnv.getMessager() .printMessage( Diagnostic.Kind.NOTE, "Writing meta model for " + enti= ty ); ClassWriter.writeFile( entity, processingEnv, context ); @@ -136,7 +136,7 @@ context.getMetaSuperclassAndEmbeddableToProcess().remove( className ); } = - for ( IMetaEntity entity : context.getMetaSuperclassAndEmbeddableToProce= ss().values() ) { + for ( MetaEntity entity : context.getMetaSuperclassAndEmbeddableToProces= s().values() ) { processingEnv.getMessager() .printMessage( Diagnostic.Kind.NOTE, "Writing meta model for " + enti= ty ); ClassWriter.writeFile( entity, processingEnv, context ); @@ -325,13 +325,13 @@ = if ( element.getKind() =3D=3D ElementKind.CLASS ) { if ( annotationType.equals( ENTITY_ANN ) ) { - MetaEntity metaEntity =3D new MetaEntity( processingEnv, ( TypeElemen= t ) element, context ); + AnnotationMetaEntity metaEntity =3D new AnnotationMetaEntity( process= ingEnv, ( TypeElement ) element, context ); // TODO instead of just adding the entity we have to do some merging. context.getMetaEntitiesToProcess().put( metaEntity.getQualifiedName()= , metaEntity ); } else if ( annotationType.equals( MAPPED_SUPERCLASS_ANN ) || annotationType.equals( EMBEDDABLE_ANN ) ) { - MetaEntity metaEntity =3D new MetaEntity( processingEnv, ( TypeElemen= t ) element, context ); + AnnotationMetaEntity metaEntity =3D new AnnotationMetaEntity( process= ingEnv, ( TypeElement ) element, context ); = // TODO instead of just adding the entity we have to do some merging. context.getMetaSuperclassAndEmbeddableToProcess().put( metaEntity.get= QualifiedName(), metaEntity ); Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaAttri= bute.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jp= amodelgen/IMetaAttribute.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaAttribute= .java (rev 0) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaAttribute= .java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,31 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen; + +/** + * @author Hardy Ferentschik + */ +public interface MetaAttribute { + String getDeclarationString(); + + String getMetaType(); + + String getPropertyName(); + + String getTypeDeclaration(); = +} Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodel= gen/MetaAttribute.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaColle= ction.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/j= pamodelgen/IMetaCollection.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaCollectio= n.java (rev 0) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaCollectio= n.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,26 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen; + +import org.hibernate.jpamodelgen.MetaAttribute; + +/** + * @author Hardy Ferentschik + */ +public interface MetaCollection extends MetaAttribute { +} Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodel= gen/MetaCollection.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaEntit= y.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jpamo= delgen/IMetaEntity.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaEntity.ja= va (rev 0) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaEntity.ja= va 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,45 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen; + +import javax.lang.model.element.Name; +import javax.lang.model.element.TypeElement; +import java.util.List; + +/** + * @author Hardy Ferentschik + */ +public interface MetaEntity extends ImportContext { + String getSimpleName(); + + String getQualifiedName(); + + String getPackageName(); + + List getMembers(); + + String generateImports(); + + String importType(String fqcn); + + String staticImport(String fqcn, String member); + + String importType(Name qualifiedName); + + TypeElement getTypeElement(); +} Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodel= gen/MetaEntity.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaSingl= eAttribute.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibern= ate/jpamodelgen/IMetaSingleAttribute.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaSingleAtt= ribute.java (rev 0) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaSingleAtt= ribute.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,24 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen; + +/** + * @author Hardy Ferentschik + */ +public interface MetaSingleAttribute extends MetaAttribute { +} Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodel= gen/MetaSingleAttribute.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotatio= n/AnnotationMetaAttribute.java (from rev 17898, jpamodelgen/trunk/src/main/= java/org/hibernate/jpamodelgen/annotation/MetaAttribute.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaAttribute.java (rev 0) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaAttribute.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,74 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.annotation; + +import org.hibernate.jpamodelgen.MetaAttribute; + +import java.beans.Introspector; + +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; + +/** + * + * @author Max Andersen + * @author Hardy Ferentschik + * @author Emmanuel Bernard + */ +public abstract class AnnotationMetaAttribute implements MetaAttribute { + + final protected Element element; + final protected AnnotationMetaEntity parent; + final protected ProcessingEnvironment pe; + private final String type; + + public AnnotationMetaAttribute(AnnotationMetaEntity parent, Element eleme= nt, String type) { + this.element =3D element; + this.parent =3D parent; + this.type =3D type; + this.pe =3D parent.pe; + } + + public String getDeclarationString() { + return "public static volatile " + parent.importType(getMetaType()) + "<= " + parent.importType(parent.getQualifiedName()) + ", " + parent.importType= (getTypeDeclaration()) + "> " + getPropertyName() + ";"; = + } + + public String getPropertyName() { + if(element.getKind()=3D=3DElementKind.FIELD) { + return element.getSimpleName().toString(); + } else if (element.getKind()=3D=3DElementKind.METHOD) { + = + String name =3D element.getSimpleName().toString(); + if(name.startsWith("get")) { + return pe.getElementUtils().getName(Introspector.decapitalize(name.sub= string("get".length()))).toString(); + } else if(name.startsWith("is")) { + return (pe.getElementUtils().getName(Introspector.decapitalize(name.su= bstring("is".length())))).toString(); + } + return pe.getElementUtils().getName(Introspector.decapitalize(name)).to= String(); + } else { + return pe.getElementUtils().getName(element.getSimpleName() + "/* " + e= lement.getKind() + " */").toString(); + } + } + + abstract public String getMetaType(); + + public String getTypeDeclaration() { + return type; = + } +} Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodel= gen/annotation/AnnotationMetaAttribute.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotatio= n/AnnotationMetaCollection.java (from rev 17898, jpamodelgen/trunk/src/main= /java/org/hibernate/jpamodelgen/annotation/MetaCollection.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaCollection.java (rev 0) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaCollection.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,46 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.annotation; + +import org.hibernate.jpamodelgen.MetaCollection; + +import javax.lang.model.element.Element; + +/** + * + * @author Max Andersen + * @author Hardy Ferentschik + * @author Emmanuel Bernard + */ +public class AnnotationMetaCollection extends AnnotationMetaAttribute impl= ements MetaCollection { + + private String collectionType; = + = + + public AnnotationMetaCollection(AnnotationMetaEntity parent, Element elem= ent, String collectionType, String elementType) { + super(parent, element, elementType); + this.collectionType =3D collectionType; = + } + + @Override + public String getMetaType() { = + return collectionType; + } + + = +} Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodel= gen/annotation/AnnotationMetaCollection.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotatio= n/AnnotationMetaEntity.java (from rev 17898, jpamodelgen/trunk/src/main/jav= a/org/hibernate/jpamodelgen/annotation/MetaEntity.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaEntity.java (rev 0) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaEntity.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,433 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.annotation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.Name; +import javax.lang.model.element.PackageElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.Modifier; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.ExecutableType; +import javax.lang.model.type.PrimitiveType; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; +import javax.lang.model.util.SimpleTypeVisitor6; +import javax.persistence.EmbeddedId; +import javax.persistence.Id; +import javax.persistence.AccessType; +import javax.persistence.Entity; +import javax.persistence.MappedSuperclass; +import javax.persistence.Transient; +import javax.persistence.Embedded; +import javax.persistence.Embeddable; +import javax.persistence.Access; +import javax.persistence.ElementCollection; +import javax.tools.Diagnostic.Kind; +import javax.tools.Diagnostic; + +import org.hibernate.jpamodelgen.MetaEntity; +import org.hibernate.jpamodelgen.MetaAttribute; +import org.hibernate.jpamodelgen.ImportContext; +import org.hibernate.jpamodelgen.ImportContextImpl; +import org.hibernate.jpamodelgen.TypeUtils; +import org.hibernate.jpamodelgen.Context; + +/** + * + * @author Max Andersen + * @author Hardy Ferentschik + * @author Emmanuel Bernard + */ +public class AnnotationMetaEntity implements MetaEntity { + + final TypeElement element; + final protected ProcessingEnvironment pe; + + final ImportContext importContext; + private Context context; + //used to propagate the access type of the root entity over to subclasses= , superclasses and embeddable + private AccessType defaultAccessTypeForHierarchy; + private AccessType defaultAccessTypeForElement; + + public AnnotationMetaEntity(ProcessingEnvironment pe, TypeElement element= , Context context) { + this.element =3D element; + this.pe =3D pe; + importContext =3D new ImportContextImpl( getPackageName() ); + this.context =3D context; + } + + public AnnotationMetaEntity(ProcessingEnvironment pe, TypeElement element= , Context context, AccessType accessType) { + this(pe, element, context); + this.defaultAccessTypeForHierarchy =3D accessType; + } + + public String getSimpleName() { + return element.getSimpleName().toString(); + } + + public Element getOriginalElement() { + return element; + } + + public String getQualifiedName() { + return element.getQualifiedName().toString(); + } + + public String getPackageName() { + PackageElement packageOf =3D pe.getElementUtils().getPackageOf( element = ); + return pe.getElementUtils().getName( packageOf.getQualifiedName() ).toSt= ring(); + } + + public List getMembers() { + List membersFound =3D new ArrayList(); + final AccessType elementAccessType =3D getAccessTypeForElement(); + + List fieldsOfClass =3D ElementFilter.fieldsIn( elemen= t.getEnclosedElements() ); + addPersistentMembers( membersFound, elementAccessType, fieldsOfClass, Ac= cessType.FIELD ); + + List methodsOfClass =3D ElementFilter.methodsIn( elem= ent.getEnclosedElements() ); + addPersistentMembers( membersFound, elementAccessType, methodsOfClass, A= ccessType.PROPERTY ); + + //process superclasses + for(TypeElement superclass =3D TypeUtils.getSuperclass(element) ; + superclass !=3D null ; + superclass =3D TypeUtils.getSuperclass( superclass ) ) { + if ( superclass.getAnnotation( Entity.class ) !=3D null ) { + break; //will be handled or has been handled already + } + else if ( superclass.getAnnotation( MappedSuperclass.class ) !=3D null = ) { + //FIXME use the class defalut access type + context.processElement( superclass, defaultAccessTypeForHierarchy ); + } + } + + //this is valid to not have properties (ie subentities) +// if ( membersFound.size() =3D=3D 0 ) { +// pe.getMessager().printMessage( Kind.WARNING, "No properties found on = " + element, element ); +// } + return membersFound; + } + + private void addPersistentMembers( + List membersFound, + AccessType elementAccessType, + List membersOfClass, + AccessType membersKind) { + pe.getMessager() + .printMessage( Kind.NOTE, "Scanning " + membersOfClass.size() + " " += membersKind + " for " + element.toString() ); + AccessType explicitAccessType; + if (elementAccessType =3D=3D membersKind) { + //all membersKind considered + explicitAccessType =3D null; + } + else { + //use membersKind only if marked with @Access(membersKind) + explicitAccessType =3D membersKind; + } + for ( Element memberOfClass : membersOfClass ) { + + AnnotationMetaAttribute result =3D memberOfClass.asType().accept( new T= ypeVisitor( this, explicitAccessType ), + memberOfClass + ); + if ( result !=3D null ) { + membersFound.add( result ); + } +//EBE not sure why? +// else { +// pe.getMessager().printMessage( Kind.WARNING, "Could not find valid i= nfo for JPA property", mymember ); +// } + } + } + + private AccessType getAccessTypeForElement() { + + //get local strategy + AccessType accessType =3D getAccessTypeForClass(element); + if (accessType =3D=3D null) { + accessType =3D this.defaultAccessTypeForHierarchy; + } + if (accessType =3D=3D null) { + //we dont' know + //if an enity go up + // + //superclasses alre always treated after their entities + //and their access type are discovered + //FIXME is it really true if only the superclass is changed + TypeElement superClass =3D element; + do { + superClass =3D TypeUtils.getSuperclass( superClass ); + if (superClass !=3D null) { + if ( superClass.getAnnotation( Entity.class ) !=3D null + || superClass.getAnnotation( MappedSuperclass.class ) !=3D null ) { + //FIXME make it work for XML + AccessType superClassAccessType =3D getAccessTypeForClass(superClass= ); + //we've reach the root entity and resolved Ids + if ( superClassAccessType !=3D null && defaultAccessTypeForHierarchy= !=3D null) { + break; //we've found it + } + } + else { + break; //neither @Entity nor @MappedSuperclass + } + } + } + while ( superClass !=3D null ); + } + + if ( accessType =3D=3D null ) { + accessType =3D AccessType.PROPERTY; //default to property + this.defaultAccessTypeForElement =3D accessType; + } + //this is a subclass so caching is OK + //this.defaultAccessTypeForHierarchy =3D accessType; + context.addAccessType( this.element, accessType ); + this.defaultAccessTypeForElement =3D accessType; + return accessType; + } + + private AccessType getAccessTypeForClass(TypeElement searchedElement) { + pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "check class" + sea= rchedElement ); + AccessType accessType =3D context.getAccessType( searchedElement ); + + if (defaultAccessTypeForHierarchy =3D=3D null) { + this.defaultAccessTypeForHierarchy =3D context.getDefaultAccessTypeForH= erarchy( searchedElement ); + } + if ( accessType !=3D null ) { + pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found in cache" += searchedElement + ":" + accessType ); + return accessType; + } + + /** + * when forcing access type, we can only override the defaultAccessTypeF= orHierarchy + * if we are the entity root (identified by having @Id or @EmbeddedId + */ + final Access accessAnn =3D searchedElement.getAnnotation( Access.class ); + AccessType forcedAccessType =3D accessAnn !=3D null ? accessAnn.value() = : null; + if ( forcedAccessType !=3D null) { + pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type " + s= earchedElement + ":" + forcedAccessType ); + context.addAccessType( searchedElement, forcedAccessType ); + } + + //continue nevertheless to check if we are root and if defaultAccessType= ForHierarchy + //should be overridden + if ( forcedAccessType =3D=3D null || defaultAccessTypeForHierarchy =3D= =3D null) { + List myMembers =3D searchedElement.getEnclosedElemen= ts(); + for ( Element subElement : myMembers ) { + List entityAnnotations =3D + pe.getElementUtils().getAllAnnotationMirrors( subElement ); + + for ( Object entityAnnotation : entityAnnotations ) { + AnnotationMirror annotationMirror =3D ( AnnotationMirror ) entityAnno= tation; + + final String annotationType =3D annotationMirror.getAnnotationType().= toString(); + + //FIXME consider XML + if ( annotationType.equals( Id.class.getName() ) + || annotationType.equals( EmbeddedId.class.getName() ) ) { + pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found id on" += searchedElement ); + final ElementKind kind =3D subElement.getKind(); + if ( kind =3D=3D ElementKind.FIELD || kind =3D=3D ElementKind.METHOD= ) { + accessType =3D kind =3D=3D ElementKind.FIELD ? AccessType.FIELD : A= ccessType.PROPERTY; + //FIXME enlever in niveau + if (defaultAccessTypeForHierarchy =3D=3D null) { + this.defaultAccessTypeForHierarchy =3D context.getDefaultAccessTyp= eForHerarchy( searchedElement ); + //we've discovered the class hierarchy, let's cache it + if ( defaultAccessTypeForHierarchy =3D=3D null ) { + this.defaultAccessTypeForHierarchy =3D accessType; + context.addAccessTypeForHierarchy( searchedElement, defaultAccess= TypeForHierarchy ); + //FIXME should we add + //context.addAccessTypeForHierarchy( element, defaultAccessTypeFo= rHierarchy ); + } + } + if ( forcedAccessType =3D=3D null) { + context.addAccessType( searchedElement, accessType ); + pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type = " + searchedElement + ":" + accessType ); + return accessType; + } + else { + return forcedAccessType; + } + } + } + } + } + } + return forcedAccessType; + } + + @Override + public String toString() { + final StringBuilder sb =3D new StringBuilder(); + sb.append( "MetaEntity" ); + sb.append( "{element=3D" ).append( element ); + sb.append( '}' ); + return sb.toString(); + } + + static Map COLLECTIONS =3D new HashMap(); + + static { + COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.Co= llectionAttribute" ); + COLLECTIONS.put( "java.util.Set", "javax.persistence.metamodel.SetAttrib= ute" ); + COLLECTIONS.put( "java.util.List", "javax.persistence.metamodel.ListAttr= ibute" ); + COLLECTIONS.put( "java.util.Map", "javax.persistence.metamodel.MapAttrib= ute" ); + } + + class TypeVisitor extends SimpleTypeVisitor6 { + + AnnotationMetaEntity parent; + //if null, process all members as implicit + //if not null, only process members marked as @Access(explicitAccessType) + private AccessType explicitAccessType; + + TypeVisitor(AnnotationMetaEntity parent, AccessType explicitAccessType) { + this.parent =3D parent; + this.explicitAccessType =3D explicitAccessType; + } + + @Override + protected AnnotationMetaAttribute defaultAction(TypeMirror e, Element p)= { + return super.defaultAction( e, p ); + } + + @Override + public AnnotationMetaAttribute visitPrimitive(PrimitiveType t, Element e= lement) { + if ( isPersistent( element ) ) { + return new AnnotationMetaSingleAttribute( parent, element, TypeUtils.t= oTypeString( t ) ); + } + else { + return null; + } + } + + private boolean isPersistent(Element element) { + //FIXME consider XML + boolean correctAccessType =3D false; + if (this.explicitAccessType =3D=3D null) { + correctAccessType =3D true; + } + else { + final Access accessAnn =3D element.getAnnotation( Access.class ); + if ( accessAnn !=3D null && explicitAccessType.equals( accessAnn.value= () ) ) { + correctAccessType =3D true; + } + } + return correctAccessType + && element.getAnnotation( Transient.class ) =3D=3D null + && !element.getModifiers().contains( Modifier.TRANSIENT ) + && !element.getModifiers().contains( Modifier.STATIC ); + + } + + + @Override + public AnnotationMetaAttribute visitDeclared(DeclaredType t, Element ele= ment) { + //FIXME consider XML + if ( isPersistent( element ) ) { + TypeElement returnedElement =3D ( TypeElement ) pe.getTypeUtils().asEl= ement( t ); + String collection =3D COLLECTIONS.get( returnedElement.getQualifiedNam= e().toString() ); // WARNING: .toString() is necessary here since Name equa= ls does not compare to String + + if ( collection !=3D null ) { + //collection of element + if ( element.getAnnotation( ElementCollection.class ) !=3D null ) { + final TypeMirror collectionType =3D t.getTypeArguments().get( 0 ); + final TypeElement collectionElement =3D ( TypeElement ) pe.getTypeUt= ils().asElement( collectionType ); + this.parent.context.processElement( collectionElement, + this.parent.defaultAccessTypeForElement ); + } + if ( collection.equals( "javax.persistence.metamodel.MapAttribute" ) = ) { + return new AnnotationMetaMap( parent, element, collection, getKeyTyp= e( t ), getElementType( t ) ); + } + else { + return new AnnotationMetaCollection( parent, element, collection, ge= tElementType( t ) ); + } + } + else { + //FIXME Consider XML + if ( element.getAnnotation( Embedded.class ) !=3D null + || returnedElement.getAnnotation( Embeddable.class ) !=3D null ) { + this.parent.context.processElement( returnedElement, = + this.parent.defaultAccessTypeForElement ); + } + return new AnnotationMetaSingleAttribute( parent, element, returnedEl= ement.getQualifiedName().toString() ); + } + } + else { + return null; + } + } + + + @Override + public AnnotationMetaAttribute visitExecutable(ExecutableType t, Element= p) { + String string =3D p.getSimpleName().toString(); + + // TODO: implement proper property get/is/boolean detection + if ( string.startsWith( "get" ) || string.startsWith( "is" ) ) { + TypeMirror returnType =3D t.getReturnType(); + + return returnType.accept( this, p ); + } + else { + return null; + } + } + } + + public String generateImports() { + return importContext.generateImports(); + } + + public String importType(String fqcn) { + return importContext.importType( fqcn ); + } + + public String staticImport(String fqcn, String member) { + return importContext.staticImport( fqcn, member ); + } + + public String importType(Name qualifiedName) { + return importType( qualifiedName.toString() ); + } + + public TypeElement getTypeElement() { + return element; + } + + private String getKeyType(DeclaredType t) { + return t.getTypeArguments().get( 0 ).toString(); + } + + + private String getElementType(DeclaredType declaredType) { + if ( declaredType.getTypeArguments().size() =3D=3D 1 ) { + return declaredType.getTypeArguments().get( 0 ).toString(); + } + else { + return declaredType.getTypeArguments().get( 1 ).toString(); + } + } +} Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodel= gen/annotation/AnnotationMetaEntity.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotatio= n/AnnotationMetaMap.java (from rev 17898, jpamodelgen/trunk/src/main/java/o= rg/hibernate/jpamodelgen/annotation/MetaMap.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaMap.java (rev 0) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaMap.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,42 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.annotation; + +import javax.lang.model.element.Element; + +/** + * + * @author Max Andersen + * @author Hardy Ferentschik + * @author Emmanuel Bernard + */ +public class AnnotationMetaMap extends AnnotationMetaCollection { + + private final String keyType; + + public AnnotationMetaMap(AnnotationMetaEntity parent, Element element, St= ring collectionType, + String keyType, String elementType) { + super(parent, element, collectionType, elementType); + this.keyType =3D keyType; = + } + + public String getDeclarationString() { + return "public static volatile " + parent.importType(getMetaType()) + "<= " + parent.importType(parent.getQualifiedName()) + ", " + parent.importType= (keyType) + ", " + parent.importType(getTypeDeclaration()) + "> " + getProp= ertyName() + ";"; = + } + +} Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodel= gen/annotation/AnnotationMetaMap.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotatio= n/AnnotationMetaSingleAttribute.java (from rev 17898, jpamodelgen/trunk/src= /main/java/org/hibernate/jpamodelgen/annotation/MetaSingleAttribute.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaSingleAttribute.java (rev 0) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaSingleAttribute.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,41 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.annotation; + +import org.hibernate.jpamodelgen.MetaSingleAttribute; + +import javax.lang.model.element.Element; + +/** + * + * @author Max Andersen + * @author Hardy Ferentschik + * @author Emmanuel Bernard + */ +public class AnnotationMetaSingleAttribute extends AnnotationMetaAttribute= implements MetaSingleAttribute { + + public AnnotationMetaSingleAttribute(AnnotationMetaEntity parent, Element= element, String type) { + super(parent, element, type); + } + + @Override + public String getMetaType() { + return "javax.persistence.metamodel.SingularAttribute"; + } + +} Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodel= gen/annotation/AnnotationMetaSingleAttribute.java ___________________________________________________________________ Name: svn:keywords + Id Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotati= on/MetaAttribute.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Me= taAttribute.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Me= taAttribute.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -1,74 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.annotation; - -import org.hibernate.jpamodelgen.IMetaAttribute; - -import java.beans.Introspector; - -import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; - -/** - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -public abstract class MetaAttribute implements IMetaAttribute { - - final protected Element element; - final protected MetaEntity parent; - final protected ProcessingEnvironment pe; - private final String type; - - public MetaAttribute(MetaEntity parent, Element element, String type) { - this.element =3D element; - this.parent =3D parent; - this.type =3D type; - this.pe =3D parent.pe; - } - - public String getDeclarationString() { - return "public static volatile " + parent.importType(getMetaType()) + "<= " + parent.importType(parent.getQualifiedName()) + ", " + parent.importType= (getTypeDeclaration()) + "> " + getPropertyName() + ";"; = - } - - public String getPropertyName() { - if(element.getKind()=3D=3DElementKind.FIELD) { - return element.getSimpleName().toString(); - } else if (element.getKind()=3D=3DElementKind.METHOD) { - = - String name =3D element.getSimpleName().toString(); - if(name.startsWith("get")) { - return pe.getElementUtils().getName(Introspector.decapitalize(name.sub= string("get".length()))).toString(); - } else if(name.startsWith("is")) { - return (pe.getElementUtils().getName(Introspector.decapitalize(name.su= bstring("is".length())))).toString(); - } - return pe.getElementUtils().getName(Introspector.decapitalize(name)).to= String(); - } else { - return pe.getElementUtils().getName(element.getSimpleName() + "/* " + e= lement.getKind() + " */").toString(); - } - } - - abstract public String getMetaType(); - - public String getTypeDeclaration() { - return type; = - } -} Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotati= on/MetaCollection.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Me= taCollection.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Me= taCollection.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -1,46 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.annotation; - -import org.hibernate.jpamodelgen.IMetaCollection; - -import javax.lang.model.element.Element; - -/** - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -public class MetaCollection extends MetaAttribute implements IMetaCollecti= on { - - private String collectionType; = - = - - public MetaCollection(MetaEntity parent, Element element, String collecti= onType, String elementType) { - super(parent, element, elementType); - this.collectionType =3D collectionType; = - } - - @Override - public String getMetaType() { = - return collectionType; - } - - = -} Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotati= on/MetaEntity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Me= taEntity.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Me= taEntity.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -1,433 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.annotation; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.Name; -import javax.lang.model.element.PackageElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.ExecutableType; -import javax.lang.model.type.PrimitiveType; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.SimpleTypeVisitor6; -import javax.persistence.EmbeddedId; -import javax.persistence.Id; -import javax.persistence.AccessType; -import javax.persistence.Entity; -import javax.persistence.MappedSuperclass; -import javax.persistence.Transient; -import javax.persistence.Embedded; -import javax.persistence.Embeddable; -import javax.persistence.Access; -import javax.persistence.ElementCollection; -import javax.tools.Diagnostic.Kind; -import javax.tools.Diagnostic; - -import org.hibernate.jpamodelgen.IMetaEntity; -import org.hibernate.jpamodelgen.IMetaAttribute; -import org.hibernate.jpamodelgen.ImportContext; -import org.hibernate.jpamodelgen.ImportContextImpl; -import org.hibernate.jpamodelgen.TypeUtils; -import org.hibernate.jpamodelgen.Context; - -/** - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -public class MetaEntity implements IMetaEntity { - - final TypeElement element; - final protected ProcessingEnvironment pe; - - final ImportContext importContext; - private Context context; - //used to propagate the access type of the root entity over to subclasses= , superclasses and embeddable - private AccessType defaultAccessTypeForHierarchy; - private AccessType defaultAccessTypeForElement; - - public MetaEntity(ProcessingEnvironment pe, TypeElement element, Context = context) { - this.element =3D element; - this.pe =3D pe; - importContext =3D new ImportContextImpl( getPackageName() ); - this.context =3D context; - } - - public MetaEntity(ProcessingEnvironment pe, TypeElement element, Context = context, AccessType accessType) { - this(pe, element, context); - this.defaultAccessTypeForHierarchy =3D accessType; - } - - public String getSimpleName() { - return element.getSimpleName().toString(); - } - - public Element getOriginalElement() { - return element; - } - - public String getQualifiedName() { - return element.getQualifiedName().toString(); - } - - public String getPackageName() { - PackageElement packageOf =3D pe.getElementUtils().getPackageOf( element = ); - return pe.getElementUtils().getName( packageOf.getQualifiedName() ).toSt= ring(); - } - - public List getMembers() { - List membersFound =3D new ArrayList(); - final AccessType elementAccessType =3D getAccessTypeForElement(); - - List fieldsOfClass =3D ElementFilter.fieldsIn( elemen= t.getEnclosedElements() ); - addPersistentMembers( membersFound, elementAccessType, fieldsOfClass, Ac= cessType.FIELD ); - - List methodsOfClass =3D ElementFilter.methodsIn( elem= ent.getEnclosedElements() ); - addPersistentMembers( membersFound, elementAccessType, methodsOfClass, A= ccessType.PROPERTY ); - - //process superclasses - for(TypeElement superclass =3D TypeUtils.getSuperclass(element) ; - superclass !=3D null ; - superclass =3D TypeUtils.getSuperclass( superclass ) ) { - if ( superclass.getAnnotation( Entity.class ) !=3D null ) { - break; //will be handled or has been handled already - } - else if ( superclass.getAnnotation( MappedSuperclass.class ) !=3D null = ) { - //FIXME use the class defalut access type - context.processElement( superclass, defaultAccessTypeForHierarchy ); - } - } - - //this is valid to not have properties (ie subentities) -// if ( membersFound.size() =3D=3D 0 ) { -// pe.getMessager().printMessage( Kind.WARNING, "No properties found on = " + element, element ); -// } - return membersFound; - } - - private void addPersistentMembers( - List membersFound, - AccessType elementAccessType, - List membersOfClass, - AccessType membersKind) { - pe.getMessager() - .printMessage( Kind.NOTE, "Scanning " + membersOfClass.size() + " " += membersKind + " for " + element.toString() ); - AccessType explicitAccessType; - if (elementAccessType =3D=3D membersKind) { - //all membersKind considered - explicitAccessType =3D null; - } - else { - //use membersKind only if marked with @Access(membersKind) - explicitAccessType =3D membersKind; - } - for ( Element memberOfClass : membersOfClass ) { - - MetaAttribute result =3D memberOfClass.asType().accept( new TypeVisitor= ( this, explicitAccessType ), - memberOfClass - ); - if ( result !=3D null ) { - membersFound.add( result ); - } -//EBE not sure why? -// else { -// pe.getMessager().printMessage( Kind.WARNING, "Could not find valid i= nfo for JPA property", mymember ); -// } - } - } - - private AccessType getAccessTypeForElement() { - - //get local strategy - AccessType accessType =3D getAccessTypeForClass(element); - if (accessType =3D=3D null) { - accessType =3D this.defaultAccessTypeForHierarchy; - } - if (accessType =3D=3D null) { - //we dont' know - //if an enity go up - // - //superclasses alre always treated after their entities - //and their access type are discovered - //FIXME is it really true if only the superclass is changed - TypeElement superClass =3D element; - do { - superClass =3D TypeUtils.getSuperclass( superClass ); - if (superClass !=3D null) { - if ( superClass.getAnnotation( Entity.class ) !=3D null - || superClass.getAnnotation( MappedSuperclass.class ) !=3D null ) { - //FIXME make it work for XML - AccessType superClassAccessType =3D getAccessTypeForClass(superClass= ); - //we've reach the root entity and resolved Ids - if ( superClassAccessType !=3D null && defaultAccessTypeForHierarchy= !=3D null) { - break; //we've found it - } - } - else { - break; //neither @Entity nor @MappedSuperclass - } - } - } - while ( superClass !=3D null ); - } - - if ( accessType =3D=3D null ) { - accessType =3D AccessType.PROPERTY; //default to property - this.defaultAccessTypeForElement =3D accessType; - } - //this is a subclass so caching is OK - //this.defaultAccessTypeForHierarchy =3D accessType; - context.addAccessType( this.element, accessType ); - this.defaultAccessTypeForElement =3D accessType; - return accessType; - } - - private AccessType getAccessTypeForClass(TypeElement searchedElement) { - pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "check class" + sea= rchedElement ); - AccessType accessType =3D context.getAccessType( searchedElement ); - - if (defaultAccessTypeForHierarchy =3D=3D null) { - this.defaultAccessTypeForHierarchy =3D context.getDefaultAccessTypeForH= erarchy( searchedElement ); - } - if ( accessType !=3D null ) { - pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found in cache" += searchedElement + ":" + accessType ); - return accessType; - } - - /** - * when forcing access type, we can only override the defaultAccessTypeF= orHierarchy - * if we are the entity root (identified by having @Id or @EmbeddedId - */ - final Access accessAnn =3D searchedElement.getAnnotation( Access.class ); - AccessType forcedAccessType =3D accessAnn !=3D null ? accessAnn.value() = : null; - if ( forcedAccessType !=3D null) { - pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type " + s= earchedElement + ":" + forcedAccessType ); - context.addAccessType( searchedElement, forcedAccessType ); - } - - //continue nevertheless to check if we are root and if defaultAccessType= ForHierarchy - //should be overridden - if ( forcedAccessType =3D=3D null || defaultAccessTypeForHierarchy =3D= =3D null) { - List myMembers =3D searchedElement.getEnclosedElemen= ts(); - for ( Element subElement : myMembers ) { - List entityAnnotations =3D - pe.getElementUtils().getAllAnnotationMirrors( subElement ); - - for ( Object entityAnnotation : entityAnnotations ) { - AnnotationMirror annotationMirror =3D ( AnnotationMirror ) entityAnno= tation; - - final String annotationType =3D annotationMirror.getAnnotationType().= toString(); - - //FIXME consider XML - if ( annotationType.equals( Id.class.getName() ) - || annotationType.equals( EmbeddedId.class.getName() ) ) { - pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found id on" += searchedElement ); - final ElementKind kind =3D subElement.getKind(); - if ( kind =3D=3D ElementKind.FIELD || kind =3D=3D ElementKind.METHOD= ) { - accessType =3D kind =3D=3D ElementKind.FIELD ? AccessType.FIELD : A= ccessType.PROPERTY; - //FIXME enlever in niveau - if (defaultAccessTypeForHierarchy =3D=3D null) { - this.defaultAccessTypeForHierarchy =3D context.getDefaultAccessTyp= eForHerarchy( searchedElement ); - //we've discovered the class hierarchy, let's cache it - if ( defaultAccessTypeForHierarchy =3D=3D null ) { - this.defaultAccessTypeForHierarchy =3D accessType; - context.addAccessTypeForHierarchy( searchedElement, defaultAccess= TypeForHierarchy ); - //FIXME should we add - //context.addAccessTypeForHierarchy( element, defaultAccessTypeFo= rHierarchy ); - } - } - if ( forcedAccessType =3D=3D null) { - context.addAccessType( searchedElement, accessType ); - pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type = " + searchedElement + ":" + accessType ); - return accessType; - } - else { - return forcedAccessType; - } - } - } - } - } - } - return forcedAccessType; - } - - @Override - public String toString() { - final StringBuilder sb =3D new StringBuilder(); - sb.append( "MetaEntity" ); - sb.append( "{element=3D" ).append( element ); - sb.append( '}' ); - return sb.toString(); - } - - static Map COLLECTIONS =3D new HashMap(); - - static { - COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.Co= llectionAttribute" ); - COLLECTIONS.put( "java.util.Set", "javax.persistence.metamodel.SetAttrib= ute" ); - COLLECTIONS.put( "java.util.List", "javax.persistence.metamodel.ListAttr= ibute" ); - COLLECTIONS.put( "java.util.Map", "javax.persistence.metamodel.MapAttrib= ute" ); - } - - class TypeVisitor extends SimpleTypeVisitor6 { - - MetaEntity parent; - //if null, process all members as implicit - //if not null, only process members marked as @Access(explicitAccessType) - private AccessType explicitAccessType; - - TypeVisitor(MetaEntity parent, AccessType explicitAccessType) { - this.parent =3D parent; - this.explicitAccessType =3D explicitAccessType; - } - - @Override - protected MetaAttribute defaultAction(TypeMirror e, Element p) { - return super.defaultAction( e, p ); - } - - @Override - public MetaAttribute visitPrimitive(PrimitiveType t, Element element) { - if ( isPersistent( element ) ) { - return new MetaSingleAttribute( parent, element, TypeUtils.toTypeStrin= g( t ) ); - } - else { - return null; - } - } - - private boolean isPersistent(Element element) { - //FIXME consider XML - boolean correctAccessType =3D false; - if (this.explicitAccessType =3D=3D null) { - correctAccessType =3D true; - } - else { - final Access accessAnn =3D element.getAnnotation( Access.class ); - if ( accessAnn !=3D null && explicitAccessType.equals( accessAnn.value= () ) ) { - correctAccessType =3D true; - } - } - return correctAccessType - && element.getAnnotation( Transient.class ) =3D=3D null - && !element.getModifiers().contains( Modifier.TRANSIENT ) - && !element.getModifiers().contains( Modifier.STATIC ); - - } - - - @Override - public MetaAttribute visitDeclared(DeclaredType t, Element element) { - //FIXME consider XML - if ( isPersistent( element ) ) { - TypeElement returnedElement =3D ( TypeElement ) pe.getTypeUtils().asEl= ement( t ); - String collection =3D COLLECTIONS.get( returnedElement.getQualifiedNam= e().toString() ); // WARNING: .toString() is necessary here since Name equa= ls does not compare to String - - if ( collection !=3D null ) { - //collection of element - if ( element.getAnnotation( ElementCollection.class ) !=3D null ) { - final TypeMirror collectionType =3D t.getTypeArguments().get( 0 ); - final TypeElement collectionElement =3D ( TypeElement ) pe.getTypeUt= ils().asElement( collectionType ); - this.parent.context.processElement( collectionElement, - this.parent.defaultAccessTypeForElement ); - } - if ( collection.equals( "javax.persistence.metamodel.MapAttribute" ) = ) { - return new MetaMap( parent, element, collection, getKeyType( t ), ge= tElementType( t ) ); - } - else { - return new MetaCollection( parent, element, collection, getElementTy= pe( t ) ); - } - } - else { - //FIXME Consider XML - if ( element.getAnnotation( Embedded.class ) !=3D null - || returnedElement.getAnnotation( Embeddable.class ) !=3D null ) { - this.parent.context.processElement( returnedElement, = - this.parent.defaultAccessTypeForElement ); - } - return new MetaSingleAttribute( parent, element, returnedElement.getQ= ualifiedName().toString() ); - } - } - else { - return null; - } - } - - - @Override - public MetaAttribute visitExecutable(ExecutableType t, Element p) { - String string =3D p.getSimpleName().toString(); - - // TODO: implement proper property get/is/boolean detection - if ( string.startsWith( "get" ) || string.startsWith( "is" ) ) { - TypeMirror returnType =3D t.getReturnType(); - - return returnType.accept( this, p ); - } - else { - return null; - } - } - } - - public String generateImports() { - return importContext.generateImports(); - } - - public String importType(String fqcn) { - return importContext.importType( fqcn ); - } - - public String staticImport(String fqcn, String member) { - return importContext.staticImport( fqcn, member ); - } - - public String importType(Name qualifiedName) { - return importType( qualifiedName.toString() ); - } - - public TypeElement getTypeElement() { - return element; - } - - private String getKeyType(DeclaredType t) { - return t.getTypeArguments().get( 0 ).toString(); - } - - - private String getElementType(DeclaredType declaredType) { - if ( declaredType.getTypeArguments().size() =3D=3D 1 ) { - return declaredType.getTypeArguments().get( 0 ).toString(); - } - else { - return declaredType.getTypeArguments().get( 1 ).toString(); - } - } -} Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotati= on/MetaMap.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Me= taMap.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Me= taMap.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -1,42 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.annotation; - -import javax.lang.model.element.Element; - -/** - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -public class MetaMap extends MetaCollection { - - private final String keyType; - - public MetaMap(MetaEntity parent, Element element, String collectionType, - String keyType, String elementType) { - super(parent, element, collectionType, elementType); - this.keyType =3D keyType; = - } - = - public String getDeclarationString() { - return "public static volatile " + parent.importType(getMetaType()) + "<= " + parent.importType(parent.getQualifiedName()) + ", " + parent.importType= (keyType) + ", " + parent.importType(getTypeDeclaration()) + "> " + getProp= ertyName() + ";"; = - } - -} Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotati= on/MetaSingleAttribute.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Me= taSingleAttribute.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Me= taSingleAttribute.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -1,41 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.annotation; - -import org.hibernate.jpamodelgen.IMetaSingleAttribute; - -import javax.lang.model.element.Element; - -/** - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -public class MetaSingleAttribute extends MetaAttribute implements IMetaSin= gleAttribute { - - public MetaSingleAttribute(MetaEntity parent, Element element, String typ= e) { - super(parent, element, type); - } - - @Override - public String getMetaType() { - return "javax.persistence.metamodel.SingularAttribute"; - } - -} Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/Xml= MetaAttribute.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAt= tribute.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAt= tribute.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -18,12 +18,12 @@ = package org.hibernate.jpamodelgen.xml; = -import org.hibernate.jpamodelgen.IMetaAttribute; +import org.hibernate.jpamodelgen.MetaAttribute; = /** * @author Hardy Ferentschik */ -public abstract class XmlMetaAttribute implements IMetaAttribute { +public abstract class XmlMetaAttribute implements MetaAttribute { = private XmlMetaEntity parentEntity; = Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/Xml= MetaCollection.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCo= llection.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCo= llection.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -17,12 +17,12 @@ */ package org.hibernate.jpamodelgen.xml; = -import org.hibernate.jpamodelgen.IMetaCollection; +import org.hibernate.jpamodelgen.MetaCollection; = /** * @author Hardy Ferentschik */ -public class XmlMetaCollection extends XmlMetaAttribute implements IMetaCo= llection { +public class XmlMetaCollection extends XmlMetaAttribute implements MetaCol= lection { = String collectionType; = Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/Xml= MetaEntity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEn= tity.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEn= tity.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -26,9 +26,9 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; = -import org.hibernate.jpamodelgen.IMetaAttribute; +import org.hibernate.jpamodelgen.MetaAttribute; import org.hibernate.jpamodelgen.ImportContextImpl; -import org.hibernate.jpamodelgen.IMetaEntity; +import org.hibernate.jpamodelgen.MetaEntity; import org.hibernate.jpamodelgen.ImportContext; import org.hibernate.jpamodelgen.xml.jaxb.Attributes; import org.hibernate.jpamodelgen.xml.jaxb.Basic; @@ -45,7 +45,7 @@ /** * @author Hardy Ferentschik */ -public class XmlMetaEntity implements IMetaEntity { +public class XmlMetaEntity implements MetaEntity { = static Map COLLECTIONS =3D new HashMap(); = @@ -62,7 +62,7 @@ = final private ImportContext importContext; = - final private List members =3D new ArrayList(); + final private List members =3D new ArrayList(); = private TypeElement element; = @@ -135,7 +135,7 @@ return packageName; } = - public List getMembers() { + public List getMembers() { return members; } = Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/Xml= MetaSingleAttribute.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSi= ngleAttribute.java 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSi= ngleAttribute.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -17,12 +17,12 @@ */ package org.hibernate.jpamodelgen.xml; = -import org.hibernate.jpamodelgen.IMetaSingleAttribute; +import org.hibernate.jpamodelgen.MetaSingleAttribute; = /** * @author Hardy Ferentschik */ -public class XmlMetaSingleAttribute extends XmlMetaAttribute implements IM= etaSingleAttribute { +public class XmlMetaSingleAttribute extends XmlMetaAttribute implements Me= taSingleAttribute { = public XmlMetaSingleAttribute(XmlMetaEntity parent, String propertyNam= e, String type) { super(parent, propertyName, type); Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Acce= ssTypeTest.java (from rev 17898, jpamodelgen/trunk/src/test/java/test/Acces= sTypeTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTy= peTest.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTy= peTest.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,93 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test; + +import org.testng.annotations.Test; +import org.testng.Assert; + +/** + * @author Emmanuel Bernard + */ +public class AccessTypeTest { + + @Test + public void testExcludeTransientFieldAndStatic() throws Exception{ + absenceOfField( "org.hibernate.jpamodelgen.test.model.Product_", "nonPer= sistent" ); + absenceOfField( "org.hibernate.jpamodelgen.test.model.Product_", "nonPer= sistent2" ); + } + + @Test + public void testDefaultAccessTypeOnEntity() throws Exception{ + absenceOfField( "org.hibernate.jpamodelgen.test.model.User_", "nonPersis= tent" ); + } + + @Test + public void testDefaultAccessTypeForSubclassOfEntity() throws Exception{ + absenceOfField( "org.hibernate.jpamodelgen.test.model.Customer_", "nonPe= rsistent" ); + } + + @Test + public void testDefaultAccessTypeForEmbeddable() throws Exception{ + absenceOfField( "org.hibernate.jpamodelgen.test.model.Detail_", "nonPers= istent" ); + } + + @Test + public void testInheritedAccessTypeForEmbeddable() throws Exception{ + absenceOfField( "org.hibernate.jpamodelgen.test.model.Country_", "nonPer= sistent" ); + absenceOfField( "org.hibernate.jpamodelgen.test.model.Pet_", "nonPersist= ent", "Colleciton of membeddable not taken care of" ); + } + + @Test + public void testDefaultAccessTypeForMappedSuperclass() throws Exception{ + absenceOfField( "org.hibernate.jpamodelgen.test.model.Detail_", "volume"= ); + } + + @Test + public void testExplicitAccessTypeAndDefaultFromRootEntity() throws Excep= tion{ + absenceOfField( "org.hibernate.jpamodelgen.test.model.LivingBeing_", "no= nPersistent", "eplicit access type on mapped superclass" ); + absenceOfField( "org.hibernate.jpamodelgen.test.model.Hominidae_", "nonP= ersistent", "eplicit access type on entity" ); + absenceOfField( "org.hibernate.jpamodelgen.test.model.Human_", "nonPersi= stent", "proper inheritance from root entity access type" ); + } + + @Test + public void testMemberAccessType() throws Exception{ + presenceOfField( "org.hibernate.jpamodelgen.test.model.Customer_", "good= Payer", "access type overriding" ); + } + + private void absenceOfField(String className, String fieldName) throws Cl= assNotFoundException { + absenceOfField( className, fieldName, "field should not be persistent" ); + } + private void absenceOfField(String className, String fieldName, String er= rorString) throws ClassNotFoundException { + Assert.assertFalse( isFieldHere(className, fieldName), errorString ); + } + + private void presenceOfField(String className, String fieldName, String e= rrorString) throws ClassNotFoundException { + Assert.assertTrue( isFieldHere(className, fieldName), errorString ); + } + + private boolean isFieldHere(String className, String fieldName) throws Cl= assNotFoundException { + Class user_ =3D Class.forName( className ); + try { + user_.getField( fieldName ); + return true; + } + catch (NoSuchFieldException e) { + return false; + } + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/AccessTypeTest.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Inhe= ritanceTest.java (from rev 17898, jpamodelgen/trunk/src/test/java/test/Inhe= ritanceTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Inherita= nceTest.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Inherita= nceTest.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,45 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test; + +import org.testng.annotations.Test; +import org.testng.Assert; +import org.hibernate.jpamodelgen.test.model.Customer_; +import org.hibernate.jpamodelgen.test.model.User_; +import org.hibernate.jpamodelgen.test.model.House_; +import org.hibernate.jpamodelgen.test.model.Building_; +import org.hibernate.jpamodelgen.test.model.Area_; + +/** + * @author Emmanuel Bernard + */ +public class InheritanceTest { + @Test + public void testSuperEntity() throws Exception { + Assert.assertEquals( Customer_.class.getSuperclass(), User_.class, + "Entity with super entity should inherit at the metamodel level"); + } + + @Test + public void testMappedSuperclass() throws Exception { + Assert.assertEquals( House_.class.getSuperclass(), Building_.class, + "Entity with mapped superclass should inherit at the metamodel level"); + Assert.assertEquals( Building_.class.getSuperclass(), Area_.class, + "mapped superclass with mapped superclass should inherit at the metamo= del level"); + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/InheritanceTest.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Quer= yTest.java (from rev 17898, jpamodelgen/trunk/src/test/java/test/QueryTest.= java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTes= t.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTes= t.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,166 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.Set; +import javax.persistence.Tuple; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Expression; +import javax.persistence.criteria.Join; +import static javax.persistence.criteria.JoinType.INNER; +import javax.persistence.criteria.ListJoin; +import javax.persistence.criteria.Path; +import javax.persistence.criteria.Root; + +import org.hibernate.jpamodelgen.test.model.Item; +import org.hibernate.jpamodelgen.test.model.Item_; +import org.hibernate.jpamodelgen.test.model.Order; +import org.hibernate.jpamodelgen.test.model.Order_; +import org.hibernate.jpamodelgen.test.model.Product; +import org.hibernate.jpamodelgen.test.model.Product_; +import org.hibernate.jpamodelgen.test.model.Shop_; + +/** + * Writing queries involves passing typesafe, statically cached, metamodel + * objects to the query builder in order to create the various parts of + * the query. The typesafe metamodel objects were validated at init time, + * so it is impossible to build invalid queries in the application code. + * + * @author Max Andersen + * @author Hardy Ferentschik + * @author Emmanuel Bernard + */ +public class QueryTest { + + CriteriaBuilder qb; + + public void test() { + CriteriaQuery q =3D qb.createTupleQuery(); + + Root order =3D q.from( Order.class ); + Join product =3D order.join( Order_.items ) + .join( Item_.product ); + + Path price =3D product.get( Product_.price ); + Path filled =3D order.get( Order_.filled ); + Path date =3D order.get( Order_.date ); + + q.select( qb.tuple( order, product ) ) + .where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) ) + .orderBy( qb.asc( price ), qb.desc( date ) ); + } + + public void testUntypesafe() { + CriteriaQuery q =3D qb.createTupleQuery(); + + Root order =3D q.from( Order.class ); + Join product =3D order.join( "items" ) + .join( "product" ); + + Path price =3D product.get( "price" ); + Path filled =3D order.get( "filled" ); + Path date =3D order.get( "date" ); + + q.select( qb.tuple( order, product ) ) + .where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) ) + .orderBy( qb.asc( price ), qb.desc( date ) ); + } + + /** + * Navigation by joining + */ + public void test2() { + CriteriaQuery q =3D qb.createQuery( Product.class ); + + Root product =3D q.from( Product.class ); + Join order =3D product.join( Product_.items ) + .join( Item_.order ); + + q.select( product ) + .where( qb.equal( order.get( Order_.id ), 12345l ) ); + } + + public void testMap() { + CriteriaQuery q =3D qb.createQuery( Item.class ); + + Root item =3D q.from( Item.class ); + item.join( Item_.namedOrders ); + } + + /** + * Navigation by compound Path + */ + public void test3() { + CriteriaQuery q =3D qb.createQuery( Item.class ); + + Root item =3D q.from( Item.class ); + Path shopName =3D item.get( Item_.order ) + .get( Order_.shop ) + .get( Shop_.name ); + q.select( item ) + .where( qb.equal( shopName, "amazon.com" ) ); + } + +// public void test4() { +// CriteriaQuery q =3D qb.create(); +// +// Root order =3D q.from(Order.class); +// ListJoin note =3D order.join(Order_.notes); +// Expression> items =3D order.get(Order_.items); +// order.fetch(Order_.items, JoinType.INNER); +// +// q.select(note) +// .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) ); +// } + + public void test4Untypesafe() { + CriteriaQuery q =3D qb.createQuery( String.class ); + + Root order =3D q.from( Order.class ); + ListJoin note =3D order.joinList( "notes" ); + Expression> items =3D order.get( "items" ); + order.fetch( "items", INNER ); + + q.select( note ) + .where( qb.and( qb.lt( note.index(), 10 ), qb.isNotEmpty( items ) ) ); + } + + /*public void test5() { + Expression l=3D null; + Expression i=3D null; + Expression x=3D null; + Expression y=3D null; + = + Expression n; + Expression f; + Expression s =3D null; + = + n =3D qb.quot(l, i); + = + f =3D qb.sum(x, y); + = + n =3D qb.quot(x, y); + = + javax.jpamodelgen.criteria.Order o =3D qb.asc(n); + javax.jpamodelgen.criteria.Order p =3D qb.ascending(s); + }*/ + +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/QueryTest.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlM= appingTest.java (from rev 17898, jpamodelgen/trunk/src/test/java/test/XmlMa= ppingTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappi= ngTest.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappi= ngTest.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,55 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.Test; + +/** + * @author Hardy Ferentschik + */ +public class XmlMappingTest { + @Test + public void testXmlConfiguredEmbeddedClassGenerated() throws Exception { + assertNotNull( Class.forName( "org.hibernate.jpamodelgen.test.model.xmlm= apped.Address_" ) ); + } + + @Test + public void testXmlConfiguredMappedSuperclassGenerated() throws Exception= { + Class building =3D Class.forName( "org.hibernate.jpamodelgen.test.mod= el.xmlmapped.Building_" ); + assertNotNull( building ); + assertNotNull( building.getField( "address" ) ); + } + + @Test + public void testClassHierarchy() throws Exception { + Class mammal =3D Class.forName( "org.hibernate.jpamodelgen.test.model= .xmlmapped.Mammal_" ); + assertNotNull( mammal ); + + Class being =3D Class.forName( "org.hibernate.jpamodelgen.test.model.= xmlmapped.LivingBeing_" ); + assertNotNull( being ); + + assertTrue( mammal.getSuperclass().equals( being ) ); + } + + @Test(expectedExceptions =3D ClassNotFoundException.class) + public void testNonExistentMappedClassesGetIgnored() throws Exception { + Class.forName( "org.hibernate.jpamodelgen.test.model.Dummy_" ); + } +} \ No newline at end of file Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/XmlMappingTest.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mode= l (from rev 17898, jpamodelgen/trunk/src/test/java/model) Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Address.java 2009-11-03 05:13:23 = UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ad= dress.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,12 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import java.util.Set; import javax.persistence.Embeddable; import javax.persistence.Access; -import javax.persistence.AccessType; import javax.persistence.ElementCollection; import javax.persistence.CollectionTable; = Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Area.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Area.java 2009-11-03 05:13:23 UTC= (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ar= ea.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.MappedSuperclass; = Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Building.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Building.java 2009-11-03 05:13:23= UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Bu= ilding.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.MappedSuperclass; = Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Country.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Country.java 2009-11-03 05:13:23 = UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Co= untry.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.Embeddable; = Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Customer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Customer.java 2009-11-03 05:13:23= UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Cu= stomer.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import java.util.Set; import javax.persistence.Entity; Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Detail.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Detail.java 2009-11-03 05:13:23 U= TC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/De= tail.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.Embeddable; = Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Hominidae.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Hominidae.java 2009-11-03 05:13:2= 3 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ho= minidae.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,11 +15,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.Entity; import javax.persistence.Access; -import javax.persistence.AccessType; = /** * @author Emmanuel Bernard Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/House.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/House.java 2009-11-03 05:13:23 UT= C (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ho= use.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.Id; import javax.persistence.Entity; Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Human.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Human.java 2009-11-03 05:13:23 UT= C (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hu= man.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.Entity; = Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mode= l/Image.java (from rev 17898, jpamodelgen/trunk/src/test/java/model/Human.j= ava) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Im= age.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Im= age.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,46 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.model; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Image { + private String name; + + private byte[] data; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public byte[] getData() { + return data; + } + + public void setData(byte[] data) { + this.data =3D data; + } +} \ No newline at end of file Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Inhabitant.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Inhabitant.java 2009-11-03 05:13:= 23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/In= habitant.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,12 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import java.util.Set; import javax.persistence.Embeddable; import javax.persistence.Access; -import javax.persistence.AccessType; import javax.persistence.ElementCollection; = /** Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Item.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Item.java 2009-11-03 05:13:23 UTC= (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/It= em.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,10 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import java.util.Map; -import java.util.Set; = import javax.persistence.Entity; import javax.persistence.Id; Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/LivingBeing.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/LivingBeing.java 2009-11-03 05:13= :23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Li= vingBeing.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,11 +15,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.MappedSuperclass; import javax.persistence.Access; -import javax.persistence.AccessType; = /** * @author Emmanuel Bernard Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Mammals.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Mammals.java 2009-11-03 05:13:23 = UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ma= mmals.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.Entity; import javax.persistence.Id; Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Order.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Order.java 2009-11-03 05:13:23 UT= C (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Or= der.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import java.util.Date; import java.util.List; Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Pet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Pet.java 2009-11-03 05:13:23 UTC = (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pe= t.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.Embeddable; = Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Product.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Product.java 2009-11-03 05:13:23 = UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pr= oduct.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import java.math.BigDecimal; import java.util.Set; Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/Shop.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/Shop.java 2009-11-03 05:13:23 UTC= (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Sh= op.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.Entity; import javax.persistence.Id; Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/User.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/User.java 2009-11-03 05:13:23 UTC= (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Us= er.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model; +package org.hibernate.jpamodelgen.test.model; = import javax.persistence.Entity; import javax.persistence.Id; Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/xmlmapped/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/xmlmapped/Address.java 2009-11-03= 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/Address.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model.xmlmapped; +package org.hibernate.jpamodelgen.test.model.xmlmapped; = /** * @author Hardy Ferentschik Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/xmlmapped/Building.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/xmlmapped/Building.java 2009-11-0= 3 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/Building.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,10 +15,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model.xmlmapped; +package org.hibernate.jpamodelgen.test.model.xmlmapped; = -import model.Address; -import model.Area; +import org.hibernate.jpamodelgen.test.model.Address; +import org.hibernate.jpamodelgen.test.model.Area; = /** * @author Hardy Ferentschik Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/xmlmapped/LivingBeing.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/xmlmapped/LivingBeing.java 2009-1= 1-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/LivingBeing.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model.xmlmapped; +package org.hibernate.jpamodelgen.test.model.xmlmapped; = /** * @author Hardy Ferentschik Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mo= del/xmlmapped/Mammal.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/model/xmlmapped/Mammal.java 2009-11-03 = 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/Mammal.java 2009-11-03 14:52:05 UTC (rev 17899) @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package model.xmlmapped; +package org.hibernate.jpamodelgen.test.model.xmlmapped; = /** * @author Hardy Ferentschik Deleted: jpamodelgen/trunk/src/test/java/test/AccessTypeTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/test/AccessTypeTest.java 2009-11-03 05:= 13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/test/AccessTypeTest.java 2009-11-03 14:= 52:05 UTC (rev 17899) @@ -1,94 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package test; - -import org.testng.annotations.Test; -import org.testng.Assert; - -/** - * @author Emmanuel Bernard - */ -(a)Test -public class AccessTypeTest { - - @Test - public void testExcludeTransientFieldAndStatic() throws Exception{ - absenceOfField( "model.Product_", "nonPersistent" ); - absenceOfField( "model.Product_", "nonPersistent2" ); - } - - @Test - public void testDefaultAccessTypeOnEntity() throws Exception{ - absenceOfField( "model.User_", "nonPersistent" ); - } - - @Test - public void testDefaultAccessTypeForSubclassOfEntity() throws Exception{ - absenceOfField( "model.Customer_", "nonPersistent" ); - } - - @Test - public void testDefaultAccessTypeForEmbeddable() throws Exception{ - absenceOfField( "model.Detail_", "nonPersistent" ); - } - - @Test - public void testInheritedAccessTypeForEmbeddable() throws Exception{ - absenceOfField( "model.Country_", "nonPersistent" ); - absenceOfField( "model.Pet_", "nonPersistent", "Colleciton of membeddabl= e not taken care of" ); - } - - @Test - public void testDefaultAccessTypeForMappedSuperclass() throws Exception{ - absenceOfField( "model.Detail_", "volume" ); - } - - @Test - public void testExplicitAccessTypeAndDefaultFromRootEntity() throws Excep= tion{ - absenceOfField( "model.LivingBeing_", "nonPersistent", "eplicit access t= ype on mapped superclass" ); - absenceOfField( "model.Hominidae_", "nonPersistent", "eplicit access typ= e on entity" ); - absenceOfField( "model.Human_", "nonPersistent", "proper inheritance fro= m root entity access type" ); - } - - @Test - public void testMemberAccessType() throws Exception{ - presenceOfField( "model.Customer_", "goodPayer", "access type overriding= " ); - } - - private void absenceOfField(String className, String fieldName) throws Cl= assNotFoundException { - absenceOfField( className, fieldName, "field should not be persistent" ); - } - private void absenceOfField(String className, String fieldName, String er= rorString) throws ClassNotFoundException { - Assert.assertFalse( isFieldHere(className, fieldName), errorString ); - } - - private void presenceOfField(String className, String fieldName, String e= rrorString) throws ClassNotFoundException { - Assert.assertTrue( isFieldHere(className, fieldName), errorString ); - } - - private boolean isFieldHere(String className, String fieldName) throws Cl= assNotFoundException { - Class user_ =3D Class.forName( className ); - try { - user_.getField( fieldName ); - return true; - } - catch (NoSuchFieldException e) { - return false; - } - } -} Deleted: jpamodelgen/trunk/src/test/java/test/InheritanceTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/test/InheritanceTest.java 2009-11-03 05= :13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/test/InheritanceTest.java 2009-11-03 14= :52:05 UTC (rev 17899) @@ -1,46 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package test; - -import org.testng.annotations.Test; -import org.testng.Assert; -import model.Customer_; -import model.User_; -import model.House_; -import model.Building_; -import model.Area_; - -/** - * @author Emmanuel Bernard - */ -(a)Test -public class InheritanceTest { - @Test - public void testSuperEntity() throws Exception { - Assert.assertEquals( Customer_.class.getSuperclass(), User_.class, - "Entity with super entity should inherit at the metamodel level"); - } - - @Test - public void testMappedSuperclass() throws Exception { - Assert.assertEquals( House_.class.getSuperclass(), Building_.class, - "Entity with mapped superclass should inherit at the metamodel level"); - Assert.assertEquals( Building_.class.getSuperclass(), Area_.class, - "mapped superclass with mapped superclass should inherit at the metamo= del level"); - } -} Deleted: jpamodelgen/trunk/src/test/java/test/QueryTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/test/QueryTest.java 2009-11-03 05:13:23= UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/test/QueryTest.java 2009-11-03 14:52:05= UTC (rev 17899) @@ -1,166 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package test; - -import java.math.BigDecimal; -import java.util.Date; -import java.util.Set; -import javax.persistence.Tuple; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Join; -import static javax.persistence.criteria.JoinType.INNER; -import javax.persistence.criteria.ListJoin; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Root; - -import model.Item; -import model.Item_; -import model.Order; -import model.Order_; -import model.Product; -import model.Product_; -import model.Shop_; - -/** - * Writing queries involves passing typesafe, statically cached, metamodel - * objects to the query builder in order to create the various parts of - * the query. The typesafe metamodel objects were validated at init time, - * so it is impossible to build invalid queries in the application code. - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -public class QueryTest { - - CriteriaBuilder qb; - - public void test() { - CriteriaQuery q =3D qb.createTupleQuery(); - - Root order =3D q.from( Order.class ); - Join product =3D order.join( Order_.items ) - .join( Item_.product ); - - Path price =3D product.get( Product_.price ); - Path filled =3D order.get( Order_.filled ); - Path date =3D order.get( Order_.date ); - - q.select( qb.tuple( order, product ) ) - .where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) ) - .orderBy( qb.asc( price ), qb.desc( date ) ); - } - - public void testUntypesafe() { - CriteriaQuery q =3D qb.createTupleQuery(); - - Root order =3D q.from( Order.class ); - Join product =3D order.join( "items" ) - .join( "product" ); - - Path price =3D product.get( "price" ); - Path filled =3D order.get( "filled" ); - Path date =3D order.get( "date" ); - - q.select( qb.tuple( order, product ) ) - .where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) ) - .orderBy( qb.asc( price ), qb.desc( date ) ); - } - - /** - * Navigation by joining - */ - public void test2() { - CriteriaQuery q =3D qb.createQuery( Product.class ); - - Root product =3D q.from( Product.class ); - Join order =3D product.join( Product_.items ) - .join( Item_.order ); - - q.select( product ) - .where( qb.equal( order.get( Order_.id ), 12345l ) ); - } - - public void testMap() { - CriteriaQuery q =3D qb.createQuery( Item.class ); - - Root item =3D q.from( Item.class ); - item.join( Item_.namedOrders ); - } - - /** - * Navigation by compound Path - */ - public void test3() { - CriteriaQuery q =3D qb.createQuery( Item.class ); - - Root item =3D q.from( Item.class ); - Path shopName =3D item.get( Item_.order ) - .get( Order_.shop ) - .get( Shop_.name ); - q.select( item ) - .where( qb.equal( shopName, "amazon.com" ) ); - } - -// public void test4() { -// CriteriaQuery q =3D qb.create(); -// -// Root order =3D q.from(Order.class); -// ListJoin note =3D order.join(Order_.notes); -// Expression> items =3D order.get(Order_.items); -// order.fetch(Order_.items, JoinType.INNER); -// -// q.select(note) -// .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) ); -// } - - public void test4Untypesafe() { - CriteriaQuery q =3D qb.createQuery( String.class ); - - Root order =3D q.from( Order.class ); - ListJoin note =3D order.joinList( "notes" ); - Expression> items =3D order.get( "items" ); - order.fetch( "items", INNER ); - - q.select( note ) - .where( qb.and( qb.lt( note.index(), 10 ), qb.isNotEmpty( items ) ) ); - } - - /*public void test5() { - Expression l=3D null; - Expression i=3D null; - Expression x=3D null; - Expression y=3D null; - = - Expression n; - Expression f; - Expression s =3D null; - = - n =3D qb.quot(l, i); - = - f =3D qb.sum(x, y); - = - n =3D qb.quot(x, y); - = - javax.jpamodelgen.criteria.Order o =3D qb.asc(n); - javax.jpamodelgen.criteria.Order p =3D qb.ascending(s); - }*/ - -} Deleted: jpamodelgen/trunk/src/test/java/test/XmlMappingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/test/XmlMappingTest.java 2009-11-03 05:= 13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/java/test/XmlMappingTest.java 2009-11-03 14:= 52:05 UTC (rev 17899) @@ -1,55 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package test; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import org.testng.annotations.Test; - -/** - * @author Hardy Ferentschik - */ -public class XmlMappingTest { - @Test - public void testXmlConfiguredEmbeddedClassGenerated() throws Exception { - assertNotNull( Class.forName( "model.xmlmapped.Address_" ) ); - } - - @Test - public void testXmlConfiguredMappedSuperclassGenerated() throws Exception= { - Class building =3D Class.forName( "model.xmlmapped.Building_" ); - assertNotNull( building ); - assertNotNull( building.getField( "address" ) ); - } - - @Test - public void testClassHierarchy() throws Exception { - Class mammal =3D Class.forName( "model.xmlmapped.Mammal_" ); - assertNotNull( mammal ); - - Class being =3D Class.forName( "model.xmlmapped.LivingBeing_" ); - assertNotNull( being ); - - assertTrue( mammal.getSuperclass().equals( being ) ); - } - - @Test(expectedExceptions =3D ClassNotFoundException.class) - public void testNonExistentMappedClassesGetIgnored() throws Exception { - Class.forName( "model.Dummy_" ); - } -} \ No newline at end of file Modified: jpamodelgen/trunk/src/test/resources/META-INF/dummy.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/META-INF/dummy.xml 2009-11-03 05:1= 3:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/resources/META-INF/dummy.xml 2009-11-03 14:5= 2:05 UTC (rev 17899) @@ -5,7 +5,7 @@ xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persiste= nce/orm orm_2_0.xsd" version=3D"2.0" > - model + org.hibernate.jpamodelgen.test.model <= !-- Class does not exist --> Modified: jpamodelgen/trunk/src/test/resources/META-INF/jpa1-orm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/META-INF/jpa1-orm.xml 2009-11-03 0= 5:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/resources/META-INF/jpa1-orm.xml 2009-11-03 1= 4:52:05 UTC (rev 17899) @@ -5,7 +5,7 @@ xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persiste= nce/orm orm_1_0.xsd" version=3D"1.0" > - model + org.hibernate.jpamodelgen.test.model Modified: jpamodelgen/trunk/src/test/resources/META-INF/malformed-mapping-x= ml.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/META-INF/malformed-mapping-xml.xml= 2009-11-03 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/resources/META-INF/malformed-mapping-xml.xml= 2009-11-03 14:52:05 UTC (rev 17899) @@ -5,7 +5,7 @@ xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persiste= nce/orm orm_2_0.xsd" version=3D"2.0" > - model + org.hibernate.jpamodelgen.test.model <= !-- Class does not exist --> Modified: jpamodelgen/trunk/src/test/resources/META-INF/orm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/META-INF/orm.xml 2009-11-03 05:13:= 23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/resources/META-INF/orm.xml 2009-11-03 14:52:= 05 UTC (rev 17899) @@ -5,7 +5,7 @@ xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persiste= nce/orm orm_2_0.xsd" version=3D"2.0" > - model + org.hibernate.jpamodelgen.test.model <= !--means ignore annotations--> Modified: jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml 2009-11-0= 3 05:13:23 UTC (rev 17898) +++ jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml 2009-11-0= 3 14:52:05 UTC (rev 17899) @@ -7,8 +7,8 @@ /META-INF/dummy.xml /META-INF/malformed-mapping-xml.xml /META-INF/jpa1-orm.xml - /model/xmlmapped/address.xml - /model/xmlmapped/building.xml - /model/xmlmapped/mammal.xml + /org/hibernate/jpamodelgen/test/model/xmlmapped/addr= ess.xml + /org/hibernate/jpamodelgen/test/model/xmlmapped/buil= ding.xml + /org/hibernate/jpamodelgen/test/model/xmlmapped/mamm= al.xml Copied: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test= /model/xmlmapped/address.xml (from rev 17898, jpamodelgen/trunk/src/test/re= sources/model/xmlmapped/address.xml) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/address.xml (rev 0) +++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/address.xml 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,17 @@ + + + + org.hibernate.jpamodelgen.test.model.xmlmapped + + + + + + + + + Property changes on: jpamodelgen/trunk/src/test/resources/org/hibernate/jpa= modelgen/test/model/xmlmapped/address.xml ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test= /model/xmlmapped/building.xml (from rev 17898, jpamodelgen/trunk/src/test/r= esources/model/xmlmapped/building.xml) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/building.xml (rev 0) +++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/building.xml 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,15 @@ + + + + org.hibernate.jpamodelgen.test.model.xmlmapped + + + + + + + Property changes on: jpamodelgen/trunk/src/test/resources/org/hibernate/jpa= modelgen/test/model/xmlmapped/building.xml ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test= /model/xmlmapped/mammal.xml (from rev 17898, jpamodelgen/trunk/src/test/res= ources/model/xmlmapped/mammal.xml) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/mammal.xml (rev 0) +++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/mammal.xml 2009-11-03 14:52:05 UTC (rev 17899) @@ -0,0 +1,20 @@ + + + + org.hibernate.jpamodelgen.test.model.xmlmapped + + + + + + + + + + + + Property changes on: jpamodelgen/trunk/src/test/resources/org/hibernate/jpa= modelgen/test/model/xmlmapped/mammal.xml ___________________________________________________________________ Name: svn:keywords + Id Modified: jpamodelgen/trunk/src/test/suite/unit-tests.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-03 05:13:23 UTC= (rev 17898) +++ jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-03 14:52:05 UTC= (rev 17899) @@ -3,7 +3,7 @@ - + \ No newline at end of file --===============8873614491184445231==-- From hibernate-commits at lists.jboss.org Tue Nov 3 09:55:48 2009 Content-Type: multipart/mixed; boundary="===============7017231616910436562==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17900 - in search/trunk/src: main/java/org/hibernate/search/backend and 1 other directories. Date: Tue, 03 Nov 2009 09:55:48 -0500 Message-ID: <200911031455.nA3EtmYS032761@svn01.web.mwc.hst.phx2.redhat.com> --===============7017231616910436562== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: sannegrinovero Date: 2009-11-03 09:55:47 -0500 (Tue, 03 Nov 2009) New Revision: 17900 Modified: search/trunk/src/main/docbook/en-US/modules/configuration.xml search/trunk/src/main/java/org/hibernate/search/backend/LuceneIndexingPa= rameters.java search/trunk/src/test/java/org/hibernate/search/test/configuration/Lucen= eIndexingParametersTest.java Log: HSEARCH-201 IndexWriter settings meant for transactional operations won't b= e inherited by the settings meant for batch operations Modified: search/trunk/src/main/docbook/en-US/modules/configuration.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/docbook/en-US/modules/configuration.xml 2009-11-0= 3 14:52:05 UTC (rev 17899) +++ search/trunk/src/main/docbook/en-US/modules/configuration.xml 2009-11-0= 3 14:55:47 UTC (rev 17900) @@ -709,13 +709,10 @@ ), the used properties are those grouped under the batch keyword: hi= bernate.search.[default|<indexname>].indexwriter.batch.<parameter_= name> = - Unless the corresponding .batch property is - explicitly set, the value will default to the - .transaction property. If no value is set for a + If no value is set for a .batch value in a specific shard configuration, Hibernate Search will look at the index section, then at the default - section and after that it will look for a .transaction - in the same order: hibernate.search.Animals.2.indexwri= ter.transaction.max_merge_docs 10 + section: hibernate.search.Animals.2.indexwriter.transa= ction.max_merge_docs 10 hibernate.search.Animals.2.indexwriter.transaction.merge_factor 20 hibernate.search.default.indexwriter.batch.max_merge_docs 100 This configuration will result in these settings applied to the second @@ -735,7 +732,7 @@ = - batch.merge_factor =3D 20 + batch.merge_factor =3D Lucene default = @@ -746,6 +743,10 @@ of Lucene you are using; values shown are relative to version 2.4. For more information about Lucene indexing performances, please refer to the Lucene documentation. + = + Previous versions had the batch + parameters inherit from transaction properties. + This needs now to be explicitly set. = List of indexing performance and behavior properties Modified: search/trunk/src/main/java/org/hibernate/search/backend/LuceneInd= exingParameters.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/backend/LuceneIndexingP= arameters.java 2009-11-03 14:52:05 UTC (rev 17899) +++ search/trunk/src/main/java/org/hibernate/search/backend/LuceneIndexingP= arameters.java 2009-11-03 14:55:47 UTC (rev 17900) @@ -68,8 +68,8 @@ Properties indexingParameters =3D new MaskedProperty( sourceProps, PROP_= GROUP, sourceProps ); //get keys for "transaction" Properties transactionProps =3D new MaskedProperty( indexingParameters, = TRANSACTION ); - //get keys for "batch" (defaulting to transaction) - Properties batchProps =3D new MaskedProperty( indexingParameters, BATCH,= transactionProps ); //TODO to close HSEARCH-201 just remove 3=C2=B0 parame= ter + //get keys for "batch" + Properties batchProps =3D new MaskedProperty( indexingParameters, BATCH = ); transactionIndexParameters =3D new ParameterSet( transactionProps, TRANS= ACTION ); batchIndexParameters =3D new ParameterSet( batchProps, BATCH ); doSanityChecks( transactionIndexParameters, batchIndexParameters ); Modified: search/trunk/src/test/java/org/hibernate/search/test/configuratio= n/LuceneIndexingParametersTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/configuration/Luce= neIndexingParametersTest.java 2009-11-03 14:52:05 UTC (rev 17899) +++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Luce= neIndexingParametersTest.java 2009-11-03 14:55:47 UTC (rev 17900) @@ -80,7 +80,7 @@ cfg.setProperty( "hibernate.search.Documents.batch.max_field_length", "9= " ); } = - public void testDefaultIndexProviderParameters() throws Exception { + public void testDefaultIndexProviderParameters() { assertValueIsSet( Author.class, BATCH, USE_COMPOUND_FILE, 1 ); assertValueIsSet( Author.class, TRANSACTION, RAM_BUFFER_SIZE, 2 ); assertValueIsSet( Author.class, TRANSACTION, MAX_MERGE_DOCS, 9 ); @@ -88,43 +88,37 @@ assertValueIsSet( Author.class, TRANSACTION, MERGE_FACTOR, 100 ); } = - public void testBatchParametersGlobals() throws Exception { + public void testBatchParametersGlobals() { assertValueIsSet( Author.class, BATCH, RAM_BUFFER_SIZE, 1 ); - assertValueIsSet( Author.class, BATCH, MAX_MERGE_DOCS, 9 ); + assertValueIsDefault( Author.class, BATCH, MAX_MERGE_DOCS ); assertValueIsSet( Author.class, BATCH, MAX_BUFFERED_DOCS, 1000 ); - assertValueIsSet( Author.class, BATCH, MERGE_FACTOR, 100 ); } = - public void testUnsetBatchValueTakesTransaction() throws Exception { - assertValueIsSet( Document.class, BATCH, MERGE_FACTOR, 6 ); - assertValueIsSet( Document.class, BATCH, MAX_BUFFERED_DOCS, 1000 ); - } - = - public void testMaxFieldLength() throws Exception { + public void testMaxFieldLength() { // there should also be logged a warning being logged about these: assertValueIsSet( Document.class, TRANSACTION, MAX_FIELD_LENGTH, 7 ); assertValueIsSet( Document.class, BATCH, MAX_FIELD_LENGTH, 9 ); } = - public void testExplicitBatchParameters() throws Exception { + public void testExplicitBatchParameters() { assertValueIsSet( Book.class, BATCH, MAX_MERGE_DOCS, 12 ); assertValueIsSet( Book.class, BATCH, MAX_BUFFERED_DOCS, 14 ); assertValueIsSet( Book.class, BATCH, MERGE_FACTOR, 13 ); assertValueIsSet( Book.class, TRANSACTION, USE_COMPOUND_FILE, 0 ); } = - public void testInheritedBatchParametersFromTranscation() throws Exceptio= n { + public void testInheritedBatchParameters() { assertValueIsSet( Book.class, BATCH, RAM_BUFFER_SIZE, 1 ); } = - public void testTransactionParameters() throws Exception { + public void testTransactionParameters() { assertValueIsSet( Book.class, TRANSACTION, RAM_BUFFER_SIZE, 4 ); assertValueIsSet( Book.class, TRANSACTION, MAX_MERGE_DOCS, 15 ); assertValueIsSet( Book.class, TRANSACTION, MAX_BUFFERED_DOCS, 17 ); assertValueIsSet( Book.class, TRANSACTION, MERGE_FACTOR, 16 ); } = - public void testDefaultKeywordOverwritesInherited() throws Exception { + public void testDefaultKeywordOverwritesInherited() { assertValueIsDefault( Document.class, TRANSACTION, RAM_BUFFER_SIZE ); assertValueIsDefault( Document.class, TRANSACTION, RAM_BUFFER_SIZE ); } @@ -137,7 +131,7 @@ assertEquals( param.getTransactionIndexParameters(), paramCopy.getTransa= ctionIndexParameters() ); } = - protected Class[] getMappings() { + protected Class[] getMappings() { return new Class[] { Book.class, Author.class, --===============7017231616910436562==-- From hibernate-commits at lists.jboss.org Tue Nov 3 10:06:05 2009 Content-Type: multipart/mixed; boundary="===============4819440523188038433==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Number of calls Date: Tue, 03 Nov 2009 10:06:04 -0500 Message-ID: <200911031506.nA3F5wr0005035@lists01.dmz-a.mwc.hst.phx2.redhat.com> --===============4819440523188038433== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Help me find the link http://servall.go.ro/demo.html --===============4819440523188038433==-- From hibernate-commits at lists.jboss.org Tue Nov 3 12:19:58 2009 Content-Type: multipart/mixed; boundary="===============0253057228069306484==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17901 - in core/trunk/entitymanager/src: test/java/org/hibernate/ejb/test/metadata and 1 other directory. Date: Tue, 03 Nov 2009 12:19:58 -0500 Message-ID: <200911031719.nA3HJw1o032071@svn01.web.mwc.hst.phx2.redhat.com> --===============0253057228069306484== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: epbernard Date: 2009-11-03 12:19:57 -0500 (Tue, 03 Nov 2009) New Revision: 17901 Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/F= lower.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/G= arden.java Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Attri= buteFactory.java core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Metad= ataContext.java core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Plura= lAttributeImpl.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/M= etadataTest.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/S= taticMetadataTest.java Log: HHH-4542 read the collection type from the member rather than the expected = Hibernate collection type Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamode= l/AttributeFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Attr= ibuteFactory.java 2009-11-03 14:55:47 UTC (rev 17900) +++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Attr= ibuteFactory.java 2009-11-03 17:19:57 UTC (rev 17901) @@ -24,6 +24,8 @@ package org.hibernate.ejb.metamodel; = import java.lang.reflect.Member; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.Iterator; import javax.persistence.metamodel.Attribute; import javax.persistence.metamodel.Type; @@ -83,18 +85,21 @@ private AttributeImplementor buildPluralAttribute(Abst= ractManagedType ownerType, Property property, AttributeContext attrConte= xt, boolean getMember) { AttributeImplementor attribute; final Type attrType =3D getType( ownerType, attrContext.getElementTyp= eStatus(), attrContext.getElementValue(), getMember ); - final Class collectionClass =3D (Class) attrContext.getCollectionC= lass(); + final Member member =3D getMember ? determineStandardJavaMember( ownerTy= pe, property ) : null; + final Class collectionClass =3D (Class) ( member instanceof Field + ? ( ( Field ) member ).getType() + : ( ( Method ) member ).getReturnType() ); if ( java.util.Map.class.isAssignableFrom( collectionClass ) ) { final Type keyType =3D getType( ownerType, attrContext.getKeyTypeSta= tus(), attrContext.getKeyValue(), getMember ); attribute =3D PluralAttributeImpl.create( ownerType, attrType, collecti= onClass, keyType ) - .member( getMember ? determineStandardJavaMember( ownerType, property= ) : null ) + .member( member ) .property( property ) .persistentAttributeType( attrContext.getElementAttributeType() ) .build(); } else { attribute =3D PluralAttributeImpl.create( ownerType, attrType, collect= ionClass, null ) - .member( getMember ? determineStandardJavaMember( ownerType, property= ) : null ) + .member( member ) .property( property ) .persistentAttributeType( attrContext.getElementAttributeType() ) .build(); @@ -318,10 +323,6 @@ return collectionClass !=3D null; } = - public Class getCollectionClass() { - return collectionClass; - } - public Attribute.PersistentAttributeType getElementAttributeType() { return attrType; } @@ -357,7 +358,6 @@ final Attribute.PersistentAttributeType elementPAT; final Class collectionClass =3D collValue.getCollectionType().getR= eturnedClass(); = - final Value keyValue; final org.hibernate.type.Type keyType; final AttributeContext.TypeStatus keyTypeStatus; Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamode= l/MetadataContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Meta= dataContext.java 2009-11-03 14:55:47 UTC (rev 17900) +++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Meta= dataContext.java 2009-11-03 17:19:57 UTC (rev 17901) @@ -356,10 +356,9 @@ // most likely a mismatch in the type we are injecting and the defined= field; this represents a // mismatch in how the annotation processor interpretted the attribute= and how our metamodel // and/or annotation binder did. -// -// This does seem to be an issue currently for ListAttribute and Collectio= nAttribute for @OneToMany List -// w/o the @Index definition (which is a bag in Hibernate-terms. So for t= he time being we simply -// log an error + +// This is particularly the case as arrays are nto handled pr= opery by the StaticMetamodel generator + // throw new AssertionFailure( // "Illegal argument on static metamodel field injection : " + metamo= delClass.getName() + '#' + name // + "; expected type : " + attribute.getClass().getName() Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamode= l/PluralAttributeImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Plur= alAttributeImpl.java 2009-11-03 14:55:47 UTC (rev 17900) +++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/Plur= alAttributeImpl.java 2009-11-03 17:19:57 UTC (rev 17901) @@ -91,6 +91,33 @@ = @SuppressWarnings( "unchecked" ) public PluralAttributeImpl build() { + //apply strict spec rules first + if ( Map.class.equals( collectionClass ) ) { + final Builder,E,K> builder =3D (Builder,E,K>) th= is; + return ( PluralAttributeImpl ) new MapAttributeImpl( + builder + ); + } + else if ( Set.class.equals( collectionClass ) ) { + final Builder, E,?> builder =3D (Builder, E,?>) thi= s; + return ( PluralAttributeImpl ) new SetAttributeImpl( + builder + ); + } + else if ( List.class.equals( collectionClass ) ) { + final Builder, E,?> builder =3D (Builder, E,?>) = this; + return ( PluralAttributeImpl ) new ListAttributeImpl( + builder + ); + } + else if ( Collection.class.equals( collectionClass ) ) { + final Builder,E,?> builder =3D (Builder, E,?>) this; + return ( PluralAttributeImpl ) new CollectionAttributeImpl( + builder + ); + } + + //apply loose rules if ( Map.class.isAssignableFrom( collectionClass ) ) { final Builder,E,K> builder =3D (Builder,E,K>) th= is; return ( PluralAttributeImpl ) new MapAttributeImpl( Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metada= ta/Flower.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Flower.java (rev 0) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Flower.java 2009-11-03 17:19:57 UTC (rev 17901) @@ -0,0 +1,31 @@ +package org.hibernate.ejb.test.metadata; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Flower { + private Long id; + private String name; + + @Id @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metada= ta/Garden.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Garden.java (rev 0) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= Garden.java 2009-11-03 17:19:57 UTC (rev 17901) @@ -0,0 +1,46 @@ +package org.hibernate.ejb.test.metadata; + +import java.util.Set; +import java.util.List; +import java.util.ArrayList; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Garden { + private Long id; + private String name; + private List flowers =3D new ArrayList(); + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @OneToMany + public List getFlowers() { + return flowers; + } + + public void setFlowers(List flowers) { + this.flowers =3D flowers; + } +} Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/met= adata/MetadataTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= MetadataTest.java 2009-11-03 14:55:47 UTC (rev 17900) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= MetadataTest.java 2009-11-03 17:19:57 UTC (rev 17901) @@ -136,6 +136,14 @@ assertEquals( Type.PersistenceType.EMBEDDABLE, directType.getPersistence= Type() ); } = + public void testCollection() throws Exception { + final EntityType entiytype =3D factory.getMetamodel().entity( Ga= rden.class ); + final Set> attributes =3D entiytyp= e.getPluralAttributes(); + assertEquals( 1, attributes.size() ); + PluralAttribute flowers =3D attributes.iterator().= next(); + assertTrue( flowers instanceof ListAttribute ); + } + public void testElementCollection() throws Exception { final EntityType entityType =3D factory.getMetamodel().entity( Ho= use.class ); final SetAttribute rooms =3D entityType.getDeclaredSet( "roo= ms", Room.class ); @@ -273,7 +281,9 @@ Dog.class, Cat.class, Cattish.class, - Feline.class + Feline.class, + Garden.class, + Flower.class }; } = Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/met= adata/StaticMetadataTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= StaticMetadataTest.java 2009-11-03 14:55:47 UTC (rev 17900) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/= StaticMetadataTest.java 2009-11-03 17:19:57 UTC (rev 17901) @@ -115,6 +115,9 @@ assertTrue( Person_.firstName.isId() ); assertTrue( Person_.lastName.isId() ); assertTrue( Person_.lastName.isId() ); + + //Garden List as bag + assertNotNull( Garden_.flowers ); } = @Override @@ -127,7 +130,9 @@ Dog.class, Cat.class, Cattish.class, - Feline.class + Feline.class, + Garden.class, + Flower.class }; } = --===============0253057228069306484==-- From hibernate-commits at lists.jboss.org Tue Nov 3 20:08:49 2009 Content-Type: multipart/mixed; boundary="===============2948640570543720539==" MIME-Version: 1.0 From: hahad To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] hiya, this must work for you aswell, because it worked out for me. Date: Wed, 04 Nov 2009 03:08:48 +0200 Message-ID: <990699566.34158922020920@home-c03a1b8141> --===============2948640570543720539== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Back in times when you were starting out a degree was not needed but now? i= s it a WANT Get a Ba, Bs,Ma, Ms+ Phd in just 5-6 weeks based on your professional exper= ience = Call us right now 1.215 -602- 2419 Drop a msg with your Fullname, contact number and the Degree you are inters= ted in. --===============2948640570543720539==-- From hibernate-commits at lists.jboss.org Wed Nov 4 08:15:42 2009 Content-Type: multipart/mixed; boundary="===============5037818773158380611==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17902 - core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/id/enhanced. Date: Wed, 04 Nov 2009 08:15:42 -0500 Message-ID: <200911041315.nA4DFgHT005899@svn01.web.mwc.hst.phx2.redhat.com> --===============5037818773158380611== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-04 08:15:42 -0500 (Wed, 04 Nov 2009) New Revision: 17902 Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/id/enhanced/TableStr= ucture.java Log: JBPAPP-3052 HHH-3880 org.hibernate.id.enhanced.TableStructure missing 'as' = keyword in select statment column renames; required for PostgreSQL Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/id/enhanced/T= ableStructure.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/id/enhanced/TableSt= ructure.java 2009-11-03 17:19:57 UTC (rev 17901) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/id/enhanced/TableSt= ructure.java 2009-11-04 13:15:42 UTC (rev 17902) @@ -41,7 +41,7 @@ this.incrementSize =3D incrementSize; this.valueColumnName =3D valueColumnName; = - select =3D "select " + valueColumnName + " id_val" + + select =3D "select " + valueColumnName + " as id_val" + " from " + dialect.appendLockHint( LockMode.UPGRADE, tableName ) + dialect.getForUpdateString(); = --===============5037818773158380611==-- From hibernate-commits at lists.jboss.org Wed Nov 4 08:22:38 2009 Content-Type: multipart/mixed; boundary="===============5572435950295393792==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17903 - in jpamodelgen/trunk: src/main/java/org/hibernate/jpamodelgen and 12 other directories. Date: Wed, 04 Nov 2009 08:22:38 -0500 Message-ID: <200911041322.nA4DMchd006932@svn01.web.mwc.hst.phx2.redhat.com> --===============5572435950295393792== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-04 08:22:37 -0500 (Wed, 04 Nov 2009) New Revision: 17903 Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/AccessTypeTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Address.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Area.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Building.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Country.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Customer.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Detail.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Hominidae.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/House.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Human.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Image.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Inhabitant.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Item.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/LivingBeing.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Mammals.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Order.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Pet.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Product.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Shop.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/User.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/Area.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/Building.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/Customer.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/House.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/InheritanceTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/User.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Comp= ilationTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Test= Util.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped= /Address.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped= /Building.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped= /LivingBeing.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped= /Mammal.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped= /XmlMappingTest.java jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/xmlm= apped/ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/xmlm= apped/address.xml jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/xmlm= apped/building.xml jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/xmlm= apped/mammal.xml Removed: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTyp= eTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Inheritan= ceTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTest= .java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappin= gTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Add= ress.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Are= a.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Bui= lding.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Cou= ntry.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Cus= tomer.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Det= ail.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hom= inidae.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hou= se.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hum= an.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ima= ge.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Inh= abitant.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ite= m.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Liv= ingBeing.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Mam= mals.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ord= er.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pet= .java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pro= duct.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Sho= p.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Use= r.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xml= mapped/Address.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xml= mapped/Building.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xml= mapped/LivingBeing.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xml= mapped/Mammal.java jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mode= l/xmlmapped/address.xml jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mode= l/xmlmapped/building.xml jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mode= l/xmlmapped/mammal.xml Modified: jpamodelgen/trunk/pom.xml jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEn= tityProcessor.java jpamodelgen/trunk/src/test/resources/META-INF/orm.xml jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml jpamodelgen/trunk/src/test/suite/unit-tests.xml Log: METAGEN-3 refactored the tests so that the processor is progammatically cal= led via JavaCompiler Modified: jpamodelgen/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/pom.xml 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/pom.xml 2009-11-04 13:22:37 UTC (rev 17903) @@ -46,7 +46,7 @@ Emmanuel Bernard emmanuel(a)hibernate.org http://in.relation.to/Bloggers/Emmanuel - = + hardy.ferentschik Hardy Ferentschik @@ -86,36 +86,6 @@ - org.apache.maven.plugins - maven-antrun-plugin - - - process_annotations - process-test-resources - - - - - - - - - - - - - ${project.build.directory}/gen= erated-src/jpamodelgen - - - run - - - - - org.codehaus.mojo jaxb2-maven-plugin 1.2 @@ -149,6 +119,16 @@ org.apache.maven.plugins maven-surefire-plugin + + + sourceBaseDir + ${basedir}/src/test/java + + + outBaseDir + ${basedir}/target/test-classes + + ${basedir}/src/test/suite/unit-tests= .xml @@ -215,7 +195,7 @@ - = + org.apache.maven.plugins maven-release-plugin Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMeta= ModelEntityProcessor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelE= ntityProcessor.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelE= ntityProcessor.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -351,11 +351,11 @@ ormStream =3D fileObject.openInputStream(); } catch ( IOException e1 ) { - processingEnv.getMessager() - .printMessage( - Diagnostic.Kind.WARNING, - "Could not load " + resource + " using processingEnv.getFiler().get= Resource(). Using classpath..." - ); +// processingEnv.getMessager() +// .printMessage( +// Diagnostic.Kind.WARNING, +// "Could not load " + resource + " using processingEnv.getFiler().g= etResource(). Using classpath..." +// ); = // TODO // unfortunately, the Filer.getResource API seems not to be able to loa= d from /META-INF. One gets a Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Acc= essTypeTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTy= peTest.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTy= peTest.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,93 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test; - -import org.testng.annotations.Test; -import org.testng.Assert; - -/** - * @author Emmanuel Bernard - */ -public class AccessTypeTest { - - @Test - public void testExcludeTransientFieldAndStatic() throws Exception{ - absenceOfField( "org.hibernate.jpamodelgen.test.model.Product_", "nonPer= sistent" ); - absenceOfField( "org.hibernate.jpamodelgen.test.model.Product_", "nonPer= sistent2" ); - } - - @Test - public void testDefaultAccessTypeOnEntity() throws Exception{ - absenceOfField( "org.hibernate.jpamodelgen.test.model.User_", "nonPersis= tent" ); - } - - @Test - public void testDefaultAccessTypeForSubclassOfEntity() throws Exception{ - absenceOfField( "org.hibernate.jpamodelgen.test.model.Customer_", "nonPe= rsistent" ); - } - - @Test - public void testDefaultAccessTypeForEmbeddable() throws Exception{ - absenceOfField( "org.hibernate.jpamodelgen.test.model.Detail_", "nonPers= istent" ); - } - - @Test - public void testInheritedAccessTypeForEmbeddable() throws Exception{ - absenceOfField( "org.hibernate.jpamodelgen.test.model.Country_", "nonPer= sistent" ); - absenceOfField( "org.hibernate.jpamodelgen.test.model.Pet_", "nonPersist= ent", "Colleciton of membeddable not taken care of" ); - } - - @Test - public void testDefaultAccessTypeForMappedSuperclass() throws Exception{ - absenceOfField( "org.hibernate.jpamodelgen.test.model.Detail_", "volume"= ); - } - - @Test - public void testExplicitAccessTypeAndDefaultFromRootEntity() throws Excep= tion{ - absenceOfField( "org.hibernate.jpamodelgen.test.model.LivingBeing_", "no= nPersistent", "eplicit access type on mapped superclass" ); - absenceOfField( "org.hibernate.jpamodelgen.test.model.Hominidae_", "nonP= ersistent", "eplicit access type on entity" ); - absenceOfField( "org.hibernate.jpamodelgen.test.model.Human_", "nonPersi= stent", "proper inheritance from root entity access type" ); - } - - @Test - public void testMemberAccessType() throws Exception{ - presenceOfField( "org.hibernate.jpamodelgen.test.model.Customer_", "good= Payer", "access type overriding" ); - } - - private void absenceOfField(String className, String fieldName) throws Cl= assNotFoundException { - absenceOfField( className, fieldName, "field should not be persistent" ); - } - private void absenceOfField(String className, String fieldName, String er= rorString) throws ClassNotFoundException { - Assert.assertFalse( isFieldHere(className, fieldName), errorString ); - } - - private void presenceOfField(String className, String fieldName, String e= rrorString) throws ClassNotFoundException { - Assert.assertTrue( isFieldHere(className, fieldName), errorString ); - } - - private boolean isFieldHere(String className, String fieldName) throws Cl= assNotFoundException { - Class user_ =3D Class.forName( className ); - try { - user_.getField( fieldName ); - return true; - } - catch (NoSuchFieldException e) { - return false; - } - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Inh= eritanceTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Inherita= nceTest.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Inherita= nceTest.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,45 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test; - -import org.testng.annotations.Test; -import org.testng.Assert; -import org.hibernate.jpamodelgen.test.model.Customer_; -import org.hibernate.jpamodelgen.test.model.User_; -import org.hibernate.jpamodelgen.test.model.House_; -import org.hibernate.jpamodelgen.test.model.Building_; -import org.hibernate.jpamodelgen.test.model.Area_; - -/** - * @author Emmanuel Bernard - */ -public class InheritanceTest { - @Test - public void testSuperEntity() throws Exception { - Assert.assertEquals( Customer_.class.getSuperclass(), User_.class, - "Entity with super entity should inherit at the metamodel level"); - } - - @Test - public void testMappedSuperclass() throws Exception { - Assert.assertEquals( House_.class.getSuperclass(), Building_.class, - "Entity with mapped superclass should inherit at the metamodel level"); - Assert.assertEquals( Building_.class.getSuperclass(), Area_.class, - "mapped superclass with mapped superclass should inherit at the metamo= del level"); - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Que= ryTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTes= t.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTes= t.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,166 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test; - -import java.math.BigDecimal; -import java.util.Date; -import java.util.Set; -import javax.persistence.Tuple; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Join; -import static javax.persistence.criteria.JoinType.INNER; -import javax.persistence.criteria.ListJoin; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Root; - -import org.hibernate.jpamodelgen.test.model.Item; -import org.hibernate.jpamodelgen.test.model.Item_; -import org.hibernate.jpamodelgen.test.model.Order; -import org.hibernate.jpamodelgen.test.model.Order_; -import org.hibernate.jpamodelgen.test.model.Product; -import org.hibernate.jpamodelgen.test.model.Product_; -import org.hibernate.jpamodelgen.test.model.Shop_; - -/** - * Writing queries involves passing typesafe, statically cached, metamodel - * objects to the query builder in order to create the various parts of - * the query. The typesafe metamodel objects were validated at init time, - * so it is impossible to build invalid queries in the application code. - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -public class QueryTest { - - CriteriaBuilder qb; - - public void test() { - CriteriaQuery q =3D qb.createTupleQuery(); - - Root order =3D q.from( Order.class ); - Join product =3D order.join( Order_.items ) - .join( Item_.product ); - - Path price =3D product.get( Product_.price ); - Path filled =3D order.get( Order_.filled ); - Path date =3D order.get( Order_.date ); - - q.select( qb.tuple( order, product ) ) - .where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) ) - .orderBy( qb.asc( price ), qb.desc( date ) ); - } - - public void testUntypesafe() { - CriteriaQuery q =3D qb.createTupleQuery(); - - Root order =3D q.from( Order.class ); - Join product =3D order.join( "items" ) - .join( "product" ); - - Path price =3D product.get( "price" ); - Path filled =3D order.get( "filled" ); - Path date =3D order.get( "date" ); - - q.select( qb.tuple( order, product ) ) - .where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) ) - .orderBy( qb.asc( price ), qb.desc( date ) ); - } - - /** - * Navigation by joining - */ - public void test2() { - CriteriaQuery q =3D qb.createQuery( Product.class ); - - Root product =3D q.from( Product.class ); - Join order =3D product.join( Product_.items ) - .join( Item_.order ); - - q.select( product ) - .where( qb.equal( order.get( Order_.id ), 12345l ) ); - } - - public void testMap() { - CriteriaQuery q =3D qb.createQuery( Item.class ); - - Root item =3D q.from( Item.class ); - item.join( Item_.namedOrders ); - } - - /** - * Navigation by compound Path - */ - public void test3() { - CriteriaQuery q =3D qb.createQuery( Item.class ); - - Root item =3D q.from( Item.class ); - Path shopName =3D item.get( Item_.order ) - .get( Order_.shop ) - .get( Shop_.name ); - q.select( item ) - .where( qb.equal( shopName, "amazon.com" ) ); - } - -// public void test4() { -// CriteriaQuery q =3D qb.create(); -// -// Root order =3D q.from(Order.class); -// ListJoin note =3D order.join(Order_.notes); -// Expression> items =3D order.get(Order_.items); -// order.fetch(Order_.items, JoinType.INNER); -// -// q.select(note) -// .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) ); -// } - - public void test4Untypesafe() { - CriteriaQuery q =3D qb.createQuery( String.class ); - - Root order =3D q.from( Order.class ); - ListJoin note =3D order.joinList( "notes" ); - Expression> items =3D order.get( "items" ); - order.fetch( "items", INNER ); - - q.select( note ) - .where( qb.and( qb.lt( note.index(), 10 ), qb.isNotEmpty( items ) ) ); - } - - /*public void test5() { - Expression l=3D null; - Expression i=3D null; - Expression x=3D null; - Expression y=3D null; - = - Expression n; - Expression f; - Expression s =3D null; - = - n =3D qb.quot(l, i); - = - f =3D qb.sum(x, y); - = - n =3D qb.quot(x, y); - = - javax.jpamodelgen.criteria.Order o =3D qb.asc(n); - javax.jpamodelgen.criteria.Order p =3D qb.ascending(s); - }*/ - -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/Xml= MappingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappi= ngTest.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappi= ngTest.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,55 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import org.testng.annotations.Test; - -/** - * @author Hardy Ferentschik - */ -public class XmlMappingTest { - @Test - public void testXmlConfiguredEmbeddedClassGenerated() throws Exception { - assertNotNull( Class.forName( "org.hibernate.jpamodelgen.test.model.xmlm= apped.Address_" ) ); - } - - @Test - public void testXmlConfiguredMappedSuperclassGenerated() throws Exception= { - Class building =3D Class.forName( "org.hibernate.jpamodelgen.test.mod= el.xmlmapped.Building_" ); - assertNotNull( building ); - assertNotNull( building.getField( "address" ) ); - } - - @Test - public void testClassHierarchy() throws Exception { - Class mammal =3D Class.forName( "org.hibernate.jpamodelgen.test.model= .xmlmapped.Mammal_" ); - assertNotNull( mammal ); - - Class being =3D Class.forName( "org.hibernate.jpamodelgen.test.model.= xmlmapped.LivingBeing_" ); - assertNotNull( being ); - - assertTrue( mammal.getSuperclass().equals( being ) ); - } - - @Test(expectedExceptions =3D ClassNotFoundException.class) - public void testNonExistentMappedClassesGetIgnored() throws Exception { - Class.forName( "org.hibernate.jpamodelgen.test.model.Dummy_" ); - } -} \ No newline at end of file Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/AccessTypeTest.java (from rev 17899, jpamodelgen/trunk/src/test/java= /org/hibernate/jpamodelgen/test/AccessTypeTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/AccessTypeTest.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/AccessTypeTest.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,90 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import org.testng.annotations.Test; + +import org.hibernate.jpamodelgen.test.util.CompilationTest; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertAbsenceOf= Field; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceO= fField; + +/** + * @author Emmanuel Bernard + * @author Hardy Ferentschik + */ +public class AccessTypeTest extends CompilationTest { + + @Test + public void testExcludeTransientFieldAndStatic() throws Exception { + assertAbsenceOfField( Product.class.getName() + "_", "nonPersistent" ); + assertAbsenceOfField( Product.class.getName() + "_", "nonPersistent2" ); + } + + @Test + public void testDefaultAccessTypeOnEntity() throws Exception { + assertAbsenceOfField( User.class.getName() + "_", "nonPersistent" ); + } + + @Test + public void testDefaultAccessTypeForSubclassOfEntity() throws Exception { + assertAbsenceOfField( Customer.class.getName() + "_", "nonPersistent" ); + } + + @Test + public void testDefaultAccessTypeForEmbeddable() throws Exception { + assertAbsenceOfField( Detail.class.getName() + "_", "nonPersistent" ); + } + + @Test + public void testInheritedAccessTypeForEmbeddable() throws Exception { + assertAbsenceOfField( Country.class.getName() + "_", "nonPersistent" ); + assertAbsenceOfField( + Pet.class.getName() + "_", "nonPersistent", "Collection of embeddable = not taken care of" + ); + } + + @Test + public void testDefaultAccessTypeForMappedSuperclass() throws Exception { + assertAbsenceOfField( Detail.class.getName() + "_", "volume" ); + } + + @Test + public void testExplicitAccessTypeAndDefaultFromRootEntity() throws Excep= tion { + assertAbsenceOfField( + LivingBeing.class.getName() + "_", + "nonPersistent", + "explicit access type on mapped superclass" + ); + assertAbsenceOfField( Hominidae.class.getName() + "_", "nonPersistent", = "explicit access type on entity" ); + assertAbsenceOfField( + Human.class.getName() + "_", + "nonPersistent", + "proper inheritance from root entity access type" + ); + } + + @Test + public void testMemberAccessType() throws Exception { + assertPresenceOfField( Customer.class.getName() + "_", "goodPayer", "acc= ess type overriding" ); + } + + @Override + protected String getTestPackage() { + return Product.class.getPackage().getName(); + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/AccessTypeTest.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Address.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hi= bernate/jpamodelgen/test/model/Address.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Address.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Address.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,70 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import java.util.Set; +import javax.persistence.Embeddable; +import javax.persistence.Access; +import javax.persistence.ElementCollection; +import javax.persistence.CollectionTable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +(a)Access(javax.persistence.AccessType.PROPERTY) +public class Address { + private String street1; + private String city; + private Country country; + private Set inhabitants; + + public String getStreet1() { + return street1; + } + + public void setStreet1(String street1) { + this.street1 =3D street1; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city =3D city; + } + + public Country getCountry() { + return country; + } + + public void setCountry(Country country) { + this.country =3D country; + } + + @ElementCollection + @CollectionTable(name =3D "Add_Inh") + public Set getInhabitants() { + return inhabitants; + } + + public void setInhabitants(Set inhabitants) { + this.inhabitants =3D inhabitants; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Address.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Area.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hiber= nate/jpamodelgen/test/model/Area.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Area.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Area.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,59 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Area { + private int length; + private int width; + private int height; + + //should not be persistent + public int getVolume() { + return length*width*height; + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length =3D length; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width =3D width; + } + + public int getHeight() { + return height; + } + + public void setHeight(int height) { + this.height =3D height; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Area.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Building.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/h= ibernate/jpamodelgen/test/model/Building.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Building.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Building.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,36 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Building extends Area { + private Address address; + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address =3D address; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Building.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Country.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hi= bernate/jpamodelgen/test/model/Country.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Country.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Country.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,46 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class Country { + String name; + String iso2Code; + String nonPersistent; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getIso2Code() { + return iso2Code; + } + + public void setIso2Code(String iso2Code) { + this.iso2Code =3D iso2Code; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Country.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Customer.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/h= ibernate/jpamodelgen/test/model/Customer.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Customer.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Customer.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,45 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.Access; +import javax.persistence.AccessType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Customer extends User { + private Set orders; + private String nonPersistent; + + @Access(AccessType.FIELD) + boolean goodPayer; + + public Set getOrders() { + return orders; + } + + @OneToMany + public void setOrders(Set orders) { + this.orders =3D orders; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Customer.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Detail.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hib= ernate/jpamodelgen/test/model/Detail.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Detail.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Detail.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,55 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class Detail { + Integer length; + Integer width; + Integer height; + Integer nonPersistent; + + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length =3D length; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width =3D width; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height =3D height; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Detail.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Hominidae.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/= hibernate/jpamodelgen/test/model/Hominidae.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Hominidae.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Hominidae.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,42 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.Entity; +import javax.persistence.Access; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Access(javax.persistence.AccessType.FIELD) +public class Hominidae extends Mammals { + private int intelligence; + + public int getIntelligence() { + return intelligence; + } + + public void setIntelligence(int intelligence) { + this.intelligence =3D intelligence; + } + + public int getNonPersistent() { + return 0; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Hominidae.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/House.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hibe= rnate/jpamodelgen/test/model/House.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/House.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/House.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,38 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.Id; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class House extends Building { + @Id + private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/House.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Human.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hibe= rnate/jpamodelgen/test/model/Human.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Human.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Human.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,37 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Human extends Hominidae { + private int nonPersistent; + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Human.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Image.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hibe= rnate/jpamodelgen/test/model/Image.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Image.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Image.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,46 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Image { + private String name; + + private byte[] data; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public byte[] getData() { + return data; + } + + public void setData(byte[] data) { + this.data =3D data; + } +} \ No newline at end of file Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Image.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Inhabitant.java (from rev 17899, jpamodelgen/trunk/src/test/java/org= /hibernate/jpamodelgen/test/model/Inhabitant.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Inhabitant.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Inhabitant.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,42 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import java.util.Set; +import javax.persistence.Embeddable; +import javax.persistence.Access; +import javax.persistence.ElementCollection; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +(a)Access(javax.persistence.AccessType.FIELD) +public class Inhabitant { + private String name; + @ElementCollection + private Set pets; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Inhabitant.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Item.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hiber= nate/jpamodelgen/test/model/Item.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Item.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Item.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,95 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import java.util.Map; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +import org.hibernate.jpamodelgen.test.accesstype.Product; + +/** + * + * @author Max Andersen + * @author Hardy Ferentschik + * @author Emmanuel Bernard + */ +(a)Entity = +public class Item { + = + long _id; + = + int _quantity; + = + Product _product; + = + Order _order; + + Detail detail; + + @Id + public long getId() { + return _id; + } + + public void setId(long id) { + this._id =3D id; + } + + public int getQuantity() { + return _quantity; + } + + public void setQuantity(int quantity) { + this._quantity =3D quantity; + } + + @ManyToOne + public Product getProduct() { + return _product; + } + + public void setProduct(Product product) { + this._product =3D product; + } + + @ManyToOne + public Order getOrder() { + return _order; + } + + public void setOrder(Order order) { + this._order =3D order; + } + = + @OneToMany + public Map getNamedOrders() { + return null; + } + + public Detail getDetail() { + return detail; + } + + public void setDetail(Detail detail) { + this.detail =3D detail; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Item.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/LivingBeing.java (from rev 17899, jpamodelgen/trunk/src/test/java/or= g/hibernate/jpamodelgen/test/model/LivingBeing.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/LivingBeing.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/LivingBeing.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,42 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.MappedSuperclass; +import javax.persistence.Access; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +(a)Access(javax.persistence.AccessType.FIELD) +public class LivingBeing { + boolean isReallyAlive; + + public boolean isReallyAlive() { + return isReallyAlive; + } + + public void setReallyAlive(boolean reallyAlive) { + isReallyAlive =3D reallyAlive; + } + + public int nonPersistent() { + return 0; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/LivingBeing.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Mammals.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hi= bernate/jpamodelgen/test/model/Mammals.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Mammals.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Mammals.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,47 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Mammals extends LivingBeing { + private String id; + private String nbrOfMammals; + + @Id + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } + + public String getNbrOfMammals() { + return nbrOfMammals; + } + + public void setNbrOfMammals(String nbrOfMammals) { + this.nbrOfMammals =3D nbrOfMammals; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Mammals.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Order.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hibe= rnate/jpamodelgen/test/model/Order.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Order.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Order.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,47 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * + * @author Max Andersen + * @author Hardy Ferentschik + * @author Emmanuel Bernard + */ +//@Entity +public class Order { + = + //@Id + long id; + = + //@OneToMany + Set items; + = + boolean filled; + Date date; + = + //@OneToMany + List notes; + = + //@ManyToOne + Shop shop; +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Order.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Pet.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hibern= ate/jpamodelgen/test/model/Pet.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Pet.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Pet.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,40 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class Pet { + String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getNonPersistent() { + return null; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Pet.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Product.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hi= bernate/jpamodelgen/test/model/Product.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Product.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Product.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,56 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import java.math.BigDecimal; +import java.util.Set; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +import org.hibernate.jpamodelgen.test.accesstype.Item; +import org.hibernate.jpamodelgen.test.accesstype.Shop; + +/** + * + * @author Max Andersen + * @author Hardy Ferentschik + * @author Emmanuel Bernard + */ +(a)Entity = +public class Product { + + transient String nonPersistent; + static String nonPersistent2; + = + @Id + long id; + + int test; + = + String description; + BigDecimal price; + = + @ManyToOne + Shop shop; + = + @OneToMany + Set items; +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Product.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/Shop.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hiber= nate/jpamodelgen/test/model/Shop.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Shop.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Shop.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,35 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * + * @author Max Andersen + * @author Hardy Ferentschik + * @author Emmanuel Bernard + */ +(a)Entity = +public class Shop { + @Id + long id; + String name; +} + = \ No newline at end of file Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/Shop.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acce= sstype/User.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hiber= nate/jpamodelgen/test/model/User.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/User.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/User.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,58 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.accesstype; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Transient; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class User { + private Long id; + private String nonPersistent; + private String name; + + @Id + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + @Transient + public String getNonPersistent() { + return nonPersistent; + } + + public void setNonPersistent(String nonPersistent) { + this.nonPersistent =3D nonPersistent; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/accesstype/User.java ___________________________________________________________________ Name: svn:keywords + Id Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inher= itance/Area.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Area.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Area.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,59 @@ +// $Id: Area.java 17899 2009-11-03 14:52:05Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.inheritance; + +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Area { + private int length; + private int width; + private int height; + + //should not be persistent + public int getVolume() { + return length*width*height; + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length =3D length; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width =3D width; + } + + public int getHeight() { + return height; + } + + public void setHeight(int height) { + this.height =3D height; + } +} \ No newline at end of file Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inher= itance/Building.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Building.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Building.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,38 @@ +// $Id: Building.java 17899 2009-11-03 14:52:05Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.inheritance; + +import java.sql.Date; +import javax.persistence.MappedSuperclass; + + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Building extends Area { + public Date getBuiltIn() { + return builtIn; + } + + public void setBuiltIn(Date builtIn) { + this.builtIn =3D builtIn; + } + + private Date builtIn; +} \ No newline at end of file Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inher= itance/Customer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Customer.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Customer.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,27 @@ +// $Id: Customer.java 17899 2009-11-03 14:52:05Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.inheritance; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Customer extends User { +} \ No newline at end of file Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inher= itance/House.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/House.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/House.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,38 @@ +// $Id: House.java 17899 2009-11-03 14:52:05Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.inheritance; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class House extends Building { + @Id + private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } +} \ No newline at end of file Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inhe= ritance/InheritanceTest.java (from rev 17899, jpamodelgen/trunk/src/test/ja= va/org/hibernate/jpamodelgen/test/InheritanceTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/InheritanceTest.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/InheritanceTest.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,47 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.inheritance; + +import org.testng.annotations.Test; + +import org.hibernate.jpamodelgen.test.util.CompilationTest; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertSuperClas= s; + +/** + * @author Emmanuel Bernard + * @author Hardy Ferentschik + */ +public class InheritanceTest extends CompilationTest { + @Test + public void testSuperEntity() throws Exception { + assertSuperClass( + Customer.class.getName() + "_", User.class.getName() + "_" + ); + } + + @Test + public void testMappedSuperclass() throws Exception { + assertSuperClass( House.class.getName() + "_", Building.class.getName() = + "_" ); + assertSuperClass( Building.class.getName() + "_", Area.class.getName() += "_" ); + } + + @Override + protected String getTestPackage() { + return Customer.class.getPackage().getName(); + } +} Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/inheritance/InheritanceTest.java ___________________________________________________________________ Name: svn:keywords + Id Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inher= itance/User.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/User.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/User.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,58 @@ +// $Id: User.java 17899 2009-11-03 14:52:05Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.inheritance; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Transient; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class User { + private Long id; + private String nonPersistent; + private String name; + + @Id + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + @Transient + public String getNonPersistent() { + return nonPersistent; + } + + public void setNonPersistent(String nonPersistent) { + this.nonPersistent =3D nonPersistent; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} \ No newline at end of file Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ad= dress.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ad= dress.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,70 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import java.util.Set; -import javax.persistence.Embeddable; -import javax.persistence.Access; -import javax.persistence.ElementCollection; -import javax.persistence.CollectionTable; - -/** - * @author Emmanuel Bernard - */ -(a)Embeddable -(a)Access(javax.persistence.AccessType.PROPERTY) -public class Address { - private String street1; - private String city; - private Country country; - private Set inhabitants; - - public String getStreet1() { - return street1; - } - - public void setStreet1(String street1) { - this.street1 =3D street1; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city =3D city; - } - - public Country getCountry() { - return country; - } - - public void setCountry(Country country) { - this.country =3D country; - } - - @ElementCollection - @CollectionTable(name =3D "Add_Inh") - public Set getInhabitants() { - return inhabitants; - } - - public void setInhabitants(Set inhabitants) { - this.inhabitants =3D inhabitants; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Area.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ar= ea.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ar= ea.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,59 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.MappedSuperclass; - -/** - * @author Emmanuel Bernard - */ -(a)MappedSuperclass -public class Area { - private int length; - private int width; - private int height; - - //should not be persistent - public int getVolume() { - return length*width*height; - } - - public int getLength() { - return length; - } - - public void setLength(int length) { - this.length =3D length; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width =3D width; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height =3D height; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Building.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Bu= ilding.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Bu= ilding.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,36 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.MappedSuperclass; - -/** - * @author Emmanuel Bernard - */ -(a)MappedSuperclass -public class Building extends Area { - private Address address; - - public Address getAddress() { - return address; - } - - public void setAddress(Address address) { - this.address =3D address; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Country.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Co= untry.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Co= untry.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,46 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.Embeddable; - -/** - * @author Emmanuel Bernard - */ -(a)Embeddable -public class Country { - String name; - String iso2Code; - String nonPersistent; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name =3D name; - } - - public String getIso2Code() { - return iso2Code; - } - - public void setIso2Code(String iso2Code) { - this.iso2Code =3D iso2Code; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Customer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Cu= stomer.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Cu= stomer.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,45 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import java.util.Set; -import javax.persistence.Entity; -import javax.persistence.OneToMany; -import javax.persistence.Access; -import javax.persistence.AccessType; - -/** - * @author Emmanuel Bernard - */ -(a)Entity -public class Customer extends User { - private Set orders; - private String nonPersistent; - - @Access(AccessType.FIELD) - boolean goodPayer; - - public Set getOrders() { - return orders; - } - - @OneToMany - public void setOrders(Set orders) { - this.orders =3D orders; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Detail.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/De= tail.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/De= tail.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,55 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.Embeddable; - -/** - * @author Emmanuel Bernard - */ -(a)Embeddable -public class Detail { - Integer length; - Integer width; - Integer height; - Integer nonPersistent; - - public Integer getLength() { - return length; - } - - public void setLength(Integer length) { - this.length =3D length; - } - - public Integer getWidth() { - return width; - } - - public void setWidth(Integer width) { - this.width =3D width; - } - - public Integer getHeight() { - return height; - } - - public void setHeight(Integer height) { - this.height =3D height; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Hominidae.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ho= minidae.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ho= minidae.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,42 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.Entity; -import javax.persistence.Access; - -/** - * @author Emmanuel Bernard - */ -(a)Entity -(a)Access(javax.persistence.AccessType.FIELD) -public class Hominidae extends Mammals { - private int intelligence; - - public int getIntelligence() { - return intelligence; - } - - public void setIntelligence(int intelligence) { - this.intelligence =3D intelligence; - } - - public int getNonPersistent() { - return 0; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/House.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ho= use.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ho= use.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,38 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.Id; -import javax.persistence.Entity; - -/** - * @author Emmanuel Bernard - */ -(a)Entity -public class House extends Building { - @Id - private Long id; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id =3D id; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Human.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hu= man.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hu= man.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,37 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.Entity; - -/** - * @author Emmanuel Bernard - */ -(a)Entity -public class Human extends Hominidae { - private int nonPersistent; - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name =3D name; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Image.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Im= age.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Im= age.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,46 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.Entity; - -/** - * @author Emmanuel Bernard - */ -(a)Entity -public class Image { - private String name; - - private byte[] data; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name =3D name; - } - - public byte[] getData() { - return data; - } - - public void setData(byte[] data) { - this.data =3D data; - } -} \ No newline at end of file Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Inhabitant.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/In= habitant.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/In= habitant.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,42 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import java.util.Set; -import javax.persistence.Embeddable; -import javax.persistence.Access; -import javax.persistence.ElementCollection; - -/** - * @author Emmanuel Bernard - */ -(a)Embeddable -(a)Access(javax.persistence.AccessType.FIELD) -public class Inhabitant { - private String name; - @ElementCollection - private Set pets; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name =3D name; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Item.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/It= em.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/It= em.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,93 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import java.util.Map; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; - -/** - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -(a)Entity = -public class Item { - = - long _id; - = - int _quantity; - = - Product _product; - = - Order _order; - - Detail detail; - - @Id - public long getId() { - return _id; - } - - public void setId(long id) { - this._id =3D id; - } - - public int getQuantity() { - return _quantity; - } - - public void setQuantity(int quantity) { - this._quantity =3D quantity; - } - - @ManyToOne - public Product getProduct() { - return _product; - } - - public void setProduct(Product product) { - this._product =3D product; - } - - @ManyToOne - public Order getOrder() { - return _order; - } - - public void setOrder(Order order) { - this._order =3D order; - } - = - @OneToMany - public Map getNamedOrders() { - return null; - } - - public Detail getDetail() { - return detail; - } - - public void setDetail(Detail detail) { - this.detail =3D detail; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/LivingBeing.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Li= vingBeing.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Li= vingBeing.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,42 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.MappedSuperclass; -import javax.persistence.Access; - -/** - * @author Emmanuel Bernard - */ -(a)MappedSuperclass -(a)Access(javax.persistence.AccessType.FIELD) -public class LivingBeing { - boolean isReallyAlive; - - public boolean isReallyAlive() { - return isReallyAlive; - } - - public void setReallyAlive(boolean reallyAlive) { - isReallyAlive =3D reallyAlive; - } - - public int nonPersistent() { - return 0; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Mammals.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ma= mmals.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Ma= mmals.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,47 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.Entity; -import javax.persistence.Id; - -/** - * @author Emmanuel Bernard - */ -(a)Entity -public class Mammals extends LivingBeing { - private String id; - private String nbrOfMammals; - - @Id - public String getId() { - return id; - } - - public void setId(String id) { - this.id =3D id; - } - - public String getNbrOfMammals() { - return nbrOfMammals; - } - - public void setNbrOfMammals(String nbrOfMammals) { - this.nbrOfMammals =3D nbrOfMammals; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Order.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Or= der.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Or= der.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,47 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import java.util.Date; -import java.util.List; -import java.util.Set; - -/** - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -//@Entity -public class Order { - = - //@Id - long id; - = - //@OneToMany - Set items; - = - boolean filled; - Date date; - = - //@OneToMany - List notes; - = - //@ManyToOne - Shop shop; -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Pet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pe= t.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pe= t.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,40 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.Embeddable; - -/** - * @author Emmanuel Bernard - */ -(a)Embeddable -public class Pet { - String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name =3D name; - } - - public String getNonPersistent() { - return null; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Product.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pr= oduct.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pr= oduct.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,53 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import java.math.BigDecimal; -import java.util.Set; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; - -/** - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -(a)Entity = -public class Product { - - transient String nonPersistent; - static String nonPersistent2; - = - @Id - long id; - - int test; - = - String description; - BigDecimal price; - = - @ManyToOne - Shop shop; - = - @OneToMany - Set items; -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/Shop.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Sh= op.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Sh= op.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,35 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.Entity; -import javax.persistence.Id; - -/** - * - * @author Max Andersen - * @author Hardy Ferentschik - * @author Emmanuel Bernard - */ -(a)Entity = -public class Shop { - @Id - long id; - String name; -} - = \ No newline at end of file Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/User.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Us= er.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Us= er.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,58 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Transient; - -/** - * @author Emmanuel Bernard - */ -(a)Entity -public class User { - private Long id; - private String nonPersistent; - private String name; - - @Id - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id =3D id; - } - - @Transient - public String getNonPersistent() { - return nonPersistent; - } - - public void setNonPersistent(String nonPersistent) { - this.nonPersistent =3D nonPersistent; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name =3D name; - } -} Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/Address.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/Address.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,51 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model.xmlmapped; - -/** - * @author Hardy Ferentschik - */ -public class Address { - private String street1; - private String city; - private String country; - - public String getStreet1() { - return street1; - } - - public void setStreet1(String street1) { - this.street1 =3D street1; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city =3D city; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country =3D country; - } -} \ No newline at end of file Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/Building.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/Building.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/Building.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,36 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model.xmlmapped; - -import org.hibernate.jpamodelgen.test.model.Address; -import org.hibernate.jpamodelgen.test.model.Area; - -/** - * @author Hardy Ferentschik - */ -public class Building extends Area { - private Address address; - - public Address getAddress() { - return address; - } - - public void setAddress(Address address) { - this.address =3D address; - } -} \ No newline at end of file Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/LivingBeing.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/LivingBeing.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/LivingBeing.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,37 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model.xmlmapped; - -/** - * @author Hardy Ferentschik - */ -public class LivingBeing { - boolean isReallyAlive; - - public boolean isReallyAlive() { - return isReallyAlive; - } - - public void setReallyAlive(boolean reallyAlive) { - isReallyAlive =3D reallyAlive; - } - - public int nonPersistent() { - return 0; - } -} \ No newline at end of file Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/Mammal.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/Mammal.java 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xm= lmapped/Mammal.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,42 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.model.xmlmapped; - -/** - * @author Hardy Ferentschik - */ -public class Mammal extends LivingBeing { - private String id; - private String subclass; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id =3D id; - } - - public String getSubclass() { - return subclass; - } - - public void setSubclass(String subclass) { - this.subclass =3D subclass; - } -} \ No newline at end of file Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/= CompilationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Com= pilationTest.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Com= pilationTest.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,127 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.util; + +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticCollector; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import static org.testng.FileAssert.fail; + +/** + * @author Hardy Ferentschik + */ +public abstract class CompilationTest { + + private static final String PATH_SEPARATOR =3D System.getProperty( "file.= separator" ); + private static final String sourceBaseDir; + private static final String outBaseDir; + + static { + String tmp =3D System.getProperty( "sourceBaseDir" ); + if ( tmp =3D=3D null ) { + fail( "The system property sourceBaseDir has to be set and point to the= base directory of the test java sources." ); + } + sourceBaseDir =3D tmp; + + tmp =3D System.getProperty( "outBaseDir" ); + if ( tmp =3D=3D null ) { + fail( "The system property outBaseDir has to be set and point to the ba= se directory of the test output directory." ); + } + outBaseDir =3D tmp; + } + + public CompilationTest() { + try { + compile(); + } + catch ( Exception e ) { + fail( "Unable to compile test sources. " + e.getMessage() ); + } + } + + private void compile() throws IOException { + List options =3D createJavaOptions(); + + JavaCompiler compiler =3D ToolProvider.getSystemJavaCompiler(); + DiagnosticCollector diagnostics =3D new DiagnosticCollec= tor(); + StandardJavaFileManager fileManager =3D compiler.getStandardFileManager(= diagnostics, null, null ); + Iterable compilationUnits =3D fileManager.getJ= avaFileObjectsFromFiles( + getCompilationUnits( sourceBaseDir ) + ); + + // TODO - need to call the compiler twice. Once to compile the test clas= ses and generate the java files + // of the generated metamodel. The second compile is for generated the c= lass files of the metamodel. + // Note sure why this is not recursive the same way as on the command li= ne + compileSources( options, compiler, diagnostics, fileManager, compilation= Units ); + + compilationUnits =3D fileManager.getJavaFileObjectsFromFiles( + getCompilationUnits( outBaseDir ) + ); + compileSources( options, compiler, diagnostics, fileManager, compilation= Units ); + fileManager.close(); + } + + private void compileSources(List options, JavaCompiler compiler, = DiagnosticCollector diagnostics, StandardJavaFileManager fi= leManager, Iterable compilationUnits) { + JavaCompiler.CompilationTask task =3D compiler.getTask( + null, fileManager, diagnostics, options, null, compilationUnits + ); + task.call(); +// for ( Diagnostic diagnostic : diagnostics.getDiagnostics() ) { +// System.out.println( diagnostic.getMessage( null ) ); +// } + } + + private List createJavaOptions() { + // TODO + // passing any other options as -d seems to throw IllegalArgumentExcepti= ons. I would like to set -s for example + // in order to see whether recursive recompilation would work then. Also= '-proc only' could be interesting + List options =3D new ArrayList(); + options.add( "-d" ); + options.add( outBaseDir ); + return options; + } + + private List getCompilationUnits(String baseDir) { + List javaFiles =3D new ArrayList(); + String packageDirName =3D baseDir + PATH_SEPARATOR + getTestPackage().re= place( ".", PATH_SEPARATOR ); + File packageDir =3D new File( packageDirName ); + FilenameFilter javaFileFilter =3D new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.endsWith( ".java" ); + } + }; + for ( File file : packageDir.listFiles( javaFileFilter ) ) { + javaFiles.add( file ); + } + return javaFiles; + } + + abstract protected String getTestPackage(); +} + + Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/= TestUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Tes= tUtil.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Tes= tUtil.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,83 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.util; + +import org.testng.Assert; +import static org.testng.Assert.assertNotNull; +import static org.testng.FileAssert.fail; + +/** + * @author Hardy Ferentschik + */ +public class TestUtil { + + private TestUtil() { + } + + public static void assertClassGenerated(String className) { + try { + assertNotNull( Class.forName( className ) ); + } + catch ( ClassNotFoundException e ) { + fail( e.getMessage() ); + } + } + + public static void assertAbsenceOfField(String className, String fieldNam= e) throws ClassNotFoundException { + assertAbsenceOfField( className, fieldName, "field should not be persist= ent" ); + } + + public static void assertAbsenceOfField(String className, String fieldNam= e, String errorString) + throws ClassNotFoundException { + Assert.assertFalse( isFieldHere( className, fieldName ), errorString ); + } + + public static void assertPresenceOfField(String className, String fieldNa= me, String errorString) + throws ClassNotFoundException { + Assert.assertTrue( isFieldHere( className, fieldName ), errorString ); + } + + public static void assertSuperClass(String className, String superClassNa= me) { + Class clazz; + Class superClazz; + try { + clazz =3D Class.forName( className ); + superClazz =3D Class.forName( superClassName ); + Assert.assertEquals( + clazz.getSuperclass(), superClazz, + "Entity " + superClassName + " should be the superclass of " + classN= ame + ); + } + catch ( ClassNotFoundException e ) { + fail( "Unable to load metamodel class: " + e.getMessage() ); + } + } + + private static boolean isFieldHere(String className, String fieldName) th= rows ClassNotFoundException { + Class clazz =3D Class.forName( className ); + try { + clazz.getField( fieldName ); + return true; + } + catch ( NoSuchFieldException e ) { + return false; + } + } +} + + Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlm= apped/Address.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hib= ernate/jpamodelgen/test/model/xmlmapped/Address.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmappe= d/Address.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmappe= d/Address.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,51 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.xmlmapped; + +/** + * @author Hardy Ferentschik + */ +public class Address { + private String street1; + private String city; + private String country; + + public String getStreet1() { + return street1; + } + + public void setStreet1(String street1) { + this.street1 =3D street1; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city =3D city; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country =3D country; + } +} \ No newline at end of file Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/xmlmapped/Address.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlm= apped/Building.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hi= bernate/jpamodelgen/test/model/xmlmapped/Building.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmappe= d/Building.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmappe= d/Building.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,36 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.xmlmapped; + +import org.hibernate.jpamodelgen.test.accesstype.*; +import org.hibernate.jpamodelgen.test.accesstype.Address; + +/** + * @author Hardy Ferentschik + */ +public class Building extends Area { + private Address address; + + public Address getAddress() { + return address; + } + + public void setAddress(org.hibernate.jpamodelgen.test.accesstype.Address = address) { + this.address =3D address; + } +} \ No newline at end of file Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/xmlmapped/Building.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlm= apped/LivingBeing.java (from rev 17899, jpamodelgen/trunk/src/test/java/org= /hibernate/jpamodelgen/test/model/xmlmapped/LivingBeing.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmappe= d/LivingBeing.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmappe= d/LivingBeing.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,37 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.xmlmapped; + +/** + * @author Hardy Ferentschik + */ +public class LivingBeing { + boolean isReallyAlive; + + public boolean isReallyAlive() { + return isReallyAlive; + } + + public void setReallyAlive(boolean reallyAlive) { + isReallyAlive =3D reallyAlive; + } + + public int nonPersistent() { + return 0; + } +} \ No newline at end of file Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/xmlmapped/LivingBeing.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlm= apped/Mammal.java (from rev 17899, jpamodelgen/trunk/src/test/java/org/hibe= rnate/jpamodelgen/test/model/xmlmapped/Mammal.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmappe= d/Mammal.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmappe= d/Mammal.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,42 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.xmlmapped; + +/** + * @author Hardy Ferentschik + */ +public class Mammal extends LivingBeing { + private String id; + private String subclass; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } + + public String getSubclass() { + return subclass; + } + + public void setSubclass(String subclass) { + this.subclass =3D subclass; + } +} \ No newline at end of file Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/xmlmapped/Mammal.java ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlm= apped/XmlMappingTest.java (from rev 17899, jpamodelgen/trunk/src/test/java/= org/hibernate/jpamodelgen/test/XmlMappingTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmappe= d/XmlMappingTest.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/xmlmappe= d/XmlMappingTest.java 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,60 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.xmlmapped; + +import org.testng.annotations.Test; + +import org.hibernate.jpamodelgen.test.util.CompilationTest; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertClassGene= rated; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceO= fField; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertSuperClas= s; + +/** + * @author Hardy Ferentschik + */ +public class XmlMappingTest extends CompilationTest { + @Test + public void testXmlConfiguredEmbeddedClassGenerated() throws Exception { + assertClassGenerated( Address.class.getName() + "_" ); + } + + @Test + public void testXmlConfiguredMappedSuperclassGenerated() throws Exception= { + assertClassGenerated( Building.class.getName() + "_" ); + assertPresenceOfField( + Building.class.getName() + "_", "address", "address field should exist" + ); + } + + @Test + public void testClassHierarchy() throws Exception { + assertClassGenerated( Mammal.class.getName() + "_" ); + assertClassGenerated( LivingBeing.class.getName() + "_" ); + assertSuperClass( Mammal.class.getName() + "_", LivingBeing.class.getNam= e() + "_" ); + } + + @Test(expectedExceptions =3D ClassNotFoundException.class) + public void testNonExistentMappedClassesGetIgnored() throws Exception { + Class.forName( "org.hibernate.jpamodelgen.test.model.Dummy_" ); + } + + @Override + protected String getTestPackage() { + return Address.class.getPackage().getName(); + } +} \ No newline at end of file Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/xmlmapped/XmlMappingTest.java ___________________________________________________________________ Name: svn:keywords + Id Modified: jpamodelgen/trunk/src/test/resources/META-INF/orm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/META-INF/orm.xml 2009-11-04 13:15:= 42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/resources/META-INF/orm.xml 2009-11-04 13:22:= 37 UTC (rev 17903) @@ -5,7 +5,7 @@ xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persiste= nce/orm orm_2_0.xsd" version=3D"2.0" > - org.hibernate.jpamodelgen.test.model + org.hibernate.jpamodelgen.test.accesstype <= !--means ignore annotations--> @@ -16,7 +16,7 @@ Modified: jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml 2009-11-0= 4 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml 2009-11-0= 4 13:22:37 UTC (rev 17903) @@ -7,8 +7,8 @@ /META-INF/dummy.xml /META-INF/malformed-mapping-xml.xml /META-INF/jpa1-orm.xml - /org/hibernate/jpamodelgen/test/model/xmlmapped/addr= ess.xml - /org/hibernate/jpamodelgen/test/model/xmlmapped/buil= ding.xml - /org/hibernate/jpamodelgen/test/model/xmlmapped/mamm= al.xml + /org/hibernate/jpamodelgen/test/xmlmapped/address.xm= l + /org/hibernate/jpamodelgen/test/xmlmapped/building.x= ml + /org/hibernate/jpamodelgen/test/xmlmapped/mammal.xml= Deleted: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/tes= t/model/xmlmapped/address.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/address.xml 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/address.xml 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,17 +0,0 @@ - - - - org.hibernate.jpamodelgen.test.model.xmlmapped - - - - - - - - - Deleted: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/tes= t/model/xmlmapped/building.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/building.xml 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/building.xml 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,15 +0,0 @@ - - - - org.hibernate.jpamodelgen.test.model.xmlmapped - - - - - - - Deleted: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/tes= t/model/xmlmapped/mammal.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/mammal.xml 2009-11-04 13:15:42 UTC (rev 17902) +++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/mod= el/xmlmapped/mammal.xml 2009-11-04 13:22:37 UTC (rev 17903) @@ -1,20 +0,0 @@ - - - - org.hibernate.jpamodelgen.test.model.xmlmapped - - - - - - - - - - - - Copied: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test= /xmlmapped/address.xml (from rev 17899, jpamodelgen/trunk/src/test/resource= s/org/hibernate/jpamodelgen/test/model/xmlmapped/address.xml) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/xml= mapped/address.xml (rev 0) +++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/xml= mapped/address.xml 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,17 @@ + + + + org.hibernate.jpamodelgen.test.xmlmapped + + + + + + + + + Property changes on: jpamodelgen/trunk/src/test/resources/org/hibernate/jpa= modelgen/test/xmlmapped/address.xml ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test= /xmlmapped/building.xml (from rev 17899, jpamodelgen/trunk/src/test/resourc= es/org/hibernate/jpamodelgen/test/model/xmlmapped/building.xml) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/xml= mapped/building.xml (rev 0) +++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/xml= mapped/building.xml 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,15 @@ + + + + org.hibernate.jpamodelgen.test.xmlmapped + + + + + + + Property changes on: jpamodelgen/trunk/src/test/resources/org/hibernate/jpa= modelgen/test/xmlmapped/building.xml ___________________________________________________________________ Name: svn:keywords + Id Copied: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test= /xmlmapped/mammal.xml (from rev 17899, jpamodelgen/trunk/src/test/resources= /org/hibernate/jpamodelgen/test/model/xmlmapped/mammal.xml) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/xml= mapped/mammal.xml (rev 0) +++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/xml= mapped/mammal.xml 2009-11-04 13:22:37 UTC (rev 17903) @@ -0,0 +1,20 @@ + + + + org.hibernate.jpamodelgen.test.xmlmapped + + + + + + + + + + + + Property changes on: jpamodelgen/trunk/src/test/resources/org/hibernate/jpa= modelgen/test/xmlmapped/mammal.xml ___________________________________________________________________ Name: svn:keywords + Id Modified: jpamodelgen/trunk/src/test/suite/unit-tests.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-04 13:15:42 UTC= (rev 17902) +++ jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-04 13:22:37 UTC= (rev 17903) @@ -3,7 +3,8 @@ - + + \ No newline at end of file --===============5572435950295393792==-- From hibernate-commits at lists.jboss.org Wed Nov 4 08:30:44 2009 Content-Type: multipart/mixed; boundary="===============8167711918290440673==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17904 - jpamodelgen/trunk/src/test/resources. Date: Wed, 04 Nov 2009 08:30:44 -0500 Message-ID: <200911041330.nA4DUi6h008014@svn01.web.mwc.hst.phx2.redhat.com> --===============8167711918290440673== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-04 08:30:44 -0500 (Wed, 04 Nov 2009) New Revision: 17904 Removed: jpamodelgen/trunk/src/test/resources/model/ Log: METAGEN-3 deleted obsolete directories --===============8167711918290440673==-- From hibernate-commits at lists.jboss.org Wed Nov 4 08:32:41 2009 Content-Type: multipart/mixed; boundary="===============3801863073566661832==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17905 - jpamodelgen/trunk/src/test/suite. Date: Wed, 04 Nov 2009 08:32:41 -0500 Message-ID: <200911041332.nA4DWfxX008176@svn01.web.mwc.hst.phx2.redhat.com> --===============3801863073566661832== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-04 08:32:41 -0500 (Wed, 04 Nov 2009) New Revision: 17905 Modified: jpamodelgen/trunk/src/test/suite/unit-tests.xml Log: METAGEN-3 Modified: jpamodelgen/trunk/src/test/suite/unit-tests.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-04 13:30:44 UTC= (rev 17904) +++ jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-04 13:32:41 UTC= (rev 17905) @@ -4,6 +4,7 @@ + --===============3801863073566661832==-- From hibernate-commits at lists.jboss.org Wed Nov 4 09:04:29 2009 Content-Type: multipart/mixed; boundary="===============6664107732396784022==" MIME-Version: 1.0 From: Catlow To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Prepare to celebrate with us Date: Wed, 04 Nov 2009 21:04:33 +0700 Message-ID: <06FBB28B.82885@lists.jboss.org> --===============6664107732396784022== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Best creative 2009 works! http://www.foyojyj.cn/ --===============6664107732396784022==-- From hibernate-commits at lists.jboss.org Wed Nov 4 10:57:21 2009 Content-Type: multipart/mixed; boundary="===============2268175479537486173==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17906 - jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance. Date: Wed, 04 Nov 2009 10:57:21 -0500 Message-ID: <200911041557.nA4FvLir008234@svn01.web.mwc.hst.phx2.redhat.com> --===============2268175479537486173== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-04 10:57:20 -0500 (Wed, 04 Nov 2009) New Revision: 17906 Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/Customer.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/House.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/User.java Log: Enabled svn keyword substitution Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/in= heritance/Customer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Customer.java 2009-11-04 13:32:41 UTC (rev 17905) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Customer.java 2009-11-04 15:57:20 UTC (rev 17906) @@ -1,4 +1,4 @@ -// $Id: Customer.java 17899 2009-11-03 14:52:05Z hardy.ferentschik $ +// $Id$ /* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/inheritance/Customer.java ___________________________________________________________________ Name: svn:keywords + Id Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/in= heritance/House.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/House.java 2009-11-04 13:32:41 UTC (rev 17905) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/House.java 2009-11-04 15:57:20 UTC (rev 17906) @@ -1,4 +1,4 @@ -// $Id: House.java 17899 2009-11-03 14:52:05Z hardy.ferentschik $ +// $Id$ /* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/inheritance/House.java ___________________________________________________________________ Name: svn:keywords + Id Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/in= heritance/User.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/User.java 2009-11-04 13:32:41 UTC (rev 17905) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/User.java 2009-11-04 15:57:20 UTC (rev 17906) @@ -1,4 +1,4 @@ -// $Id: User.java 17899 2009-11-03 14:52:05Z hardy.ferentschik $ +// $Id$ /* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/inheritance/User.java ___________________________________________________________________ Name: svn:keywords + Id --===============2268175479537486173==-- From hibernate-commits at lists.jboss.org Wed Nov 4 10:58:27 2009 Content-Type: multipart/mixed; boundary="===============1986403101887297026==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17907 - jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance. Date: Wed, 04 Nov 2009 10:58:27 -0500 Message-ID: <200911041558.nA4FwR0r008453@svn01.web.mwc.hst.phx2.redhat.com> --===============1986403101887297026== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-04 10:58:26 -0500 (Wed, 04 Nov 2009) New Revision: 17907 Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/Area.java Log: Enabled svn keyword substitution Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/in= heritance/Area.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Area.java 2009-11-04 15:57:20 UTC (rev 17906) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Area.java 2009-11-04 15:58:26 UTC (rev 17907) @@ -1,4 +1,4 @@ -// $Id: Area.java 17899 2009-11-03 14:52:05Z hardy.ferentschik $ +// $Id$ /* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/inheritance/Area.java ___________________________________________________________________ Name: svn:keywords + Id --===============1986403101887297026==-- From hibernate-commits at lists.jboss.org Wed Nov 4 10:59:00 2009 Content-Type: multipart/mixed; boundary="===============4239965820988963061==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17908 - jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance. Date: Wed, 04 Nov 2009 10:59:00 -0500 Message-ID: <200911041559.nA4Fx0EJ008546@svn01.web.mwc.hst.phx2.redhat.com> --===============4239965820988963061== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-04 10:59:00 -0500 (Wed, 04 Nov 2009) New Revision: 17908 Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritan= ce/Building.java Log: Enabled svn keyword substitution Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/in= heritance/Building.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Building.java 2009-11-04 15:58:26 UTC (rev 17907) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inherita= nce/Building.java 2009-11-04 15:59:00 UTC (rev 17908) @@ -1,4 +1,4 @@ -// $Id: Building.java 17899 2009-11-03 14:52:05Z hardy.ferentschik $ +// $Id$ /* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/inheritance/Building.java ___________________________________________________________________ Name: svn:keywords + Id --===============4239965820988963061==-- From hibernate-commits at lists.jboss.org Wed Nov 4 10:59:21 2009 Content-Type: multipart/mixed; boundary="===============3917272071495211040==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17909 - jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util. Date: Wed, 04 Nov 2009 10:59:21 -0500 Message-ID: <200911041559.nA4FxLIb008610@svn01.web.mwc.hst.phx2.redhat.com> --===============3917272071495211040== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-04 10:59:20 -0500 (Wed, 04 Nov 2009) New Revision: 17909 Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Comp= ilationTest.java Log: Enabled svn keyword substitution Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/util/CompilationTest.java ___________________________________________________________________ Name: svn:keywords + Id --===============3917272071495211040==-- From hibernate-commits at lists.jboss.org Wed Nov 4 11:01:23 2009 Content-Type: multipart/mixed; boundary="===============8377038044557142715==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17910 - in jpamodelgen/trunk/src: main/java/org/hibernate/jpamodelgen/annotation and 5 other directories. Date: Wed, 04 Nov 2009 11:01:23 -0500 Message-ID: <200911041601.nA4G1NWW009448@svn01.web.mwc.hst.phx2.redhat.com> --===============8377038044557142715== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-04 11:01:22 -0500 (Wed, 04 Nov 2009) New Revision: 17910 Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype= /ArrayTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype= /Image.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype= /TemperatureSamples.java Removed: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/Image.java Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.ja= va jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Ann= otationMetaEntity.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Ann= otationMetaSingleAttribute.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstyp= e/AccessTypeTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Test= Util.java jpamodelgen/trunk/src/test/suite/unit-tests.xml Log: METAGEN-2 Added support for arrays. Arrays are now added to the metamodel as Singular= Attribute. We don't, however, cover the case yet where there is a @*ToMany annotation = on the array Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWr= iter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.j= ava 2009-11-04 15:59:20 UTC (rev 17909) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.j= ava 2009-11-04 16:01:22 UTC (rev 17910) @@ -17,26 +17,26 @@ */ package org.hibernate.jpamodelgen; = +import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; -import java.io.IOException; import java.io.StringWriter; import java.util.List; -import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.FilerException; -import javax.tools.FileObject; -import javax.tools.Diagnostic; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.DeclaredType; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.tools.Diagnostic; +import javax.tools.FileObject; = /** * @author Emmanuel Bernard */ public class ClassWriter { - = + public static void writeFile(MetaEntity entity, ProcessingEnvironment pro= cessingEnv, Context context) { try { String metaModelPackage =3D entity.getPackageName(); @@ -89,21 +89,13 @@ StringWriter sw =3D new StringWriter(); PrintWriter pw =3D null; try { - pw =3D new PrintWriter( sw ); - + // we cannot use add @Generated into the metamodel class since this wou= ld not work in a JDK 5 environment //pw.println( "@" + entity.importType( Generated.class.getName() ) + "(= \"JPA MetaModel for " + entity.getQualifiedName() + "\")" ); - pw.println( "@" + entity.importType( "javax.persistence.metamodel.Stati= cMetamodel" ) + "(" + entity.getSimpleName() + ".class)" ); - - - printClassDeclaration( entity, pw, context ); - pw.println(); - List members =3D entity.getMembers(); - for ( MetaAttribute metaMember : members ) { pw.println( " " + metaMember.getDeclarationString() ); } @@ -124,16 +116,15 @@ final TypeMirror superClass =3D entity.getTypeElement().getSuperclass(); //superclass of Object is of NoType which returns some other kind String superclassDeclaration =3D ""; - if (superClass.getKind() =3D=3D TypeKind.DECLARED ) { + if ( superClass.getKind() =3D=3D TypeKind.DECLARED ) { //F..king Ch...t Have those people used their horrible APIs even once? final Element superClassElement =3D ( ( DeclaredType ) superClass ).asE= lement(); String superClassName =3D ( ( TypeElement ) superClassElement ).getQual= ifiedName().toString(); if ( context.getMetaEntitiesToProcess().containsKey( superClassName ) || context.getMetaSuperclassAndEmbeddableToProcess().containsKey( sup= erClassName ) ) { - pw.print( " extends " + superClassName + "_" ); + pw.print( " extends " + superClassName + "_" ); } } - pw.println( " {" ); } } Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotat= ion/AnnotationMetaEntity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaEntity.java 2009-11-04 15:59:20 UTC (rev 17909) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaEntity.java 2009-11-04 16:01:22 UTC (rev 17910) @@ -25,38 +25,37 @@ import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; +import javax.lang.model.element.Modifier; import javax.lang.model.element.Name; import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; -import javax.lang.model.element.Modifier; +import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.ExecutableType; import javax.lang.model.type.PrimitiveType; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; import javax.lang.model.util.SimpleTypeVisitor6; +import javax.persistence.Access; +import javax.persistence.AccessType; +import javax.persistence.ElementCollection; +import javax.persistence.Embeddable; +import javax.persistence.Embedded; import javax.persistence.EmbeddedId; +import javax.persistence.Entity; import javax.persistence.Id; -import javax.persistence.AccessType; -import javax.persistence.Entity; import javax.persistence.MappedSuperclass; import javax.persistence.Transient; -import javax.persistence.Embedded; -import javax.persistence.Embeddable; -import javax.persistence.Access; -import javax.persistence.ElementCollection; -import javax.tools.Diagnostic.Kind; import javax.tools.Diagnostic; = -import org.hibernate.jpamodelgen.MetaEntity; -import org.hibernate.jpamodelgen.MetaAttribute; +import org.hibernate.jpamodelgen.Context; import org.hibernate.jpamodelgen.ImportContext; import org.hibernate.jpamodelgen.ImportContextImpl; +import org.hibernate.jpamodelgen.MetaAttribute; +import org.hibernate.jpamodelgen.MetaEntity; import org.hibernate.jpamodelgen.TypeUtils; -import org.hibernate.jpamodelgen.Context; = /** - * * @author Max Andersen * @author Hardy Ferentschik * @author Emmanuel Bernard @@ -80,7 +79,7 @@ } = public AnnotationMetaEntity(ProcessingEnvironment pe, TypeElement element= , Context context, AccessType accessType) { - this(pe, element, context); + this( pe, element, context ); this.defaultAccessTypeForHierarchy =3D accessType; } = @@ -88,10 +87,6 @@ return element.getSimpleName().toString(); } = - public Element getOriginalElement() { - return element; - } - public String getQualifiedName() { return element.getQualifiedName().toString(); } @@ -112,9 +107,9 @@ addPersistentMembers( membersFound, elementAccessType, methodsOfClass, A= ccessType.PROPERTY ); = //process superclasses - for(TypeElement superclass =3D TypeUtils.getSuperclass(element) ; - superclass !=3D null ; - superclass =3D TypeUtils.getSuperclass( superclass ) ) { + for ( TypeElement superclass =3D TypeUtils.getSuperclass( element ); + superclass !=3D null; + superclass =3D TypeUtils.getSuperclass( superclass ) ) { if ( superclass.getAnnotation( Entity.class ) !=3D null ) { break; //will be handled or has been handled already } @@ -123,11 +118,6 @@ context.processElement( superclass, defaultAccessTypeForHierarchy ); } } - - //this is valid to not have properties (ie subentities) -// if ( membersFound.size() =3D=3D 0 ) { -// pe.getMessager().printMessage( Kind.WARNING, "No properties found on = " + element, element ); -// } return membersFound; } = @@ -136,10 +126,8 @@ AccessType elementAccessType, List membersOfClass, AccessType membersKind) { - pe.getMessager() - .printMessage( Kind.NOTE, "Scanning " + membersOfClass.size() + " " += membersKind + " for " + element.toString() ); AccessType explicitAccessType; - if (elementAccessType =3D=3D membersKind) { + if ( elementAccessType =3D=3D membersKind ) { //all membersKind considered explicitAccessType =3D null; } @@ -149,27 +137,22 @@ } for ( Element memberOfClass : membersOfClass ) { = - AnnotationMetaAttribute result =3D memberOfClass.asType().accept( new T= ypeVisitor( this, explicitAccessType ), - memberOfClass - ); + TypeVisitor visitor =3D new TypeVisitor( this, explicitAccessType ); + AnnotationMetaAttribute result =3D memberOfClass.asType().accept( visit= or, memberOfClass ); if ( result !=3D null ) { membersFound.add( result ); } -//EBE not sure why? -// else { -// pe.getMessager().printMessage( Kind.WARNING, "Could not find valid i= nfo for JPA property", mymember ); -// } } } = private AccessType getAccessTypeForElement() { = //get local strategy - AccessType accessType =3D getAccessTypeForClass(element); - if (accessType =3D=3D null) { + AccessType accessType =3D getAccessTypeForClass( element ); + if ( accessType =3D=3D null ) { accessType =3D this.defaultAccessTypeForHierarchy; } - if (accessType =3D=3D null) { + if ( accessType =3D=3D null ) { //we dont' know //if an enity go up // @@ -179,13 +162,13 @@ TypeElement superClass =3D element; do { superClass =3D TypeUtils.getSuperclass( superClass ); - if (superClass !=3D null) { + if ( superClass !=3D null ) { if ( superClass.getAnnotation( Entity.class ) !=3D null || superClass.getAnnotation( MappedSuperclass.class ) !=3D null ) { //FIXME make it work for XML - AccessType superClassAccessType =3D getAccessTypeForClass(superClass= ); + AccessType superClassAccessType =3D getAccessTypeForClass( superClas= s ); //we've reach the root entity and resolved Ids - if ( superClassAccessType !=3D null && defaultAccessTypeForHierarchy= !=3D null) { + if ( superClassAccessType !=3D null && defaultAccessTypeForHierarchy= !=3D null ) { break; //we've found it } } @@ -212,11 +195,12 @@ pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "check class" + sea= rchedElement ); AccessType accessType =3D context.getAccessType( searchedElement ); = - if (defaultAccessTypeForHierarchy =3D=3D null) { + if ( defaultAccessTypeForHierarchy =3D=3D null ) { this.defaultAccessTypeForHierarchy =3D context.getDefaultAccessTypeForH= erarchy( searchedElement ); } if ( accessType !=3D null ) { - pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found in cache" += searchedElement + ":" + accessType ); + pe.getMessager() + .printMessage( Diagnostic.Kind.NOTE, "Found in cache" + searchedEleme= nt + ":" + accessType ); return accessType; } = @@ -226,14 +210,15 @@ */ final Access accessAnn =3D searchedElement.getAnnotation( Access.class ); AccessType forcedAccessType =3D accessAnn !=3D null ? accessAnn.value() = : null; - if ( forcedAccessType !=3D null) { - pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type " + s= earchedElement + ":" + forcedAccessType ); + if ( forcedAccessType !=3D null ) { + pe.getMessager() + .printMessage( Diagnostic.Kind.NOTE, "access type " + searchedElement= + ":" + forcedAccessType ); context.addAccessType( searchedElement, forcedAccessType ); } = //continue nevertheless to check if we are root and if defaultAccessType= ForHierarchy //should be overridden - if ( forcedAccessType =3D=3D null || defaultAccessTypeForHierarchy =3D= =3D null) { + if ( forcedAccessType =3D=3D null || defaultAccessTypeForHierarchy =3D= =3D null ) { List myMembers =3D searchedElement.getEnclosedElemen= ts(); for ( Element subElement : myMembers ) { List entityAnnotations =3D @@ -252,8 +237,10 @@ if ( kind =3D=3D ElementKind.FIELD || kind =3D=3D ElementKind.METHOD= ) { accessType =3D kind =3D=3D ElementKind.FIELD ? AccessType.FIELD : A= ccessType.PROPERTY; //FIXME enlever in niveau - if (defaultAccessTypeForHierarchy =3D=3D null) { - this.defaultAccessTypeForHierarchy =3D context.getDefaultAccessTyp= eForHerarchy( searchedElement ); + if ( defaultAccessTypeForHierarchy =3D=3D null ) { + this.defaultAccessTypeForHierarchy =3D context.getDefaultAccessTyp= eForHerarchy( + searchedElement + ); //we've discovered the class hierarchy, let's cache it if ( defaultAccessTypeForHierarchy =3D=3D null ) { this.defaultAccessTypeForHierarchy =3D accessType; @@ -262,9 +249,11 @@ //context.addAccessTypeForHierarchy( element, defaultAccessTypeFo= rHierarchy ); } } - if ( forcedAccessType =3D=3D null) { + if ( forcedAccessType =3D=3D null ) { context.addAccessType( searchedElement, accessType ); - pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type = " + searchedElement + ":" + accessType ); + pe.getMessager().printMessage( + Diagnostic.Kind.NOTE, "access type " + searchedElement + ":" + a= ccessType + ); return accessType; } else { @@ -323,10 +312,20 @@ } } = + @Override + public AnnotationMetaAttribute visitArray(ArrayType t, Element element) { + if ( isPersistent( element ) ) { + return new AnnotationMetaSingleAttribute( parent, element, TypeUtils.t= oTypeString( t ) ); + } + else { + return null; + } + } + private boolean isPersistent(Element element) { //FIXME consider XML boolean correctAccessType =3D false; - if (this.explicitAccessType =3D=3D null) { + if ( this.explicitAccessType =3D=3D null ) { correctAccessType =3D true; } else { @@ -342,7 +341,6 @@ = } = - @Override public AnnotationMetaAttribute visitDeclared(DeclaredType t, Element ele= ment) { //FIXME consider XML @@ -354,12 +352,17 @@ //collection of element if ( element.getAnnotation( ElementCollection.class ) !=3D null ) { final TypeMirror collectionType =3D t.getTypeArguments().get( 0 ); - final TypeElement collectionElement =3D ( TypeElement ) pe.getTypeUt= ils().asElement( collectionType ); - this.parent.context.processElement( collectionElement, - this.parent.defaultAccessTypeForElement ); + final TypeElement collectionElement =3D ( TypeElement ) pe.getTypeUt= ils() + .asElement( collectionType ); + this.parent.context.processElement( + collectionElement, + this.parent.defaultAccessTypeForElement + ); } if ( collection.equals( "javax.persistence.metamodel.MapAttribute" ) = ) { - return new AnnotationMetaMap( parent, element, collection, getKeyTyp= e( t ), getElementType( t ) ); + return new AnnotationMetaMap( + parent, element, collection, getKeyType( t ), getElementType( t ) + ); } else { return new AnnotationMetaCollection( parent, element, collection, ge= tElementType( t ) ); @@ -369,10 +372,14 @@ //FIXME Consider XML if ( element.getAnnotation( Embedded.class ) !=3D null || returnedElement.getAnnotation( Embeddable.class ) !=3D null ) { - this.parent.context.processElement( returnedElement, = - this.parent.defaultAccessTypeForElement ); + this.parent.context.processElement( + returnedElement, + this.parent.defaultAccessTypeForElement + ); } - return new AnnotationMetaSingleAttribute( parent, element, returnedEl= ement.getQualifiedName().toString() ); + return new AnnotationMetaSingleAttribute( + parent, element, returnedElement.getQualifiedName().toString() + ); } } else { @@ -380,7 +387,6 @@ } } = - @Override public AnnotationMetaAttribute visitExecutable(ExecutableType t, Element= p) { String string =3D p.getSimpleName().toString(); @@ -421,7 +427,6 @@ return t.getTypeArguments().get( 0 ).toString(); } = - private String getElementType(DeclaredType declaredType) { if ( declaredType.getTypeArguments().size() =3D=3D 1 ) { return declaredType.getTypeArguments().get( 0 ).toString(); Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotat= ion/AnnotationMetaSingleAttribute.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaSingleAttribute.java 2009-11-04 15:59:20 UTC (rev 17909) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaSingleAttribute.java 2009-11-04 16:01:22 UTC (rev 17910) @@ -17,12 +17,11 @@ */ package org.hibernate.jpamodelgen.annotation; = -import org.hibernate.jpamodelgen.MetaSingleAttribute; - import javax.lang.model.element.Element; = +import org.hibernate.jpamodelgen.MetaSingleAttribute; + /** - * * @author Max Andersen * @author Hardy Ferentschik * @author Emmanuel Bernard @@ -30,12 +29,11 @@ public class AnnotationMetaSingleAttribute extends AnnotationMetaAttribute= implements MetaSingleAttribute { = public AnnotationMetaSingleAttribute(AnnotationMetaEntity parent, Element= element, String type) { - super(parent, element, type); + super( parent, element, type ); } = @Override public String getMetaType() { return "javax.persistence.metamodel.SingularAttribute"; } - } Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/ac= cesstype/AccessTypeTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/AccessTypeTest.java 2009-11-04 15:59:20 UTC (rev 17909) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/AccessTypeTest.java 2009-11-04 16:01:22 UTC (rev 17910) @@ -21,6 +21,7 @@ = import org.hibernate.jpamodelgen.test.util.CompilationTest; import static org.hibernate.jpamodelgen.test.util.TestUtil.assertAbsenceOf= Field; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertFieldType; import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceO= fField; = /** @@ -81,6 +82,7 @@ @Test public void testMemberAccessType() throws Exception { assertPresenceOfField( Customer.class.getName() + "_", "goodPayer", "acc= ess type overriding" ); + assertFieldType( Customer.class.getName() + "_", "goodPayer", Boolean.cl= ass, "access type overriding" ); } = @Override Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/acc= esstype/Image.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Image.java 2009-11-04 15:59:20 UTC (rev 17909) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accessty= pe/Image.java 2009-11-04 16:01:22 UTC (rev 17910) @@ -1,46 +0,0 @@ -// $Id$ -/* -* JBoss, Home of Professional Open Source -* Copyright 2008, Red Hat Middleware LLC, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jpamodelgen.test.accesstype; - -import javax.persistence.Entity; - -/** - * @author Emmanuel Bernard - */ -(a)Entity -public class Image { - private String name; - - private byte[] data; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name =3D name; - } - - public byte[] getData() { - return data; - } - - public void setData(byte[] data) { - this.data =3D data; - } -} \ No newline at end of file Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arra= ytype/ArrayTest.java (from rev 17903, jpamodelgen/trunk/src/test/java/org/h= ibernate/jpamodelgen/test/inheritance/InheritanceTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytyp= e/ArrayTest.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytyp= e/ArrayTest.java 2009-11-04 16:01:22 UTC (rev 17910) @@ -0,0 +1,51 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.arraytype; + +import org.testng.annotations.Test; + +import org.hibernate.jpamodelgen.test.util.CompilationTest; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertFieldType; + +/** + * @author Hardy Ferentschik + */ +public class ArrayTest extends CompilationTest { + /** + * METAGEN-2 + */ + @Test + public void testPrimitiveArray() throws Exception { + assertFieldType( Image.class.getName() + "_", "data", byte[].class, "Wro= ng type for field." ); + } + + /** + * METAGEN-2 + */ + @Test + public void testIntegerArray() throws Exception { + assertFieldType( + TemperatureSamples.class.getName() + "_", "samples", Integer[].class, = "Wrong type for field." + ); + } + + @Override + protected String getTestPackage() { + return Image.class.getPackage().getName(); + } +} \ No newline at end of file Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arra= ytype/Image.java (from rev 17903, jpamodelgen/trunk/src/test/java/org/hiber= nate/jpamodelgen/test/accesstype/Image.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytyp= e/Image.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytyp= e/Image.java 2009-11-04 16:01:22 UTC (rev 17910) @@ -0,0 +1,46 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.arraytype; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Image { + private String name; + + private byte[] data; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public byte[] getData() { + return data; + } + + public void setData(byte[] data) { + this.data =3D data; + } +} \ No newline at end of file Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/arraytype/Image.java ___________________________________________________________________ Name: svn:keywords + Id Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/array= type/TemperatureSamples.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytyp= e/TemperatureSamples.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytyp= e/TemperatureSamples.java 2009-11-04 16:01:22 UTC (rev 17910) @@ -0,0 +1,36 @@ +// $Id: Image.java 17903 2009-11-04 13:22:37Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.arraytype; + +import javax.persistence.Entity; + +/** + * @author Hardy Feretnschik + */ +(a)Entity +public class TemperatureSamples { + private Integer[] samples; + + public Integer[] getSamples() { + return samples; + } + + public void setSamples(Integer[] samples) { + this.samples =3D samples; + } +} \ No newline at end of file Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/ut= il/TestUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Tes= tUtil.java 2009-11-04 15:59:20 UTC (rev 17909) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Tes= tUtil.java 2009-11-04 16:01:22 UTC (rev 17910) @@ -17,7 +17,13 @@ */ package org.hibernate.jpamodelgen.test.util; = +import java.lang.reflect.Field; +import java.lang.reflect.GenericArrayType; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + import org.testng.Assert; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.FileAssert.fail; = @@ -52,6 +58,19 @@ Assert.assertTrue( isFieldHere( className, fieldName ), errorString ); } = + public static void assertFieldType(String className, String fieldName, Cl= ass expectedType, String errorString) + throws ClassNotFoundException { + Field field =3D getField( className, fieldName ); + assertNotNull( field ); + ParameterizedType type =3D ( ParameterizedType ) field.getGenericType(); + Type actualType =3D type.getActualTypeArguments()[1]; + if ( expectedType.isArray() ) { + expectedType =3D expectedType.getComponentType(); + actualType =3D ( ( GenericArrayType ) actualType ).getGenericComponentT= ype(); + } + assertEquals( actualType, expectedType, errorString ); + } + public static void assertSuperClass(String className, String superClassNa= me) { Class clazz; Class superClazz; @@ -69,13 +88,16 @@ } = private static boolean isFieldHere(String className, String fieldName) th= rows ClassNotFoundException { + return getField( className, fieldName ) !=3D null; + } + + private static Field getField(String className, String fieldName) throws = ClassNotFoundException { Class clazz =3D Class.forName( className ); try { - clazz.getField( fieldName ); - return true; + return clazz.getField( fieldName ); } catch ( NoSuchFieldException e ) { - return false; + return null; } } } Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/util/TestUtil.java ___________________________________________________________________ Name: svn:keywords + Id Modified: jpamodelgen/trunk/src/test/suite/unit-tests.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-04 15:59:20 UTC= (rev 17909) +++ jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-04 16:01:22 UTC= (rev 17910) @@ -4,6 +4,7 @@ + --===============8377038044557142715==-- From hibernate-commits at lists.jboss.org Wed Nov 4 11:24:29 2009 Content-Type: multipart/mixed; boundary="===============1907969881269202998==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17911 - in validator/trunk/hibernate-validator/src/test: java/org/hibernate/validator/xml and 6 other directories. Date: Wed, 04 Nov 2009 11:24:29 -0500 Message-ID: <200911041624.nA4GOTDG016555@svn01.web.mwc.hst.phx2.redhat.com> --===============1907969881269202998== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-04 11:24:28 -0500 (Wed, 04 Nov 2009) New Revision: 17911 Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/ICompetition.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/IFixture.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/InheritanceMappingsTest.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/annotation/ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/annotation/Competition.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/annotation/Fixture.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/annotation/Game.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/annotation/GameDetail.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/annotation/PersonCompetition.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/annotation/TeamCompetition.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/xml/ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/xml/Competition.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/xml/Fixture.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/xml/Game.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/xml/GameDetail.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/xml/PersonCompetition.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/mixedconfiguration/xml/TeamCompetition.java validator/trunk/hibernate-validator/src/test/resources/org/hibernate/val= idator/xml/mixedconfiguration/ validator/trunk/hibernate-validator/src/test/resources/org/hibernate/val= idator/xml/mixedconfiguration/annotation-mappings.xml validator/trunk/hibernate-validator/src/test/resources/org/hibernate/val= idator/xml/mixedconfiguration/xml-mappings.xml Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/util/TestUtil.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/xml/XmlMappingTest.java validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml Log: HV-265 Added tests Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/v= alidator/util/TestUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/util/TestUtil.java 2009-11-04 16:01:22 UTC (rev 17910) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/util/TestUtil.java 2009-11-04 16:24:28 UTC (rev 17911) @@ -23,6 +23,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import javax.validation.Configuration; import javax.validation.ConstraintViolation; import javax.validation.Path; import javax.validation.Validation; @@ -55,14 +56,16 @@ = public static Validator getValidator() { if ( hibernateValidator =3D=3D null ) { - HibernateValidatorConfiguration configuration =3D Validation - .byProvider( HibernateValidator.class ) - .configure(); + Configuration configuration =3D getConfiguration(); hibernateValidator =3D configuration.buildValidatorFactory().getValidat= or(); } return hibernateValidator; } = + public static Configuration getConfiguration() { + return Validation.byProvider( HibernateValidator.class ).configure(); + } + /** * @param path The path to the xml file which should server as vali= dation.xml for the returned * Validator. Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/v= alidator/xml/XmlMappingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/XmlMappingTest.java 2009-11-04 16:01:22 UTC (rev 17910) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/XmlMappingTest.java 2009-11-04 16:24:28 UTC (rev 17911) @@ -22,7 +22,6 @@ import java.util.Set; import javax.validation.Configuration; import javax.validation.ConstraintViolation; -import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; import javax.validation.groups.Default; @@ -30,6 +29,8 @@ import static org.testng.Assert.assertEquals; import org.testng.annotations.Test; = +import org.hibernate.validator.util.TestUtil; + /** * @author Hardy Ferentschik */ @@ -41,7 +42,7 @@ */ public void testConstraintInheritanceWithXmlConfiguration() { = - final Configuration configuration =3D Validation.byDefaultProvider().= configure(); + final Configuration configuration =3D TestUtil.getConfiguration(); configuration.addMapping( XmlMappingTest.class.getResourceAsStream( "map= ping.xml" ) ); = final ValidatorFactory validatorFactory =3D configuration.buildValidator= Factory(); @@ -58,7 +59,7 @@ */ public void testListOfString() { = - final Configuration configuration =3D Validation.byDefaultProvider().= configure(); + final Configuration configuration =3D TestUtil.getConfiguration(); configuration.addMapping( XmlMappingTest.class.getResourceAsStream( "pro= perties-mapping.xml" ) ); = final ValidatorFactory validatorFactory =3D configuration.buildValidator= Factory(); @@ -82,14 +83,14 @@ */ public void testInterfaceConfiguration() { = - final Configuration configuration =3D Validation.byDefaultProvider().= configure(); + final Configuration configuration =3D TestUtil.getConfiguration(); configuration.addMapping( XmlMappingTest.class.getResourceAsStream( "my-= interface-mapping.xml" ) ); = final ValidatorFactory validatorFactory =3D configuration.buildValidator= Factory(); final Validator validator =3D validatorFactory.getValidator(); - final Set> violations =3D validator= .validate( new MyInterfaceImpl()); + final Set> violations =3D validator= .validate( new MyInterfaceImpl() ); = - assertEquals( violations.size(), 1); + assertEquals( violations.size(), 1 ); } = @Test @@ -98,29 +99,29 @@ */ public void testInterfaceImplementationConfiguration() { = - final Configuration configuration =3D Validation.byDefaultProvider().= configure(); + final Configuration configuration =3D TestUtil.getConfiguration(); configuration.addMapping( XmlMappingTest.class.getResourceAsStream( "my-= interface-impl-mapping.xml" ) ); = final ValidatorFactory validatorFactory =3D configuration.buildValidator= Factory(); final Validator validator =3D validatorFactory.getValidator(); - final Set> violations =3D validator= .validate( new MyInterfaceImpl()); + final Set> violations =3D validator= .validate( new MyInterfaceImpl() ); = - assertEquals( violations.size(), 1); + assertEquals( violations.size(), 1 ); } - = + @Test /** * HV-263 */ public void testEmptyInterfaceConfiguration() { = - final Configuration configuration =3D Validation.byDefaultProvider().= configure(); + final Configuration configuration =3D TestUtil.getConfiguration(); configuration.addMapping( XmlMappingTest.class.getResourceAsStream( "emp= ty-my-interface-mapping.xml" ) ); = final ValidatorFactory validatorFactory =3D configuration.buildValidator= Factory(); final Validator validator =3D validatorFactory.getValidator(); - final Set> violations =3D validator= .validate( new MyInterfaceImpl()); + final Set> violations =3D validator= .validate( new MyInterfaceImpl() ); = - assertEquals( violations.size(), 0); - } = + assertEquals( violations.size(), 0 ); + } } Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/ICompetition.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/ICompetition.java (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/ICompetition.java 2009-11-04 16:24:28 UTC (rev 17= 911) @@ -0,0 +1,20 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration; + +public interface ICompetition {} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/ICompetition.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/IFixture.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/IFixture.java (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/IFixture.java 2009-11-04 16:24:28 UTC (rev 17911) @@ -0,0 +1,22 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration; + +public interface IFixture { + ICompetition getCompetition(); +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/IFixture.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/InheritanceMappingsTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/InheritanceMappingsTest.java = (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/InheritanceMappingsTest.java 2009-11-04 16:24:28 = UTC (rev 17911) @@ -0,0 +1,130 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration; + +import java.lang.annotation.Annotation; +import java.util.Set; +import javax.validation.Configuration; +import javax.validation.ConstraintViolation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; +import javax.validation.constraints.NotNull; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.FileAssert.fail; +import org.testng.annotations.Test; + +import org.hibernate.validator.util.TestUtil; + + +/** + * See HV-265 + * + * @author Hardy Ferentschik + */ +public class InheritanceMappingsTest { + + @Test + public void defaultConfigurationNoExplicitAnnotationDefinition1() { + validateAnnotatedFixture( + new org.hibernate.validator.xml.mixedconfiguration.annotation.PersonCo= mpetition(), + configure() + ); + } + + @Test + public void defaultConfigurationNoExplicitAnnotationDefinition2() { + validateAnnotatedFixture( + new org.hibernate.validator.xml.mixedconfiguration.annotation.TeamComp= etition(), + configure() + ); + } + + @Test + public void customConfigurationNoExplicitAnnotationDefinition1() { + validateAnnotatedFixture( + new org.hibernate.validator.xml.mixedconfiguration.annotation.PersonCo= mpetition(), + configure( "annotation-mappings.xml" ) + ); + } + + @Test + public void customConfigurationNoExplicitAnnotationDefinition2() { + validateAnnotatedFixture( + new org.hibernate.validator.xml.mixedconfiguration.annotation.TeamComp= etition(), + configure( "annotation-mappings.xml" ) + ); + } + + @Test + public void customConfigurationExplicitXmlDefinition() { + validateXmlDefinedFixture( + new org.hibernate.validator.xml.mixedconfiguration.xml.PersonCompetiti= on(), + configure( "xml-mappings.xml" ) + ); + } + + @Test + public void customConfigurationNoExplicitXmlDefinition() { + validateXmlDefinedFixture( + new org.hibernate.validator.xml.mixedconfiguration.xml.TeamCompetition= (), + configure( "xml-mappings.xml" ) + ); + } + + private Validator configure() { + return TestUtil.getValidator(); + } + + private Validator configure(String mappingsUrl) { + Configuration configuration =3D TestUtil.getConfiguration(); + configuration.addMapping( InheritanceMappingsTest.class.getResourceAsStr= eam( mappingsUrl ) ); + + ValidatorFactory validatorFactory =3D configuration.buildValidatorFactor= y(); + return validatorFactory.getValidator(); + } + + private void validateFixture(IFixture fixture, Validator validator) { + Set> violations =3D validator.validate( fi= xture ); + + for ( ConstraintViolation violation : violations ) { + if ( violation.getLeafBean() instanceof ICompetition + && "detail.competition.name".equals( violation.getPropertyPath().toSt= ring() ) ) { + assertEquals( violation.getLeafBean(), fixture.getCompetition() ); + Annotation annotation =3D ( ( Annotation ) violation.getConstraintDesc= riptor().getAnnotation() ); + assertEquals( annotation.annotationType(), NotNull.class ); + return; + } + } + fail( "@NotNull constraint violation for 'detail.competition.name' not d= etected" ); + } + + private void validateAnnotatedFixture(org.hibernate.validator.xml.mixedco= nfiguration.annotation.Competition competition, + Validator validator) { + org.hibernate.validator.xml.mixedconfiguration.annotation.Fixture fixtur= e =3D new org.hibernate.validator.xml.mixedconfiguration.annotation.Fixture= (); + fixture.setCompetition( competition ); + validateFixture( fixture, validator ); + } + + private void validateXmlDefinedFixture(org.hibernate.validator.xml.mixedc= onfiguration.xml.Competition competition, + Validator validator) { + org.hibernate.validator.xml.mixedconfiguration.xml.Fixture fixture =3D n= ew org.hibernate.validator.xml.mixedconfiguration.xml.Fixture(); + fixture.setCompetition( competition ); + validateFixture( fixture, validator ); + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/InheritanceMappingsTest.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/annotation/Competition.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/Competition.java = (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/Competition.java 2009-11-04 16:24:28 U= TC (rev 17911) @@ -0,0 +1,46 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.annotation; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import org.hibernate.validator.xml.mixedconfiguration.ICompetition; + +public abstract class Competition implements ICompetition { + + @NotNull + @Size(min =3D 1) + private String name; + + public Competition() { + super(); + } + + public Competition(String name) { + setName( name ); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/annotation/Competition.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/annotation/Fixture.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/Fixture.java (= rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/Fixture.java 2009-11-04 16:24:28 UTC (= rev 17911) @@ -0,0 +1,31 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.annotation; + +import org.hibernate.validator.xml.mixedconfiguration.IFixture; + +public class Fixture extends Game implements IFixture { + + public Fixture() { + super(); + } + + public Fixture(Competition competition) { + super( competition ); + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/annotation/Fixture.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/annotation/Game.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/Game.java (rev= 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/Game.java 2009-11-04 16:24:28 UTC (rev= 17911) @@ -0,0 +1,48 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.annotation; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +public abstract class Game { + + @NotNull + @Valid + private GameDetail detail; + + private Game(GameDetail detail) { + this.detail =3D detail; + } + + public Game() { + this( new GameDetail() ); + } + + public Game(Competition competition) { + this( new GameDetail( competition ) ); + } + + public Competition getCompetition() { + return detail.getCompetition(); + } + + public void setCompetition(Competition competition) { + detail.setCompetition( competition ); + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/annotation/Game.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/annotation/GameDetail.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/GameDetail.java = (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/GameDetail.java 2009-11-04 16:24:28 UT= C (rev 17911) @@ -0,0 +1,44 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.annotation; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +public class GameDetail { + + @NotNull + @Valid + private Competition competition; + + public GameDetail() { + super(); + } + + public GameDetail(Competition competition) { + setCompetition( competition ); + } + + public Competition getCompetition() { + return competition; + } + + public void setCompetition(Competition competition) { + this.competition =3D competition; + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/annotation/GameDetail.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/annotation/PersonCompetition.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/PersonCompetition.java = (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/PersonCompetition.java 2009-11-04 16:2= 4:28 UTC (rev 17911) @@ -0,0 +1,29 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.annotation; + +public class PersonCompetition extends Competition { + + public PersonCompetition() { + super(); + } + + public PersonCompetition(String name) { + super( name ); + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/annotation/PersonCompetition.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/annotation/TeamCompetition.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/TeamCompetition.java = (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/annotation/TeamCompetition.java 2009-11-04 16:24:= 28 UTC (rev 17911) @@ -0,0 +1,28 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.annotation; + +public class TeamCompetition extends Competition { + public TeamCompetition() { + super(); + } + + public TeamCompetition(String name) { + super( name ); + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/annotation/TeamCompetition.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/xml/Competition.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/Competition.java (rev= 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/Competition.java 2009-11-04 16:24:28 UTC (rev= 17911) @@ -0,0 +1,41 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.xml; + +import org.hibernate.validator.xml.mixedconfiguration.ICompetition; + +public abstract class Competition implements ICompetition { + + private String name; + + public Competition() { + super(); + } + + public Competition(String name) { + setName( name ); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/xml/Competition.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/xml/Fixture.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/Fixture.java (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/Fixture.java 2009-11-04 16:24:28 UTC (rev 179= 11) @@ -0,0 +1,36 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.xml; + +import org.hibernate.validator.xml.mixedconfiguration.IFixture; + +public class Fixture extends Game implements IFixture { + + public Fixture() { + super(); + } + + public Fixture(Competition competition) { + super( competition ); + } + + @Override + public void setCompetition(Competition competition) { + super.setCompetition( competition ); + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/xml/Fixture.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/xml/Game.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/Game.java (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/Game.java 2009-11-04 16:24:28 UTC (rev 17911) @@ -0,0 +1,43 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.xml; + +public abstract class Game { + + private GameDetail detail; + + private Game(GameDetail detail) { + this.detail =3D detail; + } + + public Game() { + this( new GameDetail() ); + } + + public Game(Competition competition) { + this( new GameDetail( competition ) ); + } + + public Competition getCompetition() { + return detail.getCompetition(); + } + + public void setCompetition(Competition competition) { + detail.setCompetition( competition ); + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/xml/Game.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/xml/GameDetail.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/GameDetail.java (rev = 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/GameDetail.java 2009-11-04 16:24:28 UTC (rev = 17911) @@ -0,0 +1,39 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.xml; + +public class GameDetail { + + private Competition competition; + + public GameDetail() { + super(); + } + + public GameDetail(Competition competition) { + setCompetition( competition ); + } + + public Competition getCompetition() { + return competition; + } + + public void setCompetition(Competition competition) { + this.competition =3D competition; + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/xml/GameDetail.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/xml/PersonCompetition.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/PersonCompetition.java = (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/PersonCompetition.java 2009-11-04 16:24:28 UT= C (rev 17911) @@ -0,0 +1,29 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.xml; + +public class PersonCompetition extends Competition { + + public PersonCompetition() { + super(); + } + + public PersonCompetition(String name) { + super( name ); + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/xml/PersonCompetition.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/xml/mixedconfiguration/xml/TeamCompetition.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/TeamCompetition.java = (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/xml/mixedconfiguration/xml/TeamCompetition.java 2009-11-04 16:24:28 UTC = (rev 17911) @@ -0,0 +1,29 @@ +// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferent= schik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.xml.mixedconfiguration.xml; + +public class TeamCompetition extends Competition { + + public TeamCompetition() { + super(); + } + + public TeamCompetition(String name) { + super( name ); + } +} Property changes on: validator/trunk/hibernate-validator/src/test/java/org/= hibernate/validator/xml/mixedconfiguration/xml/TeamCompetition.java ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/resources/org/hibernate= /validator/xml/mixedconfiguration/annotation-mappings.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/resources/org/hibernate/va= lidator/xml/mixedconfiguration/annotation-mappings.xml = (rev 0) +++ validator/trunk/hibernate-validator/src/test/resources/org/hibernate/va= lidator/xml/mixedconfiguration/annotation-mappings.xml 2009-11-04 16:24:28 = UTC (rev 17911) @@ -0,0 +1,9 @@ + + + + Property changes on: validator/trunk/hibernate-validator/src/test/resources= /org/hibernate/validator/xml/mixedconfiguration/annotation-mappings.xml ___________________________________________________________________ Name: svn:executable + * Added: validator/trunk/hibernate-validator/src/test/resources/org/hibernate= /validator/xml/mixedconfiguration/xml-mappings.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/resources/org/hibernate/va= lidator/xml/mixedconfiguration/xml-mappings.xml (re= v 0) +++ validator/trunk/hibernate-validator/src/test/resources/org/hibernate/va= lidator/xml/mixedconfiguration/xml-mappings.xml 2009-11-04 16:24:28 UTC (re= v 17911) @@ -0,0 +1,37 @@ + + + + org.hibernate.validator.xml.mixedconfiguration.xml + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + Property changes on: validator/trunk/hibernate-validator/src/test/resources= /org/hibernate/validator/xml/mixedconfiguration/xml-mappings.xml ___________________________________________________________________ Name: svn:executable + * Modified: validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml 2009-= 11-04 16:01:22 UTC (rev 17910) +++ validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml 2009-= 11-04 16:24:28 UTC (rev 17911) @@ -16,6 +16,7 @@ + \ No newline at end of file --===============1907969881269202998==-- From hibernate-commits at lists.jboss.org Wed Nov 4 13:40:13 2009 Content-Type: multipart/mixed; boundary="===============7439766529197761881==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17912 - in core/trunk/envers/src/main/java/org: hibernate/envers/exception and 2 other directories. Date: Wed, 04 Nov 2009 13:40:13 -0500 Message-ID: <200911041840.nA4IeD1L010295@svn01.web.mwc.hst.phx2.redhat.com> --===============7439766529197761881== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: adamw Date: 2009-11-04 13:40:13 -0500 (Wed, 04 Nov 2009) New Revision: 17912 Removed: core/trunk/envers/src/main/java/org/jboss/envers/ Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metad= ata/reader/AnnotationsMetadataReader.java core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metad= ata/reader/AuditedPropertiesReader.java core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditExce= ption.java core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotAudite= dException.java core/trunk/envers/src/main/java/org/hibernate/envers/exception/RevisionD= oesNotExistException.java core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderI= mpl.java core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderI= mplementor.java Log: Removing the org.jboss compatibility classes Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuratio= n/metadata/reader/AnnotationsMetadataReader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/reader/AnnotationsMetadataReader.java 2009-11-04 16:24:28 UTC (rev 179= 11) +++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/reader/AnnotationsMetadataReader.java 2009-11-04 18:40:13 UTC (rev 179= 12) @@ -36,7 +36,6 @@ import org.hibernate.annotations.common.reflection.XClass; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; -import org.jboss.envers.*; = /** * A helper class to read versioning meta-data from annotations on a persi= stent class. @@ -69,12 +68,7 @@ if (defaultAudited !=3D null) { return defaultAudited.modStore(); } else { - Versioned defaultVersioned =3D clazz.getAnnotation(Versioned.class); - if (defaultVersioned !=3D null) { - return ModificationStore.FULL; - } else { - return null; - } + return null; } } = Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuratio= n/metadata/reader/AuditedPropertiesReader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/reader/AuditedPropertiesReader.java 2009-11-04 16:24:28 UTC (rev 17911) +++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/reader/AuditedPropertiesReader.java 2009-11-04 18:40:13 UTC (rev 17912) @@ -26,7 +26,6 @@ import org.hibernate.mapping.Property; import org.hibernate.mapping.Value; import org.hibernate.MappingException; -import org.jboss.envers.Versioned; = /** * Reads persistent properties form a @@ -157,12 +156,9 @@ = // Checking if this property is explicitly audited or if all properties = are. Audited aud =3D property.getAnnotation(Audited.class); - Versioned ver =3D property.getAnnotation(Versioned.class); if (aud !=3D null) { propertyData.setStore(aud.modStore()); propertyData.setRelationTargetAuditMode(aud.targetAuditMode()); - } else if (ver !=3D null) { - propertyData.setStore(ModificationStore.FULL); } else { if (defaultStore !=3D null) { propertyData.setStore(defaultStore); Modified: core/trunk/envers/src/main/java/org/hibernate/envers/exception/Au= ditException.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditExc= eption.java 2009-11-04 16:24:28 UTC (rev 17911) +++ core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditExc= eption.java 2009-11-04 18:40:13 UTC (rev 17912) @@ -23,13 +23,15 @@ */ package org.hibernate.envers.exception; = -import org.jboss.envers.exception.VersionsException; +import org.hibernate.HibernateException; = /** * @author Adam Warski (adam at warski dot org) */ -public class AuditException extends VersionsException { - public AuditException(String message) { +public class AuditException extends HibernateException { + private static final long serialVersionUID =3D 4306480965630972168L; + + public AuditException(String message) { super(message); } = Modified: core/trunk/envers/src/main/java/org/hibernate/envers/exception/No= tAuditedException.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotAudit= edException.java 2009-11-04 16:24:28 UTC (rev 17911) +++ core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotAudit= edException.java 2009-11-04 18:40:13 UTC (rev 17912) @@ -23,13 +23,20 @@ */ package org.hibernate.envers.exception; = -import org.jboss.envers.exception.NotVersionedException; - /** * @author Adam Warski (adam at warski dot org) */ -public class NotAuditedException extends NotVersionedException { - public NotAuditedException(String entityName, String message) { - super(entityName, message); +public class NotAuditedException extends AuditException { + private static final long serialVersionUID =3D 4809674577449455510L; + = + private final String entityName; + + public NotAuditedException(String entityName, String message) { + super(message); + this.entityName =3D entityName; } + + public String getEntityName() { + return entityName; + } } Modified: core/trunk/envers/src/main/java/org/hibernate/envers/exception/Re= visionDoesNotExistException.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/exception/Revision= DoesNotExistException.java 2009-11-04 16:24:28 UTC (rev 17911) +++ core/trunk/envers/src/main/java/org/hibernate/envers/exception/Revision= DoesNotExistException.java 2009-11-04 18:40:13 UTC (rev 17912) @@ -28,12 +28,27 @@ /** * @author Adam Warski (adam at warski dot org) */ -public class RevisionDoesNotExistException extends org.jboss.envers.except= ion.RevisionDoesNotExistException { - public RevisionDoesNotExistException(Number revision) { - super(revision); +public class RevisionDoesNotExistException extends AuditException { + private static final long serialVersionUID =3D -6417768274074962282L; + = + private Number revision; + private Date date; + + public RevisionDoesNotExistException(Number revision) { + super("Revision " + revision + " does not exist."); + this.revision =3D revision; } = public RevisionDoesNotExistException(Date date) { - super(date); + super("There is no revision before or at " + date + "."); + this.date =3D date; } + + public Number getRevision() { + return revision; + } + + public Date getDate() { + return date; + } } Modified: core/trunk/envers/src/main/java/org/hibernate/envers/reader/Audit= ReaderImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReader= Impl.java 2009-11-04 16:24:28 UTC (rev 17911) +++ core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReader= Impl.java 2009-11-04 18:40:13 UTC (rev 17912) @@ -32,6 +32,7 @@ import org.hibernate.envers.exception.RevisionDoesNotExistException; import org.hibernate.envers.exception.AuditException; import org.hibernate.envers.query.AuditEntity; +import org.hibernate.envers.query.AuditQueryCreator; import static org.hibernate.envers.tools.ArgumentsTools.checkNotNull; import static org.hibernate.envers.tools.ArgumentsTools.checkPositive; import org.hibernate.envers.synchronization.AuditSync; @@ -41,7 +42,6 @@ import org.hibernate.Session; import org.hibernate.event.EventSource; import org.hibernate.engine.SessionImplementor; -import org.jboss.envers.query.VersionsQueryCreator; = /** * @author Adam Warski (adam at warski dot org) @@ -205,7 +205,7 @@ return (T) auditSync.getCurrentRevisionData(session, persist); } = - public VersionsQueryCreator createQuery() { - return new VersionsQueryCreator(verCfg, this); + public AuditQueryCreator createQuery() { + return new AuditQueryCreator(verCfg, this); } } Modified: core/trunk/envers/src/main/java/org/hibernate/envers/reader/Audit= ReaderImplementor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReader= Implementor.java 2009-11-04 16:24:28 UTC (rev 17911) +++ core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReader= Implementor.java 2009-11-04 18:40:13 UTC (rev 17912) @@ -27,13 +27,12 @@ = import org.hibernate.Session; import org.hibernate.engine.SessionImplementor; -import org.jboss.envers.VersionsReader; = /** * An interface exposed by a VersionsReader to library-facing classes. * @author Adam Warski (adam at warski dot org) */ -public interface AuditReaderImplementor extends AuditReader, VersionsReade= r { +public interface AuditReaderImplementor extends AuditReader { SessionImplementor getSessionImplementor(); Session getSession(); FirstLevelCache getFirstLevelCache(); --===============7439766529197761881==-- From hibernate-commits at lists.jboss.org Wed Nov 4 16:19:23 2009 Content-Type: multipart/mixed; boundary="===============1101282912920652979==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17913 - in core/trunk: core/src/main/java/org/hibernate/context and 16 other directories. Date: Wed, 04 Nov 2009 16:19:23 -0500 Message-ID: <200911042119.nA4LJN06008865@svn01.web.mwc.hst.phx2.redhat.com> --===============1101282912920652979== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-04 16:19:21 -0500 (Wed, 04 Nov 2009) New Revision: 17913 Added: core/trunk/core/src/main/java/org/hibernate/action/AfterTransactionCompl= etionProcess.java core/trunk/core/src/main/java/org/hibernate/action/BeforeTransactionComp= letionProcess.java Modified: core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupA= ction.java core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.java core/trunk/core/src/main/java/org/hibernate/action/EntityAction.java core/trunk/core/src/main/java/org/hibernate/action/EntityDeleteAction.ja= va core/trunk/core/src/main/java/org/hibernate/action/EntityIdentityInsertA= ction.java core/trunk/core/src/main/java/org/hibernate/action/EntityInsertAction.ja= va core/trunk/core/src/main/java/org/hibernate/action/EntityUpdateAction.ja= va core/trunk/core/src/main/java/org/hibernate/action/Executable.java core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionCo= ntext.java core/trunk/core/src/main/java/org/hibernate/dialect/MySQLDialect.java core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java core/trunk/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryP= lan.java core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater.= java core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEntity= EventListener.java core/trunk/core/src/main/java/org/hibernate/hql/ast/QueryTranslatorImpl.= java core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/AbstractStateme= ntExecutor.java core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableDelet= eExecutor.java core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableUpdat= eExecutor.java core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/FromClause.java core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/IntoClause.java core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java core/trunk/core/src/main/java/org/hibernate/jdbc/Expectations.java core/trunk/core/src/main/java/org/hibernate/loader/Loader.java core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEnt= ityPersister.java core/trunk/core/src/main/java/org/hibernate/type/CollectionType.java core/trunk/testsuite/src/test/java/org/hibernate/test/cid/CompositeIdWit= hGeneratorTest.java core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadi= ngTest.java core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JPALockTe= st.java Log: HHH-4545 - Allow o.h.action.Executable to register for either (or both) bef= ore or after transaction completion callbacks Added: core/trunk/core/src/main/java/org/hibernate/action/AfterTransactionC= ompletionProcess.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/AfterTransactionComp= letionProcess.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/action/AfterTransactionComp= letionProcess.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -0,0 +1,41 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.action; + +import org.hibernate.engine.SessionImplementor; + +/** + * Contract representing some process that needs to occur during after tra= nsaction completion. + * + * @author Steve Ebersole + */ +public interface AfterTransactionCompletionProcess { + /** + * Perform whatever processing is encapsulated here after completion of t= he transaction. + * + * @param success Did the transaction complete successfully? True means = it did. + * @param session The session on which the transaction is completing. + */ + public void doAfterTransactionCompletion(boolean success, SessionImplemen= tor session); +} Added: core/trunk/core/src/main/java/org/hibernate/action/BeforeTransaction= CompletionProcess.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/BeforeTransactionCom= pletionProcess.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/action/BeforeTransactionCom= pletionProcess.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -0,0 +1,40 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.action; + +import org.hibernate.engine.SessionImplementor; + +/** + * Contract representing some process that needs to occur during before tr= ansaction completion. + * + * @author Steve Ebersole + */ +public interface BeforeTransactionCompletionProcess { + /** + * Perform whatever processing is encapsulated here before completion of = the transaction. + * + * @param session The session on which the transaction is preparing to co= mplete. + */ + public void doBeforeTransactionCompletion(SessionImplementor session); +} Modified: core/trunk/core/src/main/java/org/hibernate/action/BulkOperationC= leanupAction.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanup= Action.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanup= Action.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -70,19 +70,13 @@ * @param session The session to which this request is tied. * @param affectedQueryables The affected entity persisters. */ - public BulkOperationCleanupAction( - SessionImplementor session, - Queryable[] affectedQueryables) { + public BulkOperationCleanupAction(SessionImplementor session, Queryable[]= affectedQueryables) { SessionFactoryImplementor factory =3D session.getFactory(); ArrayList tmpSpaces =3D new ArrayList(); for ( int i =3D 0; i < affectedQueryables.length; i++ ) { tmpSpaces.addAll( Arrays.asList( affectedQueryables[i].getQuerySpaces()= ) ); if ( affectedQueryables[i].hasCache() ) { - entityCleanups.add( - new EntityCleanup( - affectedQueryables[i].getCacheAccessStrategy() - ) - ); + entityCleanups.add( new EntityCleanup( affectedQueryables[i].getCacheA= ccessStrategy() ) ); } Set roles =3D factory.getCollectionRolesByEntityParticipant( affectedQu= eryables[i].getEntityName() ); if ( roles !=3D null ) { @@ -91,11 +85,7 @@ String role =3D ( String ) itr.next(); CollectionPersister collectionPersister =3D factory.getCollectionPers= ister( role ); if ( collectionPersister.hasCache() ) { - collectionCleanups.add( - new CollectionCleanup( - collectionPersister.getCacheAccessStrategy() - ) - ); + collectionCleanups.add( new CollectionCleanup( collectionPersister.g= etCacheAccessStrategy() ) ); } } } @@ -129,11 +119,7 @@ if ( affectedEntity( tableSpaces, entitySpaces ) ) { tmpSpaces.addAll( Arrays.asList( entitySpaces ) ); if ( persister.hasCache() ) { - entityCleanups.add( - new EntityCleanup( - persister.getCacheAccessStrategy() - ) - ); + entityCleanups.add( new EntityCleanup( persister.getCacheAccessStrate= gy() ) ); } Set roles =3D session.getFactory().getCollectionRolesByEntityParticipa= nt( persister.getEntityName() ); if ( roles !=3D null ) { @@ -143,9 +129,7 @@ CollectionPersister collectionPersister =3D factory.getCollectionPer= sister( role ); if ( collectionPersister.hasCache() ) { collectionCleanups.add( - new CollectionCleanup( - collectionPersister.getCacheAccessStrategy() - ) + new CollectionCleanup( collectionPersister.getCacheAccessStrategy= () ) ); } } @@ -169,9 +153,7 @@ * @return True if there are affected table spaces and any of the incoming * check table spaces occur in that set. */ - private boolean affectedEntity( - Set affectedTableSpaces, - Serializable[] checkTableSpaces) { + private boolean affectedEntity(Set affectedTableSpaces, Serializable[] ch= eckTableSpaces) { if ( affectedTableSpaces =3D=3D null || affectedTableSpaces.isEmpty() ) { return true; } @@ -188,22 +170,26 @@ return affectedTableSpaces; } = - public boolean hasAfterTransactionCompletion() { - return true; + public BeforeTransactionCompletionProcess getBeforeTransactionCompletionP= rocess() { + return null; } = - public void afterTransactionCompletion(boolean success) throws HibernateE= xception { - Iterator itr =3D entityCleanups.iterator(); - while ( itr.hasNext() ) { - final EntityCleanup cleanup =3D ( EntityCleanup ) itr.next(); - cleanup.release(); - } + public AfterTransactionCompletionProcess getAfterTransactionCompletionPro= cess() { + return new AfterTransactionCompletionProcess() { + public void doAfterTransactionCompletion(boolean success, SessionImplem= entor session) { + Iterator itr =3D entityCleanups.iterator(); + while ( itr.hasNext() ) { + final EntityCleanup cleanup =3D ( EntityCleanup ) itr.next(); + cleanup.release(); + } = - itr =3D collectionCleanups.iterator(); - while ( itr.hasNext() ) { - final CollectionCleanup cleanup =3D ( CollectionCleanup ) itr.next(); - cleanup.release(); - } + itr =3D collectionCleanups.iterator(); + while ( itr.hasNext() ) { + final CollectionCleanup cleanup =3D ( CollectionCleanup ) itr.next(); + cleanup.release(); + } + } + }; } = public void beforeExecutions() throws HibernateException { Modified: core/trunk/core/src/main/java/org/hibernate/action/CollectionActi= on.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.jav= a 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.jav= a 2009-11-04 21:19:21 UTC (rev 17913) @@ -39,15 +39,13 @@ = /** * Any action relating to insert/update/delete of a collection + * * @author Gavin King */ public abstract class CollectionAction implements Executable, Serializable= , Comparable { - private transient CollectionPersister persister; private final Serializable key; - private Serializable finalKey; private final SessionImplementor session; - private SoftLock lock; private final String collectionRole; private final PersistentCollection collection; = @@ -62,33 +60,47 @@ this.collectionRole =3D persister.getRole(); this.collection =3D collection; } - = + protected PersistentCollection getCollection() { return collection; } = - private void readObject(ObjectInputStream ois) throws IOException, ClassN= otFoundException { + protected void readObject(ObjectInputStream ois) throws IOException, Clas= sNotFoundException { ois.defaultReadObject(); persister =3D session.getFactory().getCollectionPersister( collectionRol= e ); } = - public void afterTransactionCompletion(boolean success) throws CacheExcep= tion { + public final void beforeExecutions() throws CacheException { + // we need to obtain the lock before any actions are + // executed, since this may be an inverse=3D"true" + // bidirectional association and it is one of the + // earlier entity actions which actually updates + // the database (this action is resposible for + // second-level cache invalidation only) if ( persister.hasCache() ) { - final CacheKey ck =3D new CacheKey( = - key, = - persister.getKeyType(), = - persister.getRole(), = - session.getEntityMode(), = - session.getFactory() = - ); - persister.getCacheAccessStrategy().unlockItem( ck, lock ); + final CacheKey ck =3D new CacheKey( + key, + persister.getKeyType(), + persister.getRole(), + session.getEntityMode(), + session.getFactory() + ); + final SoftLock lock =3D persister.getCacheAccessStrategy().lockItem( ck= , null ); + // the old behavior used key as opposed to getKey() + afterTransactionProcess =3D new CacheCleanupProcess( key, persister, lo= ck ); } } = - public boolean hasAfterTransactionCompletion() { - return persister.hasCache(); + public BeforeTransactionCompletionProcess getBeforeTransactionCompletionP= rocess() { + return null; } = + private AfterTransactionCompletionProcess afterTransactionProcess; + + public AfterTransactionCompletionProcess getAfterTransactionCompletionPro= cess() { + return afterTransactionProcess; + } + public Serializable[] getPropertySpaces() { return persister.getCollectionSpaces(); } @@ -98,7 +110,7 @@ } = protected final Serializable getKey() { - finalKey =3D key; + Serializable finalKey =3D key; if ( key instanceof DelayedPostInsertIdentifier ) { // need to look it up from the persistence-context finalKey =3D session.getPersistenceContext().getEntry( collection.getOw= ner() ).getId(); @@ -114,25 +126,6 @@ return session; } = - public final void beforeExecutions() throws CacheException { - // we need to obtain the lock before any actions are - // executed, since this may be an inverse=3D"true" - // bidirectional association and it is one of the - // earlier entity actions which actually updates - // the database (this action is resposible for - // second-level cache invalidation only) - if ( persister.hasCache() ) { - final CacheKey ck =3D new CacheKey( = - key, = - persister.getKeyType(), = - persister.getRole(), = - session.getEntityMode(), = - session.getFactory() = - ); - lock =3D persister.getCacheAccessStrategy().lockItem( ck, null ); - } - } - protected final void evict() throws CacheException { if ( persister.hasCache() ) { CacheKey ck =3D new CacheKey( = @@ -164,6 +157,29 @@ .compare( key, action.key, session.getEntityMode() ); } } + + private static class CacheCleanupProcess implements AfterTransactionCompl= etionProcess { + private final Serializable key; + private final CollectionPersister persister; + private final SoftLock lock; + + private CacheCleanupProcess(Serializable key, CollectionPersister persis= ter, SoftLock lock) { + this.key =3D key; + this.persister =3D persister; + this.lock =3D lock; + } + + public void doAfterTransactionCompletion(boolean success, SessionImpleme= ntor session) { + final CacheKey ck =3D new CacheKey( + key, + persister.getKeyType(), + persister.getRole(), + session.getEntityMode(), + session.getFactory() + ); + persister.getCacheAccessStrategy().unlockItem( ck, lock ); + } + } } = = Modified: core/trunk/core/src/main/java/org/hibernate/action/EntityAction.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/EntityAction.java 20= 09-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/action/EntityAction.java 20= 09-11-04 21:19:21 UTC (rev 17913) @@ -40,7 +40,8 @@ * * @author Gavin King */ -public abstract class EntityAction implements Executable, Serializable, Co= mparable { +public abstract class EntityAction + implements Executable, Serializable, Comparable, AfterTransactionComplet= ionProcess { = private final String entityName; private final Serializable id; @@ -65,8 +66,22 @@ this.persister =3D persister; } = + public BeforeTransactionCompletionProcess getBeforeTransactionCompletionP= rocess() { + return null; + } + + public AfterTransactionCompletionProcess getAfterTransactionCompletionPro= cess() { + return needsAfterTransactionCompletion() + ? this + : null; + } + protected abstract boolean hasPostCommitEventListeners(); = + public boolean needsAfterTransactionCompletion() { + return persister.hasCache() || hasPostCommitEventListeners(); + } + /** * entity name accessor * @@ -123,10 +138,6 @@ throw new AssertionFailure( "beforeExecutions() called for non-collectio= n action" ); } = - public boolean hasAfterTransactionCompletion() { - return persister.hasCache() || hasPostCommitEventListeners(); - } - public String toString() { return StringHelper.unqualify( getClass().getName() ) + MessageHelper.in= foString( entityName, id ); } Modified: core/trunk/core/src/main/java/org/hibernate/action/EntityDeleteAc= tion.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/EntityDeleteAction.j= ava 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/action/EntityDeleteAction.j= ava 2009-11-04 21:19:21 UTC (rev 17913) @@ -42,12 +42,12 @@ import org.hibernate.persister.entity.EntityPersister; = public final class EntityDeleteAction extends EntityAction { - private final Object version; - private SoftLock lock; private final boolean isCascadeDeleteEnabled; private final Object[] state; = + private SoftLock lock; + public EntityDeleteAction( final Serializable id, final Object[] state, @@ -86,7 +86,7 @@ persister.getRootEntityName(), = session.getEntityMode(), = session.getFactory() = - ); + ); lock =3D persister.getCacheAccessStrategy().lockItem( ck, version ); } else { @@ -112,19 +112,19 @@ persistenceContext.removeEntity(key); persistenceContext.removeProxy(key); = - if ( persister.hasCache() ) persister.getCacheAccessStrategy().remove( c= k ); + if ( persister.hasCache() ) { + persister.getCacheAccessStrategy().remove( ck ); + } = postDelete(); = if ( getSession().getFactory().getStatistics().isStatisticsEnabled() && = !veto ) { - getSession().getFactory().getStatisticsImplementor() - .deleteEntity( getPersister().getEntityName() ); + getSession().getFactory().getStatisticsImplementor().deleteEntity( getP= ersister().getEntityName() ); } } = private boolean preDelete() { - PreDeleteEventListener[] preListeners =3D getSession().getListeners() - .getPreDeleteEventListeners(); + PreDeleteEventListener[] preListeners =3D getSession().getListeners().ge= tPreDeleteEventListeners(); boolean veto =3D false; if (preListeners.length>0) { PreDeleteEvent preEvent =3D new PreDeleteEvent( getInstance(), getId(),= state, getPersister() ,(EventSource) getSession() ); @@ -169,29 +169,21 @@ } } = - public void afterTransactionCompletion(boolean success) throws HibernateE= xception { + public void doAfterTransactionCompletion(boolean success, SessionImplemen= tor session) throws HibernateException { if ( getPersister().hasCache() ) { - final CacheKey ck =3D new CacheKey( = - getId(), = - getPersister().getIdentifierType(), = + final CacheKey ck =3D new CacheKey( + getId(), + getPersister().getIdentifierType(), getPersister().getRootEntityName(), - getSession().getEntityMode(), = + getSession().getEntityMode(), getSession().getFactory() - ); + ); getPersister().getCacheAccessStrategy().unlockItem( ck, lock ); } postCommitDelete(); } = protected boolean hasPostCommitEventListeners() { - return getSession().getListeners().getPostCommitDeleteEventListeners().l= ength>0; + return getSession().getListeners().getPostCommitDeleteEventListeners().l= ength > 0; } - } - - - - - - - Modified: core/trunk/core/src/main/java/org/hibernate/action/EntityIdentity= InsertAction.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/EntityIdentityInsert= Action.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/action/EntityIdentityInsert= Action.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -37,7 +37,8 @@ import org.hibernate.event.EventSource; import org.hibernate.persister.entity.EntityPersister; = -public final class EntityIdentityInsertAction extends EntityAction { +public final class EntityIdentityInsertAction extends EntityAction { + private final Object[] state; private final boolean isDelayed; private final EntityKey delayedEntityKey; @@ -53,11 +54,10 @@ super( session, null, instance, persister ); this.state =3D state; this.isDelayed =3D isDelayed; - delayedEntityKey =3D isDelayed ? generateDelayedEntityKey() : null; + this.delayedEntityKey =3D isDelayed ? generateDelayedEntityKey() : null; } = public void execute() throws HibernateException { - = final EntityPersister persister =3D getPersister(); final SessionImplementor session =3D getSession(); final Object instance =3D getInstance(); @@ -89,12 +89,29 @@ postInsert(); = if ( session.getFactory().getStatistics().isStatisticsEnabled() && !veto= ) { - session.getFactory().getStatisticsImplementor() - .insertEntity( getPersister().getEntityName() ); + session.getFactory().getStatisticsImplementor().insertEntity( getPersis= ter().getEntityName() ); } = } = + public boolean needsAfterTransactionCompletion() { + //TODO: simply remove this override if we fix the above todos + return hasPostCommitEventListeners(); + } + + protected boolean hasPostCommitEventListeners() { + return getSession().getListeners().getPostCommitInsertEventListeners().l= ength>0; + } + + public void doAfterTransactionCompletion(boolean success, SessionImplemen= tor session) { + //TODO: reenable if we also fix the above todo + /*EntityPersister persister =3D getEntityPersister(); + if ( success && persister.hasCache() && !persister.isCacheInvalidationRe= quired() ) { + persister.getCache().afterInsert( getGeneratedId(), cacheEntry ); + }*/ + postCommitInsert(); + } + private void postInsert() { if ( isDelayed ) { getSession().getPersistenceContext().replaceDelayedEntityIdentityInsert= Keys( delayedEntityKey, generatedId ); @@ -145,26 +162,6 @@ return veto; } = - //Make 100% certain that this is called before any subsequent ScheduledUp= date.afterTransactionCompletion()!! - public void afterTransactionCompletion(boolean success) throws HibernateE= xception { - //TODO: reenable if we also fix the above todo - /*EntityPersister persister =3D getEntityPersister(); - if ( success && persister.hasCache() && !persister.isCacheInvalidationRe= quired() ) { - persister.getCache().afterInsert( getGeneratedId(), cacheEntry ); - }*/ - postCommitInsert(); - } - - public boolean hasAfterTransactionCompletion() { - //TODO: simply remove this override - // if we fix the above todos - return hasPostCommitEventListeners(); - } - - protected boolean hasPostCommitEventListeners() { - return getSession().getListeners().getPostCommitInsertEventListeners().l= ength>0; - } - = public final Serializable getGeneratedId() { return generatedId; } Modified: core/trunk/core/src/main/java/org/hibernate/action/EntityInsertAc= tion.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/EntityInsertAction.j= ava 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/action/EntityInsertAction.j= ava 2009-11-04 21:19:21 UTC (rev 17913) @@ -116,7 +116,6 @@ session.getEntityMode(), = session.getFactory() = ); -// boolean put =3D persister.getCache().insert(ck, cacheEntry); boolean put =3D persister.getCacheAccessStrategy().insert( ck, cacheEnt= ry, version ); = if ( put && factory.getStatistics().isStatisticsEnabled() ) { @@ -181,8 +180,10 @@ return veto; } = - //Make 100% certain that this is called before any subsequent ScheduledUp= date.afterTransactionCompletion()!! - public void afterTransactionCompletion(boolean success) throws HibernateE= xception { + /** + * {@inheritDoc} + */ + public void doAfterTransactionCompletion(boolean success, SessionImplemen= tor session) throws HibernateException { EntityPersister persister =3D getPersister(); if ( success && isCachePutEnabled( persister, getSession() ) ) { final CacheKey ck =3D new CacheKey( = @@ -191,7 +192,7 @@ persister.getRootEntityName(), = getSession().getEntityMode(), = getSession().getFactory() = - ); + ); boolean put =3D persister.getCacheAccessStrategy().afterInsert( ck, cac= heEntry, version ); = if ( put && getSession().getFactory().getStatistics().isStatisticsEnabl= ed() ) { @@ -207,16 +208,9 @@ } = private boolean isCachePutEnabled(EntityPersister persister, SessionImple= mentor session) { - return persister.hasCache() && = - !persister.isCacheInvalidationRequired() && = - session.getCacheMode().isPutEnabled(); + return persister.hasCache() + && !persister.isCacheInvalidationRequired() + && session.getCacheMode().isPutEnabled(); } = } - - - - - - - Modified: core/trunk/core/src/main/java/org/hibernate/action/EntityUpdateAc= tion.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/EntityUpdateAction.j= ava 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/action/EntityUpdateAction.j= ava 2009-11-04 21:19:21 UTC (rev 17913) @@ -46,14 +46,13 @@ import org.hibernate.type.TypeFactory; = public final class EntityUpdateAction extends EntityAction { - private final Object[] state; private final Object[] previousState; private final Object previousVersion; - private Object nextVersion; private final int[] dirtyFields; private final boolean hasDirtyCollection; private final Object rowId; + private Object nextVersion; private Object cacheEntry; private SoftLock lock; = @@ -149,7 +148,7 @@ nextVersion =3D Versioning.getVersion( state, persister ); } } - // have the entity entry perform post-update processing, passing it the + // have the entity entry doAfterTransactionCompletion post-update proce= ssing, passing it the // update state and the new version (if one). entry.postUpdate( instance, state, nextVersion ); } @@ -240,7 +239,11 @@ return veto; } = - public void afterTransactionCompletion(boolean success) throws CacheExcep= tion { + protected boolean hasPostCommitEventListeners() { + return getSession().getListeners().getPostCommitUpdateEventListeners().l= ength>0; + } + + public void doAfterTransactionCompletion(boolean success, SessionImplemen= tor session) throws CacheException { EntityPersister persister =3D getPersister(); if ( persister.hasCache() ) { = @@ -266,10 +269,6 @@ postCommitUpdate(); } = - protected boolean hasPostCommitEventListeners() { - return getSession().getListeners().getPostCommitUpdateEventListeners().l= ength>0; - } - = } = = Modified: core/trunk/core/src/main/java/org/hibernate/action/Executable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/Executable.java 2009= -11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/action/Executable.java 2009= -11-04 21:19:21 UTC (rev 17913) @@ -34,29 +34,43 @@ * together with required second-level cache management. * = * @author Gavin King + * @author Steve Ebersole */ public interface Executable { /** - * Called before executing any actions + * What spaces (tables) are affected by this action? + * + * @return The spaces affected by this action. */ + public Serializable[] getPropertySpaces(); + + /** + * Called before executing any actions. Gives actions a chance to perfor= m any preparation. + * + * @throws HibernateException Indicates a problem during preparation. + */ public void beforeExecutions() throws HibernateException; + /** * Execute this action + * + * @throws HibernateException Indicates a problem during execution. */ public void execute() throws HibernateException; + /** - * Do we need to retain this instance until after the - * transaction completes? - * @return false if this class defines a no-op - * hasAfterTransactionCompletion() + * Get the after-transaction-completion process, if any, for this action. + * + * @return The after-transaction-completion process, or null if we have no + * after-transaction-completion process */ - public boolean hasAfterTransactionCompletion(); + public AfterTransactionCompletionProcess getAfterTransactionCompletionPro= cess(); + /** - * Called after the transaction completes + * Get the before-transaction-completion process, if any, for this action. + * + * @return The before-transaction-completion process, or null if we have = no + * before-transaction-completion process */ - public void afterTransactionCompletion(boolean success) throws HibernateE= xception; - /** - * What spaces (tables) are affected by this action? - */ - public Serializable[] getPropertySpaces(); + public BeforeTransactionCompletionProcess getBeforeTransactionCompletionP= rocess(); } Modified: core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSe= ssionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionC= ontext.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionC= ontext.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -319,7 +319,7 @@ // method call to pass through since the real session // will complain by throwing an appropriate exception; // NOTE that allowing close() above has the same basic effect, - // but we capture that there simply to perform the unbind... + // but we capture that there simply to doAfterTransactionCompletion= the unbind... } else if ( !realSession.getTransaction().isActive() ) { // limit the methods available if no transaction is active Modified: core/trunk/core/src/main/java/org/hibernate/dialect/MySQLDialect.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/MySQLDialect.java 2= 009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/dialect/MySQLDialect.java 2= 009-11-04 21:19:21 UTC (rev 17913) @@ -287,7 +287,7 @@ = public Boolean performTemporaryTableDDLInIsolation() { // because we [drop *temporary* table...] we do not - // have to perform these in isolation. + // have to doAfterTransactionCompletion these in isolation. return Boolean.FALSE; } = Modified: core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java 200= 9-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java 200= 9-11-04 21:19:21 UTC (rev 17913) @@ -34,6 +34,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +import java.util.HashSet; = import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,6 +50,8 @@ import org.hibernate.action.EntityInsertAction; import org.hibernate.action.EntityUpdateAction; import org.hibernate.action.Executable; +import org.hibernate.action.AfterTransactionCompletionProcess; +import org.hibernate.action.BeforeTransactionCompletionProcess; import org.hibernate.cache.CacheException; import org.hibernate.type.Type; = @@ -82,7 +85,8 @@ private ArrayList collectionUpdates; private ArrayList collectionRemovals; = - private ArrayList executions; + private AfterTransactionCompletionProcessQueue afterTransactionProcesses; + private BeforeTransactionCompletionProcessQueue beforeTransactionProcesse= s; = /** * Constructs an action queue bound to the given session. @@ -103,7 +107,8 @@ collectionRemovals =3D new ArrayList( INIT_QUEUE_LIST_SIZE ); collectionUpdates =3D new ArrayList( INIT_QUEUE_LIST_SIZE ); = - executions =3D new ArrayList( INIT_QUEUE_LIST_SIZE * 3 ); + afterTransactionProcesses =3D new AfterTransactionCompletionProcessQueue= ( session ); + beforeTransactionProcesses =3D new BeforeTransactionCompletionProcessQue= ue( session ); } = public void clear() { @@ -145,10 +150,17 @@ } = public void addAction(BulkOperationCleanupAction cleanupAction) { - // Add these directly to the executions queue - executions.add( cleanupAction ); + registerProcess( cleanupAction.getAfterTransactionCompletionProcess() ); } = + public void registerProcess(AfterTransactionCompletionProcess process) { + afterTransactionProcesses.register( process ); + } + + public void registerProcess(BeforeTransactionCompletionProcess process) { + beforeTransactionProcesses.register( process ); + } + /** * Perform all currently queued entity-insertion actions. * @@ -189,32 +201,17 @@ * @param success Was the transaction successful. */ public void afterTransactionCompletion(boolean success) { - int size =3D executions.size(); - final boolean invalidateQueryCache =3D session.getFactory().getSettings(= ).isQueryCacheEnabled(); - for ( int i =3D 0; i < size; i++ ) { - try { - Executable exec =3D ( Executable ) executions.get( i ); - try { - exec.afterTransactionCompletion( success ); - } - finally { - if ( invalidateQueryCache ) { - session.getFactory().getUpdateTimestampsCache().invalidate( exec.get= PropertySpaces() ); - } - } - } - catch ( CacheException ce ) { - log.error( "could not release a cache lock", ce ); - // continue loop - } - catch ( Exception e ) { - throw new AssertionFailure( "Exception releasing cache locks", e ); - } - } - executions.clear(); + afterTransactionProcesses.afterTransactionCompletion( success ); } = /** + * Execute any registered {@link BeforeTransactionCompletionProcess} + */ + public void beforeTransactionCompletion() { + beforeTransactionProcesses.beforeTransactionCompletion(); + } + + /** * Check whether the given tables/query-spaces are to be executed against * given the currently queued actions. * @@ -267,16 +264,18 @@ } = public void execute(Executable executable) { - final boolean lockQueryCache =3D session.getFactory().getSettings().isQu= eryCacheEnabled(); - if ( executable.hasAfterTransactionCompletion() || lockQueryCache ) { - executions.add( executable ); + try { + executable.execute(); } - if ( lockQueryCache ) { - session.getFactory() - .getUpdateTimestampsCache() - .preinvalidate( executable.getPropertySpaces() ); + finally { + beforeTransactionProcesses.register( executable.getBeforeTransactionCom= pletionProcess() ); + if ( session.getFactory().getSettings().isQueryCacheEnabled() ) { + final String[] spaces =3D (String[]) executable.getPropertySpaces(); + afterTransactionProcesses.addSpacesToInvalidate( spaces ); + session.getFactory().getUpdateTimestampsCache().preinvalidate( executa= ble.getPropertySpaces() ); + } + afterTransactionProcesses.register( executable.getAfterTransactionCompl= etionProcess() ); } - executable.execute(); } = private void prepareActions(List queue) throws HibernateException { @@ -376,7 +375,8 @@ } = public boolean hasAfterTransactionActions() { - return executions.size() > 0; + // todo : method is not used anywhere; why is it here? + return afterTransactionProcesses.processes.size() > 0; } = public boolean hasAnyQueuedActions() { @@ -394,7 +394,7 @@ * * @param oos The stream to which the action queue should get written * - * @throws IOException + * @throws IOException Indicates an error writing to the stream */ public void serialize(ObjectOutputStream oos) throws IOException { log.trace( "serializing action-queue" ); @@ -447,8 +447,12 @@ * action queue * * @param ois The stream from which to read the action queue + * @param session The session to which the action queue belongs * - * @throws IOException + * @return The deserialized action queue + * + * @throws IOException indicates a problem reading from the stream + * @throws ClassNotFoundException Generally means we were unable to locat= e user classes. */ public static ActionQueue deserialize( ObjectInputStream ois, @@ -500,14 +504,100 @@ return rtn; } = + private static class BeforeTransactionCompletionProcessQueue { + private SessionImplementor session; + private List processes =3D new ArrayList(); = + private BeforeTransactionCompletionProcessQueue(SessionImplementor sessi= on) { + this.session =3D session; + } + + public void register(BeforeTransactionCompletionProcess process) { + if ( process =3D=3D null ) { + return; + } + processes.add( process ); + } + + public void beforeTransactionCompletion() { + final int size =3D processes.size(); + for ( int i =3D 0; i < size; i++ ) { + try { + BeforeTransactionCompletionProcess process =3D ( BeforeTransactionCom= pletionProcess ) processes.get( i ); + process.doBeforeTransactionCompletion( session ); + } + catch ( HibernateException he ) { + throw he; + } + catch ( Exception e ) { + throw new AssertionFailure( "Unable to perform beforeTransactionCompl= etion callback", e ); + } + } + processes.clear(); + } + } + + private static class AfterTransactionCompletionProcessQueue { + private SessionImplementor session; + private Set querySpacesToInvalidate =3D new HashSet(); + private List processes =3D new ArrayList( INIT_QUEUE_LIST_SIZE * 3 ); + + private AfterTransactionCompletionProcessQueue(SessionImplementor sessio= n) { + this.session =3D session; + } + + public void addSpacesToInvalidate(String[] spaces) { + if ( spaces =3D=3D null ) { + return; + } + for ( int i =3D 0, max =3D spaces.length; i < max; i++ ) { + addSpaceToInvalidate( spaces[i] ); + } + } + + public void addSpaceToInvalidate(String space) { + querySpacesToInvalidate.add( space ); + } + + public void register(AfterTransactionCompletionProcess process) { + if ( process =3D=3D null ) { + return; + } + processes.add( process ); + } + + public void afterTransactionCompletion(boolean success) { + final int size =3D processes.size(); + for ( int i =3D 0; i < size; i++ ) { + try { + AfterTransactionCompletionProcess process =3D ( AfterTransactionCompl= etionProcess ) processes.get( i ); + process.doAfterTransactionCompletion( success, session ); + } + catch ( CacheException ce ) { + log.error( "could not release a cache lock", ce ); + // continue loop + } + catch ( Exception e ) { + throw new AssertionFailure( "Exception releasing cache locks", e ); + } + } + processes.clear(); + + if ( session.getFactory().getSettings().isQueryCacheEnabled() ) { + session.getFactory().getUpdateTimestampsCache().invalidate( + ( String[] ) querySpacesToInvalidate.toArray( new String[ querySpace= sToInvalidate.size()] ) + ); + } + querySpacesToInvalidate.clear(); + } + } + /** * Sorts the insert actions using more hashes. * * @author Jay Erb */ private class InsertActionSorter { - // the mapping of entity names to their latest batch numbers. private HashMap latestBatches =3D new HashMap(); private HashMap entityBatchNumber; @@ -567,10 +657,16 @@ } = /** - * Finds an acceptable batch for this entity to be a member. + * Finds an acceptable batch for this entity to be a member as part of t= he {@link InsertActionSorter} + * + * @param action The action being sorted + * @param entityName The name of the entity affected by the action + * + * @return An appropriate batch number; todo document this process better */ - private Integer findBatchNumber(EntityInsertAction action, - String entityName) { + private Integer findBatchNumber( + EntityInsertAction action, + String entityName) { // loop through all the associated entities and make sure they have been // processed before the latest // batch associated with this entity type. Modified: core/trunk/core/src/main/java/org/hibernate/engine/query/NativeSQ= LQueryPlan.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/query/NativeSQLQuery= Plan.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/engine/query/NativeSQLQuery= Plan.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -179,7 +179,7 @@ ( ( EventSource ) session ).getActionQueue().addAction( action ); } else { - action.afterTransactionCompletion( true ); + action.getAfterTransactionCompletionProcess().doAfterTransactionComplet= ion( true, session ); } } = Modified: core/trunk/core/src/main/java/org/hibernate/engine/transaction/Is= olater.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater= .java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater= .java 2009-11-04 21:19:21 UTC (rev 17913) @@ -126,7 +126,7 @@ = connection =3D session.getBatcher().openConnection(); = - // perform the actual work + // doAfterTransactionCompletion the actual work work.doWork( connection ); = // if everything went ok, commit the transaction and close the obtained Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlus= hEntityEventListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEntit= yEventListener.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEntit= yEventListener.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -287,7 +287,7 @@ dirtyProperties =3D ArrayHelper.EMPTY_INT_ARRAY; } = - // check nullability but do not perform command execute + // check nullability but do not doAfterTransactionCompletion command exe= cute // we'll use scheduled updates for that. new Nullability(session).checkNullability( values, persister, true ); = Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/QueryTranslat= orImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/hql/ast/QueryTranslatorImpl= .java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/hql/ast/QueryTranslatorImpl= .java 2009-11-04 21:19:21 UTC (rev 17913) @@ -547,7 +547,7 @@ if ( persister.isMultiTable() ) { // even here, if only properties mapped to the "base table" are refere= nced // in the set and where clauses, this could be handled by the BasicDel= egate. - // TODO : decide if it is better performance-wise to perform that chec= k, or to simply use the MultiTableUpdateDelegate + // TODO : decide if it is better performance-wise to doAfterTransactio= nCompletion that check, or to simply use the MultiTableUpdateDelegate return new MultiTableUpdateExecutor( walker ); } else { Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/Abstract= StatementExecutor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/AbstractStatem= entExecutor.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/AbstractStatem= entExecutor.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -245,7 +245,7 @@ ( ( EventSource ) session ).getActionQueue().addAction( action ); } else { - action.afterTransactionCompletion( true ); + action.getAfterTransactionCompletionProcess().doAfterTransactionComplet= ion( true, session ); } } = Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTab= leDeleteExecutor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableDele= teExecutor.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableDele= teExecutor.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -59,7 +59,7 @@ super( walker, log ); = if ( !walker.getSessionFactoryHelper().getFactory().getDialect().support= sTemporaryTables() ) { - throw new HibernateException( "cannot perform multi-table deletes using= dialect not supporting temp tables" ); + throw new HibernateException( "cannot doAfterTransactionCompletion mult= i-table deletes using dialect not supporting temp tables" ); } = DeleteStatement deleteStatement =3D ( DeleteStatement ) walker.getAST(); Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTab= leUpdateExecutor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableUpda= teExecutor.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableUpda= teExecutor.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -63,7 +63,7 @@ super( walker, log ); = if ( !walker.getSessionFactoryHelper().getFactory().getDialect().support= sTemporaryTables() ) { - throw new HibernateException( "cannot perform multi-table updates using= dialect not supporting temp tables" ); + throw new HibernateException( "cannot doAfterTransactionCompletion mult= i-table updates using dialect not supporting temp tables" ); } = UpdateStatement updateStatement =3D ( UpdateStatement ) walker.getAST(); Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/FromClau= se.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/FromClause.jav= a 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/FromClause.jav= a 2009-11-04 21:19:21 UTC (rev 17913) @@ -333,7 +333,7 @@ // the subquery has already been performed (meaning that for // theta-join dialects, the join conditions have already been moved // over to the where clause). A "simple" solution here might to - // perform "join post processing" once for the entire query (including + // doAfterTransactionCompletion "join post processing" once for the ent= ire query (including // any subqueries) at one fell swoop } = Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/IntoClau= se.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/IntoClause.jav= a 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/IntoClause.jav= a 2009-11-04 21:19:21 UTC (rev 17913) @@ -220,7 +220,7 @@ return true; } = - // otherwise, perform a "deep equivalence" check... + // otherwise, doAfterTransactionCompletion a "deep equivalence" check... = if ( !target.getReturnedClass().isAssignableFrom( source.getReturnedClas= s() ) ) { return false; Modified: core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java 2009-= 11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java 2009-= 11-04 21:19:21 UTC (rev 17913) @@ -423,6 +423,7 @@ = public void beforeTransactionCompletion(Transaction tx) { log.trace( "before transaction completion" ); + actionQueue.beforeTransactionCompletion(); if ( rootSession =3D=3D null ) { try { interceptor.beforeTransactionCompletion(tx); @@ -1185,7 +1186,7 @@ errorIfClosed(); checkTransactionSynchStatus(); if ( query =3D=3D null ) { - throw new IllegalArgumentException("attempt to perform delete-by-query = with null query"); + throw new IllegalArgumentException("attempt to doAfterTransactionComple= tion delete-by-query with null query"); } = if ( log.isTraceEnabled() ) { Modified: core/trunk/core/src/main/java/org/hibernate/jdbc/Expectations.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/jdbc/Expectations.java 2009= -11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/jdbc/Expectations.java 2009= -11-04 21:19:21 UTC (rev 17913) @@ -161,7 +161,7 @@ = public static final Expectation NONE =3D new Expectation() { public void verifyOutcome(int rowCount, PreparedStatement statement, int= batchPosition) { - // explicitly perform no checking... + // explicitly doAfterTransactionCompletion no checking... } = public int prepare(PreparedStatement statement) { Modified: core/trunk/core/src/main/java/org/hibernate/loader/Loader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/loader/Loader.java 2009-11-= 04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/loader/Loader.java 2009-11-= 04 21:19:21 UTC (rev 17913) @@ -352,7 +352,7 @@ throw JDBCExceptionHelper.convert( factory.getSQLExceptionConverter(), sqle, - "could not perform sequential read of results (forward)", + "could not doAfterTransactionCompletion sequential read of resu= lts (forward)", getSQLString() ); } @@ -400,7 +400,7 @@ } = // We call getKeyFromResultSet() here so that we can know the - // key value upon which to perform the breaking logic. However, + // key value upon which to doAfterTransactionCompletion the breaking lo= gic. However, // it is also then called from getRowFromResultSet() which is certainly // not the most efficient. But the call here is needed, and there // currently is no other way without refactoring of the doQuery()/getRo= wFromResultSet() @@ -419,7 +419,7 @@ throw JDBCExceptionHelper.convert( factory.getSQLExceptionConverter(), sqle, - "could not perform sequential read of results (forward)", + "could not doAfterTransactionCompletion sequential read of resu= lts (forward)", getSQLString() ); } @@ -538,14 +538,14 @@ // at the first physical row we are interested in loading resultSet.next(); = - // and perform the load + // and doAfterTransactionCompletion the load return sequentialLoad( resultSet, session, queryParameters, returnProxi= es, keyToRead ); } catch ( SQLException sqle ) { throw JDBCExceptionHelper.convert( factory.getSQLExceptionConverter(), sqle, - "could not perform sequential read of results (forward)", + "could not doAfterTransactionCompletion sequential read of resu= lts (forward)", getSQLString() ); } Modified: core/trunk/core/src/main/java/org/hibernate/persister/entity/Abst= ractEntityPersister.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEn= tityPersister.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEn= tityPersister.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -2794,7 +2794,7 @@ // need to treat this as if it where optimistic-lock=3D"all" (dirty doe= s *not* make sense); // first we need to locate the "loaded" state // - // Note, it potentially could be a proxy, so perform the location the s= afe way... + // Note, it potentially could be a proxy, so doAfterTransactionCompleti= on the location the safe way... EntityKey key =3D new EntityKey( id, this, session.getEntityMode() ); Object entity =3D session.getPersistenceContext().getEntity( key ); if ( entity !=3D null ) { Modified: core/trunk/core/src/main/java/org/hibernate/type/CollectionType.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/type/CollectionType.java 20= 09-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/core/src/main/java/org/hibernate/type/CollectionType.java 20= 09-11-04 21:19:21 UTC (rev 17913) @@ -120,7 +120,7 @@ } = public int getHashCode(Object x, EntityMode entityMode) { - throw new UnsupportedOperationException( "cannot perform lookups on coll= ections" ); + throw new UnsupportedOperationException( "cannot doAfterTransactionCompl= etion lookups on collections" ); } = /** Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/cid/Composi= teIdWithGeneratorTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/cid/CompositeIdWi= thGeneratorTest.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/cid/CompositeIdWi= thGeneratorTest.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -494,7 +494,7 @@ s =3D openSession(); t =3D s.beginTransaction(); = - // perform a find to show that it will wire together fine + // doAfterTransactionCompletion a find to show that it will wire togethe= r fine PurchaseRecord foundRecord =3D (PurchaseRecord) s.get(PurchaseRecord.cla= ss, new PurchaseRecord.Id(foundPurchaseNumber, foundPurchaseSequence) ); Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTPars= erLoadingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoad= ingTest.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoad= ingTest.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -527,14 +527,14 @@ assertEquals( 1, types.length ); assertTrue( types[0] instanceof ComponentType ); = - // Test the ability to perform comparisions between component values + // Test the ability to doAfterTransactionCompletion comparisions between= component values s.createQuery( "from Human h where h.name =3D h.name" ).list(); s.createQuery( "from Human h where h.name =3D :name" ).setParameter( "na= me", new Name() ).list(); s.createQuery( "from Human where name =3D :name" ).setParameter( "name",= new Name() ).list(); s.createQuery( "from Human h where :name =3D h.name" ).setParameter( "na= me", new Name() ).list(); s.createQuery( "from Human h where :name <> h.name" ).setParameter( "nam= e", new Name() ).list(); = - // Test the ability to perform comparisions between a component and an e= xplicit row-value + // Test the ability to doAfterTransactionCompletion comparisions between= a component and an explicit row-value s.createQuery( "from Human h where h.name =3D ('John', 'X', 'Doe')" ).li= st(); s.createQuery( "from Human h where ('John', 'X', 'Doe') =3D h.name" ).li= st(); s.createQuery( "from Human h where ('John', 'X', 'Doe') <> h.name" ).lis= t(); Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JP= ALockTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JPALockT= est.java 2009-11-04 18:40:13 UTC (rev 17912) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JPALockT= est.java 2009-11-04 21:19:21 UTC (rev 17913) @@ -74,7 +74,7 @@ = Long itemId =3D item.getId(); = - // perform the isolated update + // doAfterTransactionCompletion the isolated update s1 =3D getSessions().openSession(); t1 =3D s1.beginTransaction(); item =3D (Item) s1.get( Item.class, itemId ); --===============1101282912920652979==-- From hibernate-commits at lists.jboss.org Wed Nov 4 16:21:36 2009 Content-Type: multipart/mixed; boundary="===============1942263944274183484==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17914 - core/trunk/testsuite/src/test/java/org/hibernate/test/hql. Date: Wed, 04 Nov 2009 16:21:36 -0500 Message-ID: <200911042121.nA4LLakN009493@svn01.web.mwc.hst.phx2.redhat.com> --===============1942263944274183484== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-04 16:21:36 -0500 (Wed, 04 Nov 2009) New Revision: 17914 Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadi= ngTest.java Log: HHH-4545 - Allow o.h.action.Executable to register for either (or both) bef= ore or after transaction completion callbacks Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTPars= erLoadingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoad= ingTest.java 2009-11-04 21:19:21 UTC (rev 17913) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoad= ingTest.java 2009-11-04 21:21:36 UTC (rev 17914) @@ -527,14 +527,14 @@ assertEquals( 1, types.length ); assertTrue( types[0] instanceof ComponentType ); = - // Test the ability to doAfterTransactionCompletion comparisions between= component values + // Test the ability to perform comparisions between component values s.createQuery( "from Human h where h.name =3D h.name" ).list(); s.createQuery( "from Human h where h.name =3D :name" ).setParameter( "na= me", new Name() ).list(); s.createQuery( "from Human where name =3D :name" ).setParameter( "name",= new Name() ).list(); s.createQuery( "from Human h where :name =3D h.name" ).setParameter( "na= me", new Name() ).list(); s.createQuery( "from Human h where :name <> h.name" ).setParameter( "nam= e", new Name() ).list(); = - // Test the ability to doAfterTransactionCompletion comparisions between= a component and an explicit row-value + // Test the ability to perform comparisions between a component and an e= xplicit row-value s.createQuery( "from Human h where h.name =3D ('John', 'X', 'Doe')" ).li= st(); s.createQuery( "from Human h where ('John', 'X', 'Doe') =3D h.name" ).li= st(); s.createQuery( "from Human h where ('John', 'X', 'Doe') <> h.name" ).lis= t(); --===============1942263944274183484==-- From hibernate-commits at lists.jboss.org Wed Nov 4 17:28:47 2009 Content-Type: multipart/mixed; boundary="===============1324339894768189516==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17915 - core/trunk/documentation/manual/src/main/docbook/en-US/content. Date: Wed, 04 Nov 2009 17:28:47 -0500 Message-ID: <200911042228.nA4MSlW8025517@svn01.web.mwc.hst.phx2.redhat.com> --===============1324339894768189516== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-04 17:28:47 -0500 (Wed, 04 Nov 2009) New Revision: 17915 Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/performan= ce.xml Log: HHH-4006 - Document fetch profiles Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/pe= rformance.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/performa= nce.xml 2009-11-04 21:21:36 UTC (rev 17914) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/performa= nce.xml 2009-11-04 22:28:47 UTC (rev 17915) @@ -589,7 +589,76 @@ = - = + + + Fetch profiles + + + Another way to affect the fetching strategy for loading as= sociated objects is through something + called a fetch profile, which is a named configuration ass= ociated with the + org.hibernate.SessionFactory but enabled, by name, on the + org.hibernate.Session. Onc= e enabled on a + org.hibernate.Session, the = fetch profile wull be in affect for + that org.hibernate.Session = until it is explicitly disabled. + + + So what does that mean? Well lets explain that by way of = an example. Say we have + the following mappings: + + + + ... + + + + + + + ... + +]]> + + Now normally when you get a reference to a particular cust= omer, that customer's set of + orders will be lazy meaning we will not yet have loaded th= ose orders from the database. + Normally this is a good thing. Now lets say that you have= a certain use case where + it is more efficient to load the customer and their orders= together. One way certainly is + to use "dynamic fetching" strategies via an HQL or criteri= a queries. But another option is + to use a fetch profile to achieve that. Just add the foll= owing to your mapping: + + + ... + + + +]]> + + or even: + + + + ... + + + + + ... +]]> + + Now the following code will actually load both the custome= r and their orders: + + + + Currently only join style fetch profiles are supported, bu= t they plan is to support additional + styles. See HHH-3414 + for details. + + + Using lazy property fetching = @@ -653,7 +722,6 @@ = - = --===============1324339894768189516==-- From hibernate-commits at lists.jboss.org Wed Nov 4 18:32:27 2009 Content-Type: multipart/mixed; boundary="===============2870735962405606471==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17916 - core/trunk/documentation/manual/src/main/docbook/en-US/content. Date: Wed, 04 Nov 2009 18:32:27 -0500 Message-ID: <200911042332.nA4NWR7K002672@svn01.web.mwc.hst.phx2.redhat.com> --===============2870735962405606471== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-04 18:32:27 -0500 (Wed, 04 Nov 2009) New Revision: 17916 Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/associati= on_mapping.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_map= ping.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/batch.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/collectio= n_mapping.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/component= _mapping.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/configura= tion.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/events.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/example_m= appings.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/example_p= arentchild.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/example_w= eblog.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/filters.x= ml core/trunk/documentation/manual/src/main/docbook/en-US/content/inheritan= ce_mapping.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/performan= ce.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/persisten= t_classes.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/portabili= ty.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/query_cri= teria.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/query_hql= .xml core/trunk/documentation/manual/src/main/docbook/en-US/content/query_sql= .xml core/trunk/documentation/manual/src/main/docbook/en-US/content/session_a= pi.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/toolset_g= uide.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/transacti= ons.xml core/trunk/documentation/manual/src/main/docbook/en-US/content/tutorial.= xml core/trunk/documentation/manual/src/main/docbook/en-US/content/xml.xml Log: HHH-4000 - Utlize jhighlight hooks for rendered syntax coloration of XML an= d Java based programlisting docbook elements Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/as= sociation_mapping.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/associat= ion_mapping.xml 2009-11-04 22:28:47 UTC (rev 17915) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/associat= ion_mapping.xml 2009-11-04 23:32:27 UTC (rev 17916) @@ -65,7 +65,7 @@ common kind of unidirectional association. = - + @@ -94,7 +94,7 @@ is almost identical. The only difference is the column unique = constraint. = - + @@ -120,7 +120,7 @@ of the association: = - + @@ -149,7 +149,7 @@ is an unusual case, and is not recommended. = - + @@ -190,7 +190,7 @@ changes the multiplicity from many-to-many to one-to-many. = - + @@ -223,7 +223,7 @@ is common when the association is optional. For example: = - + @@ -257,7 +257,7 @@ but extremely unusual. = - + @@ -292,7 +292,7 @@ Finally, here is an example of a unidirectional many= -to-many association. = - + @@ -330,7 +330,7 @@ relationship. = - + @@ -362,7 +362,7 @@ update=3D"false" and insert=3D"fal= se": = - + ... = - + @@ -429,7 +429,7 @@ uses the special id generator: = - + @@ -466,7 +466,7 @@ association, on the collection, or on the join. = - + @@ -508,7 +508,7 @@ but extremely unusual. = - + @@ -553,7 +553,7 @@ Here is an example of a bidirectional many-to-many a= ssociation. = - + @@ -597,7 +597,7 @@ and effectiveStartDatecolumns, it would be = mapped as follows: = - + case when effectiveEndDate is null then 1 else 0 end @@ -611,7 +611,7 @@ the one with null effectiveEndDate, by usin= g: = - @@ -626,7 +626,7 @@ the one with the most recent startDate, cou= ld be mapped in the following way: = - + select employeeId, orgId = @@ -646,6 +646,5 @@ = = - = Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/ba= sic_mapping.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_ma= pping.xml 2009-11-04 22:28:47 UTC (rev 17915) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_ma= pping.xml 2009-11-04 23:32:27 UTC (rev 17916) @@ -48,7 +48,7 @@ Here is an example mapping: = - + @@ -166,7 +166,7 @@ The following is an example of utilizing user namespac= ing: - + = - + @@ -212,7 +212,7 @@ - clas= s element. For example: = - + @@ -317,7 +317,7 @@ - = - + select item.name, max(bid.amount), count(*) from item @@ -613,7 +613,7 @@ property to the primary key column. = - + @@ -621,7 +621,7 @@ - <param> element. = - + uid_table next_hi_value_column @@ -840,7 +840,7 @@ Where supported, the second uses an Oracle-style seque= nce. = - + hi_value next_value @@ -848,7 +848,7 @@ ]]> = - + hi_value 100 @@ -883,13 +883,13 @@ two SQL queries to insert a new object. For example: = - + person_id_sequence ]]> = - + ]]> = @@ -926,7 +926,7 @@ Hibernate does not generate DDL with triggers. It is f= or legacy schemas only. = - + socialSecurityNumber @@ -1112,7 +1112,7 @@ composite-id = - <key-many-to-one> mappings as chi= ld elements. = - + ]]> @@ -1157,7 +1157,7 @@ element are duplicated on both the persistent class and a = separate identifier class. = - + ]]> @@ -1239,7 +1239,7 @@ yes_no, true_false. = - + @@ -1247,7 +1247,7 @@ - = - ]]> = @@ -1323,7 +1323,7 @@ use long transactions. See below for = more information: = - + @@ -1333,7 +1333,7 @@ - = - + @@ -1428,7 +1428,7 @@ - = - + @@ -1527,7 +1527,7 @@ - = - = - + @@ -1728,7 +1728,7 @@ - many-to-one declaration: = - ]]> + ]]> = The property-ref attribute should only = be used for mapping legacy @@ -1885,13 +1885,13 @@ the SchemaExport tool. = - ]]> + ]]> = Then the mapping for OrderItem might us= e: = - ]]> + ]]> = This is not encouraged, however. @@ -1906,7 +1906,7 @@ If the referenced unique key is the property of a component, = you can specify a property path: = - ]]> + ]]> = = @@ -1918,7 +1918,7 @@ one-to-one element. = - + @@ -1931,7 +1931,7 @@ - Person respectively: = - ]]> - ]]> + ]]> + ]]> = Ensure that the primary keys of the related rows in the PE= RSON and @@ -2052,7 +2052,7 @@ called foreign: = - + employee @@ -2075,21 +2075,21 @@ Person, can be expressed as: = - ]]> + ]]> = This association can be made bidirectional by adding the f= ollowing to the Person mapping: = - ]]> + ]]> = = Natural-id = - + ...... @@ -2134,7 +2134,7 @@ the "Component" examples below: = - + @@ -2145,7 +2145,7 @@ - = - + @@ -2254,7 +2254,7 @@ - <propert= ies> mapping: = - + = ... @@ -2324,7 +2324,7 @@ the Person table, instead of to the pri= mary key: = - @@ -2347,14 +2347,14 @@ mapping strategy, the <subclass> = declaration is used. For example: = - + - <joined-sub= class> element. For example: = - + - = - + @@ -2530,14 +2530,14 @@ use the <union-subclass> mapping. = For example: = - + - = - + @@ -2609,7 +2609,7 @@ - = - = ... @@ -2708,7 +2708,7 @@ the primary key of the original table. It also defines the= foreign key in the joined table: = = - + @@ -2717,7 +2717,7 @@ - formula attribu= te. For example: = - ]]> = - SQL expression]]><= /programlisting> + SQL expression<= /formula>]]> = Most of the attributes on column provid= e a means of tailoring the @@ -2827,7 +2827,7 @@ conditions. = - 'MAILING' @@ -2845,14 +2845,14 @@ classes and interfaces that are not explicitly mapped: = - ]]> + ]]> = - + - ]]> @@ -2893,7 +2893,7 @@ the meta-type to class names. = - + @@ -2901,7 +2901,7 @@ ]]> = - + @@ -2910,7 +2910,7 @@ - = - + ]]> @@ -3241,7 +3241,7 @@ files. = - + 0 @@ -3259,11 +3259,11 @@ parameter values if the type is parameterized. = - + 0 ]]> = - ]]> + ]]> = It is also possible to override the parameters supplied in= a typedef on a case-by-case basis @@ -3329,7 +3329,7 @@ Server uses brackets and MySQL uses backticks. = - + <= /id> ... @@ -3355,7 +3355,7 @@ following example of the Cat class with XDo= clet mappings: = - = - simple properties. For example, if your database provides a set of data encryptio= n functions, you can invoke them for individual columns like this: - + - + ... CREATE TRIGGER my_trigger ... @@ -3619,7 +3619,7 @@ CREATE and DROP commands. This custom class must implement the org.hibernate.mapping.AuxiliaryDatabaseObject interface. - + ... @@ -3629,7 +3629,7 @@ Additionally, these database objects can be optionally scoped = so that they only apply when certain dialects are used. - + ... Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/ba= tch.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/batch.xm= l 2009-11-04 22:28:47 UTC (rev 17915) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/batch.xm= l 2009-11-04 23:32:27 UTC (rev 17916) @@ -33,7 +33,7 @@ look like this: = - = - = - = -PreparedStatement.executeU= pdate(): = -VERSIONED ke= yword after the UPDATE keyword. - = -INSERT statement execution: = - = - = - Set. = - + @@ -134,7 +134,7 @@ <map> element is representative: = - + @@ -151,7 +151,7 @@ - not-null=3D"true". = - ]]> + ]]> = The foreign key constraint can use ON DELETE CASC= ADE. = - ]]> + ]]> = See the previous chapter for a full definition of the <key> = @@ -342,12 +342,12 @@ sequential integers that are numbered from zero by default. = - + - ]]> @@ -366,13 +366,13 @@ = - + - = - + - <element> tag. For example: = - + - <many-to-many> element. = - + @@ -509,7 +509,7 @@ - = - + ]]> @@ -596,7 +596,7 @@ order-by attribute: = - @@ -607,7 +607,7 @@ An array of entities, in this case, a many-to-many association: = - @@ -619,7 +619,7 @@ A map from string indices to dates: = - @@ -632,7 +632,7 @@ A list of components (this is discussed in the next chapter): = - @@ -676,13 +676,13 @@ association. = - + - = - @@ -755,7 +755,7 @@ java.util.SortedSet. You must specify a com= parator in the mapping file: = - @@ -788,7 +788,7 @@ not in the memory. = - + @@ -812,7 +812,7 @@ filter(): = - + = = @@ -857,7 +857,7 @@ have many items and each item can be in many categories: = - + ... @@ -885,7 +885,7 @@ a many-to-many relationship in Javais created: = - inverse=3D"true". = - + .... @@ -936,7 +936,7 @@ inverse=3D"true" on the collection mapping: = - + .... @@ -965,7 +965,7 @@ inverse=3D"true". Instead, you could use th= e following mapping: = - + .... @@ -1003,13 +1003,13 @@ Map with an association as its index: = - + ]]> = - + @@ -1044,7 +1044,7 @@ (or Collection) with bag semantics. For exa= mple: = - + @@ -1099,7 +1099,7 @@ The following class has a collection of Child inst= ances: = - = - + = @@ -1147,7 +1147,7 @@ This maps to the following table definitions: = - = = @@ -1156,7 +1156,7 @@ association: = - + = @@ -1182,7 +1182,7 @@ Notice the NOT NULL constraint: = - = - + = @@ -1221,7 +1221,7 @@ association is appropriate: = - + = Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/co= mponent_mapping.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/componen= t_mapping.xml 2009-11-04 22:28:47 UTC (rev 17915) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/componen= t_mapping.xml 2009-11-04 23:32:27 UTC (rev 17916) @@ -42,7 +42,7 @@ and not to architecture-level components. For example, you ca= n model a person like this: = - = - = - + @@ -144,7 +144,7 @@ containing entity. = - + @@ -169,7 +169,7 @@ <composite-element> tag: = - + @@ -219,7 +219,7 @@ quantity are properties of the association: = - + .... @@ -242,7 +242,7 @@ = Even ternary (or quaternary, etc) associations are possible:= = - + .... @@ -315,7 +315,7 @@ the (composite) primary key of Order. = - + = @@ -340,7 +340,7 @@ to OrderLine is mapped like this: = - + @@ -362,7 +362,7 @@ uses the composite foreign key: = - + @@ -376,7 +376,7 @@ use: = - + @@ -393,7 +393,7 @@ foreign key. = - + .... .... @@ -418,7 +418,7 @@ You can also map a property of type Map: = - + Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/co= nfiguration.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/configur= ation.xml 2009-11-04 22:28:47 UTC (rev 17915) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/configur= ation.xml 2009-11-04 23:32:27 UTC (rev 17916) @@ -52,7 +52,7 @@ use addResource(). For example: = - = @@ -61,7 +61,7 @@ allow Hibernate to find the mapping document for you: = - = @@ -76,7 +76,7 @@ properties. For example: = - = - + = Hibernate does allow your application to instantiate more than= one @@ -152,7 +152,7 @@ is as simple as: = - + = Once you start a task that requires access to the database, a = JDBC connection will be obtained from @@ -1344,7 +1344,7 @@ Configuration.setNamingStrategy() before ad= ding mappings: = - CLASSPATH. Here is an example: = - + @@ -1418,13 +1418,13 @@ With the XML configuration, starting Hibernate is then as simpl= e as: = - + = You can select a different XML configuration file using: = - = @@ -1701,7 +1701,7 @@ jboss-service.xml for JBoss 4.0.x: = - + = EmptyInterceptor. = - Interceptor. = - + = A SessionFactory-scoped interceptor is regi= stered with the Configuration @@ -158,7 +158,7 @@ sessions will use this interceptor potentially concurrently. = - + = = @@ -201,7 +201,7 @@ example of a custom load event listener: = - = - + ... @@ -230,7 +230,7 @@ Instead, you can register it programmatically: = - = @@ -264,7 +264,7 @@ authorization. = - + ]]> @@ -279,7 +279,7 @@ Next, while still in hibernate.cfg.xml, bin= d the permissions to roles: = - + ]]> = Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/ex= ample_mappings.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/example_= mappings.xml 2009-11-04 22:28:47 UTC (rev 17915) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/example_= mappings.xml 2009-11-04 23:32:27 UTC (rev 17916) @@ -57,7 +57,7 @@ Here is a possible mapping document: = - + = @@ -171,7 +171,7 @@ The following mapping document correctly represents these rela= tionships: = - + = = @@ -295,7 +295,7 @@ The mapping document will look like this: = - + = @@ -389,7 +389,7 @@ = "Typed" one-to-one association - + @@ -419,7 +419,7 @@ = Composite key example - + = @@ -536,7 +536,7 @@ = Many-to-many with shared composite key attribute - + @@ -575,7 +575,7 @@ = Content based discrimination - = Associations on alternate keys - + = Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/ex= ample_parentchild.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/example_= parentchild.xml 2009-11-04 22:28:47 UTC (rev 17915) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/example_= parentchild.xml 2009-11-04 23:32:27 UTC (rev 17916) @@ -92,7 +92,7 @@ Parent to Child. = - + ]]> @@ -101,7 +101,7 @@ If we were to execute the following code: = - not-null=3D"true" in the collection mapping: = - + ]]> @@ -144,7 +144,7 @@ solution is to make the link part of the Child mapping. = - ]]> + ]]> = You also need to add the parent property to= the Child class. @@ -155,7 +155,7 @@ not to update the link. We use the inverse = attribute to do this: = - + ]]> @@ -164,7 +164,7 @@ The following code would be used to add a new Child: = - Parent. = - @@ -189,7 +189,7 @@ The code to add a Child looks like this: = - = - + ]]> @@ -214,7 +214,7 @@ This simplifies the code above to: = - @@ -224,7 +224,7 @@ The following removes p and all its childr= en from the database. = - = @@ -232,7 +232,7 @@ However, the following code: = - delete() the Child. = - cascade=3D"all-delete-orphan". = - + ]]> @@ -290,7 +290,7 @@ newChild: = - = - = - = - + @@ -159,7 +159,7 @@ = ]]> = - + @@ -213,7 +213,7 @@ we can do with these classes using Hibernate: = - <hibernate-mapping/> element: = - + ]]> = @@ -61,7 +61,7 @@ This filter can then be attached to a class: = - + ... ]]> @@ -70,7 +70,7 @@ Or, to a collection: = - + ]]> = @@ -87,7 +87,7 @@ look like this: = - + = Methods on the org.hibernate.Filter interface do allow the met= hod-chaining common to much of Hibernate. @@ -97,7 +97,7 @@ The following is a full example, using temporal data with an e= ffective record date pattern: = - + = @@ -130,7 +130,7 @@ enable the filter on the session prior to retrieving employee = data: = - = :targetSalary") .setLong("targetSalary", new Long(1000000)) @@ -157,7 +157,7 @@ allows you to definine a default condition, either as an attri= bute or CDATA: = - xyz">... + xyz">... abc=3Dxyz]]> = Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/in= heritance_mapping.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/inherita= nce_mapping.xml 2009-11-04 22:28:47 UTC (rev 17915) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/inherita= nce_mapping.xml 2009-11-04 23:32:27 UTC (rev 17916) @@ -91,7 +91,7 @@ before subclasses. = - @@ -109,7 +109,7 @@ display in the following way: = - + @@ -143,7 +143,7 @@ A table per subclass mapping looks like this: = - + @@ -187,7 +187,7 @@ <join>, as follows: = - + @@ -231,7 +231,7 @@ using the following approach: = - + @@ -258,7 +258,7 @@ <many-to-one>. = - ]]> + ]]> = = @@ -270,7 +270,7 @@ strategy. First, you can use <union-subclass>. = - + @@ -318,7 +318,7 @@ An alternative approach is to make use of implicit polymorphis= m: = - + @@ -362,7 +362,7 @@ is usually mapped using <any>. = - + @@ -383,7 +383,7 @@ queries against the Payment interface. = - + Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/pe= rformance.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/performa= nce.xml 2009-11-04 22:28:47 UTC (rev 17915) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/performa= nce.xml 2009-11-04 23:32:27 UTC (rev 17916) @@ -161,7 +161,7 @@ in an exception. For example: = - = - = - ]]> + ]]> = The fetch strategy defined in the mappi= ng document affects: @@ -264,7 +264,7 @@ Criteria query. For example: = - @@ -308,7 +308,7 @@ There are potential problems to note when extending this a= pproach to polymorphic classes.For example: = - + ...... ..... @@ -321,7 +321,7 @@ instance of DomesticCat: = - =3D=3D: = - @@ -341,7 +341,7 @@ to different proxy objects, the underlying instance will s= till be the same object: = - = @@ -363,7 +363,7 @@ implements the interface DomesticCat. For exam= ple: = = - + ...... ..... @@ -375,7 +375,7 @@ by load() or iterate(). = = - = @@ -512,14 +512,14 @@ You can use a collection filter to get the size of a colle= ction without initializing it: = - + = The createFilter() method is also used = to efficiently retrieve subsets of a collection without needing to initialize the whole co= llection: = - + = = @@ -542,7 +542,7 @@ behavior by specifying a batch-size in = the mapping of Person: = - ...]]> + ...]]> = Hibernate will now execute only three queries: the pattern= is 10, 10, 5. @@ -557,7 +557,7 @@ collections: = - + ... @@ -605,7 +605,7 @@ So what does that mean? Well lets explain that by way of = an example. Say we have the following mappings: - + ... @@ -625,7 +625,7 @@ to use "dynamic fetching" strategies via an HQL or criteri= a queries. But another option is to use a fetch profile to achieve that. Just add the foll= owing to your mapping: - + ... @@ -634,7 +634,7 @@ or even: - + ... @@ -646,7 +646,7 @@ Now the following code will actually load both the custome= r and their orders: - = - + @@ -695,7 +695,7 @@ For bytecode instrumentation, use the following Ant task: = - + @@ -823,7 +823,7 @@ - = - + .... ]]> @@ -898,7 +898,7 @@ supports locking. The built-in cache providers d= o not support locking. = - + .... @@ -1033,7 +1033,7 @@ from the first-level cache. = - = - @@ -1097,7 +1097,7 @@ API: = - = @@ -1144,7 +1144,7 @@ Query.setCacheRegion(). = - = - = - = = - = - = - Cat. For example: = - natural candidate key): = - = - + = = @@ -421,7 +421,7 @@ Maps of Maps: = - = - = - + - + Modified: entitymanager/branches/v3_3_2_GA_CP/changelog.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- entitymanager/branches/v3_3_2_GA_CP/changelog.txt 2009-11-05 05:21:01 U= TC (rev 17919) +++ entitymanager/branches/v3_3_2_GA_CP/changelog.txt 2009-11-05 05:55:19 U= TC (rev 17920) @@ -1,6 +1,12 @@ Hibernate EntityManager Changelog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +3.3.2.GA.CP01 (04-11-2009) +-------------------- = +** Bug + * [JBPAPP-1998 / HHH-4217] - Wrong exception thrown on optimistic locking= failure due to deleted entity using hibernate.jdbc.batch_versioned_data=3D= false + + 3.3.2.GA (14-03-2008) --------------------- = Modified: entitymanager/branches/v3_3_2_GA_CP/readme.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- entitymanager/branches/v3_3_2_GA_CP/readme.txt 2009-11-05 05:21:01 UTC = (rev 17919) +++ entitymanager/branches/v3_3_2_GA_CP/readme.txt 2009-11-05 05:55:19 UTC = (rev 17920) @@ -1,6 +1,6 @@ Hibernate EntityManager =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D -Version: 3.3.2.GA, 14.03.2008 +Version: 3.3.2.GA.CP01, 04.11.2009 = THIS RELEASE OF HIBERNATE ENTITYMANAGER REQUIRES HIBERNATE CORE 3.2.0.GA (= and above) = Modified: entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/Ve= rsion.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/Version.= java 2009-11-05 05:21:01 UTC (rev 17919) +++ entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/Version.= java 2009-11-05 05:55:19 UTC (rev 17920) @@ -8,7 +8,7 @@ * @author Emmanuel Bernard */ public class Version { - public static final String VERSION =3D "3.3.2.GA"; + public static final String VERSION =3D "3.3.2.GA.CP01"; private static Log log =3D LogFactory.getLog( Version.class ); = static { --===============5091235805700176237==-- From hibernate-commits at lists.jboss.org Thu Nov 5 01:02:09 2009 Content-Type: multipart/mixed; boundary="===============8530507271521455721==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17921 - core/branches/Branch_3_2_4_SP1_CP. Date: Thu, 05 Nov 2009 01:02:09 -0500 Message-ID: <200911050602.nA562949018370@svn01.web.mwc.hst.phx2.redhat.com> --===============8530507271521455721== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-05 01:02:09 -0500 (Thu, 05 Nov 2009) New Revision: 17921 Modified: core/branches/Branch_3_2_4_SP1_CP/build.xml core/branches/Branch_3_2_4_SP1_CP/changelog.txt core/branches/Branch_3_2_4_SP1_CP/readme.txt Log: JBPAPP-3039 Create new Hibernate core tag (JBOSS_EAP_3_2_4_SP1_CP09) for EA= P 4.2.0.GA CP08 / 4.3.0.GA CP07 Modified: core/branches/Branch_3_2_4_SP1_CP/build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/build.xml 2009-11-05 05:55:19 UTC (re= v 17920) +++ core/branches/Branch_3_2_4_SP1_CP/build.xml 2009-11-05 06:02:09 UTC (re= v 17921) @@ -24,7 +24,7 @@ - + Modified: core/branches/Branch_3_2_4_SP1_CP/changelog.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/changelog.txt 2009-11-05 05:55:19 UTC= (rev 17920) +++ core/branches/Branch_3_2_4_SP1_CP/changelog.txt 2009-11-05 06:02:09 UTC= (rev 17921) @@ -5,6 +5,18 @@ refer to the particular case on JIRA using the issue tracking number to le= arn more about each case. = +Changes in version 3.2.4.sp1.cp09 +------------------------------------------- + +** Bug + * [JBPAPP-1061 / HHH-4397] - Tests using sequences are run on database= s which doesn't supports sequences + * [JBPAPP-1068 / HHH-4500] - MSSQL, Oracle - Mapping inconsistency + * [JBPAPP-1998 / HHH-4217] - Wrong exception thrown on optimistic lock= ing failure due to deleted entity using hibernate.jdbc.batch_versioned_data= =3Dfalse + * [JBPAPP-2715 / HHH-4114] - Core - ASTParserLoadingTest fails due to = missing "bit_length" function + * [JBPAPP-2716 / HHH-4115] - Core - FooBarTest - "operator does not ex= ist: character varying =3D integer" + * [JBPAPP-2900 / HHH-4486] - Account for MySQL's statement + * [JBPAPP-2910 / HHH-4415] - TestCase could check for superclass of Di= alect before skipping it + Changes in version 3.2.4.sp1.cp08 ------------------------------------------- = Modified: core/branches/Branch_3_2_4_SP1_CP/readme.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/readme.txt 2009-11-05 05:55:19 UTC (r= ev 17920) +++ core/branches/Branch_3_2_4_SP1_CP/readme.txt 2009-11-05 06:02:09 UTC (r= ev 17921) @@ -1,6 +1,6 @@ Hibernate - Relational Persistence for Idiomatic Java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D -version 3.2.4.sp1.cp08 +version 3.2.4.sp1.cp09 Copyright =C2=A9 2009 Red Hat, Inc. = = --===============8530507271521455721==-- From hibernate-commits at lists.jboss.org Thu Nov 5 01:14:04 2009 Content-Type: multipart/mixed; boundary="===============7434802902113625991==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17922 - core/tags. Date: Thu, 05 Nov 2009 01:14:04 -0500 Message-ID: <200911050614.nA56E4xT021320@svn01.web.mwc.hst.phx2.redhat.com> --===============7434802902113625991== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-05 01:14:04 -0500 (Thu, 05 Nov 2009) New Revision: 17922 Added: core/tags/JBOSS_EAP_3_2_4_SP1_CP09/ Log: JBPAPP-3039 Create new Hibernate core tag (JBOSS_EAP_3_2_4_SP1_CP09) for EA= P 4.2.0.GA CP08 / 4.3.0.GA CP07 Copied: core/tags/JBOSS_EAP_3_2_4_SP1_CP09 (from rev 17921, core/branches/B= ranch_3_2_4_SP1_CP) --===============7434802902113625991==-- From hibernate-commits at lists.jboss.org Thu Nov 5 01:26:10 2009 Content-Type: multipart/mixed; boundary="===============1994802611854680444==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17923 - entitymanager/tags. Date: Thu, 05 Nov 2009 01:26:10 -0500 Message-ID: <200911050626.nA56QAFh023849@svn01.web.mwc.hst.phx2.redhat.com> --===============1994802611854680444== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-05 01:26:10 -0500 (Thu, 05 Nov 2009) New Revision: 17923 Added: entitymanager/tags/v3_3_2_GA_CP01/ Log: JBPAPP-3040 Create new Hibernate Entity Manager tag (v3_3_2_GA_CP01) for EA= P 4.2.0.GA CP08 / 4.3.0.GA CP07 Copied: entitymanager/tags/v3_3_2_GA_CP01 (from rev 17922, entitymanager/br= anches/v3_3_2_GA_CP) --===============1994802611854680444==-- From hibernate-commits at lists.jboss.org Thu Nov 5 01:45:42 2009 Content-Type: multipart/mixed; boundary="===============1618074186397654506==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17924 - core/tags. Date: Thu, 05 Nov 2009 01:45:41 -0500 Message-ID: <200911050645.nA56jfDF028171@svn01.web.mwc.hst.phx2.redhat.com> --===============1618074186397654506== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-05 01:45:41 -0500 (Thu, 05 Nov 2009) New Revision: 17924 Removed: core/tags/JBOSS_EAP_3_2_4_SP1_CP09/ Log: will recreate later --===============1618074186397654506==-- From hibernate-commits at lists.jboss.org Thu Nov 5 01:46:27 2009 Content-Type: multipart/mixed; boundary="===============7379109445857792866==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17925 - in core/branches/Branch_3_2_4_SP1_CP: src/org/hibernate/cfg and 1 other directory. Date: Thu, 05 Nov 2009 01:46:27 -0500 Message-ID: <200911050646.nA56kRmL028299@svn01.web.mwc.hst.phx2.redhat.com> --===============7379109445857792866== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-05 01:46:27 -0500 (Thu, 05 Nov 2009) New Revision: 17925 Modified: core/branches/Branch_3_2_4_SP1_CP/lib/version-dist.properties core/branches/Branch_3_2_4_SP1_CP/lib/version.properties core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cfg/Environment.java Log: JBPAPP-3039 Create new Hibernate core tag (JBOSS_EAP_3_2_4_SP1_CP09) for EA= P 4.2.0.GA CP08 / 4.3.0.GA CP07 Modified: core/branches/Branch_3_2_4_SP1_CP/lib/version-dist.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/lib/version-dist.properties 2009-11-0= 5 06:45:41 UTC (rev 17924) +++ core/branches/Branch_3_2_4_SP1_CP/lib/version-dist.properties 2009-11-0= 5 06:46:27 UTC (rev 17925) @@ -1,6 +1,6 @@ hibernate.lib=3Dhibernate3.jar hibernate.ignorecheck=3Dtrue -hibernate.version=3D3.2.4.SP1_CP08-brew +hibernate.version=3D3.2.4.SP1_CP09-brew hibernate.name=3DHibernate core hibernate.when=3Druntime, required = Modified: core/branches/Branch_3_2_4_SP1_CP/lib/version.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/lib/version.properties 2009-11-05 06:= 45:41 UTC (rev 17924) +++ core/branches/Branch_3_2_4_SP1_CP/lib/version.properties 2009-11-05 06:= 46:27 UTC (rev 17925) @@ -39,7 +39,7 @@ cleanimports.name=3Dcleanimports cleanimports.when=3Dbuildtime = -hibernate.version=3D3.2.4.SP1_CP08-brew +hibernate.version=3D3.2.4.SP1_CP09-brew hibernate.name=3DHibernate core hibernate.when=3Druntime, required = Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cfg/Environme= nt.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cfg/Environment.jav= a 2009-11-05 06:45:41 UTC (rev 17924) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cfg/Environment.jav= a 2009-11-05 06:46:27 UTC (rev 17925) @@ -153,7 +153,7 @@ */ public final class Environment { = - public static final String VERSION =3D "3.2.4.sp1.cp08"; + public static final String VERSION =3D "3.2.4.sp1.cp09"; = /** * ConnectionProvider implementor to use when obtaining connecti= ons --===============7379109445857792866==-- From hibernate-commits at lists.jboss.org Thu Nov 5 01:47:50 2009 Content-Type: multipart/mixed; boundary="===============7784923294084838505==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17926 - core/tags. Date: Thu, 05 Nov 2009 01:47:50 -0500 Message-ID: <200911050647.nA56logk028443@svn01.web.mwc.hst.phx2.redhat.com> --===============7784923294084838505== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-05 01:47:50 -0500 (Thu, 05 Nov 2009) New Revision: 17926 Added: core/tags/JBOSS_EAP_3_2_4_SP1_CP09/ Log: JBPAPP-3039 Create new Hibernate core tag (JBOSS_EAP_3_2_4_SP1_CP09) for EA= P 4.2.0.GA CP08 / 4.3.0.GA CP07 Copied: core/tags/JBOSS_EAP_3_2_4_SP1_CP09 (from rev 17925, core/branches/B= ranch_3_2_4_SP1_CP) --===============7784923294084838505==-- From hibernate-commits at lists.jboss.org Thu Nov 5 04:51:53 2009 Content-Type: multipart/mixed; boundary="===============8056249041656194741==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17927 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validator/engine/messageinterpolation and 1 other directory. Date: Thu, 05 Nov 2009 04:51:52 -0500 Message-ID: <200911050951.nA59pqat022047@svn01.web.mwc.hst.phx2.redhat.com> --===============8056249041656194741== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-05 04:51:52 -0500 (Thu, 05 Nov 2009) New Revision: 17927 Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/engine/messageinterpolation/MessageInterpolationWithDefaultBundleTest.java validator/trunk/hibernate-validator/src/test/java/org/hibernate/validato= r/engine/messageinterpolation/User.java Modified: validator/trunk/hibernate-validator/src/main/resources/org/hibernate/val= idator/ValidationMessages.properties validator/trunk/hibernate-validator/src/main/resources/org/hibernate/val= idator/ValidationMessages_de.properties validator/trunk/hibernate-validator/src/main/resources/org/hibernate/val= idator/ValidationMessages_fr.properties Log: HV-268 Fixed resource template messages Modified: validator/trunk/hibernate-validator/src/main/resources/org/hibern= ate/validator/ValidationMessages.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/main/resources/org/hibernate/va= lidator/ValidationMessages.properties 2009-11-05 06:47:50 UTC (rev 17926) +++ validator/trunk/hibernate-validator/src/main/resources/org/hibernate/va= lidator/ValidationMessages.properties 2009-11-05 09:51:52 UTC (rev 17927) @@ -12,8 +12,8 @@ javax.validation.constraints.Past.message=3Dmust be in the past javax.validation.constraints.Pattern.message=3Dmust match "{regexp}" javax.validation.constraints.Size.message=3Dsize must be between {min} and= {max} -org.hibernate.validator.constraints.Email.message=3D"{value}" is not a val= id email address +org.hibernate.validator.constraints.Email.message=3Dnot a well-formed emai= l address org.hibernate.validator.constraints.Length.message=3Dlength must be betwee= n {min} and {max} org.hibernate.validator.constraints.NotEmpty.message=3Dmay not be empty -org.hibernate.validator.constraints.Range.message=3D{value} must be betwee= n {min} and {max} +org.hibernate.validator.constraints.Range.message=3Dmust be between {min} = and {max} = Modified: validator/trunk/hibernate-validator/src/main/resources/org/hibern= ate/validator/ValidationMessages_de.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/main/resources/org/hibernate/va= lidator/ValidationMessages_de.properties 2009-11-05 06:47:50 UTC (rev 17926) +++ validator/trunk/hibernate-validator/src/main/resources/org/hibernate/va= lidator/ValidationMessages_de.properties 2009-11-05 09:51:52 UTC (rev 17927) @@ -14,5 +14,5 @@ javax.validation.constraints.Digits.message=3Dnumerischer Wert au\u00DFerh= alb erlaubten Wertebereichs (<{integer} Ziffern>.<{fraction} Ziffern> erwar= ted) javax.validation.constraints.DecimalMin.message=3Dmuss gr\u00F6ssergleich = {value} sein javax.validation.constraints.DecimalMax.message=3Dmuss kleinergleich {valu= e} sein -org.hibernate.validator.constraints.Email.message=3D"{value}" ist keine g\= u00FCltige E-Mail-Adresse -org.hibernate.validator.constraints.Range.message=3D{value} muss zwischen = {min} und {max} liegen \ No newline at end of file +org.hibernate.validator.constraints.Email.message=3Dkeine g\u00FCltige E-M= ail-Adresse +org.hibernate.validator.constraints.Range.message=3Dmuss zwischen {min} un= d {max} liegen \ No newline at end of file Modified: validator/trunk/hibernate-validator/src/main/resources/org/hibern= ate/validator/ValidationMessages_fr.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/main/resources/org/hibernate/va= lidator/ValidationMessages_fr.properties 2009-11-05 06:47:50 UTC (rev 17926) +++ validator/trunk/hibernate-validator/src/main/resources/org/hibernate/va= lidator/ValidationMessages_fr.properties 2009-11-05 09:51:52 UTC (rev 17927) @@ -14,5 +14,5 @@ javax.validation.constraints.Digits.message=3DValeur num\u00E9rique hors l= imite (<{integer} chiffres>.<{fraction} chiffres> attendus) javax.validation.constraints.DecimalMin.message=3Ddoit \u00EAtre plus gran= d que {value} javax.validation.constraints.DecimalMax.message=3Ddoit \u00EAtre plus peti= t que {value} -org.hibernate.validator.constraints.Email.message=3DAddress email "{value}= " mal form=EF=BF=BDe -org.hibernate.validator.constraints.Range.message=3D{value} doit =EF=BF=BD= tre entre {min} et {max} \ No newline at end of file +org.hibernate.validator.constraints.Email.message=3DAddress email mal form= \u00E9e +org.hibernate.validator.constraints.Range.message=3Ddoit \u00EAtre entre {= min} et {max} \ No newline at end of file Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/engine/messageinterpolation/MessageInterpolationWithDefaultBundleTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/engine/messageinterpolation/MessageInterpolationWithDefaultBundleTest.ja= va (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/engine/messageinterpolation/MessageInterpolationWithDefaultBundleTest.ja= va 2009-11-05 09:51:52 UTC (rev 17927) @@ -0,0 +1,109 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.engine.messageinterpolation; + +import java.util.Locale; +import java.util.Set; +import javax.validation.Configuration; +import javax.validation.ConstraintViolation; +import javax.validation.Validator; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import org.hibernate.validator.engine.ResourceBundleMessageInterpolator; +import org.hibernate.validator.util.TestUtil; +import static org.hibernate.validator.util.TestUtil.assertCorrectConstrain= tViolationMessages; +import static org.hibernate.validator.util.TestUtil.assertNumberOfViolatio= ns; + +/** + * @author Hardy Ferentschik + */ +public class MessageInterpolationWithDefaultBundleTest { + private Locale defaultLocale; + + @BeforeClass + public void storeDefaultLocale() { + defaultLocale =3D Locale.getDefault(); + } + + @AfterClass + public void restoreDefaultLocale() { + Locale.setDefault( defaultLocale ); + } + + /** + * HV-268 + */ + @Test + public void testEmailAndRangeMessageEnglishLocale() { + Locale.setDefault( Locale.ENGLISH ); + Configuration config =3D TestUtil.getConfiguration(); + config.messageInterpolator( new ResourceBundleMessageInterpolator() ); + Validator validator =3D config.buildValidatorFactory().getValidator(); + User user =3D new User(); + user.setEmail( "foo" ); + user.setAge( 16 ); + Set> constraintViolations =3D validator.valida= te( user ); + assertNumberOfViolations( constraintViolations, 2 ); + assertCorrectConstraintViolationMessages( + constraintViolations, "not a well-formed email address", "must be betw= een 18 and 21" + ); + } + + /** + * HV-268 + */ + @Test + public void testEmailAndRangeMessageGermanLocale() { + Locale.setDefault( Locale.GERMAN ); + Configuration config =3D TestUtil.getConfiguration(); + config.messageInterpolator( new ResourceBundleMessageInterpolator() ); + Validator validator =3D config.buildValidatorFactory().getValidator(); + User user =3D new User(); + user.setEmail( "foo" ); + user.setAge( 16 ); + Set> constraintViolations =3D validator.valida= te( user ); + assertNumberOfViolations( constraintViolations, 2 ); + assertCorrectConstraintViolationMessages( + constraintViolations, "keine g\u00FCltige E-Mail-Adresse", "muss zwisc= hen 18 und 21 liegen" + ); + } + + /** + * HV-268 + */ + @Test + public void testEmailAndRangeMessageFrenchLocale() { + Locale.setDefault( Locale.FRENCH ); + Configuration config =3D TestUtil.getConfiguration(); + config.messageInterpolator( new ResourceBundleMessageInterpolator() ); + Validator validator =3D config.buildValidatorFactory().getValidator(); + User user =3D new User(); + user.setEmail( "foo" ); + user.setAge( 16 ); + Set> constraintViolations =3D validator.valida= te( user ); + assertNumberOfViolations( constraintViolations, 2 ); + assertCorrectConstraintViolationMessages( + constraintViolations, "Address email mal form\u00E9e", "doit \u00EAtre= entre 18 et 21" + ); + } +} + + Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/vali= dator/engine/messageinterpolation/User.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/engine/messageinterpolation/User.java (rev 0) +++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validat= or/engine/messageinterpolation/User.java 2009-11-05 09:51:52 UTC (rev 17927) @@ -0,0 +1,50 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.engine.messageinterpolation; + +import org.hibernate.validator.constraints.Email; +import org.hibernate.validator.constraints.Range; + +/** + * @author Hardy Ferentschik + */ +public class User { + @Email + private String email; + + @Range(min =3D 18, max =3D 21) + private int age; + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age =3D age; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email =3D email; + } +} + + --===============8056249041656194741==-- From hibernate-commits at lists.jboss.org Thu Nov 5 07:04:27 2009 Content-Type: multipart/mixed; boundary="===============1691082988896116448==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17928 - in annotations/branches/v3_3_1_GA_CP: doc/reference/en and 1 other directories. Date: Thu, 05 Nov 2009 07:04:27 -0500 Message-ID: <200911051204.nA5C4RKx017249@svn01.web.mwc.hst.phx2.redhat.com> --===============1691082988896116448== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-05 07:04:26 -0500 (Thu, 05 Nov 2009) New Revision: 17928 Modified: annotations/branches/v3_3_1_GA_CP/build.xml annotations/branches/v3_3_1_GA_CP/changelog.txt annotations/branches/v3_3_1_GA_CP/doc/reference/en/master.xml annotations/branches/v3_3_1_GA_CP/readme.txt annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations= /Version.java Log: JBPAPP-3065 update annotations's version to 3.3.1.GA.CP02 Modified: annotations/branches/v3_3_1_GA_CP/build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_3_1_GA_CP/build.xml 2009-11-05 09:51:52 UTC (re= v 17927) +++ annotations/branches/v3_3_1_GA_CP/build.xml 2009-11-05 12:04:26 UTC (re= v 17928) @@ -17,7 +17,7 @@ - + Modified: annotations/branches/v3_3_1_GA_CP/changelog.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_3_1_GA_CP/changelog.txt 2009-11-05 09:51:52 UTC= (rev 17927) +++ annotations/branches/v3_3_1_GA_CP/changelog.txt 2009-11-05 12:04:26 UTC= (rev 17928) @@ -1,6 +1,19 @@ Hibernate Annotations Changelog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D = +3.3.1.GA.CP02 +--------------------- + +** Bug + * [JBPAPP-1061 / ANN-764] - Tests using sequences are run on databases wh= ich doesn't supports sequences + * [JBPAPP-1068 / HHH-4500] - Annotations - MSSQL, Oracle - Mapping incons= istency + * [JBPAPP-1125 / HHH-4397] - ANN - Oracle - Dialect does not support iden= tity key generation + * [JBPAPP-1587] - Sybase - Annotations - unit tests using LOBs fail + * [JBPAPP-1679] - Modify Annotations, Entity Manager, and Search to work = with the same property settings as Core + * [JBPAPP-2901 / HHH-4415] - TestCase could check for superclass of Diale= ct before skipping it + * [JBPAPP-3058] - Annotations - JoinColumnOverrideTest fails due to "coul= d not instantiate id generator" + * [JBPAPP-3060 / ANN-748] - @JoinColumn overrides scale and percision in = ManyToOne map.. + 3.3.1.GA.CP01 --------------------- = Modified: annotations/branches/v3_3_1_GA_CP/doc/reference/en/master.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_3_1_GA_CP/doc/reference/en/master.xml 2009-11-0= 5 09:51:52 UTC (rev 17927) +++ annotations/branches/v3_3_1_GA_CP/doc/reference/en/master.xml 2009-11-0= 5 12:04:26 UTC (rev 17928) @@ -12,7 +12,7 @@ = Reference Guide = - 3.3.1.GA.CP01 + 3.3.1.GA.CP02 = Modified: annotations/branches/v3_3_1_GA_CP/readme.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_3_1_GA_CP/readme.txt 2009-11-05 09:51:52 UTC (r= ev 17927) +++ annotations/branches/v3_3_1_GA_CP/readme.txt 2009-11-05 12:04:26 UTC (r= ev 17928) @@ -1,6 +1,6 @@ Hibernate Annotations =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D -Version: 3.3.1.GA.CP01 +Version: 3.3.1.GA.CP02 = THIS RELEASE OF HIBERNATE ANNOTATIONS REQUIRES HIBERNATE CORE 3.2.0.GA (an= d above) = Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/anno= tations/Version.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotation= s/Version.java 2009-11-05 09:51:52 UTC (rev 17927) +++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotation= s/Version.java 2009-11-05 12:04:26 UTC (rev 17928) @@ -8,7 +8,7 @@ * @author Emmanuel Bernard */ public class Version { - public static final String VERSION =3D "3.3.1.GA.CP01"; + public static final String VERSION =3D "3.3.1.GA.CP02"; private static Log log =3D LogFactory.getLog( Version.class ); = static { --===============1691082988896116448==-- From hibernate-commits at lists.jboss.org Thu Nov 5 07:06:31 2009 Content-Type: multipart/mixed; boundary="===============6000021256100481290==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17929 - annotations/tags. Date: Thu, 05 Nov 2009 07:06:31 -0500 Message-ID: <200911051206.nA5C6V9s017782@svn01.web.mwc.hst.phx2.redhat.com> --===============6000021256100481290== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-05 07:06:31 -0500 (Thu, 05 Nov 2009) New Revision: 17929 Added: annotations/tags/3_3_1_GA_CP02/ Log: JBPAPP-3065 Create new Hibernate annotations tag (3_3_1_GA_CP02) for EAP 4.= 2.0.GA CP08 / 4.3.0.GA CP07 Copied: annotations/tags/3_3_1_GA_CP02 (from rev 17928, annotations/branche= s/v3_3_1_GA_CP) --===============6000021256100481290==-- From hibernate-commits at lists.jboss.org Thu Nov 5 09:01:33 2009 Content-Type: multipart/mixed; boundary="===============0927126616095421254==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17930 - search/trunk/src/test/java/org/hibernate/search/test/configuration. Date: Thu, 05 Nov 2009 09:01:33 -0500 Message-ID: <200911051401.nA5E1XK8007819@svn01.web.mwc.hst.phx2.redhat.com> --===============0927126616095421254== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: sannegrinovero Date: 2009-11-05 09:01:32 -0500 (Thu, 05 Nov 2009) New Revision: 17930 Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/Shard= sConfigurationTest.java Log: HSEARCH-201 (IndexWriter settings meant for transactional operations won't = be inherited by the settings meant for batch operations) missing testcase Modified: search/trunk/src/test/java/org/hibernate/search/test/configuratio= n/ShardsConfigurationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/configuration/Shar= dsConfigurationTest.java 2009-11-05 12:06:31 UTC (rev 17929) +++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Shar= dsConfigurationTest.java 2009-11-05 14:01:32 UTC (rev 17930) @@ -90,6 +90,7 @@ assertTrue( docDirProviders[0] instanceof RAMDirectoryProvider ); assertTrue( docDirProviders[1] instanceof FSDirectoryProvider ); assertTrue( docDirProviders[2] instanceof RAMDirectoryProvider ); + assertValueIsSet( Document.class, 0, BATCH, MAX_BUFFERED_DOCS, 4 ); } = public void testShardN2UsesDefaults() throws Exception { @@ -99,7 +100,7 @@ assertValueIsDefault( Document.class, 2, TRANSACTION, RAM_BUFFER_SIZE ); assertValueIsSet( Document.class, 2, BATCH, MAX_BUFFERED_DOCS, 4 ); assertValueIsSet( Document.class, 2, BATCH, MAX_MERGE_DOCS, 5 ); - assertValueIsSet( Document.class, 2, BATCH, MERGE_FACTOR, 100 ); + assertValueIsDefault( Document.class, 2, BATCH, MERGE_FACTOR ); assertValueIsDefault( Document.class, 2, BATCH, RAM_BUFFER_SIZE ); } = @@ -108,11 +109,6 @@ assertValueIsSet( Document.class, 1, BATCH, MAX_MERGE_DOCS, 11 ); } = - public void testShard_BatchInheritedFromTransaction() throws Exception { - assertValueIsSet( Document.class, 1, BATCH, TERM_INDEX_INTERVAL, 12 ); - assertValueIsSet( Document.class, 0, BATCH, MAX_BUFFERED_DOCS, 4 ); - } - = protected Class[] getMappings() { return new Class[] { Book.class, --===============0927126616095421254==-- From hibernate-commits at lists.jboss.org Thu Nov 5 13:51:36 2009 Content-Type: multipart/mixed; boundary="===============8273801287932580077==" MIME-Version: 1.0 From: UPS Service To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] UPS Delivery Problem Date: Fri, 06 Nov 2009 07:49:58 +1200 Message-ID: <000d01ca5e48$c5d86570$6400a8c0@stylisticz542> --===============8273801287932580077== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Dear customer! Unfortunately we were not able to deliver the postal package which was sent= on the 20th of June in time because the addressee's address is incorrect. Please print out the invoice copy attached and collect the package at our o= ffice. United Parcel Service of America. --===============8273801287932580077==-- From hibernate-commits at lists.jboss.org Thu Nov 5 14:56:14 2009 Content-Type: multipart/mixed; boundary="===============6613039970103432025==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17931 - core/branches/gradle/buildSrc. Date: Thu, 05 Nov 2009 14:56:13 -0500 Message-ID: <200911051956.nA5JuDAJ022971@svn01.web.mwc.hst.phx2.redhat.com> --===============6613039970103432025== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-05 14:56:13 -0500 (Thu, 05 Nov 2009) New Revision: 17931 Modified: core/branches/gradle/buildSrc/ Log: svn ignores Property changes on: core/branches/gradle/buildSrc ___________________________________________________________________ Name: svn:ignore - .gradle build target + .gradle target local *.ipr *.iws *.iml .classpath .project .nbattrs *.log *.properties .clover .* --===============6613039970103432025==-- From hibernate-commits at lists.jboss.org Thu Nov 5 14:59:34 2009 Content-Type: multipart/mixed; boundary="===============4446605621105779614==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17932 - core/branches/gradle/buildSrc. Date: Thu, 05 Nov 2009 14:59:33 -0500 Message-ID: <200911051959.nA5JxXW2023307@svn01.web.mwc.hst.phx2.redhat.com> --===============4446605621105779614== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-05 14:59:33 -0500 (Thu, 05 Nov 2009) New Revision: 17932 Modified: core/branches/gradle/buildSrc/ Log: svn ignores Property changes on: core/branches/gradle/buildSrc ___________________________________________________________________ Name: svn:ignore - .gradle target local *.ipr *.iws *.iml .classpath .project .nbattrs *.log *.properties .clover .* + .gradle target build local *.ipr *.iws *.iml .classpath .project .nbattrs *.log *.properties .clover .* --===============4446605621105779614==-- From hibernate-commits at lists.jboss.org Thu Nov 5 15:00:52 2009 Content-Type: multipart/mixed; boundary="===============7831388368231381433==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17933 - core/branches/gradle/hibernate-infinispan. Date: Thu, 05 Nov 2009 15:00:52 -0500 Message-ID: <200911052000.nA5K0q1M023836@svn01.web.mwc.hst.phx2.redhat.com> --===============7831388368231381433== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-05 15:00:52 -0500 (Thu, 05 Nov 2009) New Revision: 17933 Modified: core/branches/gradle/hibernate-infinispan/ Log: svn ignores Property changes on: core/branches/gradle/hibernate-infinispan ___________________________________________________________________ Name: svn:ignore - target .project .classpath .settings + .gradle target build local *.ipr *.iws *.iml .classpath .project .nbattrs *.log *.properties .clover .* --===============7831388368231381433==-- From hibernate-commits at lists.jboss.org Thu Nov 5 16:50:47 2009 Content-Type: multipart/mixed; boundary="===============5387847514267361969==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17934 - in core/branches/Branch_3_3: distribution/src/assembly and 1 other directory. Date: Thu, 05 Nov 2009 16:50:47 -0500 Message-ID: <200911052150.nA5LolcM014014@svn01.web.mwc.hst.phx2.redhat.com> --===============5387847514267361969== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-05 16:50:47 -0500 (Thu, 05 Nov 2009) New Revision: 17934 Modified: core/branches/Branch_3_3/core/pom.xml core/branches/Branch_3_3/distribution/src/assembly/dist.xml Log: HHH-4548 - Alter poms to not use javax.* artifacts under Sun proprietary li= cense Modified: core/branches/Branch_3_3/core/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/core/pom.xml 2009-11-05 20:00:52 UTC (rev 1793= 3) +++ core/branches/Branch_3_3/core/pom.xml 2009-11-05 21:50:47 UTC (rev 1793= 4) @@ -44,23 +44,17 @@ = - javax.transaction - jta - 1.1 + org.jboss.javaee + jboss-transaction-api + 1.0.1.GA - javax.security - jaas - 1.0.01 + org.jboss.javaee + jboss-jacc-api + 1.1.0.GA provided - javax.security - jacc - 1.0 - provided - - ant ant 1.6.5 Modified: core/branches/Branch_3_3/distribution/src/assembly/dist.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/distribution/src/assembly/dist.xml 2009-11-05 = 20:00:52 UTC (rev 17933) +++ core/branches/Branch_3_3/distribution/src/assembly/dist.xml 2009-11-05 = 21:50:47 UTC (rev 17934) @@ -66,6 +66,7 @@ = + lib/required antlr:antlr @@ -77,9 +78,16 @@ javassist:javassist = org.slf4j:slf4j-api + + = - javax.transaction:jta + + + lib/required + + org.jboss.javaee:jboss-transaction-api + jta-1.1.jar = --===============5387847514267361969==-- From hibernate-commits at lists.jboss.org Thu Nov 5 16:51:20 2009 Content-Type: multipart/mixed; boundary="===============7584201503231607779==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17935 - in core/trunk: distribution/src/assembly and 1 other directory. Date: Thu, 05 Nov 2009 16:51:20 -0500 Message-ID: <200911052151.nA5LpKuf014103@svn01.web.mwc.hst.phx2.redhat.com> --===============7584201503231607779== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-05 16:51:19 -0500 (Thu, 05 Nov 2009) New Revision: 17935 Modified: core/trunk/core/pom.xml core/trunk/distribution/src/assembly/dist.xml Log: HHH-4548 - Alter poms to not use javax.* artifacts under Sun proprietary li= cense Modified: core/trunk/core/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/pom.xml 2009-11-05 21:50:47 UTC (rev 17934) +++ core/trunk/core/pom.xml 2009-11-05 21:51:19 UTC (rev 17935) @@ -44,23 +44,17 @@ = - javax.transaction - jta - 1.1 + org.jboss.javaee + jboss-transaction-api + 1.0.1.GA - javax.security - jaas - 1.0.01 + org.jboss.javaee + jboss-jacc-api + 1.1.0.GA provided - javax.security - jacc - 1.0 - provided - - ant ant 1.6.5 Modified: core/trunk/distribution/src/assembly/dist.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/distribution/src/assembly/dist.xml 2009-11-05 21:50:47 UTC (= rev 17934) +++ core/trunk/distribution/src/assembly/dist.xml 2009-11-05 21:51:19 UTC (= rev 17935) @@ -66,6 +66,7 @@ = + lib/required antlr:antlr @@ -77,9 +78,16 @@ javassist:javassist = org.slf4j:slf4j-api + + = - javax.transaction:jta + + + lib/required + + org.jboss.javaee:jboss-transaction-api + jta-1.1.jar = --===============7584201503231607779==-- From hibernate-commits at lists.jboss.org Fri Nov 6 00:25:39 2009 Content-Type: multipart/mixed; boundary="===============0491370330602481214==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17936 - core/trunk/core. Date: Fri, 06 Nov 2009 00:25:39 -0500 Message-ID: <200911060525.nA65Pdtq007950@svn01.web.mwc.hst.phx2.redhat.com> --===============0491370330602481214== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-06 00:25:38 -0500 (Fri, 06 Nov 2009) New Revision: 17936 Modified: core/trunk/core/pom.xml Log: HHH-4548 - Alter poms to not use javax.* artifacts under Sun proprietary li= cense Modified: core/trunk/core/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/pom.xml 2009-11-05 21:51:19 UTC (rev 17935) +++ core/trunk/core/pom.xml 2009-11-06 05:25:38 UTC (rev 17936) @@ -47,12 +47,40 @@ org.jboss.javaee jboss-transaction-api 1.0.1.GA + + + org.jboss.javaee + jboss-servlet-api + + + org.jboss.logging + jboss-logging-spi + + + org.jboss + jboss-common-core + + org.jboss.javaee jboss-jacc-api 1.1.0.GA provided + + + org.jboss.javaee + jboss-servlet-api + + + org.jboss.logging + jboss-logging-spi + + + org.jboss + jboss-common-core + + ant --===============0491370330602481214==-- From hibernate-commits at lists.jboss.org Fri Nov 6 00:30:56 2009 Content-Type: multipart/mixed; boundary="===============5066992557135595730==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17937 - core/branches/Branch_3_3/core. Date: Fri, 06 Nov 2009 00:30:56 -0500 Message-ID: <200911060530.nA65Uusb008941@svn01.web.mwc.hst.phx2.redhat.com> --===============5066992557135595730== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-06 00:30:56 -0500 (Fri, 06 Nov 2009) New Revision: 17937 Modified: core/branches/Branch_3_3/core/pom.xml Log: HHH-4548 - Alter poms to not use javax.* artifacts under Sun proprietary li= cense Modified: core/branches/Branch_3_3/core/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/core/pom.xml 2009-11-06 05:25:38 UTC (rev 1793= 6) +++ core/branches/Branch_3_3/core/pom.xml 2009-11-06 05:30:56 UTC (rev 1793= 7) @@ -47,12 +47,40 @@ org.jboss.javaee jboss-transaction-api 1.0.1.GA + + + org.jboss.javaee + jboss-servlet-api + + + org.jboss.logging + jboss-logging-spi + + + org.jboss + jboss-common-core + + org.jboss.javaee jboss-jacc-api 1.1.0.GA provided + + + org.jboss.javaee + jboss-servlet-api + + + org.jboss.logging + jboss-logging-spi + + + org.jboss + jboss-common-core + + ant --===============5066992557135595730==-- From hibernate-commits at lists.jboss.org Fri Nov 6 02:16:34 2009 Content-Type: multipart/mixed; boundary="===============0960943560168198598==" MIME-Version: 1.0 From: UPS Service To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] UPS Delivery Problem Date: Fri, 06 Nov 2009 15:16:32 +0800 Message-ID: <000d01ca5eb1$10f64dc0$6400a8c0@maimswrz> --===============0960943560168198598== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Dear customer! Unfortunately we were not able to deliver the postal package which was sent= on the 20th of June in time because the addressee's address is incorrect. Please print out the invoice copy attached and collect the package at our o= ffice. United Parcel Service of America. --===============0960943560168198598==-- From hibernate-commits at lists.jboss.org Fri Nov 6 05:09:37 2009 Content-Type: multipart/mixed; boundary="===============0197291480800397866==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17938 - search/trunk. Date: Fri, 06 Nov 2009 05:09:36 -0500 Message-ID: <200911061009.nA6A9aYa028517@svn01.web.mwc.hst.phx2.redhat.com> --===============0197291480800397866== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jcosta(a)redhat.com Date: 2009-11-06 05:09:36 -0500 (Fri, 06 Nov 2009) New Revision: 17938 Modified: search/trunk/pom.xml Log: HSEARCH-346 - Updated MSSQL JDBC driver version Modified: search/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/pom.xml 2009-11-06 05:30:56 UTC (rev 17937) +++ search/trunk/pom.xml 2009-11-06 10:09:36 UTC (rev 17938) @@ -649,7 +649,7 @@ com.microsoft.sqlserver msjdbc - 1.1 + 2.0.1008.2 @@ -669,7 +669,7 @@ com.microsoft.sqlserver msjdbc - 1.1 + 2.0.1008.2 --===============0197291480800397866==-- From hibernate-commits at lists.jboss.org Fri Nov 6 06:02:37 2009 Content-Type: multipart/mixed; boundary="===============1976017993841283602==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17939 - in validator/trunk/hibernate-validator: src/main/docbook/en-US and 1 other directory. Date: Fri, 06 Nov 2009 06:02:37 -0500 Message-ID: <200911061102.nA6B2bSX005855@svn01.web.mwc.hst.phx2.redhat.com> --===============1976017993841283602== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-06 06:02:36 -0500 (Fri, 06 Nov 2009) New Revision: 17939 Modified: validator/trunk/hibernate-validator/readme.txt validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml Log: updates for 4.0.2 release Modified: validator/trunk/hibernate-validator/readme.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/readme.txt 2009-11-06 10:09:36 UTC = (rev 17938) +++ validator/trunk/hibernate-validator/readme.txt 2009-11-06 11:02:36 UTC = (rev 17939) @@ -31,7 +31,7 @@ ------------- = The full list of changes can be found at - http://opensource.atlassian.com/projects/hibernate/secure/ReleaseNote.js= pa?projectId=3D10060&version=3D10971 + http://opensource.atlassian.com/projects/hibernate/secure/ReleaseNote.js= pa?projectId=3D10060&version=3D10982 = System Requirements ------------------- Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/master= .xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2= 009-11-06 10:09:36 UTC (rev 17938) +++ validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2= 009-11-06 11:02:36 UTC (rev 17939) @@ -25,7 +25,7 @@ --> + ]> --===============1976017993841283602==-- From hibernate-commits at lists.jboss.org Fri Nov 6 06:11:08 2009 Content-Type: multipart/mixed; boundary="===============3273205217766407514==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17940 - in validator/trunk: hibernate-validator and 3 other directories. Date: Fri, 06 Nov 2009 06:11:08 -0500 Message-ID: <200911061111.nA6BB82P008215@svn01.web.mwc.hst.phx2.redhat.com> --===============3273205217766407514== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-06 06:11:07 -0500 (Fri, 06 Nov 2009) New Revision: 17940 Modified: validator/trunk/hibernate-validator-archetype/pom.xml validator/trunk/hibernate-validator-legacy/pom.xml validator/trunk/hibernate-validator-tck-runner/pom.xml validator/trunk/hibernate-validator/pom.xml validator/trunk/pom.xml Log: [maven-release-plugin] prepare release v4_0_2_GA Modified: validator/trunk/hibernate-validator/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/pom.xml 2009-11-06 11:02:36 UTC (re= v 17939) +++ validator/trunk/hibernate-validator/pom.xml 2009-11-06 11:11:07 UTC (re= v 17940) @@ -2,7 +2,7 @@ hibernate-validator-parent org.hibernate - 4.0.2-SNAPSHOT + 4.0.2.GA ../pom.xml 4.0.0 Modified: validator/trunk/hibernate-validator-archetype/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-archetype/pom.xml 2009-11-06 11:02:= 36 UTC (rev 17939) +++ validator/trunk/hibernate-validator-archetype/pom.xml 2009-11-06 11:11:= 07 UTC (rev 17940) @@ -4,7 +4,7 @@ hibernate-validator-parent org.hibernate - 4.0.2-SNAPSHOT + 4.0.2.GA ../pom.xml org.hibernate Modified: validator/trunk/hibernate-validator-legacy/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-legacy/pom.xml 2009-11-06 11:02:36 = UTC (rev 17939) +++ validator/trunk/hibernate-validator-legacy/pom.xml 2009-11-06 11:11:07 = UTC (rev 17940) @@ -4,13 +4,13 @@ hibernate-validator-parent org.hibernate - 4.0.2-SNAPSHOT + 4.0.2.GA ../pom.xml hibernate-validator-legacy jar Hibernate Validator Legacy - 3.1.0.GA + 4.0.2.GA http://validator.hibernate.org Modified: validator/trunk/hibernate-validator-tck-runner/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-11-06 11:02= :36 UTC (rev 17939) +++ validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-11-06 11:11= :07 UTC (rev 17940) @@ -2,7 +2,7 @@ hibernate-validator-parent org.hibernate - 4.0.2-SNAPSHOT + 4.0.2.GA 4.0.0 hibernate-validator-tck-runner Modified: validator/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/pom.xml 2009-11-06 11:02:36 UTC (rev 17939) +++ validator/trunk/pom.xml 2009-11-06 11:11:07 UTC (rev 17940) @@ -3,7 +3,7 @@ org.hibernate hibernate-validator-parent pom - 4.0.2-SNAPSHOT + 4.0.2.GA Hibernate Validator Parent http://validator.hibernate.org = @@ -170,8 +170,8 @@ = - scm:svn:https://svn.jboss.org/repos/hibernate/validato= r/trunk - http://fisheye.jboss.org/browse/Hibernate/validator/trunk + scm:svn:https://svn.jboss.org/repos/hibernate/validato= r/tags/v4_0_2_GA + http://fisheye.jboss.org/browse/Hibernate/validator/tags/v4_0= _2_GA = --===============3273205217766407514==-- From hibernate-commits at lists.jboss.org Fri Nov 6 06:11:30 2009 Content-Type: multipart/mixed; boundary="===============6334269337764974404==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17941 - validator/tags. Date: Fri, 06 Nov 2009 06:11:30 -0500 Message-ID: <200911061111.nA6BBUvW008284@svn01.web.mwc.hst.phx2.redhat.com> --===============6334269337764974404== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-06 06:11:30 -0500 (Fri, 06 Nov 2009) New Revision: 17941 Added: validator/tags/v4_0_2_GA/ Log: [maven-scm] copy for tag v4_0_2_GA Copied: validator/tags/v4_0_2_GA (from rev 17940, validator/trunk) --===============6334269337764974404==-- From hibernate-commits at lists.jboss.org Fri Nov 6 06:11:44 2009 Content-Type: multipart/mixed; boundary="===============4470687881125940200==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17942 - in validator/trunk: hibernate-validator and 3 other directories. Date: Fri, 06 Nov 2009 06:11:44 -0500 Message-ID: <200911061111.nA6BBiGN008327@svn01.web.mwc.hst.phx2.redhat.com> --===============4470687881125940200== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-06 06:11:44 -0500 (Fri, 06 Nov 2009) New Revision: 17942 Modified: validator/trunk/hibernate-validator-archetype/pom.xml validator/trunk/hibernate-validator-legacy/pom.xml validator/trunk/hibernate-validator-tck-runner/pom.xml validator/trunk/hibernate-validator/pom.xml validator/trunk/pom.xml Log: [maven-release-plugin] prepare for next development iteration Modified: validator/trunk/hibernate-validator/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/pom.xml 2009-11-06 11:11:30 UTC (re= v 17941) +++ validator/trunk/hibernate-validator/pom.xml 2009-11-06 11:11:44 UTC (re= v 17942) @@ -2,7 +2,7 @@ hibernate-validator-parent org.hibernate - 4.0.2.GA + 4.0.3-SNAPSHOT ../pom.xml 4.0.0 Modified: validator/trunk/hibernate-validator-archetype/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-archetype/pom.xml 2009-11-06 11:11:= 30 UTC (rev 17941) +++ validator/trunk/hibernate-validator-archetype/pom.xml 2009-11-06 11:11:= 44 UTC (rev 17942) @@ -4,7 +4,7 @@ hibernate-validator-parent org.hibernate - 4.0.2.GA + 4.0.3-SNAPSHOT ../pom.xml org.hibernate Modified: validator/trunk/hibernate-validator-legacy/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-legacy/pom.xml 2009-11-06 11:11:30 = UTC (rev 17941) +++ validator/trunk/hibernate-validator-legacy/pom.xml 2009-11-06 11:11:44 = UTC (rev 17942) @@ -4,13 +4,13 @@ hibernate-validator-parent org.hibernate - 4.0.2.GA + 4.0.3-SNAPSHOT ../pom.xml hibernate-validator-legacy jar Hibernate Validator Legacy - 4.0.2.GA + 3.1.0.GA http://validator.hibernate.org Modified: validator/trunk/hibernate-validator-tck-runner/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-11-06 11:11= :30 UTC (rev 17941) +++ validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-11-06 11:11= :44 UTC (rev 17942) @@ -2,7 +2,7 @@ hibernate-validator-parent org.hibernate - 4.0.2.GA + 4.0.3-SNAPSHOT 4.0.0 hibernate-validator-tck-runner Modified: validator/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/pom.xml 2009-11-06 11:11:30 UTC (rev 17941) +++ validator/trunk/pom.xml 2009-11-06 11:11:44 UTC (rev 17942) @@ -3,7 +3,7 @@ org.hibernate hibernate-validator-parent pom - 4.0.2.GA + 4.0.3-SNAPSHOT Hibernate Validator Parent http://validator.hibernate.org = @@ -170,8 +170,8 @@ = - scm:svn:https://svn.jboss.org/repos/hibernate/validato= r/tags/v4_0_2_GA - http://fisheye.jboss.org/browse/Hibernate/validator/tags/v4_0= _2_GA + scm:svn:https://svn.jboss.org/repos/hibernate/validato= r/trunk + http://fisheye.jboss.org/browse/Hibernate/validator/trunk = --===============4470687881125940200==-- From hibernate-commits at lists.jboss.org Fri Nov 6 06:36:55 2009 Content-Type: multipart/mixed; boundary="===============4410916359833902672==" MIME-Version: 1.0 From: Washpun To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Why not answering in Facebook? Date: Fri, 06 Nov 2009 06:36:51 -0500 Message-ID: <200911061136.nA6Baa5H021424@lists01.dmz-a.mwc.hst.phx2.redhat.com> --===============4410916359833902672== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Reporting service violation http://www.qivipks.cn/ (c) 2009 Ojeiqaepuxobuv. All right reserved. --===============4410916359833902672==-- From hibernate-commits at lists.jboss.org Fri Nov 6 08:04:18 2009 Content-Type: multipart/mixed; boundary="===============6601395633155122661==" MIME-Version: 1.0 From: Media Service To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Congratulations Date: Fri, 06 Nov 2009 08:04:08 -0500 Message-ID: <000d01ca5ee1$a0a30050$6400a8c0@busybodiesoi7> --===============6601395633155122661== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Congratulations!! You have won todays Macbook Air. Please open attached file and see datails. --===============6601395633155122661==-- From hibernate-commits at lists.jboss.org Fri Nov 6 08:20:11 2009 Content-Type: multipart/mixed; boundary="===============0624514550145365321==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17943 - core/trunk/annotations. Date: Fri, 06 Nov 2009 08:20:11 -0500 Message-ID: <200911061320.nA6DKBFb002615@svn01.web.mwc.hst.phx2.redhat.com> --===============0624514550145365321== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-06 08:20:10 -0500 (Fri, 06 Nov 2009) New Revision: 17943 Modified: core/trunk/annotations/pom.xml Log: updated to the latest HV version Modified: core/trunk/annotations/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/pom.xml 2009-11-06 11:11:44 UTC (rev 17942) +++ core/trunk/annotations/pom.xml 2009-11-06 13:20:10 UTC (rev 17943) @@ -86,7 +86,7 @@ org.hibernate hibernate-validator - 4.0.0.GA + 4.0.2.GA --===============0624514550145365321==-- From hibernate-commits at lists.jboss.org Fri Nov 6 08:59:38 2009 Content-Type: multipart/mixed; boundary="===============2004152116510050217==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17944 - in core/trunk: core/src/main/java/org/hibernate/action and 8 other directories. Date: Fri, 06 Nov 2009 08:59:37 -0500 Message-ID: <200911061359.nA6DxbxE010013@svn01.web.mwc.hst.phx2.redhat.com> --===============2004152116510050217== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: smarlow(a)redhat.com Date: 2009-11-06 08:59:37 -0500 (Fri, 06 Nov 2009) New Revision: 17944 Added: core/trunk/core/src/main/java/org/hibernate/OptimisticLockException.java core/trunk/core/src/main/java/org/hibernate/PessimisticLockException.java core/trunk/core/src/main/java/org/hibernate/action/EntityIncrementVersio= nProcess.java core/trunk/core/src/main/java/org/hibernate/action/EntityVerifyVersionPr= ocess.java Modified: core/trunk/core/src/main/java/org/hibernate/LockMode.java core/trunk/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.j= ava core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgrad= eEventListener.java core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventLi= stener.java core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventLi= stener.java core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEnt= ityPersister.java core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityM= anagerImpl.java core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractQueryIm= pl.java core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/lock/LockT= est.java core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JPALockTe= st.java Log: HHH-4546 - add JPA 2.0 locking Modified: core/trunk/core/src/main/java/org/hibernate/LockMode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/LockMode.java 2009-11-06 13= :20:10 UTC (rev 17943) +++ core/trunk/core/src/main/java/org/hibernate/LockMode.java 2009-11-06 13= :59:37 UTC (rev 17944) @@ -87,6 +87,7 @@ /** * An upgrade lock. Objects loaded in this lock mode are * materialized using an SQL select ... for update. + * @deprecated instead use PESSIMISTIC_WRITE */ public static final LockMode UPGRADE =3D new LockMode(10, "UPGRADE"); /** @@ -107,9 +108,47 @@ /** * Similiar to {@link #UPGRADE} except that, for versioned entities, * it results in a forced version increment. + * @deprecated instead use PESSIMISTIC_FORCE_INCREMENT */ public static final LockMode FORCE =3D new LockMode( 15, "FORCE" ); = + /** + * start of javax.persistence.LockModeType equivalent modes + */ + + /** + * Optimisticly assume that transaction will not experience contention for + * entities. The entity version will be verified near the transaction en= d. = + */ + public static final LockMode OPTIMISTIC =3D new LockMode(3,"OPTIMISTIC"); + + /** + * Optimisticly assume that transaction will not experience contention fo= r entities. + * The entity version will be verified and incremented near the transacti= on end. = + */ + public static final LockMode OPTIMISTIC_FORCE_INCREMENT =3D new LockMode(= 7,"OPTIMISTIC_FORCE_INCREMENT"); + + /** + * Implemented as PESSIMISTIC_WRITE. + * TODO: introduce separate support for PESSIMISTIC_READ + */ + public static final LockMode PESSIMISTIC_READ =3D new LockMode(12,"PESSIM= ISTIC_READ"); + + /** + * Transaction will obtain a database lock immediately. + * TODO: add PESSIMISTIC_WRITE_NOWAIT + */ + public static final LockMode PESSIMISTIC_WRITE =3D new LockMode(13,"PESSI= MISTIC_WRITE"); + + /** + * Transaction will immediately increment the entity version. + */ + public static final LockMode PESSIMISTIC_FORCE_INCREMENT =3D new LockMode= (17,"PESSIMISTIC_FORCE_INCREMENT"); + + /** + * end of javax.persistence.LockModeType modes + */ + = static { INSTANCES.put( NONE.name, NONE ); INSTANCES.put( READ.name, READ ); @@ -117,6 +156,11 @@ INSTANCES.put( UPGRADE_NOWAIT.name, UPGRADE_NOWAIT ); INSTANCES.put( WRITE.name, WRITE ); INSTANCES.put( FORCE.name, FORCE ); + INSTANCES.put( OPTIMISTIC.name, OPTIMISTIC); + INSTANCES.put( OPTIMISTIC_FORCE_INCREMENT.name, OPTIMISTIC_FORCE_INCREME= NT); + INSTANCES.put( PESSIMISTIC_READ. name, PESSIMISTIC_READ); + INSTANCES.put( PESSIMISTIC_WRITE.name, PESSIMISTIC_WRITE); + INSTANCES.put( PESSIMISTIC_FORCE_INCREMENT.name, PESSIMISTIC_FORCE_INCRE= MENT); } = private Object readResolve() { Added: core/trunk/core/src/main/java/org/hibernate/OptimisticLockException.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/OptimisticLockException.jav= a (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/OptimisticLockException.jav= a 2009-11-06 13:59:37 UTC (rev 17944) @@ -0,0 +1,51 @@ +/* + * 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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; + +/** + * + * Throw when an optimistic locking conflict occurs. + * + * @author Scott Marlow + */ +public class OptimisticLockException extends HibernateException { + + Object entity; + + public OptimisticLockException(String s) { + super(s); + } + + public OptimisticLockException(String s, Object entity) { + super(s); + this.entity =3D entity; + } + + public Object getEntity() { + return entity; + } + + +} \ No newline at end of file Added: core/trunk/core/src/main/java/org/hibernate/PessimisticLockException= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/PessimisticLockException.ja= va (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/PessimisticLockException.ja= va 2009-11-06 13:59:37 UTC (rev 17944) @@ -0,0 +1,50 @@ +/* + * 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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; + +/** + * + * Throw when an pessimistic locking conflict occurs. + * + * @author Scott Marlow + */ +public class PessimisticLockException extends HibernateException { + + Object entity; + + public PessimisticLockException(String s) { + super(s); + } + + public PessimisticLockException(String s, Object entity) { + super(s); + this.entity =3D entity; + } + + public Object getEntity() { + return entity; + } + +} \ No newline at end of file Added: core/trunk/core/src/main/java/org/hibernate/action/EntityIncrementVe= rsionProcess.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/EntityIncrementVersi= onProcess.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/action/EntityIncrementVersi= onProcess.java 2009-11-06 13:59:37 UTC (rev 17944) @@ -0,0 +1,58 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.action; + +import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.EntityEntry; +import org.hibernate.persister.entity.EntityPersister; + +/** + * Verify/Increment the entity version + * + * @author Scott Marlow + */ +public class EntityIncrementVersionProcess implements BeforeTransactionCom= pletionProcess +{ + private final Object object; + private final EntityEntry entry; + + public EntityIncrementVersionProcess(Object object, EntityEntry entry) { + this.object =3D object; + this.entry =3D entry; + } + + /** + * Perform whatever processing is encapsulated here before completion of = the transaction. + * + * @param session The session on which the transaction is preparing to co= mplete. + */ + public void doBeforeTransactionCompletion(SessionImplementor session) { + final EntityPersister persister =3D entry.getPersister(); + Object nextVersion =3D persister.forceVersionIncrement( + entry.getId(), entry.getVersion(), session + ); + entry.forceLocked( object, nextVersion ); + } +} Added: core/trunk/core/src/main/java/org/hibernate/action/EntityVerifyVersi= onProcess.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/EntityVerifyVersionP= rocess.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/action/EntityVerifyVersionP= rocess.java 2009-11-06 13:59:37 UTC (rev 17944) @@ -0,0 +1,64 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.action; + +import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.EntityEntry; +import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.HibernateException; +import org.hibernate.OptimisticLockException; + +/** + * Verify/Increment the entity version + * + * @author Scott Marlow + */ +public class EntityVerifyVersionProcess implements BeforeTransactionComple= tionProcess +{ + private final Object object; + private final EntityEntry entry; + + public EntityVerifyVersionProcess(Object object, EntityEntry entry) { + this.object =3D object; + this.entry =3D entry; + } + + /** + * Perform whatever processing is encapsulated here before completion of = the transaction. + * + * @param session The session on which the transaction is preparing to co= mplete. + */ + public void doBeforeTransactionCompletion(SessionImplementor session) { + final EntityPersister persister =3D entry.getPersister(); + + Object latestVersion =3D persister.getCurrentVersion( + entry.getId(), session + ); + if(!entry.getVersion().equals(latestVersion)) + throw new OptimisticLockException( + "Newer version ("+ latestVersion+ + ") of entity ("+entry.getEntityName()+") found in database. id=3D" + = entry.getId()); + } +} \ No newline at end of file Modified: core/trunk/core/src/main/java/org/hibernate/cfg/ResultSetMappingB= inder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.= java 2009-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.= java 2009-11-06 13:59:37 UTC (rev 17944) @@ -382,6 +382,21 @@ else if ( "force".equals( lockMode ) ) { return LockMode.FORCE; } + else if ( "optimistic".equals( lockMode ) ) { + return LockMode.OPTIMISTIC; + } + else if ( "optimistic_force_increment".equals( lockMode ) ) { + return LockMode.OPTIMISTIC_FORCE_INCREMENT; + } + else if ( "pessimistic_read".equals( lockMode ) ) { + return LockMode.PESSIMISTIC_READ; + } + else if ( "pessimistic_write".equals( lockMode ) ) { + return LockMode.PESSIMISTIC_WRITE; + } + else if ( "pessimistic_force_increment".equals( lockMode ) ) { + return LockMode.PESSIMISTIC_FORCE_INCREMENT; + } else { throw new MappingException( "unknown lockmode" ); } Modified: core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java 2009-1= 1-06 13:20:10 UTC (rev 17943) +++ core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java 2009-1= 1-06 13:59:37 UTC (rev 17944) @@ -962,13 +962,13 @@ * @return The appropriate for update fragment. */ public String getForUpdateString(LockMode lockMode) { - if ( lockMode=3D=3DLockMode.UPGRADE ) { + if ( lockMode=3D=3DLockMode.UPGRADE || lockMode=3D=3DLockMode.PESSIMISTI= C_READ || lockMode=3D=3DLockMode.PESSIMISTIC_WRITE) { return getForUpdateString(); } else if ( lockMode=3D=3DLockMode.UPGRADE_NOWAIT ) { return getForUpdateNowaitString(); } - else if ( lockMode=3D=3DLockMode.FORCE ) { + else if ( lockMode=3D=3DLockMode.FORCE || lockMode=3D=3DLockMode.PESSIMI= STIC_FORCE_INCREMENT) { return getForUpdateNowaitString(); } else { Modified: core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java 200= 9-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java 200= 9-11-06 13:59:37 UTC (rev 17944) @@ -252,7 +252,7 @@ public void forceLocked(Object entity, Object nextVersion) { version =3D nextVersion; loadedState[ persister.getVersionProperty() ] =3D version; - setLockMode( LockMode.FORCE ); + setLockMode( LockMode.FORCE ); // TODO: use LockMode.PESSIMISTIC_FORCE= _INCREMENT persister.setPropertyValue( entity, getPersister().getVersionProperty(), Modified: core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLoc= kUpgradeEventListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgra= deEventListener.java 2009-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgra= deEventListener.java 2009-11-06 13:59:37 UTC (rev 17944) @@ -29,11 +29,14 @@ = import org.hibernate.LockMode; import org.hibernate.ObjectDeletedException; +import org.hibernate.OptimisticLockException; +import org.hibernate.event.EventSource; +import org.hibernate.action.EntityIncrementVersionProcess; +import org.hibernate.action.EntityVerifyVersionProcess; import org.hibernate.cache.CacheKey; import org.hibernate.cache.access.SoftLock; import org.hibernate.engine.EntityEntry; import org.hibernate.engine.Status; -import org.hibernate.engine.SessionImplementor; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.pretty.MessageHelper; = @@ -55,7 +58,7 @@ * @param requestedLockMode The lock mode being requested for locking. * @param source The session which is the source of the event being proce= ssed. */ - protected void upgradeLock(Object object, EntityEntry entry, LockMode req= uestedLockMode, SessionImplementor source) { + protected void upgradeLock(Object object, EntityEntry entry, LockMode req= uestedLockMode, EventSource source) { = if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) { // The user requested a "greater" (i.e. more restrictive) form of @@ -97,13 +100,27 @@ } = try { - if ( persister.isVersioned() && requestedLockMode =3D=3D LockMode.FORC= E ) { + if ( persister.isVersioned() && (requestedLockMode =3D=3D LockMode.FOR= CE || requestedLockMode =3D=3D LockMode.PESSIMISTIC_FORCE_INCREMENT ) ) { // todo : should we check the current isolation mode explicitly? Object nextVersion =3D persister.forceVersionIncrement( entry.getId(), entry.getVersion(), source ); entry.forceLocked( object, nextVersion ); } + else if ( requestedLockMode =3D=3D LockMode.OPTIMISTIC_FORCE_INCREMENT= ) { + if(!persister.isVersioned()) { + throw new OptimisticLockException("force: Version column is not mapp= ed for " + entry.getPersister().getEntityName(), object); + } + EntityIncrementVersionProcess incrementVersion =3D new EntityIncremen= tVersionProcess(object, entry); + source.getActionQueue().registerProcess(incrementVersion); + } + else if ( requestedLockMode =3D=3D LockMode.OPTIMISTIC ) { + if(!persister.isVersioned()) { + throw new OptimisticLockException("Version column is not mapped for = " + entry.getPersister().getEntityName(), object); = + } + EntityVerifyVersionProcess verifyVersion =3D new EntityVerifyVersionP= rocess(object, entry); + source.getActionQueue().registerProcess(verifyVersion); + } else { persister.lock( entry.getId(), entry.getVersion(), object, requestedL= ockMode, source ); } Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoad= EventListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventL= istener.java 2009-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventL= istener.java 2009-11-06 13:59:37 UTC (rev 17944) @@ -485,7 +485,7 @@ return INCONSISTENT_RTN_CLASS_MARKER; } } - upgradeLock( old, oldEntry, event.getLockMode(), session ); + upgradeLock( old, oldEntry, event.getLockMode(), event.getSession() ); } = return old; Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLock= EventListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventL= istener.java 2009-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventL= istener.java 2009-11-06 13:59:37 UTC (rev 17944) @@ -80,11 +80,11 @@ } = entry =3D reassociate(event, entity, id, persister); - = + // TODO: make cascadeOnLock optional based on SCOPE cascadeOnLock(event, persister, entity); } = - upgradeLock( entity, entry, event.getLockMode(), source ); + upgradeLock( entity, entry, event.getLockMode(), event.getSession() ); } = private void cascadeOnLock(LockEvent event, EntityPersister persister, Ob= ject entity) { Modified: core/trunk/core/src/main/java/org/hibernate/persister/entity/Abst= ractEntityPersister.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEn= tityPersister.java 2009-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEn= tityPersister.java 2009-11-06 13:59:37 UTC (rev 17944) @@ -1391,6 +1391,11 @@ lockers.put( LockMode.UPGRADE, generateLocker( LockMode.UPGRADE ) ); lockers.put( LockMode.UPGRADE_NOWAIT, generateLocker( LockMode.UPGRADE_N= OWAIT ) ); lockers.put( LockMode.FORCE, generateLocker( LockMode.FORCE ) ); + lockers.put( LockMode.PESSIMISTIC_READ, generateLocker( LockMode.PESSIMI= STIC_READ ) ); + lockers.put( LockMode.PESSIMISTIC_WRITE, generateLocker( LockMode.PESSIM= ISTIC_WRITE ) ); + lockers.put( LockMode.PESSIMISTIC_FORCE_INCREMENT, generateLocker( LockM= ode.PESSIMISTIC_FORCE_INCREMENT ) ); + lockers.put( LockMode.OPTIMISTIC, generateLocker( LockMode.OPTIMISTIC ) = ); + lockers.put( LockMode.OPTIMISTIC_FORCE_INCREMENT, generateLocker( LockMo= de.OPTIMISTIC_FORCE_INCREMENT ) ); } = protected LockingStrategy generateLocker(LockMode lockMode) { @@ -3129,8 +3134,28 @@ readLoader : createEntityLoader( LockMode.FORCE ) ); - loaders.put( + LockMode.PESSIMISTIC_READ, + disableForUpdate ? + readLoader : + createEntityLoader( LockMode.PESSIMISTIC_READ ) + ); + loaders.put( + LockMode.PESSIMISTIC_WRITE, + disableForUpdate ? + readLoader : + createEntityLoader( LockMode.PESSIMISTIC_WRITE ) + ); + loaders.put( + LockMode.PESSIMISTIC_FORCE_INCREMENT, + disableForUpdate ? + readLoader : + createEntityLoader( LockMode.PESSIMISTIC_FORCE_INCREMENT ) + ); + loaders.put( LockMode.OPTIMISTIC, readLoader ); + loaders.put( LockMode.OPTIMISTIC_FORCE_INCREMENT, readLoader ); + = + loaders.put( "merge", new CascadeEntityLoader( this, CascadingAction.MERGE, getFactory() ) ); Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Abstract= EntityManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntity= ManagerImpl.java 2009-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntity= ManagerImpl.java 2009-11-06 13:59:37 UTC (rev 17944) @@ -38,6 +38,7 @@ import javax.persistence.OptimisticLockException; import javax.persistence.PersistenceContextType; import javax.persistence.PersistenceException; +import javax.persistence.PessimisticLockException; import javax.persistence.Query; import javax.persistence.TransactionRequiredException; import javax.persistence.TypedQuery; @@ -53,22 +54,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; = -import org.hibernate.AssertionFailure; -import org.hibernate.FlushMode; -import org.hibernate.HibernateException; -import org.hibernate.LockMode; -import org.hibernate.MappingException; -import org.hibernate.ObjectDeletedException; -import org.hibernate.ObjectNotFoundException; -import org.hibernate.QueryException; -import org.hibernate.SQLQuery; -import org.hibernate.Session; -import org.hibernate.StaleObjectStateException; -import org.hibernate.StaleStateException; -import org.hibernate.Transaction; -import org.hibernate.TransientObjectException; -import org.hibernate.TypeMismatchException; -import org.hibernate.UnresolvableObjectException; +import org.hibernate.*; import org.hibernate.cfg.Environment; import org.hibernate.ejb.transaction.JoinableCMTTransaction; import org.hibernate.ejb.util.ConfigurationHelper; @@ -253,8 +239,21 @@ = @SuppressWarnings("unchecked") public A find(Class entityClass, Object primaryKey) { + LockModeType lmt =3D null; + return find( entityClass, primaryKey, lmt); + } + + public T find(Class entityClass, Object primaryKey, Map properties) { + return find(entityClass, primaryKey); + } + + @SuppressWarnings("unchecked") + public A find(Class entityClass, Object primaryKey, LockModeType = lockModeType) { try { - return ( A ) getSession().get( entityClass, ( Serializable ) primaryKey= ); + if ( lockModeType !=3D null ) + return ( A ) getSession().get( entityClass, ( Serializable ) primaryKe= y, getLockMode(lockModeType) ); + else + return ( A ) getSession().get( entityClass, ( Serializable ) primaryKe= y ); } catch ( ObjectDeletedException e ) { //the spec is silent about people doing remove() find() on the same PC @@ -278,21 +277,10 @@ } } = - public T find(Class tClass, Object o, Map stringOb= jectMap) { - //FIXME - return null; //To change body of implemented methods use File | Setting= s | File Templates. + public A find(Class entityClass, Object primaryKey, LockModeType = lockModeType, Map properties) { + return find(entityClass, primaryKey, lockModeType); } = - public T find(Class tClass, Object o, LockModeType lockModeType) { - //FIXME - return null; //To change body of implemented methods use File | Setting= s | File Templates. - } - - public T find(Class tClass, Object o, LockModeType lockModeType, M= ap stringObjectMap) { - //FIXME - return null; //To change body of implemented methods use File | Setting= s | File Templates. - } - private void checkTransactionNeeded() { if ( persistenceContextType =3D=3D PersistenceContextType.TRANSACTION &&= !isTransactionInProgress() ) { //no need to mark as rollback, no tx in progress @@ -346,12 +334,25 @@ } = public void refresh(Object entity) { + LockModeType lmt =3D null; + refresh(entity, lmt); + } + + public void refresh(Object entity, Map properties) { + LockModeType lmt =3D null; + refresh(entity, lmt); + } + + public void refresh(Object entity, LockModeType lockModeType) { checkTransactionNeeded(); try { if ( !getSession().contains( entity ) ) { throw new IllegalArgumentException( "Entity not managed" ); } - getSession().refresh( entity ); + if(lockModeType !=3D null) + getSession().refresh( entity, getLockMode(lockModeType) ); + else + getSession().refresh( entity ); } catch ( MappingException e ) { throw new IllegalArgumentException( e.getMessage(), e ); @@ -361,21 +362,10 @@ } } = - public void refresh(Object o, Map stringObjectMap) { - //FIXME - //To change body of implemented methods use File | Settings | File Templ= ates. + public void refresh(Object entity, LockModeType lockModeType, Map properties) { + refresh(entity, lockModeType); } = - public void refresh(Object o, LockModeType lockModeType) { - //FIXME - //To change body of implemented methods use File | Settings | File Templ= ates. - } - - public void refresh(Object o, LockModeType lockModeType, Map stringObjectMap) { - //FIXME - //To change body of implemented methods use File | Settings | File Templ= ates. - } - public boolean contains(Object entity) { try { if ( entity !=3D null @@ -393,9 +383,11 @@ } } = - public LockModeType getLockMode(Object o) { - //FIXME - return null; //To change body of implemented methods use File | Setting= s | File Templates. + public LockModeType getLockMode(Object entity) { + if ( !contains( entity ) ) { + throw new IllegalArgumentException( "entity not in the persistence cont= ext" ); + } + return this.getLockModeType(getSession().getCurrentLockMode(entity)); } = public void setProperty(String s, Object o) { @@ -527,21 +519,57 @@ getSession().lock( entity, getLockMode( lockMode ) ); } catch ( HibernateException he ) { - throwPersistenceException( he ); + throw convert( he ); } } = - public void lock(Object o, LockModeType lockModeType, Map= stringObjectMap) { - //FIXME - //To change body of implemented methods use File | Settings | File Templ= ates. + public void lock(Object o, LockModeType lockModeType, Map= properties) { + // todo: support different properties passed in + lock(o,lockModeType); } = + + private LockModeType getLockModeType(LockMode lockMode) + { + if ( lockMode =3D=3D LockMode.NONE ) + return LockModeType.NONE; + else if ( lockMode =3D=3D LockMode.OPTIMISTIC || lockMode =3D=3D LockMod= e.READ ) + return LockModeType.OPTIMISTIC; + else if ( lockMode =3D=3D LockMode.OPTIMISTIC_FORCE_INCREMENT || lockMod= e =3D=3D LockMode.WRITE ) + return LockModeType.OPTIMISTIC_FORCE_INCREMENT; + else if ( lockMode =3D=3D LockMode.PESSIMISTIC_READ ) + return LockModeType.PESSIMISTIC_READ; + else if ( lockMode =3D=3D LockMode.PESSIMISTIC_WRITE ) + return LockModeType.PESSIMISTIC_WRITE; + else if ( lockMode =3D=3D LockMode.PESSIMISTIC_FORCE_INCREMENT ) + return LockModeType.PESSIMISTIC_FORCE_INCREMENT; + throw new AssertionFailure("unhandled lock mode " + lockMode ); + } + + private LockMode getLockMode(LockModeType lockMode) { switch ( lockMode ) { + case READ: - return LockMode.UPGRADE; //assuming we are on read-commited and we nee= d to prevent non repeteable read + case OPTIMISTIC: + return LockMode.OPTIMISTIC; + + case OPTIMISTIC_FORCE_INCREMENT: case WRITE: - return LockMode.FORCE; + return LockMode.OPTIMISTIC_FORCE_INCREMENT; + + case PESSIMISTIC_READ: + return LockMode.PESSIMISTIC_READ; + + case PESSIMISTIC_WRITE: + return LockMode.PESSIMISTIC_WRITE; + + case PESSIMISTIC_FORCE_INCREMENT: + return LockMode.PESSIMISTIC_FORCE_INCREMENT; + + case NONE: + return LockMode.NONE; + default: throw new AssertionFailure( "Unknown LockModeType: " + lockMode ); } @@ -772,6 +800,16 @@ handlePersistenceException( converted ); return converted; } + else if ( e instanceof org.hibernate.OptimisticLockException ) { + PersistenceException converted =3D wrapLockException(e); + handlePersistenceException( converted ); + return converted; + } + else if ( e instanceof org.hibernate.PessimisticLockException ) { + PersistenceException converted =3D wrapLockException(e); = + handlePersistenceException( converted ); + return converted; + } else if ( e instanceof ObjectNotFoundException ) { EntityNotFoundException converted =3D new EntityNotFoundException( e.ge= tMessage() ); handlePersistenceException( converted ); @@ -846,4 +884,21 @@ } return pe; } + + public PersistenceException wrapLockException(HibernateException e) { + PersistenceException pe; + if ( e instanceof org.hibernate.OptimisticLockException ) { + org.hibernate.OptimisticLockException ole =3D (org.hibernate.Optimisti= cLockException)e; + pe =3D new OptimisticLockException(ole.getMessage(), ole, ole.getEntity= ()); + } + else if ( e instanceof org.hibernate.PessimisticLockException ) { + org.hibernate.PessimisticLockException ple =3D (org.hibernate.Pessimi= sticLockException)e; + pe =3D new PessimisticLockException(ple.getMessage(), ple, ple.getEntit= y()); + } + else { + pe =3D new OptimisticLockException( e ); + } + return pe; + } + } Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Abstract= QueryImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractQueryI= mpl.java 2009-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractQueryI= mpl.java 2009-11-06 13:59:37 UTC (rev 17944) @@ -242,6 +242,17 @@ return QueryHints.getDefinedHints(); } = + private javax.persistence.LockModeType jpaLockMode =3D javax.persistence.= LockModeType.NONE; + + public TypedQuery setLockMode(javax.persistence.LockModeType lockModeT= ype) { + this.jpaLockMode =3D lockModeType; + return this; + } + + public javax.persistence.LockModeType getLockMode() { + return jpaLockMode; + } + private FlushModeType jpaFlushMode; = public TypedQuery setFlushMode(FlushModeType jpaFlushMode) { Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImp= l.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java= 2009-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java= 2009-11-06 13:59:37 UTC (rev 17944) @@ -29,7 +29,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.persistence.LockModeType; + import javax.persistence.NoResultException; import javax.persistence.NonUniqueResultException; import javax.persistence.Parameter; @@ -550,21 +550,6 @@ /** * {@inheritDoc} */ - public TypedQuery setLockMode(LockModeType lockModeType) { - // TODO : aye aye aye - throw new UnsupportedOperationException( "Not yet implemented" ); - } - - /** - * {@inheritDoc} - */ - public LockModeType getLockMode() { - return LockModeType.NONE; - } - - /** - * {@inheritDoc} - */ @SuppressWarnings({ "unchecked" }) public T unwrap(Class tClass) { if ( org.hibernate.Query.class.isAssignableFrom( tClass ) ) { Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/loc= k/LockTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/lock/Lock= Test.java 2009-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/lock/Lock= Test.java 2009-11-06 13:59:37 UTC (rev 17944) @@ -3,6 +3,7 @@ = import javax.persistence.EntityManager; import javax.persistence.LockModeType; +import javax.persistence.OptimisticLockException; = import org.hibernate.ejb.test.TestCase; = @@ -34,6 +35,29 @@ em.close(); } = + public void testLockOptimistic() throws Exception { + Lock lock =3D new Lock(); + lock.setName( "name" ); + EntityManager em =3D getOrCreateEntityManager(); + em.getTransaction().begin(); + em.persist( lock ); + em.getTransaction().commit(); + + em.getTransaction().begin(); + lock =3D em.getReference( Lock.class, lock.getId() ); + em.lock( lock, LockModeType.OPTIMISTIC ); + lock.setName( "surname" ); + em.getTransaction().commit(); + + em.getTransaction().begin(); + lock =3D em.find( Lock.class, lock.getId() ); + assertEquals( "surname", lock.getName() ); + em.remove( lock ); + em.getTransaction().commit(); + + em.close(); + } + public void testLockWrite() throws Exception { Lock lock =3D new Lock(); lock.setName( "second" ); @@ -70,7 +94,19 @@ = em.getTransaction().begin(); lock =3D em.getReference( UnversionedLock.class, lock.getId() ); - em.lock( lock, LockModeType.READ ); + try { + // getting a READ (optimistic) lock on unversioned entity is not expect= ed to work. + // To get the same functionality as prior release, change the LockMode= Type.READ lock to: + // em.lock(lock,LockModeType.PESSIMISTIC_READ); + em.lock( lock, LockModeType.READ ); + fail("expected OptimisticLockException exception"); + } catch(OptimisticLockException expected) {} + em.getTransaction().rollback(); + + // the previous code block can be rewritten as follows (to get the previ= ous behavior) + em.getTransaction().begin(); + lock =3D em.getReference( UnversionedLock.class, lock.getId() ); + em.lock( lock, LockModeType.PESSIMISTIC_READ ); em.getTransaction().commit(); = em.getTransaction().begin(); @@ -80,6 +116,58 @@ em.close(); } = + public void testLockPessimisticForceIncrement() throws Exception { + Lock lock =3D new Lock(); + lock.setName( "force" ); + EntityManager em =3D getOrCreateEntityManager(); + em.getTransaction().begin(); + em.persist( lock ); + em.getTransaction().commit(); + + em.getTransaction().begin(); + lock =3D em.getReference( Lock.class, lock.getId() ); + Integer version =3D lock.getVersion(); + em.lock( lock, LockModeType.PESSIMISTIC_FORCE_INCREMENT ); + em.getTransaction().commit(); + + em.getTransaction().begin(); + lock =3D em.getReference( Lock.class, lock.getId() ); + try { + assertEquals( "should increase the version number ", 1, lock.getVersion= () - version ); + } + finally { + em.remove( lock ); + em.getTransaction().commit(); + } + em.close(); + } + + public void testLockOptimisticForceIncrement() throws Exception { + Lock lock =3D new Lock(); + lock.setName( "force" ); + EntityManager em =3D getOrCreateEntityManager(); + em.getTransaction().begin(); + em.persist( lock ); + em.getTransaction().commit(); + + em.getTransaction().begin(); + lock =3D em.getReference( Lock.class, lock.getId() ); + Integer version =3D lock.getVersion(); + em.lock( lock, LockModeType.OPTIMISTIC_FORCE_INCREMENT ); + em.getTransaction().commit(); + + em.getTransaction().begin(); + lock =3D em.getReference( Lock.class, lock.getId() ); + try { + assertEquals( "should increase the version number ", 1, lock.getVersion= () - version ); + } + finally { + em.remove( lock ); + em.getTransaction().commit(); + } + em.close(); + } + = public Class[] getAnnotatedClasses() { return new Class[]{ Lock.class, Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JP= ALockTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JPALockT= est.java 2009-11-06 13:20:10 UTC (rev 17943) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JPALockT= est.java 2009-11-06 13:59:37 UTC (rev 17944) @@ -51,7 +51,7 @@ * must always prevent the phenomena P1 and P2. Applications that call lo= ck(entity, LockModeType.READ) * on non-versioned objects will not be portable. *

- * Odd as it may sound, EJB3 LockModeType.READ actually maps to the Hiber= nate LockMode.UPGRADE + * EJB3 LockModeType.READ actually maps to the Hibernate LockMode.OPTIMIS= TIC */ public void testLockModeTypeRead() { if ( !readCommittedIsolationMaintained( "ejb3 lock tests" ) ) { --===============2004152116510050217==-- From hibernate-commits at lists.jboss.org Fri Nov 6 11:02:26 2009 Content-Type: multipart/mixed; boundary="===============0463729044532611981==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17945 - in jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen: annotation and 1 other directory. Date: Fri, 06 Nov 2009 11:02:26 -0500 Message-ID: <200911061602.nA6G2Qjn029143@svn01.web.mwc.hst.phx2.redhat.com> --===============0463729044532611981== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-06 11:02:26 -0500 (Fri, 06 Nov 2009) New Revision: 17945 Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.ja= va jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEn= tityProcessor.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Ann= otationMetaEntity.java Log: METAGEN-5 Added an additonal option which can be passed to the processor in order to = print debug messages. Passing of the parameter is via -Adebug=3Dtrue Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWr= iter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.j= ava 2009-11-06 13:59:37 UTC (rev 17944) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.j= ava 2009-11-06 16:02:26 UTC (rev 17945) @@ -23,7 +23,6 @@ import java.io.StringWriter; import java.util.List; import javax.annotation.processing.FilerException; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; @@ -37,13 +36,13 @@ */ public class ClassWriter { = - public static void writeFile(MetaEntity entity, ProcessingEnvironment pro= cessingEnv, Context context) { + public static void writeFile(MetaEntity entity, Context context) { try { String metaModelPackage =3D entity.getPackageName(); = StringBuffer body =3D generateBody( entity, context ); = - FileObject fo =3D processingEnv.getFiler().createSourceFile( + FileObject fo =3D context.getProcessingEnvironment().getFiler().createS= ourceFile( metaModelPackage + "." + entity.getSimpleName() + "_" ); OutputStream os =3D fo.openOutputStream(); @@ -62,17 +61,14 @@ = } catch ( FilerException filerEx ) { - processingEnv.getMessager().printMessage( - Diagnostic.Kind.ERROR, - "Problem with Processing Environment Filer: " - + filerEx.getMessage() + context.logMessage( + Diagnostic.Kind.ERROR, "Problem with Processing Environment Filer: " = + filerEx.getMessage() ); } catch ( IOException ioEx ) { - processingEnv.getMessager().printMessage( + context.logMessage( Diagnostic.Kind.ERROR, - "Problem opening file to write MetaModel for " + entity.getSimpleName= () - + ioEx.getMessage() + "Problem opening file to write MetaModel for " + entity.getSimpleName= () + ioEx.getMessage() ); } } Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java = 2009-11-06 13:59:37 UTC (rev 17944) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java = 2009-11-06 16:02:26 UTC (rev 17945) @@ -17,13 +17,13 @@ */ package org.hibernate.jpamodelgen; = +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; -import java.util.HashMap; import java.util.Set; -import java.util.HashSet; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import javax.persistence.AccessType; -import javax.annotation.processing.ProcessingEnvironment; import javax.tools.Diagnostic; = import org.hibernate.jpamodelgen.annotation.AnnotationMetaEntity; @@ -34,12 +34,16 @@ * @author Emmanuel Bernard */ public class Context { + private static final String DEBUG_PARAMETER =3D "debug"; + private final Map metaEntitiesToProcess =3D new HashM= ap(); + private final Map metaSuperclassAndEmbeddableToProces= s =3D new HashMap(); + + private ProcessingEnvironment pe; + private boolean logDebug =3D false; + //used to cache access types private Map accessTypes =3D new HashMap(); private Set elementsAlreadyProcessed =3D new HashSet(); - private ProcessingEnvironment pe; - private final Map metaEntitiesToProcess =3D new HashM= ap(); - private final Map metaSuperclassAndEmbeddableToProces= s =3D new HashMap(); = private static class AccessTypeHolder { public AccessType elementAccessType; @@ -48,8 +52,16 @@ = public Context(ProcessingEnvironment pe) { this.pe =3D pe; + String debugParam =3D pe.getOptions().get( DEBUG_PARAMETER ); + if ( debugParam !=3D null && "true".equals( debugParam ) ) { + logDebug =3D true; + } } = + public ProcessingEnvironment getProcessingEnvironment() { + return pe; + } + public Map getMetaEntitiesToProcess() { return metaEntitiesToProcess; } @@ -94,11 +106,17 @@ //does not work for Entity (risk of circularity) public void processElement(TypeElement element, AccessType defaultAccessT= ypeForHierarchy) { if ( elementsAlreadyProcessed.contains( element.getQualifiedName().toStr= ing() ) ) { - pe.getMessager().printMessage( Diagnostic.Kind.WARNING, "Element alread= y processed (ignoring): " + element ); + logMessage( Diagnostic.Kind.WARNING, "Element already processed (ignori= ng): " + element ); return; } - - ClassWriter.writeFile( new AnnotationMetaEntity( pe, element, this, defa= ultAccessTypeForHierarchy ), pe, this ); + ClassWriter.writeFile( new AnnotationMetaEntity( pe, element, this, defa= ultAccessTypeForHierarchy ), this ); elementsAlreadyProcessed.add( element.getQualifiedName().toString() ); } + + public void logMessage(Diagnostic.Kind type, String message) { + if ( !logDebug && type.equals( Diagnostic.Kind.NOTE ) ) { + return; + } + pe.getMessager().printMessage( type, message ); + } } Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMeta= ModelEntityProcessor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelE= ntityProcessor.java 2009-11-06 13:59:37 UTC (rev 17944) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelE= ntityProcessor.java 2009-11-06 16:02:26 UTC (rev 17945) @@ -64,10 +64,8 @@ * @author Hardy Ferentschik * @author Emmanuel Bernard */ -//@SupportedAnnotationTypes("javax.persistence.Entity") @SupportedAnnotationTypes("*") @SupportedSourceVersion(RELEASE_6) -// TODO Extract all the XML parsing into a separate class public class JPAMetaModelEntityProcessor extends AbstractProcessor { = private static final String PATH_SEPARATOR =3D "/"; @@ -87,7 +85,7 @@ public void init(ProcessingEnvironment env) { super.init( env ); context =3D new Context( env ); - processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Init Pr= ocessor " + this ); + context.logMessage( Diagnostic.Kind.NOTE, "Init Processor " + this ); } = @Override @@ -95,13 +93,9 @@ final RoundEnvironment roundEnvironment) { = if ( roundEnvironment.processingOver() ) { - processingEnv.getMessager() - .printMessage( Diagnostic.Kind.NOTE, "Last processing round." ); - + context.logMessage( Diagnostic.Kind.NOTE, "Last processing round." ); createMetaModelClasses(); - - processingEnv.getMessager() - .printMessage( Diagnostic.Kind.NOTE, "Finished processing" ); + context.logMessage( Diagnostic.Kind.NOTE, "Finished processing" ); return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS; } = @@ -110,14 +104,13 @@ } = if ( !hostJPAAnnotations( annotations ) ) { - processingEnv.getMessager() - .printMessage( Diagnostic.Kind.NOTE, "Current processing round does n= ot contain entities" ); + context.logMessage( Diagnostic.Kind.NOTE, "Current processing round doe= s not contain entities" ); return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS; } = Set elements =3D roundEnvironment.getRootElements(); for ( Element element : elements ) { - processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Proces= sing " + element.toString() ); + context.logMessage( Diagnostic.Kind.NOTE, "Processing " + element.toStr= ing() ); handleRootElementAnnotationMirrors( element ); } = @@ -126,9 +119,8 @@ = private void createMetaModelClasses() { for ( MetaEntity entity : context.getMetaEntitiesToProcess().values() ) { - processingEnv.getMessager() - .printMessage( Diagnostic.Kind.NOTE, "Writing meta model for " + enti= ty ); - ClassWriter.writeFile( entity, processingEnv, context ); + context.logMessage( Diagnostic.Kind.NOTE, "Writing meta model for " + e= ntity ); + ClassWriter.writeFile( entity, context ); } = //process left over, in most cases is empty @@ -137,9 +129,8 @@ } = for ( MetaEntity entity : context.getMetaSuperclassAndEmbeddableToProces= s().values() ) { - processingEnv.getMessager() - .printMessage( Diagnostic.Kind.NOTE, "Writing meta model for " + enti= ty ); - ClassWriter.writeFile( entity, processingEnv, context ); + context.logMessage( Diagnostic.Kind.NOTE, "Writing meta model for " + e= ntity ); + ClassWriter.writeFile( entity, context ); } } = @@ -161,8 +152,7 @@ = private void parsePersistenceXml() { Persistence persistence =3D parseXml( PERSISTENCE_XML, Persistence.class= , PERSISTENCE_XML_XSD ); - if ( persistence !=3D null ) - { + if ( persistence !=3D null ) { List persistenceUnits =3D persistence.getP= ersistenceUnit(); for ( Persistence.PersistenceUnit unit : persistenceUnits ) { List mappingFiles =3D unit.getMappingFile(); @@ -228,7 +218,7 @@ String fullyQualifiedClassName =3D packageName + "." + entity.getClazz(= ); = if ( !xmlMappedTypeExists( fullyQualifiedClassName ) ) { - processingEnv.getMessager().printMessage( + context.logMessage( Diagnostic.Kind.WARNING, fullyQualifiedClassName + " is mapped in xml, but class does not exi= sts. Skipping meta model generation." ); @@ -240,7 +230,7 @@ ); = if ( context.getMetaEntitiesToProcess().containsKey( fullyQualifiedClas= sName ) ) { - processingEnv.getMessager().printMessage( + context.logMessage( Diagnostic.Kind.WARNING, fullyQualifiedClassName + " was already processed once. Skipping sec= ond occurance." ); @@ -266,7 +256,7 @@ String fullyQualifiedClassName =3D packageName + "." + embeddable.getCl= azz(); = if ( !xmlMappedTypeExists( fullyQualifiedClassName ) ) { - processingEnv.getMessager().printMessage( + context.logMessage( Diagnostic.Kind.WARNING, fullyQualifiedClassName + " is mapped in xml, but class does not exi= sts. Skipping meta model generation." ); @@ -278,7 +268,7 @@ ); = if ( context.getMetaSuperclassAndEmbeddableToProcess().containsKey( ful= lyQualifiedClassName ) ) { - processingEnv.getMessager().printMessage( + context.logMessage( Diagnostic.Kind.WARNING, fullyQualifiedClassName + " was already processed once. Skipping sec= ond occurance." ); @@ -294,7 +284,7 @@ String fullyQualifiedClassName =3D packageName + "." + mappedSuperClass= .getClazz(); = if ( !xmlMappedTypeExists( fullyQualifiedClassName ) ) { - processingEnv.getMessager().printMessage( + context.logMessage( Diagnostic.Kind.WARNING, fullyQualifiedClassName + " is mapped in xml, but class does not exi= sts. Skipping meta model generation." ); @@ -306,7 +296,7 @@ ); = if ( context.getMetaSuperclassAndEmbeddableToProcess().containsKey( ful= lyQualifiedClassName ) ) { - processingEnv.getMessager().printMessage( + context.logMessage( Diagnostic.Kind.WARNING, fullyQualifiedClassName + " was already processed once. Skipping sec= ond occurance." ); @@ -325,13 +315,17 @@ = if ( element.getKind() =3D=3D ElementKind.CLASS ) { if ( annotationType.equals( ENTITY_ANN ) ) { - AnnotationMetaEntity metaEntity =3D new AnnotationMetaEntity( process= ingEnv, ( TypeElement ) element, context ); + AnnotationMetaEntity metaEntity =3D new AnnotationMetaEntity( + processingEnv, ( TypeElement ) element, context + ); // TODO instead of just adding the entity we have to do some merging. context.getMetaEntitiesToProcess().put( metaEntity.getQualifiedName()= , metaEntity ); } else if ( annotationType.equals( MAPPED_SUPERCLASS_ANN ) || annotationType.equals( EMBEDDABLE_ANN ) ) { - AnnotationMetaEntity metaEntity =3D new AnnotationMetaEntity( process= ingEnv, ( TypeElement ) element, context ); + AnnotationMetaEntity metaEntity =3D new AnnotationMetaEntity( + processingEnv, ( TypeElement ) element, context + ); = // TODO instead of just adding the entity we have to do some merging. context.getMetaSuperclassAndEmbeddableToProcess().put( metaEntity.get= QualifiedName(), metaEntity ); @@ -343,8 +337,7 @@ private InputStream getInputStreamForResource(String resource) { String pkg =3D getPackage( resource ); String name =3D getRelativeName( resource ); - processingEnv.getMessager() - .printMessage( Diagnostic.Kind.NOTE, "Reading resource " + resource ); + context.logMessage( Diagnostic.Kind.NOTE, "Reading resource " + resource= ); InputStream ormStream; try { FileObject fileObject =3D processingEnv.getFiler().getResource( Standar= dLocation.CLASS_OUTPUT, pkg, name ); @@ -381,7 +374,7 @@ InputStream stream =3D getInputStreamForResource( resource ); = if ( stream =3D=3D null ) { - processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, resourc= e + " not found." ); + context.logMessage( Diagnostic.Kind.NOTE, resource + " not found." ); return null; } try { @@ -394,12 +387,12 @@ } catch ( JAXBException e ) { String message =3D "Error unmarshalling " + resource + " with exception= :\n " + e; - processingEnv.getMessager().printMessage( Diagnostic.Kind.WARNING, mess= age ); + context.logMessage( Diagnostic.Kind.WARNING, message ); return null; } catch ( Exception e ) { String message =3D "Error reading " + resource + " with exception :\n "= + e; - processingEnv.getMessager().printMessage( Diagnostic.Kind.WARNING, mess= age ); + context.logMessage( Diagnostic.Kind.WARNING, message ); return null; } } @@ -426,15 +419,15 @@ Schema schema =3D null; URL schemaUrl =3D this.getClass().getClassLoader().getResource( schemaNa= me ); if ( schemaUrl =3D=3D null ) { - return schema; + return schema; } - = + SchemaFactory sf =3D SchemaFactory.newInstance( javax.xml.XMLConstants.W= 3C_XML_SCHEMA_NS_URI ); try { schema =3D sf.newSchema( schemaUrl ); } catch ( SAXException e ) { - processingEnv.getMessager().printMessage( + context.logMessage( Diagnostic.Kind.WARNING, "Unable to create schema for " + schemaName = + ": " + e.getMessage() ); } Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotat= ion/AnnotationMetaEntity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaEntity.java 2009-11-06 13:59:37 UTC (rev 17944) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaEntity.java 2009-11-06 16:02:26 UTC (rev 17945) @@ -192,15 +192,14 @@ } = private AccessType getAccessTypeForClass(TypeElement searchedElement) { - pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "check class" + sea= rchedElement ); + context.logMessage( Diagnostic.Kind.NOTE, "check class " + searchedEleme= nt ); AccessType accessType =3D context.getAccessType( searchedElement ); = if ( defaultAccessTypeForHierarchy =3D=3D null ) { this.defaultAccessTypeForHierarchy =3D context.getDefaultAccessTypeForH= erarchy( searchedElement ); } if ( accessType !=3D null ) { - pe.getMessager() - .printMessage( Diagnostic.Kind.NOTE, "Found in cache" + searchedEleme= nt + ":" + accessType ); + context.logMessage( Diagnostic.Kind.NOTE, "Found in cache" + searchedEl= ement + ":" + accessType ); return accessType; } = @@ -211,8 +210,7 @@ final Access accessAnn =3D searchedElement.getAnnotation( Access.class ); AccessType forcedAccessType =3D accessAnn !=3D null ? accessAnn.value() = : null; if ( forcedAccessType !=3D null ) { - pe.getMessager() - .printMessage( Diagnostic.Kind.NOTE, "access type " + searchedElement= + ":" + forcedAccessType ); + context.logMessage( Diagnostic.Kind.NOTE, "access type " + searchedElem= ent + ":" + forcedAccessType ); context.addAccessType( searchedElement, forcedAccessType ); } = @@ -232,7 +230,7 @@ //FIXME consider XML if ( annotationType.equals( Id.class.getName() ) || annotationType.equals( EmbeddedId.class.getName() ) ) { - pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found id on" += searchedElement ); + context.logMessage( Diagnostic.Kind.NOTE, "Found id on" + searchedEl= ement ); final ElementKind kind =3D subElement.getKind(); if ( kind =3D=3D ElementKind.FIELD || kind =3D=3D ElementKind.METHOD= ) { accessType =3D kind =3D=3D ElementKind.FIELD ? AccessType.FIELD : A= ccessType.PROPERTY; @@ -251,7 +249,7 @@ } if ( forcedAccessType =3D=3D null ) { context.addAccessType( searchedElement, accessType ); - pe.getMessager().printMessage( + context.logMessage( Diagnostic.Kind.NOTE, "access type " + searchedElement + ":" + a= ccessType ); return accessType; --===============0463729044532611981==-- From hibernate-commits at lists.jboss.org Fri Nov 6 11:48:14 2009 Content-Type: multipart/mixed; boundary="===============8491123004685246527==" MIME-Version: 1.0 From: Media Service To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Congratulations Date: Fri, 06 Nov 2009 17:48:02 +0100 Message-ID: <000d01ca5f00$e7906880$6400a8c0@hallelujaheb26> --===============8491123004685246527== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Congratulations!! You have won todays Macbook Air. Please open attached file and see datails. --===============8491123004685246527==-- From hibernate-commits at lists.jboss.org Fri Nov 6 13:23:49 2009 Content-Type: multipart/mixed; boundary="===============4509029698466712248==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17946 - in jpamodelgen/trunk/src: main/java/org/hibernate/jpamodelgen/annotation and 4 other directories. Date: Fri, 06 Nov 2009 13:23:49 -0500 Message-ID: <200911061823.nA6INnVN026244@svn01.web.mwc.hst.phx2.redhat.com> --===============4509029698466712248== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-06 13:23:48 -0500 (Fri, 06 Nov 2009) New Revision: 17946 Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementco= llection/ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementco= llection/ElementCollectionTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementco= llection/House.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementco= llection/Room.java Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEn= tityProcessor.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Ann= otationMetaAttribute.java jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/Ann= otationMetaEntity.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Comp= ilationTest.java jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Test= Util.java jpamodelgen/trunk/src/test/suite/unit-tests.xml Log: METAGEN-8 Made sure that the right element type is extracted in case the is a Element= Collection on Map. I think however, there are more problems. We only cover the java.util.Map c= ase. We need to take care of subclasses as well. Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java = 2009-11-06 16:02:26 UTC (rev 17945) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java = 2009-11-06 18:23:48 UTC (rev 17946) @@ -109,7 +109,7 @@ logMessage( Diagnostic.Kind.WARNING, "Element already processed (ignori= ng): " + element ); return; } - ClassWriter.writeFile( new AnnotationMetaEntity( pe, element, this, defa= ultAccessTypeForHierarchy ), this ); + ClassWriter.writeFile( new AnnotationMetaEntity( element, this, defaultA= ccessTypeForHierarchy ), this ); elementsAlreadyProcessed.add( element.getQualifiedName().toString() ); } = Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMeta= ModelEntityProcessor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelE= ntityProcessor.java 2009-11-06 16:02:26 UTC (rev 17945) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelE= ntityProcessor.java 2009-11-06 18:23:48 UTC (rev 17946) @@ -315,17 +315,13 @@ = if ( element.getKind() =3D=3D ElementKind.CLASS ) { if ( annotationType.equals( ENTITY_ANN ) ) { - AnnotationMetaEntity metaEntity =3D new AnnotationMetaEntity( - processingEnv, ( TypeElement ) element, context - ); + AnnotationMetaEntity metaEntity =3D new AnnotationMetaEntity( ( TypeE= lement ) element, context ); // TODO instead of just adding the entity we have to do some merging. context.getMetaEntitiesToProcess().put( metaEntity.getQualifiedName()= , metaEntity ); } else if ( annotationType.equals( MAPPED_SUPERCLASS_ANN ) || annotationType.equals( EMBEDDABLE_ANN ) ) { - AnnotationMetaEntity metaEntity =3D new AnnotationMetaEntity( - processingEnv, ( TypeElement ) element, context - ); + AnnotationMetaEntity metaEntity =3D new AnnotationMetaEntity( ( TypeE= lement ) element, context ); = // TODO instead of just adding the entity we have to do some merging. context.getMetaSuperclassAndEmbeddableToProcess().put( metaEntity.get= QualifiedName(), metaEntity ); Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotat= ion/AnnotationMetaAttribute.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaAttribute.java 2009-11-06 16:02:26 UTC (rev 17945) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaAttribute.java 2009-11-06 18:23:48 UTC (rev 17946) @@ -17,16 +17,14 @@ */ package org.hibernate.jpamodelgen.annotation; = -import org.hibernate.jpamodelgen.MetaAttribute; - import java.beans.Introspector; - -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; +import javax.lang.model.util.Elements; = +import org.hibernate.jpamodelgen.MetaAttribute; + /** - * * @author Max Andersen * @author Hardy Ferentschik * @author Emmanuel Bernard @@ -35,40 +33,42 @@ = final protected Element element; final protected AnnotationMetaEntity parent; - final protected ProcessingEnvironment pe; private final String type; = public AnnotationMetaAttribute(AnnotationMetaEntity parent, Element eleme= nt, String type) { this.element =3D element; this.parent =3D parent; this.type =3D type; - this.pe =3D parent.pe; } = public String getDeclarationString() { - return "public static volatile " + parent.importType(getMetaType()) + "<= " + parent.importType(parent.getQualifiedName()) + ", " + parent.importType= (getTypeDeclaration()) + "> " + getPropertyName() + ";"; = + return "public static volatile " + parent.importType( getMetaType() ) + = "<" + parent.importType( parent.getQualifiedName() ) + ", " + parent + .importType( getTypeDeclaration() ) + "> " + getPropertyName() + ";"; } = public String getPropertyName() { - if(element.getKind()=3D=3DElementKind.FIELD) { + Elements elementsUtil =3D parent.getContext().getProcessingEnvironment()= .getElementUtils(); + if ( element.getKind() =3D=3D ElementKind.FIELD ) { return element.getSimpleName().toString(); - } else if (element.getKind()=3D=3DElementKind.METHOD) { - = + } + else if ( element.getKind() =3D=3D ElementKind.METHOD ) { String name =3D element.getSimpleName().toString(); - if(name.startsWith("get")) { - return pe.getElementUtils().getName(Introspector.decapitalize(name.sub= string("get".length()))).toString(); - } else if(name.startsWith("is")) { - return (pe.getElementUtils().getName(Introspector.decapitalize(name.su= bstring("is".length())))).toString(); + if ( name.startsWith( "get" ) ) { + return elementsUtil.getName( Introspector.decapitalize( name.substring= ( "get".length() ) ) ).toString(); } - return pe.getElementUtils().getName(Introspector.decapitalize(name)).to= String(); - } else { - return pe.getElementUtils().getName(element.getSimpleName() + "/* " + e= lement.getKind() + " */").toString(); + else if ( name.startsWith( "is" ) ) { + return ( elementsUtil.getName( Introspector.decapitalize( name.substri= ng( "is".length() ) ) ) ).toString(); + } + return elementsUtil.getName( Introspector.decapitalize( name ) ).toStri= ng(); } + else { + return elementsUtil.getName( element.getSimpleName() + "/* " + element.= getKind() + " */" ).toString(); + } } = abstract public String getMetaType(); = public String getTypeDeclaration() { - return type; = + return type; } } Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotat= ion/AnnotationMetaEntity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaEntity.java 2009-11-06 16:02:26 UTC (rev 17945) +++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/An= notationMetaEntity.java 2009-11-06 18:23:48 UTC (rev 17946) @@ -21,7 +21,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; @@ -62,27 +61,37 @@ */ public class AnnotationMetaEntity implements MetaEntity { = - final TypeElement element; - final protected ProcessingEnvironment pe; + static Map COLLECTIONS =3D new HashMap(); = - final ImportContext importContext; + static { + COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.Co= llectionAttribute" ); + COLLECTIONS.put( "java.util.Set", "javax.persistence.metamodel.SetAttrib= ute" ); + COLLECTIONS.put( "java.util.List", "javax.persistence.metamodel.ListAttr= ibute" ); + COLLECTIONS.put( "java.util.Map", "javax.persistence.metamodel.MapAttrib= ute" ); + } + + private final TypeElement element; + private final ImportContext importContext; private Context context; //used to propagate the access type of the root entity over to subclasses= , superclasses and embeddable private AccessType defaultAccessTypeForHierarchy; private AccessType defaultAccessTypeForElement; = - public AnnotationMetaEntity(ProcessingEnvironment pe, TypeElement element= , Context context) { + public AnnotationMetaEntity(TypeElement element, Context context) { this.element =3D element; - this.pe =3D pe; + this.context =3D context; importContext =3D new ImportContextImpl( getPackageName() ); - this.context =3D context; } = - public AnnotationMetaEntity(ProcessingEnvironment pe, TypeElement element= , Context context, AccessType accessType) { - this( pe, element, context ); + public AnnotationMetaEntity(TypeElement element, Context context, AccessT= ype accessType) { + this( element, context ); this.defaultAccessTypeForHierarchy =3D accessType; } = + public Context getContext() { + return context; + } + public String getSimpleName() { return element.getSimpleName().toString(); } @@ -92,8 +101,8 @@ } = public String getPackageName() { - PackageElement packageOf =3D pe.getElementUtils().getPackageOf( element = ); - return pe.getElementUtils().getName( packageOf.getQualifiedName() ).toSt= ring(); + PackageElement packageOf =3D context.getProcessingEnvironment().getEleme= ntUtils().getPackageOf( element ); + return context.getProcessingEnvironment().getElementUtils().getName( pac= kageOf.getQualifiedName() ).toString(); } = public List getMembers() { @@ -153,10 +162,9 @@ accessType =3D this.defaultAccessTypeForHierarchy; } if ( accessType =3D=3D null ) { - //we dont' know - //if an enity go up + //we don't know if an entity go up // - //superclasses alre always treated after their entities + //superclasses are always treated after their entities //and their access type are discovered //FIXME is it really true if only the superclass is changed TypeElement superClass =3D element; @@ -220,7 +228,7 @@ List myMembers =3D searchedElement.getEnclosedElemen= ts(); for ( Element subElement : myMembers ) { List entityAnnotations =3D - pe.getElementUtils().getAllAnnotationMirrors( subElement ); + context.getProcessingEnvironment().getElementUtils().getAllAnnotatio= nMirrors( subElement ); = for ( Object entityAnnotation : entityAnnotations ) { AnnotationMirror annotationMirror =3D ( AnnotationMirror ) entityAnno= tation; @@ -274,15 +282,6 @@ return sb.toString(); } = - static Map COLLECTIONS =3D new HashMap(); - - static { - COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.Co= llectionAttribute" ); - COLLECTIONS.put( "java.util.Set", "javax.persistence.metamodel.SetAttrib= ute" ); - COLLECTIONS.put( "java.util.List", "javax.persistence.metamodel.ListAttr= ibute" ); - COLLECTIONS.put( "java.util.Map", "javax.persistence.metamodel.MapAttrib= ute" ); - } - class TypeVisitor extends SimpleTypeVisitor6 { = AnnotationMetaEntity parent; @@ -343,15 +342,18 @@ public AnnotationMetaAttribute visitDeclared(DeclaredType t, Element ele= ment) { //FIXME consider XML if ( isPersistent( element ) ) { - TypeElement returnedElement =3D ( TypeElement ) pe.getTypeUtils().asEl= ement( t ); - String collection =3D COLLECTIONS.get( returnedElement.getQualifiedNam= e().toString() ); // WARNING: .toString() is necessary here since Name equa= ls does not compare to String - + TypeElement returnedElement =3D ( TypeElement ) context.getProcessingE= nvironment() + .getTypeUtils() + .asElement( t ); + String fqElementName =3D returnedElement.getQualifiedName() + .toString(); // WARNING: .toString() is necessary here since Name e= quals does not compare to String + String collection =3D COLLECTIONS.get( fqElementName ); if ( collection !=3D null ) { - //collection of element if ( element.getAnnotation( ElementCollection.class ) !=3D null ) { - final TypeMirror collectionType =3D t.getTypeArguments().get( 0 ); - final TypeElement collectionElement =3D ( TypeElement ) pe.getTypeUt= ils() - .asElement( collectionType ); + TypeMirror collectionElementType =3D getCollectionElementType( t, fq= ElementName ); + final TypeElement collectionElement =3D ( TypeElement ) context.getP= rocessingEnvironment() + .getTypeUtils() + .asElement( collectionElementType ); this.parent.context.processElement( collectionElement, this.parent.defaultAccessTypeForElement @@ -385,6 +387,17 @@ } } = + private TypeMirror getCollectionElementType(DeclaredType t, String fqEle= mentName) { + TypeMirror collectionElementType; + if ( Map.class.getCanonicalName().equals( fqElementName ) ) { + collectionElementType =3D t.getTypeArguments().get( 1 ); + } + else { + collectionElementType =3D t.getTypeArguments().get( 0 ); + } + return collectionElementType; + } + @Override public AnnotationMetaAttribute visitExecutable(ExecutableType t, Element= p) { String string =3D p.getSimpleName().toString(); Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elem= entcollection/ElementCollectionTest.java (from rev 17903, jpamodelgen/trunk= /src/test/java/org/hibernate/jpamodelgen/test/inheritance/InheritanceTest.j= ava) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementc= ollection/ElementCollectionTest.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementc= ollection/ElementCollectionTest.java 2009-11-06 18:23:48 UTC (rev 17946) @@ -0,0 +1,46 @@ +// $Id$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.elementcollection; + +import org.testng.annotations.Test; + +import org.hibernate.jpamodelgen.test.util.CompilationTest; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertClassGene= rated; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertClassNotF= ound; +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertNoGenerat= edSourceFile; + +/** + * @author Hardy Ferentschik + */ +public class ElementCollectionTest extends CompilationTest { + /** + * METAGEN-8 + */ + @Test + public void testElementCollectionOnMap() { + assertClassGenerated( House.class.getName() + "_" ); + assertClassGenerated( House.class.getName() + "_" ); + // side effect of METAGEN-8 was that a meta class for String was created! + assertNoGeneratedSourceFile( String.class.getName() + "_" ); + } + + @Override + protected String getTestPackage() { + return House.class.getPackage().getName(); + } +} \ No newline at end of file Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/eleme= ntcollection/House.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementc= ollection/House.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementc= ollection/House.java 2009-11-06 18:23:48 UTC (rev 17946) @@ -0,0 +1,43 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.elementcollection; + +import java.util.Map; +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.MapKeyColumn; + +/** + * @author Hardy Ferentschik + */ +(a)Entity +public class House { + private Map roomsByName; + + @ElementCollection + @MapKeyColumn(name =3D "room_name") + public Map getRoomsByName() { + return roomsByName; + } + + public void setRoomsByName(Map roomsByName) { + this.roomsByName =3D roomsByName; + } +} + + Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/elementcollection/House.java ___________________________________________________________________ Name: svn:keywords + Id Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/eleme= ntcollection/Room.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementc= ollection/Room.java (rev 0) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementc= ollection/Room.java 2009-11-06 18:23:48 UTC (rev 17946) @@ -0,0 +1,48 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.jpamodelgen.test.elementcollection; + +import java.math.BigDecimal; +import javax.persistence.Embeddable; + +/** + * @author Hardy Ferentschik + */ +(a)Embeddable +public class Room { + private BigDecimal length; + private BigDecimal width; + + public BigDecimal getLength() { + return length; + } + + public void setLength(BigDecimal length) { + this.length =3D length; + } + + public BigDecimal getWidth() { + return width; + } + + public void setWidth(BigDecimal width) { + this.width =3D width; + } +} + + Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodel= gen/test/elementcollection/Room.java ___________________________________________________________________ Name: svn:keywords + Id Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/ut= il/CompilationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Com= pilationTest.java 2009-11-06 16:02:26 UTC (rev 17945) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Com= pilationTest.java 2009-11-06 18:23:48 UTC (rev 17946) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ /* * JBoss, Home of Professional Open Source * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors @@ -22,7 +22,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import javax.tools.Diagnostic; import javax.tools.DiagnosticCollector; import javax.tools.JavaCompiler; import javax.tools.JavaFileObject; @@ -112,7 +111,7 @@ FilenameFilter javaFileFilter =3D new FilenameFilter() { @Override public boolean accept(File dir, String name) { - return name.endsWith( ".java" ); + return name.endsWith( ".java" ) && !name.endsWith( "Test.java" ); } }; for ( File file : packageDir.listFiles( javaFileFilter ) ) { Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/ut= il/TestUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Tes= tUtil.java 2009-11-06 16:02:26 UTC (rev 17945) +++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/Tes= tUtil.java 2009-11-06 18:23:48 UTC (rev 17946) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ /* * JBoss, Home of Professional Open Source * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors @@ -17,13 +17,18 @@ */ package org.hibernate.jpamodelgen.test.util; = +import java.io.File; +import java.io.FilenameFilter; import java.lang.reflect.Field; import java.lang.reflect.GenericArrayType; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import java.util.Collection; +import java.util.Vector; = import org.testng.Assert; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.FileAssert.fail; = @@ -32,6 +37,17 @@ */ public class TestUtil { = + private static final String PATH_SEPARATOR =3D System.getProperty( "file.= separator" ); + private static final String outBaseDir; + + static { + String tmp =3D System.getProperty( "outBaseDir" ); + if ( tmp =3D=3D null ) { + fail( "The system property outBaseDir has to be set and point to the ba= se directory of the test output directory." ); + } + outBaseDir =3D tmp; + } + private TestUtil() { } = @@ -44,6 +60,25 @@ } } = + public static void assertClassNotFound(String className) { + try { + Class.forName( className ); + fail( "Class " + className + " should not have been found." ); + } + catch ( ClassNotFoundException e ) { + // success + } + } + + public static void assertNoGeneratedSourceFile(String className) { + // generate the file name + String fileName =3D className.replace( ".", PATH_SEPARATOR ); + fileName =3D fileName.concat( ".java" ); + File sourceFile =3D new File(outBaseDir + PATH_SEPARATOR + fileName); + assertFalse(sourceFile.exists(), "There should be no source file: " + fi= leName); + + } + public static void assertAbsenceOfField(String className, String fieldNam= e) throws ClassNotFoundException { assertAbsenceOfField( className, fieldName, "field should not be persist= ent" ); } Modified: jpamodelgen/trunk/src/test/suite/unit-tests.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-06 16:02:26 UTC= (rev 17945) +++ jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-06 18:23:48 UTC= (rev 17946) @@ -5,6 +5,7 @@ + --===============4509029698466712248==-- From hibernate-commits at lists.jboss.org Fri Nov 6 19:38:39 2009 Content-Type: multipart/mixed; boundary="===============2750746565679766296==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17947 - core/trunk/core/src/main/java/org/hibernate/action. Date: Fri, 06 Nov 2009 19:38:39 -0500 Message-ID: <200911070038.nA70cd5J005680@svn01.web.mwc.hst.phx2.redhat.com> --===============2750746565679766296== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: gbadner Date: 2009-11-06 19:38:39 -0500 (Fri, 06 Nov 2009) New Revision: 17947 Modified: core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.java Log: HHH-4545 : change CollectionAction.readObject() to private Modified: core/trunk/core/src/main/java/org/hibernate/action/CollectionActi= on.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.jav= a 2009-11-06 18:23:48 UTC (rev 17946) +++ core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.jav= a 2009-11-07 00:38:39 UTC (rev 17947) @@ -65,7 +65,7 @@ return collection; } = - protected void readObject(ObjectInputStream ois) throws IOException, Clas= sNotFoundException { + private void readObject(ObjectInputStream ois) throws IOException, ClassN= otFoundException { ois.defaultReadObject(); persister =3D session.getFactory().getCollectionPersister( collectionRol= e ); } --===============2750746565679766296==-- From hibernate-commits at lists.jboss.org Fri Nov 6 22:17:27 2009 Content-Type: multipart/mixed; boundary="===============0713412310401923192==" MIME-Version: 1.0 From: Media Service To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Congratulations Date: Sat, 07 Nov 2009 12:16:54 +0900 Message-ID: <000d01ca5f58$c1d198a0$6400a8c0@undeterminedid39> --===============0713412310401923192== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Congratulations!! You have won todays Macbook Air. Please open attached file and see datails. --===============0713412310401923192==-- From hibernate-commits at lists.jboss.org Mon Nov 9 12:47:23 2009 Content-Type: multipart/mixed; boundary="===============3204523248404921959==" MIME-Version: 1.0 From: DHL Service To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] DHL Tracking Number 3YMH6JJY Date: Mon, 09 Nov 2009 09:47:14 -0800 Message-ID: <000d01ca6164$abe7a7b0$6400a8c0@russiansawc76> --===============3204523248404921959== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Dear customer! The courier company was not able to deliver your parcel by your address. You may pickup the parcel at our post office personaly. The shipping label is attached to this e-mail. Please print this label to get this package at our post office. Thank you for attention. DHL Express Services. --===============3204523248404921959==-- From hibernate-commits at lists.jboss.org Mon Nov 9 23:56:04 2009 Content-Type: multipart/mixed; boundary="===============4655716573037046778==" MIME-Version: 1.0 From: DHL Service To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] DHL Tracking Number 3YMH6JJY Date: Tue, 10 Nov 2009 13:55:14 +0900 Message-ID: <000d01ca61c1$fd808080$6400a8c0@bazookasw6> --===============4655716573037046778== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Dear customer! The courier company was not able to deliver your parcel by your address. You may pickup the parcel at our post office personaly. The shipping label is attached to this e-mail. Please print this label to get this package at our post office. Thank you for attention. DHL Express Services. --===============4655716573037046778==-- From hibernate-commits at lists.jboss.org Tue Nov 10 03:38:09 2009 Content-Type: multipart/mixed; boundary="===============0179068825338534717==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17948 - in core/trunk/core/src/main/java/org/hibernate: impl and 1 other directories. Date: Tue, 10 Nov 2009 03:38:09 -0500 Message-ID: <200911100838.nAA8c9sn020460@svn01.web.mwc.hst.phx2.redhat.com> --===============0179068825338534717== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: gbadner Date: 2009-11-10 03:38:09 -0500 (Tue, 10 Nov 2009) New Revision: 17948 Added: core/trunk/core/src/main/java/org/hibernate/engine/NonFlushedChanges.java core/trunk/core/src/main/java/org/hibernate/impl/NonFlushedChangesImpl.j= ava Modified: core/trunk/core/src/main/java/org/hibernate/engine/CollectionEntry.java core/trunk/core/src/main/java/org/hibernate/engine/CollectionKey.java core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java core/trunk/core/src/main/java/org/hibernate/engine/EntityKey.java core/trunk/core/src/main/java/org/hibernate/engine/SessionImplementor.ja= va core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java core/trunk/core/src/main/java/org/hibernate/impl/StatelessSessionImpl.ja= va core/trunk/core/src/main/java/org/hibernate/util/MarkerObject.java Log: HHH-2762 : SessionImplementor.getNonFlushedChanges()/applyNonFlushedChanges= () API and initial implementation Modified: core/trunk/core/src/main/java/org/hibernate/engine/CollectionEntr= y.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/CollectionEntry.java= 2009-11-07 00:38:39 UTC (rev 17947) +++ core/trunk/core/src/main/java/org/hibernate/engine/CollectionEntry.java= 2009-11-10 08:38:09 UTC (rev 17948) @@ -266,7 +266,7 @@ } = void afterDeserialize(SessionFactoryImplementor factory) { - loadedPersister =3D factory.getCollectionPersister(role); + loadedPersister =3D ( factory =3D=3D null ? null : factory.getCollection= Persister(role) ); } = public boolean wasDereferenced() { @@ -414,7 +414,7 @@ ( String ) ois.readObject(), ( Serializable ) ois.readObject(), ( Serializable ) ois.readObject(), - session.getFactory() + ( session =3D=3D null ? null : session.getFactory() ) ); } } \ No newline at end of file Modified: core/trunk/core/src/main/java/org/hibernate/engine/CollectionKey.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/CollectionKey.java 2= 009-11-07 00:38:39 UTC (rev 17947) +++ core/trunk/core/src/main/java/org/hibernate/engine/CollectionKey.java 2= 009-11-10 08:38:09 UTC (rev 17948) @@ -128,7 +128,7 @@ ( Serializable ) ois.readObject(), ( Type ) ois.readObject(), EntityMode.parse( ( String ) ois.readObject() ), - session.getFactory() + ( session =3D=3D null ? null : session.getFactory() ) ); } } \ No newline at end of file Modified: core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java 200= 9-11-07 00:38:39 UTC (rev 17947) +++ core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java 200= 9-11-10 08:38:09 UTC (rev 17948) @@ -104,7 +104,7 @@ final boolean isBeingReplicated, final boolean loadedWithLazyPropertiesUnfetched) { this.entityName =3D entityName; - this.persister =3D factory.getEntityPersister( entityName ); + this.persister =3D ( factory =3D=3D null ? null : factory.getEntityPersi= ster( entityName ) ); this.id =3D id; this.entityMode =3D entityMode; this.status =3D status; @@ -322,7 +322,7 @@ ObjectInputStream ois, SessionImplementor session) throws IOException, ClassNotFoundExce= ption { return new EntityEntry( - session.getFactory(), + ( session =3D=3D null ? null : session.getFactory() ), ( String ) ois.readObject(), ( Serializable ) ois.readObject(), EntityMode.parse( ( String ) ois.readObject() ), Modified: core/trunk/core/src/main/java/org/hibernate/engine/EntityKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/EntityKey.java 2009-= 11-07 00:38:39 UTC (rev 17947) +++ core/trunk/core/src/main/java/org/hibernate/engine/EntityKey.java 2009-= 11-10 08:38:09 UTC (rev 17948) @@ -171,7 +171,7 @@ ( String ) ois.readObject(), ( Type ) ois.readObject(), ois.readBoolean(), - session.getFactory(), + ( session =3D=3D null ? null : session.getFactory() ), EntityMode.parse( ( String ) ois.readObject() ) ); } Added: core/trunk/core/src/main/java/org/hibernate/engine/NonFlushedChanges= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/NonFlushedChanges.ja= va (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/engine/NonFlushedChanges.ja= va 2009-11-10 08:38:09 UTC (rev 17948) @@ -0,0 +1,49 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.engine; + +/** + * This interface defines the public API for changes to an EventSource tha= t have not + * been flushed to the database. + * + * @author Gail Badner + */ + +import java.io.Serializable; +import org.hibernate.event.EventSource; + +public interface NonFlushedChanges extends Serializable { + + /** + * Extracts the non-flushed Changes from an EventSource into this NonFlus= hedChanges object. + *

+ * @param source + */ + void extractFromSession(EventSource source); + + /** + * Remove the non-flushed changes from this NonFlushedChanges object. + */ + void clear(); +} \ No newline at end of file Modified: core/trunk/core/src/main/java/org/hibernate/engine/SessionImpleme= ntor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/SessionImplementor.j= ava 2009-11-07 00:38:39 UTC (rev 17947) +++ core/trunk/core/src/main/java/org/hibernate/engine/SessionImplementor.j= ava 2009-11-10 08:38:09 UTC (rev 17948) @@ -287,6 +287,24 @@ */ int executeNativeUpdate(NativeSQLQuerySpecification specification, QueryP= arameters queryParameters) throws HibernateException; = + + /** + * Return changes to this session that have not been flushed yet. + * + * @return The non-flushed changes. + */ + public NonFlushedChanges getNonFlushedChanges() throws HibernateException; + + /** + * Apply non-flushed changes from a different session to this session. It= is assumed + * that this SessionImpl is "clean" (e.g., has no non-flushed changes, no= cached entities, + * no cached collections, no queued actions). The specified NonFlushedCha= nges object cannot + * be bound to any session. + *

+ * @param nonFlushedChanges the non-flushed changes + */ + public void applyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) t= hrows HibernateException; = + // copied from Session: = public EntityMode getEntityMode(); Added: core/trunk/core/src/main/java/org/hibernate/impl/NonFlushedChangesIm= pl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/impl/NonFlushedChangesImpl.= java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/impl/NonFlushedChangesImpl.= java 2009-11-10 08:38:09 UTC (rev 17948) @@ -0,0 +1,109 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.impl; + +/** + * An implementation of NonFlushedChanges. + * + * @author Gail Badner + */ + +import org.hibernate.engine.NonFlushedChanges; +import org.hibernate.engine.ActionQueue; +import org.hibernate.engine.StatefulPersistenceContext; +import org.hibernate.event.EventSource; +import org.hibernate.AssertionFailure; +import org.hibernate.EntityMode; + +import java.util.Map; +import java.util.HashMap; +import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class NonFlushedChangesImpl implements NonFlushedChanges { + + private static final Logger log =3D LoggerFactory.getLogger(NonFlushedCha= ngesImpl.class); + + private static class SessionNonFlushedChanges implements Serializable { + private transient EntityMode entityMode; + private transient ActionQueue actionQueue; + private transient StatefulPersistenceContext persistenceContext; + + public SessionNonFlushedChanges(EventSource session) { + this.entityMode =3D session.getEntityMode(); + this.actionQueue =3D session.getActionQueue(); + this.persistenceContext =3D ( StatefulPersistenceContext ) session.getP= ersistenceContext(); + } + + private void readObject(ObjectInputStream ois) throws IOException, Class= NotFoundException { + ois.defaultReadObject(); + entityMode =3D EntityMode.parse( ( String ) ois.readObject() ); + persistenceContext =3D StatefulPersistenceContext.deserialize( ois, nul= l ); + actionQueue =3D ActionQueue.deserialize( ois, null ); + } + + private void writeObject(ObjectOutputStream oos) throws IOException { + log.trace( "serializing SessionNonFlushedChanges" ); + oos.defaultWriteObject(); + oos.writeObject( entityMode.toString() ); + persistenceContext.serialize( oos ); + actionQueue.serialize( oos ); + } + } + private Map nonFlushedChangesByEntityMode =3D new HashMap(); + + public NonFlushedChangesImpl( EventSource session ) { + extractFromSession( session ); + } + + public void extractFromSession(EventSource session) { + if ( nonFlushedChangesByEntityMode.containsKey( session.getEntityMode() = ) ) { + throw new AssertionFailure( "Already has non-flushed changes for entity= mode: " + session.getEntityMode() ); + } + nonFlushedChangesByEntityMode.put( session.getEntityMode(), new SessionN= onFlushedChanges( session ) ); + } + + private SessionNonFlushedChanges getSessionNonFlushedChanges(EntityMode e= ntityMode) { + return ( SessionNonFlushedChanges ) nonFlushedChangesByEntityMode.get( e= ntityMode ); + } + + /* package-protected */ + ActionQueue getActionQueue(EntityMode entityMode) { + return getSessionNonFlushedChanges( entityMode ).actionQueue; + } = + + /* package-protected */ + StatefulPersistenceContext getPersistenceContext(EntityMode entityMode) { + return getSessionNonFlushedChanges( entityMode ).persistenceContext; + } + + public void clear() { + nonFlushedChangesByEntityMode.clear(); + } +} \ No newline at end of file Modified: core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java 2009-= 11-07 00:38:39 UTC (rev 17947) +++ core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java 2009-= 11-10 08:38:09 UTC (rev 17948) @@ -28,6 +28,8 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; import java.sql.Connection; import java.sql.SQLException; import java.util.Collection; @@ -72,6 +74,7 @@ import org.hibernate.engine.CollectionEntry; import org.hibernate.engine.EntityEntry; import org.hibernate.engine.EntityKey; +import org.hibernate.engine.NonFlushedChanges; import org.hibernate.engine.PersistenceContext; import org.hibernate.engine.QueryParameters; import org.hibernate.engine.StatefulPersistenceContext; @@ -127,9 +130,11 @@ import org.hibernate.stat.SessionStatistics; import org.hibernate.stat.SessionStatisticsImpl; import org.hibernate.type.Type; +import org.hibernate.type.SerializationException; import org.hibernate.util.ArrayHelper; import org.hibernate.util.CollectionHelper; import org.hibernate.util.StringHelper; +import org.hibernate.util.SerializationHelper; = = /** @@ -377,6 +382,138 @@ } } = + /** + * Return changes to this session and its child sessions that have not be= en flushed yet. + *

+ * @return The non-flushed changes. + */ + public NonFlushedChanges getNonFlushedChanges() throws HibernateException= { + errorIfClosed(); + checkTransactionSynchStatus(); + NonFlushedChanges nonFlushedChanges =3D new NonFlushedChangesImpl( this = ); + if ( childSessionsByEntityMode !=3D null ) { + Iterator it =3D childSessionsByEntityMode.values().iterator(); + while ( it.hasNext() ) { + nonFlushedChanges.extractFromSession( ( EventSource ) it.next() ); + } + } + return nonFlushedChanges; + } + + /** + * Apply non-flushed changes from a different session to this session. It= is assumed + * that this SessionImpl is "clean" (e.g., has no non-flushed changes, no= cached entities, + * no cached collections, no queued actions). The specified NonFlushedCha= nges object cannot + * be bound to any session. + *

+ * @param nonFlushedChanges the non-flushed changes + */ + public void applyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) t= hrows HibernateException { + errorIfClosed(); + checkTransactionSynchStatus(); + replacePersistenceContext( ( ( NonFlushedChangesImpl ) nonFlushedChanges= ).getPersistenceContext( entityMode) ); + replaceActionQueue( ( ( NonFlushedChangesImpl ) nonFlushedChanges ).getA= ctionQueue( entityMode ) ); + if ( childSessionsByEntityMode !=3D null ) { + for ( Iterator it =3D childSessionsByEntityMode.values().iterator(); it= .hasNext(); ) { + ( ( SessionImpl ) it.next() ).applyNonFlushedChanges( nonFlushedChange= s ); + } + } + } + + private void replacePersistenceContext(StatefulPersistenceContext persist= enceContextNew) { + if ( persistenceContextNew.getSession() !=3D null ) { + throw new IllegalStateException( "new persistence context is already co= nnected to a session " ); + } + persistenceContext.clear(); + ObjectInputStream ois =3D null; + try { + ois =3D new ObjectInputStream( new ByteArrayInputStream( serializePersi= stenceContext( persistenceContextNew ) ) ); + this.persistenceContext =3D StatefulPersistenceContext.deserialize( ois= , this ); + } + catch (IOException ex) { + throw new SerializationException( "could not deserialize the persistenc= e context", ex ); + } + catch (ClassNotFoundException ex) { + throw new SerializationException( "could not deserialize the persistenc= e context", ex ); + } + finally { + try { + if (ois !=3D null) ois.close(); + } + catch (IOException ex) {} + } + } + + private static byte[] serializePersistenceContext(StatefulPersistenceCont= ext pc) { + ByteArrayOutputStream baos =3D new ByteArrayOutputStream( 512 ); + ObjectOutputStream oos =3D null; + try { + oos =3D new ObjectOutputStream( baos ); + ( ( StatefulPersistenceContext ) pc ).serialize( oos ); + } + catch (IOException ex) { + throw new SerializationException( "could not serialize persistence cont= ext", ex ); + } + finally { + if ( oos !=3D null ) { + try { + oos.close(); + } + catch( IOException ex ) { + //ignore + } + } + } + return baos.toByteArray(); + } + + private void replaceActionQueue(ActionQueue actionQueueNew) { + if ( actionQueue.hasAnyQueuedActions() ) { + throw new IllegalStateException( "cannot replace an ActionQueue with qu= eued actions " ); + } + actionQueue.clear(); + ObjectInputStream ois =3D null; + try { + ois =3D new ObjectInputStream( new ByteArrayInputStream( serializeActio= nQueue( actionQueueNew ) ) ); + actionQueue =3D ActionQueue.deserialize( ois, this ); + } + catch (IOException ex) { + throw new SerializationException( "could not deserialize the action que= ue", ex ); + } + catch (ClassNotFoundException ex) { + throw new SerializationException( "could not deserialize the action que= ue", ex ); + } + finally { + try { + if (ois !=3D null) ois.close(); + } + catch (IOException ex) {} + } + } + + private static byte[] serializeActionQueue(ActionQueue actionQueue) { + ByteArrayOutputStream baos =3D new ByteArrayOutputStream( 512 ); + ObjectOutputStream oos =3D null; + try { + oos =3D new ObjectOutputStream( baos ); + actionQueue.serialize( oos ); + } + catch (IOException ex) { + throw new SerializationException( "could not serialize action queue", e= x ); + } + finally { + if ( oos !=3D null ) { + try { + oos.close(); + } + catch( IOException ex ) { + //ignore + } + } + } + return baos.toByteArray(); + } + public boolean shouldAutoClose() { return isAutoCloseSessionEnabled() && !isClosed(); } Modified: core/trunk/core/src/main/java/org/hibernate/impl/StatelessSession= Impl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/impl/StatelessSessionImpl.j= ava 2009-11-07 00:38:39 UTC (rev 17947) +++ core/trunk/core/src/main/java/org/hibernate/impl/StatelessSessionImpl.j= ava 2009-11-10 08:38:09 UTC (rev 17948) @@ -55,6 +55,7 @@ import org.hibernate.engine.StatefulPersistenceContext; import org.hibernate.engine.Versioning; import org.hibernate.engine.LoadQueryInfluencers; +import org.hibernate.engine.NonFlushedChanges; import org.hibernate.engine.query.HQLQueryPlan; import org.hibernate.engine.query.NativeSQLQueryPlan; import org.hibernate.engine.query.sql.NativeSQLQuerySpecification; @@ -621,6 +622,14 @@ = public void flush() {} = + public NonFlushedChanges getNonFlushedChanges() { + throw new UnsupportedOperationException(); + } + + public void applyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) { + throw new UnsupportedOperationException(); + } + public String getFetchProfile() { return null; } Modified: core/trunk/core/src/main/java/org/hibernate/util/MarkerObject.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/util/MarkerObject.java 2009= -11-07 00:38:39 UTC (rev 17947) +++ core/trunk/core/src/main/java/org/hibernate/util/MarkerObject.java 2009= -11-10 08:38:09 UTC (rev 17948) @@ -24,10 +24,12 @@ */ package org.hibernate.util; = +import java.io.Serializable; + /** * @author Gavin King */ -public class MarkerObject { +public class MarkerObject implements Serializable { private String name; = public MarkerObject(String name) { --===============0179068825338534717==-- From hibernate-commits at lists.jboss.org Tue Nov 10 05:15:43 2009 Content-Type: multipart/mixed; boundary="===============7328357890194873357==" MIME-Version: 1.0 From: DHL Service To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] DHL Tracking Number 3YMH6JJY Date: Tue, 10 Nov 2009 18:15:12 +0800 Message-ID: <000d01ca61ee$b0cd5d80$6400a8c0@westernizec0116> --===============7328357890194873357== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Dear customer! The courier company was not able to deliver your parcel by your address. You may pickup the parcel at our post office personaly. The shipping label is attached to this e-mail. Please print this label to get this package at our post office. Thank you for attention. DHL Express Services. --===============7328357890194873357==-- From hibernate-commits at lists.jboss.org Tue Nov 10 06:27:22 2009 Content-Type: multipart/mixed; boundary="===============5655247159164183537==" MIME-Version: 1.0 From: DHL Service To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] DHL Tracking Number 3YMH6JJY Date: Tue, 10 Nov 2009 06:25:20 -0500 Message-ID: <000d01ca61f8$7cbdfd10$6400a8c0@paramedicwzm42> --===============5655247159164183537== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Dear customer! The courier company was not able to deliver your parcel by your address. You may pickup the parcel at our post office personaly. The shipping label is attached to this e-mail. Please print this label to get this package at our post office. Thank you for attention. DHL Express Services. --===============5655247159164183537==-- From hibernate-commits at lists.jboss.org Tue Nov 10 13:17:47 2009 Content-Type: multipart/mixed; boundary="===============8022576365587244167==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17949 - core/branches/Branch_3_3/documentation/manual/src/main/docbook/en-US/content. Date: Tue, 10 Nov 2009 13:17:47 -0500 Message-ID: <200911101817.nAAIHlV8005773@svn01.web.mwc.hst.phx2.redhat.com> --===============8022576365587244167== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-10 13:17:46 -0500 (Tue, 10 Nov 2009) New Revision: 17949 Modified: core/branches/Branch_3_3/documentation/manual/src/main/docbook/en-US/con= tent/performance.xml Log: HHH-4550 - Document that update-timestamps cache region should not be confi= gured for expiry. Modified: core/branches/Branch_3_3/documentation/manual/src/main/docbook/en= -US/content/performance.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/documentation/manual/src/main/docbook/en-US/co= ntent/performance.xml 2009-11-10 08:38:09 UTC (rev 17948) +++ core/branches/Branch_3_3/documentation/manual/src/main/docbook/en-US/co= ntent/performance.xml 2009-11-10 18:17:46 UTC (rev 17949) @@ -699,21 +699,21 @@ Hashtable (not intended for production use) org.hibernate.cache.HashtableCacheProvider= memory - + yes EHCache org.hibernate.cache.EhCacheProvider memory, disk - + yes OSCache org.hibernate.cache.OSCacheProvider memory, disk - + yes @@ -721,7 +721,7 @@ org.hibernate.cache.SwarmCacheProvider clustered (ip multicast) yes (clustered invalidation) - + JBoss Cache 1.x @@ -902,41 +902,41 @@ yes yes yes - + EHCache yes yes yes - + OSCache yes yes yes - + SwarmCache yes yes - - + + JBoss Cache 1.x yes - - + + yes JBoss Cache 2 yes - - + + yes @@ -1042,56 +1042,98 @@ hibernate.cache.use_structured_entries true]]> = = - = + The Query Cache = Query result sets can also be cached. This is only useful for = queries that are run - frequently with the same parameters. You will first need to en= able the query cache: + frequently with the same parameters. = - = - = - - This setting creates two new cache regions: one holding cached= query = - result sets (org.hibernate.cache.StandardQueryCache), the other = - holding timestamps of the most recent updates to queryable tab= les = - (org.hibernate.cache.UpdateTimestampsCache)= . Note that the query - cache does not cache the state of the actual entities in the r= esult set; it caches = - only identifier values and results of value type. The query ca= che should always be - used in conjunction with the second-level cache. - - = - - Most queries do not benefit from caching, so by default, queri= es are not cached. To - enable caching, call Query.setCacheable(true). This call allows - the query to look for existing cache results or add its result= s to the cache when - it is executed. - - = - - If you require fine-grained control over query cache expiratio= n policies, you can - specify a named cache region for a particular query by calling = - Query.setCacheRegion(). - - = - + + Enabling query caching + + Caching of query results introduces some overhead in terms= of your applications normal + transactional processing. For example, if you cache resul= ts of a query against Person + Hibernate will need to keep track of when those results sh= ould be invalidated because + changes have been committed against Person. That, coupled= with the fact that most + applications simply gain no benefit from caching query res= ults, leads Hibernate to + disable caching of query results by default. To use query= caching, you will first + need to enable the query cache: + + + + This setting creates two new cache regions: + + + + org.hibernate.cache.StandardQueryCa= che, holding + the cached query results + + + + + org.hibernate.cache.UpdateTimestamp= sCache, holding + timestamps of the most recent updates to query= able tables. These are used + to validate the results as they are served fro= m the query cache. + + + + + + + If you configure your underlying cache implementation = to use expiry or + timeouts is is very important that the cache timeout o= f the underlying + cache region for the UpdateTimestampsCache be set to a= higher value than + the timeouts of any of the query caches. In fact, we = recommend that the + the UpdateTimestampsCache region not be configured for= expiry at all. Note, + in particular, that an LRU cache expiry policy is neve= r appropriate. + + + + As mentioned above, most queries do not benefit from cachi= ng or their results. So by + default, individual queries are not cached even after enab= ling query caching. To enable + results caching for a particular query, call + org.hibernate.Query.setCacheable(true).= This call allows the query + to look for existing cache results or add its results to t= he cache when it is executed. + + + + The query cache does not cache the state of the actual= entities in the cache; it + caches only identifier values and results of value typ= e. For this reaso, the query + cache should always be used in conjunction with the se= cond-level cache for those + entities expected to be cached as part of a query resu= lt cache (just as with + collection caching). + + + = - - If the query should force a refresh of its query cache region,= you should call - Query.setCacheMode(CacheMode.REFRESH). This= is particularly useful = - in cases where underlying data may have been updated via a sep= arate process (i.e., = - not modified through Hibernate) and allows the application to = selectively refresh = - particular query result sets. This is a more efficient alterna= tive to eviction of = - a query cache region via SessionFactory.evictQueries(= ). - + + Query cache regions + + If you require fine-grained control over query cache expir= ation policies, you can + specify a named cache region for a particular query by cal= ling + Query.setCacheRegion(). + + = + + If you want to force the query cache to refresh one of its= regions (disregard any + cached results it finds there) you can use + org.hibernate.Query.setCacheMode(CacheMode.REFRES= H). In conjunction + with the region you have defined for the given query, Hibe= rnate will selectively force + the results cached in that particular region to be refresh= ed. This is particularly useful + in cases where underlying data may have been updated via a= separate process and is a far more + efficient alternative to bulk eviction of the region via + org.hibernate.SessionFactory.evictQueries(). + + = --===============8022576365587244167==-- From hibernate-commits at lists.jboss.org Tue Nov 10 15:00:15 2009 Content-Type: multipart/mixed; boundary="===============1350778082418888776==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17950 - core/trunk/documentation/manual/src/main/docbook/en-US/content. Date: Tue, 10 Nov 2009 15:00:15 -0500 Message-ID: <200911102000.nAAK0FCZ023618@svn01.web.mwc.hst.phx2.redhat.com> --===============1350778082418888776== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-10 15:00:14 -0500 (Tue, 10 Nov 2009) New Revision: 17950 Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/performan= ce.xml Log: HHH-4550 - Document that update-timestamps cache region should not be confi= gured for expiry. Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/pe= rformance.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/documentation/manual/src/main/docbook/en-US/content/performa= nce.xml 2009-11-10 18:17:46 UTC (rev 17949) +++ core/trunk/documentation/manual/src/main/docbook/en-US/content/performa= nce.xml 2009-11-10 20:00:14 UTC (rev 17950) @@ -767,21 +767,21 @@ Hashtable (not intended for production use) org.hibernate.cache.HashtableCacheProvider= memory - + yes EHCache org.hibernate.cache.EhCacheProvider memory, disk - + yes OSCache org.hibernate.cache.OSCacheProvider memory, disk - + yes @@ -789,7 +789,7 @@ org.hibernate.cache.SwarmCacheProvider clustered (ip multicast) yes (clustered invalidation) - + JBoss Cache 1.x @@ -970,41 +970,41 @@ yes yes yes - + EHCache yes yes yes - + OSCache yes yes yes - + SwarmCache yes yes - - + + JBoss Cache 1.x yes - - + + yes JBoss Cache 2 yes - - + + yes @@ -1110,56 +1110,98 @@ hibernate.cache.use_structured_entries true]]> = = - = + The Query Cache = Query result sets can also be cached. This is only useful for = queries that are run - frequently with the same parameters. You will first need to en= able the query cache: + frequently with the same parameters. = - = - = - - This setting creates two new cache regions: one holding cached= query = - result sets (org.hibernate.cache.StandardQueryCache), the other = - holding timestamps of the most recent updates to queryable tab= les = - (org.hibernate.cache.UpdateTimestampsCache)= . Note that the query - cache does not cache the state of the actual entities in the r= esult set; it caches = - only identifier values and results of value type. The query ca= che should always be - used in conjunction with the second-level cache. - - = - - Most queries do not benefit from caching, so by default, queri= es are not cached. To - enable caching, call Query.setCacheable(true). This call allows - the query to look for existing cache results or add its result= s to the cache when - it is executed. - - = - - If you require fine-grained control over query cache expiratio= n policies, you can - specify a named cache region for a particular query by calling = - Query.setCacheRegion(). - - = - + + Enabling query caching + + Caching of query results introduces some overhead in terms= of your applications normal + transactional processing. For example, if you cache resul= ts of a query against Person + Hibernate will need to keep track of when those results sh= ould be invalidated because + changes have been committed against Person. That, coupled= with the fact that most + applications simply gain no benefit from caching query res= ults, leads Hibernate to + disable caching of query results by default. To use query= caching, you will first + need to enable the query cache: + + + + This setting creates two new cache regions: + + + + org.hibernate.cache.StandardQueryCa= che, holding + the cached query results + + + + + org.hibernate.cache.UpdateTimestamp= sCache, holding + timestamps of the most recent updates to query= able tables. These are used + to validate the results as they are served fro= m the query cache. + + + + + + + If you configure your underlying cache implementation = to use expiry or + timeouts is is very important that the cache timeout o= f the underlying + cache region for the UpdateTimestampsCache be set to a= higher value than + the timeouts of any of the query caches. In fact, we = recommend that the + the UpdateTimestampsCache region not be configured for= expiry at all. Note, + in particular, that an LRU cache expiry policy is neve= r appropriate. + + + + As mentioned above, most queries do not benefit from cachi= ng or their results. So by + default, individual queries are not cached even after enab= ling query caching. To enable + results caching for a particular query, call + org.hibernate.Query.setCacheable(true).= This call allows the query + to look for existing cache results or add its results to t= he cache when it is executed. + + + + The query cache does not cache the state of the actual= entities in the cache; it + caches only identifier values and results of value typ= e. For this reaso, the query + cache should always be used in conjunction with the se= cond-level cache for those + entities expected to be cached as part of a query resu= lt cache (just as with + collection caching). + + + = - - If the query should force a refresh of its query cache region,= you should call - Query.setCacheMode(CacheMode.REFRESH). This= is particularly useful = - in cases where underlying data may have been updated via a sep= arate process (i.e., = - not modified through Hibernate) and allows the application to = selectively refresh = - particular query result sets. This is a more efficient alterna= tive to eviction of = - a query cache region via SessionFactory.evictQueries(= ). - + + Query cache regions + + If you require fine-grained control over query cache expir= ation policies, you can + specify a named cache region for a particular query by cal= ling + Query.setCacheRegion(). + + = + + If you want to force the query cache to refresh one of its= regions (disregard any + cached results it finds there) you can use + org.hibernate.Query.setCacheMode(CacheMode.REFRES= H). In conjunction + with the region you have defined for the given query, Hibe= rnate will selectively force + the results cached in that particular region to be refresh= ed. This is particularly useful + in cases where underlying data may have been updated via a= separate process and is a far more + efficient alternative to bulk eviction of the region via + org.hibernate.SessionFactory.evictQueries(). + + = --===============1350778082418888776==-- From hibernate-commits at lists.jboss.org Tue Nov 10 16:26:50 2009 Content-Type: multipart/mixed; boundary="===============6885228020373742028==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17951 - core/trunk/core/src/main/java/org/hibernate/engine/jdbc. Date: Tue, 10 Nov 2009 16:26:50 -0500 Message-ID: <200911102126.nAALQokv010436@svn01.web.mwc.hst.phx2.redhat.com> --===============6885228020373742028== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-10 16:26:50 -0500 (Tue, 10 Nov 2009) New Revision: 17951 Modified: core/trunk/core/src/main/java/org/hibernate/engine/jdbc/ContextualLobCre= ator.java Log: HHH-4560 - JDBC4 support inadvertently missed 1.4 compatibility Modified: core/trunk/core/src/main/java/org/hibernate/engine/jdbc/Contextua= lLobCreator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/jdbc/ContextualLobCr= eator.java 2009-11-10 20:00:14 UTC (rev 17950) +++ core/trunk/core/src/main/java/org/hibernate/engine/jdbc/ContextualLobCr= eator.java 2009-11-10 21:26:50 UTC (rev 17951) @@ -36,6 +36,7 @@ import java.lang.reflect.InvocationTargetException; = import org.hibernate.HibernateException; +import org.hibernate.JDBCException; = /** * {@link LobCreator} implementation using contextual creation against the= JDBC {@link java.sql.Connection} class's LOB creation @@ -70,7 +71,7 @@ return blob; } catch ( SQLException e ) { - throw new IllegalStateException( "Unable to set BLOB bytes after creati= on", e ); + throw new JDBCException( "Unable to set BLOB bytes after creation", e ); } } = @@ -88,10 +89,10 @@ return blob; } catch ( SQLException e ) { - throw new IllegalStateException( "Unable to prepare BLOB binary stream = for writing", e ); + throw new JDBCException( "Unable to prepare BLOB binary stream for writ= ing",e ); } catch ( IOException e ) { - throw new IllegalStateException( "Unable to write stream contents to BL= OB", e ); + throw new HibernateException( "Unable to write stream contents to BLOB"= , e ); } } = @@ -114,7 +115,7 @@ return clob; } catch ( SQLException e ) { - throw new IllegalStateException( "Unable to set CLOB string after creat= ion", e ); + throw new JDBCException( "Unable to set CLOB string after creation", e = ); } } = @@ -131,10 +132,10 @@ return clob; } catch ( SQLException e ) { - throw new IllegalStateException( "Unable to prepare CLOB stream for wri= ting", e ); + throw new JDBCException( "Unable to prepare CLOB stream for writing", e= ); } catch ( IOException e ) { - throw new IllegalStateException( "Unable to write CLOB stream content",= e ); + throw new HibernateException( "Unable to write CLOB stream content", e = ); } } = @@ -157,7 +158,7 @@ return clob; } catch ( SQLException e ) { - throw new IllegalStateException( "Unable to set NCLOB string after crea= tion", e ); + throw new JDBCException( "Unable to set NCLOB string after creation", e= ); } } = @@ -174,10 +175,10 @@ return clob; } catch ( SQLException e ) { - throw new IllegalStateException( "Unable to prepare NCLOB stream for wr= iting", e ); + throw new JDBCException( "Unable to prepare NCLOB stream for writing", = e ); } catch ( IOException e ) { - throw new IllegalStateException( "Unable to write NCLOB stream content"= , e ); + throw new HibernateException( "Unable to write NCLOB stream content", e= ); } } = @@ -216,11 +217,11 @@ } catch ( AbstractMethodError e ) { // this again is a big big error... - throw new IllegalStateException( "Useable implementation of " + creati= onMethod.getName() + " not found.", e ); + throw new IllegalStateException( "Useable implementation of " + creati= onMethod.getName() + " not found." ); } catch ( IllegalAccessException e ) { // this again is a big big error... - throw new IllegalStateException( "Illegal access attempt on JDBC metho= d " + creationMethod.getName(), e ); + throw new IllegalStateException( "Illegal access attempt on JDBC metho= d " + creationMethod.getName() ); } } } @@ -231,7 +232,7 @@ } catch ( NoSuchMethodException e ) { // this is a big big error if we get here and these methods are not par= t of the Connection interface... - throw new IllegalStateException( "JDBC driver did not implement " + met= hodName, e ); + throw new IllegalStateException( "JDBC driver did not implement " + met= hodName); } } } --===============6885228020373742028==-- From hibernate-commits at lists.jboss.org Tue Nov 10 16:27:01 2009 Content-Type: multipart/mixed; boundary="===============6436804535288744073==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17952 - core/trunk/core. Date: Tue, 10 Nov 2009 16:27:01 -0500 Message-ID: <200911102127.nAALR1jx010462@svn01.web.mwc.hst.phx2.redhat.com> --===============6436804535288744073== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-10 16:27:01 -0500 (Tue, 10 Nov 2009) New Revision: 17952 Modified: core/trunk/core/pom.xml Log: HHH-4548 - Alter poms to not use javax.* artifacts under Sun proprietary li= cense Modified: core/trunk/core/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/pom.xml 2009-11-10 21:26:50 UTC (rev 17951) +++ core/trunk/core/pom.xml 2009-11-10 21:27:01 UTC (rev 17952) @@ -44,33 +44,19 @@ = - org.jboss.javaee - jboss-transaction-api - 1.0.1.GA - - - org.jboss.javaee - jboss-servlet-api - - - org.jboss.logging - jboss-logging-spi - - - org.jboss - jboss-common-core - - + javax.transaction + jta + 1.1 org.jboss.javaee jboss-jacc-api - 1.1.0.GA + 1.1.1-SNAPSHOT provided - org.jboss.javaee - jboss-servlet-api + jboss.web + servlet-api org.jboss.logging --===============6436804535288744073==-- From hibernate-commits at lists.jboss.org Tue Nov 10 16:59:05 2009 Content-Type: multipart/mixed; boundary="===============4324474679680841021==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17953 - core/branches/Branch_3_3/core. Date: Tue, 10 Nov 2009 16:59:05 -0500 Message-ID: <200911102159.nAALx5Ct017064@svn01.web.mwc.hst.phx2.redhat.com> --===============4324474679680841021== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-10 16:59:05 -0500 (Tue, 10 Nov 2009) New Revision: 17953 Modified: core/branches/Branch_3_3/core/pom.xml Log: HHH-4548 - Alter poms to not use javax.* artifacts under Sun proprietary li= cense Modified: core/branches/Branch_3_3/core/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/core/pom.xml 2009-11-10 21:27:01 UTC (rev 1795= 2) +++ core/branches/Branch_3_3/core/pom.xml 2009-11-10 21:59:05 UTC (rev 1795= 3) @@ -44,33 +44,19 @@ = - org.jboss.javaee - jboss-transaction-api - 1.0.1.GA - - - org.jboss.javaee - jboss-servlet-api - - - org.jboss.logging - jboss-logging-spi - - - org.jboss - jboss-common-core - - + javax.transaction + jta + 1.1 org.jboss.javaee jboss-jacc-api - 1.1.0.GA + 1.1.1-SNAPSHOT provided - org.jboss.javaee - jboss-servlet-api + jboss.web + servlet-api org.jboss.logging --===============4324474679680841021==-- From hibernate-commits at lists.jboss.org Tue Nov 10 20:20:06 2009 Content-Type: multipart/mixed; boundary="===============5849935761335123008==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Try this stuff for relax Date: Wed, 11 Nov 2009 09:19:19 +0800 Message-ID: <000d01ca626c$fe4d0190$6400a8c0@metastasizenk80> --===============5849935761335123008== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable I use this stuff for relax http://www.google.com/reader/item/tag:google.com,2005:reader/item/9da9dea4d= 25afa4f --===============5849935761335123008==-- From hibernate-commits at lists.jboss.org Wed Nov 11 00:58:21 2009 Content-Type: multipart/mixed; boundary="===============0659001772025442927==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17954 - in core/branches/Branch_3_3/core/src/main/java/org/hibernate: jdbc and 1 other directory. Date: Wed, 11 Nov 2009 00:58:21 -0500 Message-ID: <200911110558.nAB5wLgR016088@svn01.web.mwc.hst.phx2.redhat.com> --===============0659001772025442927== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-11 00:58:21 -0500 (Wed, 11 Nov 2009) New Revision: 17954 Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/engine/transac= tion/Isolater.java core/branches/Branch_3_3/core/src/main/java/org/hibernate/jdbc/Batcher.j= ava Log: HHH-4561 - Deprecate openConnection()/closeConnection() methods on Batcher = interface Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/engine/= transaction/Isolater.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/core/src/main/java/org/hibernate/engine/transa= ction/Isolater.java 2009-11-10 21:59:05 UTC (rev 17953) +++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/engine/transa= ction/Isolater.java 2009-11-11 05:58:21 UTC (rev 17954) @@ -124,14 +124,14 @@ transactionManager.begin(); } = - connection =3D session.getBatcher().openConnection(); + connection =3D session.getFactory().getConnectionProvider().getConnect= ion(); = // perform the actual work work.doWork( connection ); = // if everything went ok, commit the transaction and close the obtained // connection handle... - session.getBatcher().closeConnection( connection ); + session.getFactory().getConnectionProvider().closeConnection( connecti= on ); = if ( transacted ) { transactionManager.commit(); @@ -144,7 +144,7 @@ caughtException =3D true; try { if ( connection !=3D null && !connection.isClosed() ) { - session.getBatcher().closeConnection( connection ); + session.getFactory().getConnectionProvider().closeConnection( connec= tion ); } } catch( Throwable ignore ) { @@ -176,6 +176,7 @@ } catch( Throwable t ) { if ( !caughtException ) { + //noinspection ThrowFromFinallyBlock throw new HibernateException( "unable to resume previously suspende= d transaction", t ); } } @@ -199,7 +200,7 @@ Connection connection =3D null; boolean wasAutoCommit =3D false; try { - connection =3D session.getBatcher().openConnection(); + connection =3D session.getFactory().getConnectionProvider().getConnect= ion(); = if ( transacted ) { if ( connection.getAutoCommit() ) { @@ -248,7 +249,12 @@ log.trace( "was unable to reset connection back to auto-commit" ); } } - session.getBatcher().closeConnection( connection ); + try { + session.getFactory().getConnectionProvider().closeConnection( connec= tion ); + } + catch ( Exception ignore ) { + log.info( "Unable to release isolated connection [" + ignore + "]" ); + } } } } Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/jdbc/Ba= tcher.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/core/src/main/java/org/hibernate/jdbc/Batcher.= java 2009-11-10 21:59:05 UTC (rev 17953) +++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/jdbc/Batcher.= java 2009-11-11 05:58:21 UTC (rev 17954) @@ -165,10 +165,14 @@ = /** * Obtain a JDBC connection + * + * @deprecated Obtain connections from {@link ConnectionProvider} instead */ public Connection openConnection() throws HibernateException; /** * Dispose of the JDBC connection + * + * @deprecated Obtain connections from {@link ConnectionProvider} instead */ public void closeConnection(Connection conn) throws HibernateException; = --===============0659001772025442927==-- From hibernate-commits at lists.jboss.org Wed Nov 11 00:58:43 2009 Content-Type: multipart/mixed; boundary="===============6256567935343890472==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17955 - in core/trunk/core/src/main/java/org/hibernate: jdbc and 1 other directory. Date: Wed, 11 Nov 2009 00:58:42 -0500 Message-ID: <200911110558.nAB5wgnd016132@svn01.web.mwc.hst.phx2.redhat.com> --===============6256567935343890472== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-11 00:58:42 -0500 (Wed, 11 Nov 2009) New Revision: 17955 Modified: core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater.= java core/trunk/core/src/main/java/org/hibernate/jdbc/Batcher.java Log: HHH-4561 - Deprecate openConnection()/closeConnection() methods on Batcher = interface Modified: core/trunk/core/src/main/java/org/hibernate/engine/transaction/Is= olater.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater= .java 2009-11-11 05:58:21 UTC (rev 17954) +++ core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater= .java 2009-11-11 05:58:42 UTC (rev 17955) @@ -28,12 +28,15 @@ import java.sql.SQLException; import javax.transaction.Transaction; import javax.transaction.TransactionManager; +import javax.transaction.SystemException; +import javax.transaction.NotSupportedException; = import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.hibernate.HibernateException; import org.hibernate.engine.SessionImplementor; import org.hibernate.exception.JDBCExceptionHelper; +import org.hibernate.exception.SQLExceptionConverter; = /** * Class which provides the isolation semantics required by @@ -108,80 +111,116 @@ = public void delegateWork(IsolatedWork work, boolean transacted) throws H= ibernateException { TransactionManager transactionManager =3D session.getFactory().getTrans= actionManager(); - Transaction surroundingTransaction =3D null; - Connection connection =3D null; - boolean caughtException =3D false; = try { - // First we need to suspend any current JTA transaction and obtain - // a JDBC connection - surroundingTransaction =3D transactionManager.suspend(); + // First we suspend any current JTA transaction + Transaction surroundingTransaction =3D transactionManager.suspend(); if ( log.isDebugEnabled() ) { log.debug( "surrounding JTA transaction suspended [" + surroundingTra= nsaction + "]" ); } = - if ( transacted ) { - transactionManager.begin(); + boolean hadProblems =3D false; + try { + // then peform the requested work + if ( transacted ) { + doTheWorkInNewTransaction( work, transactionManager ); + } + else { + doTheWorkInNoTransaction( work ); + } } + catch ( HibernateException e ) { + hadProblems =3D true; + throw e; + } + finally { + try { + transactionManager.resume( surroundingTransaction ); + if ( log.isDebugEnabled() ) { + log.debug( "surrounding JTA transaction resumed [" + surroundingTra= nsaction + "]" ); + } + } + catch( Throwable t ) { + // if the actually work had an error use that, otherwise error based= on t + if ( !hadProblems ) { + //noinspection ThrowFromFinallyBlock + throw new HibernateException( "Unable to resume previously suspende= d transaction", t ); + } + } + } + } + catch ( SystemException e ) { + throw new HibernateException( "Unable to suspend current JTA transacti= on", e ); + } + } = - connection =3D session.getBatcher().openConnection(); + private void doTheWorkInNewTransaction(IsolatedWork work, TransactionMan= ager transactionManager) { + try { + // start the new isolated transaction + transactionManager.begin(); = - // doAfterTransactionCompletion the actual work - work.doWork( connection ); - - // if everything went ok, commit the transaction and close the obtained - // connection handle... - session.getBatcher().closeConnection( connection ); - - if ( transacted ) { + try { + doTheWork( work ); + // if everythign went ok, commit the isolated transaction transactionManager.commit(); } - } - catch( Throwable t ) { - // at some point the processing went bad, so we need to: - // 1) make sure the connection handle gets released - // 2) try to cleanup the JTA context as much as possible - caughtException =3D true; - try { - if ( connection !=3D null && !connection.isClosed() ) { - session.getBatcher().closeConnection( connection ); - } - } - catch( Throwable ignore ) { - log.trace( "unable to release connection on exception [" + ignore + "= ]" ); - } - if ( transacted ) { + catch ( Exception e ) { try { transactionManager.rollback(); } - catch( Throwable ignore ) { - log.trace( "unable to rollback new transaction on exception [" + ign= ore + "]" ); + catch ( Exception ignore ) { + log.info( "Unable to rollback isolated transaction on error [" + e += "] : [" + ignore + "]" ); } } - // finally handle the exception - if ( t instanceof HibernateException ) { - throw ( HibernateException ) t; + } + catch ( SystemException e ) { + throw new HibernateException( "Unable to start isolated transaction", = e ); + } + catch ( NotSupportedException e ) { + throw new HibernateException( "Unable to start isolated transaction", = e ); + } + } + + private void doTheWorkInNoTransaction(IsolatedWork work) { + doTheWork( work ); + } + + private void doTheWork(IsolatedWork work) { + try { + // obtain our isolated connection + Connection connection =3D session.getFactory().getConnectionProvider()= .getConnection(); + try { + // do the actual work + work.doWork( connection ); } - else { - throw new HibernateException( "error performing isolated work", t ); + catch ( HibernateException e ) { + throw e; } - } - finally { - if ( surroundingTransaction !=3D null ) { + catch ( Exception e ) { + throw new HibernateException( "Unable to perform isolated work", e ); + } + finally { try { - transactionManager.resume( surroundingTransaction ); - if ( log.isDebugEnabled() ) { - log.debug( "surrounding JTA transaction resumed [" + surroundingTra= nsaction + "]" ); - } + // no matter what, release the connection (handle) + session.getFactory().getConnectionProvider().closeConnection( connec= tion ); } - catch( Throwable t ) { - if ( !caughtException ) { - throw new HibernateException( "unable to resume previously suspende= d transaction", t ); - } + catch ( Throwable ignore ) { + log.info( "Unable to release isolated connection [" + ignore + "]" ); } } } + catch ( SQLException sqle ) { + throw JDBCExceptionHelper.convert( + sqlExceptionConverter(), + sqle, + "unable to obtain isolated JDBC connection" + ); + } } + + private SQLExceptionConverter sqlExceptionConverter() { + return session.getFactory().getSQLExceptionConverter(); + } } = /** @@ -196,61 +235,75 @@ } = public void delegateWork(IsolatedWork work, boolean transacted) throws H= ibernateException { - Connection connection =3D null; boolean wasAutoCommit =3D false; try { - connection =3D session.getBatcher().openConnection(); - - if ( transacted ) { - if ( connection.getAutoCommit() ) { - wasAutoCommit =3D true; - connection.setAutoCommit( false ); + Connection connection =3D session.getFactory().getConnectionProvider()= .getConnection(); + try { + if ( transacted ) { + if ( connection.getAutoCommit() ) { + wasAutoCommit =3D true; + connection.setAutoCommit( false ); + } } - } = - work.doWork( connection ); + work.doWork( connection ); = - if ( transacted ) { - connection.commit(); + if ( transacted ) { + connection.commit(); + } } - } - catch( Throwable t ) { - try { - if ( transacted && connection !=3D null && !connection.isClosed() ) { - connection.rollback(); + catch( Exception e ) { + try { + if ( transacted && !connection.isClosed() ) { + connection.rollback(); + } } - } - catch( Throwable ignore ) { - log.trace( "unable to release connection on exception [" + ignore + "= ]" ); - } + catch( Exception ignore ) { + log.info( "unable to rollback connection on exception [" + ignore + = "]" ); + } = - if ( t instanceof HibernateException ) { - throw ( HibernateException ) t; + if ( e instanceof HibernateException ) { + throw ( HibernateException ) e; + } + else if ( e instanceof SQLException ) { + throw JDBCExceptionHelper.convert( + sqlExceptionConverter(), + ( SQLException ) e, + "error performing isolated work" + ); + } + else { + throw new HibernateException( "error performing isolated work", e ); + } } - else if ( t instanceof SQLException ) { - throw JDBCExceptionHelper.convert( - session.getFactory().getSQLExceptionConverter(), - ( SQLException ) t, - "error performing isolated work" - ); - } - else { - throw new HibernateException( "error performing isolated work", t ); - } - } - finally { - if ( connection !=3D null ) { + finally { if ( transacted && wasAutoCommit ) { try { connection.setAutoCommit( true ); } - catch( Throwable ignore ) { + catch( Exception ignore ) { log.trace( "was unable to reset connection back to auto-commit" ); } } - session.getBatcher().closeConnection( connection ); + try { + session.getFactory().getConnectionProvider().closeConnection( connec= tion ); + } + catch ( Exception ignore ) { + log.info( "Unable to release isolated connection [" + ignore + "]" ); + } } } + catch ( SQLException sqle ) { + throw JDBCExceptionHelper.convert( + sqlExceptionConverter(), + sqle, + "unable to obtain isolated JDBC connection" + ); + } } + + private SQLExceptionConverter sqlExceptionConverter() { + return session.getFactory().getSQLExceptionConverter(); + } } } Modified: core/trunk/core/src/main/java/org/hibernate/jdbc/Batcher.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/jdbc/Batcher.java 2009-11-1= 1 05:58:21 UTC (rev 17954) +++ core/trunk/core/src/main/java/org/hibernate/jdbc/Batcher.java 2009-11-1= 1 05:58:42 UTC (rev 17955) @@ -165,10 +165,14 @@ = /** * Obtain a JDBC connection + * + * @deprecated Obtain connections from {@link ConnectionProvider} instead */ public Connection openConnection() throws HibernateException; /** * Dispose of the JDBC connection + * + * @deprecated Obtain connections from {@link ConnectionProvider} instead */ public void closeConnection(Connection conn) throws HibernateException; = --===============6256567935343890472==-- From hibernate-commits at lists.jboss.org Wed Nov 11 11:30:23 2009 Content-Type: multipart/mixed; boundary="===============7555097491738430324==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17956 - core/trunk/parent. Date: Wed, 11 Nov 2009 11:30:23 -0500 Message-ID: <200911111630.nABGUN02005213@svn01.web.mwc.hst.phx2.redhat.com> --===============7555097491738430324== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jcosta(a)redhat.com Date: 2009-11-11 11:30:22 -0500 (Wed, 11 Nov 2009) New Revision: 17956 Modified: core/trunk/parent/pom.xml Log: HHH-4565 HSQLDB shouldn't be a dependency in compile scope Modified: core/trunk/parent/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/parent/pom.xml 2009-11-11 05:58:42 UTC (rev 17955) +++ core/trunk/parent/pom.xml 2009-11-11 16:30:22 UTC (rev 17956) @@ -503,6 +503,7 @@ hsqldb hsqldb 1.8.0.2 + test @@ -530,6 +531,7 @@ mysql mysql-connector-java 5.0.5 + test @@ -550,6 +552,7 @@ mysql mysql-connector-java 5.0.5 + test @@ -570,6 +573,7 @@ mysql mysql-connector-java 5.1.8 + test @@ -590,6 +594,7 @@ postgresql postgresql 8.2-504.jdbc3 + test @@ -610,6 +615,7 @@ postgresql postgresql 8.2-504.jdbc3 + test @@ -636,6 +642,7 @@ com.ibm db2jcc 3.1.57 + test com.ibm @@ -661,6 +668,7 @@ com.ibm db2jcc 3.8.47 + test com.ibm @@ -686,6 +694,7 @@ com.ibm db2jcc 3.57.86 + test com.ibm @@ -712,6 +721,7 @@ ojdbc14 10.0.2.0 + test @@ -733,6 +743,7 @@ ojdbc14 10.0.2.0 + test @@ -753,6 +764,7 @@ com.oracle ojdbc5 11.1.0.7.0 + test @@ -773,6 +785,7 @@ com.oracle ojdbc5 11.1.0.7.0 + test @@ -793,6 +806,7 @@ com.sybase jconnect 6.0.5 + test @@ -812,7 +826,8 @@ com.microsoft.sqlserver msjdbc - 1.1 + 2.0.1008.2 + test @@ -832,7 +847,8 @@ com.microsoft.sqlserver msjdbc - 1.1 + 2.0.1008.2 + test --===============7555097491738430324==-- From hibernate-commits at lists.jboss.org Wed Nov 11 11:50:34 2009 Content-Type: multipart/mixed; boundary="===============2333242541824072524==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17957 - core/trunk/annotations. Date: Wed, 11 Nov 2009 11:50:34 -0500 Message-ID: <200911111650.nABGoY5s009401@svn01.web.mwc.hst.phx2.redhat.com> --===============2333242541824072524== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-11 11:50:34 -0500 (Wed, 11 Nov 2009) New Revision: 17957 Modified: core/trunk/annotations/pom.xml Log: HHH-4566 Added test scope to the jaxb dependencies Modified: core/trunk/annotations/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/pom.xml 2009-11-11 16:30:22 UTC (rev 17956) +++ core/trunk/annotations/pom.xml 2009-11-11 16:50:34 UTC (rev 17957) @@ -146,11 +146,13 @@ javax.xml.bind jaxb-api 2.1 + test com.sun.xml.bind jaxb-impl 2.1.3 + test --===============2333242541824072524==-- From hibernate-commits at lists.jboss.org Wed Nov 11 13:56:29 2009 Content-Type: multipart/mixed; boundary="===============3963607982806184011==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17958 - core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy. Date: Wed, 11 Nov 2009 13:56:29 -0500 Message-ID: <200911111856.nABIuTH2002977@svn01.web.mwc.hst.phx2.redhat.com> --===============3963607982806184011== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: gbadner Date: 2009-11-11 13:56:29 -0500 (Wed, 11 Nov 2009) New Revision: 17958 Modified: core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/rel= ation/lazy/AbstractDelegateSessionImplementor.java Log: HHH-2762 : Add AbstractDelegateSessionImplementor.getNonFlushedChanges()/ap= plyNonFlushedChanges() Modified: core/trunk/envers/src/main/java/org/hibernate/envers/entities/map= per/relation/lazy/AbstractDelegateSessionImplementor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/re= lation/lazy/AbstractDelegateSessionImplementor.java 2009-11-11 16:50:34 UTC= (rev 17957) +++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/re= lation/lazy/AbstractDelegateSessionImplementor.java 2009-11-11 18:56:29 UTC= (rev 17958) @@ -45,6 +45,7 @@ import org.hibernate.engine.QueryParameters; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.NonFlushedChanges; import org.hibernate.engine.query.sql.NativeSQLQuerySpecification; import org.hibernate.event.EventListeners; import org.hibernate.impl.CriteriaImpl; @@ -216,6 +217,14 @@ return delegate.executeNativeUpdate(specification, queryParameters= ); } = + public NonFlushedChanges getNonFlushedChanges() throws HibernateException= { + return delegate.getNonFlushedChanges(); + } + + public void applyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) t= hrows HibernateException { + delegate.applyNonFlushedChanges( nonFlushedChanges ); = + } + public EntityMode getEntityMode() { return delegate.getEntityMode(); } --===============3963607982806184011==-- From hibernate-commits at lists.jboss.org Wed Nov 11 15:27:39 2009 Content-Type: multipart/mixed; boundary="===============5208476950083956725==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17959 - in core/trunk: core/src/main/java/org/hibernate/util and 1 other directories. Date: Wed, 11 Nov 2009 15:27:39 -0500 Message-ID: <200911112027.nABKRd3q026108@svn01.web.mwc.hst.phx2.redhat.com> --===============5208476950083956725== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-11 15:27:39 -0500 (Wed, 11 Nov 2009) New Revision: 17959 Modified: core/trunk/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.= java core/trunk/core/src/main/java/org/hibernate/util/CollectionHelper.java core/trunk/testsuite/src/test/java/org/hibernate/test/filter/DynamicFilt= erTest.java Log: HHH-4065 - Incorrect SQL is used for HQL if the number of values for a filt= er collection parameter is changed Modified: core/trunk/core/src/main/java/org/hibernate/engine/query/QueryPla= nCache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/query/QueryPlanCache= .java 2009-11-11 18:56:29 UTC (rev 17958) +++ core/trunk/core/src/main/java/org/hibernate/engine/query/QueryPlanCache= .java 2009-11-11 20:27:39 UTC (rev 17959) @@ -26,10 +26,13 @@ = import org.hibernate.util.SimpleMRUCache; import org.hibernate.util.SoftLimitMRUCache; +import org.hibernate.util.CollectionHelper; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.query.sql.NativeSQLQuerySpecification; import org.hibernate.QueryException; import org.hibernate.MappingException; +import org.hibernate.impl.FilterImpl; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; = @@ -40,6 +43,7 @@ import java.util.Set; import java.util.HashSet; import java.util.Collections; +import java.util.Collection; = /** * Acts as a cache for compiled query plans, as well as query-parameter me= tadata. @@ -174,7 +178,7 @@ private static class HQLQueryPlanKey implements Serializable { private final String query; private final boolean shallow; - private final Set filterNames; + private final Set filterKeys; private final int hashCode; = public HQLQueryPlanKey(String query, boolean shallow, Map enabledFilters= ) { @@ -182,17 +186,23 @@ this.shallow =3D shallow; = if ( enabledFilters =3D=3D null || enabledFilters.isEmpty() ) { - filterNames =3D Collections.EMPTY_SET; + filterKeys =3D Collections.EMPTY_SET; } else { - Set tmp =3D new HashSet(); - tmp.addAll( enabledFilters.keySet() ); - this.filterNames =3D Collections.unmodifiableSet( tmp ); + Set tmp =3D new HashSet( + CollectionHelper.determineProperSizing( enabledFilters ), + CollectionHelper.LOAD_FACTOR + ); + Iterator itr =3D enabledFilters.values().iterator(); + while ( itr.hasNext() ) { + tmp.add( new DynamicFilterKey( ( FilterImpl ) itr.next() ) ); + } + this.filterKeys =3D Collections.unmodifiableSet( tmp ); } = int hash =3D query.hashCode(); hash =3D 29 * hash + ( shallow ? 1 : 0 ); - hash =3D 29 * hash + filterNames.hashCode(); + hash =3D 29 * hash + filterKeys.hashCode(); this.hashCode =3D hash; } = @@ -206,17 +216,64 @@ = final HQLQueryPlanKey that =3D ( HQLQueryPlanKey ) o; = - if ( shallow !=3D that.shallow ) { - return false; + return shallow =3D=3D that.shallow + && filterKeys.equals( that.filterKeys ) + && query.equals( that.query ); + + } + + public int hashCode() { + return hashCode; + } + } + + private static class DynamicFilterKey implements Serializable { + private final String filterName; + private final Map parameterMetadata; + private final int hashCode; + + private DynamicFilterKey(FilterImpl filter) { + this.filterName =3D filter.getName(); + if ( filter.getParameters().isEmpty() ) { + parameterMetadata =3D Collections.EMPTY_MAP; } - if ( !filterNames.equals( that.filterNames ) ) { - return false; + else { + parameterMetadata =3D new HashMap( + CollectionHelper.determineProperSizing( filter.getParameters() ), + CollectionHelper.LOAD_FACTOR + ); + Iterator itr =3D filter.getParameters().entrySet().iterator(); + while ( itr.hasNext() ) { + final Integer valueCount; + final Map.Entry entry =3D ( Map.Entry ) itr.next(); + if ( Collection.class.isInstance( entry.getValue() ) ) { + valueCount =3D new Integer( ( (Collection) entry.getValue() ).size()= ); + } + else { + valueCount =3D new Integer(1); + } + parameterMetadata.put( entry.getKey(), valueCount ); + } } - if ( !query.equals( that.query ) ) { + + int hash =3D filterName.hashCode(); + hash =3D 31 * hash + parameterMetadata.hashCode(); + this.hashCode =3D hash; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) { + return true; + } + if ( o =3D=3D null || getClass() !=3D o.getClass() ) { return false; } = - return true; + DynamicFilterKey that =3D ( DynamicFilterKey ) o; + + return filterName.equals( that.filterName ) + && parameterMetadata.equals( that.parameterMetadata ); + } = public int hashCode() { @@ -262,20 +319,11 @@ = final FilterQueryPlanKey that =3D ( FilterQueryPlanKey ) o; = - if ( shallow !=3D that.shallow ) { - return false; - } - if ( !filterNames.equals( that.filterNames ) ) { - return false; - } - if ( !query.equals( that.query ) ) { - return false; - } - if ( !collectionRole.equals( that.collectionRole ) ) { - return false; - } + return shallow =3D=3D that.shallow + && filterNames.equals( that.filterNames ) + && query.equals( that.query ) + && collectionRole.equals( that.collectionRole ); = - return true; } = public int hashCode() { Modified: core/trunk/core/src/main/java/org/hibernate/util/CollectionHelper= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/util/CollectionHelper.java = 2009-11-11 18:56:29 UTC (rev 17958) +++ core/trunk/core/src/main/java/org/hibernate/util/CollectionHelper.java = 2009-11-11 20:27:39 UTC (rev 17959) @@ -29,6 +29,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; = /** * Various help for handling collections. @@ -37,6 +38,8 @@ * @author Steve Ebersole */ public final class CollectionHelper { + public static final int MINIMUM_INITIAL_CAPACITY =3D 16; + public static final float LOAD_FACTOR =3D 0.75f; = public static final List EMPTY_LIST =3D Collections.unmodifiableList( new= ArrayList(0) ); public static final Collection EMPTY_COLLECTION =3D Collections.unmodifia= bleCollection( new ArrayList(0) ); @@ -54,7 +57,40 @@ * @return The sized map. */ public static Map mapOfSize(int size) { - final int currentSize =3D (int) (size / 0.75f); - return new HashMap( Math.max( currentSize+ 1, 16), 0.75f ); + return new HashMap( determineProperSizing( size ), LOAD_FACTOR ); } + + /** + * Given a map, determine the proper initial size for a new Map to hold t= he same number of values. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param original The original map + * @return The proper size. + */ + public static int determineProperSizing(Map original) { + return determineProperSizing( original.size() ); + } + + /** + * Given a set, determine the proper initial size for a new set to hold t= he same number of values. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param original The original set + * @return The proper size. + */ + public static int determineProperSizing(Set original) { + return determineProperSizing( original.size() ); + } + + /** + * Determine the proper initial size for a new collection in order for it= to hold the given a number of elements. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param numberOfElements The number of elements to be stored. + * @return The proper size. + */ + public static int determineProperSizing(int numberOfElements) { + int actual =3D ( (int) (numberOfElements / LOAD_FACTOR) ) + 1; + return Math.max( actual, MINIMUM_INITIAL_CAPACITY ); + } } Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/filter/Dyna= micFilterTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/filter/DynamicFil= terTest.java 2009-11-11 18:56:29 UTC (rev 17958) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/filter/DynamicFil= terTest.java 2009-11-11 20:27:39 UTC (rev 17959) @@ -39,6 +39,7 @@ * * @author Steve */ +(a)SuppressWarnings({ "WhileLoopReplaceableByForEach", "unchecked" }) public class DynamicFilterTest extends FunctionalTestCase { = private Logger log =3D LoggerFactory.getLogger( DynamicFilterTest.class ); @@ -99,7 +100,7 @@ ts =3D ( ( SessionImplementor ) session ).getTimestamp(); session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", test= Data.lastMonth.getTime() ); sp =3D ( Salesperson ) session.createQuery( "from Salesperson as s where= s.id =3D :id" ) - .setLong( "id", testData.steveId.longValue() ) + .setLong( "id", testData.steveId ) .uniqueResult(); assertEquals( "Filtered-collection not bypassing 2L-cache", 1, sp.getOrd= ers().size() ); = @@ -142,6 +143,17 @@ = session.clear(); = + session.disableFilter("regionlist"); + session.enableFilter( "regionlist" ).setParameterList( "regions", new St= ring[]{"LA", "APAC", "APAC"} ); + // Second test retreival through hql with the collection as non-eager wi= th different region list + salespersons =3D session.createQuery( "select s from Salesperson as s" )= .list(); + assertEquals( "Incorrect salesperson count", 1, salespersons.size() ); + sp =3D ( Salesperson ) salespersons.get( 0 ); + assertEquals( "Incorrect order count", 1, sp.getOrders().size() ); + + session.clear(); + + // test retreival through hql with the collection join fetched salespersons =3D session.createQuery( "select s from Salesperson as s le= ft join fetch s.orders" ).list(); assertEquals( "Incorrect salesperson count", 1, salespersons.size() ); @@ -224,7 +236,7 @@ = log.info( "Criteria query against Product..." ); List products =3D session.createCriteria( Product.class ) - .add( Restrictions.eq( "stockNumber", new Integer( 124 ) ) ) + .add( Restrictions.eq( "stockNumber", 124 ) ) .list(); assertEquals( "Incorrect product count", 1, products.size() ); = @@ -288,10 +300,10 @@ session.enableFilter("region").setParameter("region", "APAC"); = DetachedCriteria lineItemSubquery =3D DetachedCriteria.forClass(LineItem= .class) - .add(Restrictions.ge( "quantity", new Long(1L) )) - .createCriteria("product") - .add(Restrictions.eq("name", "Acme Hair Gel")) - .setProjection(Property.forName("id")); + .add( Restrictions.ge( "quantity", 1L ) ) + .createCriteria( "product" ) + .add( Restrictions.eq( "name", "Acme Hair Gel" ) ) + .setProjection( Property.forName( "id" ) ); = List orders =3D session.createCriteria(Order.class) .add(Subqueries.exists(lineItemSubquery)) @@ -309,7 +321,7 @@ .setProjection(Property.forName("id")); = lineItemSubquery =3D DetachedCriteria.forClass(LineItem.class) - .add(Restrictions.ge("quantity", new Long(1L) )) + .add(Restrictions.ge("quantity", 1L )) .createCriteria("product") .add(Subqueries.propertyIn("id", productSubquery)) .setProjection(Property.forName("id")); @@ -662,7 +674,7 @@ = // Force the categories to not get initialized here List result =3D session.createQuery( "from Product as p where p.id =3D := id" ) - .setLong( "id", testData.prod1Id.longValue() ) + .setLong( "id", testData.prod1Id ) .list(); assertTrue( "No products returned from HQL", !result.isEmpty() ); = --===============5208476950083956725==-- From hibernate-commits at lists.jboss.org Wed Nov 11 15:36:03 2009 Content-Type: multipart/mixed; boundary="===============6989888454851505297==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17960 - in core/branches/Branch_3_3: core/src/main/java/org/hibernate/util and 1 other directories. Date: Wed, 11 Nov 2009 15:36:03 -0500 Message-ID: <200911112036.nABKa3Op027857@svn01.web.mwc.hst.phx2.redhat.com> --===============6989888454851505297== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-11 15:36:03 -0500 (Wed, 11 Nov 2009) New Revision: 17960 Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/engine/query/Q= ueryPlanCache.java core/branches/Branch_3_3/core/src/main/java/org/hibernate/util/Collectio= nHelper.java core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/filt= er/DynamicFilterTest.java Log: HHH-4065 - Incorrect SQL is used for HQL if the number of values for a filt= er collection parameter is changed Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/engine/= query/QueryPlanCache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/core/src/main/java/org/hibernate/engine/query/= QueryPlanCache.java 2009-11-11 20:27:39 UTC (rev 17959) +++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/engine/query/= QueryPlanCache.java 2009-11-11 20:36:03 UTC (rev 17960) @@ -26,10 +26,13 @@ = import org.hibernate.util.SimpleMRUCache; import org.hibernate.util.SoftLimitMRUCache; +import org.hibernate.util.CollectionHelper; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.query.sql.NativeSQLQuerySpecification; import org.hibernate.QueryException; import org.hibernate.MappingException; +import org.hibernate.impl.FilterImpl; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; = @@ -40,6 +43,7 @@ import java.util.Set; import java.util.HashSet; import java.util.Collections; +import java.util.Collection; = /** * Acts as a cache for compiled query plans, as well as query-parameter me= tadata. @@ -174,7 +178,7 @@ private static class HQLQueryPlanKey implements Serializable { private final String query; private final boolean shallow; - private final Set filterNames; + private final Set filterKeys; private final int hashCode; = public HQLQueryPlanKey(String query, boolean shallow, Map enabledFilters= ) { @@ -182,17 +186,23 @@ this.shallow =3D shallow; = if ( enabledFilters =3D=3D null || enabledFilters.isEmpty() ) { - filterNames =3D Collections.EMPTY_SET; + filterKeys =3D Collections.EMPTY_SET; } else { - Set tmp =3D new HashSet(); - tmp.addAll( enabledFilters.keySet() ); - this.filterNames =3D Collections.unmodifiableSet( tmp ); + Set tmp =3D new HashSet( + CollectionHelper.determineProperSizing( enabledFilters ), + CollectionHelper.LOAD_FACTOR + ); + Iterator itr =3D enabledFilters.values().iterator(); + while ( itr.hasNext() ) { + tmp.add( new DynamicFilterKey( ( FilterImpl ) itr.next() ) ); + } + this.filterKeys =3D Collections.unmodifiableSet( tmp ); } = int hash =3D query.hashCode(); hash =3D 29 * hash + ( shallow ? 1 : 0 ); - hash =3D 29 * hash + filterNames.hashCode(); + hash =3D 29 * hash + filterKeys.hashCode(); this.hashCode =3D hash; } = @@ -206,17 +216,63 @@ = final HQLQueryPlanKey that =3D ( HQLQueryPlanKey ) o; = - if ( shallow !=3D that.shallow ) { - return false; + return shallow =3D=3D that.shallow + && filterKeys.equals( that.filterKeys ) + && query.equals( that.query ); + } + + public int hashCode() { + return hashCode; + } + } + + private static class DynamicFilterKey implements Serializable { + private final String filterName; + private final Map parameterMetadata; + private final int hashCode; + + private DynamicFilterKey(FilterImpl filter) { + this.filterName =3D filter.getName(); + if ( filter.getParameters().isEmpty() ) { + parameterMetadata =3D Collections.EMPTY_MAP; } - if ( !filterNames.equals( that.filterNames ) ) { - return false; + else { + parameterMetadata =3D new HashMap( + CollectionHelper.determineProperSizing( filter.getParameters() ), + CollectionHelper.LOAD_FACTOR + ); + Iterator itr =3D filter.getParameters().entrySet().iterator(); + while ( itr.hasNext() ) { + final Integer valueCount; + final Map.Entry entry =3D ( Map.Entry ) itr.next(); + if ( Collection.class.isInstance( entry.getValue() ) ) { + valueCount =3D new Integer( ( (Collection) entry.getValue() ).size()= ); + } + else { + valueCount =3D new Integer(1); + } + parameterMetadata.put( entry.getKey(), valueCount ); + } } - if ( !query.equals( that.query ) ) { + + int hash =3D filterName.hashCode(); + hash =3D 31 * hash + parameterMetadata.hashCode(); + this.hashCode =3D hash; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) { + return true; + } + if ( o =3D=3D null || getClass() !=3D o.getClass() ) { return false; } = - return true; + DynamicFilterKey that =3D ( DynamicFilterKey ) o; + + return filterName.equals( that.filterName ) + && parameterMetadata.equals( that.parameterMetadata ); + } = public int hashCode() { @@ -262,20 +318,10 @@ = final FilterQueryPlanKey that =3D ( FilterQueryPlanKey ) o; = - if ( shallow !=3D that.shallow ) { - return false; - } - if ( !filterNames.equals( that.filterNames ) ) { - return false; - } - if ( !query.equals( that.query ) ) { - return false; - } - if ( !collectionRole.equals( that.collectionRole ) ) { - return false; - } - - return true; + return shallow =3D=3D that.shallow + && filterNames.equals( that.filterNames ) + && query.equals( that.query ) + && collectionRole.equals( that.collectionRole ); } = public int hashCode() { Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/util/Co= llectionHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/core/src/main/java/org/hibernate/util/Collecti= onHelper.java 2009-11-11 20:27:39 UTC (rev 17959) +++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/util/Collecti= onHelper.java 2009-11-11 20:36:03 UTC (rev 17960) @@ -29,6 +29,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; = /** * Various help for handling collections. @@ -37,11 +38,13 @@ * @author Steve Ebersole */ public final class CollectionHelper { + public static final int MINIMUM_INITIAL_CAPACITY =3D 16; + public static final float LOAD_FACTOR =3D 0.75f; = public static final List EMPTY_LIST =3D Collections.unmodifiableList( new= ArrayList(0) ); public static final Collection EMPTY_COLLECTION =3D Collections.unmodifia= bleCollection( new ArrayList(0) ); public static final Map EMPTY_MAP =3D Collections.unmodifiableMap( new Ha= shMap(0) ); - = + private CollectionHelper() { } = @@ -54,7 +57,40 @@ * @return The sized map. */ public static Map mapOfSize(int size) { - final int currentSize =3D (int) (size / 0.75f); - return new HashMap( Math.max( currentSize+ 1, 16), 0.75f ); + return new HashMap( determineProperSizing( size ), LOAD_FACTOR ); } + + /** + * Given a map, determine the proper initial size for a new Map to hold t= he same number of values. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param original The original map + * @return The proper size. + */ + public static int determineProperSizing(Map original) { + return determineProperSizing( original.size() ); + } + + /** + * Given a set, determine the proper initial size for a new set to hold t= he same number of values. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param original The original set + * @return The proper size. + */ + public static int determineProperSizing(Set original) { + return determineProperSizing( original.size() ); + } + + /** + * Determine the proper initial size for a new collection in order for it= to hold the given a number of elements. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param numberOfElements The number of elements to be stored. + * @return The proper size. + */ + public static int determineProperSizing(int numberOfElements) { + int actual =3D ( (int) (numberOfElements / LOAD_FACTOR) ) + 1; + return Math.max( actual, MINIMUM_INITIAL_CAPACITY ); + } } Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/te= st/filter/DynamicFilterTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/fil= ter/DynamicFilterTest.java 2009-11-11 20:27:39 UTC (rev 17959) +++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/fil= ter/DynamicFilterTest.java 2009-11-11 20:36:03 UTC (rev 17960) @@ -39,6 +39,7 @@ * * @author Steve */ +(a)SuppressWarnings({ "WhileLoopReplaceableByForEach", "unchecked" }) public class DynamicFilterTest extends FunctionalTestCase { = private Logger log =3D LoggerFactory.getLogger( DynamicFilterTest.class ); @@ -99,7 +100,7 @@ ts =3D ( ( SessionImplementor ) session ).getTimestamp(); session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", test= Data.lastMonth.getTime() ); sp =3D ( Salesperson ) session.createQuery( "from Salesperson as s where= s.id =3D :id" ) - .setLong( "id", testData.steveId.longValue() ) + .setLong( "id", testData.steveId ) .uniqueResult(); assertEquals( "Filtered-collection not bypassing 2L-cache", 1, sp.getOrd= ers().size() ); = @@ -142,6 +143,17 @@ = session.clear(); = + session.disableFilter( "regionlist" ); + session.enableFilter( "regionlist" ).setParameterList( "regions", new St= ring[]{"LA", "APAC", "APAC"} ); + // Second test retreival through hql with the collection as non-eager wi= th different region list + salespersons =3D session.createQuery( "select s from Salesperson as s" )= .list(); + assertEquals( "Incorrect salesperson count", 1, salespersons.size() ); + sp =3D ( Salesperson ) salespersons.get( 0 ); + assertEquals( "Incorrect order count", 1, sp.getOrders().size() ); + + session.clear(); + + // test retreival through hql with the collection join fetched salespersons =3D session.createQuery( "select s from Salesperson as s le= ft join fetch s.orders" ).list(); assertEquals( "Incorrect salesperson count", 1, salespersons.size() ); @@ -206,7 +218,7 @@ = log.info( "Criteria query against Product..." ); List products =3D session.createCriteria( Product.class ) - .add( Restrictions.eq( "stockNumber", new Integer( 124 ) ) ) + .add( Restrictions.eq( "stockNumber", 124 ) ) .list(); assertEquals( "Incorrect product count", 1, products.size() ); = @@ -644,7 +656,7 @@ = // Force the categories to not get initialized here List result =3D session.createQuery( "from Product as p where p.id =3D := id" ) - .setLong( "id", testData.prod1Id.longValue() ) + .setLong( "id", testData.prod1Id ) .list(); assertTrue( "No products returned from HQL", !result.isEmpty() ); = --===============6989888454851505297==-- From hibernate-commits at lists.jboss.org Wed Nov 11 17:20:48 2009 Content-Type: multipart/mixed; boundary="===============8420612317669620832==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17961 - in core/trunk/entitymanager/src: test/java/org/hibernate/ejb/test and 1 other directory. Date: Wed, 11 Nov 2009 17:20:48 -0500 Message-ID: <200911112220.nABMKmTa014207@svn01.web.mwc.hst.phx2.redhat.com> --===============8420612317669620832== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-11 17:20:48 -0500 (Wed, 11 Nov 2009) New Revision: 17961 Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/QueryTest.= java Log: HHH-4567 - EntiytManager's QueryImpl mishandles ordinal position of HQL-sty= le positional parameters Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImp= l.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java= 2009-11-11 20:36:03 UTC (rev 17960) +++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java= 2009-11-11 22:20:48 UTC (rev 17961) @@ -75,7 +75,7 @@ extractParameterInfo(); } = - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings({ "unchecked", "RedundantCast" }) private void extractParameterInfo() { if ( ! AbstractQueryImpl.class.isInstance( query ) ) { throw new IllegalStateException( "Unknown query type for parameter extr= action" ); @@ -108,7 +108,7 @@ final OrdinalParameterDescriptor descriptor =3D queryImpl.getParameterMetadata().getOrdinalParameterDescriptor( i+1 ); ParameterImpl parameter =3D new ParameterImpl( - descriptor.getOrdinalPosition() + 1, + i + 1, descriptor.getExpectedType() =3D=3D null ? null : descriptor.getExpectedType().getReturnedClass() @@ -204,7 +204,7 @@ /** * {@inheritDoc} */ - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings({ "unchecked", "RedundantCast" }) public List getResultList() { try { return (List) query.list(); @@ -223,7 +223,7 @@ /** * {@inheritDoc} */ - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings({ "unchecked", "RedundantCast" }) public X getSingleResult() { try { boolean mucked =3D false; Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/Que= ryTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/QueryTest= .java 2009-11-11 20:36:03 UTC (rev 17960) +++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/QueryTest= .java 2009-11-11 22:20:48 UTC (rev 17961) @@ -212,6 +212,40 @@ em.close(); } = + public void testPositionalParameterForms() throws Exception { + EntityManager em =3D getOrCreateEntityManager(); + em.getTransaction().begin(); + Wallet w =3D new Wallet(); + w.setBrand( "Lacoste" ); + w.setModel( "Minimic" ); + w.setSerial( "0100202002" ); + em.persist( w ); + em.getTransaction().commit(); + + em.getTransaction().begin(); + // first using jpa-style positional parameter + Query query =3D em.createQuery( "select w from Wallet w where w.brand = =3D ?1" ); + query.setParameter( 1, "Lacoste" ); + w =3D (Wallet) query.getSingleResult(); + assertNotNull( w ); + + // next using jpa-style positional parameter, but as a name (which is ho= w Hibernate core treats these + query =3D em.createQuery( "select w from Wallet w where w.brand =3D ?1" = ); + query.setParameter( "1", "Lacoste" ); + w =3D (Wallet) query.getSingleResult(); + assertNotNull( w ); + + // finally using hql-style positional parameter + query =3D em.createQuery( "select w from Wallet w where w.brand =3D ?" ); + query.setParameter( 1, "Lacoste" ); + w =3D (Wallet) query.getSingleResult(); + assertNotNull( w ); + + em.remove( w ); + em.getTransaction().commit(); + em.close(); + } + public void testNativeQuestionMarkParameter() throws Exception { EntityManager em =3D getOrCreateEntityManager(); em.getTransaction().begin(); --===============8420612317669620832==-- From hibernate-commits at lists.jboss.org Wed Nov 11 23:20:41 2009 Content-Type: multipart/mixed; boundary="===============8103698463193818818==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17962 - in core/trunk/core/src/main/java/org/hibernate: dialect and 3 other directories. Date: Wed, 11 Nov 2009 23:20:41 -0500 Message-ID: <200911120420.nAC4Kfok019638@svn01.web.mwc.hst.phx2.redhat.com> --===============8103698463193818818== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: smarlow(a)redhat.com Date: 2009-11-11 23:20:41 -0500 (Wed, 11 Nov 2009) New Revision: 17962 Added: core/trunk/core/src/main/java/org/hibernate/dialect/lock/OptimisticForce= IncrementLockingStrategy.java core/trunk/core/src/main/java/org/hibernate/dialect/lock/OptimisticLocki= ngStrategy.java core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticForc= eIncrementLockingStrategy.java core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticRead= SelectLockingStrategy.java core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticRead= UpdateLockingStrategy.java core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticWrit= eSelectLockingStrategy.java core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticWrit= eUpdateLockingStrategy.java Modified: core/trunk/core/src/main/java/org/hibernate/LockMode.java core/trunk/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java core/trunk/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.java core/trunk/core/src/main/java/org/hibernate/dialect/HSQLDialect.java core/trunk/core/src/main/java/org/hibernate/dialect/MckoiDialect.java core/trunk/core/src/main/java/org/hibernate/dialect/PointbaseDialect.java core/trunk/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.ja= va core/trunk/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java core/trunk/core/src/main/java/org/hibernate/dialect/TimesTenDialect.java core/trunk/core/src/main/java/org/hibernate/dialect/lock/LockingStrategy= .java core/trunk/core/src/main/java/org/hibernate/dialect/lock/SelectLockingSt= rategy.java core/trunk/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingSt= rategy.java core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgrad= eEventListener.java core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEnt= ityPersister.java Log: HHH-4546 - add JPA 2.0 locking. Modified: core/trunk/core/src/main/java/org/hibernate/LockMode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/LockMode.java 2009-11-11 22= :20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/LockMode.java 2009-11-12 04= :20:41 UTC (rev 17962) @@ -120,30 +120,30 @@ * Optimisticly assume that transaction will not experience contention for * entities. The entity version will be verified near the transaction en= d. = */ - public static final LockMode OPTIMISTIC =3D new LockMode(3,"OPTIMISTIC"); + public static final LockMode OPTIMISTIC =3D new LockMode( 3, "OPTIMISTIC"= ); = /** * Optimisticly assume that transaction will not experience contention fo= r entities. * The entity version will be verified and incremented near the transacti= on end. = */ - public static final LockMode OPTIMISTIC_FORCE_INCREMENT =3D new LockMode(= 7,"OPTIMISTIC_FORCE_INCREMENT"); + public static final LockMode OPTIMISTIC_FORCE_INCREMENT =3D new LockMode(= 4, "OPTIMISTIC_FORCE_INCREMENT"); = /** * Implemented as PESSIMISTIC_WRITE. * TODO: introduce separate support for PESSIMISTIC_READ */ - public static final LockMode PESSIMISTIC_READ =3D new LockMode(12,"PESSIM= ISTIC_READ"); + public static final LockMode PESSIMISTIC_READ =3D new LockMode( 12, "PESS= IMISTIC_READ"); = /** * Transaction will obtain a database lock immediately. * TODO: add PESSIMISTIC_WRITE_NOWAIT */ - public static final LockMode PESSIMISTIC_WRITE =3D new LockMode(13,"PESSI= MISTIC_WRITE"); + public static final LockMode PESSIMISTIC_WRITE =3D new LockMode( 13, "PES= SIMISTIC_WRITE"); = /** * Transaction will immediately increment the entity version. */ - public static final LockMode PESSIMISTIC_FORCE_INCREMENT =3D new LockMode= (17,"PESSIMISTIC_FORCE_INCREMENT"); + public static final LockMode PESSIMISTIC_FORCE_INCREMENT =3D new LockMode= ( 17, "PESSIMISTIC_FORCE_INCREMENT"); = /** * end of javax.persistence.LockModeType modes Modified: core/trunk/core/src/main/java/org/hibernate/dialect/Cache71Dialec= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java= 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java= 2009-11-12 04:20:41 UTC (rev 17962) @@ -41,9 +41,7 @@ import org.hibernate.dialect.function.StandardJDBCEscapeFunction; import org.hibernate.dialect.function.ConvertFunction; import org.hibernate.dialect.function.ConditionalParenthesisFunction; -import org.hibernate.dialect.lock.LockingStrategy; -import org.hibernate.dialect.lock.SelectLockingStrategy; -import org.hibernate.dialect.lock.UpdateLockingStrategy; +import org.hibernate.dialect.lock.*; import org.hibernate.exception.CacheSQLStateConverter; import org.hibernate.exception.SQLExceptionConverter; import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter; @@ -564,7 +562,22 @@ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode loc= kMode) { // InterSystems Cache' does not current support "SELECT ... FOR UPDATE" = syntax... // Set your transaction mode to READ_COMMITTED before using - if ( lockMode.greaterThan( LockMode.READ ) ) { + if ( lockMode=3D=3DLockMode.PESSIMISTIC_FORCE_INCREMENT) { + return new PessimisticForceIncrementLockingStrategy( lockable, lockMode= ); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_WRITE) { + return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_READ) { + return new PessimisticReadUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC) { + return new OptimisticLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC_FORCE_INCREMENT) { + return new OptimisticForceIncrementLockingStrategy( lockable, lockMode); + } + else if ( lockMode.greaterThan( LockMode.READ ) ) { return new UpdateLockingStrategy( lockable, lockMode ); } else { Modified: core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java 2009-1= 1-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java 2009-1= 1-12 04:20:41 UTC (rev 17962) @@ -48,8 +48,7 @@ import org.hibernate.dialect.function.SQLFunction; import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.StandardSQLFunction; -import org.hibernate.dialect.lock.LockingStrategy; -import org.hibernate.dialect.lock.SelectLockingStrategy; +import org.hibernate.dialect.lock.*; import org.hibernate.engine.Mapping; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.exception.SQLExceptionConverter; @@ -952,6 +951,21 @@ * @since 3.2 */ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode loc= kMode) { + if ( lockMode=3D=3DLockMode.PESSIMISTIC_FORCE_INCREMENT) { + return new PessimisticForceIncrementLockingStrategy( lockable, lockMode= ); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_WRITE) { + return new PessimisticWriteSelectLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_READ) { + return new PessimisticReadSelectLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC) { + return new OptimisticLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC_FORCE_INCREMENT) { + return new OptimisticForceIncrementLockingStrategy( lockable, lockMode); + } return new SelectLockingStrategy( lockable, lockMode ); } = Modified: core/trunk/core/src/main/java/org/hibernate/dialect/FrontBaseDial= ect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.ja= va 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.ja= va 2009-11-12 04:20:41 UTC (rev 17962) @@ -24,9 +24,7 @@ */ package org.hibernate.dialect; = -import org.hibernate.dialect.lock.LockingStrategy; -import org.hibernate.dialect.lock.UpdateLockingStrategy; -import org.hibernate.dialect.lock.SelectLockingStrategy; +import org.hibernate.dialect.lock.*; import org.hibernate.persister.entity.Lockable; import org.hibernate.LockMode; = @@ -104,7 +102,22 @@ = public LockingStrategy getLockingStrategy(Lockable lockable, LockMode loc= kMode) { // Frontbase has no known variation of a "SELECT ... FOR UPDATE" syntax.= .. - if ( lockMode.greaterThan( LockMode.READ ) ) { + if ( lockMode=3D=3DLockMode.PESSIMISTIC_FORCE_INCREMENT) { + return new PessimisticForceIncrementLockingStrategy( lockable, lockMode= ); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_WRITE) { + return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_READ) { + return new PessimisticReadUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC) { + return new OptimisticLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC_FORCE_INCREMENT) { + return new OptimisticForceIncrementLockingStrategy( lockable, lockMode); + } + else if ( lockMode.greaterThan( LockMode.READ ) ) { return new UpdateLockingStrategy( lockable, lockMode ); } else { Modified: core/trunk/core/src/main/java/org/hibernate/dialect/HSQLDialect.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/HSQLDialect.java 20= 09-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/HSQLDialect.java 20= 09-11-12 04:20:41 UTC (rev 17962) @@ -38,8 +38,7 @@ import org.hibernate.dialect.function.NoArgSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction; -import org.hibernate.dialect.lock.LockingStrategy; -import org.hibernate.dialect.lock.SelectLockingStrategy; +import org.hibernate.dialect.lock.*; import org.hibernate.exception.JDBCExceptionHelper; import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.ViolatedConstraintNameExtracter; @@ -292,7 +291,17 @@ = public LockingStrategy getLockingStrategy(Lockable lockable, LockMode loc= kMode) { // HSQLDB only supports READ_UNCOMMITTED transaction isolation + if ( lockMode=3D=3DLockMode.PESSIMISTIC_FORCE_INCREMENT) { + return new PessimisticForceIncrementLockingStrategy( lockable, lockMode= ); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC) { + return new OptimisticLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC_FORCE_INCREMENT) { + return new OptimisticForceIncrementLockingStrategy( lockable, lockMode); + } return new ReadUncommittedLockingStrategy( lockable, lockMode ); + = } = public static class ReadUncommittedLockingStrategy extends SelectLockingS= trategy { @@ -300,12 +309,12 @@ super( lockable, lockMode ); } = - public void lock(Serializable id, Object version, Object object, Session= Implementor session) + public void lock(Serializable id, Object version, Object object, int tim= eout, SessionImplementor session) throws StaleObjectStateException, JDBCException { if ( getLockMode().greaterThan( LockMode.READ ) ) { log.warn( "HSQLDB supports only READ_UNCOMMITTED isolation" ); } - super.lock( id, version, object, session ); + super.lock( id, version, object, timeout, session ); } } = Modified: core/trunk/core/src/main/java/org/hibernate/dialect/MckoiDialect.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/MckoiDialect.java 2= 009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/MckoiDialect.java 2= 009-11-12 04:20:41 UTC (rev 17962) @@ -31,9 +31,7 @@ import org.hibernate.persister.entity.Lockable; import org.hibernate.cfg.Environment; import org.hibernate.dialect.function.StandardSQLFunction; -import org.hibernate.dialect.lock.LockingStrategy; -import org.hibernate.dialect.lock.UpdateLockingStrategy; -import org.hibernate.dialect.lock.SelectLockingStrategy; +import org.hibernate.dialect.lock.*; import org.hibernate.sql.CaseFragment; import org.hibernate.sql.MckoiCaseFragment; = @@ -111,7 +109,22 @@ = public LockingStrategy getLockingStrategy(Lockable lockable, LockMode loc= kMode) { // Mckoi has no known variation of a "SELECT ... FOR UPDATE" syntax... - if ( lockMode.greaterThan( LockMode.READ ) ) { + if ( lockMode=3D=3DLockMode.PESSIMISTIC_FORCE_INCREMENT) { + return new PessimisticForceIncrementLockingStrategy( lockable, lockMode= ); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_WRITE) { + return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_READ) { + return new PessimisticReadUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC) { + return new OptimisticLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC_FORCE_INCREMENT) { + return new OptimisticForceIncrementLockingStrategy( lockable, lockMode); + } + else if ( lockMode.greaterThan( LockMode.READ ) ) { return new UpdateLockingStrategy( lockable, lockMode ); } else { Modified: core/trunk/core/src/main/java/org/hibernate/dialect/PointbaseDial= ect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/PointbaseDialect.ja= va 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/PointbaseDialect.ja= va 2009-11-12 04:20:41 UTC (rev 17962) @@ -24,9 +24,7 @@ */ package org.hibernate.dialect; = -import org.hibernate.dialect.lock.LockingStrategy; -import org.hibernate.dialect.lock.UpdateLockingStrategy; -import org.hibernate.dialect.lock.SelectLockingStrategy; +import org.hibernate.dialect.lock.*; import org.hibernate.persister.entity.Lockable; import org.hibernate.LockMode; = @@ -81,7 +79,22 @@ = public LockingStrategy getLockingStrategy(Lockable lockable, LockMode loc= kMode) { // Pointbase has no known variation of a "SELECT ... FOR UPDATE" syntax.= .. - if ( lockMode.greaterThan( LockMode.READ ) ) { + if ( lockMode=3D=3DLockMode.PESSIMISTIC_FORCE_INCREMENT) { + return new PessimisticForceIncrementLockingStrategy( lockable, lockMode= ); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_WRITE) { + return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_READ) { + return new PessimisticReadUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC) { + return new OptimisticLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC_FORCE_INCREMENT) { + return new OptimisticForceIncrementLockingStrategy( lockable, lockMode); + } + else if ( lockMode.greaterThan( LockMode.READ ) ) { return new UpdateLockingStrategy( lockable, lockMode ); } else { Modified: core/trunk/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dia= lect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.j= ava 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.j= ava 2009-11-12 04:20:41 UTC (rev 17962) @@ -27,9 +27,7 @@ import org.hibernate.dialect.function.NoArgSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.SQLFunctionTemplate; -import org.hibernate.dialect.lock.LockingStrategy; -import org.hibernate.dialect.lock.UpdateLockingStrategy; -import org.hibernate.dialect.lock.SelectLockingStrategy; +import org.hibernate.dialect.lock.*; = import java.sql.Types; import org.hibernate.Hibernate; @@ -336,7 +334,22 @@ = public LockingStrategy getLockingStrategy(Lockable lockable, LockMode loc= kMode) { // RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax... - if ( lockMode.greaterThan( LockMode.READ ) ) { + if ( lockMode=3D=3DLockMode.PESSIMISTIC_FORCE_INCREMENT) { + return new PessimisticForceIncrementLockingStrategy( lockable, lockMode= ); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_WRITE) { + return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_READ) { + return new PessimisticReadUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC) { + return new OptimisticLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC_FORCE_INCREMENT) { + return new OptimisticForceIncrementLockingStrategy( lockable, lockMode); + } + else if ( lockMode.greaterThan( LockMode.READ ) ) { return new UpdateLockingStrategy( lockable, lockMode ); } else { Modified: core/trunk/core/src/main/java/org/hibernate/dialect/SQLServerDial= ect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/SQLServerDialect.ja= va 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/SQLServerDialect.ja= va 2009-11-12 04:20:41 UTC (rev 17962) @@ -111,10 +111,15 @@ } = public String appendLockHint(LockMode mode, String tableName) { - if ( mode.greaterThan( LockMode.READ ) ) { - // does this need holdlock also? : return tableName + " with (updlock, = rowlock, holdlock)"; + if ( ( mode =3D=3D LockMode.UPGRADE ) || + ( mode =3D=3D LockMode.UPGRADE_NOWAIT ) || + ( mode =3D=3D LockMode.PESSIMISTIC_WRITE ) || = + ( mode =3D=3D LockMode.WRITE ) ) { return tableName + " with (updlock, rowlock)"; } + else if ( mode =3D=3D LockMode.PESSIMISTIC_READ ) { + return tableName + " with (holdlock, rowlock)"; + } else { return tableName; } Modified: core/trunk/core/src/main/java/org/hibernate/dialect/TimesTenDiale= ct.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/TimesTenDialect.jav= a 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/TimesTenDialect.jav= a 2009-11-12 04:20:41 UTC (rev 17962) @@ -32,9 +32,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.dialect.function.NoArgSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction; -import org.hibernate.dialect.lock.LockingStrategy; -import org.hibernate.dialect.lock.UpdateLockingStrategy; -import org.hibernate.dialect.lock.SelectLockingStrategy; +import org.hibernate.dialect.lock.*; import org.hibernate.sql.JoinFragment; import org.hibernate.sql.OracleJoinFragment; = @@ -217,7 +215,22 @@ = public LockingStrategy getLockingStrategy(Lockable lockable, LockMode loc= kMode) { // TimesTen has no known variation of a "SELECT ... FOR UPDATE" syntax... - if ( lockMode.greaterThan( LockMode.READ ) ) { + if ( lockMode=3D=3DLockMode.PESSIMISTIC_FORCE_INCREMENT) { + return new PessimisticForceIncrementLockingStrategy( lockable, lockMode= ); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_WRITE) { + return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.PESSIMISTIC_READ) { + return new PessimisticReadUpdateLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC) { + return new OptimisticLockingStrategy( lockable, lockMode); + } + else if ( lockMode=3D=3DLockMode.OPTIMISTIC_FORCE_INCREMENT) { + return new OptimisticForceIncrementLockingStrategy( lockable, lockMode); + } + else if ( lockMode.greaterThan( LockMode.READ ) ) { return new UpdateLockingStrategy( lockable, lockMode ); } else { Modified: core/trunk/core/src/main/java/org/hibernate/dialect/lock/LockingS= trategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/lock/LockingStrateg= y.java 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/lock/LockingStrateg= y.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -51,11 +51,12 @@ * @param id The id of the row to be locked * @param version The current version (or null if not versioned) * @param object The object logically being locked (currently not used) + * @param timeout timeout in milliseconds, 0 =3D no wait, -1 =3D wait ind= efinitely * @param session The session from which the lock request originated * @throws StaleObjectStateException Indicates an optimisitic lock failure * as part of acquiring the requested database lock. * @throws JDBCException */ - public void lock(Serializable id, Object version, Object object, SessionI= mplementor session) + public void lock(Serializable id, Object version, Object object, int time= out, SessionImplementor session) throws StaleObjectStateException, JDBCException; } Added: core/trunk/core/src/main/java/org/hibernate/dialect/lock/OptimisticF= orceIncrementLockingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/lock/OptimisticForc= eIncrementLockingStrategy.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/dialect/lock/OptimisticForc= eIncrementLockingStrategy.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -0,0 +1,91 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.dialect.lock; + +import java.io.Serializable; + +import org.hibernate.HibernateException; +import org.hibernate.JDBCException; +import org.hibernate.LockMode; +import org.hibernate.StaleObjectStateException; +import org.hibernate.event.EventSource; +import org.hibernate.action.EntityIncrementVersionProcess; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.EntityEntry; +import org.hibernate.persister.entity.Lockable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * An optimistic locking strategy that forces an increment of the version = (after verifying that version hasn't changed). + * This takes place just prior to transaction commit. + *

+ * This strategy is valid for LockMode.OPTIMISTIC_FORCE_INCREMENT + * + * @since 3.5 + * + * @author Scott Marlow + */ +public class OptimisticForceIncrementLockingStrategy implements LockingStr= ategy { + private static final Logger log =3D LoggerFactory.getLogger( OptimisticFo= rceIncrementLockingStrategy.class ); + + private final Lockable lockable; + private final LockMode lockMode; + /** + * Construct locking strategy. + * + * @param lockable The metadata for the entity to be locked. + * @param lockMode Indictates the type of lock to be acquired. + */ + public OptimisticForceIncrementLockingStrategy(Lockable lockable, LockMod= e lockMode) { + this.lockable =3D lockable; + this.lockMode =3D lockMode; + if ( lockMode.lessThan( LockMode.OPTIMISTIC_FORCE_INCREMENT ) ) { + throw new HibernateException( "[" + lockMode + "] not valid for [" + lo= ckable.getEntityName() + "]" ); + } + } + + /** + * @see LockingStrategy#lock + */ + public void lock( + Serializable id, + Object version, + Object object, + int timeout, SessionImplementor session) throws StaleObjectStateExce= ption, JDBCException { + if ( !lockable.isVersioned() ) { + throw new HibernateException( "[" + lockMode + "] not supported for non= -versioned entities [" + lockable.getEntityName() + "]" ); + } + EntityEntry entry =3D session.getPersistenceContext().getEntry(objec= t); + EntityIncrementVersionProcess incrementVersion =3D new EntityIncrementVe= rsionProcess(object, entry); + EventSource source =3D (EventSource)session; + // Register the EntityIncrementVersionProcess action to run just prior t= o transaction commit. = + source.getActionQueue().registerProcess(incrementVersion); + } + + protected LockMode getLockMode() { + return lockMode; + } +} \ No newline at end of file Added: core/trunk/core/src/main/java/org/hibernate/dialect/lock/OptimisticL= ockingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/lock/OptimisticLock= ingStrategy.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/dialect/lock/OptimisticLock= ingStrategy.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -0,0 +1,88 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.dialect.lock; + +import java.io.Serializable; + +import org.hibernate.*; +import org.hibernate.event.EventSource; +import org.hibernate.action.EntityVerifyVersionProcess; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.EntityEntry; +import org.hibernate.persister.entity.Lockable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * An optimistic locking strategy that verifies that the version hasn't ch= anged (prior to transaction commit). + *

+ * This strategy is valid for LockMode.OPTIMISTIC + * + * @since 3.5 + * + * @author Scott Marlow + */ +public class OptimisticLockingStrategy implements LockingStrategy { + private static final Logger log =3D LoggerFactory.getLogger( OptimisticLo= ckingStrategy.class ); + + private final Lockable lockable; + private final LockMode lockMode; + + /** + * Construct locking strategy. + * + * @param lockable The metadata for the entity to be locked. + * @param lockMode Indictates the type of lock to be acquired. + */ + public OptimisticLockingStrategy(Lockable lockable, LockMode lockMode) { + this.lockable =3D lockable; + this.lockMode =3D lockMode; + if ( lockMode.lessThan( LockMode.OPTIMISTIC ) ) { + throw new HibernateException( "[" + lockMode + "] not valid for [" + lo= ckable.getEntityName() + "]" ); + } + } + + /** + * @see org.hibernate.dialect.lock.LockingStrategy#lock + */ + public void lock( + Serializable id, + Object version, + Object object, + int timeout, SessionImplementor session) throws StaleObjectStateExce= ption, JDBCException { + if ( !lockable.isVersioned() ) { + throw new OptimisticLockException( "[" + lockMode + "] not supported fo= r non-versioned entities [" + lockable.getEntityName() + "]" ); + } + EntityEntry entry =3D session.getPersistenceContext().getEntry(object); + EventSource source =3D (EventSource)session; + EntityVerifyVersionProcess verifyVersion =3D new EntityVerifyVersionProc= ess(object, entry); + // Register the EntityVerifyVersionProcess action to run just prior to t= ransaction commit. + source.getActionQueue().registerProcess(verifyVersion); + } + + protected LockMode getLockMode() { + return lockMode; + } +} \ No newline at end of file Added: core/trunk/core/src/main/java/org/hibernate/dialect/lock/Pessimistic= ForceIncrementLockingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticFor= ceIncrementLockingStrategy.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticFor= ceIncrementLockingStrategy.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -0,0 +1,93 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.dialect.lock; + +import java.io.Serializable; + +import org.hibernate.HibernateException; +import org.hibernate.JDBCException; +import org.hibernate.LockMode; +import org.hibernate.StaleObjectStateException; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.EntityEntry; +import org.hibernate.persister.entity.Lockable; +import org.hibernate.persister.entity.EntityPersister; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A pessimistic locking strategy that increments the version immediately = (obtaining an exclusive write lock). + *

+ * This strategy is valid for LockMode.PESSIMISTIC_FORCE_INCREMENT + * + * @since 3.5 + * + * @author Scott Marlow + */ +public class PessimisticForceIncrementLockingStrategy implements LockingSt= rategy { + private static final Logger log =3D LoggerFactory.getLogger( PessimisticF= orceIncrementLockingStrategy.class ); + + private final Lockable lockable; + private final LockMode lockMode; + + /** + * Construct locking strategy. + * + * @param lockable The metadata for the entity to be locked. + * @param lockMode Indictates the type of lock to be acquired. + */ + public PessimisticForceIncrementLockingStrategy(Lockable lockable, LockMo= de lockMode) { + this.lockable =3D lockable; + this.lockMode =3D lockMode; + // ForceIncrement can be used for PESSIMISTIC_READ, PESSIMISTIC_WRITE or= PESSIMISTIC_FORCE_INCREMENT + if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) { + throw new HibernateException( "[" + lockMode + "] not valid for [" + lo= ckable.getEntityName() + "]" ); + } + } + + /** + * @see org.hibernate.dialect.lock.LockingStrategy#lock + */ + public void lock( + Serializable id, + Object version, + Object object, + int timeout, + SessionImplementor session) throws StaleObjectStateException, JDBCExcept= ion { + if ( !lockable.isVersioned() ) { + throw new HibernateException( "[" + lockMode + "] not supported for non= -versioned entities [" + lockable.getEntityName() + "]" ); + } + EntityEntry entry =3D session.getPersistenceContext().getEntry(objec= t); + final EntityPersister persister =3D entry.getPersister(); + Object nextVersion =3D persister.forceVersionIncrement( + entry.getId(), entry.getVersion(), session + ); + entry.forceLocked( object, nextVersion ); + } + + protected LockMode getLockMode() { + return lockMode; + } +} \ No newline at end of file Added: core/trunk/core/src/main/java/org/hibernate/dialect/lock/Pessimistic= ReadSelectLockingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticRea= dSelectLockingStrategy.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticRea= dSelectLockingStrategy.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -0,0 +1,148 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.dialect.lock; + +import org.hibernate.persister.entity.Lockable; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.StaleObjectStateException; +import org.hibernate.JDBCException; +import org.hibernate.LockMode; +import org.hibernate.sql.SimpleSelect; +import org.hibernate.pretty.MessageHelper; +import org.hibernate.exception.JDBCExceptionHelper; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * A pessimistic locking strategy where the locks are obtained through sel= ect statements. + *

+ * For non-read locks, this is achieved through the Dialect's specific + * SELECT ... FOR UPDATE syntax. + * + * This strategy is valid for LockMode.PESSIMISTIC_READ + * + * This class is a clone of SelectLockingStrategy. + * + * @see org.hibernate.dialect.Dialect#getForUpdateString(org.hibernate.Loc= kMode) + * @see org.hibernate.dialect.Dialect#appendLockHint(org.hibernate.LockMod= e, String) + * @since 3.5 + * + * @author Steve Ebersole + * @author Scott Marlow + */ +public class PessimisticReadSelectLockingStrategy implements LockingStrate= gy { + + private final Lockable lockable; + private final LockMode lockMode; + private final String sql; + + /** + * Construct a locking strategy based on SQL SELECT statements. + * + * @param lockable The metadata for the entity to be locked. + * @param lockMode Indictates the type of lock to be acquired. + */ + public PessimisticReadSelectLockingStrategy(Lockable lockable, LockMode l= ockMode) { + this.lockable =3D lockable; + this.lockMode =3D lockMode; + this.sql =3D generateLockString(); + } + + /** + * @see org.hibernate.dialect.lock.LockingStrategy#lock + */ + public void lock( + Serializable id, + Object version, + Object object, + int timeout, SessionImplementor session) throws StaleObjectStateExce= ption, JDBCException { + + SessionFactoryImplementor factory =3D session.getFactory(); + try { + PreparedStatement st =3D session.getBatcher().prepareSelectStatement( s= ql ); + try { + lockable.getIdentifierType().nullSafeSet( st, id, 1, session ); + if ( lockable.isVersioned() ) { + lockable.getVersionType().nullSafeSet( + st, + version, + lockable.getIdentifierType().getColumnSpan( factory ) + 1, + session + ); + } + + ResultSet rs =3D st.executeQuery(); + try { + if ( !rs.next() ) { + if ( factory.getStatistics().isStatisticsEnabled() ) { + factory.getStatisticsImplementor() + .optimisticFailure( lockable.getEntityName() ); + } + throw new StaleObjectStateException( lockable.getEntityName(), id ); + } + } + finally { + rs.close(); + } + } + finally { + session.getBatcher().closeStatement( st ); + } + + } + catch ( SQLException sqle ) { + throw JDBCExceptionHelper.convert( + session.getFactory().getSQLExceptionConverter(), + sqle, + "could not lock: " + MessageHelper.infoString( lockable, id, session.= getFactory() ), + sql + ); + } + } + + protected LockMode getLockMode() { + return lockMode; + } + + protected String generateLockString() { + SessionFactoryImplementor factory =3D lockable.getFactory(); + SimpleSelect select =3D new SimpleSelect( factory.getDialect() ) + .setLockMode( lockMode ) + .setTableName( lockable.getRootTableName() ) + .addColumn( lockable.getRootTableIdentifierColumnNames()[0] ) + .addCondition( lockable.getRootTableIdentifierColumnNames(), "=3D?" ); + if ( lockable.isVersioned() ) { + select.addCondition( lockable.getVersionColumnName(), "=3D?" ); + } + if ( factory.getSettings().isCommentsEnabled() ) { + select.setComment( lockMode + " lock " + lockable.getEntityName() ); + } + return select.toStatementString(); + } +} \ No newline at end of file Added: core/trunk/core/src/main/java/org/hibernate/dialect/lock/Pessimistic= ReadUpdateLockingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticRea= dUpdateLockingStrategy.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticRea= dUpdateLockingStrategy.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -0,0 +1,148 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.dialect.lock; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.hibernate.HibernateException; +import org.hibernate.JDBCException; +import org.hibernate.LockMode; +import org.hibernate.StaleObjectStateException; +import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.exception.JDBCExceptionHelper; +import org.hibernate.persister.entity.Lockable; +import org.hibernate.pretty.MessageHelper; +import org.hibernate.sql.Update; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A pessimistic locking strategy where the locks are obtained through upd= ate statements. + *

+ * This strategy is valid for LockMode.PESSIMISTIC_READ + * + * This class is a clone of UpdateLockingStrategy. + * + * @since 3.5 + * + * @author Steve Ebersole + * @author Scott Marlow + */ +public class PessimisticReadUpdateLockingStrategy implements LockingStrate= gy { + private static final Logger log =3D LoggerFactory.getLogger( PessimisticR= eadUpdateLockingStrategy.class ); + + private final Lockable lockable; + private final LockMode lockMode; + private final String sql; + + /** + * Construct a locking strategy based on SQL UPDATE statements. + * + * @param lockable The metadata for the entity to be locked. + * @param lockMode Indictates the type of lock to be acquired. Note that + * read-locks are not valid for this strategy. + */ + public PessimisticReadUpdateLockingStrategy(Lockable lockable, LockMode l= ockMode) { + this.lockable =3D lockable; + this.lockMode =3D lockMode; + if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) { + throw new HibernateException( "[" + lockMode + "] not valid for update = statement" ); + } + if ( !lockable.isVersioned() ) { + log.warn( "write locks via update not supported for non-versioned entit= ies [" + lockable.getEntityName() + "]" ); + this.sql =3D null; + } + else { + this.sql =3D generateLockString(); + } + } + + /** + * @see org.hibernate.dialect.lock.LockingStrategy#lock + */ + public void lock( + Serializable id, + Object version, + Object object, + int timeout, SessionImplementor session) throws StaleObjectStateExce= ption, JDBCException { + if ( !lockable.isVersioned() ) { + throw new HibernateException( "write locks via update not supported for= non-versioned entities [" + lockable.getEntityName() + "]" ); + } + SessionFactoryImplementor factory =3D session.getFactory(); + try { + PreparedStatement st =3D session.getBatcher().prepareSelectStatement( s= ql ); + try { + lockable.getVersionType().nullSafeSet( st, version, 1, session ); + int offset =3D 2; + + lockable.getIdentifierType().nullSafeSet( st, id, offset, session ); + offset +=3D lockable.getIdentifierType().getColumnSpan( factory ); + + if ( lockable.isVersioned() ) { + lockable.getVersionType().nullSafeSet( st, version, offset, session ); + } + + int affected =3D st.executeUpdate(); + if ( affected < 0 ) { // todo: should this instead check for exactly= one row modified? + factory.getStatisticsImplementor().optimisticFailure( lockable.getEnt= ityName() ); + throw new StaleObjectStateException( lockable.getEntityName(), id ); + } + + } + finally { + session.getBatcher().closeStatement( st ); + } + + } + catch ( SQLException sqle ) { + throw JDBCExceptionHelper.convert( + session.getFactory().getSQLExceptionConverter(), + sqle, + "could not lock: " + MessageHelper.infoString( lockable, id, se= ssion.getFactory() ), + sql + ); + } + } + + protected String generateLockString() { + SessionFactoryImplementor factory =3D lockable.getFactory(); + Update update =3D new Update( factory.getDialect() ); + update.setTableName( lockable.getRootTableName() ); + update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames(= ) ); + update.setVersionColumnName( lockable.getVersionColumnName() ); + update.addColumn( lockable.getVersionColumnName() ); + if ( factory.getSettings().isCommentsEnabled() ) { + update.setComment( lockMode + " lock " + lockable.getEntityName() ); + } + return update.toStatementString(); + } + + protected LockMode getLockMode() { + return lockMode; + } +} \ No newline at end of file Added: core/trunk/core/src/main/java/org/hibernate/dialect/lock/Pessimistic= WriteSelectLockingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticWri= teSelectLockingStrategy.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticWri= teSelectLockingStrategy.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -0,0 +1,148 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.dialect.lock; + +import org.hibernate.persister.entity.Lockable; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.StaleObjectStateException; +import org.hibernate.JDBCException; +import org.hibernate.LockMode; +import org.hibernate.sql.SimpleSelect; +import org.hibernate.pretty.MessageHelper; +import org.hibernate.exception.JDBCExceptionHelper; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * A pessimistic locking strategy where the locks are obtained through sel= ect statements. + *

+ * For non-read locks, this is achieved through the Dialect's specific + * SELECT ... FOR UPDATE syntax. + * = + * This strategy is valid for LockMode.PESSIMISTIC_WRITE + * + * This class is a clone of SelectLockingStrategy. + * + * @see org.hibernate.dialect.Dialect#getForUpdateString(org.hibernate.Loc= kMode) + * @see org.hibernate.dialect.Dialect#appendLockHint(org.hibernate.LockMod= e, String) + * @since 3.5 + * + * @author Steve Ebersole + * @author Scott Marlow + */ +public class PessimisticWriteSelectLockingStrategy implements LockingStrat= egy { + + private final Lockable lockable; + private final LockMode lockMode; + private final String sql; + + /** + * Construct a locking strategy based on SQL SELECT statements. + * + * @param lockable The metadata for the entity to be locked. + * @param lockMode Indictates the type of lock to be acquired. + */ + public PessimisticWriteSelectLockingStrategy(Lockable lockable, LockMode = lockMode) { + this.lockable =3D lockable; + this.lockMode =3D lockMode; + this.sql =3D generateLockString(); + } + + /** + * @see LockingStrategy#lock + */ + public void lock( + Serializable id, + Object version, + Object object, + int timeout, SessionImplementor session) throws StaleObjectStateExce= ption, JDBCException { + + SessionFactoryImplementor factory =3D session.getFactory(); + try { + PreparedStatement st =3D session.getBatcher().prepareSelectStatement( s= ql ); + try { + lockable.getIdentifierType().nullSafeSet( st, id, 1, session ); + if ( lockable.isVersioned() ) { + lockable.getVersionType().nullSafeSet( + st, + version, + lockable.getIdentifierType().getColumnSpan( factory ) + 1, + session + ); + } + + ResultSet rs =3D st.executeQuery(); + try { + if ( !rs.next() ) { + if ( factory.getStatistics().isStatisticsEnabled() ) { + factory.getStatisticsImplementor() + .optimisticFailure( lockable.getEntityName() ); + } + throw new StaleObjectStateException( lockable.getEntityName(), id ); + } + } + finally { + rs.close(); + } + } + finally { + session.getBatcher().closeStatement( st ); + } + + } + catch ( SQLException sqle ) { + throw JDBCExceptionHelper.convert( + session.getFactory().getSQLExceptionConverter(), + sqle, + "could not lock: " + MessageHelper.infoString( lockable, id, session.= getFactory() ), + sql + ); + } + } + + protected LockMode getLockMode() { + return lockMode; + } + + protected String generateLockString() { + SessionFactoryImplementor factory =3D lockable.getFactory(); + SimpleSelect select =3D new SimpleSelect( factory.getDialect() ) + .setLockMode( lockMode ) + .setTableName( lockable.getRootTableName() ) + .addColumn( lockable.getRootTableIdentifierColumnNames()[0] ) + .addCondition( lockable.getRootTableIdentifierColumnNames(), "=3D?" ); + if ( lockable.isVersioned() ) { + select.addCondition( lockable.getVersionColumnName(), "=3D?" ); + } + if ( factory.getSettings().isCommentsEnabled() ) { + select.setComment( lockMode + " lock " + lockable.getEntityName() ); + } + return select.toStatementString(); + } +} \ No newline at end of file Added: core/trunk/core/src/main/java/org/hibernate/dialect/lock/Pessimistic= WriteUpdateLockingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticWri= teUpdateLockingStrategy.java (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/dialect/lock/PessimisticWri= teUpdateLockingStrategy.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -0,0 +1,148 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.dialect.lock; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.hibernate.HibernateException; +import org.hibernate.JDBCException; +import org.hibernate.LockMode; +import org.hibernate.StaleObjectStateException; +import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.exception.JDBCExceptionHelper; +import org.hibernate.persister.entity.Lockable; +import org.hibernate.pretty.MessageHelper; +import org.hibernate.sql.Update; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A pessimistic locking strategy where the locks are obtained through upd= ate statements. + *

+ * This strategy is valid for LockMode.PESSIMISTIC_WRITE + * + * This class is a clone of UpdateLockingStrategy. + * + * @since 3.5 + * + * @author Steve Ebersole + * @author Scott Marlow + */ +public class PessimisticWriteUpdateLockingStrategy implements LockingStrat= egy { + private static final Logger log =3D LoggerFactory.getLogger( PessimisticW= riteUpdateLockingStrategy.class ); + + private final Lockable lockable; + private final LockMode lockMode; + private final String sql; + + /** + * Construct a locking strategy based on SQL UPDATE statements. + * + * @param lockable The metadata for the entity to be locked. + * @param lockMode Indictates the type of lock to be acquired. Note that + * read-locks are not valid for this strategy. + */ + public PessimisticWriteUpdateLockingStrategy(Lockable lockable, LockMode = lockMode) { + this.lockable =3D lockable; + this.lockMode =3D lockMode; + if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) { + throw new HibernateException( "[" + lockMode + "] not valid for update = statement" ); + } + if ( !lockable.isVersioned() ) { + log.warn( "write locks via update not supported for non-versioned entit= ies [" + lockable.getEntityName() + "]" ); + this.sql =3D null; + } + else { + this.sql =3D generateLockString(); + } + } + + /** + * @see LockingStrategy#lock + */ + public void lock( + Serializable id, + Object version, + Object object, + int timeout, SessionImplementor session) throws StaleObjectStateExce= ption, JDBCException { + if ( !lockable.isVersioned() ) { + throw new HibernateException( "write locks via update not supported for= non-versioned entities [" + lockable.getEntityName() + "]" ); + } + SessionFactoryImplementor factory =3D session.getFactory(); + try { + PreparedStatement st =3D session.getBatcher().prepareSelectStatement( s= ql ); + try { + lockable.getVersionType().nullSafeSet( st, version, 1, session ); + int offset =3D 2; + + lockable.getIdentifierType().nullSafeSet( st, id, offset, session ); + offset +=3D lockable.getIdentifierType().getColumnSpan( factory ); + + if ( lockable.isVersioned() ) { + lockable.getVersionType().nullSafeSet( st, version, offset, session ); + } + + int affected =3D st.executeUpdate(); + if ( affected < 0 ) { // todo: should this instead check for exactly= one row modified? + factory.getStatisticsImplementor().optimisticFailure( lockable.getEnt= ityName() ); + throw new StaleObjectStateException( lockable.getEntityName(), id ); + } + + } + finally { + session.getBatcher().closeStatement( st ); + } + + } + catch ( SQLException sqle ) { + throw JDBCExceptionHelper.convert( + session.getFactory().getSQLExceptionConverter(), + sqle, + "could not lock: " + MessageHelper.infoString( lockable, id, se= ssion.getFactory() ), + sql + ); + } + } + + protected String generateLockString() { + SessionFactoryImplementor factory =3D lockable.getFactory(); + Update update =3D new Update( factory.getDialect() ); + update.setTableName( lockable.getRootTableName() ); + update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames(= ) ); + update.setVersionColumnName( lockable.getVersionColumnName() ); + update.addColumn( lockable.getVersionColumnName() ); + if ( factory.getSettings().isCommentsEnabled() ) { + update.setComment( lockMode + " lock " + lockable.getEntityName() ); + } + return update.toStatementString(); + } + + protected LockMode getLockMode() { + return lockMode; + } +} \ No newline at end of file Modified: core/trunk/core/src/main/java/org/hibernate/dialect/lock/SelectLo= ckingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/lock/SelectLockingS= trategy.java 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/lock/SelectLockingS= trategy.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -76,6 +76,7 @@ Serializable id, Object version, Object object, + int timeout, = SessionImplementor session) throws StaleObjectStateException, JDB= CException { = SessionFactoryImplementor factory =3D session.getFactory(); Modified: core/trunk/core/src/main/java/org/hibernate/dialect/lock/UpdateLo= ckingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingS= trategy.java 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingS= trategy.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -83,9 +83,10 @@ * @see LockingStrategy#lock */ public void lock( - Serializable id, + Serializable id, Object version, Object object, + int timeout, SessionImplementor session) throws StaleObjectStateException, JDB= CException { if ( !lockable.isVersioned() ) { throw new HibernateException( "write locks via update not supported for= non-versioned entities [" + lockable.getEntityName() + "]" ); Modified: core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLoc= kUpgradeEventListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgra= deEventListener.java 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgra= deEventListener.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -100,27 +100,13 @@ } = try { - if ( persister.isVersioned() && (requestedLockMode =3D=3D LockMode.FOR= CE || requestedLockMode =3D=3D LockMode.PESSIMISTIC_FORCE_INCREMENT ) ) { + if ( persister.isVersioned() && requestedLockMode =3D=3D LockMode.FORC= E ) { // todo : should we check the current isolation mode explicitly? Object nextVersion =3D persister.forceVersionIncrement( entry.getId(), entry.getVersion(), source ); entry.forceLocked( object, nextVersion ); } - else if ( requestedLockMode =3D=3D LockMode.OPTIMISTIC_FORCE_INCREMENT= ) { - if(!persister.isVersioned()) { - throw new OptimisticLockException("force: Version column is not mapp= ed for " + entry.getPersister().getEntityName(), object); - } - EntityIncrementVersionProcess incrementVersion =3D new EntityIncremen= tVersionProcess(object, entry); - source.getActionQueue().registerProcess(incrementVersion); - } - else if ( requestedLockMode =3D=3D LockMode.OPTIMISTIC ) { - if(!persister.isVersioned()) { - throw new OptimisticLockException("Version column is not mapped for = " + entry.getPersister().getEntityName(), object); = - } - EntityVerifyVersionProcess verifyVersion =3D new EntityVerifyVersionP= rocess(object, entry); - source.getActionQueue().registerProcess(verifyVersion); - } else { persister.lock( entry.getId(), entry.getVersion(), object, requestedL= ockMode, source ); } Modified: core/trunk/core/src/main/java/org/hibernate/persister/entity/Abst= ractEntityPersister.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEn= tityPersister.java 2009-11-11 22:20:48 UTC (rev 17961) +++ core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEn= tityPersister.java 2009-11-12 04:20:41 UTC (rev 17962) @@ -1412,7 +1412,7 @@ Object object, LockMode lockMode, SessionImplementor session) throws HibernateException { - getLocker( lockMode ).lock( id, version, object, session ); + getLocker( lockMode ).lock( id, version, object, -1, session ); } = public String getRootTableName() { --===============8103698463193818818==-- From hibernate-commits at lists.jboss.org Thu Nov 12 11:17:12 2009 Content-Type: multipart/mixed; boundary="===============3331481259070982073==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17963 - sandbox/trunk. Date: Thu, 12 Nov 2009 11:17:12 -0500 Message-ID: <200911121617.nACGHC4V026419@svn01.web.mwc.hst.phx2.redhat.com> --===============3331481259070982073== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-12 11:17:12 -0500 (Thu, 12 Nov 2009) New Revision: 17963 Added: sandbox/trunk/new-metadata/ Log: snadbox for working on the separated metamodel redesign --===============3331481259070982073==-- From hibernate-commits at lists.jboss.org Thu Nov 12 14:46:04 2009 Content-Type: multipart/mixed; boundary="===============1557665224899299619==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17964 - in core/trunk: testsuite/src/test/java/org/hibernate/test/cfg and 1 other directories. Date: Thu, 12 Nov 2009 14:46:04 -0500 Message-ID: <200911121946.nACJk43p006167@svn01.web.mwc.hst.phx2.redhat.com> --===============1557665224899299619== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-12 14:46:04 -0500 (Thu, 12 Nov 2009) New Revision: 17964 Added: core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/ConfigurationS= erializationTest.java core/trunk/testsuite/src/test/perf/org/hibernate/test/perf/Configuration= PerformanceTest.java Removed: core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/ConfigurationP= erformanceTest.java Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/CacheableFileT= est.java core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/ListenerTest.j= ava Log: HHH-4569 - Split focus of ConfigurationPerformanceTest Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java 2009= -11-12 16:17:12 UTC (rev 17963) +++ core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java 2009= -11-12 19:46:04 UTC (rev 17964) @@ -424,70 +424,85 @@ * the non-cached file. */ public Configuration addCacheableFile(File xmlFile) throws MappingExcepti= on { + File cachedFile =3D determineCachedDomFile( xmlFile ); + try { - File cachedFile =3D new File( xmlFile.getAbsolutePath() + ".bin" ); - org.dom4j.Document doc =3D null; + return addCacheableFileStrictly( xmlFile ); + } + catch ( SerializationException e ) { + log.warn( "Could not deserialize cache file: " + cachedFile.getPath() += " : " + e ); + } + catch ( FileNotFoundException e ) { + log.warn( "I/O reported cached file could not be found : " + cachedFile= .getPath() + " : " + e ); + } = - final boolean useCachedFile =3D xmlFile.exists() && - cachedFile.exists() && - xmlFile.lastModified() < cachedFile.lastModified(); + if ( !xmlFile.exists() ) { + throw new MappingNotFoundException( "file", xmlFile.toString() ); + } = - if ( useCachedFile ) { - try { - log.info( "Reading mappings from cache file: " + cachedFile ); - doc =3D ( org.dom4j.Document ) SerializationHelper.deserialize( new F= ileInputStream( cachedFile ) ); - } - catch ( SerializationException e ) { - log.warn( "Could not deserialize cache file: " + cachedFile.getPath()= , e ); - } - catch ( FileNotFoundException e ) { - log.warn( "I/O reported cached file could not be found : " + cachedFi= le.getPath(), e ); - } + log.info( "Reading mappings from file: " + xmlFile ); + List errors =3D new ArrayList(); + try { + org.dom4j.Document doc =3D xmlHelper.createSAXReader( xmlFile.getAbsolu= tePath(), errors, entityResolver ).read( xmlFile ); + if ( errors.size() !=3D 0 ) { + throw new MappingException( "invalid mapping", ( Throwable ) errors.ge= t( 0 ) ); } = - // if doc is null, then for whatever reason, the cached file cannot be = used... - if ( doc =3D=3D null ) { - if ( !xmlFile.exists() ) { - throw new MappingNotFoundException( "file", xmlFile.toString() ); - } - - log.info( "Reading mappings from file: " + xmlFile ); - List errors =3D new ArrayList(); - try { - doc =3D xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors,= entityResolver ).read( xmlFile ); - if ( errors.size() !=3D 0 ) { - throw new MappingException( "invalid mapping", ( Throwable ) errors.= get( 0 ) ); - } - } - catch( DocumentException e){ - throw new MappingException( "invalid mapping", e ); - } - - try { - log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFil= e ); - SerializationHelper.serialize( ( Serializable ) doc, new FileOutputSt= ream( cachedFile ) ); - } - catch ( SerializationException e ) { - log.warn( "Could not write cached file: " + cachedFile, e ); - } - catch ( FileNotFoundException e ) { - log.warn( "I/O reported error writing cached file : " + cachedFile.ge= tPath(), e ); - } + try { + log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFile= ); + SerializationHelper.serialize( ( Serializable ) doc, new FileOutputStr= eam( cachedFile ) ); } + catch ( SerializationException e ) { + log.warn( "Could not write cached file: " + cachedFile, e ); + } + catch ( FileNotFoundException e ) { + log.warn( "I/O reported error writing cached file : " + cachedFile.get= Path(), e ); + } = add( doc ); - return this; - } - catch ( InvalidMappingException e ) { - throw e; + catch( DocumentException e){ + throw new MappingException( "invalid mapping", e ); } - catch ( MappingNotFoundException e ) { - throw e; + + return this; + } + + private File determineCachedDomFile(File xmlFile) { + return new File( xmlFile.getAbsolutePath() + ".bin" ); + } + + /** + * INTENDED FOR TESTSUITE USE ONLY! + *

+ * Much like {@link addCacheableFile(File)} except that here we will fail= immediately if + * the cache version cannot be found or used for whatever reason + * + * @param xmlFile The xml file, not the bin! + * + * @return The dom "deserialized" from the cached file. + * + * @throws MappingException Indicates a problem in the underlyiong call t= o {@link #add(org.dom4j.Document)} + * @throws SerializationException Indicates a problem deserializing the c= ached dom tree + * @throws FileNotFoundException Indicates that the cached file was not f= ound or was not usable. + */ + public Configuration addCacheableFileStrictly(File xmlFile) + throws MappingException, SerializationException, FileNotFoundException { + final File cachedFile =3D determineCachedDomFile( xmlFile ); + + final boolean useCachedFile =3D xmlFile.exists() + && cachedFile.exists() + && xmlFile.lastModified() < cachedFile.lastModified(); + + if ( ! useCachedFile ) { + throw new FileNotFoundException( "Cached file could not be found or cou= ld not be used" ); } - catch ( Exception e ) { - throw new InvalidMappingException( "file", xmlFile.toString(), e ); - } + + log.info( "Reading mappings from cache file: " + cachedFile ); + org.dom4j.Document document =3D + ( org.dom4j.Document ) SerializationHelper.deserialize( new FileInputS= tream( cachedFile ) ); + add( document ); + return this; } = /** Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/Cacheab= leFileTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/CacheableFile= Test.java 2009-11-12 16:17:12 UTC (rev 17963) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/CacheableFile= Test.java 2009-11-12 19:46:04 UTC (rev 17964) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.test.cfg; = import java.io.File; @@ -4,17 +27,18 @@ = import org.hibernate.cfg.Configuration; import org.hibernate.junit.UnitTestCase; +import org.hibernate.util.SerializationHelper; = /** - * {@inheritDoc} + * Tests using of cacheable configuration files. * * @author Steve Ebersole */ public class CacheableFileTest extends UnitTestCase { - public static final String MAPPING =3D "org/hibernate/test/cfg/Cacheable.= hbm.xml"; = private File mappingFile; + private File mappingBinFile; = public CacheableFileTest(String string) { super( string ); @@ -24,21 +48,31 @@ super.setUp(); mappingFile =3D new File( getClass().getClassLoader().getResource( MAPPI= NG ).toURI() ); assertTrue( mappingFile.exists() ); - File cached =3D new File( mappingFile.getParentFile(), mappingFile.getNa= me() + ".bin" ); - if ( cached.exists() ) { - cached.delete(); + mappingBinFile =3D new File( mappingFile.getParentFile(), mappingFile.ge= tName() + ".bin" ); + if ( mappingBinFile.exists() ) { + //noinspection ResultOfMethodCallIgnored + mappingBinFile.delete(); } } = protected void tearDown() throws Exception { + if ( mappingBinFile !=3D null && mappingBinFile.exists() ) { + // be nice + //noinspection ResultOfMethodCallIgnored + mappingBinFile.delete(); + } + mappingBinFile =3D null; mappingFile =3D null; super.tearDown(); } = - public void testCachedFiles() { - Configuration cfg =3D new Configuration(); - cfg.addCacheableFile( mappingFile ); - Configuration cfg2 =3D new Configuration(); - cfg2.addCacheableFile( mappingFile ); + public void testCachedFiles() throws Exception { + assertFalse( mappingBinFile.exists() ); + // This call should create the cached file + new Configuration().addCacheableFile( mappingFile ); + assertTrue( mappingBinFile.exists() ); + + Configuration cfg =3D new Configuration().addCacheableFileStrictly( mapp= ingFile ); + SerializationHelper.clone( cfg ); } } Deleted: core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/Configur= ationPerformanceTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/Configuration= PerformanceTest.java 2009-11-12 16:17:12 UTC (rev 17963) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/Configuration= PerformanceTest.java 2009-11-12 19:46:04 UTC (rev 17964) @@ -1,352 +0,0 @@ -/* - * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, v. 2.1. This program is distributed in t= he - * hope that it will be useful, but WITHOUT A WARRANTY; without even the i= mplied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See th= e GNU - * Lesser General Public License for more details. You should have receive= d a - * copy of the GNU Lesser General Public License, v.2.1 along with this - * distribution; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Red Hat Author(s): Max Andersen, Steve Ebersole - */ -package org.hibernate.test.cfg; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.PrintWriter; - -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; -import org.hibernate.cfg.Environment; -import org.hibernate.classic.Session; -import org.hibernate.junit.UnitTestCase; - -/** - * Test of configuration, specifically "cacheable files". - * - * @author Max Andersen - * @author Steve Ebersole - */ -public class ConfigurationPerformanceTest extends UnitTestCase { - - private final String workPackageName =3D "org.hibernate.test.cfg.work"; - private File compilationBaseDir; - private File mappingBaseDir; - private File workPackageDir; - - protected void setUp() throws Exception { - compilationBaseDir =3D getTestComplileDirectory(); - mappingBaseDir =3D new File( compilationBaseDir, "org/hibernate/test" ); - workPackageDir =3D new File( compilationBaseDir, workPackageName.replace= ( '.', '/' ) ); - if ( workPackageDir.exists() ) { - //noinspection ResultOfMethodCallIgnored - workPackageDir.delete(); - } - boolean created =3D workPackageDir.mkdirs(); - if ( !created ) { - System.err.println( "Unable to create workPackageDir during setup" ); - } - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - private static final String[] FILES =3D new String[] { - "legacy/ABC.hbm.xml", - "legacy/ABCExtends.hbm.xml", - "legacy/Baz.hbm.xml", - "legacy/Blobber.hbm.xml", - "legacy/Broken.hbm.xml", - "legacy/Category.hbm.xml", - "legacy/Circular.hbm.xml", - "legacy/Commento.hbm.xml", - "legacy/ComponentNotNullMaster.hbm.xml", - "legacy/Componentizable.hbm.xml", - "legacy/Container.hbm.xml", - "legacy/Custom.hbm.xml", - "legacy/CustomSQL.hbm.xml", - "legacy/Eye.hbm.xml", - "legacy/Fee.hbm.xml", - "legacy/Fo.hbm.xml", - "legacy/FooBar.hbm.xml", - "legacy/Fum.hbm.xml", - "legacy/Fumm.hbm.xml", - "legacy/Glarch.hbm.xml", - "legacy/Holder.hbm.xml", - "legacy/IJ2.hbm.xml", - "legacy/Immutable.hbm.xml", - "legacy/Location.hbm.xml", - "legacy/Many.hbm.xml", - "legacy/Map.hbm.xml", - "legacy/Marelo.hbm.xml", - "legacy/MasterDetail.hbm.xml", - "legacy/Middle.hbm.xml", - "legacy/Multi.hbm.xml", - "legacy/MultiExtends.hbm.xml", - "legacy/Nameable.hbm.xml", - "legacy/One.hbm.xml", - "legacy/ParentChild.hbm.xml", - "legacy/Qux.hbm.xml", - "legacy/Simple.hbm.xml", - "legacy/SingleSeveral.hbm.xml", - "legacy/Stuff.hbm.xml", - "legacy/UpDown.hbm.xml", - "legacy/Vetoer.hbm.xml", - "legacy/WZ.hbm.xml", - }; - - public ConfigurationPerformanceTest(String string) { - super( string ); - } - - public static Test suite() { - return new TestSuite( ConfigurationPerformanceTest.class ); - } - - public static void main(String[] args) throws Exception { - TestRunner.run( suite() ); - } - - public void testLoadingAndSerializationOfConfiguration() throws Throwable= { - final File cachedCfgFile =3D new File( workPackageDir, "hibernate.cfg.bi= n" ); - try { - System.err.println( "#### Preparing serialized configuration ~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~~~" ); - prepareSerializedConfiguration( mappingBaseDir, FILES, cachedCfgFile ); - System.err.println( "#### Preparing serialized configuration complete ~= ~~~~~~~~~~~~~~~~~~~~~~~" ); - - // now make sure we can reload the serialized configuration... - System.err.println( "#### Reading serialized configuration ~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~~~" ); - readSerializedConfiguration( cachedCfgFile ); - System.err.println( "#### Reading serialized configuration complete ~~~= ~~~~~~~~~~~~~~~~~~~~~~~" ); - } - finally { - System.err.println( "###CLEANING UP###" ); - if ( ! cachedCfgFile.delete() ) { - System.err.println( "Unable to cleanup file " + cachedCfgFile.getAbsol= utePath() ); - } - //noinspection ForLoopReplaceableByForEach - for ( int i =3D 0; i < FILES.length; i++ ) { - File file =3D new File( mappingBaseDir, FILES[i] + ".bin" ); - if ( ! file.delete() ) { - System.err.println( "Unable to cleanup file " + file.getAbsolutePath(= ) ); - } - } - } - } - - public void testSessionFactoryCreationTime() throws Throwable { - generateTestFiles(); - if ( !workPackageDir.exists() ) { - System.err.println( workPackageDir.getAbsoluteFile() + " not found" ); - return; - } - - long start =3D System.currentTimeMillis(); - Configuration configuration =3D buildConfigurationFromCacheableFiles( - workPackageDir, - workPackageDir.list( - new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.endsWith( ".hbm.xml" ); - } - } - ) - ); - SessionFactory factory =3D configuration.buildSessionFactory(); - long initial =3D System.currentTimeMillis() - start; - factory.close(); - - start =3D System.currentTimeMillis(); - configuration =3D buildConfigurationFromCacheableFiles( - workPackageDir, - workPackageDir.list( - new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.endsWith( ".hbm.xml" ); - } - } - ) - ); - factory =3D configuration.buildSessionFactory(); - long subsequent =3D System.currentTimeMillis() - start; - - // Let's make sure the mappings were read in correctly (in termas of the= y are operational). - Session session =3D factory.openSession(); - session.beginTransaction(); - session.createQuery( "from Test1" ).list(); - session.getTransaction().commit(); - session.close(); - factory.close(); - - System.err.println( "Initial SessionFactory load time : " + initial ); - System.err.println( "Subsequent SessionFactory load time : " + subsequen= t ); - } - - private void prepareSerializedConfiguration( - File mappingFileBase, - String[] files, - File cachedCfgFile) throws IOException { - Configuration cfg =3D buildConfigurationFromCacheableFiles( mappingFileB= ase, files ); - - ObjectOutputStream os =3D new ObjectOutputStream( new FileOutputStream( = cachedCfgFile ) ); - os.writeObject( cfg ); // need to serialize Configuration *before* build= ing sf since it would require non-mappings and cfg types to be serializable - os.flush(); - os.close(); - - timeBuildingSessionFactory( cfg ); - } - - private Configuration buildConfigurationFromCacheableFiles(File mappingFi= leBase, String[] files) { - long start =3D System.currentTimeMillis(); - Configuration cfg =3D new Configuration(); - cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); - System.err.println( - "Created configuration: " + ( System.currentTimeMillis() - start ) / 1= 000.0 + " sec." - ); - - start =3D System.currentTimeMillis(); - //noinspection ForLoopReplaceableByForEach - for ( int i =3D 0; i < files.length; i++ ) { - cfg.addCacheableFile( new File( mappingFileBase, files[i] ) ); - } - System.err.println( - "Added " + ( files.length ) + " resources: " + - ( System.currentTimeMillis() - start ) / 1000.0 + " sec." - ); - return cfg; - } - - private void timeBuildingSessionFactory(Configuration configuration) { - long start =3D System.currentTimeMillis(); - System.err.println( "Start build of session factory" ); - SessionFactory factory =3D configuration.buildSessionFactory(); - System.err.println( "Built session factory :" + ( System.currentTimeMill= is() - start ) / 1000.0 + " sec." ); - factory.close(); - } - - private void readSerializedConfiguration(File cachedCfgFile) throws Class= NotFoundException, IOException { - long start =3D System.currentTimeMillis(); - ObjectInputStream is =3D new ObjectInputStream( new FileInputStream( cac= hedCfgFile ) ); - Configuration cfg =3D ( Configuration ) is.readObject(); - is.close(); - System.err.println( - "Loaded serializable configuration :" + - ( System.currentTimeMillis() - start ) / 1000.0 + " sec." - ); - - timeBuildingSessionFactory( cfg ); - } - - public void generateTestFiles() throws Throwable { - String filesToCompile =3D ""; - for ( int count =3D 0; count < 100; count++ ) { - String name =3D "Test" + count; - File javaFile =3D new File( workPackageDir, name + ".java" ); - File hbmFile =3D new File( workPackageDir, name + ".hbm.xml" ); - filesToCompile +=3D ( javaFile.getAbsolutePath() + " " ); - - System.out.println( "Generating " + javaFile.getAbsolutePath() ); - PrintWriter javaWriter =3D null; - PrintWriter hbmWriter =3D null; - try { - javaWriter =3D new PrintWriter( new FileWriter( javaFile ) ); - hbmWriter =3D new PrintWriter( new FileWriter( hbmFile ) ); - - javaWriter.println( "package " + workPackageName + ";" ); - hbmWriter.println( - "\r\n" + - "\= r\n" - ); - - hbmWriter.println( "" ); - - javaWriter.println( "public class " + name + " {" ); - javaWriter.println( " static { System.out.println(\"" + name + " initi= alized!\"); }" ); - hbmWriter.println( "" ); - - hbmWriter.println( "" ); - for ( int propCount =3D 0; propCount < 100; propCount++ ) { - String propName =3D "Prop" + propCount; - - writeJavaProperty( javaWriter, propName ); - - hbmWriter.println( "" ); - - } - hbmWriter.println( "" ); - javaWriter.println( "}" ); - hbmWriter.println( "" ); - } - finally { - if ( javaWriter !=3D null ) { - javaWriter.flush(); - javaWriter.close(); - } - if ( hbmWriter !=3D null ) { - hbmWriter.flush(); - hbmWriter.close(); - } - } - } - - String javac =3D "javac -version -d " + compilationBaseDir + " " + files= ToCompile; - System.err.println( "JAVAC : " + javac ); - Process process =3D Runtime.getRuntime().exec( javac ); - process.waitFor(); - System.err.println( "********************* JAVAC OUTPUT ****************= ******" ); - pullStream( process.getInputStream() ); - System.err.println( "---------------------------------------------------= ------" ); - pullStream( process.getErrorStream() ); - System.err.println( "***************************************************= ******" ); - } - - private void pullStream(InputStream stream) throws IOException { - if ( stream =3D=3D null || stream.available() <=3D 0 ) { - return; - } - byte[] buffer =3D new byte[256]; - while ( true ) { - int read =3D stream.read( buffer ); - if ( read =3D=3D -1 ) { - break; - } - System.err.write( buffer, 0, read ); - } -// System.err.println( "" ); - } - - private void writeJavaProperty(PrintWriter javaWriter, String propName) { - javaWriter.println( " String " + propName + ";" ); - javaWriter.println( " String get" + propName + "() { return " + propName= + "; }" ); - javaWriter.println( " void set" + propName + "(String newVal) { " + prop= Name + "=3DnewVal; }" ); - } - - private File getTestComplileDirectory() { - String resourceName =3D "org/hibernate/test/legacy/ABC.hbm.xml"; - String prefix =3D getClass().getClassLoader().getResource( resourceName = ).getFile(); - prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // ABC.hbm.= xml - prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // legacy/ - prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // test/ - prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // hibernat= e/ - prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // org/ - return new File( prefix + '/' ); - } -} Added: core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/Configurat= ionSerializationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/Configuration= SerializationTest.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/Configuration= SerializationTest.java 2009-11-12 19:46:04 UTC (rev 17964) @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.test.cfg; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.hibernate.junit.UnitTestCase; +import org.hibernate.cfg.Configuration; +import org.hibernate.util.SerializationHelper; +import org.hibernate.SessionFactory; + +/** + * Copied over mostly from ConfigurationPerformanceTest + * + * @author Steve Ebersole + * @author Max Andersen + */ +public class ConfigurationSerializationTest extends UnitTestCase { + public ConfigurationSerializationTest(String string) { + super( string ); + } + + public static Test suite() { + return new TestSuite( ConfigurationSerializationTest.class ); + } + + private static final String[] FILES =3D new String[] { + "legacy/ABC.hbm.xml", + "legacy/ABCExtends.hbm.xml", + "legacy/Baz.hbm.xml", + "legacy/Blobber.hbm.xml", + "legacy/Broken.hbm.xml", + "legacy/Category.hbm.xml", + "legacy/Circular.hbm.xml", + "legacy/Commento.hbm.xml", + "legacy/ComponentNotNullMaster.hbm.xml", + "legacy/Componentizable.hbm.xml", + "legacy/Container.hbm.xml", + "legacy/Custom.hbm.xml", + "legacy/CustomSQL.hbm.xml", + "legacy/Eye.hbm.xml", + "legacy/Fee.hbm.xml", + "legacy/Fo.hbm.xml", + "legacy/FooBar.hbm.xml", + "legacy/Fum.hbm.xml", + "legacy/Fumm.hbm.xml", + "legacy/Glarch.hbm.xml", + "legacy/Holder.hbm.xml", + "legacy/IJ2.hbm.xml", + "legacy/Immutable.hbm.xml", + "legacy/Location.hbm.xml", + "legacy/Many.hbm.xml", + "legacy/Map.hbm.xml", + "legacy/Marelo.hbm.xml", + "legacy/MasterDetail.hbm.xml", + "legacy/Middle.hbm.xml", + "legacy/Multi.hbm.xml", + "legacy/MultiExtends.hbm.xml", + "legacy/Nameable.hbm.xml", + "legacy/One.hbm.xml", + "legacy/ParentChild.hbm.xml", + "legacy/Qux.hbm.xml", + "legacy/Simple.hbm.xml", + "legacy/SingleSeveral.hbm.xml", + "legacy/Stuff.hbm.xml", + "legacy/UpDown.hbm.xml", + "legacy/Vetoer.hbm.xml", + "legacy/WZ.hbm.xml", + }; + + public void testConfiguraionSerializability() { + Configuration cfg =3D new Configuration(); + for ( String file : FILES ) { + cfg.addResource( "org/hibernate/test/" + file ); + } + + byte[] bytes =3D SerializationHelper.serialize( cfg ); + cfg =3D ( Configuration ) SerializationHelper.deserialize( bytes ); + + // try to build SF + SessionFactory factory =3D cfg.buildSessionFactory(); + factory.close(); + } +} Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/Listene= rTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/ListenerTest.= java 2009-11-12 16:17:12 UTC (rev 17963) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/cfg/ListenerTest.= java 2009-11-12 19:46:04 UTC (rev 17964) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.test.cfg; = import java.util.Set; Copied: core/trunk/testsuite/src/test/perf/org/hibernate/test/perf/Configur= ationPerformanceTest.java (from rev 17887, core/trunk/testsuite/src/test/ja= va/org/hibernate/test/cfg/ConfigurationPerformanceTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/perf/org/hibernate/test/perf/Configuratio= nPerformanceTest.java (rev 0) +++ core/trunk/testsuite/src/test/perf/org/hibernate/test/perf/Configuratio= nPerformanceTest.java 2009-11-12 19:46:04 UTC (rev 17964) @@ -0,0 +1,248 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.test.perf; + +import java.io.File; +import java.io.FileWriter; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; + +import junit.framework.Test; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +import org.hibernate.SessionFactory; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import org.hibernate.classic.Session; +import org.hibernate.junit.UnitTestCase; + +/** + * Test of configuration, specifically "cacheable files". + * + * @author Max Andersen + * @author Steve Ebersole + */ +public class ConfigurationPerformanceTest extends UnitTestCase { + + private final String workPackageName =3D "org.hibernate.test.cfg.work"; + private File compilationBaseDir; + private File workPackageDir; + + protected void setUp() throws Exception { + compilationBaseDir =3D getTestComplileDirectory(); + workPackageDir =3D new File( compilationBaseDir, workPackageName.replace= ( '.', '/' ) ); + if ( workPackageDir.exists() ) { + //noinspection ResultOfMethodCallIgnored + workPackageDir.delete(); + } + boolean created =3D workPackageDir.mkdirs(); + if ( !created ) { + System.err.println( "Unable to create workPackageDir during setup" ); + } + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + public ConfigurationPerformanceTest(String string) { + super( string ); + } + + public static Test suite() { + return new TestSuite( ConfigurationPerformanceTest.class ); + } + + public static void main(String[] args) throws Exception { + TestRunner.run( suite() ); + } + + public void testSessionFactoryCreationTime() throws Throwable { + generateTestFiles(); + if ( !workPackageDir.exists() ) { + System.err.println( workPackageDir.getAbsoluteFile() + " not found" ); + return; + } + + long start =3D System.currentTimeMillis(); + Configuration configuration =3D buildConfigurationFromCacheableFiles( + workPackageDir, + workPackageDir.list( + new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith( ".hbm.xml" ); + } + } + ) + ); + SessionFactory factory =3D configuration.buildSessionFactory(); + long initial =3D System.currentTimeMillis() - start; + factory.close(); + + start =3D System.currentTimeMillis(); + configuration =3D buildConfigurationFromCacheableFiles( + workPackageDir, + workPackageDir.list( + new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith( ".hbm.xml" ); + } + } + ) + ); + factory =3D configuration.buildSessionFactory(); + long subsequent =3D System.currentTimeMillis() - start; + + // Let's make sure the mappings were read in correctly (in termas of the= y are operational). + Session session =3D factory.openSession(); + session.beginTransaction(); + session.createQuery( "from Test1" ).list(); + session.getTransaction().commit(); + session.close(); + factory.close(); + + System.err.println( "Initial SessionFactory load time : " + initial ); + System.err.println( "Subsequent SessionFactory load time : " + subsequen= t ); + } + + private Configuration buildConfigurationFromCacheableFiles(File mappingFi= leBase, String[] files) { + long start =3D System.currentTimeMillis(); + Configuration cfg =3D new Configuration(); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + System.err.println( + "Created configuration: " + ( System.currentTimeMillis() - start ) / 1= 000.0 + " sec." + ); + + start =3D System.currentTimeMillis(); + //noinspection ForLoopReplaceableByForEach + for ( int i =3D 0; i < files.length; i++ ) { + cfg.addCacheableFile( new File( mappingFileBase, files[i] ) ); + } + System.err.println( + "Added " + ( files.length ) + " resources: " + + ( System.currentTimeMillis() - start ) / 1000.0 + " sec." + ); + return cfg; + } + + public void generateTestFiles() throws Throwable { + String filesToCompile =3D ""; + for ( int count =3D 0; count < 100; count++ ) { + String name =3D "Test" + count; + File javaFile =3D new File( workPackageDir, name + ".java" ); + File hbmFile =3D new File( workPackageDir, name + ".hbm.xml" ); + filesToCompile +=3D ( javaFile.getAbsolutePath() + " " ); + + System.out.println( "Generating " + javaFile.getAbsolutePath() ); + PrintWriter javaWriter =3D null; + PrintWriter hbmWriter =3D null; + try { + javaWriter =3D new PrintWriter( new FileWriter( javaFile ) ); + hbmWriter =3D new PrintWriter( new FileWriter( hbmFile ) ); + + javaWriter.println( "package " + workPackageName + ";" ); + hbmWriter.println( + "\r\n" + + "\= r\n" + ); + + hbmWriter.println( "" ); + + javaWriter.println( "public class " + name + " {" ); + javaWriter.println( " static { System.out.println(\"" + name + " initi= alized!\"); }" ); + hbmWriter.println( "" ); + + hbmWriter.println( "" ); + for ( int propCount =3D 0; propCount < 100; propCount++ ) { + String propName =3D "Prop" + propCount; + + writeJavaProperty( javaWriter, propName ); + + hbmWriter.println( "" ); + + } + hbmWriter.println( "" ); + javaWriter.println( "}" ); + hbmWriter.println( "" ); + } + finally { + if ( javaWriter !=3D null ) { + javaWriter.flush(); + javaWriter.close(); + } + if ( hbmWriter !=3D null ) { + hbmWriter.flush(); + hbmWriter.close(); + } + } + } + + String javac =3D "javac -version -d " + compilationBaseDir + " " + files= ToCompile; + System.err.println( "JAVAC : " + javac ); + Process process =3D Runtime.getRuntime().exec( javac ); + process.waitFor(); + System.err.println( "********************* JAVAC OUTPUT ****************= ******" ); + pullStream( process.getInputStream() ); + System.err.println( "---------------------------------------------------= ------" ); + pullStream( process.getErrorStream() ); + System.err.println( "***************************************************= ******" ); + } + + private void pullStream(InputStream stream) throws IOException { + if ( stream =3D=3D null || stream.available() <=3D 0 ) { + return; + } + byte[] buffer =3D new byte[256]; + while ( true ) { + int read =3D stream.read( buffer ); + if ( read =3D=3D -1 ) { + break; + } + System.err.write( buffer, 0, read ); + } +// System.err.println( "" ); + } + + private void writeJavaProperty(PrintWriter javaWriter, String propName) { + javaWriter.println( " String " + propName + ";" ); + javaWriter.println( " String get" + propName + "() { return " + propName= + "; }" ); + javaWriter.println( " void set" + propName + "(String newVal) { " + prop= Name + "=3DnewVal; }" ); + } + + private File getTestComplileDirectory() { + String resourceName =3D "org/hibernate/test/legacy/ABC.hbm.xml"; + String prefix =3D getClass().getClassLoader().getResource( resourceName = ).getFile(); + prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // ABC.hbm.= xml + prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // legacy/ + prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // test/ + prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // hibernat= e/ + prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // org/ + return new File( prefix + '/' ); + } +} --===============1557665224899299619==-- From hibernate-commits at lists.jboss.org Thu Nov 12 14:46:52 2009 Content-Type: multipart/mixed; boundary="===============3124397643189097199==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17965 - in core/branches/Branch_3_3: testsuite/src/test/java/org/hibernate/test/cfg and 1 other directories. Date: Thu, 12 Nov 2009 14:46:52 -0500 Message-ID: <200911121946.nACJkqAa006238@svn01.web.mwc.hst.phx2.redhat.com> --===============3124397643189097199== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-12 14:46:51 -0500 (Thu, 12 Nov 2009) New Revision: 17965 Added: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg/= ConfigurationSerializationTest.java core/branches/Branch_3_3/testsuite/src/test/perf/org/hibernate/test/perf= /ConfigurationPerformanceTest.java Removed: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg/= ConfigurationPerformanceTest.java Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Configurat= ion.java core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg/= CacheableFileTest.java core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg/= ListenerTest.java Log: HHH-4569 - Split focus of ConfigurationPerformanceTest Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Con= figuration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Configura= tion.java 2009-11-12 19:46:04 UTC (rev 17964) +++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Configura= tion.java 2009-11-12 19:46:51 UTC (rev 17965) @@ -384,70 +384,85 @@ * the non-cached file. */ public Configuration addCacheableFile(File xmlFile) throws MappingExcepti= on { + File cachedFile =3D determineCachedDomFile( xmlFile ); + try { - File cachedFile =3D new File( xmlFile.getAbsolutePath() + ".bin" ); - org.dom4j.Document doc =3D null; + return addCacheableFileStrictly( xmlFile ); + } + catch ( SerializationException e ) { + log.warn( "Could not deserialize cache file: " + cachedFile.getPath() += " : " + e ); + } + catch ( FileNotFoundException e ) { + log.warn( "I/O reported cached file could not be found : " + cachedFile= .getPath() + " : " + e ); + } = - final boolean useCachedFile =3D xmlFile.exists() && - cachedFile.exists() && - xmlFile.lastModified() < cachedFile.lastModified(); + if ( !xmlFile.exists() ) { + throw new MappingNotFoundException( "file", xmlFile.toString() ); + } = - if ( useCachedFile ) { - try { - log.info( "Reading mappings from cache file: " + cachedFile ); - doc =3D ( org.dom4j.Document ) SerializationHelper.deserialize( new F= ileInputStream( cachedFile ) ); - } - catch ( SerializationException e ) { - log.warn( "Could not deserialize cache file: " + cachedFile.getPath()= , e ); - } - catch ( FileNotFoundException e ) { - log.warn( "I/O reported cached file could not be found : " + cachedFi= le.getPath(), e ); - } + log.info( "Reading mappings from file: " + xmlFile ); + List errors =3D new ArrayList(); + try { + org.dom4j.Document doc =3D xmlHelper.createSAXReader( xmlFile.getAbsolu= tePath(), errors, entityResolver ).read( xmlFile ); + if ( errors.size() !=3D 0 ) { + throw new MappingException( "invalid mapping", ( Throwable ) errors.ge= t( 0 ) ); } = - // if doc is null, then for whatever reason, the cached file cannot be = used... - if ( doc =3D=3D null ) { - if ( !xmlFile.exists() ) { - throw new MappingNotFoundException( "file", xmlFile.toString() ); - } - - log.info( "Reading mappings from file: " + xmlFile ); - List errors =3D new ArrayList(); - try { - doc =3D xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors,= entityResolver ).read( xmlFile ); - if ( errors.size() !=3D 0 ) { - throw new MappingException( "invalid mapping", ( Throwable ) errors.= get( 0 ) ); - } - } - catch( DocumentException e){ - throw new MappingException( "invalid mapping", e ); - } - - try { - log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFil= e ); - SerializationHelper.serialize( ( Serializable ) doc, new FileOutputSt= ream( cachedFile ) ); - } - catch ( SerializationException e ) { - log.warn( "Could not write cached file: " + cachedFile, e ); - } - catch ( FileNotFoundException e ) { - log.warn( "I/O reported error writing cached file : " + cachedFile.ge= tPath(), e ); - } + try { + log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFile= ); + SerializationHelper.serialize( ( Serializable ) doc, new FileOutputStr= eam( cachedFile ) ); } + catch ( SerializationException e ) { + log.warn( "Could not write cached file: " + cachedFile, e ); + } + catch ( FileNotFoundException e ) { + log.warn( "I/O reported error writing cached file : " + cachedFile.get= Path(), e ); + } = add( doc ); - return this; - } - catch ( InvalidMappingException e ) { - throw e; + catch( DocumentException e){ + throw new MappingException( "invalid mapping", e ); } - catch ( MappingNotFoundException e ) { - throw e; + + return this; + } + + private File determineCachedDomFile(File xmlFile) { + return new File( xmlFile.getAbsolutePath() + ".bin" ); + } + + /** + * INTENDED FOR TESTSUITE USE ONLY! + *

+ * Much like {@link addCacheableFile(File)} except that here we will fail= immediately if + * the cache version cannot be found or used for whatever reason + * + * @param xmlFile The xml file, not the bin! + * + * @return The dom "deserialized" from the cached file. + * + * @throws MappingException Indicates a problem in the underlyiong call t= o {@link #add(org.dom4j.Document)} + * @throws SerializationException Indicates a problem deserializing the c= ached dom tree + * @throws FileNotFoundException Indicates that the cached file was not f= ound or was not usable. + */ + public Configuration addCacheableFileStrictly(File xmlFile) + throws MappingException, SerializationException, FileNotFoundException { + final File cachedFile =3D determineCachedDomFile( xmlFile ); + + final boolean useCachedFile =3D xmlFile.exists() + && cachedFile.exists() + && xmlFile.lastModified() < cachedFile.lastModified(); + + if ( ! useCachedFile ) { + throw new FileNotFoundException( "Cached file could not be found or cou= ld not be used" ); } - catch ( Exception e ) { - throw new InvalidMappingException( "file", xmlFile.toString(), e ); - } + + log.info( "Reading mappings from cache file: " + cachedFile ); + org.dom4j.Document document =3D + ( org.dom4j.Document ) SerializationHelper.deserialize( new FileInputS= tream( cachedFile ) ); + add( document ); + return this; } = /** Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/te= st/cfg/CacheableFileTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg= /CacheableFileTest.java 2009-11-12 19:46:04 UTC (rev 17964) +++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg= /CacheableFileTest.java 2009-11-12 19:46:51 UTC (rev 17965) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.test.cfg; = import java.io.File; @@ -4,17 +27,18 @@ = import org.hibernate.cfg.Configuration; import org.hibernate.junit.UnitTestCase; +import org.hibernate.util.SerializationHelper; = /** - * {@inheritDoc} + * Tests using of cacheable configuration files. * * @author Steve Ebersole */ public class CacheableFileTest extends UnitTestCase { - public static final String MAPPING =3D "org/hibernate/test/cfg/Cacheable.= hbm.xml"; = private File mappingFile; + private File mappingBinFile; = public CacheableFileTest(String string) { super( string ); @@ -24,21 +48,31 @@ super.setUp(); mappingFile =3D new File( getClass().getClassLoader().getResource( MAPPI= NG ).toURI() ); assertTrue( mappingFile.exists() ); - File cached =3D new File( mappingFile.getParentFile(), mappingFile.getNa= me() + ".bin" ); - if ( cached.exists() ) { - cached.delete(); + mappingBinFile =3D new File( mappingFile.getParentFile(), mappingFile.ge= tName() + ".bin" ); + if ( mappingBinFile.exists() ) { + //noinspection ResultOfMethodCallIgnored + mappingBinFile.delete(); } } = protected void tearDown() throws Exception { + if ( mappingBinFile !=3D null && mappingBinFile.exists() ) { + // be nice + //noinspection ResultOfMethodCallIgnored + mappingBinFile.delete(); + } + mappingBinFile =3D null; mappingFile =3D null; super.tearDown(); } = - public void testCachedFiles() { - Configuration cfg =3D new Configuration(); - cfg.addCacheableFile( mappingFile ); - Configuration cfg2 =3D new Configuration(); - cfg2.addCacheableFile( mappingFile ); + public void testCachedFiles() throws Exception { + assertFalse( mappingBinFile.exists() ); + // This call should create the cached file + new Configuration().addCacheableFile( mappingFile ); + assertTrue( mappingBinFile.exists() ); + + Configuration cfg =3D new Configuration().addCacheableFileStrictly( mapp= ingFile ); + SerializationHelper.clone( cfg ); } } Deleted: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/tes= t/cfg/ConfigurationPerformanceTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg= /ConfigurationPerformanceTest.java 2009-11-12 19:46:04 UTC (rev 17964) +++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg= /ConfigurationPerformanceTest.java 2009-11-12 19:46:51 UTC (rev 17965) @@ -1,353 +0,0 @@ -/* - * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, v. 2.1. This program is distributed in t= he - * hope that it will be useful, but WITHOUT A WARRANTY; without even the i= mplied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See th= e GNU - * Lesser General Public License for more details. You should have receive= d a - * copy of the GNU Lesser General Public License, v.2.1 along with this - * distribution; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Red Hat Author(s): Max Andersen, Steve Ebersole - */ -package org.hibernate.test.cfg; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.PrintWriter; - -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; -import org.hibernate.cfg.Environment; -import org.hibernate.classic.Session; -import org.hibernate.junit.UnitTestCase; - -/** - * Test of configuration, specifically "cacheable files". - * - * @author Max Andersen - * @author Steve Ebersole - */ -public class ConfigurationPerformanceTest extends UnitTestCase { - - private final String workPackageName =3D "org.hibernate.test.cfg.work"; - private File compilationBaseDir; - private File mappingBaseDir; - private File workPackageDir; - - protected void setUp() throws Exception { - compilationBaseDir =3D getTestComplileDirectory(); - mappingBaseDir =3D new File( compilationBaseDir, "org/hibernate/test" ); - workPackageDir =3D new File( compilationBaseDir, workPackageName.replace= ( '.', '/' ) ); - if ( workPackageDir.exists() ) { - //noinspection ResultOfMethodCallIgnored - workPackageDir.delete(); - } - boolean created =3D workPackageDir.mkdirs(); - if ( !created ) { - System.err.println( "Unable to create workPackageDir during setup" ); - } - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - private static final String[] FILES =3D new String[] { - "legacy/ABC.hbm.xml", - "legacy/ABCExtends.hbm.xml", - "legacy/Baz.hbm.xml", - "legacy/Blobber.hbm.xml", - "legacy/Broken.hbm.xml", - "legacy/Category.hbm.xml", - "legacy/Circular.hbm.xml", - "legacy/Commento.hbm.xml", - "legacy/ComponentNotNullMaster.hbm.xml", - "legacy/Componentizable.hbm.xml", - "legacy/Container.hbm.xml", - "legacy/Custom.hbm.xml", - "legacy/CustomSQL.hbm.xml", - "legacy/Eye.hbm.xml", - "legacy/Fee.hbm.xml", - "legacy/Fo.hbm.xml", - "legacy/FooBar.hbm.xml", - "legacy/Fum.hbm.xml", - "legacy/Fumm.hbm.xml", - "legacy/Glarch.hbm.xml", - "legacy/Holder.hbm.xml", - "legacy/IJ2.hbm.xml", - "legacy/Immutable.hbm.xml", - "legacy/Location.hbm.xml", - "legacy/Many.hbm.xml", - "legacy/Map.hbm.xml", - "legacy/Marelo.hbm.xml", - "legacy/MasterDetail.hbm.xml", - "legacy/Middle.hbm.xml", - "legacy/Multi.hbm.xml", - "legacy/MultiExtends.hbm.xml", - "legacy/Nameable.hbm.xml", - "legacy/One.hbm.xml", - "legacy/ParentChild.hbm.xml", - "legacy/Qux.hbm.xml", - "legacy/Simple.hbm.xml", - "legacy/SingleSeveral.hbm.xml", - "legacy/Stuff.hbm.xml", - "legacy/UpDown.hbm.xml", - "legacy/Vetoer.hbm.xml", - "legacy/WZ.hbm.xml", - }; - - public ConfigurationPerformanceTest(String string) { - super( string ); - } - - public static Test suite() { - return new TestSuite( ConfigurationPerformanceTest.class ); - } - - public static void main(String[] args) throws Exception { - TestRunner.run( suite() ); - } - - public void testLoadingAndSerializationOfConfiguration() throws Throwable= { - final File cachedCfgFile =3D new File( workPackageDir, "hibernate.cfg.bi= n" ); - try { - System.err.println( "#### Preparing serialized configuration ~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~~~" ); - prepareSerializedConfiguration( mappingBaseDir, FILES, cachedCfgFile ); - System.err.println( "#### Preparing serialized configuration complete ~= ~~~~~~~~~~~~~~~~~~~~~~~" ); - - // now make sure we can reload the serialized configuration... - System.err.println( "#### Reading serialized configuration ~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~~~" ); - readSerializedConfiguration( cachedCfgFile ); - System.err.println( "#### Reading serialized configuration complete ~~~= ~~~~~~~~~~~~~~~~~~~~~~~" ); - } - finally { - System.err.println( "###CLEANING UP###" ); - if ( ! cachedCfgFile.delete() ) { - System.err.println( "Unable to cleanup file " + cachedCfgFile.getAbsol= utePath() ); - } - - //noinspection ForLoopReplaceableByForEach - for ( int i =3D 0; i < FILES.length; i++ ) { - File file =3D new File( mappingBaseDir, FILES[i] + ".bin" ); - if ( ! file.delete() ) { - System.err.println( "Unable to cleanup file " + file.getAbsolutePath(= ) ); - } - } - } - } - - public void testSessionFactoryCreationTime() throws Throwable { - generateTestFiles(); - if ( !workPackageDir.exists() ) { - System.err.println( workPackageDir.getAbsoluteFile() + " not found" ); - return; - } - - long start =3D System.currentTimeMillis(); - Configuration configuration =3D buildConfigurationFromCacheableFiles( - workPackageDir, - workPackageDir.list( - new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.endsWith( ".hbm.xml" ); - } - } - ) - ); - SessionFactory factory =3D configuration.buildSessionFactory(); - long initial =3D System.currentTimeMillis() - start; - factory.close(); - - start =3D System.currentTimeMillis(); - configuration =3D buildConfigurationFromCacheableFiles( - workPackageDir, - workPackageDir.list( - new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.endsWith( ".hbm.xml" ); - } - } - ) - ); - factory =3D configuration.buildSessionFactory(); - long subsequent =3D System.currentTimeMillis() - start; - - // Let's make sure the mappings were read in correctly (in termas of the= y are operational). - Session session =3D factory.openSession(); - session.beginTransaction(); - session.createQuery( "from Test1" ).list(); - session.getTransaction().commit(); - session.close(); - factory.close(); - - System.err.println( "Initial SessionFactory load time : " + initial ); - System.err.println( "Subsequent SessionFactory load time : " + subsequen= t ); - } - - private void prepareSerializedConfiguration( - File mappingFileBase, - String[] files, - File cachedCfgFile) throws IOException { - Configuration cfg =3D buildConfigurationFromCacheableFiles( mappingFileB= ase, files ); - - ObjectOutputStream os =3D new ObjectOutputStream( new FileOutputStream( = cachedCfgFile ) ); - os.writeObject( cfg ); // need to serialize Configuration *before* build= ing sf since it would require non-mappings and cfg types to be serializable - os.flush(); - os.close(); - - timeBuildingSessionFactory( cfg ); - } - - private Configuration buildConfigurationFromCacheableFiles(File mappingFi= leBase, String[] files) { - long start =3D System.currentTimeMillis(); - Configuration cfg =3D new Configuration(); - cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); - System.err.println( - "Created configuration: " + ( System.currentTimeMillis() - start ) / 1= 000.0 + " sec." - ); - - start =3D System.currentTimeMillis(); - //noinspection ForLoopReplaceableByForEach - for ( int i =3D 0; i < files.length; i++ ) { - cfg.addCacheableFile( new File( mappingFileBase, files[i] ) ); - } - System.err.println( - "Added " + ( files.length ) + " resources: " + - ( System.currentTimeMillis() - start ) / 1000.0 + " sec." - ); - return cfg; - } - - private void timeBuildingSessionFactory(Configuration configuration) { - long start =3D System.currentTimeMillis(); - System.err.println( "Start build of session factory" ); - SessionFactory factory =3D configuration.buildSessionFactory(); - System.err.println( "Built session factory :" + ( System.currentTimeMill= is() - start ) / 1000.0 + " sec." ); - factory.close(); - } - - private void readSerializedConfiguration(File cachedCfgFile) throws Class= NotFoundException, IOException { - long start =3D System.currentTimeMillis(); - ObjectInputStream is =3D new ObjectInputStream( new FileInputStream( cac= hedCfgFile ) ); - Configuration cfg =3D ( Configuration ) is.readObject(); - is.close(); - System.err.println( - "Loaded serializable configuration :" + - ( System.currentTimeMillis() - start ) / 1000.0 + " sec." - ); - - timeBuildingSessionFactory( cfg ); - } - - public void generateTestFiles() throws Throwable { - String filesToCompile =3D ""; - for ( int count =3D 0; count < 100; count++ ) { - String name =3D "Test" + count; - File javaFile =3D new File( workPackageDir, name + ".java" ); - File hbmFile =3D new File( workPackageDir, name + ".hbm.xml" ); - filesToCompile +=3D ( javaFile.getAbsolutePath() + " " ); - - System.out.println( "Generating " + javaFile.getAbsolutePath() ); - PrintWriter javaWriter =3D null; - PrintWriter hbmWriter =3D null; - try { - javaWriter =3D new PrintWriter( new FileWriter( javaFile ) ); - hbmWriter =3D new PrintWriter( new FileWriter( hbmFile ) ); - - javaWriter.println( "package " + workPackageName + ";" ); - hbmWriter.println( - "\r\n" + - "\= r\n" - ); - - hbmWriter.println( "" ); - - javaWriter.println( "public class " + name + " {" ); - javaWriter.println( " static { System.out.println(\"" + name + " initi= alized!\"); }" ); - hbmWriter.println( "" ); - - hbmWriter.println( "" ); - for ( int propCount =3D 0; propCount < 100; propCount++ ) { - String propName =3D "Prop" + propCount; - - writeJavaProperty( javaWriter, propName ); - - hbmWriter.println( "" ); - - } - hbmWriter.println( "" ); - javaWriter.println( "}" ); - hbmWriter.println( "" ); - } - finally { - if ( javaWriter !=3D null ) { - javaWriter.flush(); - javaWriter.close(); - } - if ( hbmWriter !=3D null ) { - hbmWriter.flush(); - hbmWriter.close(); - } - } - } - - String javac =3D "javac -version -d " + compilationBaseDir + " " + files= ToCompile; - System.err.println( "JAVAC : " + javac ); - Process process =3D Runtime.getRuntime().exec( javac ); - process.waitFor(); - System.err.println( "********************* JAVAC OUTPUT ****************= ******" ); - pullStream( process.getInputStream() ); - System.err.println( "---------------------------------------------------= ------" ); - pullStream( process.getErrorStream() ); - System.err.println( "***************************************************= ******" ); - } - - private void pullStream(InputStream stream) throws IOException { - if ( stream =3D=3D null || stream.available() <=3D 0 ) { - return; - } - byte[] buffer =3D new byte[256]; - while ( true ) { - int read =3D stream.read( buffer ); - if ( read =3D=3D -1 ) { - break; - } - System.err.write( buffer, 0, read ); - } -// System.err.println( "" ); - } - - private void writeJavaProperty(PrintWriter javaWriter, String propName) { - javaWriter.println( " String " + propName + ";" ); - javaWriter.println( " String get" + propName + "() { return " + propName= + "; }" ); - javaWriter.println( " void set" + propName + "(String newVal) { " + prop= Name + "=3DnewVal; }" ); - } - - private File getTestComplileDirectory() { - String resourceName =3D "org/hibernate/test/legacy/ABC.hbm.xml"; - String prefix =3D getClass().getClassLoader().getResource( resourceName = ).getFile(); - prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // ABC.hbm.= xml - prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // legacy/ - prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // test/ - prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // hibernat= e/ - prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // org/ - return new File( prefix + '/' ); - } -} Added: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/= cfg/ConfigurationSerializationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg= /ConfigurationSerializationTest.java (rev 0) +++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg= /ConfigurationSerializationTest.java 2009-11-12 19:46:51 UTC (rev 17965) @@ -0,0 +1,106 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.test.cfg; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.hibernate.junit.UnitTestCase; +import org.hibernate.cfg.Configuration; +import org.hibernate.util.SerializationHelper; +import org.hibernate.SessionFactory; + +/** + * Copied over mostly from ConfigurationPerformanceTest + * + * @author Steve Ebersole + * @author Max Andersen + */ +public class ConfigurationSerializationTest extends UnitTestCase { + public ConfigurationSerializationTest(String string) { + super( string ); + } + + public static Test suite() { + return new TestSuite( ConfigurationSerializationTest.class ); + } + + private static final String[] FILES =3D new String[] { + "legacy/ABC.hbm.xml", + "legacy/ABCExtends.hbm.xml", + "legacy/Baz.hbm.xml", + "legacy/Blobber.hbm.xml", + "legacy/Broken.hbm.xml", + "legacy/Category.hbm.xml", + "legacy/Circular.hbm.xml", + "legacy/Commento.hbm.xml", + "legacy/ComponentNotNullMaster.hbm.xml", + "legacy/Componentizable.hbm.xml", + "legacy/Container.hbm.xml", + "legacy/Custom.hbm.xml", + "legacy/CustomSQL.hbm.xml", + "legacy/Eye.hbm.xml", + "legacy/Fee.hbm.xml", + "legacy/Fo.hbm.xml", + "legacy/FooBar.hbm.xml", + "legacy/Fum.hbm.xml", + "legacy/Fumm.hbm.xml", + "legacy/Glarch.hbm.xml", + "legacy/Holder.hbm.xml", + "legacy/IJ2.hbm.xml", + "legacy/Immutable.hbm.xml", + "legacy/Location.hbm.xml", + "legacy/Many.hbm.xml", + "legacy/Map.hbm.xml", + "legacy/Marelo.hbm.xml", + "legacy/MasterDetail.hbm.xml", + "legacy/Middle.hbm.xml", + "legacy/Multi.hbm.xml", + "legacy/MultiExtends.hbm.xml", + "legacy/Nameable.hbm.xml", + "legacy/One.hbm.xml", + "legacy/ParentChild.hbm.xml", + "legacy/Qux.hbm.xml", + "legacy/Simple.hbm.xml", + "legacy/SingleSeveral.hbm.xml", + "legacy/Stuff.hbm.xml", + "legacy/UpDown.hbm.xml", + "legacy/Vetoer.hbm.xml", + "legacy/WZ.hbm.xml", + }; + + public void testConfiguraionSerializability() { + Configuration cfg =3D new Configuration(); + for ( String file : FILES ) { + cfg.addResource( "org/hibernate/test/" + file ); + } + + byte[] bytes =3D SerializationHelper.serialize( cfg ); + cfg =3D ( Configuration ) SerializationHelper.deserialize( bytes ); + + // try to build SF + SessionFactory factory =3D cfg.buildSessionFactory(); + factory.close(); + } +} Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/te= st/cfg/ListenerTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg= /ListenerTest.java 2009-11-12 19:46:04 UTC (rev 17964) +++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/cfg= /ListenerTest.java 2009-11-12 19:46:51 UTC (rev 17965) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.test.cfg; = import java.util.Set; Copied: core/branches/Branch_3_3/testsuite/src/test/perf/org/hibernate/test= /perf/ConfigurationPerformanceTest.java (from rev 16994, core/branches/Bran= ch_3_3/testsuite/src/test/java/org/hibernate/test/cfg/ConfigurationPerforma= nceTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/testsuite/src/test/perf/org/hibernate/test/per= f/ConfigurationPerformanceTest.java (rev 0) +++ core/branches/Branch_3_3/testsuite/src/test/perf/org/hibernate/test/per= f/ConfigurationPerformanceTest.java 2009-11-12 19:46:51 UTC (rev 17965) @@ -0,0 +1,248 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.test.perf; + +import java.io.File; +import java.io.FileWriter; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; + +import junit.framework.Test; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +import org.hibernate.SessionFactory; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import org.hibernate.classic.Session; +import org.hibernate.junit.UnitTestCase; + +/** + * Test of configuration, specifically "cacheable files". + * + * @author Max Andersen + * @author Steve Ebersole + */ +public class ConfigurationPerformanceTest extends UnitTestCase { + + private final String workPackageName =3D "org.hibernate.test.cfg.work"; + private File compilationBaseDir; + private File workPackageDir; + + protected void setUp() throws Exception { + compilationBaseDir =3D getTestComplileDirectory(); + workPackageDir =3D new File( compilationBaseDir, workPackageName.replace= ( '.', '/' ) ); + if ( workPackageDir.exists() ) { + //noinspection ResultOfMethodCallIgnored + workPackageDir.delete(); + } + boolean created =3D workPackageDir.mkdirs(); + if ( !created ) { + System.err.println( "Unable to create workPackageDir during setup" ); + } + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + public ConfigurationPerformanceTest(String string) { + super( string ); + } + + public static Test suite() { + return new TestSuite( ConfigurationPerformanceTest.class ); + } + + public static void main(String[] args) throws Exception { + TestRunner.run( suite() ); + } + + public void testSessionFactoryCreationTime() throws Throwable { + generateTestFiles(); + if ( !workPackageDir.exists() ) { + System.err.println( workPackageDir.getAbsoluteFile() + " not found" ); + return; + } + + long start =3D System.currentTimeMillis(); + Configuration configuration =3D buildConfigurationFromCacheableFiles( + workPackageDir, + workPackageDir.list( + new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith( ".hbm.xml" ); + } + } + ) + ); + SessionFactory factory =3D configuration.buildSessionFactory(); + long initial =3D System.currentTimeMillis() - start; + factory.close(); + + start =3D System.currentTimeMillis(); + configuration =3D buildConfigurationFromCacheableFiles( + workPackageDir, + workPackageDir.list( + new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith( ".hbm.xml" ); + } + } + ) + ); + factory =3D configuration.buildSessionFactory(); + long subsequent =3D System.currentTimeMillis() - start; + + // Let's make sure the mappings were read in correctly (in termas of the= y are operational). + Session session =3D factory.openSession(); + session.beginTransaction(); + session.createQuery( "from Test1" ).list(); + session.getTransaction().commit(); + session.close(); + factory.close(); + + System.err.println( "Initial SessionFactory load time : " + initial ); + System.err.println( "Subsequent SessionFactory load time : " + subsequen= t ); + } + + private Configuration buildConfigurationFromCacheableFiles(File mappingFi= leBase, String[] files) { + long start =3D System.currentTimeMillis(); + Configuration cfg =3D new Configuration(); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + System.err.println( + "Created configuration: " + ( System.currentTimeMillis() - start ) / 1= 000.0 + " sec." + ); + + start =3D System.currentTimeMillis(); + //noinspection ForLoopReplaceableByForEach + for ( int i =3D 0; i < files.length; i++ ) { + cfg.addCacheableFile( new File( mappingFileBase, files[i] ) ); + } + System.err.println( + "Added " + ( files.length ) + " resources: " + + ( System.currentTimeMillis() - start ) / 1000.0 + " sec." + ); + return cfg; + } + + public void generateTestFiles() throws Throwable { + String filesToCompile =3D ""; + for ( int count =3D 0; count < 100; count++ ) { + String name =3D "Test" + count; + File javaFile =3D new File( workPackageDir, name + ".java" ); + File hbmFile =3D new File( workPackageDir, name + ".hbm.xml" ); + filesToCompile +=3D ( javaFile.getAbsolutePath() + " " ); + + System.out.println( "Generating " + javaFile.getAbsolutePath() ); + PrintWriter javaWriter =3D null; + PrintWriter hbmWriter =3D null; + try { + javaWriter =3D new PrintWriter( new FileWriter( javaFile ) ); + hbmWriter =3D new PrintWriter( new FileWriter( hbmFile ) ); + + javaWriter.println( "package " + workPackageName + ";" ); + hbmWriter.println( + "\r\n" + + "\= r\n" + ); + + hbmWriter.println( "" ); + + javaWriter.println( "public class " + name + " {" ); + javaWriter.println( " static { System.out.println(\"" + name + " initi= alized!\"); }" ); + hbmWriter.println( "" ); + + hbmWriter.println( "" ); + for ( int propCount =3D 0; propCount < 100; propCount++ ) { + String propName =3D "Prop" + propCount; + + writeJavaProperty( javaWriter, propName ); + + hbmWriter.println( "" ); + + } + hbmWriter.println( "" ); + javaWriter.println( "}" ); + hbmWriter.println( "" ); + } + finally { + if ( javaWriter !=3D null ) { + javaWriter.flush(); + javaWriter.close(); + } + if ( hbmWriter !=3D null ) { + hbmWriter.flush(); + hbmWriter.close(); + } + } + } + + String javac =3D "javac -version -d " + compilationBaseDir + " " + files= ToCompile; + System.err.println( "JAVAC : " + javac ); + Process process =3D Runtime.getRuntime().exec( javac ); + process.waitFor(); + System.err.println( "********************* JAVAC OUTPUT ****************= ******" ); + pullStream( process.getInputStream() ); + System.err.println( "---------------------------------------------------= ------" ); + pullStream( process.getErrorStream() ); + System.err.println( "***************************************************= ******" ); + } + + private void pullStream(InputStream stream) throws IOException { + if ( stream =3D=3D null || stream.available() <=3D 0 ) { + return; + } + byte[] buffer =3D new byte[256]; + while ( true ) { + int read =3D stream.read( buffer ); + if ( read =3D=3D -1 ) { + break; + } + System.err.write( buffer, 0, read ); + } +// System.err.println( "" ); + } + + private void writeJavaProperty(PrintWriter javaWriter, String propName) { + javaWriter.println( " String " + propName + ";" ); + javaWriter.println( " String get" + propName + "() { return " + propName= + "; }" ); + javaWriter.println( " void set" + propName + "(String newVal) { " + prop= Name + "=3DnewVal; }" ); + } + + private File getTestComplileDirectory() { + String resourceName =3D "org/hibernate/test/legacy/ABC.hbm.xml"; + String prefix =3D getClass().getClassLoader().getResource( resourceName = ).getFile(); + prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // ABC.hbm.= xml + prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // legacy/ + prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // test/ + prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // hibernat= e/ + prefix =3D prefix.substring( 0, prefix.lastIndexOf( '/' ) ); // org/ + return new File( prefix + '/' ); + } +} --===============3124397643189097199==-- From hibernate-commits at lists.jboss.org Thu Nov 12 14:55:39 2009 Content-Type: multipart/mixed; boundary="===============1500065929040527631==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17966 - sandbox/trunk/new-metadata. Date: Thu, 12 Nov 2009 14:55:39 -0500 Message-ID: <200911121955.nACJtd9Y007330@svn01.web.mwc.hst.phx2.redhat.com> --===============1500065929040527631== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-12 14:55:38 -0500 (Thu, 12 Nov 2009) New Revision: 17966 Modified: sandbox/trunk/new-metadata/ Log: svn ignores Property changes on: sandbox/trunk/new-metadata ___________________________________________________________________ Name: svn:ignore + target local *.ipr *.iws *.iml .classpath .project .nbattrs *.log *.properties .clover .idea --===============1500065929040527631==-- From hibernate-commits at lists.jboss.org Thu Nov 12 15:52:13 2009 Content-Type: multipart/mixed; boundary="===============4601152390237621229==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17967 - in sandbox/trunk/new-metadata: src and 8 other directories. Date: Thu, 12 Nov 2009 15:52:13 -0500 Message-ID: <200911122052.nACKqDPv017605@svn01.web.mwc.hst.phx2.redhat.com> --===============4601152390237621229== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-12 15:52:13 -0500 (Thu, 12 Nov 2009) New Revision: 17967 Added: sandbox/trunk/new-metadata/build.gradle sandbox/trunk/new-metadata/settings.gradle sandbox/trunk/new-metadata/src/ sandbox/trunk/new-metadata/src/main/ sandbox/trunk/new-metadata/src/main/java/ sandbox/trunk/new-metadata/src/main/java/org/ sandbox/trunk/new-metadata/src/main/java/org/hibernate/ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Nat= ure.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/pac= kage.html sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/= DatatypeMapping.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/= package.html sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/A= bstractColumn.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/A= bstractColumnConstraint.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/A= bstractTable.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/C= olumn.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/C= onstraint.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/D= atatype.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/D= erivedColumn.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/E= xportable.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/F= oreignKey.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/I= ndex.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/L= ogicalTable.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/P= hysicalColumn.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/P= hysicalTable.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/P= rimaryKey.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/T= able.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/U= niqueKey.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/p= ackage.html Modified: sandbox/trunk/new-metadata/ Log: selective move from local working Property changes on: sandbox/trunk/new-metadata ___________________________________________________________________ Name: svn:ignore - target local *.ipr *.iws *.iml .classpath .project .nbattrs *.log *.properties .clover .idea + target build local *.ipr *.iws *.iml .classpath .project .nbattrs *.log *.properties .clover .idea Added: sandbox/trunk/new-metadata/build.gradle =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/build.gradle (rev 0) +++ sandbox/trunk/new-metadata/build.gradle 2009-11-12 20:52:13 UTC (rev 17= 967) @@ -0,0 +1,40 @@ +usePlugin('java') + +defaultTasks 'classes' + +repositories { + mavenCentral() + mavenRepo name: "jboss", urls: "http://repository.jboss.org/maven2/" + mavenRepo name: "jboss-snapshots", urls: "http://snapshots.jboss.org/m= aven2/" +} + +group =3D 'org.hibernate.sandbox' +version =3D '1.0.0-SNAPSHOT' + +dependencies { + hibernateVersion =3D '3.3.2.GA' + slf4jVersion =3D '1.5.8' + jtaVersion =3D '1.1' + javassistVersion =3D '3.9.0.GA' + + junitVersion =3D '3.8.2' + + h2Version =3D '1.0.79' + + compile( + [group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion], + [group: 'org.hibernate', name: 'hibernate-core', version: hibe= rnateVersion] + ) + testCompile( + [group: 'junit', name: 'junit', version: junitVersion] + ) + testRuntime( + [group: 'org.slf4j', name: 'jcl-over-slf4j', version: slf4jVer= sion], + [group: 'org.slf4j', name: 'slf4j-log4j12', version: slf4jVers= ion], + [group: 'javassist', name:'javassist', version: javassistVersi= on], + [group: "com.h2database", name: "h2", version: h2Version] + ) +} + +targetCompatibility =3D "1.4" +sourceCompatibility =3D "1.4" Added: sandbox/trunk/new-metadata/settings.gradle =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/settings.gradle (rev= 0) +++ sandbox/trunk/new-metadata/settings.gradle 2009-11-12 20:52:13 UTC (rev= 17967) @@ -0,0 +1 @@ +rootProject.name =3D 'hibernate-new-metadata' Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java= /Nature.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Na= ture.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Na= ture.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,78 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.java; + +import java.io.Serializable; +import java.util.HashMap; + +/** + * Enumerations of the various types or natures of attributes. + * + * @author Steve Ebersole + */ +public class Nature implements Serializable { + private static final HashMap INSTANCES =3D new HashMap(); + + public static final Nature VALUE =3D new Nature( "VALUE" ); + public static final Nature COMPONENT =3D new Nature( "COMPONENT" ); + public static final Nature ANY =3D new Nature( "ANY", true ); + public static final Nature ENTITY =3D new Nature( "ENTITY", true ); + public static final Nature COLLECTION =3D new Nature( "COLLECTION", true = ); + + static { + INSTANCES.put( VALUE.name, VALUE ); + INSTANCES.put( COMPONENT.name, COMPONENT ); + INSTANCES.put( ANY.name, ANY ); + INSTANCES.put( ENTITY.name, ENTITY ); + INSTANCES.put( COLLECTION.name, COLLECTION ); + } + + private final String name; + private final boolean association; + + private Nature(String name, boolean association) { + this.name =3D name; + this.association =3D association; + } + + private Nature(String name) { + this( name, false ); + } + + public String getName() { + return name; + } + + public boolean isAssociation() { + return association; + } + + public String toString() { + return super.toString() + "[" + getName() + "]"; + } + + private Object readResolve() { + return INSTANCES.get( name ); + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java= /package.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/pa= ckage.html (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/pa= ckage.html 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,31 @@ + + + + +

+ This package defines metadata modeling of a Java domain model. +

+ + Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapp= ing/DatatypeMapping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping= /DatatypeMapping.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping= /DatatypeMapping.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,47 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.mapping; + +import org.hibernate.metadata.schema.Datatype; + +/** + * Represents the structural information pertaining to mapping between a J= ava type and an SQL datatype. + * + * @author Steve Ebersole + */ +public interface DatatypeMapping { + /** + * Retrieve the Java type described by this mapping. + * + * @return The Java class. + */ + public Class getJavaType(); + + /** + * Retrieve the metadata about the contained SQL datatypes. + * + * @return The SQL datatype metadata. + */ + public Datatype getSqlDatatypes(); +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapp= ing/package.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping= /package.html (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping= /package.html 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,34 @@ + + + + +

+ This package builds upon the {@link org.hibernate.metadata.schema} pac= kage providing + metadata modeling of Java entities to that RDBMS schema. +

+(a)see org.hibernate.metadata.schema +(a)see org.hibernate.metadata.java + + Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/AbstractColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractColumn.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractColumn.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,44 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * Basic support for {@link Column} implementations. + * + * @author Steve Ebersole + */ +public abstract class AbstractColumn implements Column { + private final Table table; + + protected AbstractColumn(Table table) { + this.table =3D table; + } + + /** + * {@inheritDoc} + */ + public Table getTable() { + return table; + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/AbstractColumnConstraint.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractColumnConstraint.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractColumnConstraint.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,59 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.List; +import java.util.ArrayList; + +/** + * Support for contraints which specifically apply to a column or series o= f columns. + * + * @author Steve Ebersole + */ +public abstract class AbstractColumnConstraint implements Constraint { + private final Table table; + private final String name; + private List/**/ columns =3D new ArrayList(); + + protected AbstractColumnConstraint(Table table, String name) { + this.table =3D table; + this.name =3D name; + } + + public Table getTable() { + return table; + } + + public String getName() { + return name; + } + + public List/**/ getColumns() { + return columns; + } + + public void addColumn(Column column) { + columns.add( column ); + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/AbstractTable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractTable.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractTable.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,49 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.Iterator; +import java.util.LinkedHashSet; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public abstract class AbstractTable implements Table { + private PrimaryKey primaryKey =3D new PrimaryKey( this ); + private final LinkedHashSet columns =3D new LinkedHashSet(); + + public void addColumn(Column column) { + columns.add( column ); + } + + public PrimaryKey getPrimaryKey() { + return primaryKey; + } + + public Iterator iterateColumns() { + return columns.iterator(); + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/Column.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Column.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Column.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,40 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * Models a column within a {@link Table}. + * + * @author Steve Ebersole + */ +public interface Column { + /** + * Retrieve the table that owns this column. + * + * @return The owning table. + */ + public Table getTable(); + + public String toDebugString(); +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/Constraint.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Constraint.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Constraint.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,42 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.List; + +/** + * Basic contract for the types of constraints we fully support as metdata= constructs:
    + *
  • primary key contraint
  • + *
  • foreign key constraint
  • + *
  • unique constraint
  • + *
+ * + * @author Steve Ebersole + */ +public interface Constraint { + public Table getTable(); + public String getName(); + + public List/**/ getColumns(); +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/Datatype.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Datatype.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Datatype.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,54 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * Models a SQL DATATYPE. + * + * @author Steve Ebersole + */ +public class Datatype { + private final int typeCode; + private final String typeName; + private final Class javaType; + + public Datatype(int typeCode, String typeName, Class javaType) { + this.typeCode =3D typeCode; + this.typeName =3D typeName; + this.javaType =3D javaType; + } + + public int getTypeCode() { + return typeCode; + } + + public String getTypeName() { + return typeName; + } + + public Class getJavaType() { + return javaType; + } + +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/DerivedColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= DerivedColumn.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= DerivedColumn.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,42 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * A derived column is the result of a formula mapping. + * + * @author Steve Ebersole + */ +public class DerivedColumn extends AbstractColumn implements Column { + public DerivedColumn(Table table) { + super( table ); + } + + /** + * {@inheritDoc} + */ + public String toDebugString() { + return getTable().toDebugString() + ".{derived-column}"; + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/Exportable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Exportable.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Exportable.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,39 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * Contract for entities (in the ERD sense) which can be exported via = CREATE, ALTER, etc + * statements. + * + * @author Steve Ebersole + */ +public interface Exportable { + /** + * Get a uniqueing identifier to make sure we are not exporting the same = database structure multiple times. + * + * @return The exporting identifier. + */ + public String getExportIdentifier(); +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/ForeignKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= ForeignKey.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= ForeignKey.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,115 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.List; +import java.util.ArrayList; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class ForeignKey implements Constraint { + private static final Logger log =3D LoggerFactory.getLogger( ForeignKey.c= lass ); + + private final Table sourceTable; + private final Table targetTable; + private final String name; + + private List/**/ sourceColumns =3D new ArrayList(); + private List/**/ targetColumns; + + public ForeignKey(Table sourceTable, Table targetTable, String name) { + this.sourceTable =3D sourceTable; + this.targetTable =3D targetTable; + this.name =3D name; + } + + public ForeignKey(Table sourceTable, Table targetTable) { + this( sourceTable, targetTable, null ); + } + + public String getName() { + return name; + } + + public Table getTable() { + return getSourceTable(); + } + + public Table getSourceTable() { + return sourceTable; + } + + public Table getTargetTable() { + return targetTable; + } + + public List/**/ getColumns() { + return getSourceColumns(); + } + + public List getSourceColumns() { + return sourceColumns; + } + + public List getTargetColumns() { + return targetColumns =3D=3D null + ? getTargetTable().getPrimaryKey().getColumns() + : targetColumns; + } + + public void addColumnMapping(Column sourceColumn, Column targetColumn) { + if ( targetColumn =3D=3D null ) { + if ( targetColumns !=3D null ) { + if ( log.isWarnEnabled() ) { + log.warn( + "Attempt to map column [" + sourceColumn.toDebugString() + + "] to no target column after explicit target column(s) named fo= r FK [name=3D" + + getName() + "]" + ); + } + } + } + else { + if ( targetColumns =3D=3D null ) { + if ( !sourceColumns.isEmpty() ) { + log.warn( + "Column mapping mismatch as part of FK [table=3D" + getTable().toDe= bugString() + + ", name=3D" + getName() + "] while adding source column [" + + sourceColumn.toDebugString() + "]" + ); + } + targetColumns =3D new ArrayList(); + } + targetColumns.add( targetColumn ); + } + sourceColumns.add( sourceColumn ); + } + +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/Index.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Index.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Index.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,35 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class Index extends AbstractColumnConstraint implements Constraint { + protected Index(Table table, String name) { + super( table, name ); + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/LogicalTable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= LogicalTable.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= LogicalTable.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,57 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.Set; +import java.util.HashSet; + +/** + * A data container defined by a SELECT statement. This= translates into an inline view in the + * SQL statements: select ... from (select ... from logical_table_ta= ble ...) ... + * + * @author Steve Ebersole + */ +public class LogicalTable extends AbstractTable implements Table { + private final String select; + private Set synchronizedTableSpaces =3D java.util.Collections.EMPTY_SET; + + public LogicalTable(String select) { + this.select =3D select; + } + + public void addSynchronizedTableSpace(String space) { + if ( synchronizedTableSpaces =3D=3D java.util.Collections.EMPTY_SET ) { + synchronizedTableSpaces =3D new HashSet(); + } + synchronizedTableSpaces.add( space ); + } + + public Set getSpaces() { + return synchronizedTableSpaces; + } + + public String toDebugString() { + return "{inline-view}"; + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/PhysicalColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PhysicalColumn.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PhysicalColumn.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,46 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class PhysicalColumn extends AbstractColumn implements Column { + private final String name; + + protected PhysicalColumn(Table table, String name) { + super( table ); + this.name =3D name; + } + + public String getName() { + return name; + } + + public String toDebugString() { + return getTable().toDebugString() + '.' + getName(); + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/PhysicalTable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PhysicalTable.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PhysicalTable.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,58 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.Set; + +/** + * Models the concept of a relational TABLE (or VIEW) da= tabase to which we map information. + * + * @author Gavin King + * @author Steve Ebersole + */ +public class PhysicalTable extends AbstractTable implements Table, Exporta= ble { + private final String explicitSchema; + private final String explicitCatalog; + private final String name; + private final Set spaces; + + public PhysicalTable(String explicitSchema, String explicitCatalog, Strin= g name) { + this.explicitSchema =3D explicitSchema; + this.explicitCatalog =3D explicitCatalog; + this.name =3D name; + this.spaces =3D java.util.Collections.singleton( name ); + } + + public String getExportIdentifier() { + return name; + } + + public Set getSpaces() { + return spaces; + } + + public String toDebugString() { + return name; + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/PrimaryKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PrimaryKey.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PrimaryKey.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,53 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + + +/** + * Models a table's primary key. + *

+ * NOTE : This need not be a physical primary key; we just mean a column o= r columns which uniquely identify rows in + * the table. Of course it is recommended to define proper integrity cons= traints, including primary keys. + * + * @author Steve Ebersole + */ +public class PrimaryKey extends AbstractColumnConstraint implements Constr= aint { + // IMPL NOTE : I override the name behavior here because: + // (1) primary keys are not required to be named. + // (2) because a primary key is required for each table, it is easier to= allow setting the constraint name + // later in terms of building the metamodel + private String name; + + public PrimaryKey(Table table) { + super( table, null ); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/Table.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Table.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Table.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,44 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.Iterator; +import java.util.Set; + +/** + * Contract for data containers (what the ANSI SQL spec calls "table speci= fications") to which we can map + * entity state. + * + * @author Steve Ebersole + */ +public interface Table { + public PrimaryKey getPrimaryKey(); + + public void addColumn(Column column); + + public Iterator iterateColumns(); + public Set getSpaces(); + + public String toDebugString(); +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/UniqueKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= UniqueKey.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= UniqueKey.java 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,35 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class UniqueKey extends AbstractColumnConstraint implements Constra= int { + protected UniqueKey(Table table, String name) { + super( table, name ); + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/package.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= package.html (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= package.html 2009-11-12 20:52:13 UTC (rev 17967) @@ -0,0 +1,31 @@ + + + + +

+ This package defines metadata modeling of a RDBMS schema. +

+ + --===============4601152390237621229==-- From hibernate-commits at lists.jboss.org Thu Nov 12 17:27:26 2009 Content-Type: multipart/mixed; boundary="===============5757828664934975926==" MIME-Version: 1.0 From: Joanie To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hey hibernate-commits Date: Thu, 12 Nov 2009 17:27:25 -0500 Message-ID: <200911122227.nACMRPfE028111@lists01.dmz-a.mwc.hst.phx2.redhat.com> --===============5757828664934975926== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Ready for upcoming Friday? http://lapka.by.ru/hot.html --===============5757828664934975926==-- From hibernate-commits at lists.jboss.org Thu Nov 12 23:26:58 2009 Content-Type: multipart/mixed; boundary="===============3165339177886988956==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17968 - core/trunk/core/src/main/java/org/hibernate/cfg. Date: Thu, 12 Nov 2009 23:26:57 -0500 Message-ID: <200911130426.nAD4QvW3010171@svn01.web.mwc.hst.phx2.redhat.com> --===============3165339177886988956== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-12 23:26:57 -0500 (Thu, 12 Nov 2009) New Revision: 17968 Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java Log: HHH-4569 - Split focus of ConfigurationPerformanceTest Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java 2009= -11-12 20:52:13 UTC (rev 17967) +++ core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java 2009= -11-13 04:26:57 UTC (rev 17968) @@ -445,7 +445,7 @@ try { org.dom4j.Document doc =3D xmlHelper.createSAXReader( xmlFile.getAbsolu= tePath(), errors, entityResolver ).read( xmlFile ); if ( errors.size() !=3D 0 ) { - throw new MappingException( "invalid mapping", ( Throwable ) errors.ge= t( 0 ) ); + throw new InvalidMappingException( "file", xmlFile.toString(), (Throwa= ble) errors.get(0) ); } = try { @@ -461,8 +461,8 @@ = add( doc ); } - catch( DocumentException e){ - throw new MappingException( "invalid mapping", e ); + catch (DocumentException e) { + throw new InvalidMappingException( "file", xmlFile.toString(), e ); } = return this; --===============3165339177886988956==-- From hibernate-commits at lists.jboss.org Thu Nov 12 23:27:35 2009 Content-Type: multipart/mixed; boundary="===============4753197696424073598==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17969 - core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg. Date: Thu, 12 Nov 2009 23:27:35 -0500 Message-ID: <200911130427.nAD4RZUN010310@svn01.web.mwc.hst.phx2.redhat.com> --===============4753197696424073598== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-12 23:27:35 -0500 (Thu, 12 Nov 2009) New Revision: 17969 Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Configurat= ion.java Log: HHH-4569 - Split focus of ConfigurationPerformanceTest Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Con= figuration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Configura= tion.java 2009-11-13 04:26:57 UTC (rev 17968) +++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Configura= tion.java 2009-11-13 04:27:35 UTC (rev 17969) @@ -405,7 +405,7 @@ try { org.dom4j.Document doc =3D xmlHelper.createSAXReader( xmlFile.getAbsolu= tePath(), errors, entityResolver ).read( xmlFile ); if ( errors.size() !=3D 0 ) { - throw new MappingException( "invalid mapping", ( Throwable ) errors.ge= t( 0 ) ); + throw new InvalidMappingException( "file", xmlFile.toString(), (Throwa= ble) errors.get(0) ); } = try { @@ -422,7 +422,7 @@ add( doc ); } catch( DocumentException e){ - throw new MappingException( "invalid mapping", e ); + throw new InvalidMappingException( "file", xmlFile.toString(), e ); } = return this; --===============4753197696424073598==-- From hibernate-commits at lists.jboss.org Fri Nov 13 02:24:39 2009 Content-Type: multipart/mixed; boundary="===============5949752937643503497==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17970 - in sandbox/trunk/new-metadata: src and 9 other directories. Date: Fri, 13 Nov 2009 02:24:39 -0500 Message-ID: <200911130724.nAD7Od1S007393@svn01.web.mwc.hst.phx2.redhat.com> --===============5949752937643503497== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-13 02:24:38 -0500 (Fri, 13 Nov 2009) New Revision: 17970 Added: sandbox/trunk/new-metadata/DESIGN.txt sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Att= ribute.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Att= ributeContainer.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Bas= icType.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Ent= ity.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Typ= e.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Typ= eNature.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/= AttributeMapping.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/A= bstractValueContainer.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/C= olumn.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/D= erivedValue.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/I= nLineView.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/O= bjectName.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/T= able.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/V= alue.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/V= alueContainer.java sandbox/trunk/new-metadata/src/test/ sandbox/trunk/new-metadata/src/test/java/ sandbox/trunk/new-metadata/src/test/java/org/ sandbox/trunk/new-metadata/src/test/java/org/hibernate/ sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/ sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/ sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/O= bjectNameTests.java Removed: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Nat= ure.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/= DatatypeMapping.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/A= bstractTable.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/C= olumn.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/D= erivedColumn.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/L= ogicalTable.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/P= hysicalColumn.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/P= hysicalTable.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/T= able.java Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/A= bstractColumn.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/A= bstractColumnConstraint.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/C= onstraint.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/D= atatype.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/F= oreignKey.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/I= ndex.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/P= rimaryKey.java sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/U= niqueKey.java Log: tad more work on this Added: sandbox/trunk/new-metadata/DESIGN.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/DESIGN.txt (rev 0) +++ sandbox/trunk/new-metadata/DESIGN.txt 2009-11-13 07:24:38 UTC (rev 1797= 0) @@ -0,0 +1,19 @@ +This file is intended as a list of the design goals for this work. What a= re we trying to achieve? why? And +how are we planning on going about it. + +Mainly this is to be a refactoring of the existing org.hibernate.mapping p= ackage. There are two main problems with +the current code: +1) It represents a single unified view of the logical model which is neith= er the java mode nor the +database model; it is somewhere in between. Yet it does this in a singula= r manner. +2) Lack of encapsulation + +To attempt to alleviate these problems, the proposal is a separation such = that we have: +1) Metadata about the database schema, in org.hibernate.metadata.schema pa= ckage +2) Metadata about the Java model, in the org.hibernate.metadata.java pack= age. todo : what about other entitymodes? +3) Metadata about the mapping between the two above, in the org.hibernate.= metadata.mapping package + +Especially trying to keep them as independent as possible. Especially, the +org.hibernate.metadata.schema and org.hibernate.metadata.java package shou= ld +be independent onto themselves, with the org.hibernate.metadata.mapping pa= ckage +providing the linkage/binding + Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java= /Attribute.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/At= tribute.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/At= tribute.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,34 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.java; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public interface Attribute { + public String getName(); + public AttributeContainer getAttributeContainer(); +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java= /AttributeContainer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/At= tributeContainer.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/At= tributeContainer.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,37 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.java; + +import java.util.Set; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public interface AttributeContainer extends Type { + public Set getAttributes(); + + public Attribute getAttribute(String name); +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java= /BasicType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Ba= sicType.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Ba= sicType.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,45 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.java; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class BasicType implements Type { + private final Class javaType; + + public BasicType(Class javaType) { + this.javaType =3D javaType; + } + + public TypeNature getNature() { + return TypeNature.BASIC; + } + + public Class getJavaType() { + return javaType; + } +} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java= /Entity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/En= tity.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/En= tity.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,32 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.java; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class Entity { +} Deleted: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/ja= va/Nature.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Na= ture.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Na= ture.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -1,78 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by - * third-party contributors as indicated by either @author tags or express - * copyright attribution statements applied by the authors. All - * third-party contributions are distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * 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.metadata.java; - -import java.io.Serializable; -import java.util.HashMap; - -/** - * Enumerations of the various types or natures of attributes. - * - * @author Steve Ebersole - */ -public class Nature implements Serializable { - private static final HashMap INSTANCES =3D new HashMap(); - - public static final Nature VALUE =3D new Nature( "VALUE" ); - public static final Nature COMPONENT =3D new Nature( "COMPONENT" ); - public static final Nature ANY =3D new Nature( "ANY", true ); - public static final Nature ENTITY =3D new Nature( "ENTITY", true ); - public static final Nature COLLECTION =3D new Nature( "COLLECTION", true = ); - - static { - INSTANCES.put( VALUE.name, VALUE ); - INSTANCES.put( COMPONENT.name, COMPONENT ); - INSTANCES.put( ANY.name, ANY ); - INSTANCES.put( ENTITY.name, ENTITY ); - INSTANCES.put( COLLECTION.name, COLLECTION ); - } - - private final String name; - private final boolean association; - - private Nature(String name, boolean association) { - this.name =3D name; - this.association =3D association; - } - - private Nature(String name) { - this( name, false ); - } - - public String getName() { - return name; - } - - public boolean isAssociation() { - return association; - } - - public String toString() { - return super.toString() + "[" + getName() + "]"; - } - - private Object readResolve() { - return INSTANCES.get( name ); - } -} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java= /Type.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Ty= pe.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Ty= pe.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,45 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.java; + +/** + * Basic information about a Java type, in regards to its role in particul= ar set of mappings. + * + * @author Steve Ebersole + */ +public interface Type { + /** + * Return the persistence type. + * + * @return persistence type + */ + public TypeNature getNature(); + + /** + * Return the represented Java type. + * + * @return Java type + */ + public Class getJavaType(); +} Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/jav= a/TypeNature.java (from rev 17967, sandbox/trunk/new-metadata/src/main/java= /org/hibernate/metadata/java/Nature.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Ty= peNature.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Ty= peNature.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,65 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.java; + +import java.io.Serializable; +import java.util.HashMap; + +/** + * Describes the nature of a type. + * + * @author Steve Ebersole + */ +public class TypeNature implements Serializable { + public static final TypeNature BASIC =3D new TypeNature( "BASIC" ); + public static final TypeNature COMPONENT =3D new TypeNature( "COMPONENT" = ); + public static final TypeNature ENTITY =3D new TypeNature( "ENTITY" ); + public static final TypeNature SUPERCLASS =3D new TypeNature( "SUPERCLASS= " ); + + private static final HashMap INSTANCES =3D new HashMap(); + static { + INSTANCES.put( BASIC.name, BASIC ); + INSTANCES.put( COMPONENT.name, COMPONENT ); + INSTANCES.put( ENTITY.name, ENTITY ); + INSTANCES.put( SUPERCLASS.name, SUPERCLASS ); + } + + private final String name; + + private TypeNature(String name) { + this.name =3D name; + } + + public String getName() { + return name; + } + + public String toString() { + return super.toString() + "[" + getName() + "]"; + } + + private Object readResolve() { + return INSTANCES.get( name ); + } +} Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/map= ping/AttributeMapping.java (from rev 17967, sandbox/trunk/new-metadata/src/= main/java/org/hibernate/metadata/mapping/DatatypeMapping.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping= /AttributeMapping.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping= /AttributeMapping.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,41 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.mapping; + +import org.hibernate.metadata.java.Attribute; +import org.hibernate.metadata.schema.Value; + +/** + * Defines information about mapping an {@link Attribute attribute} to a s= et of one or more database + * Represents the structural information pertaining to mapping between a J= ava type and an SQL datatype. + * + * @author Steve Ebersole + */ +public interface AttributeMapping { + public Attribute getAttribute(); + + public Value[] getColumns(); + + // todo : type/transformation information... +} Deleted: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/ma= pping/DatatypeMapping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping= /DatatypeMapping.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping= /DatatypeMapping.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -1,47 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by - * third-party contributors as indicated by either @author tags or express - * copyright attribution statements applied by the authors. All - * third-party contributions are distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * 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.metadata.mapping; - -import org.hibernate.metadata.schema.Datatype; - -/** - * Represents the structural information pertaining to mapping between a J= ava type and an SQL datatype. - * - * @author Steve Ebersole - */ -public interface DatatypeMapping { - /** - * Retrieve the Java type described by this mapping. - * - * @return The Java class. - */ - public Class getJavaType(); - - /** - * Retrieve the metadata about the contained SQL datatypes. - * - * @return The SQL datatype metadata. - */ - public Datatype getSqlDatatypes(); -} Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/s= chema/AbstractColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractColumn.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractColumn.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -23,22 +23,43 @@ */ package org.hibernate.metadata.schema; = +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** - * Basic support for {@link Column} implementations. + * Basic support for {@link Value} implementations. * * @author Steve Ebersole */ -public abstract class AbstractColumn implements Column { - private final Table table; +public abstract class AbstractColumn implements Value { + private static final Logger log =3D LoggerFactory.getLogger( AbstractColu= mn.class ); = - protected AbstractColumn(Table table) { + private final ValueContainer table; + private Datatype datatype; + + protected AbstractColumn(ValueContainer table) { this.table =3D table; } = /** * {@inheritDoc} */ - public Table getTable() { + public ValueContainer getTable() { return table; } + + /** + * {@inheritDoc} + */ + public Datatype getDatatype() { + return datatype; + } + + /** + * {@inheritDoc} + */ + public void setDatatype(Datatype datatype) { + log.debug( "setting datatype for column " + toDebugString() + " : " + da= tatype.getTypeCode() ); + this.datatype =3D datatype; + } } Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/s= chema/AbstractColumnConstraint.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractColumnConstraint.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractColumnConstraint.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -28,20 +28,22 @@ = /** * Support for contraints which specifically apply to a column or series o= f columns. + *

+ * todo : do we need to support defining these on particular schemas/catal= ogs? * * @author Steve Ebersole */ public abstract class AbstractColumnConstraint implements Constraint { - private final Table table; + private final ValueContainer table; private final String name; - private List/**/ columns =3D new ArrayList(); + private List/**/ columns =3D new ArrayList(); = - protected AbstractColumnConstraint(Table table, String name) { + protected AbstractColumnConstraint(ValueContainer table, String name) { this.table =3D table; this.name =3D name; } = - public Table getTable() { + public ValueContainer getTable() { return table; } = @@ -49,11 +51,14 @@ return name; } = - public List/**/ getColumns() { + public List/**/ getColumns() { return columns; } = - public void addColumn(Column column) { + public void addColumn(Value column) { + if ( column.getTable() !=3D getTable() ) { + throw new IllegalArgumentException( "Unable to add column to constraint= ; tables did not match" ); + } columns.add( column ); } } Deleted: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sc= hema/AbstractTable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractTable.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractTable.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -1,49 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by - * third-party contributors as indicated by either @author tags or express - * copyright attribution statements applied by the authors. All - * third-party contributions are distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * 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.metadata.schema; - -import java.util.Iterator; -import java.util.LinkedHashSet; - -/** - * TODO : javadoc - * - * @author Steve Ebersole - */ -public abstract class AbstractTable implements Table { - private PrimaryKey primaryKey =3D new PrimaryKey( this ); - private final LinkedHashSet columns =3D new LinkedHashSet(); - - public void addColumn(Column column) { - columns.add( column ); - } - - public PrimaryKey getPrimaryKey() { - return primaryKey; - } - - public Iterator iterateColumns() { - return columns.iterator(); - } -} Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sch= ema/AbstractValueContainer.java (from rev 17967, sandbox/trunk/new-metadata= /src/main/java/org/hibernate/metadata/schema/AbstractTable.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractValueContainer.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= AbstractValueContainer.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,58 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.Iterator; +import java.util.LinkedHashSet; + +/** + * Convenience base class for implementing the {@link ValueContainer} cont= ract + * + * @author Steve Ebersole + */ +public abstract class AbstractValueContainer implements ValueContainer { + private PrimaryKey primaryKey =3D new PrimaryKey( this ); + private final LinkedHashSet values =3D new LinkedHashSet(); + + /** + * {@inheritDoc} + */ + public void addValue(Value value) { + values.add( value ); + } + + /** + * {@inheritDoc} + */ + public Iterator iterateValues() { + return values.iterator(); + } + + /** + * {@inheritDoc} + */ + public PrimaryKey getPrimaryKey() { + return primaryKey; + } +} Deleted: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sc= hema/Column.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Column.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Column.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -1,40 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by - * third-party contributors as indicated by either @author tags or express - * copyright attribution statements applied by the authors. All - * third-party contributions are distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * 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.metadata.schema; - -/** - * Models a column within a {@link Table}. - * - * @author Steve Ebersole - */ -public interface Column { - /** - * Retrieve the table that owns this column. - * - * @return The owning table. - */ - public Table getTable(); - - public String toDebugString(); -} Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sch= ema/Column.java (from rev 17967, sandbox/trunk/new-metadata/src/main/java/o= rg/hibernate/metadata/schema/PhysicalColumn.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Column.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Column.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,49 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class Column extends AbstractColumn implements Value { + private final String name; + + protected Column(ValueContainer table, String name) { + super( table ); + this.name =3D name; + } + + public String getName() { + return name; + } + + /** + * {@inheritDoc} + */ + public String toDebugString() { + return getTable().toDebugString() + '.' + getName(); + } +} Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/s= chema/Constraint.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Constraint.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Constraint.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -35,8 +35,8 @@ * @author Steve Ebersole */ public interface Constraint { - public Table getTable(); + public ValueContainer getTable(); public String getName(); = - public List/**/ getColumns(); + public List/**/ getColumns(); } Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/s= chema/Datatype.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Datatype.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Datatype.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -24,7 +24,9 @@ package org.hibernate.metadata.schema; = /** - * Models a SQL DATATYPE. + * Models a JDBC {@link java.sql.Types DATATYPE} + *

+ * todo : should we model scale and precision here or on Value? * * @author Steve Ebersole */ Deleted: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sc= hema/DerivedColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= DerivedColumn.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= DerivedColumn.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -1,42 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by - * third-party contributors as indicated by either @author tags or express - * copyright attribution statements applied by the authors. All - * third-party contributions are distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * 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.metadata.schema; - -/** - * A derived column is the result of a formula mapping. - * - * @author Steve Ebersole - */ -public class DerivedColumn extends AbstractColumn implements Column { - public DerivedColumn(Table table) { - super( table ); - } - - /** - * {@inheritDoc} - */ - public String toDebugString() { - return getTable().toDebugString() + ".{derived-column}"; - } -} Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sch= ema/DerivedValue.java (from rev 17967, sandbox/trunk/new-metadata/src/main/= java/org/hibernate/metadata/schema/DerivedColumn.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= DerivedValue.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= DerivedValue.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,42 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * A derived column is the result of a formula mapping. + * + * @author Steve Ebersole + */ +public class DerivedValue extends AbstractColumn implements Value { + public DerivedValue(ValueContainer table) { + super( table ); + } + + /** + * {@inheritDoc} + */ + public String toDebugString() { + return getTable().toDebugString() + ".{derived-column}"; + } +} Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/s= chema/ForeignKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= ForeignKey.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= ForeignKey.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -37,20 +37,20 @@ public class ForeignKey implements Constraint { private static final Logger log =3D LoggerFactory.getLogger( ForeignKey.c= lass ); = - private final Table sourceTable; - private final Table targetTable; + private final ValueContainer sourceTable; + private final ValueContainer targetTable; private final String name; = - private List/**/ sourceColumns =3D new ArrayList(); - private List/**/ targetColumns; + private List/**/ sourceColumns =3D new ArrayList(); + private List/**/ targetColumns; = - public ForeignKey(Table sourceTable, Table targetTable, String name) { + public ForeignKey(ValueContainer sourceTable, ValueContainer targetTable,= String name) { this.sourceTable =3D sourceTable; this.targetTable =3D targetTable; this.name =3D name; } = - public ForeignKey(Table sourceTable, Table targetTable) { + public ForeignKey(ValueContainer sourceTable, ValueContainer targetTable)= { this( sourceTable, targetTable, null ); } = @@ -58,19 +58,19 @@ return name; } = - public Table getTable() { + public ValueContainer getTable() { return getSourceTable(); } = - public Table getSourceTable() { + public ValueContainer getSourceTable() { return sourceTable; } = - public Table getTargetTable() { + public ValueContainer getTargetTable() { return targetTable; } = - public List/**/ getColumns() { + public List/**/ getColumns() { return getSourceColumns(); } = @@ -84,7 +84,7 @@ : targetColumns; } = - public void addColumnMapping(Column sourceColumn, Column targetColumn) { + public void addColumnMapping(Value sourceColumn, Value targetColumn) { if ( targetColumn =3D=3D null ) { if ( targetColumns !=3D null ) { if ( log.isWarnEnabled() ) { @@ -100,7 +100,7 @@ if ( targetColumns =3D=3D null ) { if ( !sourceColumns.isEmpty() ) { log.warn( - "Column mapping mismatch as part of FK [table=3D" + getTable().toDe= bugString() + "Value mapping mismatch as part of FK [table=3D" + getTable().toDeb= ugString() + ", name=3D" + getName() + "] while adding source column [" + sourceColumn.toDebugString() + "]" ); Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sch= ema/InLineView.java (from rev 17967, sandbox/trunk/new-metadata/src/main/ja= va/org/hibernate/metadata/schema/LogicalTable.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= InLineView.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= InLineView.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,67 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.Set; +import java.util.HashSet; + +/** + * A data container defined by a SELECT statement. This= translates into an inline view in the + * SQL statements: select ... from (select ... from logical_table_ta= ble ...) ... + * + * @author Steve Ebersole + */ +public class InLineView extends AbstractValueContainer implements ValueCon= tainer { + private final String select; + private final String uniqueValueQualifier; + private Set synchronizedTableSpaces =3D java.util.Collections.EMPTY_SET; + + public InLineView(String select, String uniqueValueQualifier) { + this.select =3D select; + this.uniqueValueQualifier =3D uniqueValueQualifier; + } + + public String getSelect() { + return select; + } + + public String getUniqueValueQualifier() { + return uniqueValueQualifier; + } + + public void addSynchronizedTableSpace(String space) { + if ( synchronizedTableSpaces =3D=3D java.util.Collections.EMPTY_SET ) { + synchronizedTableSpaces =3D new HashSet(); + } + synchronizedTableSpaces.add( space ); + } + + public Set getSpaces() { + return synchronizedTableSpaces; + } + + public String toDebugString() { + return "{inline-view}"; + } +} Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/s= chema/Index.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Index.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Index.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -29,7 +29,7 @@ * @author Steve Ebersole */ public class Index extends AbstractColumnConstraint implements Constraint { - protected Index(Table table, String name) { + protected Index(ValueContainer table, String name) { super( table, name ); } } Deleted: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sc= hema/LogicalTable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= LogicalTable.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= LogicalTable.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -1,57 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by - * third-party contributors as indicated by either @author tags or express - * copyright attribution statements applied by the authors. All - * third-party contributions are distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * 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.metadata.schema; - -import java.util.Set; -import java.util.HashSet; - -/** - * A data container defined by a SELECT statement. This= translates into an inline view in the - * SQL statements: select ... from (select ... from logical_table_ta= ble ...) ... - * - * @author Steve Ebersole - */ -public class LogicalTable extends AbstractTable implements Table { - private final String select; - private Set synchronizedTableSpaces =3D java.util.Collections.EMPTY_SET; - - public LogicalTable(String select) { - this.select =3D select; - } - - public void addSynchronizedTableSpace(String space) { - if ( synchronizedTableSpaces =3D=3D java.util.Collections.EMPTY_SET ) { - synchronizedTableSpaces =3D new HashSet(); - } - synchronizedTableSpaces.add( space ); - } - - public Set getSpaces() { - return synchronizedTableSpaces; - } - - public String toDebugString() { - return "{inline-view}"; - } -} Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sche= ma/ObjectName.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= ObjectName.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= ObjectName.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,125 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * Models the qualified name of a database object. + * + * @author Steve Ebersole + */ +public class ObjectName { + private final String name; + private final String schema; + private final String catalog; + private final String identifier; + private final int hashCode; + + /** + * Creates a qualified name reference. + * + * @param schema The in which the object is defined (optional) + * @param catalog The catalog in which the object is defined (optional) + * @param name The name (required) + */ + public ObjectName(String schema, String catalog, String name) { + if ( name =3D=3D null || name.trim().length() =3D=3D 0 ) { + throw new IllegalArgumentException( "Object name must be specified" ); + } + this.name =3D name; + this.schema =3D schema; + this.catalog =3D catalog; + + StringBuffer buff =3D new StringBuffer( name ); + if ( catalog !=3D null ) { + buff.insert( 0, catalog + '.' ); + } + if ( schema !=3D null ) { + buff.insert( 0, schema + '.' ); + } + this.identifier =3D buff.toString(); + + int tmpHashCode =3D schema !=3D null ? schema.hashCode() : 0; + tmpHashCode =3D 31 * tmpHashCode + (catalog !=3D null ? catalog.hashCode= () : 0); + tmpHashCode =3D 31 * tmpHashCode + name.hashCode(); + this.hashCode =3D tmpHashCode; + } + + public String getSchema() { + return schema; + } + + public String getCatalog() { + return catalog; + } + + public String getName() { + return name; + } + + public String getIdentifier() { + return identifier; + } + + /** + * {@inheritDoc} + */ + public boolean equals(Object o) { + if (this =3D=3D o) { + return true; + } + if (o =3D=3D null || getClass() !=3D o.getClass()) { + return false; + } + + ObjectName that =3D (ObjectName) o; + + return name.equals( that.name ) + && areEqual( catalog, that.catalog ) + && areEqual( schema, that.schema ); + } + + private boolean areEqual(String one, String other) { + return one =3D=3D null + ? other =3D=3D null + : one.equals( other ); + } + + /** + * {@inheritDoc} + */ + public int hashCode() { + return hashCode; + } + + /** + * {@inheritDoc} + */ + public String toString() { + return "ObjectName{" + + "name=3D'" + name + '\'' + + ", schema=3D'" + schema + '\'' + + ", catalog=3D'" + catalog + '\'' + + '}'; + } +} Deleted: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sc= hema/PhysicalColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PhysicalColumn.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PhysicalColumn.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -1,46 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by - * third-party contributors as indicated by either @author tags or express - * copyright attribution statements applied by the authors. All - * third-party contributions are distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * 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.metadata.schema; - -/** - * TODO : javadoc - * - * @author Steve Ebersole - */ -public class PhysicalColumn extends AbstractColumn implements Column { - private final String name; - - protected PhysicalColumn(Table table, String name) { - super( table ); - this.name =3D name; - } - - public String getName() { - return name; - } - - public String toDebugString() { - return getTable().toDebugString() + '.' + getName(); - } -} Deleted: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sc= hema/PhysicalTable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PhysicalTable.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PhysicalTable.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -1,58 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by - * third-party contributors as indicated by either @author tags or express - * copyright attribution statements applied by the authors. All - * third-party contributions are distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * 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.metadata.schema; - -import java.util.Set; - -/** - * Models the concept of a relational TABLE (or VIEW) da= tabase to which we map information. - * - * @author Gavin King - * @author Steve Ebersole - */ -public class PhysicalTable extends AbstractTable implements Table, Exporta= ble { - private final String explicitSchema; - private final String explicitCatalog; - private final String name; - private final Set spaces; - - public PhysicalTable(String explicitSchema, String explicitCatalog, Strin= g name) { - this.explicitSchema =3D explicitSchema; - this.explicitCatalog =3D explicitCatalog; - this.name =3D name; - this.spaces =3D java.util.Collections.singleton( name ); - } - - public String getExportIdentifier() { - return name; - } - - public Set getSpaces() { - return spaces; - } - - public String toDebugString() { - return name; - } -} Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/s= chema/PrimaryKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PrimaryKey.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= PrimaryKey.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -39,7 +39,7 @@ // later in terms of building the metamodel private String name; = - public PrimaryKey(Table table) { + public PrimaryKey(ValueContainer table) { super( table, null ); } = Deleted: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sc= hema/Table.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Table.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Table.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -1,44 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by - * third-party contributors as indicated by either @author tags or express - * copyright attribution statements applied by the authors. All - * third-party contributions are distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * 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.metadata.schema; - -import java.util.Iterator; -import java.util.Set; - -/** - * Contract for data containers (what the ANSI SQL spec calls "table speci= fications") to which we can map - * entity state. - * - * @author Steve Ebersole - */ -public interface Table { - public PrimaryKey getPrimaryKey(); - - public void addColumn(Column column); - - public Iterator iterateColumns(); - public Set getSpaces(); - - public String toDebugString(); -} Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sch= ema/Table.java (from rev 17967, sandbox/trunk/new-metadata/src/main/java/or= g/hibernate/metadata/schema/PhysicalTable.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Table.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Table.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,83 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.Set; + +/** + * Models the concept of a relational TABLE (or VIEW). + * + * @author Gavin King + * @author Steve Ebersole + */ +public class Table extends AbstractValueContainer implements ValueContaine= r, Exportable { + private final ObjectName name; + private final Set spaces; + + public Table(ObjectName name) { + this.name =3D name; + this.spaces =3D java.util.Collections.singleton( name ); + } + + public ObjectName getObjectName() { + return name; + } + + /** + * {@inheritDoc} + */ + public String getUniqueValueQualifier() { + return getObjectName().getIdentifier(); + } + + /** + * {@inheritDoc} + */ + public String getExportIdentifier() { + return getObjectName().getIdentifier(); + } + + /** + * {@inheritDoc} + */ + public Set getSpaces() { + return spaces; + } + + /** + * {@inheritDoc} + */ + public String toDebugString() { + return getObjectName().getIdentifier(); + } + + /** + * {@inheritDoc} + */ + public String toString() { + return "Table{" + + "name=3D" + getObjectName().getIdentifier() + + '}'; + } +} Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/s= chema/UniqueKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= UniqueKey.java 2009-11-13 04:27:35 UTC (rev 17969) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= UniqueKey.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -29,7 +29,7 @@ * @author Steve Ebersole */ public class UniqueKey extends AbstractColumnConstraint implements Constra= int { - protected UniqueKey(Table table, String name) { + protected UniqueKey(ValueContainer table, String name) { super( table, name ); } } Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sch= ema/Value.java (from rev 17967, sandbox/trunk/new-metadata/src/main/java/or= g/hibernate/metadata/schema/Column.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Value.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= Value.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,55 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +/** + * Models a value within a {@link ValueContainer}. This will generally be= either a + * {@link Column column} or a {@link DerivedValue derived value}. + * + * @author Steve Ebersole + */ +public interface Value { + /** + * Retrieve the table that owns this value. + * + * @return The owning table. + */ + public ValueContainer getTable(); + + /** + * Retrieve the datatype of this value. + * = + * @return The value's datatype + */ + public Datatype getDatatype(); + + /** + * Set the datatype of this value. + * + * @param datatype + */ + public void setDatatype(Datatype datatype); + + public String toDebugString(); +} Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/sch= ema/ValueContainer.java (from rev 17967, sandbox/trunk/new-metadata/src/mai= n/java/org/hibernate/metadata/schema/Table.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= ValueContainer.java (rev 0) +++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/= ValueContainer.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,68 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import java.util.Iterator; +import java.util.Set; + +/** + * Contract for data containers (what the ANSI SQL spec calls "table speci= fications") to which we can map + * entity state. The two flavors here are {@link Table physical table} an= d {@link InLineView inline view}. + * + * @author Steve Ebersole + */ +public interface ValueContainer { + /** + * Get the primary key definition for this container. + * + * @return The PK definition. + */ + public PrimaryKey getPrimaryKey(); + + /** + * Adds a value definition to the container. + * + * @param value The value definition + */ + public void addValue(Value value); + + /** + * Obtain an iterator over this containers current set of value definitio= ns. + * + * @return Iterator over value definitions. + */ + public Iterator iterateValues(); + + public Set getSpaces(); + + /** + * Get a unique identifier which can be used to qualify {@link Value valu= es} belonging to + * this container. Intended for use in logging. + * + * @return The qualifier + */ + public String getUniqueValueQualifier(); + + public String toDebugString(); +} Added: sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/sche= ma/ObjectNameTests.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/= ObjectNameTests.java (rev 0) +++ sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/= ObjectNameTests.java 2009-11-13 07:24:38 UTC (rev 17970) @@ -0,0 +1,54 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.metadata.schema; + +import junit.framework.TestCase; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class ObjectNameTests extends TestCase { + public void testMissingName() { + try { + new ObjectName( null, null, null ); + fail(); + } + catch ( IllegalArgumentException ignore ) { + } + + try { + new ObjectName( "schema", "catalog", null ); + fail(); + } + catch ( IllegalArgumentException ignore ) { + } + } + + public void testIdentifierBuilding() { + ObjectName on =3D new ObjectName( "schema", "catalog", "name" ); + assertEquals( "schema.catalog.name", on.getIdentifier() ); + } +} --===============5949752937643503497==-- From hibernate-commits at lists.jboss.org Fri Nov 13 09:40:44 2009 Content-Type: multipart/mixed; boundary="===============3192141452054001899==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17971 - in core/branches/Branch_3_2_4_SP1_CP: src/org/hibernate/util and 1 other directories. Date: Fri, 13 Nov 2009 09:40:44 -0500 Message-ID: <200911131440.nADEeiQo032558@svn01.web.mwc.hst.phx2.redhat.com> --===============3192141452054001899== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-13 09:40:44 -0500 (Fri, 13 Nov 2009) New Revision: 17971 Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/query/QueryPl= anCache.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/util/CollectionHelpe= r.java core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/Dynamic= FilterTest.java Log: JBPAPP-3098 HHH-4065 - Incorrect SQL is used for HQL if the number of value= s for a filter collection parameter is changed Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/query/= QueryPlanCache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/query/QueryP= lanCache.java 2009-11-13 07:24:38 UTC (rev 17970) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/query/QueryP= lanCache.java 2009-11-13 14:40:44 UTC (rev 17971) @@ -1,16 +1,19 @@ package org.hibernate.engine.query; = import org.hibernate.util.ArrayHelper; +import org.hibernate.util.CollectionHelper; import org.hibernate.util.SimpleMRUCache; import org.hibernate.util.SoftLimitMRUCache; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.query.sql.NativeSQLQuerySpecification; +import org.hibernate.impl.FilterImpl; import org.hibernate.QueryException; import org.hibernate.MappingException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; = import java.io.Serializable; +import java.util.Collection; import java.util.Map; import java.util.HashMap; import java.util.List; @@ -152,7 +155,7 @@ private static class HQLQueryPlanKey implements Serializable { private final String query; private final boolean shallow; - private final Set filterNames; + private final Set filterKeys; private final int hashCode; = public HQLQueryPlanKey(String query, boolean shallow, Map enabledFilters= ) { @@ -160,17 +163,23 @@ this.shallow =3D shallow; = if ( enabledFilters =3D=3D null || enabledFilters.isEmpty() ) { - filterNames =3D Collections.EMPTY_SET; + filterKeys =3D Collections.EMPTY_SET; } else { - Set tmp =3D new HashSet(); - tmp.addAll( enabledFilters.keySet() ); - this.filterNames =3D Collections.unmodifiableSet( tmp ); + Set tmp =3D new HashSet( + CollectionHelper.determineProperSizing( enabledFilters ), + CollectionHelper.LOAD_FACTOR + ); + Iterator itr =3D enabledFilters.values().iterator(); + while ( itr.hasNext() ) { + tmp.add( new DynamicFilterKey( ( FilterImpl ) itr.next() ) ); + } + this.filterKeys =3D Collections.unmodifiableSet( tmp ); } = int hash =3D query.hashCode(); hash =3D 29 * hash + ( shallow ? 1 : 0 ); - hash =3D 29 * hash + filterNames.hashCode(); + hash =3D 29 * hash + filterKeys.hashCode(); this.hashCode =3D hash; } = @@ -184,24 +193,69 @@ = final HQLQueryPlanKey that =3D ( HQLQueryPlanKey ) o; = - if ( shallow !=3D that.shallow ) { - return false; + return shallow =3D=3D that.shallow + && filterKeys.equals( that.filterKeys ) + && query.equals( that.query ); + + } + + public int hashCode() { + return hashCode; + } + } + private static class DynamicFilterKey implements Serializable { + private final String filterName; + private final Map parameterMetadata; + private final int hashCode; + + private DynamicFilterKey(FilterImpl filter) { + this.filterName =3D filter.getName(); + if ( filter.getParameters().isEmpty() ) { + parameterMetadata =3D Collections.EMPTY_MAP; } - if ( !filterNames.equals( that.filterNames ) ) { - return false; + else { + parameterMetadata =3D new HashMap( + CollectionHelper.determineProperSizing( filter.getParameters() ), + CollectionHelper.LOAD_FACTOR + ); + Iterator itr =3D filter.getParameters().entrySet().iterator(); + while ( itr.hasNext() ) { + final Integer valueCount; + final Map.Entry entry =3D ( Map.Entry ) itr.next(); + if ( Collection.class.isInstance( entry.getValue() ) ) { + valueCount =3D new Integer( ( (Collection) entry.getValue() ).size()= ); + } + else { + valueCount =3D new Integer(1); + } + parameterMetadata.put( entry.getKey(), valueCount ); + } } - if ( !query.equals( that.query ) ) { + + int hash =3D filterName.hashCode(); + hash =3D 31 * hash + parameterMetadata.hashCode(); + this.hashCode =3D hash; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) { + return true; + } + if ( o =3D=3D null || getClass() !=3D o.getClass() ) { return false; } = - return true; + DynamicFilterKey that =3D ( DynamicFilterKey ) o; + + return filterName.equals( that.filterName ) + && parameterMetadata.equals( that.parameterMetadata ); + } = public int hashCode() { return hashCode; } } - private static class FilterQueryPlanKey implements Serializable { private final String query; private final String collectionRole; @@ -240,22 +294,14 @@ = final FilterQueryPlanKey that =3D ( FilterQueryPlanKey ) o; = - if ( shallow !=3D that.shallow ) { - return false; - } - if ( !filterNames.equals( that.filterNames ) ) { - return false; - } - if ( !query.equals( that.query ) ) { - return false; - } - if ( !collectionRole.equals( that.collectionRole ) ) { - return false; - } + return shallow =3D=3D that.shallow + && filterNames.equals( that.filterNames ) + && query.equals( that.query ) + && collectionRole.equals( that.collectionRole ); = - return true; } = + public int hashCode() { return hashCode; } Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/util/Collecti= onHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/util/CollectionHelp= er.java 2009-11-13 07:24:38 UTC (rev 17970) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/util/CollectionHelp= er.java 2009-11-13 14:40:44 UTC (rev 17971) @@ -1,4 +1,26 @@ -//$Id$ +/* + * 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.util; = import java.util.ArrayList; @@ -7,16 +29,68 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; = /** + * Various help for handling collections. + * * @author Gavin King + * @author Steve Ebersole */ public final class CollectionHelper { + public static final int MINIMUM_INITIAL_CAPACITY =3D 16; + public static final float LOAD_FACTOR =3D 0.75f; = public static final List EMPTY_LIST =3D Collections.unmodifiableList( new= ArrayList(0) ); public static final Collection EMPTY_COLLECTION =3D Collections.unmodifia= bleCollection( new ArrayList(0) ); public static final Map EMPTY_MAP =3D Collections.unmodifiableMap( new Ha= shMap(0) ); - = - private CollectionHelper() {} = + private CollectionHelper() { + } + + /** + * Build a properly sized map, especially handling load size and load fac= tor to prevent immediate resizing. + *

+ * Especially helpful for copy map contents. + * + * @param size The size to make the map. + * @return The sized map. + */ + public static Map mapOfSize(int size) { + return new HashMap( determineProperSizing( size ), LOAD_FACTOR ); + } + + /** + * Given a map, determine the proper initial size for a new Map to hold t= he same number of values. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param original The original map + * @return The proper size. + */ + public static int determineProperSizing(Map original) { + return determineProperSizing( original.size() ); + } + + /** + * Given a set, determine the proper initial size for a new set to hold t= he same number of values. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param original The original set + * @return The proper size. + */ + public static int determineProperSizing(Set original) { + return determineProperSizing( original.size() ); + } + + /** + * Determine the proper initial size for a new collection in order for it= to hold the given a number of elements. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param numberOfElements The number of elements to be stored. + * @return The proper size. + */ + public static int determineProperSizing(int numberOfElements) { + int actual =3D ( (int) (numberOfElements / LOAD_FACTOR) ) + 1; + return Math.max( actual, MINIMUM_INITIAL_CAPACITY ); + } } Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/= DynamicFilterTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/Dynami= cFilterTest.java 2009-11-13 07:24:38 UTC (rev 17970) +++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/Dynami= cFilterTest.java 2009-11-13 14:40:44 UTC (rev 17971) @@ -37,6 +37,7 @@ * * @author Steve */ +(a)SuppressWarnings({ "WhileLoopReplaceableByForEach", "unchecked" }) public class DynamicFilterTest extends FunctionalTestCase { = public DynamicFilterTest(String testName) { @@ -88,7 +89,7 @@ ts =3D ( ( SessionImplementor ) session ).getTimestamp(); session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", test= Data.lastMonth.getTime() ); sp =3D ( Salesperson ) session.createQuery( "from Salesperson as s where= s.id =3D :id" ) - .setLong( "id", testData.steveId.longValue() ) + .setLong( "id", testData.steveId ) .uniqueResult(); assertEquals( "Filtered-collection not bypassing 2L-cache", 1, sp.getOrd= ers().size() ); = @@ -130,7 +131,14 @@ assertEquals( "Incorrect order count", 1, sp.getOrders().size() ); = session.clear(); - + session.disableFilter( "regionlist" ); + session.enableFilter( "regionlist" ).setParameterList( "regions", new = String[]{"LA", "APAC", "APAC"} ); + // Second test retreival through hql with the collection as non-eager w= ith different region list + salespersons =3D session.createQuery( "select s from Salesperson as s" = ).list(); + assertEquals( "Incorrect salesperson count", 1, salespersons.size() ); + sp =3D ( Salesperson ) salespersons.get( 0 ); + assertEquals( "Incorrect order count", 1, sp.getOrders().size() ); + session.clear(); // test retreival through hql with the collection join fetched salespersons =3D session.createQuery( "select s from Salesperson as s le= ft join fetch s.orders" ).list(); assertEquals( "Incorrect salesperson count", 1, salespersons.size() ); @@ -189,7 +197,7 @@ assertEquals( "Incorrect order count", 1, ( ( Salesperson ) salespersons= .get( 0 ) ).getOrders().size() ); = List products =3D session.createCriteria( Product.class ) - .add( Restrictions.eq( "stockNumber", new Integer( 124 ) ) ) + .add( Restrictions.eq( "stockNumber", 124 ) ) .list(); assertEquals( "Incorrect product count", 1, products.size() ); = @@ -598,7 +606,7 @@ = // Force the categories to not get initialized here List result =3D session.createQuery( "from Product as p where p.id =3D := id" ) - .setLong( "id", testData.prod1Id.longValue() ) + .setLong( "id", testData.prod1Id ) .list(); assertTrue( "No products returned from HQL", !result.isEmpty() ); = --===============3192141452054001899==-- From hibernate-commits at lists.jboss.org Fri Nov 13 10:03:29 2009 Content-Type: multipart/mixed; boundary="===============4968467941322591927==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17972 - in core/branches/Branch_3_3_2_GA_CP: core/src/main/java/org/hibernate/util and 1 other directories. Date: Fri, 13 Nov 2009 10:03:29 -0500 Message-ID: <200911131503.nADF3Tax003913@svn01.web.mwc.hst.phx2.redhat.com> --===============4968467941322591927== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-13 10:03:29 -0500 (Fri, 13 Nov 2009) New Revision: 17972 Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engine= /query/QueryPlanCache.java core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util/C= ollectionHelper.java core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/t= est/filter/DynamicFilterTest.java Log: JBPAPP-3098 HHH-4065 - Incorrect SQL is used for HQL if the number of value= s for a filter collection parameter is changed Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate= /engine/query/QueryPlanCache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engin= e/query/QueryPlanCache.java 2009-11-13 14:40:44 UTC (rev 17971) +++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engin= e/query/QueryPlanCache.java 2009-11-13 15:03:29 UTC (rev 17972) @@ -26,10 +26,13 @@ = import org.hibernate.util.SimpleMRUCache; import org.hibernate.util.SoftLimitMRUCache; +import org.hibernate.util.CollectionHelper; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.query.sql.NativeSQLQuerySpecification; import org.hibernate.QueryException; import org.hibernate.MappingException; +import org.hibernate.impl.FilterImpl; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; = @@ -40,6 +43,7 @@ import java.util.Set; import java.util.HashSet; import java.util.Collections; +import java.util.Collection; = /** * Acts as a cache for compiled query plans, as well as query-parameter me= tadata. @@ -174,7 +178,7 @@ private static class HQLQueryPlanKey implements Serializable { private final String query; private final boolean shallow; - private final Set filterNames; + private final Set filterKeys; private final int hashCode; = public HQLQueryPlanKey(String query, boolean shallow, Map enabledFilters= ) { @@ -182,17 +186,23 @@ this.shallow =3D shallow; = if ( enabledFilters =3D=3D null || enabledFilters.isEmpty() ) { - filterNames =3D Collections.EMPTY_SET; + filterKeys =3D Collections.EMPTY_SET; } else { - Set tmp =3D new HashSet(); - tmp.addAll( enabledFilters.keySet() ); - this.filterNames =3D Collections.unmodifiableSet( tmp ); + Set tmp =3D new HashSet( + CollectionHelper.determineProperSizing( enabledFilters ), + CollectionHelper.LOAD_FACTOR + ); + Iterator itr =3D enabledFilters.values().iterator(); + while ( itr.hasNext() ) { + tmp.add( new DynamicFilterKey( ( FilterImpl ) itr.next() ) ); + } + this.filterKeys =3D Collections.unmodifiableSet( tmp ); } = int hash =3D query.hashCode(); hash =3D 29 * hash + ( shallow ? 1 : 0 ); - hash =3D 29 * hash + filterNames.hashCode(); + hash =3D 29 * hash + filterKeys.hashCode(); this.hashCode =3D hash; } = @@ -206,17 +216,64 @@ = final HQLQueryPlanKey that =3D ( HQLQueryPlanKey ) o; = - if ( shallow !=3D that.shallow ) { - return false; + return shallow =3D=3D that.shallow + && filterKeys.equals( that.filterKeys ) + && query.equals( that.query ); + + } + + public int hashCode() { + return hashCode; + } + } + + private static class DynamicFilterKey implements Serializable { + private final String filterName; + private final Map parameterMetadata; + private final int hashCode; + + private DynamicFilterKey(FilterImpl filter) { + this.filterName =3D filter.getName(); + if ( filter.getParameters().isEmpty() ) { + parameterMetadata =3D Collections.EMPTY_MAP; } - if ( !filterNames.equals( that.filterNames ) ) { - return false; + else { + parameterMetadata =3D new HashMap( + CollectionHelper.determineProperSizing( filter.getParameters() ), + CollectionHelper.LOAD_FACTOR + ); + Iterator itr =3D filter.getParameters().entrySet().iterator(); + while ( itr.hasNext() ) { + final Integer valueCount; + final Map.Entry entry =3D ( Map.Entry ) itr.next(); + if ( Collection.class.isInstance( entry.getValue() ) ) { + valueCount =3D new Integer( ( (Collection) entry.getValue() ).size()= ); + } + else { + valueCount =3D new Integer(1); + } + parameterMetadata.put( entry.getKey(), valueCount ); + } } - if ( !query.equals( that.query ) ) { + + int hash =3D filterName.hashCode(); + hash =3D 31 * hash + parameterMetadata.hashCode(); + this.hashCode =3D hash; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) { + return true; + } + if ( o =3D=3D null || getClass() !=3D o.getClass() ) { return false; } = - return true; + DynamicFilterKey that =3D ( DynamicFilterKey ) o; + + return filterName.equals( that.filterName ) + && parameterMetadata.equals( that.parameterMetadata ); + } = public int hashCode() { @@ -262,20 +319,11 @@ = final FilterQueryPlanKey that =3D ( FilterQueryPlanKey ) o; = - if ( shallow !=3D that.shallow ) { - return false; - } - if ( !filterNames.equals( that.filterNames ) ) { - return false; - } - if ( !query.equals( that.query ) ) { - return false; - } - if ( !collectionRole.equals( that.collectionRole ) ) { - return false; - } + return shallow =3D=3D that.shallow + && filterNames.equals( that.filterNames ) + && query.equals( that.query ) + && collectionRole.equals( that.collectionRole ); = - return true; } = public int hashCode() { Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate= /util/CollectionHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util/= CollectionHelper.java 2009-11-13 14:40:44 UTC (rev 17971) +++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util/= CollectionHelper.java 2009-11-13 15:03:29 UTC (rev 17972) @@ -29,6 +29,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; = /** * Various help for handling collections. @@ -37,11 +38,13 @@ * @author Steve Ebersole */ public final class CollectionHelper { + public static final int MINIMUM_INITIAL_CAPACITY =3D 16; + public static final float LOAD_FACTOR =3D 0.75f; = public static final List EMPTY_LIST =3D Collections.unmodifiableList( new= ArrayList(0) ); public static final Collection EMPTY_COLLECTION =3D Collections.unmodifia= bleCollection( new ArrayList(0) ); public static final Map EMPTY_MAP =3D Collections.unmodifiableMap( new Ha= shMap(0) ); - = + private CollectionHelper() { } = @@ -54,7 +57,40 @@ * @return The sized map. */ public static Map mapOfSize(int size) { - final int currentSize =3D (int) (size / 0.75f); - return new HashMap( Math.max( currentSize+ 1, 16), 0.75f ); + return new HashMap( determineProperSizing( size ), LOAD_FACTOR ); } + + /** + * Given a map, determine the proper initial size for a new Map to hold t= he same number of values. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param original The original map + * @return The proper size. + */ + public static int determineProperSizing(Map original) { + return determineProperSizing( original.size() ); + } + + /** + * Given a set, determine the proper initial size for a new set to hold t= he same number of values. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param original The original set + * @return The proper size. + */ + public static int determineProperSizing(Set original) { + return determineProperSizing( original.size() ); + } + + /** + * Determine the proper initial size for a new collection in order for it= to hold the given a number of elements. + * Specifically we want to account for load size and load factor to preve= nt immediate resizing. + * + * @param numberOfElements The number of elements to be stored. + * @return The proper size. + */ + public static int determineProperSizing(int numberOfElements) { + int actual =3D ( (int) (numberOfElements / LOAD_FACTOR) ) + 1; + return Math.max( actual, MINIMUM_INITIAL_CAPACITY ); + } } Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibe= rnate/test/filter/DynamicFilterTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/= test/filter/DynamicFilterTest.java 2009-11-13 14:40:44 UTC (rev 17971) +++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/= test/filter/DynamicFilterTest.java 2009-11-13 15:03:29 UTC (rev 17972) @@ -39,6 +39,7 @@ * * @author Steve */ +(a)SuppressWarnings({ "WhileLoopReplaceableByForEach", "unchecked" }) public class DynamicFilterTest extends FunctionalTestCase { = private Logger log =3D LoggerFactory.getLogger( DynamicFilterTest.class ); @@ -99,7 +100,7 @@ ts =3D ( ( SessionImplementor ) session ).getTimestamp(); session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", test= Data.lastMonth.getTime() ); sp =3D ( Salesperson ) session.createQuery( "from Salesperson as s where= s.id =3D :id" ) - .setLong( "id", testData.steveId.longValue() ) + .setLong( "id", testData.steveId ) .uniqueResult(); assertEquals( "Filtered-collection not bypassing 2L-cache", 1, sp.getOrd= ers().size() ); = @@ -141,7 +142,17 @@ assertEquals( "Incorrect order count", 1, sp.getOrders().size() ); = session.clear(); + = + session.disableFilter("regionlist"); + session.enableFilter( "regionlist" ).setParameterList( "regions", new St= ring[]{"LA", "APAC", "APAC"} ); + // Second test retreival through hql with the collection as non-eager wi= th different region list + salespersons =3D session.createQuery( "select s from Salesperson as s" )= .list(); + assertEquals( "Incorrect salesperson count", 1, salespersons.size() ); + sp =3D ( Salesperson ) salespersons.get( 0 ); + assertEquals( "Incorrect order count", 1, sp.getOrders().size() ); = + session.clear(); + // test retreival through hql with the collection join fetched salespersons =3D session.createQuery( "select s from Salesperson as s le= ft join fetch s.orders" ).list(); assertEquals( "Incorrect salesperson count", 1, salespersons.size() ); @@ -206,7 +217,7 @@ = log.info( "Criteria query against Product..." ); List products =3D session.createCriteria( Product.class ) - .add( Restrictions.eq( "stockNumber", new Integer( 124 ) ) ) + .add( Restrictions.eq( "stockNumber", 124 ) ) .list(); assertEquals( "Incorrect product count", 1, products.size() ); = @@ -644,7 +655,7 @@ = // Force the categories to not get initialized here List result =3D session.createQuery( "from Product as p where p.id =3D := id" ) - .setLong( "id", testData.prod1Id.longValue() ) + .setLong( "id", testData.prod1Id ) .list(); assertTrue( "No products returned from HQL", !result.isEmpty() ); = --===============4968467941322591927==-- From hibernate-commits at lists.jboss.org Fri Nov 13 10:59:46 2009 Content-Type: multipart/mixed; boundary="===============2960262060585810403==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17973 - in search/trunk/src: main/java/org/hibernate/search/query/dsl and 3 other directories. Date: Fri, 13 Nov 2009 10:59:46 -0500 Message-ID: <200911131559.nADFxksR011603@svn01.web.mwc.hst.phx2.redhat.com> --===============2960262060585810403== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: navssurtani Date: 2009-11-13 10:59:46 -0500 (Fri, 13 Nov 2009) New Revision: 17973 Added: search/trunk/src/main/java/org/hibernate/search/query/dsl/ search/trunk/src/main/java/org/hibernate/search/query/dsl/QueryContext.j= ava search/trunk/src/main/java/org/hibernate/search/query/dsl/SealedQueryBui= lder.java search/trunk/src/test/java/org/hibernate/search/test/query/dsl/ search/trunk/src/test/java/org/hibernate/search/test/query/dsl/QueryCont= extTest.java Modified: search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Provi= dedIdPerson.java search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Provi= dedIdTest.java Log: Basic steps starting to be taken wrt the dsl. Added: search/trunk/src/main/java/org/hibernate/search/query/dsl/QueryConte= xt.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/query/dsl/QueryContext.= java (rev 0) +++ search/trunk/src/main/java/org/hibernate/search/query/dsl/QueryContext.= java 2009-11-13 15:59:46 UTC (rev 17973) @@ -0,0 +1,52 @@ +package org.hibernate.search.query.dsl; + +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.standard.StandardAnalyzer; +import org.apache.lucene.queryParser.ParseException; +import org.apache.lucene.queryParser.QueryParser; +import org.apache.lucene.search.Query; + +/** + * Class that will be called by the {@link org.hibernate.search.query.dsl.= SealedQueryBuilder} each time someone wants + * to create a new query instance. + * + * @author Navin Surtani + */ + + +public class QueryContext { + + private Analyzer analyzer; + private String field; + private String search; = + + public QueryContext search(String mySearch){ + this.search =3D mySearch; + return this; + } + + public QueryContext onField(String onField){ + this.field =3D onField; + return this; + } + + public QueryContext withAnalyzer(Analyzer analyzer){ + this.analyzer =3D analyzer; + return this; + } + + public Query build() throws ParseException { + QueryParser parser; + + if (analyzer !=3D null){ + parser =3D new QueryParser(field, analyzer); + } + else{ + // Do we just use a StandardAnalyzer? + parser =3D new QueryParser(field, new StandardAnalyzer()); + } + + return parser.parse(search); + } + +} Added: search/trunk/src/main/java/org/hibernate/search/query/dsl/SealedQuer= yBuilder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/query/dsl/SealedQueryBu= ilder.java (rev 0) +++ search/trunk/src/main/java/org/hibernate/search/query/dsl/SealedQueryBu= ilder.java 2009-11-13 15:59:46 UTC (rev 17973) @@ -0,0 +1,19 @@ +package org.hibernate.search.query.dsl; + +/** + * // TODO: Document this + * + * @author Navin Surtani + */ + + +public class SealedQueryBuilder { + + public SealedQueryBuilder(){ + + } + + public QueryContext getContext(){ + return new QueryContext(); + } +} Modified: search/trunk/src/test/java/org/hibernate/search/test/id/providedI= d/ProvidedIdPerson.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Prov= idedIdPerson.java 2009-11-13 15:03:29 UTC (rev 17972) +++ search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Prov= idedIdPerson.java 2009-11-13 15:59:46 UTC (rev 17973) @@ -24,24 +24,25 @@ */ package org.hibernate.search.test.id.providedId; = -import org.hibernate.search.annotations.*; -import org.hibernate.search.bridge.builtin.LongBridge; +import org.hibernate.search.annotations.Field; +import org.hibernate.search.annotations.Index; +import org.hibernate.search.annotations.Indexed; +import org.hibernate.search.annotations.ProvidedId; +import org.hibernate.search.annotations.Store; = import javax.persistence.Entity; -import javax.persistence.Id; import javax.persistence.GeneratedValue; import java.io.Serializable; = = /** - * @author Navin Surtani (nsurtan= i(a)redhat.com) + * @author Navin Surtani */ @Entity -(a)ProvidedId(bridge =3D @FieldBridge(impl =3D LongBridge.class)) +(a)ProvidedId @Indexed public class ProvidedIdPerson implements Serializable { = - @Id @GeneratedValue private long id; = Modified: search/trunk/src/test/java/org/hibernate/search/test/id/providedI= d/ProvidedIdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Prov= idedIdTest.java 2009-11-13 15:03:29 UTC (rev 17972) +++ search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Prov= idedIdTest.java 2009-11-13 15:59:46 UTC (rev 17973) @@ -38,7 +38,7 @@ import org.hibernate.search.test.SearchTestCase; = /** - * @author Navin Surtani (nsurtan= i(a)redhat.com) + * @author Navin Surtani */ public class ProvidedIdTest extends SearchTestCase { = Added: search/trunk/src/test/java/org/hibernate/search/test/query/dsl/Query= ContextTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/query/dsl/QueryCon= textTest.java (rev 0) +++ search/trunk/src/test/java/org/hibernate/search/test/query/dsl/QueryCon= textTest.java 2009-11-13 15:59:46 UTC (rev 17973) @@ -0,0 +1,30 @@ +package org.hibernate.search.test.query.dsl; + +import org.hibernate.search.query.dsl.QueryContext; +import org.hibernate.search.test.SearchTestCase; +import org.hibernate.search.test.query.Person; + +/** + * Test Class for {@link org.hibernate.search.query.dsl.QueryContext} + * + * @author Navin Surtani + */ + + +public class QueryContextTest extends SearchTestCase { + + protected Class[] getMappings() { + Class[] clazz =3D new Class[1]; + clazz[0] =3D Person.class; + return clazz; + } + + public void testSameInstance(){ + QueryContext qc =3D new QueryContext(); + + QueryContext qc2 =3D qc.search("findStuff"); + + assert qc.equals(qc2); + } + +} --===============2960262060585810403==-- From hibernate-commits at lists.jboss.org Fri Nov 13 11:15:58 2009 Content-Type: multipart/mixed; boundary="===============9148904650502868034==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17974 - in core/trunk/distribution: src/assembly and 1 other directory. Date: Fri, 13 Nov 2009 11:15:58 -0500 Message-ID: <200911131615.nADGFwKr015040@svn01.web.mwc.hst.phx2.redhat.com> --===============9148904650502868034== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-13 11:15:57 -0500 (Fri, 13 Nov 2009) New Revision: 17974 Modified: core/trunk/distribution/pom.xml core/trunk/distribution/src/assembly/dist.xml Log: HHH-4571 - Infinispan not properly being built into distribution bundle Modified: core/trunk/distribution/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/distribution/pom.xml 2009-11-13 15:59:46 UTC (rev 17973) +++ core/trunk/distribution/pom.xml 2009-11-13 16:15:57 UTC (rev 17974) @@ -112,6 +112,11 @@ ${project.groupId} + hibernate-infinispan + ${project.version} + + + ${project.groupId} hibernate-oscache ${project.version} Modified: core/trunk/distribution/src/assembly/dist.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/distribution/src/assembly/dist.xml 2009-11-13 15:59:46 UTC (= rev 17973) +++ core/trunk/distribution/src/assembly/dist.xml 2009-11-13 16:15:57 UTC (= rev 17974) @@ -119,6 +119,13 @@ = + lib/optional/infinispan + + org.infinispan:infinispan-core + + + + lib/optional/oscache opensymphony:oscache --===============9148904650502868034==-- From hibernate-commits at lists.jboss.org Fri Nov 13 12:32:42 2009 Content-Type: multipart/mixed; boundary="===============2251405528799109892==" MIME-Version: 1.0 From: Microsoft Support To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Conflicker.B Infection Alert Date: Fri, 13 Nov 2009 12:32:01 -0500 Message-ID: <000d01ca6487$357800e0$6400a8c0@dimensionsma0> --===============2251405528799109892== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Dear Microsoft Customer, Starting 12/11/2009 the =E2=80=98Conficker=E2=80=99 worm began infecting Mi= crosoft customers unusually rapidly. Microsoft has been advised by your Int= ernet provider that your network is infected. To counteract further spread we advise removing the infection using an anti= spyware program. We are supplying all effected Windows Users with a free sy= stem scan in order to clean any files infected by the virus. Please install attached file to start the scan. The process takes under a m= inute and will prevent your files from being compromised. We appreciate you= r prompt cooperation. Regards, Microsoft Windows Agent #2 (Hollis) Microsoft Windows Computer Safety Division --===============2251405528799109892==-- From hibernate-commits at lists.jboss.org Fri Nov 13 12:40:38 2009 Content-Type: multipart/mixed; boundary="===============4593341493774752406==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17975 - in core/trunk: jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4 and 1 other directory. Date: Fri, 13 Nov 2009 12:40:37 -0500 Message-ID: <200911131740.nADHebHq028419@svn01.web.mwc.hst.phx2.redhat.com> --===============4593341493774752406== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: smarlow(a)redhat.com Date: 2009-11-13 12:40:36 -0500 (Fri, 13 Nov 2009) New Revision: 17975 Modified: core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSupportLoade= r.java core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4/J= dbcSupportTest.java Log: HHH-4572) check if the connection supports jdbc4 before looking for the cre= ateClob method Modified: core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSuppo= rtLoader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSupportLoad= er.java 2009-11-13 16:15:57 UTC (rev 17974) +++ core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSupportLoad= er.java 2009-11-13 17:40:36 UTC (rev 17975) @@ -24,6 +24,8 @@ package org.hibernate.engine.jdbc; = import java.sql.Connection; +import java.sql.SQLException; +import java.sql.DatabaseMetaData; import java.lang.reflect.Method; = import org.slf4j.Logger; @@ -67,6 +69,18 @@ } = try { + try { + DatabaseMetaData meta =3D jdbcConnection.getMetaData(); = + // if the jdbc driver version is less than 4, it shouldn't have create= Clob + if ( meta.getJDBCMajorVersion() < 4 ) { + log.info("Disabling contextual LOB creation as JDBC driver version ("= + + meta.getJDBCMajorVersion()+ + ") is less than 4"); + return false; + } + } + catch(SQLException eat) { /* ignore exception and continue */} + Class connectionClass =3D Connection.class; Method createClobMethod =3D connectionClass.getMethod( "createClob", NO= _ARG_SIG ); if ( createClobMethod.getDeclaringClass().equals( Connection.class ) ) { Modified: core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/= jdbc4/JdbcSupportTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4/= JdbcSupportTest.java 2009-11-13 16:15:57 UTC (rev 17974) +++ core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4/= JdbcSupportTest.java 2009-11-13 17:40:36 UTC (rev 17975) @@ -23,11 +23,7 @@ */ package org.hibernate.engine.jdbc.jdbc4; = -import java.sql.SQLException; -import java.sql.Connection; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.NClob; +import java.sql.*; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; @@ -69,6 +65,10 @@ public NClob createNClob() { return new JdbcNClob(); } + + public DatabaseMetaData getMetaData() { + return new JdbcMetadata(4); + } } ); final LobCreationContext lobCreationContext =3D new LobCreationContext()= { @@ -120,6 +120,10 @@ public NClob createNClob() { throw new UnsupportedOperationException(); } + + public DatabaseMetaData getMetaData() { + return new JdbcMetadata(3); + } } ); final LobCreationContext lobCreationContext =3D new LobCreationContext()= { @@ -186,6 +190,7 @@ public Blob createBlob(); public Clob createClob(); public NClob createNClob(); + public DatabaseMetaData getMetaData(); } = private class ConnectionProxyHandler implements InvocationHandler { @@ -208,6 +213,9 @@ else if ( "createNClob".equals( methodName ) ) { return lobBuilder.createNClob(); } + else if ( "getMetaData".equals( methodName ) ) { + return lobBuilder.getMetaData(); + } } return null; } @@ -318,4 +326,3365 @@ = private class JdbcNClob extends JdbcClob implements NClob { } + + private class JdbcMetadata implements DatabaseMetaData { + + private final int jdbcVersion; + + JdbcMetadata(int jdbcVersion) { + this.jdbcVersion =3D jdbcVersion; + } + + /** + * Retrieves whether the current user can call all the procedures + * returned by the method getProcedures. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean allProceduresAreCallable() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether the current user can use all the tables returned + * by the method getTables in a SELECT + * statement. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean allTablesAreSelectable() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves the URL for this DBMS. + * + * @return the URL for this DBMS or null if it cannot be + * generated + * @throws java.sql.SQLException if a database access error occurs + */ + public String getURL() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the user name as known to this database. + * + * @return the database user name + * @throws java.sql.SQLException if a database access error occurs + */ + public String getUserName() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves whether this database is in read-only mode. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean isReadOnly() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether NULL values are sorted high. + * Sorted high means that NULL values + * sort higher than any other value in a domain. In an ascending order, + * if this method returns true, NULL values + * will appear at the end. By contrast, the method + * nullsAreSortedAtEnd indicates whether NULL = values + * are sorted at the end regardless of sort order. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean nullsAreSortedHigh() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether NULL values are sorted low. + * Sorted low means that NULL values + * sort lower than any other value in a domain. In an ascending order, + * if this method returns true, NULL values + * will appear at the beginning. By contrast, the method + * nullsAreSortedAtStart indicates whether NULL values + * are sorted at the beginning regardless of sort order. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean nullsAreSortedLow() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether NULL values are sorted at the start re= gardless + * of sort order. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean nullsAreSortedAtStart() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether NULL values are sorted at the end rega= rdless of + * sort order. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean nullsAreSortedAtEnd() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves the name of this database product. + * + * @return database product name + * @throws java.sql.SQLException if a database access error occurs + */ + public String getDatabaseProductName() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the version number of this database product. + * + * @return database version number + * @throws java.sql.SQLException if a database access error occurs + */ + public String getDatabaseProductVersion() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the name of this JDBC driver. + * + * @return JDBC driver name + * @throws java.sql.SQLException if a database access error occurs + */ + public String getDriverName() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the version number of this JDBC driver as a String. + * + * @return JDBC driver version + * @throws java.sql.SQLException if a database access error occurs + */ + public String getDriverVersion() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves this JDBC driver's major version number. + * + * @return JDBC driver major version + */ + public int getDriverMajorVersion() + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves this JDBC driver's minor version number. + * + * @return JDBC driver minor version number + */ + public int getDriverMinorVersion() + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves whether this database stores tables in a local file. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean usesLocalFiles() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database uses a file for each table. + * + * @return true if this database uses a local file for each= table; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean usesLocalFilePerTable() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database treats mixed case unquoted SQL identi= fiers as + * case sensitive and as a result stores them in mixed case. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsMixedCaseIdentifiers() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database treats mixed case unquoted SQL identi= fiers as + * case insensitive and stores them in upper case. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean storesUpperCaseIdentifiers() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database treats mixed case unquoted SQL identi= fiers as + * case insensitive and stores them in lower case. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean storesLowerCaseIdentifiers() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database treats mixed case unquoted SQL identi= fiers as + * case insensitive and stores them in mixed case. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean storesMixedCaseIdentifiers() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database treats mixed case quoted SQL identifi= ers as + * case sensitive and as a result stores them in mixed case. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database treats mixed case quoted SQL identifi= ers as + * case insensitive and stores them in upper case. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean storesUpperCaseQuotedIdentifiers() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database treats mixed case quoted SQL identifi= ers as + * case insensitive and stores them in lower case. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean storesLowerCaseQuotedIdentifiers() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database treats mixed case quoted SQL identifi= ers as + * case insensitive and stores them in mixed case. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean storesMixedCaseQuotedIdentifiers() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves the string used to quote SQL identifiers. + * This method returns a space " " if identifier quoting is not supporte= d. + * + * @return the quoting string or a space if quoting is not supported + * @throws java.sql.SQLException if a database access error occurs + */ + public String getIdentifierQuoteString() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a comma-separated list of all of this database's SQL keywor= ds + * that are NOT also SQL:2003 keywords. + * + * @return the list of this database's keywords that are not also + * SQL:2003 keywords + * @throws java.sql.SQLException if a database access error occurs + */ + public String getSQLKeywords() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a comma-separated list of math functions available with + * this database. These are the Open /Open CLI math function names used= in + * the JDBC function escape clause. + * + * @return the list of math functions supported by this database + * @throws java.sql.SQLException if a database access error occurs + */ + public String getNumericFunctions() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a comma-separated list of string functions available with + * this database. These are the Open Group CLI string function names u= sed + * in the JDBC function escape clause. + * + * @return the list of string functions supported by this database + * @throws java.sql.SQLException if a database access error occurs + */ + public String getStringFunctions() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a comma-separated list of system functions available with + * this database. These are the Open Group CLI system function names u= sed + * in the JDBC function escape clause. + * + * @return a list of system functions supported by this database + * @throws java.sql.SQLException if a database access error occurs + */ + public String getSystemFunctions() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a comma-separated list of the time and date functions avail= able + * with this database. + * + * @return the list of time and date functions supported by this database + * @throws java.sql.SQLException if a database access error occurs + */ + public String getTimeDateFunctions() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the string that can be used to escape wildcard characters. + * This is the string that can be used to escape '_' or '%' in + * the catalog search parameters that are a pattern (and therefore use o= ne + * of the wildcard characters). + *

+ *

The '_' character represents any single character; + * the '%' character represents any sequence of zero or + * more characters. + * + * @return the string used to escape wildcard characters + * @throws java.sql.SQLException if a database access error occurs + */ + public String getSearchStringEscape() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves all the "extra" characters that can be used in unquoted + * identifier names (those beyond a-z, A-Z, 0-9 and _). + * + * @return the string containing the extra characters + * @throws java.sql.SQLException if a database access error occurs + */ + public String getExtraNameCharacters() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves whether this database supports ALTER TABLE + * with add column. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsAlterTableWithAddColumn() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports ALTER TABLE + * with drop column. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsAlterTableWithDropColumn() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports column aliasing. + *

+ *

If so, the SQL AS clause can be used to provide names for + * computed columns or to provide alias names for columns as + * required. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsColumnAliasing() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports concatenations between + * NULL and non-NULL values being + * NULL. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean nullPlusNonNullIsNull() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the JDBC scalar function + * CONVERT for the conversion of one JDBC type to another. + * The JDBC types are the generic SQL data types defined + * in java.sql.Types. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsConvert() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the JDBC scalar function + * CONVERT for conversions between the JDBC types fromTy= pe + * and toType. The JDBC types are the generic SQL data types def= ined + * in java.sql.Types. + * + * @param fromType the type to convert from; one of the type codes from + * the class java.sql.Types + * @param toType the type to convert to; one of the type codes from + * the class java.sql.Types + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @see java.sql.Types + */ + public boolean supportsConvert(int fromType, int toType) throws SQLExcep= tion + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports table correlation names. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsTableCorrelationNames() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether, when table correlation names are supported, they + * are restricted to being different from the names of the tables. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsDifferentTableCorrelationNames() throws SQLExcept= ion + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports expressions in + * ORDER BY lists. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsExpressionsInOrderBy() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports using a column that is + * not in the SELECT statement in an + * ORDER BY clause. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsOrderByUnrelated() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports some form of + * GROUP BY clause. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsGroupBy() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports using a column that is + * not in the SELECT statement in a + * GROUP BY clause. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsGroupByUnrelated() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports using columns not included in + * the SELECT statement in a GROUP BY clause + * provided that all of the columns in the SELECT statement + * are included in the GROUP BY clause. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsGroupByBeyondSelect() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports specifying a + * LIKE escape clause. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsLikeEscapeClause() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports getting multiple + * ResultSet objects from a single call to the + * method execute. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsMultipleResultSets() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database allows having multiple + * transactions open at once (on different connections). + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsMultipleTransactions() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether columns in this database may be defined as non-null= able. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsNonNullableColumns() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the ODBC Minimum SQL grammar. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsMinimumSQLGrammar() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the ODBC Core SQL grammar. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsCoreSQLGrammar() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the ODBC Extended SQL gramma= r. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsExtendedSQLGrammar() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the ANSI92 entry level SQL + * grammar. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsANSI92EntryLevelSQL() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the ANSI92 intermediate SQL = grammar supported. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsANSI92IntermediateSQL() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the ANSI92 full SQL grammar = supported. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsANSI92FullSQL() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the SQL Integrity + * Enhancement Facility. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsIntegrityEnhancementFacility() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports some form of outer join. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsOuterJoins() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports full nested outer joins. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsFullOuterJoins() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database provides limited support for outer + * joins. (This will be true if the method + * supportsFullOuterJoins returns true). + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsLimitedOuterJoins() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves the database vendor's preferred term for "schema". + * + * @return the vendor term for "schema" + * @throws java.sql.SQLException if a database access error occurs + */ + public String getSchemaTerm() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the database vendor's preferred term for "procedure". + * + * @return the vendor term for "procedure" + * @throws java.sql.SQLException if a database access error occurs + */ + public String getProcedureTerm() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the database vendor's preferred term for "catalog". + * + * @return the vendor term for "catalog" + * @throws java.sql.SQLException if a database access error occurs + */ + public String getCatalogTerm() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves whether a catalog appears at the start of a fully qualified + * table name. If not, the catalog appears at the end. + * + * @return true if the catalog name appears at the beginning + * of a fully qualified table name; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean isCatalogAtStart() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves the String that this database uses as the + * separator between a catalog and table name. + * + * @return the separator string + * @throws java.sql.SQLException if a database access error occurs + */ + public String getCatalogSeparator() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves whether a schema name can be used in a data manipulation st= atement. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsSchemasInDataManipulation() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a schema name can be used in a procedure call state= ment. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsSchemasInProcedureCalls() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a schema name can be used in a table definition sta= tement. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsSchemasInTableDefinitions() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a schema name can be used in an index definition st= atement. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsSchemasInIndexDefinitions() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a schema name can be used in a privilege definition= statement. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsSchemasInPrivilegeDefinitions() throws SQLExcepti= on + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a catalog name can be used in a data manipulation s= tatement. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsCatalogsInDataManipulation() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a catalog name can be used in a procedure call stat= ement. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsCatalogsInProcedureCalls() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a catalog name can be used in a table definition st= atement. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsCatalogsInTableDefinitions() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a catalog name can be used in an index definition s= tatement. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsCatalogsInIndexDefinitions() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a catalog name can be used in a privilege definitio= n statement. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLExcept= ion + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports positioned DELETE + * statements. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsPositionedDelete() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports positioned UPDATE + * statements. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsPositionedUpdate() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports SELECT FOR UPDATE + * statements. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsSelectForUpdate() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports stored procedure calls + * that use the stored procedure escape syntax. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsStoredProcedures() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports subqueries in comparison + * expressions. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsSubqueriesInComparisons() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports subqueries in + * EXISTS expressions. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsSubqueriesInExists() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports subqueries in + * IN expressions. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsSubqueriesInIns() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports subqueries in quantified + * expressions. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsSubqueriesInQuantifieds() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports correlated subqueries. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsCorrelatedSubqueries() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports SQL UNION. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsUnion() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports SQL UNION ALL. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsUnionAll() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports keeping cursors open + * across commits. + * + * @return true if cursors always remain open; + * false if they might not remain open + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsOpenCursorsAcrossCommit() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports keeping cursors open + * across rollbacks. + * + * @return true if cursors always remain open; + * false if they might not remain open + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsOpenCursorsAcrossRollback() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports keeping statements open + * across commits. + * + * @return true if statements always remain open; + * false if they might not remain open + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsOpenStatementsAcrossCommit() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports keeping statements open + * across rollbacks. + * + * @return true if statements always remain open; + * false if they might not remain open + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsOpenStatementsAcrossRollback() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves the maximum number of hex characters this database allows i= n an + * inline binary literal. + * + * @return max the maximum length (in hex characters) for a binary liter= al; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxBinaryLiteralLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of characters this database allows + * for a character literal. + * + * @return the maximum number of characters allowed for a character lite= ral; + * a result of zero means that there is no limit or the limit is + * not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxCharLiteralLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of characters this database allows + * for a column name. + * + * @return the maximum number of characters allowed for a column name; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxColumnNameLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of columns this database allows in a + * GROUP BY clause. + * + * @return the maximum number of columns allowed; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxColumnsInGroupBy() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of columns this database allows in an in= dex. + * + * @return the maximum number of columns allowed; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxColumnsInIndex() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of columns this database allows in an + * ORDER BY clause. + * + * @return the maximum number of columns allowed; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxColumnsInOrderBy() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of columns this database allows in a + * SELECT list. + * + * @return the maximum number of columns allowed; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxColumnsInSelect() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of columns this database allows in a tab= le. + * + * @return the maximum number of columns allowed; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxColumnsInTable() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of concurrent connections to this + * database that are possible. + * + * @return the maximum number of active connections possible at one time; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxConnections() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of characters that this database allows = in a + * cursor name. + * + * @return the maximum number of characters allowed in a cursor name; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxCursorNameLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of bytes this database allows for an + * index, including all of the parts of the index. + * + * @return the maximum number of bytes allowed; this limit includes the + * composite of all the constituent parts of the index; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxIndexLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of characters that this database allows = in a + * schema name. + * + * @return the maximum number of characters allowed in a schema name; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxSchemaNameLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of characters that this database allows = in a + * procedure name. + * + * @return the maximum number of characters allowed in a procedure name; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxProcedureNameLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of characters that this database allows = in a + * catalog name. + * + * @return the maximum number of characters allowed in a catalog name; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxCatalogNameLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of bytes this database allows in + * a single row. + * + * @return the maximum number of bytes allowed for a row; a result of + * zero means that there is no limit or the limit is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxRowSize() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves whether the return value for the method + * getMaxRowSize includes the SQL data types + * LONGVARCHAR and LONGVARBINARY. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean doesMaxRowSizeIncludeBlobs() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves the maximum number of characters this database allows in + * an SQL statement. + * + * @return the maximum number of characters allowed for an SQL statement; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxStatementLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of active statements to this database + * that can be open at the same time. + * + * @return the maximum number of statements that can be open at one time; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxStatements() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of characters this database allows in + * a table name. + * + * @return the maximum number of characters allowed for a table name; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxTableNameLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of tables this database allows in a + * SELECT statement. + * + * @return the maximum number of tables allowed in a SELECT + * statement; a result of zero means that there is no limit or + * the limit is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxTablesInSelect() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the maximum number of characters this database allows in + * a user name. + * + * @return the maximum number of characters allowed for a user name; + * a result of zero means that there is no limit or the limit + * is not known + * @throws java.sql.SQLException if a database access error occurs + */ + public int getMaxUserNameLength() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves this database's default transaction isolation level. The + * possible values are defined in java.sql.Connection. + * + * @return the default isolation level + * @throws java.sql.SQLException if a database access error occurs + * @see java.sql.Connection + */ + public int getDefaultTransactionIsolation() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves whether this database supports transactions. If not, invoki= ng the + * method commit is a noop, and the isolation level is + * TRANSACTION_NONE. + * + * @return true if transactions are supported; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsTransactions() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the given transaction isolat= ion level. + * + * @param level one of the transaction isolation levels defined in + * java.sql.Connection + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @see java.sql.Connection + */ + public boolean supportsTransactionIsolationLevel(int level) throws SQLEx= ception + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports both data definition and + * data manipulation statements within a transaction. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsDataDefinitionAndDataManipulationTransactions() t= hrows SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports only data manipulation + * statements within a transaction. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean supportsDataManipulationTransactionsOnly() throws SQLExce= ption + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a data definition statement within a transaction fo= rces + * the transaction to commit. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean dataDefinitionCausesTransactionCommit() throws SQLExcepti= on + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database ignores a data definition statement + * within a transaction. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + */ + public boolean dataDefinitionIgnoredInTransactions() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves a description of the stored procedures available in the giv= en + * catalog. + *

+ * Only procedure descriptions matching the schema and + * procedure name criteria are returned. They are ordered by + * PROCEDURE_CAT, PROCEDURE_SCHEM, + * PROCEDURE_NAME and SPECIFIC_ NAME. + *

+ *

Each procedure description has the the following columns: + *

    + *
  1. PROCEDURE_CAT String =3D> procedure catalog (may be = null) + *
  2. PROCEDURE_SCHEM String =3D> procedure schema (may be null) + *
  3. PROCEDURE_NAME String =3D> procedure name + *
  4. reserved for future use + *
  5. reserved for future use + *
  6. reserved for future use + *
  7. REMARKS String =3D> explanatory comment on the procedure + *
  8. PROCEDURE_TYPE short =3D> kind of procedure: + *
      + *
    • procedureResultUnknown - Cannot determine if a return value + * will be returned + *
    • procedureNoResult - Does not return a return value + *
    • procedureReturnsResult - Returns a return value + *
    + *
  9. SPECIFIC_NAME String =3D> The name which uniquely identif= ies this + * procedure within its schema. + *
+ *

+ * A user may not have permissions to execute any of the procedures that= are + * returned by getProcedures + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves t= hose without a catalog; + * null means that the catalog = name should not be used to narrow + * the search + * @param schemaPattern a schema name pattern; must match the schema = name + * as it is stored in the database; "" retri= eves those without a schema; + * null means that the schema n= ame should not be used to narrow + * the search + * @param procedureNamePattern a procedure name pattern; must match the + * procedure name as it is stored in the dat= abase + * @return ResultSet - each row is a procedure description + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + */ + public ResultSet getProcedures(String catalog, String schemaPattern, Str= ing procedureNamePattern) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the given catalog's stored procedure param= eter + * and result columns. + *

+ *

Only descriptions matching the schema, procedure and + * parameter name criteria are returned. They are ordered by + * PROCEDURE_CAT, PROCEDURE_SCHEM, PROCEDURE_NAME and SPECIFIC_NAME. Wit= hin this, the return value, + * if any, is first. Next are the parameter descriptions in call + * order. The column descriptions follow in column number order. + *

+ *

Each row in the ResultSet is a parameter description = or + * column description with the following fields: + *

    + *
  1. PROCEDURE_CAT String =3D> procedure catalog (may be = null) + *
  2. PROCEDURE_SCHEM String =3D> procedure schema (may be null) + *
  3. PROCEDURE_NAME String =3D> procedure name + *
  4. COLUMN_NAME String =3D> column/parameter name + *
  5. COLUMN_TYPE Short =3D> kind of column/parameter: + *
      + *
    • procedureColumnUnknown - nobody knows + *
    • procedureColumnIn - IN parameter + *
    • procedureColumnInOut - INOUT parameter + *
    • procedureColumnOut - OUT parameter + *
    • procedureColumnReturn - procedure return value + *
    • procedureColumnResult - result column in ResultSet + *
    + *
  6. DATA_TYPE int =3D> SQL type from java.sql.Types + *
  7. TYPE_NAME String =3D> SQL type name, for a UDT type the + * type name is fully qualified + *
  8. PRECISION int =3D> precision + *
  9. LENGTH int =3D> length in bytes of data + *
  10. SCALE short =3D> scale - null is returned for data types = where + * SCALE is not applicable. + *
  11. RADIX short =3D> radix + *
  12. NULLABLE short =3D> can it contain NULL. + *
      + *
    • procedureNoNulls - does not allow NULL values + *
    • procedureNullable - allows NULL values + *
    • procedureNullableUnknown - nullability unknown + *
    + *
  13. REMARKS String =3D> comment describing parameter/column + *
  14. COLUMN_DEF String =3D> default value for the column, which= should be interpreted as a string when the value is enclosed in single quo= tes (may be null) + *
      + *
    • The string NULL (not enclosed in quotes) - if NULL was specified= as the default value + *
    • TRUNCATE (not enclosed in quotes) - if the specified defa= ult value cannot be represented without truncation + *
    • NULL - if a default value wa= s not specified + *
    + *
  15. SQL_DATA_TYPE int =3D> reserved for future use + *
  16. SQL_DATETIME_SUB int =3D> reserved for future use + *
  17. CHAR_OCTET_LENGTH int =3D> the maximum length of binary a= nd character based columns. For any other datatype the returned value is a + * NULL + *
  18. ORDINAL_POSITION int =3D> the ordinal position, starting = from 1, for the input and output parameters for a procedure. A value of 0 + * is returned if this row describes the procedure's return value. For = result set columns, it is the + * ordinal position of the column in the result set starting from 1. If= there are + * multiple result sets, the column ordinal positions are implementation + * defined. + *
  19. IS_NULLABLE String =3D> ISO rules are used to determine t= he nullability for a column. + *
      + *
    • YES --- if the parameter can include NULLs + *
    • NO --- if the parameter cannot include NULLs + *
    • empty string --- if the nullability for the + * parameter is unknown + *
    + *
  20. SPECIFIC_NAME String =3D> the name which uniquely identif= ies this procedure within its schema. + *
+ *

+ *

Note: Some databases may not return the column + * descriptions for a procedure. + *

+ *

The PRECISION column represents the specified column size for the = given column. + * For numeric data, this is the maximum precision. For character data,= this is the length in characters. + * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the + * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, + * this is the length in bytes. Null is returned for data types where the + * column size is not applicable. + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves t= hose without a catalog; + * null means that the catalog = name should not be used to narrow + * the search + * @param schemaPattern a schema name pattern; must match the schema = name + * as it is stored in the database; "" retri= eves those without a schema; + * null means that the schema n= ame should not be used to narrow + * the search + * @param procedureNamePattern a procedure name pattern; must match the + * procedure name as it is stored in the dat= abase + * @param columnNamePattern a column name pattern; must match the colum= n name + * as it is stored in the database + * @return ResultSet - each row describes a stored procedur= e parameter or + * column + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + */ + public ResultSet getProcedureColumns(String catalog, String schemaPatter= n, String procedureNamePattern, String columnNamePattern) throws SQLExcepti= on + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the tables available in the given catalog. + * Only table descriptions matching the catalog, schema, table + * name and type criteria are returned. They are ordered by + * TABLE_TYPE, TABLE_CAT, + * TABLE_SCHEM and TABLE_NAME. + *

+ * Each table description has the following columns: + *

    + *
  1. TABLE_CAT String =3D> table catalog (may be null) + *
  2. TABLE_SCHEM String =3D> table schema (may be null) + *
  3. TABLE_NAME String =3D> table name + *
  4. TABLE_TYPE String =3D> table type. Typical types are "TAB= LE", + * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", + * "LOCAL TEMPORARY", "ALIAS", "SYNONYM". + *
  5. REMARKS String =3D> explanatory comment on the table + *
  6. TYPE_CAT String =3D> the types catalog (may be null<= /code>) + *
  7. TYPE_SCHEM String =3D> the types schema (may be null= ) + *
  8. TYPE_NAME String =3D> type name (may be null) + *
  9. SELF_REFERENCING_COL_NAME String =3D> name of the designat= ed + * "identifier" column of a typed table (may be null) + *
  10. REF_GENERATION String =3D> specifies how values in + * SELF_REFERENCING_COL_NAME are created. Values are + * "SYSTEM", "USER", "DERIVED". (may be null) + *
+ *

+ *

Note: Some databases may not return information for + * all tables. + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves those= without a catalog; + * null means that the catalog name= should not be used to narrow + * the search + * @param schemaPattern a schema name pattern; must match the schema na= me + * as it is stored in the database; "" retrieves= those without a schema; + * null means that the schema name = should not be used to narrow + * the search + * @param tableNamePattern a table name pattern; must match the + * table name as it is stored in the database + * @param types a list of table types, which must be from the list of= table types + * returned from {@link #getTableTypes},to inclu= de; null returns + * all types + * @return ResultSet - each row is a table description + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + */ + public ResultSet getTables(String catalog, String schemaPattern, String = tableNamePattern, String[] types) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the schema names available in this database. The results + * are ordered by TABLE_CATALOG and + * TABLE_SCHEM. + *

+ *

The schema columns are: + *

    + *
  1. TABLE_SCHEM String =3D> schema name + *
  2. TABLE_CATALOG String =3D> catalog name (may be null<= /code>) + *
+ * + * @return a ResultSet object in which each row is a + * schema description + * @throws java.sql.SQLException if a database access error occurs + */ + public ResultSet getSchemas() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the catalog names available in this database. The results + * are ordered by catalog name. + *

+ *

The catalog column is: + *

    + *
  1. TABLE_CAT String =3D> catalog name + *
+ * + * @return a ResultSet object in which each row has a + * single String column that is a catalog name + * @throws java.sql.SQLException if a database access error occurs + */ + public ResultSet getCatalogs() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the table types available in this database. The results + * are ordered by table type. + *

+ *

The table type is: + *

    + *
  1. TABLE_TYPE String =3D> table type. Typical types are "TAB= LE", + * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", + * "LOCAL TEMPORARY", "ALIAS", "SYNONYM". + *
+ * + * @return a ResultSet object in which each row has a + * single String column that is a table type + * @throws java.sql.SQLException if a database access error occurs + */ + public ResultSet getTableTypes() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of table columns available in + * the specified catalog. + *

+ *

Only column descriptions matching the catalog, schema, table + * and column name criteria are returned. They are ordered by + * TABLE_CAT,TABLE_SCHEM, + * TABLE_NAME, and ORDINAL_POSITION. + *

+ *

Each column description has the following columns: + *

    + *
  1. TABLE_CAT String =3D> table catalog (may be null) + *
  2. TABLE_SCHEM String =3D> table schema (may be null) + *
  3. TABLE_NAME String =3D> table name + *
  4. COLUMN_NAME String =3D> column name + *
  5. DATA_TYPE int =3D> SQL type from java.sql.Types + *
  6. TYPE_NAME String =3D> Data source dependent type name, + * for a UDT the type name is fully qualified + *
  7. COLUMN_SIZE int =3D> column size. + *
  8. BUFFER_LENGTH is not used. + *
  9. DECIMAL_DIGITS int =3D> the number of fractional digits. N= ull is returned for data types where + * DECIMAL_DIGITS is not applicable. + *
  10. NUM_PREC_RADIX int =3D> Radix (typically either 10 or 2) + *
  11. NULLABLE int =3D> is NULL allowed. + *
      + *
    • columnNoNulls - might not allow NULL values + *
    • columnNullable - definitely allows NULL values + *
    • columnNullableUnknown - nullability unknown + *
    + *
  12. REMARKS String =3D> comment describing column (may be null) + *
  13. COLUMN_DEF String =3D> default value for the column, which= should be interpreted as a string when the value is enclosed in single quo= tes (may be null) + *
  14. SQL_DATA_TYPE int =3D> unused + *
  15. SQL_DATETIME_SUB int =3D> unused + *
  16. CHAR_OCTET_LENGTH int =3D> for char types the + * maximum number of bytes in the column + *
  17. ORDINAL_POSITION int =3D> index of column in table + * (starting at 1) + *
  18. IS_NULLABLE String =3D> ISO rules are used to determine t= he nullability for a column. + *
      + *
    • YES --- if the parameter can include NULLs + *
    • NO --- if the parameter cannot include NULLs + *
    • empty string --- if the nullability for the + * parameter is unknown + *
    + *
  19. SCOPE_CATLOG String =3D> catalog of table that is the scope + * of a reference attribute (null if DATA_TYPE isn't REF) + *
  20. SCOPE_SCHEMA String =3D> schema of table that is the scope + * of a reference attribute (null if the DATA_TYPE isn't RE= F) + *
  21. SCOPE_TABLE String =3D> table name that this the scope + * of a reference attribure (null if the DATA_TYPE isn't RE= F) + *
  22. SOURCE_DATA_TYPE short =3D> source type of a distinct type= or user-generated + * Ref type, SQL type from java.sql.Types (null if DATA_TYPE + * isn't DISTINCT or user-generated REF) + *
  23. IS_AUTOINCREMENT String =3D> Indicates whether this colum= n is auto incremented + *
      + *
    • YES --- if the column is auto incremented + *
    • NO --- if the column is not auto incremented + *
    • empty string --- if it cannot be determined whether the column = is auto incremented + * parameter is unknown + *
    + *
+ *

+ *

The COLUMN_SIZE column the specified column size for the given col= umn. + * For numeric data, this is the maximum precision. For character data,= this is the length in characters. + * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the + * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, + * this is the length in bytes. Null is returned for data types where the + * column size is not applicable. + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves thos= e without a catalog; + * null means that the catalog nam= e should not be used to narrow + * the search + * @param schemaPattern a schema name pattern; must match the schema n= ame + * as it is stored in the database; "" retrieve= s those without a schema; + * null means that the schema name= should not be used to narrow + * the search + * @param tableNamePattern a table name pattern; must match the + * table name as it is stored in the database + * @param columnNamePattern a column name pattern; must match the column + * name as it is stored in the database + * @return ResultSet - each row is a column description + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + */ + public ResultSet getColumns(String catalog, String schemaPattern, String= tableNamePattern, String columnNamePattern) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the access rights for a table's columns. + *

+ *

Only privileges matching the column name criteria are + * returned. They are ordered by COLUMN_NAME and PRIVILEGE. + *

+ *

Each privilige description has the following columns: + *

    + *
  1. TABLE_CAT String =3D> table catalog (may be null) + *
  2. TABLE_SCHEM String =3D> table schema (may be null) + *
  3. TABLE_NAME String =3D> table name + *
  4. COLUMN_NAME String =3D> column name + *
  5. GRANTOR String =3D> grantor of access (may be null) + *
  6. GRANTEE String =3D> grantee of access + *
  7. PRIVILEGE String =3D> name of access (SELECT, + * INSERT, UPDATE, REFRENCES, ...) + *
  8. IS_GRANTABLE String =3D> "YES" if grantee is permitted + * to grant to others; "NO" if not; null if unknown + *
+ * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves thos= e without a catalog; + * null means that the catalog nam= e should not be used to narrow + * the search + * @param schema a schema name; must match the schema name as it is + * stored in the database; "" retrieves those w= ithout a schema; + * null means that the schema name= should not be used to narrow + * the search + * @param table a table name; must match the table name as it is + * stored in the database + * @param columnNamePattern a column name pattern; must match the column + * name as it is stored in the database + * @return ResultSet - each row is a column privilege descr= iption + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + */ + public ResultSet getColumnPrivileges(String catalog, String schema, Stri= ng table, String columnNamePattern) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the access rights for each table available + * in a catalog. Note that a table privilege applies to one or + * more columns in the table. It would be wrong to assume that + * this privilege applies to all columns (this may be true for + * some systems but is not true for all.) + *

+ *

Only privileges matching the schema and table name + * criteria are returned. They are ordered by + * TABLE_CAT, + * TABLE_SCHEM, TABLE_NAME, + * and PRIVILEGE. + *

+ *

Each privilige description has the following columns: + *

    + *
  1. TABLE_CAT String =3D> table catalog (may be null) + *
  2. TABLE_SCHEM String =3D> table schema (may be null) + *
  3. TABLE_NAME String =3D> table name + *
  4. GRANTOR String =3D> grantor of access (may be null) + *
  5. GRANTEE String =3D> grantee of access + *
  6. PRIVILEGE String =3D> name of access (SELECT, + * INSERT, UPDATE, REFRENCES, ...) + *
  7. IS_GRANTABLE String =3D> "YES" if grantee is permitted + * to grant to others; "NO" if not; null if unknown + *
+ * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves those= without a catalog; + * null means that the catalog name= should not be used to narrow + * the search + * @param schemaPattern a schema name pattern; must match the schema na= me + * as it is stored in the database; "" retrieves= those without a schema; + * null means that the schema name = should not be used to narrow + * the search + * @param tableNamePattern a table name pattern; must match the + * table name as it is stored in the database + * @return ResultSet - each row is a table privilege descri= ption + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + */ + public ResultSet getTablePrivileges(String catalog, String schemaPattern= , String tableNamePattern) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of a table's optimal set of columns that + * uniquely identifies a row. They are ordered by SCOPE. + *

+ *

Each column description has the following columns: + *

    + *
  1. SCOPE short =3D> actual scope of result + *
      + *
    • bestRowTemporary - very temporary, while using row + *
    • bestRowTransaction - valid for remainder of current transaction + *
    • bestRowSession - valid for remainder of current session + *
    + *
  2. COLUMN_NAME String =3D> column name + *
  3. DATA_TYPE int =3D> SQL data type from java.sql.Types + *
  4. TYPE_NAME String =3D> Data source dependent type name, + * for a UDT the type name is fully qualified + *
  5. COLUMN_SIZE int =3D> precision + *
  6. BUFFER_LENGTH int =3D> not used + *
  7. DECIMAL_DIGITS short =3D> scale - Null is returned for da= ta types where + * DECIMAL_DIGITS is not applicable. + *
  8. PSEUDO_COLUMN short =3D> is this a pseudo column + * like an Oracle ROWID + *
      + *
    • bestRowUnknown - may or may not be pseudo column + *
    • bestRowNotPseudo - is NOT a pseudo column + *
    • bestRowPseudo - is a pseudo column + *
    + *
+ *

+ *

The COLUMN_SIZE column represents the specified column size for th= e given column. + * For numeric data, this is the maximum precision. For character data,= this is the length in characters. + * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the + * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, + * this is the length in bytes. Null is returned for data types where the + * column size is not applicable. + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves those without= a catalog; + * null means that the catalog name should = not be used to narrow + * the search + * @param schema a schema name; must match the schema name + * as it is stored in the database; "" retrieves those w= ithout a schema; + * null means that the schema name should n= ot be used to narrow + * the search + * @param table a table name; must match the table name as it is stored + * in the database + * @param scope the scope of interest; use same values as SCOPE + * @param nullable include columns that are nullable. + * @return ResultSet - each row is a column description + * @throws java.sql.SQLException if a database access error occurs + */ + public ResultSet getBestRowIdentifier(String catalog, String schema, Str= ing table, int scope, boolean nullable) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of a table's columns that are automatically + * updated when any value in a row is updated. They are + * unordered. + *

+ *

Each column description has the following columns: + *

    + *
  1. SCOPE short =3D> is not used + *
  2. COLUMN_NAME String =3D> column name + *
  3. DATA_TYPE int =3D> SQL data type from java.sql.Types= + *
  4. TYPE_NAME String =3D> Data source-dependent type name + *
  5. COLUMN_SIZE int =3D> precision + *
  6. BUFFER_LENGTH int =3D> length of column value in bytes + *
  7. DECIMAL_DIGITS short =3D> scale - Null is returned for da= ta types where + * DECIMAL_DIGITS is not applicable. + *
  8. PSEUDO_COLUMN short =3D> whether this is pseudo column + * like an Oracle ROWID + *
      + *
    • versionColumnUnknown - may or may not be pseudo column + *
    • versionColumnNotPseudo - is NOT a pseudo column + *
    • versionColumnPseudo - is a pseudo column + *
    + *
+ *

+ *

The COLUMN_SIZE column represents the specified column size for th= e given column. + * For numeric data, this is the maximum precision. For character data,= this is the length in characters. + * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the + * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, + * this is the length in bytes. Null is returned for data types where the + * column size is not applicable. + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves those without = a catalog; + * null means that the catalog name should n= ot be used to narrow + * the search + * @param schema a schema name; must match the schema name + * as it is stored in the database; "" retrieves those wi= thout a schema; + * null means that the schema name should no= t be used to narrow + * the search + * @param table a table name; must match the table name as it is stored + * in the database + * @return a ResultSet object in which each row is a + * column description + * @throws java.sql.SQLException if a database access error occurs + */ + public ResultSet getVersionColumns(String catalog, String schema, String= table) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the given table's primary key columns. Th= ey + * are ordered by COLUMN_NAME. + *

+ *

Each primary key column description has the following columns: + *

    + *
  1. TABLE_CAT String =3D> table catalog (may be null) + *
  2. TABLE_SCHEM String =3D> table schema (may be null) + *
  3. TABLE_NAME String =3D> table name + *
  4. COLUMN_NAME String =3D> column name + *
  5. KEY_SEQ short =3D> sequence number within primary key( a v= alue + * of 1 represents the first column of the primary key, a value of 2 wou= ld + * represent the second column within the primary key). + *
  6. PK_NAME String =3D> primary key name (may be null) + *
+ * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves those without = a catalog; + * null means that the catalog name should n= ot be used to narrow + * the search + * @param schema a schema name; must match the schema name + * as it is stored in the database; "" retrieves those wi= thout a schema; + * null means that the schema name should no= t be used to narrow + * the search + * @param table a table name; must match the table name as it is stored + * in the database + * @return ResultSet - each row is a primary key column des= cription + * @throws java.sql.SQLException if a database access error occurs + */ + public ResultSet getPrimaryKeys(String catalog, String schema, String ta= ble) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the primary key columns that are + * referenced by the given table's foreign key columns (the primary keys + * imported by a table). They are ordered by PKTABLE_CAT, + * PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ. + *

+ *

Each primary key column description has the following columns: + *

    + *
  1. PKTABLE_CAT String =3D> primary key table catalog + * being imported (may be null) + *
  2. PKTABLE_SCHEM String =3D> primary key table schema + * being imported (may be null) + *
  3. PKTABLE_NAME String =3D> primary key table name + * being imported + *
  4. PKCOLUMN_NAME String =3D> primary key column name + * being imported + *
  5. FKTABLE_CAT String =3D> foreign key table catalog (may be = null) + *
  6. FKTABLE_SCHEM String =3D> foreign key table schema (may be= null) + *
  7. FKTABLE_NAME String =3D> foreign key table name + *
  8. FKCOLUMN_NAME String =3D> foreign key column name + *
  9. KEY_SEQ short =3D> sequence number within a foreign key( a= value + * of 1 represents the first column of the foreign key, a value of 2 wou= ld + * represent the second column within the foreign key). + *
  10. UPDATE_RULE short =3D> What happens to a + * foreign key when the primary key is updated: + *
      + *
    • importedNoAction - do not allow update of primary + * key if it has been imported + *
    • importedKeyCascade - change imported key to agree + * with primary key update + *
    • importedKeySetNull - change imported key to NULL + * if its primary key has been updated + *
    • importedKeySetDefault - change imported key to default values + * if its primary key has been updated + *
    • importedKeyRestrict - same as importedKeyNoAction + * (for ODBC 2.x compatibility) + *
    + *
  11. DELETE_RULE short =3D> What happens to + * the foreign key when primary is deleted. + *
      + *
    • importedKeyNoAction - do not allow delete of primary + * key if it has been imported + *
    • importedKeyCascade - delete rows that import a deleted key + *
    • importedKeySetNull - change imported key to NULL if + * its primary key has been deleted + *
    • importedKeyRestrict - same as importedKeyNoAction + * (for ODBC 2.x compatibility) + *
    • importedKeySetDefault - change imported key to default if + * its primary key has been deleted + *
    + *
  12. FK_NAME String =3D> foreign key name (may be null) + *
  13. PK_NAME String =3D> primary key name (may be null) + *
  14. DEFERRABILITY short =3D> can the evaluation of foreign key + * constraints be deferred until commit + *
      + *
    • importedKeyInitiallyDeferred - see SQL92 for definition + *
    • importedKeyInitiallyImmediate - see SQL92 for definition + *
    • importedKeyNotDeferrable - see SQL92 for definition + *
    + *
+ * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves those without = a catalog; + * null means that the catalog name should n= ot be used to narrow + * the search + * @param schema a schema name; must match the schema name + * as it is stored in the database; "" retrieves those wi= thout a schema; + * null means that the schema name should no= t be used to narrow + * the search + * @param table a table name; must match the table name as it is stored + * in the database + * @return ResultSet - each row is a primary key column des= cription + * @throws java.sql.SQLException if a database access error occurs + * @see #getExportedKeys + */ + public ResultSet getImportedKeys(String catalog, String schema, String t= able) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the foreign key columns that reference the + * given table's primary key columns (the foreign keys exported by a + * table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM, + * FKTABLE_NAME, and KEY_SEQ. + *

+ *

Each foreign key column description has the following columns: + *

    + *
  1. PKTABLE_CAT String =3D> primary key table catalog (may be = null) + *
  2. PKTABLE_SCHEM String =3D> primary key table schema (may be= null) + *
  3. PKTABLE_NAME String =3D> primary key table name + *
  4. PKCOLUMN_NAME String =3D> primary key column name + *
  5. FKTABLE_CAT String =3D> foreign key table catalog (may be = null) + * being exported (may be null) + *
  6. FKTABLE_SCHEM String =3D> foreign key table schema (may be= null) + * being exported (may be null) + *
  7. FKTABLE_NAME String =3D> foreign key table name + * being exported + *
  8. FKCOLUMN_NAME String =3D> foreign key column name + * being exported + *
  9. KEY_SEQ short =3D> sequence number within foreign key( a v= alue + * of 1 represents the first column of the foreign key, a value of 2 wou= ld + * represent the second column within the foreign key). + *
  10. UPDATE_RULE short =3D> What happens to + * foreign key when primary is updated: + *
      + *
    • importedNoAction - do not allow update of primary + * key if it has been imported + *
    • importedKeyCascade - change imported key to agree + * with primary key update + *
    • importedKeySetNull - change imported key to NULL if + * its primary key has been updated + *
    • importedKeySetDefault - change imported key to default values + * if its primary key has been updated + *
    • importedKeyRestrict - same as importedKeyNoAction + * (for ODBC 2.x compatibility) + *
    + *
  11. DELETE_RULE short =3D> What happens to + * the foreign key when primary is deleted. + *
      + *
    • importedKeyNoAction - do not allow delete of primary + * key if it has been imported + *
    • importedKeyCascade - delete rows that import a deleted key + *
    • importedKeySetNull - change imported key to NULL if + * its primary key has been deleted + *
    • importedKeyRestrict - same as importedKeyNoAction + * (for ODBC 2.x compatibility) + *
    • importedKeySetDefault - change imported key to default if + * its primary key has been deleted + *
    + *
  12. FK_NAME String =3D> foreign key name (may be null) + *
  13. PK_NAME String =3D> primary key name (may be null) + *
  14. DEFERRABILITY short =3D> can the evaluation of foreign key + * constraints be deferred until commit + *
      + *
    • importedKeyInitiallyDeferred - see SQL92 for definition + *
    • importedKeyInitiallyImmediate - see SQL92 for definition + *
    • importedKeyNotDeferrable - see SQL92 for definition + *
    + *
+ * + * @param catalog a catalog name; must match the catalog name as it + * is stored in this database; "" retrieves those without= a catalog; + * null means that the catalog name should n= ot be used to narrow + * the search + * @param schema a schema name; must match the schema name + * as it is stored in the database; "" retrieves those wi= thout a schema; + * null means that the schema name should no= t be used to narrow + * the search + * @param table a table name; must match the table name as it is stored + * in this database + * @return a ResultSet object in which each row is a + * foreign key column description + * @throws java.sql.SQLException if a database access error occurs + * @see #getImportedKeys + */ + public ResultSet getExportedKeys(String catalog, String schema, String t= able) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the foreign key columns in the given forei= gn key + * table that reference the primary key or the columns representing a un= ique constraint of the parent table (could be the same or a different tabl= e). + * The number of columns returned from the parent table must match the n= umber of + * columns that make up the foreign key. They + * are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and + * KEY_SEQ. + *

+ *

Each foreign key column description has the following columns: + *

    + *
  1. PKTABLE_CAT String =3D> parent key table catalog (may be <= code>null) + *
  2. PKTABLE_SCHEM String =3D> parent key table schema (may be = null) + *
  3. PKTABLE_NAME String =3D> parent key table name + *
  4. PKCOLUMN_NAME String =3D> parent key column name + *
  5. FKTABLE_CAT String =3D> foreign key table catalog (may be = null) + * being exported (may be null) + *
  6. FKTABLE_SCHEM String =3D> foreign key table schema (may be= null) + * being exported (may be null) + *
  7. FKTABLE_NAME String =3D> foreign key table name + * being exported + *
  8. FKCOLUMN_NAME String =3D> foreign key column name + * being exported + *
  9. KEY_SEQ short =3D> sequence number within foreign key( a v= alue + * of 1 represents the first column of the foreign key, a value of 2 wou= ld + * represent the second column within the foreign key). + *
  10. UPDATE_RULE short =3D> What happens to + * foreign key when parent key is updated: + *
      + *
    • importedNoAction - do not allow update of parent + * key if it has been imported + *
    • importedKeyCascade - change imported key to agree + * with parent key update + *
    • importedKeySetNull - change imported key to NULL if + * its parent key has been updated + *
    • importedKeySetDefault - change imported key to default values + * if its parent key has been updated + *
    • importedKeyRestrict - same as importedKeyNoAction + * (for ODBC 2.x compatibility) + *
    + *
  11. DELETE_RULE short =3D> What happens to + * the foreign key when parent key is deleted. + *
      + *
    • importedKeyNoAction - do not allow delete of parent + * key if it has been imported + *
    • importedKeyCascade - delete rows that import a deleted key + *
    • importedKeySetNull - change imported key to NULL if + * its primary key has been deleted + *
    • importedKeyRestrict - same as importedKeyNoAction + * (for ODBC 2.x compatibility) + *
    • importedKeySetDefault - change imported key to default if + * its parent key has been deleted + *
    + *
  12. FK_NAME String =3D> foreign key name (may be null) + *
  13. PK_NAME String =3D> parent key name (may be null) + *
  14. DEFERRABILITY short =3D> can the evaluation of foreign key + * constraints be deferred until commit + *
      + *
    • importedKeyInitiallyDeferred - see SQL92 for definition + *
    • importedKeyInitiallyImmediate - see SQL92 for definition + *
    • importedKeyNotDeferrable - see SQL92 for definition + *
    + *
+ * + * @param parentCatalog a catalog name; must match the catalog name + * as it is stored in the database; "" retrieves t= hose without a + * catalog; null means drop catalog n= ame from the selection criteria + * @param parentSchema a schema name; must match the schema name as + * it is stored in the database; "" retrieves thos= e without a schema; + * null means drop schema name from t= he selection criteria + * @param parentTable the name of the table that exports the key; must = match + * the table name as it is stored in the database + * @param foreignCatalog a catalog name; must match the catalog name as + * it is stored in the database; "" retrieves thos= e without a + * catalog; null means drop catalog n= ame from the selection criteria + * @param foreignSchema a schema name; must match the schema name as it + * is stored in the database; "" retrieves those w= ithout a schema; + * null means drop schema name from t= he selection criteria + * @param foreignTable the name of the table that imports the key; must = match + * the table name as it is stored in the database + * @return ResultSet - each row is a foreign key column des= cription + * @throws java.sql.SQLException if a database access error occurs + * @see #getImportedKeys + */ + public ResultSet getCrossReference(String parentCatalog, String parentSc= hema, String parentTable, String foreignCatalog, String foreignSchema, Stri= ng foreignTable) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of all the data types supported by + * this database. They are ordered by DATA_TYPE and then by how + * closely the data type maps to the corresponding JDBC SQL type. + *

+ *

If the database supports SQL distinct types, then getTypeInfo() wi= ll return + * a single row with a TYPE_NAME of DISTINCT and a DATA_TYPE of Types.DI= STINCT. + * If the database supports SQL structured types, then getTypeInfo() wil= l return + * a single row with a TYPE_NAME of STRUCT and a DATA_TYPE of Types.STRU= CT. + *

+ *

If SQL distinct or structured types are supported, then informatio= n on the + * individual types may be obtained from the getUDTs() method. + *

+ *

+ *

+ *

Each type description has the following columns: + *

    + *
  1. TYPE_NAME String =3D> Type name + *
  2. DATA_TYPE int =3D> SQL data type from java.sql.Types + *
  3. PRECISION int =3D> maximum precision + *
  4. LITERAL_PREFIX String =3D> prefix used to quote a literal + * (may be null) + *
  5. LITERAL_SUFFIX String =3D> suffix used to quote a literal + * (may be null) + *
  6. CREATE_PARAMS String =3D> parameters used in creating + * the type (may be null) + *
  7. NULLABLE short =3D> can you use NULL for this type. + *
      + *
    • typeNoNulls - does not allow NULL values + *
    • typeNullable - allows NULL values + *
    • typeNullableUnknown - nullability unknown + *
    + *
  8. CASE_SENSITIVE boolean=3D> is it case sensitive. + *
  9. SEARCHABLE short =3D> can you use "WHERE" based on this ty= pe: + *
      + *
    • typePredNone - No support + *
    • typePredChar - Only supported with WHERE .. LIKE + *
    • typePredBasic - Supported except for WHERE .. LIKE + *
    • typeSearchable - Supported for all WHERE .. + *
    + *
  10. UNSIGNED_ATTRIBUTE boolean =3D> is it unsigned. + *
  11. FIXED_PREC_SCALE boolean =3D> can it be a money value. + *
  12. AUTO_INCREMENT boolean =3D> can it be used for an + * auto-increment value. + *
  13. LOCAL_TYPE_NAME String =3D> localized version of type name + * (may be null) + *
  14. MINIMUM_SCALE short =3D> minimum scale supported + *
  15. MAXIMUM_SCALE short =3D> maximum scale supported + *
  16. SQL_DATA_TYPE int =3D> unused + *
  17. SQL_DATETIME_SUB int =3D> unused + *
  18. NUM_PREC_RADIX int =3D> usually 2 or 10 + *
+ *

+ *

The PRECISION column represents the maximum column size that the s= erver supports for the given datatype. + * For numeric data, this is the maximum precision. For character data,= this is the length in characters. + * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the + * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, + * this is the length in bytes. Null is returned for data types where the + * column size is not applicable. + * + * @return a ResultSet object in which each row is an SQL + * type description + * @throws java.sql.SQLException if a database access error occurs + */ + public ResultSet getTypeInfo() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the given table's indices and statistics. = They are + * ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION. + *

+ *

Each index column description has the following columns: + *

    + *
  1. TABLE_CAT String =3D> table catalog (may be null) + *
  2. TABLE_SCHEM String =3D> table schema (may be null) + *
  3. TABLE_NAME String =3D> table name + *
  4. NON_UNIQUE boolean =3D> Can index values be non-unique. + * false when TYPE is tableIndexStatistic + *
  5. INDEX_QUALIFIER String =3D> index catalog (may be nu= ll); + * null when TYPE is tableIndexStatistic + *
  6. INDEX_NAME String =3D> index name; null when = TYPE is + * tableIndexStatistic + *
  7. TYPE short =3D> index type: + *
      + *
    • tableIndexStatistic - this identifies table statistics that are + * returned in conjuction with a table's index descriptions + *
    • tableIndexClustered - this is a clustered index + *
    • tableIndexHashed - this is a hashed index + *
    • tableIndexOther - this is some other style of index + *
    + *
  8. ORDINAL_POSITION short =3D> column sequence number + * within index; zero when TYPE is tableIndexStatistic + *
  9. COLUMN_NAME String =3D> column name; null whe= n TYPE is + * tableIndexStatistic + *
  10. ASC_OR_DESC String =3D> column sort sequence, "A" =3D> asc= ending, + * "D" =3D> descending, may be null if sort sequence is not= supported; + * null when TYPE is tableIndexStatistic + *
  11. CARDINALITY int =3D> When TYPE is tableIndexStatistic, then + * this is the number of rows in the table; otherwise, it is the + * number of unique values in the index. + *
  12. PAGES int =3D> When TYPE is tableIndexStatisic then + * this is the number of pages used for the table, otherwise it + * is the number of pages used for the current index. + *
  13. FILTER_CONDITION String =3D> Filter condition, if any. + * (may be null) + *
+ * + * @param catalog a catalog name; must match the catalog name as it + * is stored in this database; "" retrieves those wit= hout a catalog; + * null means that the catalog name shou= ld not be used to narrow + * the search + * @param schema a schema name; must match the schema name + * as it is stored in this database; "" retrieves tho= se without a schema; + * null means that the schema name shoul= d not be used to narrow + * the search + * @param table a table name; must match the table name as it is stored + * in this database + * @param unique when true, return only indices for unique values; + * when false, return indices regardless of whether u= nique or not + * @param approximate when true, result is allowed to reflect approximate + * or out of data values; when false, results are req= uested to be + * accurate + * @return ResultSet - each row is an index column descript= ion + * @throws java.sql.SQLException if a database access error occurs + */ + public ResultSet getIndexInfo(String catalog, String schema, String tabl= e, boolean unique, boolean approximate) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves whether this database supports the given result set type. + * + * @param type defined in java.sql.ResultSet + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @see java.sql.Connection + * @since 1.2 + */ + public boolean supportsResultSetType(int type) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports the given concurrency type + * in combination with the given result set type. + * + * @param type defined in java.sql.ResultSet + * @param concurrency type defined in java.sql.ResultSet + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @see java.sql.Connection + * @since 1.2 + */ + public boolean supportsResultSetConcurrency(int type, int concurrency) t= hrows SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether for the given type of ResultSet object, + * the result set's own updates are visible. + * + * @param type the ResultSet type; one of + * ResultSet.TYPE_FORWARD_ONLY, + * ResultSet.TYPE_SCROLL_INSENSITIVE, or + * ResultSet.TYPE_SCROLL_SENSITIVE + * @return true if updates are visible for the given result= set type; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public boolean ownUpdatesAreVisible(int type) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a result set's own deletes are visible. + * + * @param type the ResultSet type; one of + * ResultSet.TYPE_FORWARD_ONLY, + * ResultSet.TYPE_SCROLL_INSENSITIVE, or + * ResultSet.TYPE_SCROLL_SENSITIVE + * @return true if deletes are visible for the given result= set type; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public boolean ownDeletesAreVisible(int type) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a result set's own inserts are visible. + * + * @param type the ResultSet type; one of + * ResultSet.TYPE_FORWARD_ONLY, + * ResultSet.TYPE_SCROLL_INSENSITIVE, or + * ResultSet.TYPE_SCROLL_SENSITIVE + * @return true if inserts are visible for the given result= set type; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public boolean ownInsertsAreVisible(int type) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether updates made by others are visible. + * + * @param type the ResultSet type; one of + * ResultSet.TYPE_FORWARD_ONLY, + * ResultSet.TYPE_SCROLL_INSENSITIVE, or + * ResultSet.TYPE_SCROLL_SENSITIVE + * @return true if updates made by others + * are visible for the given result set type; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public boolean othersUpdatesAreVisible(int type) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether deletes made by others are visible. + * + * @param type the ResultSet type; one of + * ResultSet.TYPE_FORWARD_ONLY, + * ResultSet.TYPE_SCROLL_INSENSITIVE, or + * ResultSet.TYPE_SCROLL_SENSITIVE + * @return true if deletes made by others + * are visible for the given result set type; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public boolean othersDeletesAreVisible(int type) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether inserts made by others are visible. + * + * @param type the ResultSet type; one of + * ResultSet.TYPE_FORWARD_ONLY, + * ResultSet.TYPE_SCROLL_INSENSITIVE, or + * ResultSet.TYPE_SCROLL_SENSITIVE + * @return true if inserts made by others + * are visible for the given result set type; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public boolean othersInsertsAreVisible(int type) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether or not a visible row update can be detected by + * calling the method ResultSet.rowUpdated. + * + * @param type the ResultSet type; one of + * ResultSet.TYPE_FORWARD_ONLY, + * ResultSet.TYPE_SCROLL_INSENSITIVE, or + * ResultSet.TYPE_SCROLL_SENSITIVE + * @return true if changes are detected by the result set t= ype; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public boolean updatesAreDetected(int type) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether or not a visible row delete can be detected by + * calling the method ResultSet.rowDeleted. If the method + * deletesAreDetected returns false, it means = that + * deleted rows are removed from the result set. + * + * @param type the ResultSet type; one of + * ResultSet.TYPE_FORWARD_ONLY, + * ResultSet.TYPE_SCROLL_INSENSITIVE, or + * ResultSet.TYPE_SCROLL_SENSITIVE + * @return true if deletes are detected by the given result= set type; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public boolean deletesAreDetected(int type) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether or not a visible row insert can be detected + * by calling the method ResultSet.rowInserted. + * + * @param type the ResultSet type; one of + * ResultSet.TYPE_FORWARD_ONLY, + * ResultSet.TYPE_SCROLL_INSENSITIVE, or + * ResultSet.TYPE_SCROLL_SENSITIVE + * @return true if changes are detected by the specified re= sult + * set type; false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public boolean insertsAreDetected(int type) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports batch updates. + * + * @return true if this database supports batch upcates; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public boolean supportsBatchUpdates() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves a description of the user-defined types (UDTs) defined + * in a particular schema. Schema-specific UDTs may have type + * JAVA_OBJECT, STRUCT, + * or DISTINCT. + *

+ *

Only types matching the catalog, schema, type name and type + * criteria are returned. They are ordered by DATA_TYPE, + * TYPE_CAT, TYPE_SCHEM and + * TYPE_NAME. The type name parameter may be a fully-quali= fied + * name. In this case, the catalog and schemaPattern parameters are + * ignored. + *

+ *

Each type description has the following columns: + *

    + *
  1. TYPE_CAT String =3D> the type's catalog (may be null= ) + *
  2. TYPE_SCHEM String =3D> type's schema (may be null) + *
  3. TYPE_NAME String =3D> type name + *
  4. CLASS_NAME String =3D> Java class name + *
  5. DATA_TYPE int =3D> type value defined in java.sql.Types. + * One of JAVA_OBJECT, STRUCT, or DISTINCT + *
  6. REMARKS String =3D> explanatory comment on the type + *
  7. BASE_TYPE short =3D> type code of the source type of a + * DISTINCT type or the type that implements the user-generated + * reference type of the SELF_REFERENCING_COLUMN of a structured + * type as defined in java.sql.Types (null if DATA_TYPE is = not + * DISTINCT or not STRUCT with REFERENCE_GENERATION =3D USER_DEFINED) + *
+ *

+ *

Note: If the driver does not support UDTs, an empty + * result set is returned. + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves those = without a catalog; + * null means that the catalog name = should not be used to narrow + * the search + * @param schemaPattern a schema pattern name; must match the schema name + * as it is stored in the database; "" retrieves = those without a schema; + * null means that the schema name s= hould not be used to narrow + * the search + * @param typeNamePattern a type name pattern; must match the type name + * as it is stored in the database; may be a full= y qualified name + * @param types a list of user-defined types (JAVA_OBJECT, + * STRUCT, or DISTINCT) to include; null returns all types + * @return ResultSet object in which each row describes a U= DT + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + * @since 1.2 + */ + public ResultSet getUDTs(String catalog, String schemaPattern, String ty= peNamePattern, int[] types) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the connection that produced this metadata object. + *

+ * + * @return the connection that produced this metadata object + * @throws java.sql.SQLException if a database access error occurs + * @since 1.2 + */ + public Connection getConnection() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves whether this database supports savepoints. + * + * @return true if savepoints are supported; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.4 + */ + public boolean supportsSavepoints() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports named parameters to callable + * statements. + * + * @return true if named parameters are supported; + * false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.4 + */ + public boolean supportsNamedParameters() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether it is possible to have multiple ResultSet objects + * returned from a CallableStatement object + * simultaneously. + * + * @return true if a CallableStatement object + * can return multiple ResultSet objects + * simultaneously; false otherwise + * @throws java.sql.SQLException if a datanase access error occurs + * @since 1.4 + */ + public boolean supportsMultipleOpenResults() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether auto-generated keys can be retrieved after + * a statement has been executed + * + * @return true if auto-generated keys can be retrieved + * after a statement has executed; false otherwise + *

If true is returned, the JDBC driver must sup= port the + * returning of auto-generated keys for at least SQL INSERT stat= ements + *

+ * @throws java.sql.SQLException if a database access error occurs + * @since 1.4 + */ + public boolean supportsGetGeneratedKeys() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves a description of the user-defined type (UDT) hierarchies de= fined in a + * particular schema in this database. Only the immediate super type/ + * sub type relationship is modeled. + *

+ * Only supertype information for UDTs matching the catalog, + * schema, and type name is returned. The type name parameter + * may be a fully-qualified name. When the UDT name supplied is a + * fully-qualified name, the catalog and schemaPattern parameters are + * ignored. + *

+ * If a UDT does not have a direct super type, it is not listed here. + * A row of the ResultSet object returned by this method + * describes the designated UDT and a direct supertype. A row has the fo= llowing + * columns: + *

    + *
  1. TYPE_CAT String =3D> the UDT's catalog (may be null<= /code>) + *
  2. TYPE_SCHEM String =3D> UDT's schema (may be null) + *
  3. TYPE_NAME String =3D> type name of the UDT + *
  4. SUPERTYPE_CAT String =3D> the direct super type's catalog + * (may be null) + *
  5. SUPERTYPE_SCHEM String =3D> the direct super type's schema + * (may be null) + *
  6. SUPERTYPE_NAME String =3D> the direct super type's name + *
+ *

+ *

Note: If the driver does not support type hierarchies, an + * empty result set is returned. + * + * @param catalog a catalog name; "" retrieves those without a catalog; + * null means drop catalog name from= the selection criteria + * @param schemaPattern a schema name pattern; "" retrieves those + * without a schema + * @param typeNamePattern a UDT name pattern; may be a fully-qualified + * name + * @return a ResultSet object in which a row gives informat= ion + * about the designated UDT + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + * @since 1.4 + */ + public ResultSet getSuperTypes(String catalog, String schemaPattern, Str= ing typeNamePattern) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the table hierarchies defined in a particu= lar + * schema in this database. + *

+ *

Only supertable information for tables matching the catalog, schema + * and table name are returned. The table name parameter may be a fully- + * qualified name, in which case, the catalog and schemaPattern paramete= rs + * are ignored. If a table does not have a super table, it is not listed= here. + * Supertables have to be defined in the same catalog and schema as the + * sub tables. Therefore, the type description does not need to include + * this information for the supertable. + *

+ *

Each type description has the following columns: + *

    + *
  1. TABLE_CAT String =3D> the type's catalog (may be nul= l) + *
  2. TABLE_SCHEM String =3D> type's schema (may be null) + *
  3. TABLE_NAME String =3D> type name + *
  4. SUPERTABLE_NAME String =3D> the direct super type's name + *
+ *

+ *

Note: If the driver does not support type hierarchies, an + * empty result set is returned. + * + * @param catalog a catalog name; "" retrieves those without a catalo= g; + * null means drop catalog name fro= m the selection criteria + * @param schemaPattern a schema name pattern; "" retrieves those + * without a schema + * @param tableNamePattern a table name pattern; may be a fully-qualified + * name + * @return a ResultSet object in which each row is a type d= escription + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + * @since 1.4 + */ + public ResultSet getSuperTables(String catalog, String schemaPattern, St= ring tableNamePattern) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the given attribute of the given type + * for a user-defined type (UDT) that is available in the given schema + * and catalog. + *

+ * Descriptions are returned only for attributes of UDTs matching the + * catalog, schema, type, and attribute name criteria. They are ordered = by + * TYPE_CAT, TYPE_SCHEM, + * TYPE_NAME and ORDINAL_POSITION. This descri= ption + * does not contain inherited attributes. + *

+ * The ResultSet object that is returned has the following + * columns: + *

    + *
  1. TYPE_CAT String =3D> type catalog (may be null) + *
  2. TYPE_SCHEM String =3D> type schema (may be null) + *
  3. TYPE_NAME String =3D> type name + *
  4. ATTR_NAME String =3D> attribute name + *
  5. DATA_TYPE int =3D> attribute type SQL type from java.sql.T= ypes + *
  6. ATTR_TYPE_NAME String =3D> Data source dependent type name. + * For a UDT, the type name is fully qualified. For a REF, the type name= is + * fully qualified and represents the target type of the reference type. + *
  7. ATTR_SIZE int =3D> column size. For char or date + * types this is the maximum number of characters; for numeric or + * decimal types this is precision. + *
  8. DECIMAL_DIGITS int =3D> the number of fractional digits. N= ull is returned for data types where + * DECIMAL_DIGITS is not applicable. + *
  9. NUM_PREC_RADIX int =3D> Radix (typically either 10 or 2) + *
  10. NULLABLE int =3D> whether NULL is allowed + *
      + *
    • attributeNoNulls - might not allow NULL values + *
    • attributeNullable - definitely allows NULL values + *
    • attributeNullableUnknown - nullability unknown + *
    + *
  11. REMARKS String =3D> comment describing column (may be null) + *
  12. ATTR_DEF String =3D> default value (may be null) + *
  13. SQL_DATA_TYPE int =3D> unused + *
  14. SQL_DATETIME_SUB int =3D> unused + *
  15. CHAR_OCTET_LENGTH int =3D> for char types the + * maximum number of bytes in the column + *
  16. ORDINAL_POSITION int =3D> index of the attribute in the UDT + * (starting at 1) + *
  17. IS_NULLABLE String =3D> ISO rules are used to determine + * the nullability for a attribute. + *
      + *
    • YES --- if the attribute can include NULLs + *
    • NO --- if the attribute cannot include NULLs + *
    • empty string --- if the nullability for the + * attribute is unknown + *
    + *
  18. SCOPE_CATALOG String =3D> catalog of table that is the + * scope of a reference attribute (null if DATA_TYPE isn't = REF) + *
  19. SCOPE_SCHEMA String =3D> schema of table that is the + * scope of a reference attribute (null if DATA_TYPE isn't = REF) + *
  20. SCOPE_TABLE String =3D> table name that is the scope of a + * reference attribute (null if the DATA_TYPE isn't REF) + *
  21. SOURCE_DATA_TYPE short =3D> source type of a distinct type= or user-generated + * Ref type,SQL type from java.sql.Types (null if DATA_TYPE + * isn't DISTINCT or user-generated REF) + *
+ * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves t= hose without a catalog; + * null means that the catalog = name should not be used to narrow + * the search + * @param schemaPattern a schema name pattern; must match the schema = name + * as it is stored in the database; "" retri= eves those without a schema; + * null means that the schema n= ame should not be used to narrow + * the search + * @param typeNamePattern a type name pattern; must match the + * type name as it is stored in the database + * @param attributeNamePattern an attribute name pattern; must match the= attribute + * name as it is declared in the database + * @return a ResultSet object in which each row is an + * attribute description + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + * @since 1.4 + */ + public ResultSet getAttributes(String catalog, String schemaPattern, Str= ing typeNamePattern, String attributeNamePattern) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves whether this database supports the given result set holdabi= lity. + * + * @param holdability one of the following constants: + * ResultSet.HOLD_CURSORS_OVER_COMMIT or + * ResultSet.CLOSE_CURSORS_AT_COMMIT + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @see java.sql.Connection + * @since 1.4 + */ + public boolean supportsResultSetHoldability(int holdability) throws SQLE= xception + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves this database's default holdability for ResultSet + * objects. + * + * @return the default holdability; either + * ResultSet.HOLD_CURSORS_OVER_COMMIT or + * ResultSet.CLOSE_CURSORS_AT_COMMIT + * @throws java.sql.SQLException if a database access error occurs + * @since 1.4 + */ + public int getResultSetHoldability() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the major version number of the underlying database. + * + * @return the underlying database's major version + * @throws java.sql.SQLException if a database access error occurs + * @since 1.4 + */ + public int getDatabaseMajorVersion() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the minor version number of the underlying database. + * + * @return underlying database's minor version + * @throws java.sql.SQLException if a database access error occurs + * @since 1.4 + */ + public int getDatabaseMinorVersion() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Retrieves the major JDBC version number for this + * driver. + * + * @return JDBC version major number + * @throws java.sql.SQLException if a database access error occurs + * @since 1.4 + */ + public int getJDBCMajorVersion() throws SQLException + { + return jdbcVersion; + } + + /** + * Retrieves the minor JDBC version number for this + * driver. + * + * @return JDBC version minor number + * @throws java.sql.SQLException if a database access error occurs + * @since 1.4 + */ + public int getJDBCMinorVersion() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Indicates whether the SQLSTATE returned by SQLException.getSQLS= tate + * is X/Open (now known as Open Group) SQL CLI or SQL:2003. + * + * @return the type of SQLSTATE; one of: + * sqlStateXOpen or + * sqlStateSQL + * @throws java.sql.SQLException if a database access error occurs + * @since 1.4 + */ + public int getSQLStateType() throws SQLException + { + return 0; //To change body of implemented methods use File | Settings = | File Templates. + } + + /** + * Indicates whether updates made to a LOB are made on a copy or directly + * to the LOB. + * + * @return true if updates are made to a copy of the LOB; + * false if updates are made directly to the LOB + * @throws java.sql.SQLException if a database access error occurs + * @since 1.4 + */ + public boolean locatorsUpdateCopy() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether this database supports statement pooling. + * + * @return true if so; false otherwise + * @throws SQLExcpetion if a database access error occurs + * @since 1.4 + */ + public boolean supportsStatementPooling() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Indicates whether or not this data source supports the SQL ROWI= D type, + * and if so the lifetime for which a RowId object remains= valid. + *

+ * The returned int values have the following relationship: + *

+		 *     ROWID_UNSUPPORTED < ROWID_VALID_OTHER < ROWID_VALID_TRANSACTION
+		 *         < ROWID_VALID_SESSION < ROWID_VALID_FOREVER
+		 * 
+ * so conditional logic such as + *
+		 *     if (metadata.getRowIdLifetime() > DatabaseMetaData.ROWID_VALID_TR=
ANSACTION)
+		 * 
+ * can be used. Valid Forever means valid across all Sessions, and valid= for + * a Session means valid across all its contained Transactions. + * + * @return the status indicating the lifetime of a RowId + * @throws java.sql.SQLException if a database access error occurs + * @since 1.6 + */ + public RowIdLifetime getRowIdLifetime() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves the schema names available in this database. The results + * are ordered by TABLE_CATALOG and + * TABLE_SCHEM. + *

+ *

The schema columns are: + *

    + *
  1. TABLE_SCHEM String =3D> schema name + *
  2. TABLE_CATALOG String =3D> catalog name (may be null<= /code>) + *
+ * + * @param catalog a catalog name; must match the catalog name as it is= stored + * in the database;"" retrieves those without a cat= alog; null means catalog + * name should not be used to narrow down the searc= h. + * @param schemaPattern a schema name; must match the schema name as it = is + * stored in the database; null means + * schema name should not be used to narrow down th= e search. + * @return a ResultSet object in which each row is a + * schema description + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + * @since 1.6 + */ + public ResultSet getSchemas(String catalog, String schemaPattern) throws= SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves whether this database supports invoking user-defined or ven= dor functions + * using the stored procedure escape syntax. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.6 + */ + public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLExcept= ion + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves whether a SQLException while autoCommit is true inidcates + * that all open ResultSets are closed, even ones that are holdable. Wh= en a SQLException occurs while + * autocommit is true, it is vendor specific whether the JD= BC driver responds with a commit operation, a + * rollback operation, or by doing neither a commit nor a rollback. A p= otential result of this difference + * is in whether or not holdable ResultSets are closed. + * + * @return true if so; false otherwise + * @throws java.sql.SQLException if a database access error occurs + * @since 1.6 + */ + public boolean autoCommitFailureClosesAllResultSets() throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + + /** + * Retrieves a list of the client info properties + * that the driver supports. The result set contains the following colu= mns + *

+ *

    + *
  1. NAME String=3D> The name of the client info property
    + *
  2. MAX_LEN int=3D> The maximum length of the value for the pr= operty
    + *
  3. DEFAULT_VALUE String=3D> The default value of the property=
    + *
  4. DESCRIPTION String=3D> A description of the property. Thi= s will typically + * contain information as to where this property is + * stored in the database. + *
+ *

+ * The ResultSet is sorted by the NAME column + *

+ * + * @throws java.sql.SQLException if a database access error occurs + *

+ * @return A ResultSet object; each row is a supported clie= nt info + * property + *

+ * @since 1.6 + */ + public ResultSet getClientInfoProperties() throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the system and user functions available + * in the given catalog. + *

+ * Only system and user function descriptions matching the schema and + * function name criteria are returned. They are ordered by + * FUNCTION_CAT, FUNCTION_SCHEM, + * FUNCTION_NAME and + * SPECIFIC_ NAME. + *

+ *

Each function description has the the following columns: + *

    + *
  1. FUNCTION_CAT String =3D> function catalog (may be nu= ll) + *
  2. FUNCTION_SCHEM String =3D> function schema (may be n= ull) + *
  3. FUNCTION_NAME String =3D> function name. This is the name + * used to invoke the function + *
  4. REMARKS String =3D> explanatory comment on the function + *
  5. FUNCTION_TYPE short =3D> kind of function: + *
      + *
    • functionResultUnknown - Cannot determine if a return value + * or table will be returned + *
    • functionNoTable- Does not return a table + *
    • functionReturnsTable - Returns a table + *
    + *
  6. SPECIFIC_NAME String =3D> the name which uniquely identif= ies + * this function within its schema. This is a user specified, or DBMS + * generated, name that may be different then the FUNCTION_NAME + * for example with overload functions + *
+ *

+ * A user may not have permission to execute any of the functions that a= re + * returned by getFunctions + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves th= ose without a catalog; + * null means that the catalog n= ame should not be used to narrow + * the search + * @param schemaPattern a schema name pattern; must match the schema n= ame + * as it is stored in the database; "" retrie= ves those without a schema; + * null means that the schema na= me should not be used to narrow + * the search + * @param functionNamePattern a function name pattern; must match the + * function name as it is stored in the datab= ase + * @return ResultSet - each row is a function description + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + * @since 1.6 + */ + public ResultSet getFunctions(String catalog, String schemaPattern, Stri= ng functionNamePattern) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Retrieves a description of the given catalog's system or user + * function parameters and return type. + *

+ *

Only descriptions matching the schema, function and + * parameter name criteria are returned. They are ordered by + * FUNCTION_CAT, FUNCTION_SCHEM, + * FUNCTION_NAME and + * SPECIFIC_ NAME. Within this, the return value, + * if any, is first. Next are the parameter descriptions in call + * order. The column descriptions follow in column number order. + *

+ *

Each row in the ResultSet + * is a parameter description, column description or + * return type description with the following fields: + *

    + *
  1. FUNCTION_CAT String =3D> function catalog (may be nu= ll) + *
  2. FUNCTION_SCHEM String =3D> function schema (may be n= ull) + *
  3. FUNCTION_NAME String =3D> function name. This is the name + * used to invoke the function + *
  4. COLUMN_NAME String =3D> column/parameter name + *
  5. COLUMN_TYPE Short =3D> kind of column/parameter: + *
      + *
    • functionColumnUnknown - nobody knows + *
    • functionColumnIn - IN parameter + *
    • functionColumnInOut - INOUT parameter + *
    • functionColumnOut - OUT parameter + *
    • functionColumnReturn - function return value + *
    • functionColumnResult - Indicates that the parameter or column + * is a column in the ResultSet + *
    + *
  6. DATA_TYPE int =3D> SQL type from java.sql.Types + *
  7. TYPE_NAME String =3D> SQL type name, for a UDT type the + * type name is fully qualified + *
  8. PRECISION int =3D> precision + *
  9. LENGTH int =3D> length in bytes of data + *
  10. SCALE short =3D> scale - null is returned for data types = where + * SCALE is not applicable. + *
  11. RADIX short =3D> radix + *
  12. NULLABLE short =3D> can it contain NULL. + *
      + *
    • functionNoNulls - does not allow NULL values + *
    • functionNullable - allows NULL values + *
    • functionNullableUnknown - nullability unknown + *
    + *
  13. REMARKS String =3D> comment describing column/parameter + *
  14. CHAR_OCTET_LENGTH int =3D> the maximum length of binary + * and character based parameters or columns. For any other datatype th= e returned value + * is a NULL + *
  15. ORDINAL_POSITION int =3D> the ordinal position, starting + * from 1, for the input and output parameters. A value of 0 + * is returned if this row describes the function's return value. + * For result set columns, it is the + * ordinal position of the column in the result set starting from 1. + *
  16. IS_NULLABLE String =3D> ISO rules are used to determine + * the nullability for a parameter or column. + *
      + *
    • YES --- if the parameter or column can include NULLs + *
    • NO --- if the parameter or column cannot include NUL= Ls + *
    • empty string --- if the nullability for the + * parameter or column is unknown + *
    + *
  17. SPECIFIC_NAME String =3D> the name which uniquely identif= ies + * this function within its schema. This is a user specified, or DBMS + * generated, name that may be different then the FUNCTION_NAME + * for example with overload functions + *
+ *

+ *

The PRECISION column represents the specified column size for the = given + * parameter or column. + * For numeric data, this is the maximum precision. For character data,= this is the length in characters. + * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the + * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, + * this is the length in bytes. Null is returned for data types where the + * column size is not applicable. + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves th= ose without a catalog; + * null means that the catalog n= ame should not be used to narrow + * the search + * @param schemaPattern a schema name pattern; must match the schema n= ame + * as it is stored in the database; "" retrie= ves those without a schema; + * null means that the schema na= me should not be used to narrow + * the search + * @param functionNamePattern a procedure name pattern; must match the + * function name as it is stored in the datab= ase + * @param columnNamePattern a parameter name pattern; must match the + * parameter or column name as it is stored i= n the database + * @return ResultSet - each row describes a + * user function parameter, column or return type + * @throws java.sql.SQLException if a database access error occurs + * @see #getSearchStringEscape + * @since 1.6 + */ + public ResultSet getFunctionColumns(String catalog, String schemaPattern= , String functionNamePattern, String columnNamePattern) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Returns an object that implements the given interface to allow access= to + * non-standard methods, or standard methods not exposed by the proxy. + *

+ * If the receiver implements the interface then the result is the recei= ver + * or a proxy for the receiver. If the receiver is a wrapper + * and the wrapped object implements the interface then the result is the + * wrapped object or a proxy for the wrapped object. Otherwise return the + * the result of calling unwrap recursively on the wrapped = object + * or a proxy for that result. If the receiver is not a + * wrapper and does not implement the interface, then an SQLExcept= ion is thrown. + * + * @param iface A Class defining an interface that the result must imple= ment. + * @return an object that implements the interface. May be a proxy for t= he actual implementing object. + * @throws java.sql.SQLException If no object found that implements the = interface + * @since 1.6 + */ + public T unwrap(Class iface) throws SQLException + { + return null; //To change body of implemented methods use File | Settin= gs | File Templates. + } + + /** + * Returns true if this either implements the interface argument or is d= irectly or indirectly a wrapper + * for an object that does. Returns false otherwise. If this implements = the interface then return true, + * else if this is a wrapper then return the result of recursively calli= ng isWrapperFor on the wrapped + * object. If this does not implement the interface and is not a wrapper= , return false. + * This method should be implemented as a low-cost operation compared to= unwrap so that + * callers can use this method to avoid expensive unwrap ca= lls that may fail. If this method + * returns true then calling unwrap with the same argument = should succeed. + * + * @param iface a Class defining an interface. + * @return true if this implements the interface or directly or indirect= ly wraps an object that does. + * @throws java.sql.SQLException if an error occurs while determining wh= ether this is a wrapper + * for an object with the given interface. + * @since 1.6 + */ + public boolean isWrapperFor(Class iface) throws SQLException + { + return false; //To change body of implemented methods use File | Setti= ngs | File Templates. + } + } + } --===============4593341493774752406==-- From hibernate-commits at lists.jboss.org Fri Nov 13 13:12:54 2009 Content-Type: multipart/mixed; boundary="===============7481940074238747519==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17976 - in core/trunk/cache-infinispan: src/main/java/org/hibernate/cache/infinispan and 17 other directories. Date: Fri, 13 Nov 2009 13:12:53 -0500 Message-ID: <200911131812.nADICrvr032081@svn01.web.mwc.hst.phx2.redhat.com> --===============7481940074238747519== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: galder.zamarreno(a)jboss.com Date: 2009-11-13 13:12:53 -0500 (Fri, 13 Nov 2009) New Revision: 17976 Added: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /util/AddressAdapter.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /util/AddressAdapterImpl.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /util/CacheAdapter.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /util/CacheAdapterImpl.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /util/FlagAdapter.java Modified: core/trunk/cache-infinispan/pom.xml core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /InfinispanRegionFactory.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /access/TransactionalAccessDelegate.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /collection/CollectionRegionImpl.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /collection/TransactionalAccess.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /entity/EntityRegionImpl.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /entity/TransactionalAccess.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /impl/BaseGeneralDataRegion.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /impl/BaseRegion.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /impl/BaseTransactionalDataRegion.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /query/QueryResultsRegionImpl.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /timestamp/TimestampsRegionImpl.java core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan= /util/CacheHelper.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/AbstractGeneralDataRegionTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/AbstractNonFunctionalTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/AbstractRegionImplTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/InfinispanRegionFactoryTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/entity/AbstractEntityRegionAccessStrategyTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/entity/EntityRegionImplTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/functional/AbstractFunctionalTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/functional/BasicTransactionalTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/functional/bulk/BulkOperationsTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/functional/classloader/CacheAccessListener.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/functional/classloader/IsolatedClassLoaderTest.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/functional/cluster/AbstractDualNodeTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/functional/cluster/EntityCollectionInvalidationTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/query/QueryRegionImplTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/timestamp/TimestampsRegionImplTestCase.java core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/tm/XaTransactionImpl.java Log: [HHH-4519] (Hibernate/Infinispan integration doesn't property handle Entity= /CollectionRegionAccessStrategy evictAll) Fixed and got provider to work wi= th forthcoming Infinispan 4.0.0.CR2 which has been just tagged but the mave= n repo has not been updated yet. Modified: core/trunk/cache-infinispan/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/pom.xml 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/pom.xml 2009-11-13 18:12:53 UTC (rev 17976) @@ -17,7 +17,7 @@ Integration of Hibernate with Infinispan = - 4.0.0.BETA2 + 4.0.0-SNAPSHOT 1.8.0.2 2.2 3.4.GA Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/InfinispanRegionFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/InfinispanRegionFactory.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/InfinispanRegionFactory.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -24,6 +24,8 @@ import org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl; import org.hibernate.cache.infinispan.timestamp.TimestampTypeOverrides; import org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup; +import org.hibernate.cache.infinispan.util.CacheAdapter; +import org.hibernate.cache.infinispan.util.CacheAdapterImpl; import org.hibernate.cfg.Settings; import org.hibernate.util.PropertiesHelper; import org.infinispan.Cache; @@ -154,14 +156,20 @@ public CollectionRegion buildCollectionRegion(String regionName, Proper= ties properties, CacheDataDescription metadata) throws CacheException { log.debug("Building collection cache region [" + regionName + "]"); Cache cache =3D getCache(regionName, COLLECTION_KEY, properties); - return new CollectionRegionImpl(cache, regionName, metadata, transac= tionManager); + CacheAdapter cacheAdapter =3D CacheAdapterImpl.newInstance(cache); + CollectionRegionImpl region =3D new CollectionRegionImpl(cacheAdapte= r, regionName, metadata, transactionManager); + region.start(); + return region; } = /** {@inheritDoc} */ public EntityRegion buildEntityRegion(String regionName, Properties pro= perties, CacheDataDescription metadata) throws CacheException { if (log.isDebugEnabled()) log.debug("Building entity cache region ["= + regionName + "]"); Cache cache =3D getCache(regionName, ENTITY_KEY, properties); - return new EntityRegionImpl(cache, regionName, metadata, transaction= Manager); + CacheAdapter cacheAdapter =3D CacheAdapterImpl.newInstance(cache); + EntityRegionImpl region =3D new EntityRegionImpl(cacheAdapter, regio= nName, metadata, transactionManager); + region.start(); + return region; } = /** @@ -171,7 +179,10 @@ throws CacheException { log.debug("Building query results cache region [" + regionName + "]"= ); String cacheName =3D typeOverrides.get(QUERY_KEY).getCacheName(); - return new QueryResultsRegionImpl(manager.getCache(cacheName), regio= nName, properties, transactionManager); + CacheAdapter cacheAdapter =3D CacheAdapterImpl.newInstance(manager.g= etCache(cacheName)); + QueryResultsRegionImpl region =3D new QueryResultsRegionImpl(cacheAd= apter, regionName, properties, transactionManager); + region.start(); + return region; } = /** @@ -181,7 +192,10 @@ throws CacheException { log.debug("Building timestamps cache region [" + regionName + "]"); String cacheName =3D typeOverrides.get(TIMESTAMPS_KEY).getCacheName(= ); - return new TimestampsRegionImpl(manager.getCache(cacheName), regionN= ame, transactionManager); + CacheAdapter cacheAdapter =3D CacheAdapterImpl.newInstance(manager.g= etCache(cacheName)); + TimestampsRegionImpl region =3D new TimestampsRegionImpl(cacheAdapte= r, regionName, transactionManager); + region.start(); + return region; } = /** Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/access/TransactionalAccessDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/access/TransactionalAccessDelegate.java 2009-11-13 17:40:36 UTC (rev 1797= 5) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/access/TransactionalAccessDelegate.java 2009-11-13 18:12:53 UTC (rev 1797= 6) @@ -23,11 +23,15 @@ */ package org.hibernate.cache.infinispan.access; = +import javax.transaction.Transaction; + import org.hibernate.cache.CacheException; import org.hibernate.cache.access.CollectionRegionAccessStrategy; import org.hibernate.cache.access.EntityRegionAccessStrategy; import org.hibernate.cache.access.SoftLock; -import org.infinispan.Cache; +import org.hibernate.cache.infinispan.impl.BaseRegion; +import org.hibernate.cache.infinispan.util.CacheAdapter; +import org.hibernate.cache.infinispan.util.CacheHelper; = /** * Defines the strategy for transactional access to entity or collection d= ata in a Infinispan instance. @@ -41,18 +45,24 @@ */ public class TransactionalAccessDelegate { = - protected final Cache cache; + protected final CacheAdapter cacheAdapter; + protected final BaseRegion region; = - public TransactionalAccessDelegate(Cache cache) { - this.cache =3D cache; + public TransactionalAccessDelegate(BaseRegion region) { + this.region =3D region; + this.cacheAdapter =3D region.getCacheAdapter(); } = public Object get(Object key, long txTimestamp) throws CacheException { - return cache.get(key); + if (!region.checkValid()) = + return null; + return cacheAdapter.get(key); } = public boolean putFromLoad(Object key, Object value, long txTimestamp, = Object version) throws CacheException { - cache.putForExternalRead(key, value); + if (!region.checkValid()) + return false; + cacheAdapter.putForExternalRead(key, value); return true; } = @@ -76,7 +86,9 @@ } = public boolean insert(Object key, Object value, Object version) throws = CacheException { - cache.put(key, value); + if (!region.checkValid()) + return false; + cacheAdapter.put(key, value); return true; } = @@ -85,7 +97,10 @@ } = public boolean update(Object key, Object value, Object currentVersion, = Object previousVersion) throws CacheException { - cache.put(key, value); + // We update whether or not the region is valid. Other nodes + // may have already restored the region so they need to + // be informed of the change. + cacheAdapter.put(key, value); return true; } = @@ -95,18 +110,26 @@ } = public void remove(Object key) throws CacheException { - cache.remove(key); + // We update whether or not the region is valid. Other nodes + // may have already restored the region so they need to + // be informed of the change. + cacheAdapter.remove(key); } = public void removeAll() throws CacheException { - cache.clear(); + cacheAdapter.clear(); } = - public void evictAll() throws CacheException { - evictOrRemoveAll(); + public void evict(Object key) throws CacheException { + cacheAdapter.remove(key); } = - private void evictOrRemoveAll() throws CacheException { - cache.clear(); + public void evictAll() throws CacheException { + Transaction tx =3D region.suspend(); + try { + CacheHelper.sendEvictAllNotification(cacheAdapter, region.getAddr= ess()); + } finally { + region.resume(tx); + } } } Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/collection/CollectionRegionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/collection/CollectionRegionImpl.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/collection/CollectionRegionImpl.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -8,17 +8,19 @@ import org.hibernate.cache.access.AccessType; import org.hibernate.cache.access.CollectionRegionAccessStrategy; import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion; -import org.infinispan.Cache; +import org.hibernate.cache.infinispan.util.CacheAdapter; +import org.infinispan.notifications.Listener; = /** * @author Chris Bredesen * @author Galder Zamarre=C3=B1o * @since 3.5 */ +(a)Listener public class CollectionRegionImpl extends BaseTransactionalDataRegion impl= ements CollectionRegion { = - public CollectionRegionImpl(Cache cache, String name, CacheDataDescript= ion metadata, TransactionManager transactionManager) { - super(cache, name, metadata, transactionManager); + public CollectionRegionImpl(CacheAdapter cacheAdapter, String name, Cac= heDataDescription metadata, TransactionManager transactionManager) { + super(cacheAdapter, name, metadata, transactionManager); } = public CollectionRegionAccessStrategy buildAccessStrategy(AccessType ac= cessType) throws CacheException { Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/collection/TransactionalAccess.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/collection/TransactionalAccess.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/collection/TransactionalAccess.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -21,11 +21,11 @@ = TransactionalAccess(CollectionRegionImpl region) { this.region =3D region; - this.delegate =3D new TransactionalAccessDelegate(region.getCache()); + this.delegate =3D new TransactionalAccessDelegate(region); } = public void evict(Object key) throws CacheException { - delegate.remove(key); + delegate.evict(key); } = public void evictAll() throws CacheException { Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/entity/EntityRegionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/entity/EntityRegionImpl.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/entity/EntityRegionImpl.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -8,17 +8,19 @@ import org.hibernate.cache.access.AccessType; import org.hibernate.cache.access.EntityRegionAccessStrategy; import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion; -import org.infinispan.Cache; +import org.hibernate.cache.infinispan.util.CacheAdapter; +import org.infinispan.notifications.Listener; = /** * @author Chris Bredesen * @author Galder Zamarre=C3=B1o * @since 3.5 */ +(a)Listener public class EntityRegionImpl extends BaseTransactionalDataRegion implemen= ts EntityRegion { = - public EntityRegionImpl(Cache cache, String name, CacheDataDescription = metadata, TransactionManager transactionManager) { - super(cache, name, metadata, transactionManager); + public EntityRegionImpl(CacheAdapter cacheAdapter, String name, CacheDa= taDescription metadata, TransactionManager transactionManager) { + super(cacheAdapter, name, metadata, transactionManager); } = public EntityRegionAccessStrategy buildAccessStrategy(AccessType access= Type) throws CacheException { Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/entity/TransactionalAccess.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/entity/TransactionalAccess.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/entity/TransactionalAccess.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -21,11 +21,11 @@ = TransactionalAccess(EntityRegionImpl region) { this.region =3D region; - this.delegate =3D new TransactionalAccessDelegate(region.getCache()); + this.delegate =3D new TransactionalAccessDelegate(region); } = public void evict(Object key) throws CacheException { - delegate.remove(key); + delegate.evict(key); } = public void evictAll() throws CacheException { @@ -41,8 +41,7 @@ } = public boolean insert(Object key, Object value, Object version) throws = CacheException { - region.getCache().put(key, value); - return true; // TODO this is suspect + return delegate.insert(key, value, version); } = public boolean putFromLoad(Object key, Object value, long txTimestamp, = Object version) throws CacheException { Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/impl/BaseGeneralDataRegion.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/impl/BaseGeneralDataRegion.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/impl/BaseGeneralDataRegion.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -4,7 +4,7 @@ = import org.hibernate.cache.CacheException; import org.hibernate.cache.GeneralDataRegion; -import org.infinispan.Cache; +import org.hibernate.cache.infinispan.util.CacheAdapter; = /** * Support for Infinispan {@link GeneralDataRegion} implementors. @@ -15,24 +15,24 @@ */ public abstract class BaseGeneralDataRegion extends BaseRegion implements = GeneralDataRegion { = - public BaseGeneralDataRegion(Cache cache, String name, TransactionManag= er transactionManager) { - super(cache, name, transactionManager); + public BaseGeneralDataRegion(CacheAdapter cacheAdapter, String name, Tr= ansactionManager transactionManager) { + super(cacheAdapter, name, transactionManager); } = public void evict(Object key) throws CacheException { - getCache().evict(key); + cacheAdapter.evict(key); } = public void evictAll() throws CacheException { - getCache().clear(); + cacheAdapter.clear(); } = public Object get(Object key) throws CacheException { - return getCache().get(key); + return cacheAdapter.get(key); } = public void put(Object key, Object value) throws CacheException { - getCache().put(key, value); + cacheAdapter.put(key, value); } = } \ No newline at end of file Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/impl/BaseRegion.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/impl/BaseRegion.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/impl/BaseRegion.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -1,6 +1,11 @@ package org.hibernate.cache.infinispan.impl; = +import java.util.Collections; +import java.util.HashSet; +import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; = import javax.transaction.SystemException; import javax.transaction.Transaction; @@ -8,9 +13,19 @@ = import org.hibernate.cache.CacheException; import org.hibernate.cache.Region; +import org.hibernate.cache.infinispan.util.AddressAdapter; +import org.hibernate.cache.infinispan.util.AddressAdapterImpl; +import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.cache.infinispan.util.CacheHelper; -import org.infinispan.Cache; -import org.infinispan.context.Flag; +import org.hibernate.cache.infinispan.util.FlagAdapter; +import org.infinispan.notifications.cachelistener.annotation.CacheEntryInv= alidated; +import org.infinispan.notifications.cachelistener.annotation.CacheEntryMod= ified; +import org.infinispan.notifications.cachelistener.event.CacheEntryInvalida= tedEvent; +import org.infinispan.notifications.cachelistener.event.CacheEntryModified= Event; +import org.infinispan.notifications.cachemanagerlistener.annotation.ViewCh= anged; +import org.infinispan.notifications.cachemanagerlistener.event.ViewChanged= Event; +import org.infinispan.util.logging.Log; +import org.infinispan.util.logging.LogFactory; = /** * Support for Infinispan {@link Region}s. Handles common "utility" method= s for an underlying named @@ -22,26 +37,69 @@ * @since 3.5 */ public abstract class BaseRegion implements Region { - private final Cache cache; + private enum InvalidateState { INVALID, CLEARING, VALID }; + private static final Log log =3D LogFactory.getLog(BaseRegion.class); private final String name; + protected final CacheAdapter cacheAdapter; + protected final AddressAdapter address; + protected final Set currentView =3D new HashSet(); protected final TransactionManager transactionManager; + protected final boolean replication; + protected final Object invalidationMutex =3D new Object(); + protected final AtomicReference invalidateState =3D ne= w AtomicReference(InvalidateState.VALID); = - public BaseRegion(Cache cache, String name, TransactionManager transact= ionManager) { - this.cache =3D cache; + public BaseRegion(CacheAdapter cacheAdapter, String name, TransactionMa= nager transactionManager) { + this.cacheAdapter =3D cacheAdapter; this.name =3D name; this.transactionManager =3D transactionManager; + this.replication =3D cacheAdapter.isClusteredReplication(); + this.address =3D this.cacheAdapter.getAddress(); + this.cacheAdapter.addListener(this); } = - public Cache getCache() { - return cache; + public void start() { + if (address !=3D null) { + synchronized (currentView) { + List view =3D cacheAdapter.getMembers(); + if (view !=3D null) { + currentView.addAll(view); + establishInternalNodes(); + } + } + } } = + /** + * Calls to this method must be done from synchronized (currentView) bl= ocks only!! + */ + private void establishInternalNodes() { + Transaction tx =3D suspend(); + try { + for (AddressAdapter member : currentView) { + CacheHelper.initInternalEvict(cacheAdapter, member); + } + } finally { + resume(tx); + } + } + public String getName() { return name; } = + public CacheAdapter getCacheAdapter() { + return cacheAdapter; + } + public long getElementCountInMemory() { - return cache.size(); + if (checkValid()) { + Set keySet =3D cacheAdapter.keySet(); + int size =3D cacheAdapter.size(); + if (CacheHelper.containsEvictAllNotification(keySet, address)) + size--; + return size; + } + return 0; } = /** @@ -71,17 +129,64 @@ } = public Map toMap() { - return cache; + if (checkValid()) { + Map map =3D cacheAdapter.toMap(); + Set keys =3D map.keySet(); + for (Object key : keys) { + if (CacheHelper.isEvictAllNotification(key)) { + map.remove(key); + } + } + return map; + } + return Collections.EMPTY_MAP; } = public void destroy() throws CacheException { - cache.clear(); + try { + cacheAdapter.clear(); + } finally { + cacheAdapter.removeListener(this); + } } = public boolean contains(Object key) { - return CacheHelper.containsKey(cache, key, Flag.ZERO_LOCK_ACQUISITIO= N_TIMEOUT); + if (!checkValid()) + return false; + // Reads are non-blocking in Infinispan, so not sure of the necessit= y of passing ZERO_LOCK_ACQUISITION_TIMEOUT + return cacheAdapter.withFlags(FlagAdapter.ZERO_LOCK_ACQUISITION_TIME= OUT).containsKey(key); } - = + + public AddressAdapter getAddress() { + return address; + } + + public boolean checkValid() { + boolean valid =3D invalidateState.get() =3D=3D InvalidateState.VALID; + if (!valid) { + synchronized (invalidationMutex) { + if (invalidateState.compareAndSet(InvalidateState.INVALID, Inv= alidateState.CLEARING)) { + Transaction tx =3D suspend(); + try { + cacheAdapter.withFlags(FlagAdapter.CACHE_MODE_LOCAL, Fla= gAdapter.ZERO_LOCK_ACQUISITION_TIMEOUT).clear(); + invalidateState.compareAndSet(InvalidateState.CLEARING, = InvalidateState.VALID); + } + catch (Exception e) { + if (log.isTraceEnabled()) { + log.trace("Could not invalidate region: " + e.getLoca= lizedMessage()); + } + } + finally { + resume(tx); + } + } + } + valid =3D invalidateState.get() =3D=3D InvalidateState.VALID; + } + = + return valid; + } + /** * Performs a JBoss Cache get(Fqn, Object) after first * {@link #suspend suspending any ongoing transaction}. Wraps any excep= tion @@ -93,13 +198,13 @@ * @return The retrieved object * @throws CacheException issue managing transaction or talking to ca= che */ - protected Object suspendAndGet(Object key, Flag opt, boolean suppressTi= meout) throws CacheException { + protected Object suspendAndGet(Object key, FlagAdapter opt, boolean sup= pressTimeout) throws CacheException { Transaction tx =3D suspend(); try { if (suppressTimeout) - return CacheHelper.getAllowingTimeout(cache, key); + return cacheAdapter.getAllowingTimeout(key); else - return CacheHelper.get(cache, key); + return cacheAdapter.get(key); } finally { resume(tx); } @@ -111,7 +216,7 @@ * @return the transaction that was suspended, or null if * there wasn't one */ - protected Transaction suspend() { + public Transaction suspend() { Transaction tx =3D null; try { if (transactionManager !=3D null) { @@ -122,14 +227,14 @@ } return tx; } - = + /** * Tell the TransactionManager to resume the given transaction * = * @param tx * the transaction to suspend. May be null. */ - protected void resume(Transaction tx) { + public void resume(Transaction tx) { try { if (tx !=3D null) transactionManager.resume(tx); @@ -138,4 +243,44 @@ } } = + @CacheEntryModified + public void entryModified(CacheEntryModifiedEvent event) { + handleEvictAllModification(event); + } + + protected boolean handleEvictAllModification(CacheEntryModifiedEvent ev= ent) { + if (!event.isPre() && (replication || event.isOriginLocal()) && Cach= eHelper.isEvictAllNotification(event.getKey(), event.getValue())) { + if (log.isTraceEnabled()) log.trace("Set invalid state because ma= rker cache entry was put: {0}", event); + invalidateState.set(InvalidateState.INVALID); + return true; + } + return false; + } + + @CacheEntryInvalidated + public void entryInvalidated(CacheEntryInvalidatedEvent event) { + if (log.isTraceEnabled()) log.trace("Cache entry invalidated: {0}", = event); + handleEvictAllInvalidation(event); + } + + protected boolean handleEvictAllInvalidation(CacheEntryInvalidatedEvent= event) { + if (!event.isPre() && CacheHelper.isEvictAllNotification(event.getKe= y())) { + if (log.isTraceEnabled()) log.trace("Set invalid state because ma= rker cache entry was invalidated: {0}", event); + invalidateState.set(InvalidateState.INVALID); + return true; + } + return false; + } + + @ViewChanged + public void viewChanged(ViewChangedEvent event) { + synchronized (currentView) { + List view =3D AddressAdapterImpl.toAddressAdapter= (event.getNewMembers()); + if (view !=3D null) { + currentView.addAll(view); + establishInternalNodes(); + } + } + } + } \ No newline at end of file Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/impl/BaseTransactionalDataRegion.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/impl/BaseTransactionalDataRegion.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/impl/BaseTransactionalDataRegion.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -4,7 +4,7 @@ = import org.hibernate.cache.CacheDataDescription; import org.hibernate.cache.TransactionalDataRegion; -import org.infinispan.Cache; +import org.hibernate.cache.infinispan.util.CacheAdapter; = /** * Support for Inifinispan {@link TransactionalDataRegion} implementors. @@ -17,8 +17,8 @@ = private final CacheDataDescription metadata; = - public BaseTransactionalDataRegion(Cache cache, String name, CacheDataD= escription metadata, TransactionManager transactionManager) { - super(cache, name, transactionManager); + public BaseTransactionalDataRegion(CacheAdapter cacheAdapter, String na= me, CacheDataDescription metadata, TransactionManager transactionManager) { + super(cacheAdapter, name, transactionManager); this.metadata =3D metadata; } = Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/query/QueryResultsRegionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/query/QueryResultsRegionImpl.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/query/QueryResultsRegionImpl.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -2,74 +2,85 @@ = import java.util.Properties; = +import javax.transaction.Transaction; import javax.transaction.TransactionManager; = import org.hibernate.cache.CacheException; import org.hibernate.cache.QueryResultsRegion; import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion; +import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.cache.infinispan.util.CacheHelper; -import org.infinispan.Cache; -import org.infinispan.context.Flag; +import org.hibernate.cache.infinispan.util.FlagAdapter; +import org.infinispan.notifications.Listener; = /** * @author Chris Bredesen * @author Galder Zamarre=C3=B1o * @since 3.5 */ +(a)Listener public class QueryResultsRegionImpl extends BaseTransactionalDataRegion im= plements QueryResultsRegion { private boolean localOnly; = - public QueryResultsRegionImpl(Cache cache, String name, Properties prop= erties, TransactionManager transactionManager) { - super(cache, name, null, transactionManager); + public QueryResultsRegionImpl(CacheAdapter cacheAdapter, String name, P= roperties properties, TransactionManager transactionManager) { + super(cacheAdapter, name, null, transactionManager); = // If Infinispan is using INVALIDATION for query cache, we don't wan= t to propagate changes. // We use the Timestamps cache to manage invalidation - localOnly =3D CacheHelper.isClusteredInvalidation(cache); + localOnly =3D cacheAdapter.isClusteredInvalidation(); } = public void evict(Object key) throws CacheException { if (localOnly) - CacheHelper.removeKey(getCache(), key, Flag.CACHE_MODE_LOCAL); + cacheAdapter.withFlags(FlagAdapter.CACHE_MODE_LOCAL).remove(key); else = - CacheHelper.removeKey(getCache(), key); + cacheAdapter.remove(key); } = public void evictAll() throws CacheException { - if (localOnly) - CacheHelper.removeAll(getCache(), Flag.CACHE_MODE_LOCAL); - else = - CacheHelper.removeAll(getCache()); + Transaction tx =3D suspend(); + try { + CacheHelper.sendEvictAllNotification(cacheAdapter, getAddress()); + } finally { + resume(tx); + } } = public Object get(Object key) throws CacheException { + if (!checkValid()) + return null; + // Don't hold the JBC node lock throughout the tx, as that // prevents updates // Add a zero (or low) timeout option so we don't block // waiting for tx's that did a put to commit - return suspendAndGet(key, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT, true); + return suspendAndGet(key, FlagAdapter.ZERO_LOCK_ACQUISITION_TIMEOUT,= true); } = public void put(Object key, Object value) throws CacheException { - // Here we don't want to suspend the tx. If we do: - // 1) We might be caching query results that reflect uncommitted - // changes. No tx =3D=3D no WL on cache node, so other threads - // can prematurely see those query results - // 2) No tx =3D=3D immediate replication. More overhead, plus we - // spread issue #1 above around the cluster + if (checkValid()) { + // Here we don't want to suspend the tx. If we do: + // 1) We might be caching query results that reflect uncommitted + // changes. No tx =3D=3D no WL on cache node, so other threads + // can prematurely see those query results + // 2) No tx =3D=3D immediate replication. More overhead, plus we + // spread issue #1 above around the cluster = - // Add a zero (or quite low) timeout option so we don't block. - // Ignore any TimeoutException. Basically we forego caching the - // query result in order to avoid blocking. - // Reads are done with suspended tx, so they should not hold the - // lock for long. Not caching the query result is OK, since - // any subsequent read will just see the old result with its - // out-of-date timestamp; that result will be discarded and the - // db query performed again. - if (localOnly) - CacheHelper.putAllowingTimeout(getCache(), key, value, Flag.ZERO_= LOCK_ACQUISITION_TIMEOUT, Flag.CACHE_MODE_LOCAL); - else = - CacheHelper.putAllowingTimeout(getCache(), key, value, Flag.ZERO_= LOCK_ACQUISITION_TIMEOUT); - = + // Add a zero (or quite low) timeout option so we don't block. + // Ignore any TimeoutException. Basically we forego caching the + // query result in order to avoid blocking. + // Reads are done with suspended tx, so they should not hold the + // lock for long. Not caching the query result is OK, since + // any subsequent read will just see the old result with its + // out-of-date timestamp; that result will be discarded and the + // db query performed again. + if (localOnly) + cacheAdapter.withFlags(FlagAdapter.ZERO_LOCK_ACQUISITION_TIMEO= UT, FlagAdapter.CACHE_MODE_LOCAL) + .putAllowingTimeout(key, value); + else = + cacheAdapter.withFlags(FlagAdapter.ZERO_LOCK_ACQUISITION_TIMEO= UT) + .putAllowingTimeout(key, value); + } } = } \ No newline at end of file Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/timestamp/TimestampsRegionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/timestamp/TimestampsRegionImpl.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/timestamp/TimestampsRegionImpl.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -10,12 +10,13 @@ import org.hibernate.cache.CacheException; import org.hibernate.cache.TimestampsRegion; import org.hibernate.cache.infinispan.impl.BaseGeneralDataRegion; +import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.cache.infinispan.util.CacheHelper; -import org.infinispan.Cache; -import org.infinispan.context.Flag; +import org.hibernate.cache.infinispan.util.FlagAdapter; import org.infinispan.notifications.Listener; import org.infinispan.notifications.cachelistener.annotation.CacheEntryMod= ified; import org.infinispan.notifications.cachelistener.annotation.CacheEntryRem= oved; +import org.infinispan.notifications.cachelistener.event.CacheEntryInvalida= tedEvent; import org.infinispan.notifications.cachelistener.event.CacheEntryModified= Event; import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedE= vent; = @@ -31,26 +32,31 @@ = private Map localCache =3D new ConcurrentHashMap(); = - public TimestampsRegionImpl(Cache cache, String name, TransactionManage= r transactionManager) { - super(cache, name, transactionManager); - cache.addListener(this); + public TimestampsRegionImpl(CacheAdapter cacheAdapter, String name, Tra= nsactionManager transactionManager) { + super(cacheAdapter, name, transactionManager); + cacheAdapter.addListener(this); populateLocalCache(); } = @Override public void evict(Object key) throws CacheException { // TODO Is this a valid operation on a timestamps cache? - CacheHelper.removeKey(getCache(), key); + cacheAdapter.remove(key); } = public void evictAll() throws CacheException { // TODO Is this a valid operation on a timestamps cache? - CacheHelper.removeAll(getCache()); + Transaction tx =3D suspend(); + try { = + CacheHelper.sendEvictAllNotification(cacheAdapter, getAddress()); + } finally { + resume(tx); + } } = public Object get(Object key) throws CacheException { Object value =3D localCache.get(key); - if (value =3D=3D null) { + if (value =3D=3D null && checkValid()) { value =3D suspendAndGet(key, null, false); if (value !=3D null) localCache.put(key, value); @@ -64,7 +70,7 @@ Transaction tx =3D suspend(); try { // We ensure ASYNC semantics (JBCACHE-1175) - CacheHelper.put(getCache(), key, value, Flag.FORCE_ASYNCHRONOUS); + cacheAdapter.withFlags(FlagAdapter.FORCE_ASYNCHRONOUS).put(key, v= alue); } catch (Exception e) { throw new CacheException(e); } finally { @@ -75,7 +81,7 @@ @Override public void destroy() throws CacheException { localCache.clear(); - getCache().removeListener(this); + cacheAdapter.removeListener(this); super.destroy(); } = @@ -86,8 +92,9 @@ */ @CacheEntryModified public void nodeModified(CacheEntryModifiedEvent event) { - if (event.isPre()) return; - localCache.put(event.getKey(), event.getValue()); + if (!handleEvictAllModification(event) && !event.isPre()) { + localCache.put(event.getKey(), event.getValue()); + } } = /** @@ -101,11 +108,29 @@ localCache.remove(event.getKey()); } = + @Override + protected boolean handleEvictAllModification(CacheEntryModifiedEvent ev= ent) { + boolean result =3D super.handleEvictAllModification(event); + if (result) { + localCache.clear(); + } + return result; + } + + @Override + protected boolean handleEvictAllInvalidation(CacheEntryInvalidatedEvent= event) { + boolean result =3D super.handleEvictAllInvalidation(event); + if (result) { + localCache.clear(); + } + return result; + } + /** * Brings all data from the distributed cache into our local cache. */ private void populateLocalCache() { - Set children =3D CacheHelper.getKeySet(getCache()); + Set children =3D cacheAdapter.keySet(); for (Object key : children) get(key); } Added: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infini= span/util/AddressAdapter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/AddressAdapter.java (rev 0) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/AddressAdapter.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2009, Red Hat, Inc. and/or its affiliates, and + * individual contributors as indicated by the @author tags. See the + * copyright.txt file in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.hibernate.cache.infinispan.util; + +/** + * AddressAdapter. + * = + * @author Galder Zamarre=C3=B1o + * @since 3.5 + */ +public interface AddressAdapter { +} Added: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infini= span/util/AddressAdapterImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/AddressAdapterImpl.java (rev 0) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/AddressAdapterImpl.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -0,0 +1,84 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2009, Red Hat, Inc. and/or its affiliates, and + * individual contributors as indicated by the @author tags. See the + * copyright.txt file in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.hibernate.cache.infinispan.util; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.ArrayList; +import java.util.List; + +import org.infinispan.remoting.transport.Address; + +/** + * AddressAdapterImpl. + * = + * @author Galder Zamarre=C3=B1o + * @since 3.5 + */ +public class AddressAdapterImpl implements AddressAdapter, Externalizable { + + private Address address; + + private AddressAdapterImpl(Address address) { + this.address =3D address; + } + + static AddressAdapter newInstance(Address address) { + return new AddressAdapterImpl(address); + } + + public static List toAddressAdapter(List

ispnA= ddresses) { + List addresses =3D new ArrayList(isp= nAddresses.size()); + for (Address address : ispnAddresses) { + addresses.add(AddressAdapterImpl.newInstance(address)); + } + return addresses; + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFo= undException { + address =3D (Address) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(address); + } + + @Override + public boolean equals(Object obj) { + if (obj =3D=3D this) + return true; + if (!(obj instanceof AddressAdapterImpl)) + return false; + AddressAdapterImpl other =3D (AddressAdapterImpl) obj; + return other.address.equals(address); + } + + @Override + public int hashCode() { + int result =3D 17; + result =3D 31 * result + address.hashCode(); + return result; + } +} Added: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infini= span/util/CacheAdapter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/CacheAdapter.java (rev 0) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/CacheAdapter.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -0,0 +1,207 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2009, Red Hat, Inc. and/or its affiliates, and + * individual contributors as indicated by the @author tags. See the + * copyright.txt file in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.hibernate.cache.infinispan.util; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.hibernate.cache.CacheException; +import org.infinispan.Cache; +import org.infinispan.config.Configuration; +import org.infinispan.util.concurrent.TimeoutException; + +/** + * Infinispan cache abstraction. + * = + * @author Galder Zamarre=C3=B1o + * @since 3.5 + */ +public interface CacheAdapter { + + /** + * Is this cache participating in a cluster with invalidation? + * = + * @return true if the cache is configured for synchronous/asynchronous= invalidation; false otherwise. + */ + boolean isClusteredInvalidation(); + + /** + * Is this cache participating in a cluster with replication? + * = + * @return true if the cache is configured for synchronous/asynchronous= invalidation; false otherwise. + */ + boolean isClusteredReplication(); + + /** + * Is this cache configured for synchronous communication? + * = + * @return true if the cache is configured for synchronous communicatio= n; false otherwise. + */ + boolean isSynchronous(); + + /** + * Set of keys of this cache. + * = + * @return Set containing keys stored in this cache. + */ + Set keySet(); + + /** = + * A builder-style method that adds flags to any cache API call. + * = + * @param flagAdapters a set of flags to apply. See the {@link FlagAda= pter} documentation. + * @return a cache on which a real operation is to be invoked. + */ + CacheAdapter withFlags(FlagAdapter... flagAdapters); + + /** + * Method to check whether a certain key exists in this cache. + * = + * @param key key to look up. + * @return true if key is present, false otherwise. + */ + boolean containsKey(Object key); + + /** + * Performs an get(Object) on the cache, wrapping any exce= ption in a {@link CacheException}. + * = + * @param key key to retrieve + * @throws CacheException + */ + Object get(Object key) throws CacheException; + + /** + * Performs an get(Object) on the cache ignoring any {@lin= k TimeoutException} = + * and wrapping any other exception in a {@link CacheException}. + * = + * @param key key to retrieve + * @throws CacheException + */ + Object getAllowingTimeout(Object key) throws CacheException; + + /** + * Performs a put(Object, Object) on the cache, wrapping a= ny exception in a {@link CacheException}. + * = + * @param key key whose value will be modified + * @param value data to store in the cache entry + * @return the previous value associated with key, or null= = + * if there was no mapping for key. + * @throws CacheException + */ + Object put(Object key, Object value) throws CacheException; + + /** + * Performs a put(Object, Object) on the cache ignoring an= y {@link TimeoutException} = + * and wrapping any exception in a {@link CacheException}. + * = + * @param key key whose value will be modified + * @param value data to store in the cache entry + * @return the previous value associated with key, or null= = + * if there was no mapping for key. + * @throws CacheException + */ + Object putAllowingTimeout(Object key, Object value) throws CacheExcepti= on; + + /** + * See {@link Cache#putForExternalRead(Object, Object)} for detailed do= cumentation. + * = + * @param key key with which the specified value is to be associated. + * @param value value to be associated with the specified key. + * @throws CacheException + */ + void putForExternalRead(Object key, Object value) throws CacheException; + + /** + * Performs a remove(Object), wrapping any exception in a = {@link CacheException}. + * = + * @param key key to be removed + * @return the previous value associated with key, or = + * null if there was no mapping for key. + * @throws CacheException + */ + Object remove(Object key) throws CacheException; + + /** + * Evict the given key from memory. + * = + * @param key to evict. + */ + void evict(Object key) throws CacheException; + + /** + * Clear the cache. + * = + * @throws CacheException + */ + void clear() throws CacheException; + + /** + * Add listener to this cache. + * = + * @param listener to be added to cache. + */ + void addListener(Object listener); + + /** + * Get local cluster address. + * = + * @return Address representing local address. + */ + AddressAdapter getAddress(); + + /** + * Get cluster members. + * = + * @return List of cluster member Address instances + */ + List getMembers(); + + /** + * Size of cache. + * = + * @return number of cache entries. + */ + int size(); + + /** + * This method returns a Map view of the cache. + * = + * @return Map view of cache. + */ + Map toMap(); + + /** + * Remove listener from cache instance. + * = + * @param listener to be removed. + */ + void removeListener(Object listener); + + /** + * Get cache configuration. + * = + * @return Configuration instance associated with this cache. + */ + Configuration getConfiguration(); +} Added: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infini= span/util/CacheAdapterImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/CacheAdapterImpl.java (rev 0) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/CacheAdapterImpl.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -0,0 +1,205 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2009, Red Hat, Inc. and/or its affiliates, and + * individual contributors as indicated by the @author tags. See the + * copyright.txt file in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.hibernate.cache.infinispan.util; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.hibernate.cache.CacheException; +import org.infinispan.Cache; +import org.infinispan.config.Configuration; +import org.infinispan.context.Flag; +import org.infinispan.remoting.rpc.RpcManager; +import org.infinispan.util.concurrent.TimeoutException; + +/** + * CacheAdapterImpl. + * = + * @author Galder Zamarre=C3=B1o + * @since 3.5 + */ +public class CacheAdapterImpl implements CacheAdapter { + + private final Cache cache; + + private CacheAdapterImpl(Cache cache) { + this.cache =3D cache; + } + + public static CacheAdapter newInstance(Cache cache) { + return new CacheAdapterImpl(cache); + } + + public boolean isClusteredInvalidation() { + return isClusteredInvalidation(cache.getConfiguration().getCacheMode= ()); + } + + public boolean isClusteredReplication() { + return isClusteredReplication(cache.getConfiguration().getCacheMode(= )); + } + + public boolean isSynchronous() { + return isSynchronous(cache.getConfiguration().getCacheMode()); + } + + public Set keySet() { + return cache.keySet(); + } + + public CacheAdapter withFlags(FlagAdapter... flagAdapters) { + Flag[] flags =3D FlagAdapter.toFlags(flagAdapters); + return newInstance(cache.getAdvancedCache().withFlags(flags)); + } + + public Object get(Object key) throws CacheException { + try { + return cache.get(key); + } catch (Exception e) { + throw new CacheException(e); + } + } + + public Object getAllowingTimeout(Object key) throws CacheException { + try { + return cache.get(key); + } catch (TimeoutException ignored) { + // ignore it + return null; + } catch (Exception e) { + throw new CacheException(e); + } + } + + public Object put(Object key, Object value) throws CacheException { + try { + return cache.put(key, value); + } catch (Exception e) { + throw new CacheException(e); + } + } + + public Object putAllowingTimeout(Object key, Object value) throws Cache= Exception { + try { + return cache.put(key, value); + } catch (TimeoutException allowed) { + // ignore it + return null; + } catch (Exception e) { + throw new CacheException(e); + } + } + + public void putForExternalRead(Object key, Object value) throws CacheEx= ception { + try { + cache.putForExternalRead(key, value); + } catch (Exception e) { + throw new CacheException(e); + } + } + + public Object remove(Object key) throws CacheException { + try { + return cache.remove(key); + } catch (Exception e) { + throw new CacheException(e); + } + } + + public void evict(Object key) throws CacheException { + try { + cache.evict(key); + } catch (Exception e) { + throw new CacheException(e); + } + } + + public void clear() throws CacheException { + try { + cache.clear(); + } catch (Exception e) { + throw new CacheException(e); + } + } + + private static boolean isClusteredInvalidation(Configuration.CacheMode = cacheMode) { + return cacheMode =3D=3D Configuration.CacheMode.INVALIDATION_ASYNC + || cacheMode =3D=3D Configuration.CacheMode.INVALIDATION_SY= NC; + } + + private static boolean isClusteredReplication(Configuration.CacheMode c= acheMode) { + return cacheMode =3D=3D Configuration.CacheMode.REPL_ASYNC + || cacheMode =3D=3D Configuration.CacheMode.REPL_SYNC; + } + + private static boolean isSynchronous(Configuration.CacheMode cacheMode)= { + return cacheMode =3D=3D Configuration.CacheMode.REPL_SYNC + || cacheMode =3D=3D Configuration.CacheMode.INVALIDATION_SY= NC + || cacheMode =3D=3D Configuration.CacheMode.DIST_SYNC; + } + + public void addListener(Object listener) { + cache.addListener(listener); + } + + public AddressAdapter getAddress() { + RpcManager rpc =3D cache.getAdvancedCache().getRpcManager(); + if (rpc !=3D null) { + return AddressAdapterImpl.newInstance(rpc.getTransport().getAddre= ss()); + } + return null; + } + + public List getMembers() { + RpcManager rpc =3D cache.getAdvancedCache().getRpcManager(); + if (rpc !=3D null) { + return AddressAdapterImpl.toAddressAdapter(rpc.getTransport().get= Members()); + } + return null; + } + + public RpcManager getRpcManager() { + return cache.getAdvancedCache().getRpcManager(); + } + + public int size() { + return cache.size(); + } + + public Map toMap() { + return cache; + } + + public void removeListener(Object listener) { + cache.removeListener(listener); + } + + public boolean containsKey(Object key) { + return cache.containsKey(key); + } + + public Configuration getConfiguration() { + return cache.getConfiguration(); + } + +} Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/inf= inispan/util/CacheHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/CacheHelper.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/CacheHelper.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -23,13 +23,12 @@ */ package org.hibernate.cache.infinispan.util; = +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.util.Set; = -import org.hibernate.cache.CacheException; -import org.infinispan.Cache; -import org.infinispan.config.Configuration; -import org.infinispan.context.Flag; -import org.infinispan.util.concurrent.TimeoutException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; = @@ -49,324 +48,68 @@ private CacheHelper() { } = - /** - * Is this cache participating in a cluster with invalidation? - * = - * @param cache - * The cache to check. - * @return True if the cache is configured for synchronous/asynchronous= invalidation; false - * otherwise. - */ - public static boolean isClusteredInvalidation(Cache cache) { - return isClusteredInvalidation(cache.getConfiguration().getCacheMode= ()); + public static void initInternalEvict(CacheAdapter cacheAdapter, Address= Adapter member) { + EvictAll eKey =3D new EvictAll(member =3D=3D null ? NoAddress.INSTAN= CE : member); + cacheAdapter.withFlags(FlagAdapter.CACHE_MODE_LOCAL).put(eKey, Inter= nal.INIT); } = - /** - * Does this cache mode indicate clustered invalidation? - * = - * @param cacheMode - * The cache to check - * @return True if the cache mode is confiogured for synchronous/asynch= ronous invalidation; false - * otherwise. - */ - public static boolean isClusteredInvalidation(Configuration.CacheMode c= acheMode) { - return cacheMode =3D=3D Configuration.CacheMode.INVALIDATION_ASYNC - || cacheMode =3D=3D Configuration.CacheMode.INVALIDATION_SY= NC; + public static void sendEvictAllNotification(CacheAdapter cacheAdapter, = AddressAdapter member) { + EvictAll eKey =3D new EvictAll(member =3D=3D null ? NoAddress.INSTAN= CE : member); + cacheAdapter.put(eKey, Internal.EVICT); } = - /** - * Is this cache participating in a cluster with replication? - * = - * @param cache - * The cache to check. - * @return True if the cache is configured for synchronous/asynchronous= invalidation; false - * otherwise. - */ - public static boolean isClusteredReplication(Cache cache) { - return isClusteredReplication(cache.getConfiguration().getCacheMode(= )); + public static boolean isEvictAllNotification(Object key) { + return key instanceof EvictAll; } = - /** - * Does this cache mode indicate clustered replication? - * = - * @param cacheMode - * The cache to check - * @return True if the cache mode is confiogured for synchronous/asynch= ronous invalidation; false - * otherwise. - */ - public static boolean isClusteredReplication(Configuration.CacheMode ca= cheMode) { - return cacheMode =3D=3D Configuration.CacheMode.REPL_ASYNC || cacheM= ode =3D=3D Configuration.CacheMode.REPL_SYNC; + public static boolean containsEvictAllNotification(Set keySet, AddressA= dapter member) { + EvictAll eKey =3D new EvictAll(member =3D=3D null ? NoAddress.INSTAN= CE : member); + return keySet.contains(eKey); } = - public static boolean isSynchronous(Cache cache) { - return isSynchronous(cache.getConfiguration().getCacheMode()); + public static boolean isEvictAllNotification(Object key, Object value) { + return key instanceof EvictAll && value =3D=3D Internal.EVICT; } = - public static boolean isSynchronous(Configuration.CacheMode cacheMode) { - return cacheMode =3D=3D Configuration.CacheMode.REPL_SYNC || cacheMo= de =3D=3D Configuration.CacheMode.INVALIDATION_SYNC; - } + private static class EvictAll implements Externalizable { + AddressAdapter member; = - public static Set getKeySet(Cache cache) { - return cache.keySet(); - } - - /** - * Builds an {@link Fqn} from region and key = and performs a JBoss Cache - * get(Fqn, Object), wrapping any exception in a {@link Ca= cheException}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - * @param key - * specific key to append to the region to form = the full Fqn - */ - public static Object get(Cache cache, Object key) throws CacheException= { - try { - return cache.get(key); - } catch (Exception e) { - throw new CacheException(e); + EvictAll(AddressAdapter member) { + this.member =3D member; } - } = - /** - * Builds an {@link Fqn} from region and key = and performs a JBoss Cache - * get(Fqn, Object), wrapping any exception in a {@link Ca= cheException}. - * = - * @param cache - * the cache to invoke on - * @param key - * specific key to append to the region to form = the full Fqn - */ - public static Object getAllowingTimeout(Cache cache, Object key) throws= CacheException { - try { - return cache.get(key); - } catch (TimeoutException ignored) { - // ignore it - return null; - } catch (Exception e) { - throw new CacheException(e); + @Override + public boolean equals(Object obj) { + if (obj =3D=3D this) + return true; + if (!(obj instanceof EvictAll)) + return false; + EvictAll ek =3D (EvictAll) obj; + return ek.member.equals(member); } - } = - /** - * Builds an {@link Fqn} from region and key = and performs a JBoss Cache - * put(Object, Object), wrapping any exception in a {@link= CacheException}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - * @param key - * specific key to append to the region to form = the full Fqn - * @param value - * data to store in the cache node - */ - public static void put(Cache cache, Object key, Object value) throws Ca= cheException { - put(cache, key, value, null); - } - - /** - * Builds an {@link Fqn} from region and key = and performs a JBoss Cache - * put(Object, Object), wrapping any exception in a {@link= CacheException}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - * @param key - * specific key to append to the region to form = the full Fqn - * @param value - * data to store in the cache node - * @param option - * invocation Option to set for this invocation. May be null. - */ - public static void put(Cache cache, Object key, Object value, Flag opti= on) throws CacheException { - try { - cache.getAdvancedCache().put(key, value, option); - } catch (Exception e) { - throw new CacheException(e); + @Override + public int hashCode() { + int result =3D 17; + result =3D 31 * result + member.hashCode(); + return result; } - } = - /** - * Builds an {@link Fqn} from region and key = and performs a JBoss Cache - * put(Object, Object), ignoring any {@link TimeoutExcepti= on} and wrapping any other - * exception in a {@link CacheException}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - * @param key - * specific key to append to the region to form = the full Fqn - * @param value - * data to store in the cache node - * @param option - * invocation Option to set for this invocation. May be null. - */ - public static void putAllowingTimeout(Cache cache, Object key, Object v= alue, Flag... option) throws CacheException { - try { - cache.getAdvancedCache().put(key, value, option); - } catch (TimeoutException allowed) { - // ignore it - } catch (Exception e) { - throw new CacheException(e); + public void readExternal(ObjectInput in) throws IOException, ClassNo= tFoundException { + member =3D (AddressAdapter) in.readObject(); } - } = - /** - * Builds an {@link Fqn} from region and key = and performs a JBoss Cache - * putForExternalRead(Object, Object), wrapping any except= ion in a - * {@link CacheException}. Ignores any JBoss Cache {@link TimeoutExcept= ion}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - * @param key - * specific key to append to the region to form = the full Fqn - * @param value - * data to store in the cache node - */ - public static boolean putForExternalRead(Cache cache, Object key, Objec= t value) throws CacheException { - return putForExternalRead(cache, key, value, (Flag[])null); - } - - /** - * Builds an {@link Fqn} from region and key = and performs a JBoss Cache - * putForExternalRead(Object, Object), wrapping any except= ion in a - * {@link CacheException}. Ignores any JBoss Cache {@link TimeoutExcept= ion}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - * @param key - * specific key to append to the region to form = the full Fqn - * @param value - * data to store in the cache node - * @param option - * invocation Option to set for this invocation. May be null. - */ - public static boolean putForExternalRead(Cache cache, Object key, Objec= t value, Flag... option) throws CacheException { - try { - cache.getAdvancedCache().putForExternalRead(key, value, option); - return true; - } catch (TimeoutException te) { - // ignore! - log.debug("ignoring write lock acquisition failure"); - return false; - } catch (Throwable t) { - throw new CacheException(t); + public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(member); } } = - /** - * Builds an {@link Fqn} from region and key = and performs a JBoss Cache - * removeNode(Fqn), wrapping any exception in a {@link Cac= heException}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - * @param key - * specific key to append to the region to form = the full Fqn - */ - public static void remove(Cache cache, Object key) throws CacheExceptio= n { - remove(cache, key, null); + private enum NoAddress implements AddressAdapter { + INSTANCE; } = - /** - * Builds an {@link Fqn} from region and key = and performs a JBoss Cache - * removeNode(Fqn), wrapping any exception in a {@link Cac= heException}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - * @param key - * specific key to append to the region to form = the full Fqn - * @param option - * invocation Option to set for this invocation. May be null. - */ - public static void remove(Cache cache, Object key, Flag option) throws = CacheException { - try { - cache.getAdvancedCache().remove(key, option); - } catch (Exception e) { - throw new CacheException(e); - } + private enum Internal { = + INIT, EVICT; } = - /** - * Performs a JBoss Cache removeNode(Fqn), wrapping any ex= ception in a - * {@link CacheException}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - */ - public static void removeAll(Cache cache) throws CacheException { - try { - cache.clear(); - } catch (Exception e) { - throw new CacheException(e); - } - } - - /** - * Performs a JBoss Cache removeNode(Fqn), wrapping any ex= ception in a - * {@link CacheException}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - * @param option - * invocation Option to set for this invocation. May be null. - */ - public static void removeAll(Cache cache, Flag option) throws CacheExce= ption { - try { - cache.getAdvancedCache().clear(option); - } catch (Exception e) { - throw new CacheException(e); - } - } - - /** - * Performs a JBoss Cache removeNode(Fqn), wrapping any ex= ception in a - * {@link CacheException}. - * = - * @param cache - * the cache to invoke on - * @param region - * base Fqn for the cache region - * @param option - * invocation Option to set for this invocation. May be null. - */ - public static void removeKey(Cache cache, Object key, Flag option) thro= ws CacheException { - try { - cache.getAdvancedCache().remove(key, option); - } catch (Exception e) { - throw new CacheException(e); - } - } - = - public static void removeKey(Cache cache, Object key) throws CacheExcep= tion { - try { - cache.remove(key); - } catch (Exception e) { - throw new CacheException(e); - } - } - = - public static boolean containsKey(Cache cache, Object key, Flag... flag= s) { - try { - return cache.getAdvancedCache().containsKey(key, flags); - } catch (Exception e) { - throw new CacheException(e); - } - } - } Added: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infini= span/util/FlagAdapter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/FlagAdapter.java (rev 0) +++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispa= n/util/FlagAdapter.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -0,0 +1,59 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2009, Red Hat, Inc. and/or its affiliates, and + * individual contributors as indicated by the @author tags. See the + * copyright.txt file in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.hibernate.cache.infinispan.util; + +import org.hibernate.cache.CacheException; +import org.infinispan.context.Flag; + +/** + * FlagAdapter. + * = + * @author Galder Zamarre=C3=B1o + * @since 3.5 + */ +public enum FlagAdapter { + ZERO_LOCK_ACQUISITION_TIMEOUT, + CACHE_MODE_LOCAL, + FORCE_ASYNCHRONOUS; + = + Flag toFlag() { + switch(this) { + case ZERO_LOCK_ACQUISITION_TIMEOUT: + return Flag.ZERO_LOCK_ACQUISITION_TIMEOUT; + case CACHE_MODE_LOCAL: + return Flag.CACHE_MODE_LOCAL; + case FORCE_ASYNCHRONOUS: + return Flag.FORCE_ASYNCHRONOUS; + default: + throw new CacheException("Unmatched Infinispan flag " + this); + } + } + = + static Flag[] toFlags(FlagAdapter[] adapters) { + Flag[] flags =3D new Flag[adapters.length]; + for (int i =3D 0; i < adapters.length; i++) { + flags[i] =3D adapters[i].toFlag(); + } + return flags; + } +} Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/AbstractGeneralDataRegionTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/AbstractGeneralDataRegionTestCase.java 2009-11-13 17:40:36 UTC (rev = 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/AbstractGeneralDataRegionTestCase.java 2009-11-13 18:12:53 UTC (rev = 17976) @@ -29,10 +29,9 @@ import org.hibernate.cache.QueryResultsRegion; import org.hibernate.cache.Region; import org.hibernate.cache.infinispan.InfinispanRegionFactory; -import org.hibernate.cache.infinispan.util.CacheHelper; +import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.cfg.Configuration; import org.hibernate.test.cache.infinispan.util.CacheTestUtil; -import org.infinispan.Cache; import org.infinispan.transaction.tm.BatchModeTransactionManager; = /** @@ -74,8 +73,8 @@ private void evictOrRemoveTest() throws Exception { Configuration cfg =3D createConfiguration(); InfinispanRegionFactory regionFactory =3D CacheTestUtil.startRegionF= actory(cfg, getCacheTestSupport()); - Cache localCache =3D getInfinispanCache(regionFactory); - boolean invalidation =3D CacheHelper.isClusteredInvalidation(localCa= che); + CacheAdapter localCache =3D getInfinispanCache(regionFactory); + boolean invalidation =3D localCache.isClusteredInvalidation(); = // Sleep a bit to avoid concurrent FLUSH problem avoidConcurrentFlush(); @@ -123,7 +122,7 @@ private void evictOrRemoveAllTest(String configName) throws Exception { Configuration cfg =3D createConfiguration(); InfinispanRegionFactory regionFactory =3D CacheTestUtil.startRegionF= actory(cfg, getCacheTestSupport()); - Cache localCache =3D getInfinispanCache(regionFactory); + CacheAdapter localCache =3D getInfinispanCache(regionFactory); = // Sleep a bit to avoid concurrent FLUSH problem avoidConcurrentFlush(); @@ -133,7 +132,7 @@ = cfg =3D createConfiguration(); regionFactory =3D CacheTestUtil.startRegionFactory(cfg, getCacheTest= Support()); - Cache remoteCache =3D getInfinispanCache(regionFactory); + CacheAdapter remoteCache =3D getInfinispanCache(regionFactory); = // Sleep a bit to avoid concurrent FLUSH problem avoidConcurrentFlush(); @@ -141,11 +140,11 @@ GeneralDataRegion remoteRegion =3D (GeneralDataRegion) createRegion(= regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), = null); = - Set children =3D CacheHelper.getKeySet(localCache); - assertEquals("No children in " + children, 0, children.size()); + Set keys =3D localCache.keySet(); + assertEquals("No valid children in " + keys, 0, getValidKeyCount(key= s)); = - children =3D CacheHelper.getKeySet(remoteCache); - assertEquals("No children in " + children, 0, children.size()); + keys =3D remoteCache.keySet(); + assertEquals("No valid children in " + keys, 0, getValidKeyCount(key= s)); = assertNull("local is clean", localRegion.get(KEY)); assertNull("remote is clean", remoteRegion.get(KEY)); @@ -168,11 +167,13 @@ sleep(250); // This should re-establish the region root node in the optimistic c= ase assertNull(localRegion.get(KEY)); + assertEquals("No valid children in " + keys, 0, getValidKeyCount(loc= alCache.keySet())); = // Re-establishing the region root on the local node doesn't // propagate it to other nodes. Do a get on the remote node to re-es= tablish // This only adds a node in the case of optimistic locking assertEquals(null, remoteRegion.get(KEY)); + assertEquals("No valid children in " + keys, 0, getValidKeyCount(rem= oteCache.keySet())); = assertEquals("local is clean", null, localRegion.get(KEY)); assertEquals("remote is clean", null, remoteRegion.get(KEY)); Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/AbstractNonFunctionalTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/AbstractNonFunctionalTestCase.java 2009-11-13 17:40:36 UTC (rev 1797= 5) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/AbstractNonFunctionalTestCase.java 2009-11-13 18:12:53 UTC (rev 1797= 6) @@ -23,7 +23,10 @@ */ package org.hibernate.test.cache.infinispan; = +import java.util.Set; + import org.hibernate.cache.RegionFactory; +import org.hibernate.cache.infinispan.util.CacheHelper; import org.hibernate.junit.UnitTestCase; import org.hibernate.test.cache.infinispan.util.CacheTestSupport; import org.infinispan.Cache; @@ -81,7 +84,7 @@ protected CacheTestSupport getCacheTestSupport() { return testSupport; } - = + protected void sleep(long ms) { try { Thread.sleep(ms); @@ -94,4 +97,15 @@ protected void avoidConcurrentFlush() { testSupport.avoidConcurrentFlush(); } + + protected int getValidKeyCount(Set keys) { + int result =3D 0; + for (Object key : keys) { + if (!(CacheHelper.isEvictAllNotification(key))) { + result++; + } + } + return result; + } + } \ No newline at end of file Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/AbstractRegionImplTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/AbstractRegionImplTestCase.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/AbstractRegionImplTestCase.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -29,8 +29,8 @@ import org.hibernate.cache.Region; import org.hibernate.cache.impl.CacheDataDescriptionImpl; import org.hibernate.cache.infinispan.InfinispanRegionFactory; +import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.util.ComparableComparator; -import org.infinispan.Cache; = /** * Base class for tests of Region implementations. @@ -44,7 +44,7 @@ super(name); } = - protected abstract Cache getInfinispanCache(InfinispanRegionFactory reg= ionFactory); + protected abstract CacheAdapter getInfinispanCache(InfinispanRegionFact= ory regionFactory); = protected abstract Region createRegion(InfinispanRegionFactory regionFa= ctory, String regionName, Properties properties, CacheDataDescription cdd); = Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/InfinispanRegionFactoryTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/InfinispanRegionFactoryTestCase.java 2009-11-13 17:40:36 UTC (rev 17= 975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/InfinispanRegionFactoryTestCase.java 2009-11-13 18:12:53 UTC (rev 17= 976) @@ -29,7 +29,7 @@ import org.hibernate.cache.infinispan.entity.EntityRegionImpl; import org.hibernate.cache.infinispan.query.QueryResultsRegionImpl; import org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl; -import org.infinispan.Cache; +import org.hibernate.cache.infinispan.util.CacheAdapter; import org.infinispan.config.Configuration; import org.infinispan.config.Configuration.CacheMode; import org.infinispan.eviction.EvictionStrategy; @@ -125,13 +125,13 @@ assertFalse(factory.getDefinedConfigurations().contains(person)); assertNotNull(factory.getTypeOverrides().get(addresses)); assertFalse(factory.getDefinedConfigurations().contains(addresses= )); - Cache cache =3D null; + CacheAdapter cache =3D null; = EntityRegionImpl region =3D (EntityRegionImpl) factory.buildEntit= yRegion(person, p, null); assertNotNull(factory.getTypeOverrides().get(person)); assertTrue(factory.getDefinedConfigurations().contains(person)); assertNull(factory.getTypeOverrides().get(address)); - cache =3D region.getCache(); + cache =3D region.getCacheAdapter(); Configuration cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy()= ); assertEquals(2000, cacheCfg.getEvictionWakeUpInterval()); @@ -143,7 +143,7 @@ assertNotNull(factory.getTypeOverrides().get(person)); assertTrue(factory.getDefinedConfigurations().contains(person)); assertNull(factory.getTypeOverrides().get(address)); - cache =3D region.getCache(); + cache =3D region.getCacheAdapter(); cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy(= )); assertEquals(3000, cacheCfg.getEvictionWakeUpInterval()); @@ -153,7 +153,7 @@ assertNotNull(factory.getTypeOverrides().get(person)); assertTrue(factory.getDefinedConfigurations().contains(person)); assertNull(factory.getTypeOverrides().get(address)); - cache =3D region.getCache(); + cache =3D region.getCacheAdapter(); cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy(= )); assertEquals(3000, cacheCfg.getEvictionWakeUpInterval()); @@ -163,7 +163,7 @@ assertNotNull(factory.getTypeOverrides().get(addresses)); assertTrue(factory.getDefinedConfigurations().contains(person)); assertNull(factory.getTypeOverrides().get(parts)); - cache =3D collectionRegion .getCache(); + cache =3D collectionRegion .getCacheAdapter(); cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy(= )); assertEquals(2500, cacheCfg.getEvictionWakeUpInterval()); @@ -175,7 +175,7 @@ assertNotNull(factory.getTypeOverrides().get(addresses)); assertTrue(factory.getDefinedConfigurations().contains(addresses)= ); assertNull(factory.getTypeOverrides().get(parts)); - cache =3D collectionRegion.getCache(); + cache =3D collectionRegion.getCacheAdapter(); cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy()= ); assertEquals(3500, cacheCfg.getEvictionWakeUpInterval()); @@ -185,7 +185,7 @@ assertNotNull(factory.getTypeOverrides().get(addresses)); assertTrue(factory.getDefinedConfigurations().contains(addresses)= ); assertNull(factory.getTypeOverrides().get(parts)); - cache =3D collectionRegion.getCache(); + cache =3D collectionRegion.getCacheAdapter(); cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy()= ); assertEquals(3500, cacheCfg.getEvictionWakeUpInterval()); @@ -196,7 +196,7 @@ } = public void testBuildEntityCollectionRegionOverridesOnly() { - Cache cache =3D null; + CacheAdapter cache =3D null; Properties p =3D new Properties(); p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy",= "FIFO"); p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_in= terval", "3000"); @@ -211,7 +211,7 @@ try { EntityRegionImpl region =3D (EntityRegionImpl) factory.buildEntit= yRegion("com.acme.Address", p, null); assertNull(factory.getTypeOverrides().get("com.acme.Address")); - cache =3D region.getCache(); + cache =3D region.getCacheAdapter(); Configuration cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy(= )); assertEquals(3000, cacheCfg.getEvictionWakeUpInterval()); @@ -220,7 +220,7 @@ = CollectionRegionImpl collectionRegion =3D (CollectionRegionImpl) = factory.buildCollectionRegion("com.acme.Person.addresses", p, null); assertNull(factory.getTypeOverrides().get("com.acme.Person.addres= ses")); - cache =3D collectionRegion.getCache(); + cache =3D collectionRegion.getCacheAdapter(); cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy()= ); assertEquals(3500, cacheCfg.getEvictionWakeUpInterval()); @@ -252,7 +252,7 @@ EntityRegionImpl region =3D (EntityRegionImpl) factory.buildEntit= yRegion(person, p, null); assertNotNull(factory.getTypeOverrides().get(person)); assertTrue(factory.getDefinedConfigurations().contains(person)); - Cache cache =3D region.getCache(); + CacheAdapter cache =3D region.getCacheAdapter(); Configuration cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy()= ); assertEquals(3000, cacheCfg.getEvictionWakeUpInterval()); @@ -297,7 +297,7 @@ config.setFetchInMemoryState(false); manager.defineConfiguration("timestamps", config); TimestampsRegionImpl region =3D (TimestampsRegionImpl) factory.bu= ildTimestampsRegion(timestamps, p); - Cache cache =3D region.getCache(); + CacheAdapter cache =3D region.getCacheAdapter(); Configuration cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.NONE, cacheCfg.getEvictionStrategy(= )); assertEquals(CacheMode.REPL_ASYNC, cacheCfg.getCacheMode()); @@ -324,7 +324,7 @@ config.setCacheMode(CacheMode.REPL_SYNC); manager.defineConfiguration("unrecommended-timestamps", config); TimestampsRegionImpl region =3D (TimestampsRegionImpl) factory.bu= ildTimestampsRegion(timestamps, p); - Cache cache =3D region.getCache(); + CacheAdapter cache =3D region.getCacheAdapter(); Configuration cacheCfg =3D cache.getConfiguration(); assertEquals(EvictionStrategy.NONE, cacheCfg.getEvictionStrategy(= )); assertEquals(CacheMode.REPL_SYNC, cacheCfg.getCacheMode()); @@ -400,7 +400,7 @@ try { assertTrue(factory.getDefinedConfigurations().contains("local-que= ry")); QueryResultsRegionImpl region =3D (QueryResultsRegionImpl) factor= y.buildQueryResultsRegion(query, p); - Cache cache =3D region.getCache(); + CacheAdapter cache =3D region.getCacheAdapter(); Configuration cacheCfg =3D cache.getConfiguration(); assertEquals(CacheMode.LOCAL, cacheCfg.getCacheMode()); } finally { Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2009-= 11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2009-= 11-13 18:12:53 UTC (rev 17976) @@ -38,13 +38,12 @@ import org.hibernate.cache.impl.CacheDataDescriptionImpl; import org.hibernate.cache.infinispan.InfinispanRegionFactory; import org.hibernate.cache.infinispan.impl.BaseRegion; -import org.hibernate.cache.infinispan.util.CacheHelper; +import org.hibernate.cache.infinispan.util.CacheAdapter; +import org.hibernate.cache.infinispan.util.FlagAdapter; import org.hibernate.cfg.Configuration; import org.hibernate.test.cache.infinispan.AbstractNonFunctionalTestCase; import org.hibernate.test.cache.infinispan.util.CacheTestUtil; import org.hibernate.util.ComparableComparator; -import org.infinispan.Cache; -import org.infinispan.context.Flag; import org.infinispan.transaction.tm.BatchModeTransactionManager; = /** @@ -64,10 +63,10 @@ = protected static Configuration localCfg; protected static InfinispanRegionFactory localRegionFactory; - protected Cache localCache; + protected CacheAdapter localCache; protected static Configuration remoteCfg; protected static InfinispanRegionFactory remoteRegionFactory; - protected Cache remoteCache; + protected CacheAdapter remoteCache; = protected CollectionRegion localCollectionRegion; protected CollectionRegionAccessStrategy localAccessStrategy; @@ -112,17 +111,17 @@ = localCollectionRegion =3D localRegionFactory.buildCollectionRegion(R= EGION_NAME, localCfg.getProperties(), getCacheDataDescription()); - localCache =3D ((BaseRegion) localCollectionRegion).getCache(); + localCache =3D ((BaseRegion) localCollectionRegion).getCacheAdapter(= ); localAccessStrategy =3D localCollectionRegion.buildAccessStrategy(ge= tAccessType()); - invalidation =3D CacheHelper.isClusteredInvalidation(localCache); - synchronous =3D CacheHelper.isSynchronous(localCache); + invalidation =3D localCache.isClusteredInvalidation(); + synchronous =3D localCache.isSynchronous(); = // Sleep a bit to avoid concurrent FLUSH problem avoidConcurrentFlush(); = remoteCollectionRegion =3D remoteRegionFactory.buildCollectionRegion= (REGION_NAME, remoteCfg.getProperties(), getCacheDataDescription()); - remoteCache =3D ((BaseRegion) remoteCollectionRegion).getCache(); + remoteCache =3D ((BaseRegion) remoteCollectionRegion).getCacheAdapte= r(); remoteAccessStrategy =3D remoteCollectionRegion.buildAccessStrategy(= getAccessType()); = node1Exception =3D null; @@ -142,13 +141,13 @@ remoteCollectionRegion.destroy(); = try { - localCache.getAdvancedCache().clear(Flag.CACHE_MODE_LOCAL); + localCache.withFlags(FlagAdapter.CACHE_MODE_LOCAL).clear(); } catch (Exception e) { log.error("Problem purging local cache", e); } = try { - remoteCache.getAdvancedCache().clear(Flag.CACHE_MODE_LOCAL); + remoteCache.withFlags(FlagAdapter.CACHE_MODE_LOCAL).clear(); } catch (Exception e) { log.error("Problem purging remote cache", e); } @@ -402,9 +401,9 @@ = final String KEY =3D KEY_BASE + testCount++; = - assertEquals(0, localCache.keySet().size()); + assertEquals(0, getValidKeyCount(localCache.keySet())); = - assertEquals(0, remoteCache.keySet().size()); + assertEquals(0, getValidKeyCount(remoteCache.keySet())); = assertNull("local is clean", localAccessStrategy.get(KEY, System.cur= rentTimeMillis())); assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.c= urrentTimeMillis())); @@ -425,19 +424,19 @@ // This should re-establish the region root node assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis())); = - assertEquals(0, localCache.keySet().size()); + assertEquals(0, getValidKeyCount(localCache.keySet())); = // Re-establishing the region root on the local node doesn't // propagate it to other nodes. Do a get on the remote node to re-es= tablish assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeM= illis())); = - assertEquals(0, remoteCache.keySet().size()); + assertEquals(0, getValidKeyCount(remoteCache.keySet())); = // Test whether the get above messes up the optimistic version remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMill= is(), new Integer(1)); assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTim= eMillis())); = - assertEquals(1, remoteCache.keySet().size()); + assertEquals(1, getValidKeyCount(remoteCache.keySet())); = // Wait for async propagation of the putFromLoad sleep(250); Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/entity/AbstractEntityRegionAccessStrategyTestCase.java 2009-11-13 17= :40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/entity/AbstractEntityRegionAccessStrategyTestCase.java 2009-11-13 18= :12:53 UTC (rev 17976) @@ -38,13 +38,12 @@ import org.hibernate.cache.impl.CacheDataDescriptionImpl; import org.hibernate.cache.infinispan.InfinispanRegionFactory; import org.hibernate.cache.infinispan.impl.BaseRegion; -import org.hibernate.cache.infinispan.util.CacheHelper; +import org.hibernate.cache.infinispan.util.CacheAdapter; +import org.hibernate.cache.infinispan.util.FlagAdapter; import org.hibernate.cfg.Configuration; import org.hibernate.test.cache.infinispan.AbstractNonFunctionalTestCase; import org.hibernate.test.cache.infinispan.util.CacheTestUtil; import org.hibernate.util.ComparableComparator; -import org.infinispan.Cache; -import org.infinispan.context.Flag; import org.infinispan.transaction.tm.BatchModeTransactionManager; = /** @@ -64,10 +63,10 @@ = protected static Configuration localCfg; protected static InfinispanRegionFactory localRegionFactory; - protected Cache localCache; + protected CacheAdapter localCache; protected static Configuration remoteCfg; protected static InfinispanRegionFactory remoteRegionFactory; - protected Cache remoteCache; + protected CacheAdapter remoteCache; = protected boolean invalidation; protected boolean synchronous; @@ -114,10 +113,10 @@ .getProperties(), getCacheDataDescription()); localAccessStrategy =3D localEntityRegion.buildAccessStrategy(getAcc= essType()); = - localCache =3D ((BaseRegion) localEntityRegion).getCache(); + localCache =3D ((BaseRegion) localEntityRegion).getCacheAdapter(); = - invalidation =3D CacheHelper.isClusteredInvalidation(localCache); - synchronous =3D CacheHelper.isSynchronous(localCache); + invalidation =3D localCache.isClusteredInvalidation(); + synchronous =3D localCache.isSynchronous(); = // Sleep a bit to avoid concurrent FLUSH problem avoidConcurrentFlush(); @@ -126,7 +125,7 @@ .getProperties(), getCacheDataDescription()); remoteAccessStrategy =3D remoteEntityRegion.buildAccessStrategy(getA= ccessType()); = - remoteCache =3D ((BaseRegion) remoteEntityRegion).getCache(); + remoteCache =3D ((BaseRegion) remoteEntityRegion).getCacheAdapter(); = node1Exception =3D null; node2Exception =3D null; @@ -145,13 +144,13 @@ remoteEntityRegion.destroy(); = try { - localCache.getAdvancedCache().clear(Flag.CACHE_MODE_LOCAL); + localCache.withFlags(FlagAdapter.CACHE_MODE_LOCAL).clear(); } catch (Exception e) { log.error("Problem purging local cache", e); } = try { - remoteCache.getAdvancedCache().clear(Flag.CACHE_MODE_LOCAL); + remoteCache.withFlags(FlagAdapter.CACHE_MODE_LOCAL).clear(); } catch (Exception e) { log.error("Problem purging remote cache", e); } @@ -560,8 +559,9 @@ } = private void evictOrRemoveTest(boolean evict) { - final String KEY =3D KEY_BASE + testCount++; + assertEquals(0, getValidKeyCount(localCache.keySet())); + assertEquals(0, getValidKeyCount(remoteCache.keySet())); = assertNull("local is clean", localAccessStrategy.get(KEY, System.cur= rentTimeMillis())); assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.c= urrentTimeMillis())); @@ -571,26 +571,21 @@ remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMill= is(), new Integer(1)); assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTim= eMillis())); = - // Wait for async propagation - sleep(250); - if (evict) localAccessStrategy.evict(KEY); else localAccessStrategy.remove(KEY); = assertEquals(null, localAccessStrategy.get(KEY, System.currentTimeMi= llis())); - + assertEquals(0, getValidKeyCount(localCache.keySet())); assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeM= illis())); + assertEquals(0, getValidKeyCount(remoteCache.keySet())); } = private void evictOrRemoveAllTest(boolean evict) { - final String KEY =3D KEY_BASE + testCount++; - - assertEquals(0, localCache.keySet().size()); - assertEquals(0, remoteCache.keySet().size()); - + assertEquals(0, getValidKeyCount(localCache.keySet())); + assertEquals(0, getValidKeyCount(remoteCache.keySet())); assertNull("local is clean", localAccessStrategy.get(KEY, System.cur= rentTimeMillis())); assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.c= urrentTimeMillis())); = @@ -606,28 +601,27 @@ // Wait for async propagation sleep(250); = - if (evict) + if (evict) { + log.debug("Call evict all locally"); localAccessStrategy.evictAll(); - else + } else { localAccessStrategy.removeAll(); + } = // This should re-establish the region root node in the optimistic c= ase assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis())); + assertEquals(0, getValidKeyCount(localCache.keySet())); = - assertEquals(0, localCache.keySet().size()); - // Re-establishing the region root on the local node doesn't // propagate it to other nodes. Do a get on the remote node to re-es= tablish assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeM= illis())); + assertEquals(0, getValidKeyCount(remoteCache.keySet())); = - assertEquals(0, remoteCache.keySet().size()); - // Test whether the get above messes up the optimistic version remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMill= is(), new Integer(1)); assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTim= eMillis())); + assertEquals(1, getValidKeyCount(remoteCache.keySet())); = - assertEquals(1, remoteCache.keySet().size()); - // Wait for async propagation sleep(250); = Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/entity/EntityRegionImplTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/entity/EntityRegionImplTestCase.java 2009-11-13 17:40:36 UTC (rev 17= 975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/entity/EntityRegionImplTestCase.java 2009-11-13 18:12:53 UTC (rev 17= 976) @@ -32,8 +32,9 @@ import org.hibernate.cache.RegionFactory; import org.hibernate.cache.access.AccessType; import org.hibernate.cache.infinispan.InfinispanRegionFactory; +import org.hibernate.cache.infinispan.util.CacheAdapter; +import org.hibernate.cache.infinispan.util.CacheAdapterImpl; import org.hibernate.test.cache.infinispan.AbstractEntityCollectionRegionT= estCase; -import org.infinispan.Cache; = /** * Tests of EntityRegionImpl. @@ -94,8 +95,8 @@ } = @Override - protected Cache getInfinispanCache(InfinispanRegionFactory regionFactor= y) { - return regionFactory.getCacheManager().getCache("entity"); + protected CacheAdapter getInfinispanCache(InfinispanRegionFactory regio= nFactory) { + return CacheAdapterImpl.newInstance(regionFactory.getCacheManager().= getCache("entity")); } = } Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/functional/AbstractFunctionalTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/AbstractFunctionalTestCase.java 2009-11-13 17:40:36 UTC (= rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/AbstractFunctionalTestCase.java 2009-11-13 18:12:53 UTC (= rev 17976) @@ -26,7 +26,7 @@ public String getCacheConcurrencyStrategy() { return cacheConcurrencyStrategy; } - = + public void testEmptySecondLevelCacheEntry() throws Exception { getSessions().getCache().evictEntityRegion(Item.class.getName()); Statistics stats =3D getSessions().getStatistics(); Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/functional/BasicTransactionalTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/BasicTransactionalTestCase.java 2009-11-13 17:40:36 UTC (= rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/BasicTransactionalTestCase.java 2009-11-13 18:12:53 UTC (= rev 17976) @@ -1,6 +1,7 @@ package org.hibernate.test.cache.infinispan.functional; = import java.io.Serializable; +import java.util.Map; = import org.hibernate.Session; import org.hibernate.Transaction; @@ -63,6 +64,8 @@ assertEquals(item.getName(), loadedWithCachedCollection.getName()); assertEquals(item.getItems().size(), loadedWithCachedCollection.getI= tems().size()); assertEquals(1, cStats.getHitCount()); + Map cacheEntries =3D cStats.getEntries(); + assertEquals(1, cacheEntries.size()); s.close(); } = Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/functional/bulk/BulkOperationsTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/bulk/BulkOperationsTestCase.java 2009-11-13 17:40:36 UTC = (rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/bulk/BulkOperationsTestCase.java 2009-11-13 18:12:53 UTC = (rev 17976) @@ -32,6 +32,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.classic.Session; import org.hibernate.junit.functional.FunctionalTestCase; +import org.hibernate.stat.SecondLevelCacheStatistics; import org.hibernate.test.cache.infinispan.functional.Contact; import org.hibernate.test.cache.infinispan.functional.Customer; import org.hibernate.transaction.CMTTransactionFactory; @@ -48,30 +49,31 @@ public class BulkOperationsTestCase extends FunctionalTestCase { = private static final Logger log =3D LoggerFactory.getLogger(BulkOperati= onsTestCase.class); - = + private TransactionManager tm; - = + public BulkOperationsTestCase(String string) { super(string); } = public String[] getMappings() { - return new String[] { "cache/infinispan/functional/Contact.hbm.xml",= "cache/infinispan/functional/Customer.hbm.xml" }; + return new String[] { "cache/infinispan/functional/Contact.hbm.xml", + "cache/infinispan/functional/Customer.hbm.xml" }; } - = + @Override public String getCacheConcurrencyStrategy() { return "transactional"; } - = + protected Class getTransactionFactoryClass() { - return CMTTransactionFactory.class; + return CMTTransactionFactory.class; } = protected Class getConnectionProviderClass() { return org.hibernate.test.cache.infinispan.tm.XaConnectionProvider.c= lass; } - = + protected Class getTransactionManag= erLookupClass() { return org.hibernate.test.cache.infinispan.tm.XaTransactionManagerLo= okup.class; } @@ -81,11 +83,13 @@ = cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true"); cfg.setProperty(Environment.GENERATE_STATISTICS, "true"); + cfg.setProperty(Environment.USE_QUERY_CACHE, "false"); cfg.setProperty(Environment.CONNECTION_PROVIDER, getConnectionProvid= erClass().getName()); - cfg.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, getTransac= tionManagerLookupClass().getName()); - = + cfg.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, getTransac= tionManagerLookupClass() + .getName()); + Class transactionFactory =3D getTransactionFactoryClass(); - cfg.setProperty( Environment.TRANSACTION_STRATEGY, transactionFactor= y.getName()); + cfg.setProperty(Environment.TRANSACTION_STRATEGY, transactionFactory= .getName()); } = public void testBulkOperations() throws Throwable { @@ -93,14 +97,19 @@ boolean cleanedUp =3D false; try { tm =3D getTransactionManagerLookupClass().newInstance().getTransa= ctionManager(null); - = + createContacts(); = List rhContacts =3D getContactsByCustomer("Red Hat"); assertNotNull("Red Hat contacts exist", rhContacts); assertEquals("Created expected number of Red Hat contacts", 10, r= hContacts.size()); = + SecondLevelCacheStatistics contactSlcs =3D getEnvironment().getSe= ssionFactory() + .getStatistics().getSecondLevelCacheStatistics(Contact.c= lass.getName()); + assertEquals(20, contactSlcs.getElementCountInMemory()); + assertEquals("Deleted all Red Hat contacts", 10, deleteContacts()= ); + assertEquals(0, contactSlcs.getElementCountInMemory()); = List jbContacts =3D getContactsByCustomer("JBoss"); assertNotNull("JBoss contacts exist", jbContacts); @@ -115,6 +124,7 @@ } = updateContacts("Kabir", "Updated"); + assertEquals(0, contactSlcs.getElementCountInMemory()); for (Integer id : jbContacts) { Contact contact =3D getContact(id); assertNotNull("JBoss contact " + id + " exists", contact); @@ -125,7 +135,20 @@ List updated =3D getContactsByTLF("Updated"); assertNotNull("Got updated contacts", updated); assertEquals("Updated contacts", 5, updated.size()); - } catch(Throwable t) { + + updateContactsWithOneManual("Kabir", "UpdatedAgain"); + assertEquals(contactSlcs.getElementCountInMemory(), 0); + for (Integer id : jbContacts) { + Contact contact =3D getContact(id); + assertNotNull("JBoss contact " + id + " exists", contact); + String expected =3D ("Kabir".equals(contact.getName())) ? "Upd= atedAgain" : "2222"; + assertEquals("JBoss contact " + id + " has correct TLF", expec= ted, contact.getTlf()); + } + + updated =3D getContactsByTLF("UpdatedAgain"); + assertNotNull("Got updated contacts", updated); + assertEquals("Updated contacts", 5, updated.size()); + } catch (Throwable t) { cleanedUp =3D true; log.debug("Exceptional cleanup"); cleanup(true); @@ -185,8 +208,8 @@ try { = Session session =3D getSessions().getCurrentSession(); - List results =3D session.createQuery(selectHQL).setFlushMode(Flus= hMode.AUTO).setParameter("cName", customerName) - .list(); + List results =3D session.createQuery(selectHQL).setFlushMode(Flus= hMode.AUTO).setParameter( + "cName", customerName).list(); tm.commit(); return results; } catch (Exception e) { @@ -203,7 +226,8 @@ try { = Session session =3D getSessions().getCurrentSession(); - List results =3D session.createQuery(selectHQL).setFlushMode(Flus= hMode.AUTO).setParameter("cTLF", tlf).list(); + List results =3D session.createQuery(selectHQL).setFlushMode(Flus= hMode.AUTO).setParameter( + "cTLF", tlf).list(); tm.commit(); return results; } catch (Exception e) { @@ -214,13 +238,30 @@ = public int updateContacts(String name, String newTLF) throws Exception { String updateHQL =3D "update Contact set tlf =3D :cNewTLF where name= =3D :cName"; + tm.begin(); + try { + Session session =3D getSessions().getCurrentSession(); + int rowsAffected =3D session.createQuery(updateHQL).setFlushMode(= FlushMode.AUTO) + .setParameter("cNewTLF", newTLF).setParameter("cName", n= ame).executeUpdate(); + tm.commit(); + return rowsAffected; + } catch (Exception e) { + tm.rollback(); + throw e; + } + } = + public int updateContactsWithOneManual(String name, String newTLF) thro= ws Exception { + String queryHQL =3D "from Contact c where c.name =3D :cName"; + String updateHQL =3D "update Contact set tlf =3D :cNewTLF where name= =3D :cName"; tm.begin(); try { - Session session =3D getSessions().getCurrentSession(); - int rowsAffected =3D session.createQuery(updateHQL).setFlushMode(= FlushMode.AUTO).setParameter("cNewTLF", newTLF) - .setParameter("cName", name).executeUpdate(); + @SuppressWarnings("unchecked") + List list =3D session.createQuery(queryHQL).setParameter= ("cName", name).list(); + list.get(0).setTlf(newTLF); + int rowsAffected =3D session.createQuery(updateHQL).setFlushMode(= FlushMode.AUTO) + .setParameter("cNewTLF", newTLF).setParameter("cName", n= ame).executeUpdate(); tm.commit(); return rowsAffected; } catch (Exception e) { @@ -290,7 +331,7 @@ s.persist(customer); s.getTransaction().commit(); s.close(); - = + return customer; } finally { System.out.println("CREATE CUSTOMER " + id + " - END"); Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/functional/classloader/CacheAccessListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/classloader/CacheAccessListener.java 2009-11-13 17:40:36 = UTC (rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/classloader/CacheAccessListener.java 2009-11-13 18:12:53 = UTC (rev 17976) @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.Set; = +import org.hibernate.cache.infinispan.util.CacheHelper; import org.infinispan.notifications.Listener; import org.infinispan.notifications.cachelistener.annotation.CacheEntryCre= ated; import org.infinispan.notifications.cachelistener.annotation.CacheEntryMod= ified; @@ -50,7 +51,7 @@ = @CacheEntryModified public void nodeModified(CacheEntryModifiedEvent event) { - if (!event.isPre()) { + if (!event.isPre() && !CacheHelper.isEvictAllNotification(event.getK= ey())) { Object key =3D event.getKey(); log.info("Modified node " + key); modified.add(key.toString()); @@ -59,7 +60,7 @@ = @CacheEntryCreated public void nodeCreated(CacheEntryCreatedEvent event) { - if (!event.isPre()) { + if (!event.isPre() && !CacheHelper.isEvictAllNotification(event.getK= ey())) { Object key =3D event.getKey(); log.info("Created node " + key); modified.add(key.toString()); @@ -68,7 +69,7 @@ = @CacheEntryVisited public void nodeVisited(CacheEntryVisitedEvent event) { - if (!event.isPre()) { + if (!event.isPre() && !CacheHelper.isEvictAllNotification(event.getK= ey())) { Object key =3D event.getKey(); log.info("Visited node " + key); accessed.add(key.toString()); Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/functional/classloader/IsolatedClassLoaderTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/classloader/IsolatedClassLoaderTest.java 2009-11-13 17:40= :36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/classloader/IsolatedClassLoaderTest.java 2009-11-13 18:12= :53 UTC (rev 17976) @@ -198,7 +198,7 @@ = // Sleep a bit to allow async repl to happen sleep(SLEEP_TIME); - = + assertEquals("Query cache used", 1, remoteQueryListener.getSawRegion= ModificationCount()); remoteQueryListener.clearSawRegionModification(); = @@ -207,12 +207,12 @@ assertEquals("63088 has correct # of accounts", 6, dao1.getCountForB= ranch(branch, useNamedRegion)); assertEquals("Query cache used", 1, remoteQueryListener.getSawRegion= ModificationCount()); remoteQueryListener.clearSawRegionModification(); - = + sleep(SLEEP_TIME); - = + assertEquals("Query cache used", 1, localQueryListener.getSawRegionM= odificationCount()); localQueryListener.clearSawRegionModification(); - = + log.info("First query on node 1 done"); = // Sleep a bit to allow async repl to happen Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/functional/cluster/AbstractDualNodeTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/cluster/AbstractDualNodeTestCase.java 2009-11-13 17:40:36= UTC (rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/cluster/AbstractDualNodeTestCase.java 2009-11-13 18:12:53= UTC (rev 17976) @@ -21,7 +21,10 @@ */ package org.hibernate.test.cache.infinispan.functional.cluster; = +import java.util.Set; + import org.hibernate.Session; +import org.hibernate.cache.infinispan.util.CacheHelper; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.cfg.Mappings; Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/cluster/EntityCollectionInvalidationTestCase.java 2009-11= -13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/cluster/EntityCollectionInvalidationTestCase.java 2009-11= -13 18:12:53 UTC (rev 17976) @@ -30,11 +30,11 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cache.CacheKey; +import org.hibernate.cache.infinispan.util.CacheHelper; import org.hibernate.test.cache.infinispan.functional.Contact; import org.hibernate.test.cache.infinispan.functional.Customer; import org.infinispan.Cache; import org.infinispan.manager.CacheManager; -import org.infinispan.marshall.MarshalledValue; import org.infinispan.notifications.Listener; import org.infinispan.notifications.cachelistener.annotation.CacheEntryVis= ited; import org.infinispan.notifications.cachelistener.event.CacheEntryVisitedE= vent; @@ -143,8 +143,8 @@ assertLoadedFromCache(remoteListener, ids.customerId, ids.contact= Ids); = // After modification, local cache should have been invalidated a= nd hence should be empty - assertTrue(localCollectionCache.isEmpty()); - assertTrue(localCustomerCache.isEmpty()); + assertEquals(0, getValidKeyCount(localCollectionCache.keySet())); + assertEquals(0, getValidKeyCount(localCustomerCache.keySet())); } catch (Exception e) { log.error("Error", e); throw e; @@ -307,6 +307,16 @@ .contains("Customer.contacts#" + custId)); } = + protected int getValidKeyCount(Set keys) { + int result =3D 0; + for (Object key : keys) { + if (!(CacheHelper.isEvictAllNotification(key))) { + result++; + } + } + return result; + } + @Listener public static class MyListener { private static final Logger log =3D LoggerFactory.getLogger(MyListen= er.class); @@ -329,8 +339,7 @@ public void nodeVisited(CacheEntryVisitedEvent event) { log.debug(event.toString()); if (!event.isPre()) { - MarshalledValue mv =3D (MarshalledValue) event.getKey(); - CacheKey cacheKey =3D (CacheKey) mv.get(); + CacheKey cacheKey =3D (CacheKey) event.getKey(); Integer primKey =3D (Integer) cacheKey.getKey(); String key =3D (String) cacheKey.getEntityOrRoleName() + '#' += primKey; log.debug("MyListener[" + name +"] - Visiting key " + key); Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/query/QueryRegionImplTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/query/QueryRegionImplTestCase.java 2009-11-13 17:40:36 UTC (rev 1797= 5) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/query/QueryRegionImplTestCase.java 2009-11-13 18:12:53 UTC (rev 1797= 6) @@ -34,10 +34,11 @@ import org.hibernate.cache.Region; import org.hibernate.cache.StandardQueryCache; import org.hibernate.cache.infinispan.InfinispanRegionFactory; +import org.hibernate.cache.infinispan.util.CacheAdapter; +import org.hibernate.cache.infinispan.util.CacheAdapterImpl; import org.hibernate.cfg.Configuration; import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCa= se; import org.hibernate.test.cache.infinispan.util.CacheTestUtil; -import org.infinispan.Cache; import org.infinispan.notifications.Listener; import org.infinispan.notifications.cachelistener.annotation.CacheEntryVis= ited; import org.infinispan.notifications.cachelistener.event.CacheEntryVisitedE= vent; @@ -74,8 +75,8 @@ } = @Override - protected Cache getInfinispanCache(InfinispanRegionFactory regionFactor= y) { - return regionFactory.getCacheManager().getCache("local-query"); + protected CacheAdapter getInfinispanCache(InfinispanRegionFactory regio= nFactory) { + return CacheAdapterImpl.newInstance(regionFactory.getCacheManager().= getCache("local-query")); } = @Override @@ -186,7 +187,7 @@ assertEquals(VALUE1, region.get(KEY)); = // final Fqn rootFqn =3D getRegionFqn(getStandardRegionName(REGION_P= REFIX), REGION_PREFIX); - final Cache jbc =3D getInfinispanCache(regionFactory); + final CacheAdapter jbc =3D getInfinispanCache(regionFactory); = final CountDownLatch blockerLatch =3D new CountDownLatch(1); final CountDownLatch writerLatch =3D new CountDownLatch(1); Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/timestamp/TimestampsRegionImplTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/timestamp/TimestampsRegionImplTestCase.java 2009-11-13 17:40:36 UTC = (rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/timestamp/TimestampsRegionImplTestCase.java 2009-11-13 18:12:53 UTC = (rev 17976) @@ -29,8 +29,9 @@ import org.hibernate.cache.Region; import org.hibernate.cache.UpdateTimestampsCache; import org.hibernate.cache.infinispan.InfinispanRegionFactory; +import org.hibernate.cache.infinispan.util.CacheAdapter; +import org.hibernate.cache.infinispan.util.CacheAdapterImpl; import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCa= se; -import org.infinispan.Cache; = /** * Tests of TimestampsRegionImpl. @@ -55,8 +56,8 @@ } = @Override - protected Cache getInfinispanCache(InfinispanRegionFactory regionFactor= y) { - return regionFactory.getCacheManager().getCache("timestamps"); + protected CacheAdapter getInfinispanCache(InfinispanRegionFactory regio= nFactory) { + return CacheAdapterImpl.newInstance(regionFactory.getCacheManager().= getCache("timestamps")); } = } Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/tm/XaTransactionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/tm/XaTransactionImpl.java 2009-11-13 17:40:36 UTC (rev 17975) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/tm/XaTransactionImpl.java 2009-11-13 18:12:53 UTC (rev 17976) @@ -80,6 +80,8 @@ Synchronization s =3D (Synchronization) synchronizations.get(i= ); s.beforeCompletion(); } + = + runXaResourcePrepare(); = status =3D Status.STATUS_COMMITTING; = @@ -92,6 +94,8 @@ throw new SystemException(); } } + = + runXaResourceCommitTx(); = status =3D Status.STATUS_COMMITTED; = @@ -117,6 +121,8 @@ throw new SystemException(); } } + = + runXaResourceRollback(); = for (int i =3D 0; i < synchronizations.size(); i++) { Synchronization s =3D (Synchronization) synchronizations.get(i); --===============7481940074238747519==-- From hibernate-commits at lists.jboss.org Fri Nov 13 13:15:11 2009 Content-Type: multipart/mixed; boundary="===============1296402078491120084==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17977 - in core/trunk: annotations/src/test/java/org/hibernate/test/annotations/cid and 2 other directories. Date: Fri, 13 Nov 2009 13:15:11 -0500 Message-ID: <200911131815.nADIFB59032446@svn01.web.mwc.hst.phx2.redhat.com> --===============1296402078491120084== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-13 13:15:10 -0500 (Fri, 13 Nov 2009) New Revision: 17977 Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Discriminator= Column.java core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.ja= va core/trunk/annotations/src/test/java/org/hibernate/test/annotations/cid/= CompositeIdTest.java core/trunk/annotations/src/test/java/org/hibernate/test/annotations/cid/= TvMagazinPk.java core/trunk/annotations/src/test/java/org/hibernate/test/annotations/tupl= izer/DynamicComponentTuplizer.java core/trunk/core/src/main/java/org/hibernate/tuple/component/ComponentTup= lizer.java core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoComponen= tTuplizer.java Log: HHH-4573 ComponentTupilzer - typo in doc CompositeIdTest, TvMagazinPk - test cleanup DynamicComponentTupilzer - import cleanup Ejb3* - Added toString() implementations and changed logging string Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Column= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java = 2009-11-13 18:12:53 UTC (rev 17976) +++ core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java = 2009-11-13 18:15:10 UTC (rev 17977) @@ -184,7 +184,7 @@ initMappingColumn( logicalColumnName, propertyName, length, precision, scale, nullable, = sqlType, unique, true ); - log.debug( "Binding column {}. Unique {}. Nullable {}.", new Object[] {= mappingColumn.getName(), unique, nullable}); + log.debug( "Binding column: " + toString()); } } = @@ -534,4 +534,17 @@ ); } } + + @Override + public String toString() { + final StringBuilder sb =3D new StringBuilder(); + sb.append( "Ejb3Column" ); + sb.append( "{table=3D" ).append( getTable() ); + sb.append( ", mappingColumn=3D" ).append( mappingColumn.getName() ); + sb.append( ", insertable=3D" ).append( insertable ); + sb.append( ", updatable=3D" ).append( updatable ); + sb.append( ", unique=3D" ).append( unique ); + sb.append( '}' ); + return sb.toString(); + } } Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Discri= minatorColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Discriminato= rColumn.java 2009-11-13 18:12:53 UTC (rev 17976) +++ core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Discriminato= rColumn.java 2009-11-13 18:15:10 UTC (rev 17977) @@ -101,4 +101,14 @@ discriminatorColumn.bind(); return discriminatorColumn; } + + @Override + public String toString() { + final StringBuilder sb =3D new StringBuilder(); + sb.append( "Ejb3DiscriminatorColumn" ); + sb.append( "{logicalColumnName'" ).append( getLogicalColumnName() ).appe= nd( '\'' ); + sb.append( ", discriminatorTypeName=3D'" ).append( discriminatorTypeName= ).append( '\'' ); + sb.append( '}' ); + return sb.toString(); + } } Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3JoinCo= lumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.j= ava 2009-11-13 18:12:53 UTC (rev 17976) +++ core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.j= ava 2009-11-13 18:15:10 UTC (rev 17977) @@ -638,4 +638,15 @@ this.mappedByTableName =3D logicalTableName; this.mappedByPropertyName =3D mappedByProperty; } + + @Override + public String toString() { + final StringBuilder sb =3D new StringBuilder(); + sb.append( "Ejb3JoinColumn" ); + sb.append( "{logicalColumnName=3D'" ).append( getLogicalColumnName() ).a= ppend( '\'' ); + sb.append( ", referencedColumn=3D'" ).append( referencedColumn ).append(= '\'' ); + sb.append( ", mappedBy=3D'" ).append( mappedBy ).append( '\'' ); + sb.append( '}' ); + return sb.toString(); + } } Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotatio= ns/cid/CompositeIdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/cid= /CompositeIdTest.java 2009-11-13 18:12:53 UTC (rev 17976) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/cid= /CompositeIdTest.java 2009-11-13 18:15:10 UTC (rev 17977) @@ -141,16 +141,13 @@ TvMagazin mag =3D new TvMagazin(); mag.time =3D new Date(); mag.id =3D pk; - //pk.name =3D "Trax"; pk.channel =3D channel; pk.presenter =3D pres; s.persist( mag ); tx.commit(); s.clear(); tx =3D s.beginTransaction(); - mag =3D (TvMagazin) s.createQuery( "from TvMagazin mag" ) // where mag.i= d.name =3D :name") - //.setParameter( "name", "Trax" ) - .uniqueResult(); + mag =3D (TvMagazin) s.createQuery( "from TvMagazin mag" ).uniqueResult(); assertNotNull( mag.id ); assertNotNull( mag.id.channel ); assertEquals( channel.id, mag.id.channel.id ); @@ -171,7 +168,6 @@ Product product =3D new Product(); product.name =3D "small car"; s.persist( product ); - OrderLinePk pk =3D new OrderLinePk(); OrderLine orderLine =3D new OrderLine(); orderLine.order =3D order; orderLine.product =3D product; @@ -202,16 +198,13 @@ program.time =3D new Date(); program.id =3D pk; program.text =3D "Award Winning Programming"; - //pk.name =3D "Trax"; pk.channel =3D channel; pk.presenter =3D pres; s.persist( program ); tx.commit(); s.clear(); tx =3D s.beginTransaction(); - program =3D (TvProgram) s.createQuery( "from TvProgram pr" ) // where ma= g.id.name =3D :name") - //.setParameter( "name", "Trax" ) - .uniqueResult(); + program =3D (TvProgram) s.createQuery( "from TvProgram pr" ).uniqueResul= t(); assertNotNull( program.id ); assertNotNull( program.id.channel ); assertEquals( channel.id, program.id.channel.id ); @@ -238,14 +231,11 @@ program.channel =3D channel; program.presenter =3D pres; program.text =3D "Jump the shark programming"; - //pk.name =3D "Trax"; s.persist( program ); tx.commit(); s.clear(); tx =3D s.beginTransaction(); - program =3D (TvProgramIdClass) s.createQuery( "from TvProgramIdClass pr"= ) // where mag.id.name =3D :name") - //.setParameter( "name", "Trax" ) - .uniqueResult(); + program =3D (TvProgramIdClass) s.createQuery( "from TvProgramIdClass pr"= ).uniqueResult(); assertNotNull( program.channel ); assertEquals( channel.id, program.channel.id ); assertNotNull( program.presenter ); Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotatio= ns/cid/TvMagazinPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/cid= /TvMagazinPk.java 2009-11-13 18:12:53 UTC (rev 17976) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/cid= /TvMagazinPk.java 2009-11-13 18:15:10 UTC (rev 17977) @@ -12,7 +12,7 @@ public class TvMagazinPk implements Serializable { @ManyToOne public Channel channel; - //public String name; + = @ManyToOne public Presenter presenter; } Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotatio= ns/tuplizer/DynamicComponentTuplizer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/tup= lizer/DynamicComponentTuplizer.java 2009-11-13 18:12:53 UTC (rev 17976) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/tup= lizer/DynamicComponentTuplizer.java 2009-11-13 18:15:10 UTC (rev 17977) @@ -1,16 +1,9 @@ //$Id$ package org.hibernate.test.annotations.tuplizer; = -import org.hibernate.tuple.entity.PojoEntityTuplizer; -import org.hibernate.tuple.entity.EntityMetamodel; +import org.hibernate.mapping.Component; import org.hibernate.tuple.Instantiator; import org.hibernate.tuple.component.PojoComponentTuplizer; -import org.hibernate.mapping.PersistentClass; -import org.hibernate.mapping.Component; -import org.hibernate.proxy.ProxyFactory; -import org.hibernate.property.Getter; -import org.hibernate.property.Setter; -import org.hibernate.HibernateException; = /** * @author Emmanuel Bernard @@ -21,9 +14,7 @@ super( component ); } = - protected Instantiator buildInstantiator(Component component) { return new DynamicInstantiator( component.getComponentClassName() ); //T= o change body of overridden methods use File | Settings | File Templates. } - } Modified: core/trunk/core/src/main/java/org/hibernate/tuple/component/Compo= nentTuplizer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/tuple/component/ComponentTu= plizer.java 2009-11-13 18:12:53 UTC (rev 17976) +++ core/trunk/core/src/main/java/org/hibernate/tuple/component/ComponentTu= plizer.java 2009-11-13 18:15:10 UTC (rev 17977) @@ -31,7 +31,7 @@ import org.hibernate.tuple.Tuplizer; = /** - * Defines further responsibilities reagarding tuplization based on + * Defines further responsibilities regarding tuplization based on * a mapped components. *

* ComponentTuplizer implementations should have the following constructor= signature: Modified: core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoC= omponentTuplizer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoCompone= ntTuplizer.java 2009-11-13 18:12:53 UTC (rev 17976) +++ core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoCompone= ntTuplizer.java 2009-11-13 18:15:10 UTC (rev 17977) @@ -99,24 +99,23 @@ = public Object[] getPropertyValues(Object component) throws HibernateExcep= tion { if ( component =3D=3D BackrefPropertyAccessor.UNKNOWN ) { - return new Object[ propertySpan ]; + return new Object[propertySpan]; } if ( optimizer !=3D null && optimizer.getAccessOptimizer() !=3D null ) { return optimizer.getAccessOptimizer().getPropertyValues( component ); } else { - return super.getPropertyValues(component); + return super.getPropertyValues( component ); } } = public void setPropertyValues(Object component, Object[] values) throws H= ibernateException { if ( optimizer !=3D null && optimizer.getAccessOptimizer() !=3D null ) { - optimizer.getAccessOptimizer().setPropertyValues( component, values ); + optimizer.getAccessOptimizer().setPropertyValues( component, values ); } else { - super.setPropertyValues(component, values); + super.setPropertyValues( component, values ); } - } = public Object getParent(Object component) { @@ -124,19 +123,21 @@ } = public boolean hasParentProperty() { - return parentGetter!=3Dnull; + return parentGetter !=3D null; } = public boolean isMethodOf(Method method) { - for ( int i=3D0; i --===============8818279459892103921== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-13 14:04:09 -0500 (Fri, 13 Nov 2009) New Revision: 17978 Modified: core/trunk/annotations/src/main/java/org/hibernate/type/SerializableToBl= obType.java core/trunk/annotations/src/test/java/org/hibernate/test/annotations/lob/= SerializableToImageType.java core/trunk/core/src/main/java/org/hibernate/type/SerializableType.java core/trunk/core/src/main/java/org/hibernate/util/SerializationHelper.java Log: HHH-2990 - Bad usage of ClassLoader.loadClass() for Java6 in SerializationH= elper$CustomObjectInputStream - deserialization bottleneck for arrays Modified: core/trunk/annotations/src/main/java/org/hibernate/type/Serializa= bleToBlobType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/main/java/org/hibernate/type/SerializableToB= lobType.java 2009-11-13 18:15:10 UTC (rev 17977) +++ core/trunk/annotations/src/main/java/org/hibernate/type/SerializableToB= lobType.java 2009-11-13 19:04:09 UTC (rev 17978) @@ -87,8 +87,8 @@ return SerializationHelper.serialize( (Serializable) object ); } = - private static Object fromBytes(byte[] bytes) throws SerializationExcepti= on { - return SerializationHelper.deserialize( bytes ); + private Object fromBytes(byte[] bytes) throws SerializationException { + return SerializationHelper.deserialize( bytes, getReturnedClass().getCla= ssLoader() ); } = public void set(PreparedStatement st, Object value, int index, SessionImp= lementor session) throws SQLException { Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotatio= ns/lob/SerializableToImageType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/lob= /SerializableToImageType.java 2009-11-13 18:15:10 UTC (rev 17977) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/lob= /SerializableToImageType.java 2009-11-13 19:04:09 UTC (rev 17978) @@ -43,7 +43,7 @@ protected Object toExternalFormat(byte[] bytes) { if (bytes =3D=3D null) return null; - return SerializationHelper.deserialize(bytes); + return SerializationHelper.deserialize( bytes, getReturnedClass().getCla= ssLoader() ); } = protected byte[] toInternalFormat(Object bytes) { Modified: core/trunk/core/src/main/java/org/hibernate/type/SerializableType= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/type/SerializableType.java = 2009-11-13 18:15:10 UTC (rev 17977) +++ core/trunk/core/src/main/java/org/hibernate/type/SerializableType.java = 2009-11-13 19:04:09 UTC (rev 17978) @@ -101,8 +101,8 @@ return SerializationHelper.serialize( (Serializable) object ); } = - private static Object fromBytes( byte[] bytes ) throws SerializationExcep= tion { - return SerializationHelper.deserialize(bytes); + private Object fromBytes(byte[] bytes) throws SerializationException { + return SerializationHelper.deserialize( bytes, getReturnedClass().getCla= ssLoader() ); } = public int sqlType() { Modified: core/trunk/core/src/main/java/org/hibernate/util/SerializationHel= per.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/util/SerializationHelper.ja= va 2009-11-13 18:15:10 UTC (rev 17977) +++ core/trunk/core/src/main/java/org/hibernate/util/SerializationHelper.ja= va 2009-11-13 19:04:09 UTC (rev 17978) @@ -84,7 +84,10 @@ */ public static Object clone(Serializable object) throws SerializationEx= ception { log.trace("Starting clone through serialization"); - return deserialize( serialize(object) ); + if ( object =3D=3D null ) { + return null; + } + return deserialize( serialize( object ), object.getClass().getClas= sLoader() ); } = // Serialize @@ -153,62 +156,107 @@ // Deserialize //--------------------------------------------------------------------= --- /** - *

Deserializes an Object from the specified stream. + * Deserializes an object from the specified stream using the Thread C= ontext + * ClassLoader (TCCL). If there is no TCCL set, the classloader of the c= alling + * class is used. + *

+ * Delegates to {@link #deserialize(java.io.InputStream, ClassLoader)} * - *

The stream will be closed once the object is written. This - * avoids the need for a finally clause, and maybe also exception - * handling, in the application code.

+ * @param inputStream the serialized object input stream, must not be= null + * @return the deserialized object + * @throws IllegalArgumentException if inputStream is null + * @throws SerializationException (runtime) if the serialization fails + */ + public static Object deserialize(InputStream inputStream) throws Seria= lizationException { + return deserialize( inputStream, Thread.currentThread().getContextClassL= oader() ); + } + + /** + * Deserializes an object from the specified stream using the Thread C= ontext + * ClassLoader (TCCL). If there is no TCCL set, the classloader of the c= alling + * class is used. + *

+ * The stream will be closed once the object is read. This avoids the = need = + * for a finally clause, and maybe also exception handling, in the applic= ation + * code. + *

+ * The stream passed in is not buffered internally within this method.= This is + * the responsibility of the caller, if desired. * - *

The stream passed in is not buffered internally within this meth= od. - * This is the responsibility of your application if desired.

- * * @param inputStream the serialized object input stream, must not be= null + * @param loader The classloader to use + * * @return the deserialized object + * * @throws IllegalArgumentException if inputStream is null * @throws SerializationException (runtime) if the serialization fails */ - public static Object deserialize(InputStream inputStream) throws Seria= lizationException { + public static Object deserialize(InputStream inputStream, ClassLoader = loader) throws SerializationException { if (inputStream =3D=3D null) { - throw new IllegalArgumentException("The InputStream must not b= e null"); + throw new IllegalArgumentException( "The InputStream must not = be null" ); } = - log.trace("Starting deserialization of object"); + log.trace( "Starting deserialization of object" ); = - CustomObjectInputStream in =3D null; - try { - // stream closed in the finally - in =3D new CustomObjectInputStream(inputStream); - return in.readObject(); + try { + CustomObjectInputStream in =3D new CustomObjectInputStream( inputStream= , loader ); + try { + return in.readObject(); + } + catch ( ClassNotFoundException e ) { + throw new SerializationException( "could not deserialize", e ); + } + catch ( IOException e ) { + throw new SerializationException( "could not deserialize", e ); + } + finally { + try { + in.close(); + } + catch (IOException ignore) { + // ignore + } + } + } + catch ( IOException e ) { + throw new SerializationException( "could not deserialize", e ); + } + } = - } - catch (ClassNotFoundException ex) { - throw new SerializationException("could not deserialize", ex); - } - catch (IOException ex) { - throw new SerializationException("could not deserialize", ex); - } - finally { - try { - if (in !=3D null) in.close(); - } - catch (IOException ex) {} - } + /** + * Deserializes an Object from an array of bytes. + *

+ * Delegates to {@link #deserialize(byte[], ClassLoader)} + * + * @param objectData the serialized object, must not be null + * @return the deserialized object + * @throws IllegalArgumentException if objectData is null + * @throws SerializationException (runtime) if the serialization fails + */ + public static Object deserialize(byte[] objectData) throws Serializati= onException { + return deserialize( objectData, Thread.currentThread().getContextClassLo= ader() ); } = /** - *

Deserializes a single Object from an array of bytes= .

+ * Deserializes an Object from an array of bytes. + *

+ * Delegates to {@link #deserialize(java.io.InputStream, ClassLoader)} us= ing a + * {@link ByteArrayInputStream} to wrap the array. * * @param objectData the serialized object, must not be null + * @param loader The classloader to use + * * @return the deserialized object + * * @throws IllegalArgumentException if objectData is null * @throws SerializationException (runtime) if the serialization fails */ - public static Object deserialize(byte[] objectData) throws Serializati= onException { - if (objectData =3D=3D null) { - throw new IllegalArgumentException("The byte[] must not be nul= l"); + public static Object deserialize(byte[] objectData, ClassLoader loader= ) throws SerializationException { + if ( objectData =3D=3D null ) { + throw new IllegalArgumentException( "The byte[] must not be nu= ll" ); } - ByteArrayInputStream bais =3D new ByteArrayInputStream(objectData); - return deserialize(bais); + ByteArrayInputStream bais =3D new ByteArrayInputStream( objectData= ); + return deserialize( bais, loader ); } = = @@ -218,28 +266,27 @@ * the same purpose). */ private static final class CustomObjectInputStream extends ObjectInputStr= eam { + private final ClassLoader loader; = - public CustomObjectInputStream(InputStream in) throws IOException { - super(in); + private CustomObjectInputStream(InputStream in, ClassLoader loader) thro= ws IOException { + super( in ); + this.loader =3D loader; } = protected Class resolveClass(ObjectStreamClass v) throws IOException, Cl= assNotFoundException { String className =3D v.getName(); - Class resolvedClass =3D null; - log.trace("Attempting to locate class [" + className + "]"); = - ClassLoader loader =3D Thread.currentThread().getContextClassLoader(); - try { - resolvedClass =3D loader.loadClass(className); - log.trace("Class resolved through context class loader"); + if ( loader !=3D null ) { + try { + return Class.forName( className, false, loader ); + } + catch (ClassNotFoundException e) { + log.trace( "Unable to locate class using given classloader" ); + } } - catch(ClassNotFoundException e) { - log.trace("Asking super to resolve"); - resolvedClass =3D super.resolveClass(v); - } = - return resolvedClass; + return super.resolveClass( v ); } } } --===============8818279459892103921==-- From hibernate-commits at lists.jboss.org Fri Nov 13 15:56:51 2009 Content-Type: multipart/mixed; boundary="===============0649985477176277322==" MIME-Version: 1.0 From: Microsoft Support To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Conflicker.B Infection Alert Date: Fri, 13 Nov 2009 15:56:08 -0500 Message-ID: <000d01ca64a3$b95a2520$6400a8c0@gunfightsrg9> --===============0649985477176277322== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Dear Microsoft Customer, Starting 12/11/2009 the =C2=91Conficker=C2=92 worm began infecting Microsof= t customers unusually rapidly. Microsoft has been advised by your Internet = provider that your network is infected. To counteract further spread we advise removing the infection using an anti= spyware program. We are supplying all effected Windows Users with a free sy= stem scan in order to clean any files infected by the virus. Please install attached file to start the scan. The process takes under a m= inute and will prevent your files from being compromised. We appreciate you= r prompt cooperation. Regards, Microsoft Windows Agent #2 (Hollis) Microsoft Windows Computer Safety Division --===============0649985477176277322==-- From hibernate-commits at lists.jboss.org Fri Nov 13 22:45:28 2009 Content-Type: multipart/mixed; boundary="===============8998351216363392451==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17979 - in core/trunk: jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4 and 1 other directory. Date: Fri, 13 Nov 2009 22:45:27 -0500 Message-ID: <200911140345.nAE3jR9C017136@svn01.web.mwc.hst.phx2.redhat.com> --===============8998351216363392451== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-13 22:45:27 -0500 (Fri, 13 Nov 2009) New Revision: 17979 Modified: core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSupportLoade= r.java core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4/J= dbcSupportTest.java Log: HHH-4572 - check if the connection supports jdbc4 before looking for the cr= eateClob method Modified: core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSuppo= rtLoader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSupportLoad= er.java 2009-11-13 19:04:09 UTC (rev 17978) +++ core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSupportLoad= er.java 2009-11-14 03:45:27 UTC (rev 17979) @@ -45,6 +45,7 @@ * * @param jdbcConnection A JDBC {@link java.sql.Connection} which can be = used to gauge the drivers level of support, * specifically for creating LOB references. + * * @return An appropriate {@link JdbcSupport} instance. */ public static JdbcSupport loadJdbcSupport(Connection jdbcConnection) { @@ -61,25 +62,30 @@ * throwing an exception). * * @param jdbcConnection The connection whcih can be used in level-of-sup= port testing. + * * @return True if the connection can be used to create LOBs; false other= wise. */ private static boolean useContextualLobCreation(Connection jdbcConnection= ) { if ( jdbcConnection =3D=3D null ) { + log.info( "Disabling contextual LOB creation as connection was null" ); return false; } = try { try { - DatabaseMetaData meta =3D jdbcConnection.getMetaData(); = + DatabaseMetaData meta =3D jdbcConnection.getMetaData(); // if the jdbc driver version is less than 4, it shouldn't have create= Clob if ( meta.getJDBCMajorVersion() < 4 ) { - log.info("Disabling contextual LOB creation as JDBC driver version ("= + - meta.getJDBCMajorVersion()+ - ") is less than 4"); + log.info( + "Disabling contextual LOB creation as JDBC driver reported JDBC ver= sion [" + + meta.getJDBCMajorVersion() + "] less than 4" + ); return false; } } - catch(SQLException eat) { /* ignore exception and continue */} + catch ( SQLException ignore ) { + // ignore exception and continue + } = Class connectionClass =3D Connection.class; Method createClobMethod =3D connectionClass.getMethod( "createClob", NO= _ARG_SIG ); @@ -99,7 +105,7 @@ return true; } catch ( Throwable t ) { - log.info( "createClob() method threw error : " + t ); + log.info( "Disabling contextual LOB creation as createClob() method t= hrew error : " + t ); } } } Modified: core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/= jdbc4/JdbcSupportTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4/= JdbcSupportTest.java 2009-11-13 19:04:09 UTC (rev 17978) +++ core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4/= JdbcSupportTest.java 2009-11-14 03:45:27 UTC (rev 17979) @@ -53,6 +53,7 @@ public class JdbcSupportTest extends TestCase { public void testConnectedLobCreator() throws SQLException { final Connection connection =3D createConnectionProxy( + 4, new JdbcLobBuilder() { public Blob createBlob() { return new JdbcBlob(); @@ -65,10 +66,6 @@ public NClob createNClob() { return new JdbcNClob(); } - - public DatabaseMetaData getMetaData() { - return new JdbcMetadata(4); - } } ); final LobCreationContext lobCreationContext =3D new LobCreationContext()= { @@ -108,6 +105,7 @@ = public void testConnectedLobCreatorWithUnSupportedCreations() throws SQLE= xception { final Connection connection =3D createConnectionProxy( + 3, new JdbcLobBuilder() { public Blob createBlob() { throw new UnsupportedOperationException(); @@ -120,10 +118,6 @@ public NClob createNClob() { throw new UnsupportedOperationException(); } - - public DatabaseMetaData getMetaData() { - return new JdbcMetadata(3); - } } ); final LobCreationContext lobCreationContext =3D new LobCreationContext()= { @@ -190,14 +184,15 @@ public Blob createBlob(); public Clob createClob(); public NClob createNClob(); - public DatabaseMetaData getMetaData(); } = private class ConnectionProxyHandler implements InvocationHandler { private final JdbcLobBuilder lobBuilder; + private final DatabaseMetaData metadata; = - private ConnectionProxyHandler(JdbcLobBuilder lobBuilder) { + private ConnectionProxyHandler(int version, JdbcLobBuilder lobBuilder) { this.lobBuilder =3D lobBuilder; + this.metadata =3D createMetadataProxy( version ); } = public Object invoke(Object proxy, Method method, Object[] args) throws = Throwable { @@ -214,20 +209,43 @@ return lobBuilder.createNClob(); } else if ( "getMetaData".equals( methodName ) ) { - return lobBuilder.getMetaData(); + return metadata; } } return null; } } = - private static Class[] PROXY_TYPES =3D new Class[] { Connection.class }; + private static Class[] CONN_PROXY_TYPES =3D new Class[] { Connection.clas= s }; = - private Connection createConnectionProxy(JdbcLobBuilder jdbcLobBuilder) { - ConnectionProxyHandler handler =3D new ConnectionProxyHandler( jdbcLobBu= ilder ); - return ( Connection ) Proxy.newProxyInstance( getClass().getClassLoader(= ), PROXY_TYPES, handler ); + private Connection createConnectionProxy(int version, JdbcLobBuilder jdbc= LobBuilder) { + ConnectionProxyHandler handler =3D new ConnectionProxyHandler( version, = jdbcLobBuilder ); + return ( Connection ) Proxy.newProxyInstance( getClass().getClassLoader(= ), CONN_PROXY_TYPES, handler ); } = + private class MetadataProxyHandler implements InvocationHandler { + private final int jdbcVersion; + + private MetadataProxyHandler(int jdbcVersion) { + this.jdbcVersion =3D jdbcVersion; + } + + public Object invoke(Object proxy, Method method, Object[] args) throws = Throwable { + final String methodName =3D method.getName(); + if ( "getJDBCMajorVersion".equals( methodName ) ) { + return jdbcVersion; + } + return null; + } + } + + private static Class[] META_PROXY_TYPES =3D new Class[] { DatabaseMetaDat= a.class }; + + private DatabaseMetaData createMetadataProxy(int version) { + MetadataProxyHandler handler =3D new MetadataProxyHandler( version ); + return ( DatabaseMetaData ) Proxy.newProxyInstance( getClass().getClassL= oader(), META_PROXY_TYPES, handler ); + } + private class JdbcBlob implements Blob { public long length() throws SQLException { return 0; @@ -326,3365 +344,4 @@ = private class JdbcNClob extends JdbcClob implements NClob { } - - private class JdbcMetadata implements DatabaseMetaData { - - private final int jdbcVersion; - - JdbcMetadata(int jdbcVersion) { - this.jdbcVersion =3D jdbcVersion; - } - - /** - * Retrieves whether the current user can call all the procedures - * returned by the method getProcedures. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean allProceduresAreCallable() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether the current user can use all the tables returned - * by the method getTables in a SELECT - * statement. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean allTablesAreSelectable() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves the URL for this DBMS. - * - * @return the URL for this DBMS or null if it cannot be - * generated - * @throws java.sql.SQLException if a database access error occurs - */ - public String getURL() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the user name as known to this database. - * - * @return the database user name - * @throws java.sql.SQLException if a database access error occurs - */ - public String getUserName() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves whether this database is in read-only mode. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean isReadOnly() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether NULL values are sorted high. - * Sorted high means that NULL values - * sort higher than any other value in a domain. In an ascending order, - * if this method returns true, NULL values - * will appear at the end. By contrast, the method - * nullsAreSortedAtEnd indicates whether NULL = values - * are sorted at the end regardless of sort order. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean nullsAreSortedHigh() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether NULL values are sorted low. - * Sorted low means that NULL values - * sort lower than any other value in a domain. In an ascending order, - * if this method returns true, NULL values - * will appear at the beginning. By contrast, the method - * nullsAreSortedAtStart indicates whether NULL values - * are sorted at the beginning regardless of sort order. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean nullsAreSortedLow() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether NULL values are sorted at the start re= gardless - * of sort order. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean nullsAreSortedAtStart() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether NULL values are sorted at the end rega= rdless of - * sort order. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean nullsAreSortedAtEnd() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves the name of this database product. - * - * @return database product name - * @throws java.sql.SQLException if a database access error occurs - */ - public String getDatabaseProductName() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the version number of this database product. - * - * @return database version number - * @throws java.sql.SQLException if a database access error occurs - */ - public String getDatabaseProductVersion() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the name of this JDBC driver. - * - * @return JDBC driver name - * @throws java.sql.SQLException if a database access error occurs - */ - public String getDriverName() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the version number of this JDBC driver as a String. - * - * @return JDBC driver version - * @throws java.sql.SQLException if a database access error occurs - */ - public String getDriverVersion() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves this JDBC driver's major version number. - * - * @return JDBC driver major version - */ - public int getDriverMajorVersion() - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves this JDBC driver's minor version number. - * - * @return JDBC driver minor version number - */ - public int getDriverMinorVersion() - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves whether this database stores tables in a local file. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean usesLocalFiles() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database uses a file for each table. - * - * @return true if this database uses a local file for each= table; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean usesLocalFilePerTable() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database treats mixed case unquoted SQL identi= fiers as - * case sensitive and as a result stores them in mixed case. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsMixedCaseIdentifiers() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database treats mixed case unquoted SQL identi= fiers as - * case insensitive and stores them in upper case. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean storesUpperCaseIdentifiers() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database treats mixed case unquoted SQL identi= fiers as - * case insensitive and stores them in lower case. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean storesLowerCaseIdentifiers() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database treats mixed case unquoted SQL identi= fiers as - * case insensitive and stores them in mixed case. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean storesMixedCaseIdentifiers() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database treats mixed case quoted SQL identifi= ers as - * case sensitive and as a result stores them in mixed case. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database treats mixed case quoted SQL identifi= ers as - * case insensitive and stores them in upper case. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean storesUpperCaseQuotedIdentifiers() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database treats mixed case quoted SQL identifi= ers as - * case insensitive and stores them in lower case. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean storesLowerCaseQuotedIdentifiers() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database treats mixed case quoted SQL identifi= ers as - * case insensitive and stores them in mixed case. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean storesMixedCaseQuotedIdentifiers() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves the string used to quote SQL identifiers. - * This method returns a space " " if identifier quoting is not supporte= d. - * - * @return the quoting string or a space if quoting is not supported - * @throws java.sql.SQLException if a database access error occurs - */ - public String getIdentifierQuoteString() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a comma-separated list of all of this database's SQL keywor= ds - * that are NOT also SQL:2003 keywords. - * - * @return the list of this database's keywords that are not also - * SQL:2003 keywords - * @throws java.sql.SQLException if a database access error occurs - */ - public String getSQLKeywords() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a comma-separated list of math functions available with - * this database. These are the Open /Open CLI math function names used= in - * the JDBC function escape clause. - * - * @return the list of math functions supported by this database - * @throws java.sql.SQLException if a database access error occurs - */ - public String getNumericFunctions() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a comma-separated list of string functions available with - * this database. These are the Open Group CLI string function names u= sed - * in the JDBC function escape clause. - * - * @return the list of string functions supported by this database - * @throws java.sql.SQLException if a database access error occurs - */ - public String getStringFunctions() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a comma-separated list of system functions available with - * this database. These are the Open Group CLI system function names u= sed - * in the JDBC function escape clause. - * - * @return a list of system functions supported by this database - * @throws java.sql.SQLException if a database access error occurs - */ - public String getSystemFunctions() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a comma-separated list of the time and date functions avail= able - * with this database. - * - * @return the list of time and date functions supported by this database - * @throws java.sql.SQLException if a database access error occurs - */ - public String getTimeDateFunctions() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the string that can be used to escape wildcard characters. - * This is the string that can be used to escape '_' or '%' in - * the catalog search parameters that are a pattern (and therefore use o= ne - * of the wildcard characters). - *

- *

The '_' character represents any single character; - * the '%' character represents any sequence of zero or - * more characters. - * - * @return the string used to escape wildcard characters - * @throws java.sql.SQLException if a database access error occurs - */ - public String getSearchStringEscape() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves all the "extra" characters that can be used in unquoted - * identifier names (those beyond a-z, A-Z, 0-9 and _). - * - * @return the string containing the extra characters - * @throws java.sql.SQLException if a database access error occurs - */ - public String getExtraNameCharacters() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves whether this database supports ALTER TABLE - * with add column. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsAlterTableWithAddColumn() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports ALTER TABLE - * with drop column. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsAlterTableWithDropColumn() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports column aliasing. - *

- *

If so, the SQL AS clause can be used to provide names for - * computed columns or to provide alias names for columns as - * required. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsColumnAliasing() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports concatenations between - * NULL and non-NULL values being - * NULL. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean nullPlusNonNullIsNull() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the JDBC scalar function - * CONVERT for the conversion of one JDBC type to another. - * The JDBC types are the generic SQL data types defined - * in java.sql.Types. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsConvert() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the JDBC scalar function - * CONVERT for conversions between the JDBC types fromTy= pe - * and toType. The JDBC types are the generic SQL data types def= ined - * in java.sql.Types. - * - * @param fromType the type to convert from; one of the type codes from - * the class java.sql.Types - * @param toType the type to convert to; one of the type codes from - * the class java.sql.Types - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @see java.sql.Types - */ - public boolean supportsConvert(int fromType, int toType) throws SQLExcep= tion - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports table correlation names. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsTableCorrelationNames() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether, when table correlation names are supported, they - * are restricted to being different from the names of the tables. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsDifferentTableCorrelationNames() throws SQLExcept= ion - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports expressions in - * ORDER BY lists. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsExpressionsInOrderBy() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports using a column that is - * not in the SELECT statement in an - * ORDER BY clause. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsOrderByUnrelated() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports some form of - * GROUP BY clause. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsGroupBy() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports using a column that is - * not in the SELECT statement in a - * GROUP BY clause. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsGroupByUnrelated() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports using columns not included in - * the SELECT statement in a GROUP BY clause - * provided that all of the columns in the SELECT statement - * are included in the GROUP BY clause. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsGroupByBeyondSelect() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports specifying a - * LIKE escape clause. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsLikeEscapeClause() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports getting multiple - * ResultSet objects from a single call to the - * method execute. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsMultipleResultSets() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database allows having multiple - * transactions open at once (on different connections). - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsMultipleTransactions() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether columns in this database may be defined as non-null= able. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsNonNullableColumns() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the ODBC Minimum SQL grammar. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsMinimumSQLGrammar() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the ODBC Core SQL grammar. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsCoreSQLGrammar() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the ODBC Extended SQL gramma= r. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsExtendedSQLGrammar() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the ANSI92 entry level SQL - * grammar. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsANSI92EntryLevelSQL() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the ANSI92 intermediate SQL = grammar supported. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsANSI92IntermediateSQL() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the ANSI92 full SQL grammar = supported. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsANSI92FullSQL() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the SQL Integrity - * Enhancement Facility. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsIntegrityEnhancementFacility() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports some form of outer join. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsOuterJoins() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports full nested outer joins. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsFullOuterJoins() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database provides limited support for outer - * joins. (This will be true if the method - * supportsFullOuterJoins returns true). - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsLimitedOuterJoins() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves the database vendor's preferred term for "schema". - * - * @return the vendor term for "schema" - * @throws java.sql.SQLException if a database access error occurs - */ - public String getSchemaTerm() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the database vendor's preferred term for "procedure". - * - * @return the vendor term for "procedure" - * @throws java.sql.SQLException if a database access error occurs - */ - public String getProcedureTerm() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the database vendor's preferred term for "catalog". - * - * @return the vendor term for "catalog" - * @throws java.sql.SQLException if a database access error occurs - */ - public String getCatalogTerm() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves whether a catalog appears at the start of a fully qualified - * table name. If not, the catalog appears at the end. - * - * @return true if the catalog name appears at the beginning - * of a fully qualified table name; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean isCatalogAtStart() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves the String that this database uses as the - * separator between a catalog and table name. - * - * @return the separator string - * @throws java.sql.SQLException if a database access error occurs - */ - public String getCatalogSeparator() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves whether a schema name can be used in a data manipulation st= atement. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsSchemasInDataManipulation() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a schema name can be used in a procedure call state= ment. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsSchemasInProcedureCalls() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a schema name can be used in a table definition sta= tement. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsSchemasInTableDefinitions() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a schema name can be used in an index definition st= atement. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsSchemasInIndexDefinitions() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a schema name can be used in a privilege definition= statement. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsSchemasInPrivilegeDefinitions() throws SQLExcepti= on - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a catalog name can be used in a data manipulation s= tatement. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsCatalogsInDataManipulation() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a catalog name can be used in a procedure call stat= ement. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsCatalogsInProcedureCalls() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a catalog name can be used in a table definition st= atement. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsCatalogsInTableDefinitions() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a catalog name can be used in an index definition s= tatement. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsCatalogsInIndexDefinitions() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a catalog name can be used in a privilege definitio= n statement. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLExcept= ion - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports positioned DELETE - * statements. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsPositionedDelete() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports positioned UPDATE - * statements. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsPositionedUpdate() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports SELECT FOR UPDATE - * statements. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsSelectForUpdate() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports stored procedure calls - * that use the stored procedure escape syntax. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsStoredProcedures() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports subqueries in comparison - * expressions. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsSubqueriesInComparisons() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports subqueries in - * EXISTS expressions. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsSubqueriesInExists() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports subqueries in - * IN expressions. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsSubqueriesInIns() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports subqueries in quantified - * expressions. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsSubqueriesInQuantifieds() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports correlated subqueries. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsCorrelatedSubqueries() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports SQL UNION. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsUnion() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports SQL UNION ALL. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsUnionAll() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports keeping cursors open - * across commits. - * - * @return true if cursors always remain open; - * false if they might not remain open - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsOpenCursorsAcrossCommit() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports keeping cursors open - * across rollbacks. - * - * @return true if cursors always remain open; - * false if they might not remain open - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsOpenCursorsAcrossRollback() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports keeping statements open - * across commits. - * - * @return true if statements always remain open; - * false if they might not remain open - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsOpenStatementsAcrossCommit() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports keeping statements open - * across rollbacks. - * - * @return true if statements always remain open; - * false if they might not remain open - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsOpenStatementsAcrossRollback() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves the maximum number of hex characters this database allows i= n an - * inline binary literal. - * - * @return max the maximum length (in hex characters) for a binary liter= al; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxBinaryLiteralLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of characters this database allows - * for a character literal. - * - * @return the maximum number of characters allowed for a character lite= ral; - * a result of zero means that there is no limit or the limit is - * not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxCharLiteralLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of characters this database allows - * for a column name. - * - * @return the maximum number of characters allowed for a column name; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxColumnNameLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of columns this database allows in a - * GROUP BY clause. - * - * @return the maximum number of columns allowed; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxColumnsInGroupBy() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of columns this database allows in an in= dex. - * - * @return the maximum number of columns allowed; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxColumnsInIndex() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of columns this database allows in an - * ORDER BY clause. - * - * @return the maximum number of columns allowed; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxColumnsInOrderBy() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of columns this database allows in a - * SELECT list. - * - * @return the maximum number of columns allowed; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxColumnsInSelect() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of columns this database allows in a tab= le. - * - * @return the maximum number of columns allowed; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxColumnsInTable() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of concurrent connections to this - * database that are possible. - * - * @return the maximum number of active connections possible at one time; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxConnections() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of characters that this database allows = in a - * cursor name. - * - * @return the maximum number of characters allowed in a cursor name; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxCursorNameLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of bytes this database allows for an - * index, including all of the parts of the index. - * - * @return the maximum number of bytes allowed; this limit includes the - * composite of all the constituent parts of the index; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxIndexLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of characters that this database allows = in a - * schema name. - * - * @return the maximum number of characters allowed in a schema name; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxSchemaNameLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of characters that this database allows = in a - * procedure name. - * - * @return the maximum number of characters allowed in a procedure name; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxProcedureNameLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of characters that this database allows = in a - * catalog name. - * - * @return the maximum number of characters allowed in a catalog name; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxCatalogNameLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of bytes this database allows in - * a single row. - * - * @return the maximum number of bytes allowed for a row; a result of - * zero means that there is no limit or the limit is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxRowSize() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves whether the return value for the method - * getMaxRowSize includes the SQL data types - * LONGVARCHAR and LONGVARBINARY. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean doesMaxRowSizeIncludeBlobs() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves the maximum number of characters this database allows in - * an SQL statement. - * - * @return the maximum number of characters allowed for an SQL statement; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxStatementLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of active statements to this database - * that can be open at the same time. - * - * @return the maximum number of statements that can be open at one time; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxStatements() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of characters this database allows in - * a table name. - * - * @return the maximum number of characters allowed for a table name; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxTableNameLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of tables this database allows in a - * SELECT statement. - * - * @return the maximum number of tables allowed in a SELECT - * statement; a result of zero means that there is no limit or - * the limit is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxTablesInSelect() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the maximum number of characters this database allows in - * a user name. - * - * @return the maximum number of characters allowed for a user name; - * a result of zero means that there is no limit or the limit - * is not known - * @throws java.sql.SQLException if a database access error occurs - */ - public int getMaxUserNameLength() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves this database's default transaction isolation level. The - * possible values are defined in java.sql.Connection. - * - * @return the default isolation level - * @throws java.sql.SQLException if a database access error occurs - * @see java.sql.Connection - */ - public int getDefaultTransactionIsolation() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves whether this database supports transactions. If not, invoki= ng the - * method commit is a noop, and the isolation level is - * TRANSACTION_NONE. - * - * @return true if transactions are supported; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsTransactions() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the given transaction isolat= ion level. - * - * @param level one of the transaction isolation levels defined in - * java.sql.Connection - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @see java.sql.Connection - */ - public boolean supportsTransactionIsolationLevel(int level) throws SQLEx= ception - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports both data definition and - * data manipulation statements within a transaction. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsDataDefinitionAndDataManipulationTransactions() t= hrows SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports only data manipulation - * statements within a transaction. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean supportsDataManipulationTransactionsOnly() throws SQLExce= ption - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a data definition statement within a transaction fo= rces - * the transaction to commit. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean dataDefinitionCausesTransactionCommit() throws SQLExcepti= on - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database ignores a data definition statement - * within a transaction. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - */ - public boolean dataDefinitionIgnoredInTransactions() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves a description of the stored procedures available in the giv= en - * catalog. - *

- * Only procedure descriptions matching the schema and - * procedure name criteria are returned. They are ordered by - * PROCEDURE_CAT, PROCEDURE_SCHEM, - * PROCEDURE_NAME and SPECIFIC_ NAME. - *

- *

Each procedure description has the the following columns: - *

    - *
  1. PROCEDURE_CAT String =3D> procedure catalog (may be = null) - *
  2. PROCEDURE_SCHEM String =3D> procedure schema (may be null) - *
  3. PROCEDURE_NAME String =3D> procedure name - *
  4. reserved for future use - *
  5. reserved for future use - *
  6. reserved for future use - *
  7. REMARKS String =3D> explanatory comment on the procedure - *
  8. PROCEDURE_TYPE short =3D> kind of procedure: - *
      - *
    • procedureResultUnknown - Cannot determine if a return value - * will be returned - *
    • procedureNoResult - Does not return a return value - *
    • procedureReturnsResult - Returns a return value - *
    - *
  9. SPECIFIC_NAME String =3D> The name which uniquely identif= ies this - * procedure within its schema. - *
- *

- * A user may not have permissions to execute any of the procedures that= are - * returned by getProcedures - * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves t= hose without a catalog; - * null means that the catalog = name should not be used to narrow - * the search - * @param schemaPattern a schema name pattern; must match the schema = name - * as it is stored in the database; "" retri= eves those without a schema; - * null means that the schema n= ame should not be used to narrow - * the search - * @param procedureNamePattern a procedure name pattern; must match the - * procedure name as it is stored in the dat= abase - * @return ResultSet - each row is a procedure description - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - */ - public ResultSet getProcedures(String catalog, String schemaPattern, Str= ing procedureNamePattern) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the given catalog's stored procedure param= eter - * and result columns. - *

- *

Only descriptions matching the schema, procedure and - * parameter name criteria are returned. They are ordered by - * PROCEDURE_CAT, PROCEDURE_SCHEM, PROCEDURE_NAME and SPECIFIC_NAME. Wit= hin this, the return value, - * if any, is first. Next are the parameter descriptions in call - * order. The column descriptions follow in column number order. - *

- *

Each row in the ResultSet is a parameter description = or - * column description with the following fields: - *

    - *
  1. PROCEDURE_CAT String =3D> procedure catalog (may be = null) - *
  2. PROCEDURE_SCHEM String =3D> procedure schema (may be null) - *
  3. PROCEDURE_NAME String =3D> procedure name - *
  4. COLUMN_NAME String =3D> column/parameter name - *
  5. COLUMN_TYPE Short =3D> kind of column/parameter: - *
      - *
    • procedureColumnUnknown - nobody knows - *
    • procedureColumnIn - IN parameter - *
    • procedureColumnInOut - INOUT parameter - *
    • procedureColumnOut - OUT parameter - *
    • procedureColumnReturn - procedure return value - *
    • procedureColumnResult - result column in ResultSet - *
    - *
  6. DATA_TYPE int =3D> SQL type from java.sql.Types - *
  7. TYPE_NAME String =3D> SQL type name, for a UDT type the - * type name is fully qualified - *
  8. PRECISION int =3D> precision - *
  9. LENGTH int =3D> length in bytes of data - *
  10. SCALE short =3D> scale - null is returned for data types = where - * SCALE is not applicable. - *
  11. RADIX short =3D> radix - *
  12. NULLABLE short =3D> can it contain NULL. - *
      - *
    • procedureNoNulls - does not allow NULL values - *
    • procedureNullable - allows NULL values - *
    • procedureNullableUnknown - nullability unknown - *
    - *
  13. REMARKS String =3D> comment describing parameter/column - *
  14. COLUMN_DEF String =3D> default value for the column, which= should be interpreted as a string when the value is enclosed in single quo= tes (may be null) - *
      - *
    • The string NULL (not enclosed in quotes) - if NULL was specified= as the default value - *
    • TRUNCATE (not enclosed in quotes) - if the specified defa= ult value cannot be represented without truncation - *
    • NULL - if a default value wa= s not specified - *
    - *
  15. SQL_DATA_TYPE int =3D> reserved for future use - *
  16. SQL_DATETIME_SUB int =3D> reserved for future use - *
  17. CHAR_OCTET_LENGTH int =3D> the maximum length of binary a= nd character based columns. For any other datatype the returned value is a - * NULL - *
  18. ORDINAL_POSITION int =3D> the ordinal position, starting = from 1, for the input and output parameters for a procedure. A value of 0 - * is returned if this row describes the procedure's return value. For = result set columns, it is the - * ordinal position of the column in the result set starting from 1. If= there are - * multiple result sets, the column ordinal positions are implementation - * defined. - *
  19. IS_NULLABLE String =3D> ISO rules are used to determine t= he nullability for a column. - *
      - *
    • YES --- if the parameter can include NULLs - *
    • NO --- if the parameter cannot include NULLs - *
    • empty string --- if the nullability for the - * parameter is unknown - *
    - *
  20. SPECIFIC_NAME String =3D> the name which uniquely identif= ies this procedure within its schema. - *
- *

- *

Note: Some databases may not return the column - * descriptions for a procedure. - *

- *

The PRECISION column represents the specified column size for the = given column. - * For numeric data, this is the maximum precision. For character data,= this is the length in characters. - * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the - * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, - * this is the length in bytes. Null is returned for data types where the - * column size is not applicable. - * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves t= hose without a catalog; - * null means that the catalog = name should not be used to narrow - * the search - * @param schemaPattern a schema name pattern; must match the schema = name - * as it is stored in the database; "" retri= eves those without a schema; - * null means that the schema n= ame should not be used to narrow - * the search - * @param procedureNamePattern a procedure name pattern; must match the - * procedure name as it is stored in the dat= abase - * @param columnNamePattern a column name pattern; must match the colum= n name - * as it is stored in the database - * @return ResultSet - each row describes a stored procedur= e parameter or - * column - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - */ - public ResultSet getProcedureColumns(String catalog, String schemaPatter= n, String procedureNamePattern, String columnNamePattern) throws SQLExcepti= on - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the tables available in the given catalog. - * Only table descriptions matching the catalog, schema, table - * name and type criteria are returned. They are ordered by - * TABLE_TYPE, TABLE_CAT, - * TABLE_SCHEM and TABLE_NAME. - *

- * Each table description has the following columns: - *

    - *
  1. TABLE_CAT String =3D> table catalog (may be null) - *
  2. TABLE_SCHEM String =3D> table schema (may be null) - *
  3. TABLE_NAME String =3D> table name - *
  4. TABLE_TYPE String =3D> table type. Typical types are "TAB= LE", - * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", - * "LOCAL TEMPORARY", "ALIAS", "SYNONYM". - *
  5. REMARKS String =3D> explanatory comment on the table - *
  6. TYPE_CAT String =3D> the types catalog (may be null<= /code>) - *
  7. TYPE_SCHEM String =3D> the types schema (may be null= ) - *
  8. TYPE_NAME String =3D> type name (may be null) - *
  9. SELF_REFERENCING_COL_NAME String =3D> name of the designat= ed - * "identifier" column of a typed table (may be null) - *
  10. REF_GENERATION String =3D> specifies how values in - * SELF_REFERENCING_COL_NAME are created. Values are - * "SYSTEM", "USER", "DERIVED". (may be null) - *
- *

- *

Note: Some databases may not return information for - * all tables. - * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves those= without a catalog; - * null means that the catalog name= should not be used to narrow - * the search - * @param schemaPattern a schema name pattern; must match the schema na= me - * as it is stored in the database; "" retrieves= those without a schema; - * null means that the schema name = should not be used to narrow - * the search - * @param tableNamePattern a table name pattern; must match the - * table name as it is stored in the database - * @param types a list of table types, which must be from the list of= table types - * returned from {@link #getTableTypes},to inclu= de; null returns - * all types - * @return ResultSet - each row is a table description - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - */ - public ResultSet getTables(String catalog, String schemaPattern, String = tableNamePattern, String[] types) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the schema names available in this database. The results - * are ordered by TABLE_CATALOG and - * TABLE_SCHEM. - *

- *

The schema columns are: - *

    - *
  1. TABLE_SCHEM String =3D> schema name - *
  2. TABLE_CATALOG String =3D> catalog name (may be null<= /code>) - *
- * - * @return a ResultSet object in which each row is a - * schema description - * @throws java.sql.SQLException if a database access error occurs - */ - public ResultSet getSchemas() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the catalog names available in this database. The results - * are ordered by catalog name. - *

- *

The catalog column is: - *

    - *
  1. TABLE_CAT String =3D> catalog name - *
- * - * @return a ResultSet object in which each row has a - * single String column that is a catalog name - * @throws java.sql.SQLException if a database access error occurs - */ - public ResultSet getCatalogs() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the table types available in this database. The results - * are ordered by table type. - *

- *

The table type is: - *

    - *
  1. TABLE_TYPE String =3D> table type. Typical types are "TAB= LE", - * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", - * "LOCAL TEMPORARY", "ALIAS", "SYNONYM". - *
- * - * @return a ResultSet object in which each row has a - * single String column that is a table type - * @throws java.sql.SQLException if a database access error occurs - */ - public ResultSet getTableTypes() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of table columns available in - * the specified catalog. - *

- *

Only column descriptions matching the catalog, schema, table - * and column name criteria are returned. They are ordered by - * TABLE_CAT,TABLE_SCHEM, - * TABLE_NAME, and ORDINAL_POSITION. - *

- *

Each column description has the following columns: - *

    - *
  1. TABLE_CAT String =3D> table catalog (may be null) - *
  2. TABLE_SCHEM String =3D> table schema (may be null) - *
  3. TABLE_NAME String =3D> table name - *
  4. COLUMN_NAME String =3D> column name - *
  5. DATA_TYPE int =3D> SQL type from java.sql.Types - *
  6. TYPE_NAME String =3D> Data source dependent type name, - * for a UDT the type name is fully qualified - *
  7. COLUMN_SIZE int =3D> column size. - *
  8. BUFFER_LENGTH is not used. - *
  9. DECIMAL_DIGITS int =3D> the number of fractional digits. N= ull is returned for data types where - * DECIMAL_DIGITS is not applicable. - *
  10. NUM_PREC_RADIX int =3D> Radix (typically either 10 or 2) - *
  11. NULLABLE int =3D> is NULL allowed. - *
      - *
    • columnNoNulls - might not allow NULL values - *
    • columnNullable - definitely allows NULL values - *
    • columnNullableUnknown - nullability unknown - *
    - *
  12. REMARKS String =3D> comment describing column (may be null) - *
  13. COLUMN_DEF String =3D> default value for the column, which= should be interpreted as a string when the value is enclosed in single quo= tes (may be null) - *
  14. SQL_DATA_TYPE int =3D> unused - *
  15. SQL_DATETIME_SUB int =3D> unused - *
  16. CHAR_OCTET_LENGTH int =3D> for char types the - * maximum number of bytes in the column - *
  17. ORDINAL_POSITION int =3D> index of column in table - * (starting at 1) - *
  18. IS_NULLABLE String =3D> ISO rules are used to determine t= he nullability for a column. - *
      - *
    • YES --- if the parameter can include NULLs - *
    • NO --- if the parameter cannot include NULLs - *
    • empty string --- if the nullability for the - * parameter is unknown - *
    - *
  19. SCOPE_CATLOG String =3D> catalog of table that is the scope - * of a reference attribute (null if DATA_TYPE isn't REF) - *
  20. SCOPE_SCHEMA String =3D> schema of table that is the scope - * of a reference attribute (null if the DATA_TYPE isn't RE= F) - *
  21. SCOPE_TABLE String =3D> table name that this the scope - * of a reference attribure (null if the DATA_TYPE isn't RE= F) - *
  22. SOURCE_DATA_TYPE short =3D> source type of a distinct type= or user-generated - * Ref type, SQL type from java.sql.Types (null if DATA_TYPE - * isn't DISTINCT or user-generated REF) - *
  23. IS_AUTOINCREMENT String =3D> Indicates whether this colum= n is auto incremented - *
      - *
    • YES --- if the column is auto incremented - *
    • NO --- if the column is not auto incremented - *
    • empty string --- if it cannot be determined whether the column = is auto incremented - * parameter is unknown - *
    - *
- *

- *

The COLUMN_SIZE column the specified column size for the given col= umn. - * For numeric data, this is the maximum precision. For character data,= this is the length in characters. - * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the - * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, - * this is the length in bytes. Null is returned for data types where the - * column size is not applicable. - * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves thos= e without a catalog; - * null means that the catalog nam= e should not be used to narrow - * the search - * @param schemaPattern a schema name pattern; must match the schema n= ame - * as it is stored in the database; "" retrieve= s those without a schema; - * null means that the schema name= should not be used to narrow - * the search - * @param tableNamePattern a table name pattern; must match the - * table name as it is stored in the database - * @param columnNamePattern a column name pattern; must match the column - * name as it is stored in the database - * @return ResultSet - each row is a column description - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - */ - public ResultSet getColumns(String catalog, String schemaPattern, String= tableNamePattern, String columnNamePattern) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the access rights for a table's columns. - *

- *

Only privileges matching the column name criteria are - * returned. They are ordered by COLUMN_NAME and PRIVILEGE. - *

- *

Each privilige description has the following columns: - *

    - *
  1. TABLE_CAT String =3D> table catalog (may be null) - *
  2. TABLE_SCHEM String =3D> table schema (may be null) - *
  3. TABLE_NAME String =3D> table name - *
  4. COLUMN_NAME String =3D> column name - *
  5. GRANTOR String =3D> grantor of access (may be null) - *
  6. GRANTEE String =3D> grantee of access - *
  7. PRIVILEGE String =3D> name of access (SELECT, - * INSERT, UPDATE, REFRENCES, ...) - *
  8. IS_GRANTABLE String =3D> "YES" if grantee is permitted - * to grant to others; "NO" if not; null if unknown - *
- * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves thos= e without a catalog; - * null means that the catalog nam= e should not be used to narrow - * the search - * @param schema a schema name; must match the schema name as it is - * stored in the database; "" retrieves those w= ithout a schema; - * null means that the schema name= should not be used to narrow - * the search - * @param table a table name; must match the table name as it is - * stored in the database - * @param columnNamePattern a column name pattern; must match the column - * name as it is stored in the database - * @return ResultSet - each row is a column privilege descr= iption - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - */ - public ResultSet getColumnPrivileges(String catalog, String schema, Stri= ng table, String columnNamePattern) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the access rights for each table available - * in a catalog. Note that a table privilege applies to one or - * more columns in the table. It would be wrong to assume that - * this privilege applies to all columns (this may be true for - * some systems but is not true for all.) - *

- *

Only privileges matching the schema and table name - * criteria are returned. They are ordered by - * TABLE_CAT, - * TABLE_SCHEM, TABLE_NAME, - * and PRIVILEGE. - *

- *

Each privilige description has the following columns: - *

    - *
  1. TABLE_CAT String =3D> table catalog (may be null) - *
  2. TABLE_SCHEM String =3D> table schema (may be null) - *
  3. TABLE_NAME String =3D> table name - *
  4. GRANTOR String =3D> grantor of access (may be null) - *
  5. GRANTEE String =3D> grantee of access - *
  6. PRIVILEGE String =3D> name of access (SELECT, - * INSERT, UPDATE, REFRENCES, ...) - *
  7. IS_GRANTABLE String =3D> "YES" if grantee is permitted - * to grant to others; "NO" if not; null if unknown - *
- * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves those= without a catalog; - * null means that the catalog name= should not be used to narrow - * the search - * @param schemaPattern a schema name pattern; must match the schema na= me - * as it is stored in the database; "" retrieves= those without a schema; - * null means that the schema name = should not be used to narrow - * the search - * @param tableNamePattern a table name pattern; must match the - * table name as it is stored in the database - * @return ResultSet - each row is a table privilege descri= ption - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - */ - public ResultSet getTablePrivileges(String catalog, String schemaPattern= , String tableNamePattern) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of a table's optimal set of columns that - * uniquely identifies a row. They are ordered by SCOPE. - *

- *

Each column description has the following columns: - *

    - *
  1. SCOPE short =3D> actual scope of result - *
      - *
    • bestRowTemporary - very temporary, while using row - *
    • bestRowTransaction - valid for remainder of current transaction - *
    • bestRowSession - valid for remainder of current session - *
    - *
  2. COLUMN_NAME String =3D> column name - *
  3. DATA_TYPE int =3D> SQL data type from java.sql.Types - *
  4. TYPE_NAME String =3D> Data source dependent type name, - * for a UDT the type name is fully qualified - *
  5. COLUMN_SIZE int =3D> precision - *
  6. BUFFER_LENGTH int =3D> not used - *
  7. DECIMAL_DIGITS short =3D> scale - Null is returned for da= ta types where - * DECIMAL_DIGITS is not applicable. - *
  8. PSEUDO_COLUMN short =3D> is this a pseudo column - * like an Oracle ROWID - *
      - *
    • bestRowUnknown - may or may not be pseudo column - *
    • bestRowNotPseudo - is NOT a pseudo column - *
    • bestRowPseudo - is a pseudo column - *
    - *
- *

- *

The COLUMN_SIZE column represents the specified column size for th= e given column. - * For numeric data, this is the maximum precision. For character data,= this is the length in characters. - * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the - * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, - * this is the length in bytes. Null is returned for data types where the - * column size is not applicable. - * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves those without= a catalog; - * null means that the catalog name should = not be used to narrow - * the search - * @param schema a schema name; must match the schema name - * as it is stored in the database; "" retrieves those w= ithout a schema; - * null means that the schema name should n= ot be used to narrow - * the search - * @param table a table name; must match the table name as it is stored - * in the database - * @param scope the scope of interest; use same values as SCOPE - * @param nullable include columns that are nullable. - * @return ResultSet - each row is a column description - * @throws java.sql.SQLException if a database access error occurs - */ - public ResultSet getBestRowIdentifier(String catalog, String schema, Str= ing table, int scope, boolean nullable) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of a table's columns that are automatically - * updated when any value in a row is updated. They are - * unordered. - *

- *

Each column description has the following columns: - *

    - *
  1. SCOPE short =3D> is not used - *
  2. COLUMN_NAME String =3D> column name - *
  3. DATA_TYPE int =3D> SQL data type from java.sql.Types= - *
  4. TYPE_NAME String =3D> Data source-dependent type name - *
  5. COLUMN_SIZE int =3D> precision - *
  6. BUFFER_LENGTH int =3D> length of column value in bytes - *
  7. DECIMAL_DIGITS short =3D> scale - Null is returned for da= ta types where - * DECIMAL_DIGITS is not applicable. - *
  8. PSEUDO_COLUMN short =3D> whether this is pseudo column - * like an Oracle ROWID - *
      - *
    • versionColumnUnknown - may or may not be pseudo column - *
    • versionColumnNotPseudo - is NOT a pseudo column - *
    • versionColumnPseudo - is a pseudo column - *
    - *
- *

- *

The COLUMN_SIZE column represents the specified column size for th= e given column. - * For numeric data, this is the maximum precision. For character data,= this is the length in characters. - * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the - * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, - * this is the length in bytes. Null is returned for data types where the - * column size is not applicable. - * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves those without = a catalog; - * null means that the catalog name should n= ot be used to narrow - * the search - * @param schema a schema name; must match the schema name - * as it is stored in the database; "" retrieves those wi= thout a schema; - * null means that the schema name should no= t be used to narrow - * the search - * @param table a table name; must match the table name as it is stored - * in the database - * @return a ResultSet object in which each row is a - * column description - * @throws java.sql.SQLException if a database access error occurs - */ - public ResultSet getVersionColumns(String catalog, String schema, String= table) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the given table's primary key columns. Th= ey - * are ordered by COLUMN_NAME. - *

- *

Each primary key column description has the following columns: - *

    - *
  1. TABLE_CAT String =3D> table catalog (may be null) - *
  2. TABLE_SCHEM String =3D> table schema (may be null) - *
  3. TABLE_NAME String =3D> table name - *
  4. COLUMN_NAME String =3D> column name - *
  5. KEY_SEQ short =3D> sequence number within primary key( a v= alue - * of 1 represents the first column of the primary key, a value of 2 wou= ld - * represent the second column within the primary key). - *
  6. PK_NAME String =3D> primary key name (may be null) - *
- * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves those without = a catalog; - * null means that the catalog name should n= ot be used to narrow - * the search - * @param schema a schema name; must match the schema name - * as it is stored in the database; "" retrieves those wi= thout a schema; - * null means that the schema name should no= t be used to narrow - * the search - * @param table a table name; must match the table name as it is stored - * in the database - * @return ResultSet - each row is a primary key column des= cription - * @throws java.sql.SQLException if a database access error occurs - */ - public ResultSet getPrimaryKeys(String catalog, String schema, String ta= ble) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the primary key columns that are - * referenced by the given table's foreign key columns (the primary keys - * imported by a table). They are ordered by PKTABLE_CAT, - * PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ. - *

- *

Each primary key column description has the following columns: - *

    - *
  1. PKTABLE_CAT String =3D> primary key table catalog - * being imported (may be null) - *
  2. PKTABLE_SCHEM String =3D> primary key table schema - * being imported (may be null) - *
  3. PKTABLE_NAME String =3D> primary key table name - * being imported - *
  4. PKCOLUMN_NAME String =3D> primary key column name - * being imported - *
  5. FKTABLE_CAT String =3D> foreign key table catalog (may be = null) - *
  6. FKTABLE_SCHEM String =3D> foreign key table schema (may be= null) - *
  7. FKTABLE_NAME String =3D> foreign key table name - *
  8. FKCOLUMN_NAME String =3D> foreign key column name - *
  9. KEY_SEQ short =3D> sequence number within a foreign key( a= value - * of 1 represents the first column of the foreign key, a value of 2 wou= ld - * represent the second column within the foreign key). - *
  10. UPDATE_RULE short =3D> What happens to a - * foreign key when the primary key is updated: - *
      - *
    • importedNoAction - do not allow update of primary - * key if it has been imported - *
    • importedKeyCascade - change imported key to agree - * with primary key update - *
    • importedKeySetNull - change imported key to NULL - * if its primary key has been updated - *
    • importedKeySetDefault - change imported key to default values - * if its primary key has been updated - *
    • importedKeyRestrict - same as importedKeyNoAction - * (for ODBC 2.x compatibility) - *
    - *
  11. DELETE_RULE short =3D> What happens to - * the foreign key when primary is deleted. - *
      - *
    • importedKeyNoAction - do not allow delete of primary - * key if it has been imported - *
    • importedKeyCascade - delete rows that import a deleted key - *
    • importedKeySetNull - change imported key to NULL if - * its primary key has been deleted - *
    • importedKeyRestrict - same as importedKeyNoAction - * (for ODBC 2.x compatibility) - *
    • importedKeySetDefault - change imported key to default if - * its primary key has been deleted - *
    - *
  12. FK_NAME String =3D> foreign key name (may be null) - *
  13. PK_NAME String =3D> primary key name (may be null) - *
  14. DEFERRABILITY short =3D> can the evaluation of foreign key - * constraints be deferred until commit - *
      - *
    • importedKeyInitiallyDeferred - see SQL92 for definition - *
    • importedKeyInitiallyImmediate - see SQL92 for definition - *
    • importedKeyNotDeferrable - see SQL92 for definition - *
    - *
- * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves those without = a catalog; - * null means that the catalog name should n= ot be used to narrow - * the search - * @param schema a schema name; must match the schema name - * as it is stored in the database; "" retrieves those wi= thout a schema; - * null means that the schema name should no= t be used to narrow - * the search - * @param table a table name; must match the table name as it is stored - * in the database - * @return ResultSet - each row is a primary key column des= cription - * @throws java.sql.SQLException if a database access error occurs - * @see #getExportedKeys - */ - public ResultSet getImportedKeys(String catalog, String schema, String t= able) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the foreign key columns that reference the - * given table's primary key columns (the foreign keys exported by a - * table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM, - * FKTABLE_NAME, and KEY_SEQ. - *

- *

Each foreign key column description has the following columns: - *

    - *
  1. PKTABLE_CAT String =3D> primary key table catalog (may be = null) - *
  2. PKTABLE_SCHEM String =3D> primary key table schema (may be= null) - *
  3. PKTABLE_NAME String =3D> primary key table name - *
  4. PKCOLUMN_NAME String =3D> primary key column name - *
  5. FKTABLE_CAT String =3D> foreign key table catalog (may be = null) - * being exported (may be null) - *
  6. FKTABLE_SCHEM String =3D> foreign key table schema (may be= null) - * being exported (may be null) - *
  7. FKTABLE_NAME String =3D> foreign key table name - * being exported - *
  8. FKCOLUMN_NAME String =3D> foreign key column name - * being exported - *
  9. KEY_SEQ short =3D> sequence number within foreign key( a v= alue - * of 1 represents the first column of the foreign key, a value of 2 wou= ld - * represent the second column within the foreign key). - *
  10. UPDATE_RULE short =3D> What happens to - * foreign key when primary is updated: - *
      - *
    • importedNoAction - do not allow update of primary - * key if it has been imported - *
    • importedKeyCascade - change imported key to agree - * with primary key update - *
    • importedKeySetNull - change imported key to NULL if - * its primary key has been updated - *
    • importedKeySetDefault - change imported key to default values - * if its primary key has been updated - *
    • importedKeyRestrict - same as importedKeyNoAction - * (for ODBC 2.x compatibility) - *
    - *
  11. DELETE_RULE short =3D> What happens to - * the foreign key when primary is deleted. - *
      - *
    • importedKeyNoAction - do not allow delete of primary - * key if it has been imported - *
    • importedKeyCascade - delete rows that import a deleted key - *
    • importedKeySetNull - change imported key to NULL if - * its primary key has been deleted - *
    • importedKeyRestrict - same as importedKeyNoAction - * (for ODBC 2.x compatibility) - *
    • importedKeySetDefault - change imported key to default if - * its primary key has been deleted - *
    - *
  12. FK_NAME String =3D> foreign key name (may be null) - *
  13. PK_NAME String =3D> primary key name (may be null) - *
  14. DEFERRABILITY short =3D> can the evaluation of foreign key - * constraints be deferred until commit - *
      - *
    • importedKeyInitiallyDeferred - see SQL92 for definition - *
    • importedKeyInitiallyImmediate - see SQL92 for definition - *
    • importedKeyNotDeferrable - see SQL92 for definition - *
    - *
- * - * @param catalog a catalog name; must match the catalog name as it - * is stored in this database; "" retrieves those without= a catalog; - * null means that the catalog name should n= ot be used to narrow - * the search - * @param schema a schema name; must match the schema name - * as it is stored in the database; "" retrieves those wi= thout a schema; - * null means that the schema name should no= t be used to narrow - * the search - * @param table a table name; must match the table name as it is stored - * in this database - * @return a ResultSet object in which each row is a - * foreign key column description - * @throws java.sql.SQLException if a database access error occurs - * @see #getImportedKeys - */ - public ResultSet getExportedKeys(String catalog, String schema, String t= able) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the foreign key columns in the given forei= gn key - * table that reference the primary key or the columns representing a un= ique constraint of the parent table (could be the same or a different tabl= e). - * The number of columns returned from the parent table must match the n= umber of - * columns that make up the foreign key. They - * are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and - * KEY_SEQ. - *

- *

Each foreign key column description has the following columns: - *

    - *
  1. PKTABLE_CAT String =3D> parent key table catalog (may be <= code>null) - *
  2. PKTABLE_SCHEM String =3D> parent key table schema (may be = null) - *
  3. PKTABLE_NAME String =3D> parent key table name - *
  4. PKCOLUMN_NAME String =3D> parent key column name - *
  5. FKTABLE_CAT String =3D> foreign key table catalog (may be = null) - * being exported (may be null) - *
  6. FKTABLE_SCHEM String =3D> foreign key table schema (may be= null) - * being exported (may be null) - *
  7. FKTABLE_NAME String =3D> foreign key table name - * being exported - *
  8. FKCOLUMN_NAME String =3D> foreign key column name - * being exported - *
  9. KEY_SEQ short =3D> sequence number within foreign key( a v= alue - * of 1 represents the first column of the foreign key, a value of 2 wou= ld - * represent the second column within the foreign key). - *
  10. UPDATE_RULE short =3D> What happens to - * foreign key when parent key is updated: - *
      - *
    • importedNoAction - do not allow update of parent - * key if it has been imported - *
    • importedKeyCascade - change imported key to agree - * with parent key update - *
    • importedKeySetNull - change imported key to NULL if - * its parent key has been updated - *
    • importedKeySetDefault - change imported key to default values - * if its parent key has been updated - *
    • importedKeyRestrict - same as importedKeyNoAction - * (for ODBC 2.x compatibility) - *
    - *
  11. DELETE_RULE short =3D> What happens to - * the foreign key when parent key is deleted. - *
      - *
    • importedKeyNoAction - do not allow delete of parent - * key if it has been imported - *
    • importedKeyCascade - delete rows that import a deleted key - *
    • importedKeySetNull - change imported key to NULL if - * its primary key has been deleted - *
    • importedKeyRestrict - same as importedKeyNoAction - * (for ODBC 2.x compatibility) - *
    • importedKeySetDefault - change imported key to default if - * its parent key has been deleted - *
    - *
  12. FK_NAME String =3D> foreign key name (may be null) - *
  13. PK_NAME String =3D> parent key name (may be null) - *
  14. DEFERRABILITY short =3D> can the evaluation of foreign key - * constraints be deferred until commit - *
      - *
    • importedKeyInitiallyDeferred - see SQL92 for definition - *
    • importedKeyInitiallyImmediate - see SQL92 for definition - *
    • importedKeyNotDeferrable - see SQL92 for definition - *
    - *
- * - * @param parentCatalog a catalog name; must match the catalog name - * as it is stored in the database; "" retrieves t= hose without a - * catalog; null means drop catalog n= ame from the selection criteria - * @param parentSchema a schema name; must match the schema name as - * it is stored in the database; "" retrieves thos= e without a schema; - * null means drop schema name from t= he selection criteria - * @param parentTable the name of the table that exports the key; must = match - * the table name as it is stored in the database - * @param foreignCatalog a catalog name; must match the catalog name as - * it is stored in the database; "" retrieves thos= e without a - * catalog; null means drop catalog n= ame from the selection criteria - * @param foreignSchema a schema name; must match the schema name as it - * is stored in the database; "" retrieves those w= ithout a schema; - * null means drop schema name from t= he selection criteria - * @param foreignTable the name of the table that imports the key; must = match - * the table name as it is stored in the database - * @return ResultSet - each row is a foreign key column des= cription - * @throws java.sql.SQLException if a database access error occurs - * @see #getImportedKeys - */ - public ResultSet getCrossReference(String parentCatalog, String parentSc= hema, String parentTable, String foreignCatalog, String foreignSchema, Stri= ng foreignTable) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of all the data types supported by - * this database. They are ordered by DATA_TYPE and then by how - * closely the data type maps to the corresponding JDBC SQL type. - *

- *

If the database supports SQL distinct types, then getTypeInfo() wi= ll return - * a single row with a TYPE_NAME of DISTINCT and a DATA_TYPE of Types.DI= STINCT. - * If the database supports SQL structured types, then getTypeInfo() wil= l return - * a single row with a TYPE_NAME of STRUCT and a DATA_TYPE of Types.STRU= CT. - *

- *

If SQL distinct or structured types are supported, then informatio= n on the - * individual types may be obtained from the getUDTs() method. - *

- *

- *

- *

Each type description has the following columns: - *

    - *
  1. TYPE_NAME String =3D> Type name - *
  2. DATA_TYPE int =3D> SQL data type from java.sql.Types - *
  3. PRECISION int =3D> maximum precision - *
  4. LITERAL_PREFIX String =3D> prefix used to quote a literal - * (may be null) - *
  5. LITERAL_SUFFIX String =3D> suffix used to quote a literal - * (may be null) - *
  6. CREATE_PARAMS String =3D> parameters used in creating - * the type (may be null) - *
  7. NULLABLE short =3D> can you use NULL for this type. - *
      - *
    • typeNoNulls - does not allow NULL values - *
    • typeNullable - allows NULL values - *
    • typeNullableUnknown - nullability unknown - *
    - *
  8. CASE_SENSITIVE boolean=3D> is it case sensitive. - *
  9. SEARCHABLE short =3D> can you use "WHERE" based on this ty= pe: - *
      - *
    • typePredNone - No support - *
    • typePredChar - Only supported with WHERE .. LIKE - *
    • typePredBasic - Supported except for WHERE .. LIKE - *
    • typeSearchable - Supported for all WHERE .. - *
    - *
  10. UNSIGNED_ATTRIBUTE boolean =3D> is it unsigned. - *
  11. FIXED_PREC_SCALE boolean =3D> can it be a money value. - *
  12. AUTO_INCREMENT boolean =3D> can it be used for an - * auto-increment value. - *
  13. LOCAL_TYPE_NAME String =3D> localized version of type name - * (may be null) - *
  14. MINIMUM_SCALE short =3D> minimum scale supported - *
  15. MAXIMUM_SCALE short =3D> maximum scale supported - *
  16. SQL_DATA_TYPE int =3D> unused - *
  17. SQL_DATETIME_SUB int =3D> unused - *
  18. NUM_PREC_RADIX int =3D> usually 2 or 10 - *
- *

- *

The PRECISION column represents the maximum column size that the s= erver supports for the given datatype. - * For numeric data, this is the maximum precision. For character data,= this is the length in characters. - * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the - * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, - * this is the length in bytes. Null is returned for data types where the - * column size is not applicable. - * - * @return a ResultSet object in which each row is an SQL - * type description - * @throws java.sql.SQLException if a database access error occurs - */ - public ResultSet getTypeInfo() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the given table's indices and statistics. = They are - * ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION. - *

- *

Each index column description has the following columns: - *

    - *
  1. TABLE_CAT String =3D> table catalog (may be null) - *
  2. TABLE_SCHEM String =3D> table schema (may be null) - *
  3. TABLE_NAME String =3D> table name - *
  4. NON_UNIQUE boolean =3D> Can index values be non-unique. - * false when TYPE is tableIndexStatistic - *
  5. INDEX_QUALIFIER String =3D> index catalog (may be nu= ll); - * null when TYPE is tableIndexStatistic - *
  6. INDEX_NAME String =3D> index name; null when = TYPE is - * tableIndexStatistic - *
  7. TYPE short =3D> index type: - *
      - *
    • tableIndexStatistic - this identifies table statistics that are - * returned in conjuction with a table's index descriptions - *
    • tableIndexClustered - this is a clustered index - *
    • tableIndexHashed - this is a hashed index - *
    • tableIndexOther - this is some other style of index - *
    - *
  8. ORDINAL_POSITION short =3D> column sequence number - * within index; zero when TYPE is tableIndexStatistic - *
  9. COLUMN_NAME String =3D> column name; null whe= n TYPE is - * tableIndexStatistic - *
  10. ASC_OR_DESC String =3D> column sort sequence, "A" =3D> asc= ending, - * "D" =3D> descending, may be null if sort sequence is not= supported; - * null when TYPE is tableIndexStatistic - *
  11. CARDINALITY int =3D> When TYPE is tableIndexStatistic, then - * this is the number of rows in the table; otherwise, it is the - * number of unique values in the index. - *
  12. PAGES int =3D> When TYPE is tableIndexStatisic then - * this is the number of pages used for the table, otherwise it - * is the number of pages used for the current index. - *
  13. FILTER_CONDITION String =3D> Filter condition, if any. - * (may be null) - *
- * - * @param catalog a catalog name; must match the catalog name as it - * is stored in this database; "" retrieves those wit= hout a catalog; - * null means that the catalog name shou= ld not be used to narrow - * the search - * @param schema a schema name; must match the schema name - * as it is stored in this database; "" retrieves tho= se without a schema; - * null means that the schema name shoul= d not be used to narrow - * the search - * @param table a table name; must match the table name as it is stored - * in this database - * @param unique when true, return only indices for unique values; - * when false, return indices regardless of whether u= nique or not - * @param approximate when true, result is allowed to reflect approximate - * or out of data values; when false, results are req= uested to be - * accurate - * @return ResultSet - each row is an index column descript= ion - * @throws java.sql.SQLException if a database access error occurs - */ - public ResultSet getIndexInfo(String catalog, String schema, String tabl= e, boolean unique, boolean approximate) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves whether this database supports the given result set type. - * - * @param type defined in java.sql.ResultSet - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @see java.sql.Connection - * @since 1.2 - */ - public boolean supportsResultSetType(int type) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports the given concurrency type - * in combination with the given result set type. - * - * @param type defined in java.sql.ResultSet - * @param concurrency type defined in java.sql.ResultSet - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @see java.sql.Connection - * @since 1.2 - */ - public boolean supportsResultSetConcurrency(int type, int concurrency) t= hrows SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether for the given type of ResultSet object, - * the result set's own updates are visible. - * - * @param type the ResultSet type; one of - * ResultSet.TYPE_FORWARD_ONLY, - * ResultSet.TYPE_SCROLL_INSENSITIVE, or - * ResultSet.TYPE_SCROLL_SENSITIVE - * @return true if updates are visible for the given result= set type; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public boolean ownUpdatesAreVisible(int type) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a result set's own deletes are visible. - * - * @param type the ResultSet type; one of - * ResultSet.TYPE_FORWARD_ONLY, - * ResultSet.TYPE_SCROLL_INSENSITIVE, or - * ResultSet.TYPE_SCROLL_SENSITIVE - * @return true if deletes are visible for the given result= set type; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public boolean ownDeletesAreVisible(int type) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a result set's own inserts are visible. - * - * @param type the ResultSet type; one of - * ResultSet.TYPE_FORWARD_ONLY, - * ResultSet.TYPE_SCROLL_INSENSITIVE, or - * ResultSet.TYPE_SCROLL_SENSITIVE - * @return true if inserts are visible for the given result= set type; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public boolean ownInsertsAreVisible(int type) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether updates made by others are visible. - * - * @param type the ResultSet type; one of - * ResultSet.TYPE_FORWARD_ONLY, - * ResultSet.TYPE_SCROLL_INSENSITIVE, or - * ResultSet.TYPE_SCROLL_SENSITIVE - * @return true if updates made by others - * are visible for the given result set type; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public boolean othersUpdatesAreVisible(int type) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether deletes made by others are visible. - * - * @param type the ResultSet type; one of - * ResultSet.TYPE_FORWARD_ONLY, - * ResultSet.TYPE_SCROLL_INSENSITIVE, or - * ResultSet.TYPE_SCROLL_SENSITIVE - * @return true if deletes made by others - * are visible for the given result set type; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public boolean othersDeletesAreVisible(int type) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether inserts made by others are visible. - * - * @param type the ResultSet type; one of - * ResultSet.TYPE_FORWARD_ONLY, - * ResultSet.TYPE_SCROLL_INSENSITIVE, or - * ResultSet.TYPE_SCROLL_SENSITIVE - * @return true if inserts made by others - * are visible for the given result set type; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public boolean othersInsertsAreVisible(int type) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether or not a visible row update can be detected by - * calling the method ResultSet.rowUpdated. - * - * @param type the ResultSet type; one of - * ResultSet.TYPE_FORWARD_ONLY, - * ResultSet.TYPE_SCROLL_INSENSITIVE, or - * ResultSet.TYPE_SCROLL_SENSITIVE - * @return true if changes are detected by the result set t= ype; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public boolean updatesAreDetected(int type) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether or not a visible row delete can be detected by - * calling the method ResultSet.rowDeleted. If the method - * deletesAreDetected returns false, it means = that - * deleted rows are removed from the result set. - * - * @param type the ResultSet type; one of - * ResultSet.TYPE_FORWARD_ONLY, - * ResultSet.TYPE_SCROLL_INSENSITIVE, or - * ResultSet.TYPE_SCROLL_SENSITIVE - * @return true if deletes are detected by the given result= set type; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public boolean deletesAreDetected(int type) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether or not a visible row insert can be detected - * by calling the method ResultSet.rowInserted. - * - * @param type the ResultSet type; one of - * ResultSet.TYPE_FORWARD_ONLY, - * ResultSet.TYPE_SCROLL_INSENSITIVE, or - * ResultSet.TYPE_SCROLL_SENSITIVE - * @return true if changes are detected by the specified re= sult - * set type; false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public boolean insertsAreDetected(int type) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports batch updates. - * - * @return true if this database supports batch upcates; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public boolean supportsBatchUpdates() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves a description of the user-defined types (UDTs) defined - * in a particular schema. Schema-specific UDTs may have type - * JAVA_OBJECT, STRUCT, - * or DISTINCT. - *

- *

Only types matching the catalog, schema, type name and type - * criteria are returned. They are ordered by DATA_TYPE, - * TYPE_CAT, TYPE_SCHEM and - * TYPE_NAME. The type name parameter may be a fully-quali= fied - * name. In this case, the catalog and schemaPattern parameters are - * ignored. - *

- *

Each type description has the following columns: - *

    - *
  1. TYPE_CAT String =3D> the type's catalog (may be null= ) - *
  2. TYPE_SCHEM String =3D> type's schema (may be null) - *
  3. TYPE_NAME String =3D> type name - *
  4. CLASS_NAME String =3D> Java class name - *
  5. DATA_TYPE int =3D> type value defined in java.sql.Types. - * One of JAVA_OBJECT, STRUCT, or DISTINCT - *
  6. REMARKS String =3D> explanatory comment on the type - *
  7. BASE_TYPE short =3D> type code of the source type of a - * DISTINCT type or the type that implements the user-generated - * reference type of the SELF_REFERENCING_COLUMN of a structured - * type as defined in java.sql.Types (null if DATA_TYPE is = not - * DISTINCT or not STRUCT with REFERENCE_GENERATION =3D USER_DEFINED) - *
- *

- *

Note: If the driver does not support UDTs, an empty - * result set is returned. - * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves those = without a catalog; - * null means that the catalog name = should not be used to narrow - * the search - * @param schemaPattern a schema pattern name; must match the schema name - * as it is stored in the database; "" retrieves = those without a schema; - * null means that the schema name s= hould not be used to narrow - * the search - * @param typeNamePattern a type name pattern; must match the type name - * as it is stored in the database; may be a full= y qualified name - * @param types a list of user-defined types (JAVA_OBJECT, - * STRUCT, or DISTINCT) to include; null returns all types - * @return ResultSet object in which each row describes a U= DT - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - * @since 1.2 - */ - public ResultSet getUDTs(String catalog, String schemaPattern, String ty= peNamePattern, int[] types) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the connection that produced this metadata object. - *

- * - * @return the connection that produced this metadata object - * @throws java.sql.SQLException if a database access error occurs - * @since 1.2 - */ - public Connection getConnection() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves whether this database supports savepoints. - * - * @return true if savepoints are supported; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.4 - */ - public boolean supportsSavepoints() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports named parameters to callable - * statements. - * - * @return true if named parameters are supported; - * false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.4 - */ - public boolean supportsNamedParameters() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether it is possible to have multiple ResultSet objects - * returned from a CallableStatement object - * simultaneously. - * - * @return true if a CallableStatement object - * can return multiple ResultSet objects - * simultaneously; false otherwise - * @throws java.sql.SQLException if a datanase access error occurs - * @since 1.4 - */ - public boolean supportsMultipleOpenResults() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether auto-generated keys can be retrieved after - * a statement has been executed - * - * @return true if auto-generated keys can be retrieved - * after a statement has executed; false otherwise - *

If true is returned, the JDBC driver must sup= port the - * returning of auto-generated keys for at least SQL INSERT stat= ements - *

- * @throws java.sql.SQLException if a database access error occurs - * @since 1.4 - */ - public boolean supportsGetGeneratedKeys() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves a description of the user-defined type (UDT) hierarchies de= fined in a - * particular schema in this database. Only the immediate super type/ - * sub type relationship is modeled. - *

- * Only supertype information for UDTs matching the catalog, - * schema, and type name is returned. The type name parameter - * may be a fully-qualified name. When the UDT name supplied is a - * fully-qualified name, the catalog and schemaPattern parameters are - * ignored. - *

- * If a UDT does not have a direct super type, it is not listed here. - * A row of the ResultSet object returned by this method - * describes the designated UDT and a direct supertype. A row has the fo= llowing - * columns: - *

    - *
  1. TYPE_CAT String =3D> the UDT's catalog (may be null<= /code>) - *
  2. TYPE_SCHEM String =3D> UDT's schema (may be null) - *
  3. TYPE_NAME String =3D> type name of the UDT - *
  4. SUPERTYPE_CAT String =3D> the direct super type's catalog - * (may be null) - *
  5. SUPERTYPE_SCHEM String =3D> the direct super type's schema - * (may be null) - *
  6. SUPERTYPE_NAME String =3D> the direct super type's name - *
- *

- *

Note: If the driver does not support type hierarchies, an - * empty result set is returned. - * - * @param catalog a catalog name; "" retrieves those without a catalog; - * null means drop catalog name from= the selection criteria - * @param schemaPattern a schema name pattern; "" retrieves those - * without a schema - * @param typeNamePattern a UDT name pattern; may be a fully-qualified - * name - * @return a ResultSet object in which a row gives informat= ion - * about the designated UDT - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - * @since 1.4 - */ - public ResultSet getSuperTypes(String catalog, String schemaPattern, Str= ing typeNamePattern) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the table hierarchies defined in a particu= lar - * schema in this database. - *

- *

Only supertable information for tables matching the catalog, schema - * and table name are returned. The table name parameter may be a fully- - * qualified name, in which case, the catalog and schemaPattern paramete= rs - * are ignored. If a table does not have a super table, it is not listed= here. - * Supertables have to be defined in the same catalog and schema as the - * sub tables. Therefore, the type description does not need to include - * this information for the supertable. - *

- *

Each type description has the following columns: - *

    - *
  1. TABLE_CAT String =3D> the type's catalog (may be nul= l) - *
  2. TABLE_SCHEM String =3D> type's schema (may be null) - *
  3. TABLE_NAME String =3D> type name - *
  4. SUPERTABLE_NAME String =3D> the direct super type's name - *
- *

- *

Note: If the driver does not support type hierarchies, an - * empty result set is returned. - * - * @param catalog a catalog name; "" retrieves those without a catalo= g; - * null means drop catalog name fro= m the selection criteria - * @param schemaPattern a schema name pattern; "" retrieves those - * without a schema - * @param tableNamePattern a table name pattern; may be a fully-qualified - * name - * @return a ResultSet object in which each row is a type d= escription - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - * @since 1.4 - */ - public ResultSet getSuperTables(String catalog, String schemaPattern, St= ring tableNamePattern) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the given attribute of the given type - * for a user-defined type (UDT) that is available in the given schema - * and catalog. - *

- * Descriptions are returned only for attributes of UDTs matching the - * catalog, schema, type, and attribute name criteria. They are ordered = by - * TYPE_CAT, TYPE_SCHEM, - * TYPE_NAME and ORDINAL_POSITION. This descri= ption - * does not contain inherited attributes. - *

- * The ResultSet object that is returned has the following - * columns: - *

    - *
  1. TYPE_CAT String =3D> type catalog (may be null) - *
  2. TYPE_SCHEM String =3D> type schema (may be null) - *
  3. TYPE_NAME String =3D> type name - *
  4. ATTR_NAME String =3D> attribute name - *
  5. DATA_TYPE int =3D> attribute type SQL type from java.sql.T= ypes - *
  6. ATTR_TYPE_NAME String =3D> Data source dependent type name. - * For a UDT, the type name is fully qualified. For a REF, the type name= is - * fully qualified and represents the target type of the reference type. - *
  7. ATTR_SIZE int =3D> column size. For char or date - * types this is the maximum number of characters; for numeric or - * decimal types this is precision. - *
  8. DECIMAL_DIGITS int =3D> the number of fractional digits. N= ull is returned for data types where - * DECIMAL_DIGITS is not applicable. - *
  9. NUM_PREC_RADIX int =3D> Radix (typically either 10 or 2) - *
  10. NULLABLE int =3D> whether NULL is allowed - *
      - *
    • attributeNoNulls - might not allow NULL values - *
    • attributeNullable - definitely allows NULL values - *
    • attributeNullableUnknown - nullability unknown - *
    - *
  11. REMARKS String =3D> comment describing column (may be null) - *
  12. ATTR_DEF String =3D> default value (may be null) - *
  13. SQL_DATA_TYPE int =3D> unused - *
  14. SQL_DATETIME_SUB int =3D> unused - *
  15. CHAR_OCTET_LENGTH int =3D> for char types the - * maximum number of bytes in the column - *
  16. ORDINAL_POSITION int =3D> index of the attribute in the UDT - * (starting at 1) - *
  17. IS_NULLABLE String =3D> ISO rules are used to determine - * the nullability for a attribute. - *
      - *
    • YES --- if the attribute can include NULLs - *
    • NO --- if the attribute cannot include NULLs - *
    • empty string --- if the nullability for the - * attribute is unknown - *
    - *
  18. SCOPE_CATALOG String =3D> catalog of table that is the - * scope of a reference attribute (null if DATA_TYPE isn't = REF) - *
  19. SCOPE_SCHEMA String =3D> schema of table that is the - * scope of a reference attribute (null if DATA_TYPE isn't = REF) - *
  20. SCOPE_TABLE String =3D> table name that is the scope of a - * reference attribute (null if the DATA_TYPE isn't REF) - *
  21. SOURCE_DATA_TYPE short =3D> source type of a distinct type= or user-generated - * Ref type,SQL type from java.sql.Types (null if DATA_TYPE - * isn't DISTINCT or user-generated REF) - *
- * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves t= hose without a catalog; - * null means that the catalog = name should not be used to narrow - * the search - * @param schemaPattern a schema name pattern; must match the schema = name - * as it is stored in the database; "" retri= eves those without a schema; - * null means that the schema n= ame should not be used to narrow - * the search - * @param typeNamePattern a type name pattern; must match the - * type name as it is stored in the database - * @param attributeNamePattern an attribute name pattern; must match the= attribute - * name as it is declared in the database - * @return a ResultSet object in which each row is an - * attribute description - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - * @since 1.4 - */ - public ResultSet getAttributes(String catalog, String schemaPattern, Str= ing typeNamePattern, String attributeNamePattern) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves whether this database supports the given result set holdabi= lity. - * - * @param holdability one of the following constants: - * ResultSet.HOLD_CURSORS_OVER_COMMIT or - * ResultSet.CLOSE_CURSORS_AT_COMMIT - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @see java.sql.Connection - * @since 1.4 - */ - public boolean supportsResultSetHoldability(int holdability) throws SQLE= xception - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves this database's default holdability for ResultSet
- * objects. - * - * @return the default holdability; either - * ResultSet.HOLD_CURSORS_OVER_COMMIT or - * ResultSet.CLOSE_CURSORS_AT_COMMIT - * @throws java.sql.SQLException if a database access error occurs - * @since 1.4 - */ - public int getResultSetHoldability() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the major version number of the underlying database. - * - * @return the underlying database's major version - * @throws java.sql.SQLException if a database access error occurs - * @since 1.4 - */ - public int getDatabaseMajorVersion() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the minor version number of the underlying database. - * - * @return underlying database's minor version - * @throws java.sql.SQLException if a database access error occurs - * @since 1.4 - */ - public int getDatabaseMinorVersion() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Retrieves the major JDBC version number for this - * driver. - * - * @return JDBC version major number - * @throws java.sql.SQLException if a database access error occurs - * @since 1.4 - */ - public int getJDBCMajorVersion() throws SQLException - { - return jdbcVersion; - } - - /** - * Retrieves the minor JDBC version number for this - * driver. - * - * @return JDBC version minor number - * @throws java.sql.SQLException if a database access error occurs - * @since 1.4 - */ - public int getJDBCMinorVersion() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Indicates whether the SQLSTATE returned by SQLException.getSQLS= tate - * is X/Open (now known as Open Group) SQL CLI or SQL:2003. - * - * @return the type of SQLSTATE; one of: - * sqlStateXOpen or - * sqlStateSQL - * @throws java.sql.SQLException if a database access error occurs - * @since 1.4 - */ - public int getSQLStateType() throws SQLException - { - return 0; //To change body of implemented methods use File | Settings = | File Templates. - } - - /** - * Indicates whether updates made to a LOB are made on a copy or directly - * to the LOB. - * - * @return true if updates are made to a copy of the LOB; - * false if updates are made directly to the LOB - * @throws java.sql.SQLException if a database access error occurs - * @since 1.4 - */ - public boolean locatorsUpdateCopy() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether this database supports statement pooling. - * - * @return true if so; false otherwise - * @throws SQLExcpetion if a database access error occurs - * @since 1.4 - */ - public boolean supportsStatementPooling() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Indicates whether or not this data source supports the SQL ROWI= D type, - * and if so the lifetime for which a RowId object remains= valid. - *

- * The returned int values have the following relationship: - *

-		 *     ROWID_UNSUPPORTED < ROWID_VALID_OTHER < ROWID_VALID_TRANSACTION
-		 *         < ROWID_VALID_SESSION < ROWID_VALID_FOREVER
-		 * 
- * so conditional logic such as - *
-		 *     if (metadata.getRowIdLifetime() > DatabaseMetaData.ROWID_VALID_TR=
ANSACTION)
-		 * 
- * can be used. Valid Forever means valid across all Sessions, and valid= for - * a Session means valid across all its contained Transactions. - * - * @return the status indicating the lifetime of a RowId - * @throws java.sql.SQLException if a database access error occurs - * @since 1.6 - */ - public RowIdLifetime getRowIdLifetime() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves the schema names available in this database. The results - * are ordered by TABLE_CATALOG and - * TABLE_SCHEM. - *

- *

The schema columns are: - *

    - *
  1. TABLE_SCHEM String =3D> schema name - *
  2. TABLE_CATALOG String =3D> catalog name (may be null<= /code>) - *
- * - * @param catalog a catalog name; must match the catalog name as it is= stored - * in the database;"" retrieves those without a cat= alog; null means catalog - * name should not be used to narrow down the searc= h. - * @param schemaPattern a schema name; must match the schema name as it = is - * stored in the database; null means - * schema name should not be used to narrow down th= e search. - * @return a ResultSet object in which each row is a - * schema description - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - * @since 1.6 - */ - public ResultSet getSchemas(String catalog, String schemaPattern) throws= SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves whether this database supports invoking user-defined or ven= dor functions - * using the stored procedure escape syntax. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.6 - */ - public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLExcept= ion - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves whether a SQLException while autoCommit is true inidcates - * that all open ResultSets are closed, even ones that are holdable. Wh= en a SQLException occurs while - * autocommit is true, it is vendor specific whether the JD= BC driver responds with a commit operation, a - * rollback operation, or by doing neither a commit nor a rollback. A p= otential result of this difference - * is in whether or not holdable ResultSets are closed. - * - * @return true if so; false otherwise - * @throws java.sql.SQLException if a database access error occurs - * @since 1.6 - */ - public boolean autoCommitFailureClosesAllResultSets() throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - - /** - * Retrieves a list of the client info properties - * that the driver supports. The result set contains the following colu= mns - *

- *

    - *
  1. NAME String=3D> The name of the client info property
    - *
  2. MAX_LEN int=3D> The maximum length of the value for the pr= operty
    - *
  3. DEFAULT_VALUE String=3D> The default value of the property=
    - *
  4. DESCRIPTION String=3D> A description of the property. Thi= s will typically - * contain information as to where this property is - * stored in the database. - *
- *

- * The ResultSet is sorted by the NAME column - *

- * - * @throws java.sql.SQLException if a database access error occurs - *

- * @return A ResultSet object; each row is a supported clie= nt info - * property - *

- * @since 1.6 - */ - public ResultSet getClientInfoProperties() throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the system and user functions available - * in the given catalog. - *

- * Only system and user function descriptions matching the schema and - * function name criteria are returned. They are ordered by - * FUNCTION_CAT, FUNCTION_SCHEM, - * FUNCTION_NAME and - * SPECIFIC_ NAME. - *

- *

Each function description has the the following columns: - *

    - *
  1. FUNCTION_CAT String =3D> function catalog (may be nu= ll) - *
  2. FUNCTION_SCHEM String =3D> function schema (may be n= ull) - *
  3. FUNCTION_NAME String =3D> function name. This is the name - * used to invoke the function - *
  4. REMARKS String =3D> explanatory comment on the function - *
  5. FUNCTION_TYPE short =3D> kind of function: - *
      - *
    • functionResultUnknown - Cannot determine if a return value - * or table will be returned - *
    • functionNoTable- Does not return a table - *
    • functionReturnsTable - Returns a table - *
    - *
  6. SPECIFIC_NAME String =3D> the name which uniquely identif= ies - * this function within its schema. This is a user specified, or DBMS - * generated, name that may be different then the FUNCTION_NAME - * for example with overload functions - *
- *

- * A user may not have permission to execute any of the functions that a= re - * returned by getFunctions - * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves th= ose without a catalog; - * null means that the catalog n= ame should not be used to narrow - * the search - * @param schemaPattern a schema name pattern; must match the schema n= ame - * as it is stored in the database; "" retrie= ves those without a schema; - * null means that the schema na= me should not be used to narrow - * the search - * @param functionNamePattern a function name pattern; must match the - * function name as it is stored in the datab= ase - * @return ResultSet - each row is a function description - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - * @since 1.6 - */ - public ResultSet getFunctions(String catalog, String schemaPattern, Stri= ng functionNamePattern) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Retrieves a description of the given catalog's system or user - * function parameters and return type. - *

- *

Only descriptions matching the schema, function and - * parameter name criteria are returned. They are ordered by - * FUNCTION_CAT, FUNCTION_SCHEM, - * FUNCTION_NAME and - * SPECIFIC_ NAME. Within this, the return value, - * if any, is first. Next are the parameter descriptions in call - * order. The column descriptions follow in column number order. - *

- *

Each row in the ResultSet - * is a parameter description, column description or - * return type description with the following fields: - *

    - *
  1. FUNCTION_CAT String =3D> function catalog (may be nu= ll) - *
  2. FUNCTION_SCHEM String =3D> function schema (may be n= ull) - *
  3. FUNCTION_NAME String =3D> function name. This is the name - * used to invoke the function - *
  4. COLUMN_NAME String =3D> column/parameter name - *
  5. COLUMN_TYPE Short =3D> kind of column/parameter: - *
      - *
    • functionColumnUnknown - nobody knows - *
    • functionColumnIn - IN parameter - *
    • functionColumnInOut - INOUT parameter - *
    • functionColumnOut - OUT parameter - *
    • functionColumnReturn - function return value - *
    • functionColumnResult - Indicates that the parameter or column - * is a column in the ResultSet - *
    - *
  6. DATA_TYPE int =3D> SQL type from java.sql.Types - *
  7. TYPE_NAME String =3D> SQL type name, for a UDT type the - * type name is fully qualified - *
  8. PRECISION int =3D> precision - *
  9. LENGTH int =3D> length in bytes of data - *
  10. SCALE short =3D> scale - null is returned for data types = where - * SCALE is not applicable. - *
  11. RADIX short =3D> radix - *
  12. NULLABLE short =3D> can it contain NULL. - *
      - *
    • functionNoNulls - does not allow NULL values - *
    • functionNullable - allows NULL values - *
    • functionNullableUnknown - nullability unknown - *
    - *
  13. REMARKS String =3D> comment describing column/parameter - *
  14. CHAR_OCTET_LENGTH int =3D> the maximum length of binary - * and character based parameters or columns. For any other datatype th= e returned value - * is a NULL - *
  15. ORDINAL_POSITION int =3D> the ordinal position, starting - * from 1, for the input and output parameters. A value of 0 - * is returned if this row describes the function's return value. - * For result set columns, it is the - * ordinal position of the column in the result set starting from 1. - *
  16. IS_NULLABLE String =3D> ISO rules are used to determine - * the nullability for a parameter or column. - *
      - *
    • YES --- if the parameter or column can include NULLs - *
    • NO --- if the parameter or column cannot include NUL= Ls - *
    • empty string --- if the nullability for the - * parameter or column is unknown - *
    - *
  17. SPECIFIC_NAME String =3D> the name which uniquely identif= ies - * this function within its schema. This is a user specified, or DBMS - * generated, name that may be different then the FUNCTION_NAME - * for example with overload functions - *
- *

- *

The PRECISION column represents the specified column size for the = given - * parameter or column. - * For numeric data, this is the maximum precision. For character data,= this is the length in characters. - * For datetime datatypes, this is the length in characters of the Strin= g representation (assuming the - * maximum allowed precision of the fractional seconds component). For b= inary data, this is the length in bytes. For the ROWID datatype, - * this is the length in bytes. Null is returned for data types where the - * column size is not applicable. - * - * @param catalog a catalog name; must match the catalog name as it - * is stored in the database; "" retrieves th= ose without a catalog; - * null means that the catalog n= ame should not be used to narrow - * the search - * @param schemaPattern a schema name pattern; must match the schema n= ame - * as it is stored in the database; "" retrie= ves those without a schema; - * null means that the schema na= me should not be used to narrow - * the search - * @param functionNamePattern a procedure name pattern; must match the - * function name as it is stored in the datab= ase - * @param columnNamePattern a parameter name pattern; must match the - * parameter or column name as it is stored i= n the database - * @return ResultSet - each row describes a - * user function parameter, column or return type - * @throws java.sql.SQLException if a database access error occurs - * @see #getSearchStringEscape - * @since 1.6 - */ - public ResultSet getFunctionColumns(String catalog, String schemaPattern= , String functionNamePattern, String columnNamePattern) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Returns an object that implements the given interface to allow access= to - * non-standard methods, or standard methods not exposed by the proxy. - *

- * If the receiver implements the interface then the result is the recei= ver - * or a proxy for the receiver. If the receiver is a wrapper - * and the wrapped object implements the interface then the result is the - * wrapped object or a proxy for the wrapped object. Otherwise return the - * the result of calling unwrap recursively on the wrapped = object - * or a proxy for that result. If the receiver is not a - * wrapper and does not implement the interface, then an SQLExcept= ion is thrown. - * - * @param iface A Class defining an interface that the result must imple= ment. - * @return an object that implements the interface. May be a proxy for t= he actual implementing object. - * @throws java.sql.SQLException If no object found that implements the = interface - * @since 1.6 - */ - public T unwrap(Class iface) throws SQLException - { - return null; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - /** - * Returns true if this either implements the interface argument or is d= irectly or indirectly a wrapper - * for an object that does. Returns false otherwise. If this implements = the interface then return true, - * else if this is a wrapper then return the result of recursively calli= ng isWrapperFor on the wrapped - * object. If this does not implement the interface and is not a wrapper= , return false. - * This method should be implemented as a low-cost operation compared to= unwrap so that - * callers can use this method to avoid expensive unwrap ca= lls that may fail. If this method - * returns true then calling unwrap with the same argument = should succeed. - * - * @param iface a Class defining an interface. - * @return true if this implements the interface or directly or indirect= ly wraps an object that does. - * @throws java.sql.SQLException if an error occurs while determining wh= ether this is a wrapper - * for an object with the given interface. - * @since 1.6 - */ - public boolean isWrapperFor(Class iface) throws SQLException - { - return false; //To change body of implemented methods use File | Setti= ngs | File Templates. - } - } - } --===============8998351216363392451==-- From hibernate-commits at lists.jboss.org Sat Nov 14 07:55:13 2009 Content-Type: multipart/mixed; boundary="===============0420183513507683419==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17980 - annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/type. Date: Sat, 14 Nov 2009 07:55:12 -0500 Message-ID: <200911141255.nAECtCmv025397@svn01.web.mwc.hst.phx2.redhat.com> --===============0420183513507683419== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-14 07:55:12 -0500 (Sat, 14 Nov 2009) New Revision: 17980 Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/type/Serializab= leToBlobType.java Log: JBPAPP-906 HHH-2990 - Bad usage of ClassLoader.loadClass() for Java6 in Ser= ializationHelper - deserialization bottleneck for arrays Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/type/Ser= ializableToBlobType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/type/Serializa= bleToBlobType.java 2009-11-14 03:45:27 UTC (rev 17979) +++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/type/Serializa= bleToBlobType.java 2009-11-14 12:55:12 UTC (rev 17980) @@ -65,8 +65,8 @@ return SerializationHelper.serialize( (Serializable) object ); } = - private static Object fromBytes(byte[] bytes) throws SerializationExcepti= on { - return SerializationHelper.deserialize( bytes ); + private Object fromBytes(byte[] bytes) throws SerializationException { + return SerializationHelper.deserialize( bytes, getReturnedClass().getCla= ssLoader() ); } = public void set(PreparedStatement st, Object value, int index, SessionImp= lementor session) throws SQLException { --===============0420183513507683419==-- From hibernate-commits at lists.jboss.org Sat Nov 14 07:56:09 2009 Content-Type: multipart/mixed; boundary="===============2812827933476591188==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17981 - in core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate: util and 1 other directory. Date: Sat, 14 Nov 2009 07:56:09 -0500 Message-ID: <200911141256.nAECu98f025536@svn01.web.mwc.hst.phx2.redhat.com> --===============2812827933476591188== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-14 07:56:08 -0500 (Sat, 14 Nov 2009) New Revision: 17981 Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/SerializableTyp= e.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/util/SerializationHe= lper.java Log: JBPAPP-906 HHH-2990 - Bad usage of ClassLoader.loadClass() for Java6 in Ser= ializationHelper - deserialization bottleneck for arrays Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/Serializ= ableType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/SerializableTy= pe.java 2009-11-14 12:55:12 UTC (rev 17980) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/SerializableTy= pe.java 2009-11-14 12:56:08 UTC (rev 17981) @@ -78,8 +78,8 @@ return SerializationHelper.serialize( (Serializable) object ); } = - private static Object fromBytes( byte[] bytes ) throws SerializationExcep= tion { - return SerializationHelper.deserialize(bytes); + private Object fromBytes( byte[] bytes ) throws SerializationException { + return SerializationHelper.deserialize( bytes, getReturnedClass().getCla= ssLoader() ); } = public int sqlType() { Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/util/Serializ= ationHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/util/SerializationH= elper.java 2009-11-14 12:55:12 UTC (rev 17980) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/util/SerializationH= elper.java 2009-11-14 12:56:08 UTC (rev 17981) @@ -113,7 +113,10 @@ */ public static Object clone(Serializable object) throws SerializationEx= ception { log.trace("Starting clone through serialization"); - return deserialize( serialize(object) ); + if ( object =3D=3D null ) { + return null; + } + return deserialize( serialize( object ), object.getClass().getClas= sLoader() ); } = // Serialize @@ -182,62 +185,107 @@ // Deserialize //--------------------------------------------------------------------= --- /** - *

Deserializes an Object from the specified stream. + * Deserializes an object from the specified stream using the Thread C= ontext + * ClassLoader (TCCL). If there is no TCCL set, the classloader of the c= alling + * class is used. + *

+ * Delegates to {@link #deserialize(java.io.InputStream, ClassLoader)} * - *

The stream will be closed once the object is written. This - * avoids the need for a finally clause, and maybe also exception - * handling, in the application code.

+ * @param inputStream the serialized object input stream, must not be= null + * @return the deserialized object + * @throws IllegalArgumentException if inputStream is null
+ * @throws SerializationException (runtime) if the serialization fails + */ + public static Object deserialize(InputStream inputStream) throws Seria= lizationException { + return deserialize( inputStream, Thread.currentThread().getContextClassL= oader() ); + } + + /** + * Deserializes an object from the specified stream using the Thread C= ontext + * ClassLoader (TCCL). If there is no TCCL set, the classloader of the c= alling + * class is used. + *

+ * The stream will be closed once the object is read. This avoids the = need = + * for a finally clause, and maybe also exception handling, in the applic= ation + * code. + *

+ * The stream passed in is not buffered internally within this method.= This is + * the responsibility of the caller, if desired. * - *

The stream passed in is not buffered internally within this meth= od. - * This is the responsibility of your application if desired.

- * * @param inputStream the serialized object input stream, must not be= null + * @param loader The classloader to use + * * @return the deserialized object + * * @throws IllegalArgumentException if inputStream is null
* @throws SerializationException (runtime) if the serialization fails */ - public static Object deserialize(InputStream inputStream) throws Seria= lizationException { + public static Object deserialize(InputStream inputStream, ClassLoader = loader) throws SerializationException { if (inputStream =3D=3D null) { - throw new IllegalArgumentException("The InputStream must not b= e null"); + throw new IllegalArgumentException( "The InputStream must not = be null" ); } = - log.trace("Starting deserialization of object"); + log.trace( "Starting deserialization of object" ); = - CustomObjectInputStream in =3D null; - try { - // stream closed in the finally - in =3D new CustomObjectInputStream(inputStream); - return in.readObject(); + try { + CustomObjectInputStream in =3D new CustomObjectInputStream( inputStream= , loader ); + try { + return in.readObject(); + } + catch ( ClassNotFoundException e ) { + throw new SerializationException( "could not deserialize", e ); + } + catch ( IOException e ) { + throw new SerializationException( "could not deserialize", e ); + } + finally { + try { + in.close(); + } + catch (IOException ignore) { + // ignore + } + } + } + catch ( IOException e ) { + throw new SerializationException( "could not deserialize", e ); + } + } = - } - catch (ClassNotFoundException ex) { - throw new SerializationException("could not deserialize", ex); - } - catch (IOException ex) { - throw new SerializationException("could not deserialize", ex); - } - finally { - try { - if (in !=3D null) in.close(); - } - catch (IOException ex) {} - } + /** + * Deserializes an Object from an array of bytes. + *

+ * Delegates to {@link #deserialize(byte[], ClassLoader)} + * + * @param objectData the serialized object, must not be null + * @return the deserialized object + * @throws IllegalArgumentException if objectData is null + * @throws SerializationException (runtime) if the serialization fails + */ + public static Object deserialize(byte[] objectData) throws Serializati= onException { + return deserialize( objectData, Thread.currentThread().getContextClassLo= ader() ); } = /** - *

Deserializes a single Object from an array of bytes= .

+ * Deserializes an Object from an array of bytes. + *

+ * Delegates to {@link #deserialize(java.io.InputStream, ClassLoader)} us= ing a + * {@link ByteArrayInputStream} to wrap the array. * * @param objectData the serialized object, must not be null + * @param loader The classloader to use + * * @return the deserialized object + * * @throws IllegalArgumentException if objectData is null * @throws SerializationException (runtime) if the serialization fails */ - public static Object deserialize(byte[] objectData) throws Serializati= onException { - if (objectData =3D=3D null) { - throw new IllegalArgumentException("The byte[] must not be nul= l"); + public static Object deserialize(byte[] objectData, ClassLoader loader= ) throws SerializationException { + if ( objectData =3D=3D null ) { + throw new IllegalArgumentException( "The byte[] must not be nu= ll" ); } - ByteArrayInputStream bais =3D new ByteArrayInputStream(objectData); - return deserialize(bais); + ByteArrayInputStream bais =3D new ByteArrayInputStream( objectData= ); + return deserialize( bais, loader ); } = = @@ -247,28 +295,27 @@ * the same purpose). */ private static final class CustomObjectInputStream extends ObjectInputStr= eam { + private final ClassLoader loader; = - public CustomObjectInputStream(InputStream in) throws IOException { - super(in); + private CustomObjectInputStream(InputStream in, ClassLoader loader) thro= ws IOException { + super( in ); + this.loader =3D loader; } = protected Class resolveClass(ObjectStreamClass v) throws IOException, Cl= assNotFoundException { String className =3D v.getName(); - Class resolvedClass =3D null; - log.trace("Attempting to locate class [" + className + "]"); = - ClassLoader loader =3D Thread.currentThread().getContextClassLoader(); - try { - resolvedClass =3D loader.loadClass(className); - log.trace("Class resolved through context class loader"); + if ( loader !=3D null ) { + try { + return Class.forName( className, false, loader ); + } + catch (ClassNotFoundException e) { + log.trace( "Unable to locate class using given classloader" ); + } } - catch(ClassNotFoundException e) { - log.trace("Asking super to resolve"); - resolvedClass =3D super.resolveClass(v); - } = - return resolvedClass; + return super.resolveClass( v ); } } } --===============2812827933476591188==-- From hibernate-commits at lists.jboss.org Sat Nov 14 08:21:01 2009 Content-Type: multipart/mixed; boundary="===============4368579962563186330==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17982 - annotations/branches/v3_4_0_GA_CP/src/java/org/hibernate/type. Date: Sat, 14 Nov 2009 08:18:45 -0500 Message-ID: <200911141318.nAEDIj6s030270@svn01.web.mwc.hst.phx2.redhat.com> --===============4368579962563186330== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-14 08:18:39 -0500 (Sat, 14 Nov 2009) New Revision: 17982 Modified: annotations/branches/v3_4_0_GA_CP/src/java/org/hibernate/type/Serializab= leToBlobType.java Log: JBPAPP-2277 HHH-2990 - Bad usage of ClassLoader.loadClass() for Java6 in Se= rializationHelper - deserialization bottleneck for arrays Modified: annotations/branches/v3_4_0_GA_CP/src/java/org/hibernate/type/Ser= ializableToBlobType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/java/org/hibernate/type/Serializa= bleToBlobType.java 2009-11-14 12:56:08 UTC (rev 17981) +++ annotations/branches/v3_4_0_GA_CP/src/java/org/hibernate/type/Serializa= bleToBlobType.java 2009-11-14 13:18:39 UTC (rev 17982) @@ -65,8 +65,8 @@ return SerializationHelper.serialize( (Serializable) object ); } = - private static Object fromBytes(byte[] bytes) throws SerializationExcepti= on { - return SerializationHelper.deserialize( bytes ); + private Object fromBytes(byte[] bytes) throws SerializationException { + return SerializationHelper.deserialize( bytes, getReturnedClass().getCla= ssLoader() ); } = public void set(PreparedStatement st, Object value, int index, SessionImp= lementor session) throws SQLException { --===============4368579962563186330==-- From hibernate-commits at lists.jboss.org Sat Nov 14 08:21:07 2009 Content-Type: multipart/mixed; boundary="===============0822417111110756554==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17983 - in core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate: util and 1 other directory. Date: Sat, 14 Nov 2009 08:20:32 -0500 Message-ID: <200911141320.nAEDKWvJ030705@svn01.web.mwc.hst.phx2.redhat.com> --===============0822417111110756554== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-14 08:20:27 -0500 (Sat, 14 Nov 2009) New Revision: 17983 Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/type/S= erializableType.java core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util/S= erializationHelper.java Log: JBPAPP-2277 HHH-2990 - Bad usage of ClassLoader.loadClass() for Java6 in Se= rializationHelper - deserialization bottleneck for arrays Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate= /type/SerializableType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/type/= SerializableType.java 2009-11-14 13:18:39 UTC (rev 17982) +++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/type/= SerializableType.java 2009-11-14 13:20:27 UTC (rev 17983) @@ -101,8 +101,8 @@ return SerializationHelper.serialize( (Serializable) object ); } = - private static Object fromBytes( byte[] bytes ) throws SerializationExcep= tion { - return SerializationHelper.deserialize(bytes); + private Object fromBytes( byte[] bytes ) throws SerializationException { + return SerializationHelper.deserialize( bytes, getReturnedClass().getCla= ssLoader() ); } = public int sqlType() { Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate= /util/SerializationHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util/= SerializationHelper.java 2009-11-14 13:18:39 UTC (rev 17982) +++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/util/= SerializationHelper.java 2009-11-14 13:20:27 UTC (rev 17983) @@ -84,7 +84,10 @@ */ public static Object clone(Serializable object) throws SerializationEx= ception { log.trace("Starting clone through serialization"); - return deserialize( serialize(object) ); + if ( object =3D=3D null ) { + return null; + } + return deserialize( serialize( object ), object.getClass().getClas= sLoader() ); } = // Serialize @@ -153,62 +156,107 @@ // Deserialize //--------------------------------------------------------------------= --- /** - *

Deserializes an Object from the specified stream. + * Deserializes an object from the specified stream using the Thread C= ontext + * ClassLoader (TCCL). If there is no TCCL set, the classloader of the c= alling + * class is used. + *

+ * Delegates to {@link #deserialize(java.io.InputStream, ClassLoader)} * - *

The stream will be closed once the object is written. This - * avoids the need for a finally clause, and maybe also exception - * handling, in the application code.

+ * @param inputStream the serialized object input stream, must not be= null + * @return the deserialized object + * @throws IllegalArgumentException if inputStream is null + * @throws SerializationException (runtime) if the serialization fails + */ + public static Object deserialize(InputStream inputStream) throws Seria= lizationException { + return deserialize( inputStream, Thread.currentThread().getContextClassL= oader() ); + } + + /** + * Deserializes an object from the specified stream using the Thread C= ontext + * ClassLoader (TCCL). If there is no TCCL set, the classloader of the c= alling + * class is used. + *

+ * The stream will be closed once the object is read. This avoids the = need = + * for a finally clause, and maybe also exception handling, in the applic= ation + * code. + *

+ * The stream passed in is not buffered internally within this method.= This is + * the responsibility of the caller, if desired. * - *

The stream passed in is not buffered internally within this meth= od. - * This is the responsibility of your application if desired.

- * * @param inputStream the serialized object input stream, must not be= null + * @param loader The classloader to use + * * @return the deserialized object + * * @throws IllegalArgumentException if inputStream is null * @throws SerializationException (runtime) if the serialization fails */ - public static Object deserialize(InputStream inputStream) throws Seria= lizationException { + public static Object deserialize(InputStream inputStream, ClassLoader = loader) throws SerializationException { if (inputStream =3D=3D null) { - throw new IllegalArgumentException("The InputStream must not b= e null"); + throw new IllegalArgumentException( "The InputStream must not = be null" ); } = - log.trace("Starting deserialization of object"); + log.trace( "Starting deserialization of object" ); = - CustomObjectInputStream in =3D null; - try { - // stream closed in the finally - in =3D new CustomObjectInputStream(inputStream); - return in.readObject(); + try { + CustomObjectInputStream in =3D new CustomObjectInputStream( inputStream= , loader ); + try { + return in.readObject(); + } + catch ( ClassNotFoundException e ) { + throw new SerializationException( "could not deserialize", e ); + } + catch ( IOException e ) { + throw new SerializationException( "could not deserialize", e ); + } + finally { + try { + in.close(); + } + catch (IOException ignore) { + // ignore + } + } + } + catch ( IOException e ) { + throw new SerializationException( "could not deserialize", e ); + } + } = - } - catch (ClassNotFoundException ex) { - throw new SerializationException("could not deserialize", ex); - } - catch (IOException ex) { - throw new SerializationException("could not deserialize", ex); - } - finally { - try { - if (in !=3D null) in.close(); - } - catch (IOException ex) {} - } + /** + * Deserializes an Object from an array of bytes. + *

+ * Delegates to {@link #deserialize(byte[], ClassLoader)} + * + * @param objectData the serialized object, must not be null + * @return the deserialized object + * @throws IllegalArgumentException if objectData is null + * @throws SerializationException (runtime) if the serialization fails + */ + public static Object deserialize(byte[] objectData) throws Serializati= onException { + return deserialize( objectData, Thread.currentThread().getContextClassLo= ader() ); } = /** - *

Deserializes a single Object from an array of bytes= .

+ * Deserializes an Object from an array of bytes. + *

+ * Delegates to {@link #deserialize(java.io.InputStream, ClassLoader)} us= ing a + * {@link ByteArrayInputStream} to wrap the array. * * @param objectData the serialized object, must not be null + * @param loader The classloader to use + * * @return the deserialized object + * * @throws IllegalArgumentException if objectData is null * @throws SerializationException (runtime) if the serialization fails */ - public static Object deserialize(byte[] objectData) throws Serializati= onException { - if (objectData =3D=3D null) { - throw new IllegalArgumentException("The byte[] must not be nul= l"); + public static Object deserialize(byte[] objectData, ClassLoader loader= ) throws SerializationException { + if ( objectData =3D=3D null ) { + throw new IllegalArgumentException( "The byte[] must not be nu= ll" ); } - ByteArrayInputStream bais =3D new ByteArrayInputStream(objectData); - return deserialize(bais); + ByteArrayInputStream bais =3D new ByteArrayInputStream( objectData= ); + return deserialize( bais, loader ); } = = @@ -218,28 +266,27 @@ * the same purpose). */ private static final class CustomObjectInputStream extends ObjectInputStr= eam { + private final ClassLoader loader; = - public CustomObjectInputStream(InputStream in) throws IOException { - super(in); + private CustomObjectInputStream(InputStream in, ClassLoader loader) thro= ws IOException { + super( in ); + this.loader =3D loader; } = protected Class resolveClass(ObjectStreamClass v) throws IOException, Cl= assNotFoundException { String className =3D v.getName(); - Class resolvedClass =3D null; - log.trace("Attempting to locate class [" + className + "]"); = - ClassLoader loader =3D Thread.currentThread().getContextClassLoader(); - try { - resolvedClass =3D loader.loadClass(className); - log.trace("Class resolved through context class loader"); + if ( loader !=3D null ) { + try { + return Class.forName( className, false, loader ); + } + catch (ClassNotFoundException e) { + log.trace( "Unable to locate class using given classloader" ); + } } - catch(ClassNotFoundException e) { - log.trace("Asking super to resolve"); - resolvedClass =3D super.resolveClass(v); - } = - return resolvedClass; + return super.resolveClass( v ); } } } --===============0822417111110756554==-- From hibernate-commits at lists.jboss.org Sat Nov 14 13:03:16 2009 Content-Type: multipart/mixed; boundary="===============7245666647776852021==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17984 - core/trunk/core/src/main/java/org/hibernate/util. Date: Sat, 14 Nov 2009 13:03:16 -0500 Message-ID: <200911141803.nAEI3GJ6017775@svn01.web.mwc.hst.phx2.redhat.com> --===============7245666647776852021== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-14 13:03:16 -0500 (Sat, 14 Nov 2009) New Revision: 17984 Modified: core/trunk/core/src/main/java/org/hibernate/util/SerializationHelper.java Log: HHH-4572 - check if the connection supports jdbc4 before looking for the cr= eateClob method Modified: core/trunk/core/src/main/java/org/hibernate/util/SerializationHel= per.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/util/SerializationHelper.ja= va 2009-11-14 13:20:27 UTC (rev 17983) +++ core/trunk/core/src/main/java/org/hibernate/util/SerializationHelper.ja= va 2009-11-14 18:03:16 UTC (rev 17984) @@ -224,7 +224,9 @@ } = /** - * Deserializes an Object from an array of bytes. + * Deserializes an object from an array of bytes using the Thread Cont= ext + * ClassLoader (TCCL). If there is no TCCL set, the classloader of the c= alling + * class is used. *

* Delegates to {@link #deserialize(byte[], ClassLoader)} * @@ -238,7 +240,7 @@ } = /** - * Deserializes an Object from an array of bytes. + * Deserializes an object from an array of bytes. *

* Delegates to {@link #deserialize(java.io.InputStream, ClassLoader)} us= ing a * {@link ByteArrayInputStream} to wrap the array. @@ -261,9 +263,12 @@ = = /** - * Custom ObjectInputStream implementation to more appropriately handle c= lassloading - * within app servers (mainly jboss - hence this class inspired by jboss'= s class of - * the same purpose). + * By default, to resolve the classes being deserialized JDK serializatio= n uses the + * classes loader which loaded the class which initiated the deserializat= ion call. Here + * that would be hibernate classes. However, there are cases where that = is not the correct + * class loader to use; mainly here we are worried about deserializing us= er classes in + * environments (app servers, etc) where Hibernate is on a parent classes= loader. To + * facilitate for that we allow passing in the class loader we should use. */ private static final class CustomObjectInputStream extends ObjectInputStr= eam { private final ClassLoader loader; @@ -273,10 +278,14 @@ this.loader =3D loader; } = + /** + * {@inheritDoc} + */ protected Class resolveClass(ObjectStreamClass v) throws IOException, Cl= assNotFoundException { String className =3D v.getName(); log.trace("Attempting to locate class [" + className + "]"); = + // if we were given a classloader, attempt to use it to resolve the cla= ss... if ( loader !=3D null ) { try { return Class.forName( className, false, loader ); @@ -286,6 +295,8 @@ } } = + // By default delegate to normal JDK deserialization which will use the= class loader + // of the class which is calling this deserialization. return super.resolveClass( v ); } } --===============7245666647776852021==-- From hibernate-commits at lists.jboss.org Mon Nov 16 08:50:07 2009 Content-Type: multipart/mixed; boundary="===============3180361221168296476==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17986 - core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql. Date: Mon, 16 Nov 2009 08:50:06 -0500 Message-ID: <200911161350.nAGDo6d4005875@svn01.web.mwc.hst.phx2.redhat.com> --===============3180361221168296476== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-16 08:50:05 -0500 (Mon, 16 Nov 2009) New Revision: 17986 Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/BulkManipu= lationTest.java core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/Vehicle.hb= m.xml Log: JBPAPP-3067 HHH-4576 - Tests in MySQL using different case for objects as d= efined in configuration Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/Bul= kManipulationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/BulkManip= ulationTest.java 2009-11-16 13:01:09 UTC (rev 17985) +++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/BulkManip= ulationTest.java 2009-11-16 13:50:05 UTC (rev 17986) @@ -186,7 +186,7 @@ List l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),4); = - s.createSQLQuery( "insert into PICKUP (id, vin, owner) select id, vin, o= wner from Car" ).executeUpdate(); + s.createSQLQuery( "insert into Pickup (id, vin, owner) select id, vin, o= wner from Car" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),5); @@ -194,7 +194,7 @@ t.commit(); t =3D s.beginTransaction(); = - s.createSQLQuery( "delete from TRUCK" ).executeUpdate(); + s.createSQLQuery( "delete from Truck" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),4); @@ -207,7 +207,7 @@ = assertEquals(0,s.createSQLQuery( "delete from SUV where owner =3D :owner= " ).setString( "owner", "NotThere" ).executeUpdate()); assertEquals(1,s.createSQLQuery( "delete from SUV where owner =3D :owner= " ).setString( "owner", "Joe" ).executeUpdate()); - s.createSQLQuery( "delete from PICKUP" ).executeUpdate(); + s.createSQLQuery( "delete from Pickup" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),0); Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/Veh= icle.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/Vehicle.h= bm.xml 2009-11-16 13:01:09 UTC (rev 17985) +++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/Vehicle.h= bm.xml 2009-11-16 13:50:05 UTC (rev 17986) @@ -26,6 +26,6 @@ = - delete from CAR where owner =3D ? + delete from Car where owner =3D ? \ No newline at end of file --===============3180361221168296476==-- From hibernate-commits at lists.jboss.org Mon Nov 16 08:50:49 2009 Content-Type: multipart/mixed; boundary="===============2270021823388383589==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17987 - core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/sql/hand/custom/mysql. Date: Mon, 16 Nov 2009 08:50:49 -0500 Message-ID: <200911161350.nAGDon96006191@svn01.web.mwc.hst.phx2.redhat.com> --===============2270021823388383589== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-16 08:50:49 -0500 (Mon, 16 Nov 2009) New Revision: 17987 Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/sql/hand/custo= m/mysql/Mappings.hbm.xml Log: JBPAPP-3067 HHH-4576 - Tests in MySQL using different case for objects as d= efined in configuration Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/sql/han= d/custom/mysql/Mappings.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/sql/hand/cust= om/mysql/Mappings.hbm.xml 2009-11-16 13:50:05 UTC (rev 17986) +++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/sql/hand/cust= om/mysql/Mappings.hbm.xml 2009-11-16 13:50:49 UTC (rev 17987) @@ -26,9 +26,9 @@ - INSERT INTO ORGANIZATION (NAME, ORGID) VALUES ( UPPER(?), ? = ) - UPDATE ORGANIZATION SET NAME=3DUPPER(?) WHERE ORGID=3D? - DELETE FROM ORGANIZATION WHERE ORGID=3D? + INSERT INTO Organization (NAME, ORGID) VALUES ( UPPER(?), ? = ) + UPDATE Organization SET NAME=3DUPPER(?) WHERE ORGID=3D? + DELETE FROM Organization WHERE ORGID=3D? = @@ -37,9 +37,9 @@ - INSERT INTO PERSON (NAME, PERID) VALUES ( UPPER(?), ? ) - UPDATE PERSON SET NAME=3DUPPER(?) WHERE PERID=3D? - DELETE FROM PERSON WHERE PERID=3D? + INSERT INTO Person (NAME, PERID) VALUES ( UPPER(?), ? ) + UPDATE Person SET NAME=3DUPPER(?) WHERE PERID=3D? + DELETE FROM Person WHERE PERID=3D? = @@ -57,12 +57,12 @@ - INSERT INTO EMPLOYMENT = + INSERT INTO Employment = (EMPLOYEE, EMPLOYER, STARTDATE, REGIONCODE, VALUE, CURRENCY, EMPID) = VALUES (?, ?, now(), UPPER(?), ?, ?, ?) - UPDATE EMPLOYMENT SET ENDDATE=3D?, VALUE=3D?, CURRENCY=3D? W= HERE EMPID=3D? = - DELETE FROM EMPLOYMENT WHERE EMPID=3D? = + UPDATE Employment SET ENDDATE=3D?, VALUE=3D?, CURRENCY=3D? W= HERE EMPID=3D? = + DELETE FROM Employment WHERE EMPID=3D? = = @@ -79,15 +79,15 @@ = - SELECT NAME AS {p.name}, PERID AS {p.id} FROM PERSON WHERE PERID=3D? /*F= OR UPDATE*/ + SELECT NAME AS {p.name}, PERID AS {p.id} FROM Person WHERE PERID=3D? /*F= OR UPDATE*/ = SELECT {org.*}, {emp.*} - FROM ORGANIZATION org - LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID =3D emp.EMPLOYER + FROM Organization org + LEFT OUTER JOIN Employment emp ON org.ORGID =3D emp.EMPLOYER WHERE org.ORGID=3D? = @@ -102,8 +102,8 @@ SELECT DISTINCT org.NAME AS {org.name}, org.ORGID AS {org.id} = - FROM ORGANIZATION org - INNER JOIN EMPLOYMENT e ON e.EMPLOYER =3D org.ORGID + FROM Organization org + INNER JOIN Employment e ON e.EMPLOYER =3D org.ORGID = @@ -111,7 +111,7 @@ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer}, = STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate}, REGIONCODE as {emp.regionCode}, EMPID AS {emp.id} - FROM EMPLOYMENT + FROM Employment WHERE EMPID =3D ? = @@ -119,7 +119,7 @@ SELECT {empcol.*} - FROM EMPLOYMENT empcol + FROM Employment empcol WHERE EMPLOYER =3D :id ORDER BY STARTDATE ASC, EMPLOYEE ASC @@ -140,7 +140,7 @@ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer}, = STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate}, REGIONCODE as {emp.regionCode}, EMPID AS {emp.id}, VALUE, CURRENCY - FROM EMPLOYMENT + FROM Employment WHERE EMPLOYER =3D :id AND ENDDATE IS NULL ORDER BY STARTDATE ASC @@ -186,7 +186,7 @@ CREATE PROCEDURE selectAllEmployments () SELECT EMPLOYEE, EMPLOYER, STARTDATE, ENDDATE, = REGIONCODE, EMPID, VALUE, CURRENCY - FROM EMPLOYMENT + FROM Employment DROP PROCEDURE selectAllEmployments --===============2270021823388383589==-- From hibernate-commits at lists.jboss.org Mon Nov 16 09:04:16 2009 Content-Type: multipart/mixed; boundary="===============8650392258441653402==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17988 - core/trunk/testsuite/src/test/java/org/hibernate/test/hql. Date: Mon, 16 Nov 2009 09:04:16 -0500 Message-ID: <200911161404.nAGE4Gwp008586@svn01.web.mwc.hst.phx2.redhat.com> --===============8650392258441653402== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-16 09:04:16 -0500 (Mon, 16 Nov 2009) New Revision: 17988 Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulati= onTest.java core/trunk/testsuite/src/test/java/org/hibernate/test/hql/Vehicle.hbm.xml Log: HHH-4576 - Tests in MySQL using different case for objects as defined in co= nfiguration Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/BulkMan= ipulationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulat= ionTest.java 2009-11-16 13:50:49 UTC (rev 17987) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulat= ionTest.java 2009-11-16 14:04:16 UTC (rev 17988) @@ -186,7 +186,7 @@ List l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),4); = - s.createSQLQuery( "insert into PICKUP (id, vin, owner) select id, vin, o= wner from Car" ).executeUpdate(); + s.createSQLQuery( "insert into Pickup (id, vin, owner) select id, vin, o= wner from Car" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),5); @@ -194,7 +194,7 @@ t.commit(); t =3D s.beginTransaction(); = - s.createSQLQuery( "delete from TRUCK" ).executeUpdate(); + s.createSQLQuery( "delete from Truck" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),4); @@ -207,7 +207,7 @@ = assertEquals(0,s.createSQLQuery( "delete from SUV where owner =3D :owner= " ).setString( "owner", "NotThere" ).executeUpdate()); assertEquals(1,s.createSQLQuery( "delete from SUV where owner =3D :owner= " ).setString( "owner", "Joe" ).executeUpdate()); - s.createSQLQuery( "delete from PICKUP" ).executeUpdate(); + s.createSQLQuery( "delete from Pickup" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),0); Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/Vehicle= .hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/Vehicle.hbm.x= ml 2009-11-16 13:50:49 UTC (rev 17987) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/Vehicle.hbm.x= ml 2009-11-16 14:04:16 UTC (rev 17988) @@ -26,6 +26,6 @@ = - delete from CAR where owner =3D ? + delete from Car where owner =3D ? \ No newline at end of file --===============8650392258441653402==-- From hibernate-commits at lists.jboss.org Mon Nov 16 09:05:18 2009 Content-Type: multipart/mixed; boundary="===============3455788179381480812==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17989 - core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/mysql. Date: Mon, 16 Nov 2009 09:05:18 -0500 Message-ID: <200911161405.nAGE5Ioq008974@svn01.web.mwc.hst.phx2.redhat.com> --===============3455788179381480812== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-16 09:05:17 -0500 (Mon, 16 Nov 2009) New Revision: 17989 Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/my= sql/Mappings.hbm.xml Log: HHH-4576 - Tests in MySQL using different case for objects as defined in co= nfiguration Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/cu= stom/mysql/Mappings.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/m= ysql/Mappings.hbm.xml 2009-11-16 14:04:16 UTC (rev 17988) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/m= ysql/Mappings.hbm.xml 2009-11-16 14:05:17 UTC (rev 17989) @@ -26,9 +26,9 @@ - INSERT INTO ORGANIZATION (NAME, ORGID) VALUES ( UPPER(?), ? = ) - UPDATE ORGANIZATION SET NAME=3DUPPER(?) WHERE ORGID=3D? - DELETE FROM ORGANIZATION WHERE ORGID=3D? + INSERT INTO Organization (NAME, ORGID) VALUES ( UPPER(?), ? = ) + UPDATE Organization SET NAME=3DUPPER(?) WHERE ORGID=3D? + DELETE FROM Organization WHERE ORGID=3D? = @@ -37,9 +37,9 @@ - INSERT INTO PERSON (NAME, PERID) VALUES ( UPPER(?), ? ) - UPDATE PERSON SET NAME=3DUPPER(?) WHERE PERID=3D? - DELETE FROM PERSON WHERE PERID=3D? + INSERT INTO Person (NAME, PERID) VALUES ( UPPER(?), ? ) + UPDATE Person SET NAME=3DUPPER(?) WHERE PERID=3D? + DELETE FROM Person WHERE PERID=3D? = @@ -57,12 +57,12 @@ - INSERT INTO EMPLOYMENT = + INSERT INTO Employment = (EMPLOYEE, EMPLOYER, STARTDATE, REGIONCODE, VALUE, CURRENCY, EMPID) = VALUES (?, ?, now(), UPPER(?), ?, ?, ?) - UPDATE EMPLOYMENT SET ENDDATE=3D?, VALUE=3D?, CURRENCY=3D? W= HERE EMPID=3D? = - DELETE FROM EMPLOYMENT WHERE EMPID=3D? = + UPDATE Employment SET ENDDATE=3D?, VALUE=3D?, CURRENCY=3D? W= HERE EMPID=3D? = + DELETE FROM Employment WHERE EMPID=3D? = = @@ -72,12 +72,12 @@ - INSERT INTO TEXTHOLDER + INSERT INTO TextHolder (DESCRIPTION, ID) VALUES (?, ?) - UPDATE TEXTHOLDER SET DESCRIPTION=3D? WHERE ID=3D? - DELETE FROM TEXTHOLDER WHERE ID=3D? + UPDATE TextHolder SET DESCRIPTION=3D? WHERE ID=3D? + DELETE FROM TextHolder WHERE ID=3D? = @@ -87,12 +87,12 @@ - INSERT INTO IMAGEHOLDER + INSERT INTO ImageHolder (PHOTO, ID) VALUES (?, ?) - UPDATE IMAGEHOLDER SET PHOTO=3D? WHERE ID=3D? - DELETE FROM IMAGEHOLDER WHERE ID=3D? + UPDATE ImageHolder SET PHOTO=3D? WHERE ID=3D? + DELETE FROM ImageHolder WHERE ID=3D? = @@ -109,15 +109,15 @@ = - SELECT NAME AS {p.name}, PERID AS {p.id} FROM PERSON WHERE PERID=3D? /*F= OR UPDATE*/ + SELECT NAME AS {p.name}, PERID AS {p.id} FROM Person WHERE PERID=3D? /*F= OR UPDATE*/ = SELECT {org.*}, {emp.*} - FROM ORGANIZATION org - LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID =3D emp.EMPLOYER + FROM Organization org + LEFT OUTER JOIN Employment emp ON org.ORGID =3D emp.EMPLOYER WHERE org.ORGID=3D? = @@ -132,8 +132,8 @@ SELECT DISTINCT org.NAME AS {org.name}, org.ORGID AS {org.id} = - FROM ORGANIZATION org - INNER JOIN EMPLOYMENT e ON e.EMPLOYER =3D org.ORGID + FROM Organization org + INNER JOIN Employment e ON e.EMPLOYER =3D org.ORGID = @@ -141,7 +141,7 @@ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer}, = STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate}, REGIONCODE as {emp.regionCode}, EMPID AS {emp.id} - FROM EMPLOYMENT + FROM Employment WHERE EMPID =3D ? = @@ -149,7 +149,7 @@ SELECT {empcol.*} - FROM EMPLOYMENT empcol + FROM Employment empcol WHERE EMPLOYER =3D :id ORDER BY STARTDATE ASC, EMPLOYEE ASC @@ -170,7 +170,7 @@ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer}, = STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate}, REGIONCODE as {emp.regionCode}, EMPID AS {emp.id}, VALUE, CURRENCY - FROM EMPLOYMENT + FROM Employment WHERE EMPLOYER =3D :id AND ENDDATE IS NULL ORDER BY STARTDATE ASC @@ -213,12 +213,12 @@ = - SELECT ID AS {h.id}, DESCRIPTION AS {h.description} FROM TEXTHOLDE= R WHERE ID=3D? /*FOR UPDATE*/ + SELECT ID AS {h.id}, DESCRIPTION AS {h.description} FROM TextHolde= r WHERE ID=3D? /*FOR UPDATE*/ = - SELECT ID AS {h.id}, PHOTO AS {h.photo} FROM IMAGEHOLDER WHERE ID= =3D? /*FOR UPDATE*/ + SELECT ID AS {h.id}, PHOTO AS {h.photo} FROM ImageHolder WHERE ID= =3D? /*FOR UPDATE*/ = @@ -226,7 +226,7 @@ CREATE PROCEDURE selectAllEmployments () SELECT EMPLOYEE, EMPLOYER, STARTDATE, ENDDATE, = REGIONCODE, EMPID, VALUE, CURRENCY - FROM EMPLOYMENT + FROM Employment DROP PROCEDURE selectAllEmployments --===============3455788179381480812==-- From hibernate-commits at lists.jboss.org Mon Nov 16 09:06:37 2009 Content-Type: multipart/mixed; boundary="===============7638800324786992176==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17990 - in core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test: sql/hand/custom/mysql and 1 other directory. Date: Mon, 16 Nov 2009 09:06:37 -0500 Message-ID: <200911161406.nAGE6beI009180@svn01.web.mwc.hst.phx2.redhat.com> --===============7638800324786992176== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-16 09:06:36 -0500 (Mon, 16 Nov 2009) New Revision: 17990 Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/t= est/hql/BulkManipulationTest.java core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/t= est/hql/Vehicle.hbm.xml core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/t= est/sql/hand/custom/mysql/Mappings.hbm.xml Log: JBPAPP-3067 HHH-4576 - Tests in MySQL using different case for objects as d= efined in configuration Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibe= rnate/test/hql/BulkManipulationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/= test/hql/BulkManipulationTest.java 2009-11-16 14:05:17 UTC (rev 17989) +++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/= test/hql/BulkManipulationTest.java 2009-11-16 14:06:36 UTC (rev 17990) @@ -186,7 +186,7 @@ List l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),4); = - s.createSQLQuery( "insert into PICKUP (id, vin, owner) select id, vin, o= wner from Car" ).executeUpdate(); + s.createSQLQuery( "insert into Pickup (id, vin, owner) select id, vin, o= wner from Car" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),5); @@ -194,7 +194,7 @@ t.commit(); t =3D s.beginTransaction(); = - s.createSQLQuery( "delete from TRUCK" ).executeUpdate(); + s.createSQLQuery( "delete from Truck" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),4); @@ -207,7 +207,7 @@ = assertEquals(0,s.createSQLQuery( "delete from SUV where owner =3D :owner= " ).setString( "owner", "NotThere" ).executeUpdate()); assertEquals(1,s.createSQLQuery( "delete from SUV where owner =3D :owner= " ).setString( "owner", "Joe" ).executeUpdate()); - s.createSQLQuery( "delete from PICKUP" ).executeUpdate(); + s.createSQLQuery( "delete from Pickup" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),0); Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibe= rnate/test/hql/Vehicle.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/= test/hql/Vehicle.hbm.xml 2009-11-16 14:05:17 UTC (rev 17989) +++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/= test/hql/Vehicle.hbm.xml 2009-11-16 14:06:36 UTC (rev 17990) @@ -26,6 +26,6 @@ = - delete from CAR where owner =3D ? + delete from Car where owner =3D ? \ No newline at end of file Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibe= rnate/test/sql/hand/custom/mysql/Mappings.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/= test/sql/hand/custom/mysql/Mappings.hbm.xml 2009-11-16 14:05:17 UTC (rev 17= 989) +++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/= test/sql/hand/custom/mysql/Mappings.hbm.xml 2009-11-16 14:06:36 UTC (rev 17= 990) @@ -26,9 +26,9 @@ - INSERT INTO ORGANIZATION (NAME, ORGID) VALUES ( UPPER(?), ? = ) - UPDATE ORGANIZATION SET NAME=3DUPPER(?) WHERE ORGID=3D? - DELETE FROM ORGANIZATION WHERE ORGID=3D? + INSERT INTO Organization (NAME, ORGID) VALUES ( UPPER(?), ? = ) + UPDATE Organization SET NAME=3DUPPER(?) WHERE ORGID=3D? + DELETE FROM Organization WHERE ORGID=3D? = @@ -37,9 +37,9 @@ - INSERT INTO PERSON (NAME, PERID) VALUES ( UPPER(?), ? ) - UPDATE PERSON SET NAME=3DUPPER(?) WHERE PERID=3D? - DELETE FROM PERSON WHERE PERID=3D? + INSERT INTO Person (NAME, PERID) VALUES ( UPPER(?), ? ) + UPDATE Person SET NAME=3DUPPER(?) WHERE PERID=3D? + DELETE FROM Person WHERE PERID=3D? = @@ -57,12 +57,12 @@ - INSERT INTO EMPLOYMENT = + INSERT INTO Employment = (EMPLOYEE, EMPLOYER, STARTDATE, REGIONCODE, VALUE, CURRENCY, EMPID) = VALUES (?, ?, now(), UPPER(?), ?, ?, ?) - UPDATE EMPLOYMENT SET ENDDATE=3D?, VALUE=3D?, CURRENCY=3D? W= HERE EMPID=3D? = - DELETE FROM EMPLOYMENT WHERE EMPID=3D? = + UPDATE Employment SET ENDDATE=3D?, VALUE=3D?, CURRENCY=3D? W= HERE EMPID=3D? = + DELETE FROM Employment WHERE EMPID=3D? = = @@ -86,8 +86,8 @@ SELECT {org.*}, {emp.*} - FROM ORGANIZATION org - LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID =3D emp.EMPLOYER + FROM Organization org + LEFT OUTER JOIN Employment emp ON org.ORGID =3D emp.EMPLOYER WHERE org.ORGID=3D? = @@ -102,8 +102,8 @@ SELECT DISTINCT org.NAME AS {org.name}, org.ORGID AS {org.id} = - FROM ORGANIZATION org - INNER JOIN EMPLOYMENT e ON e.EMPLOYER =3D org.ORGID + FROM Organization org + INNER JOIN Employment e ON e.EMPLOYER =3D org.ORGID = @@ -111,7 +111,7 @@ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer}, = STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate}, REGIONCODE as {emp.regionCode}, EMPID AS {emp.id} - FROM EMPLOYMENT + FROM Employment WHERE EMPID =3D ? = @@ -119,7 +119,7 @@ SELECT {empcol.*} - FROM EMPLOYMENT empcol + FROM Employment empcol WHERE EMPLOYER =3D :id ORDER BY STARTDATE ASC, EMPLOYEE ASC @@ -140,7 +140,7 @@ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer}, = STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate}, REGIONCODE as {emp.regionCode}, EMPID AS {emp.id}, VALUE, CURRENCY - FROM EMPLOYMENT + FROM Employment WHERE EMPLOYER =3D :id AND ENDDATE IS NULL ORDER BY STARTDATE ASC @@ -186,7 +186,7 @@ CREATE PROCEDURE selectAllEmployments () SELECT EMPLOYEE, EMPLOYER, STARTDATE, ENDDATE, = REGIONCODE, EMPID, VALUE, CURRENCY - FROM EMPLOYMENT + FROM Employment DROP PROCEDURE selectAllEmployments --===============7638800324786992176==-- From hibernate-commits at lists.jboss.org Mon Nov 16 09:12:38 2009 Content-Type: multipart/mixed; boundary="===============3681104858482549043==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17991 - in core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test: sql/hand/custom/mysql and 1 other directory. Date: Mon, 16 Nov 2009 09:12:38 -0500 Message-ID: <200911161412.nAGECcdl010094@svn01.web.mwc.hst.phx2.redhat.com> --===============3681104858482549043== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-16 09:12:38 -0500 (Mon, 16 Nov 2009) New Revision: 17991 Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql/= BulkManipulationTest.java core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql/= Vehicle.hbm.xml core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/sql/= hand/custom/mysql/Mappings.hbm.xml Log: HHH-4576 - Tests in MySQL using different case for objects as defined in co= nfiguration Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/te= st/hql/BulkManipulationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql= /BulkManipulationTest.java 2009-11-16 14:06:36 UTC (rev 17990) +++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql= /BulkManipulationTest.java 2009-11-16 14:12:38 UTC (rev 17991) @@ -186,7 +186,7 @@ List l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),4); = - s.createSQLQuery( "insert into PICKUP (id, vin, owner) select id, vin, o= wner from Car" ).executeUpdate(); + s.createSQLQuery( "insert into Pickup (id, vin, owner) select id, vin, o= wner from Car" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),5); @@ -194,7 +194,7 @@ t.commit(); t =3D s.beginTransaction(); = - s.createSQLQuery( "delete from TRUCK" ).executeUpdate(); + s.createSQLQuery( "delete from Truck" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),4); @@ -207,7 +207,7 @@ = assertEquals(0,s.createSQLQuery( "delete from SUV where owner =3D :owner= " ).setString( "owner", "NotThere" ).executeUpdate()); assertEquals(1,s.createSQLQuery( "delete from SUV where owner =3D :owner= " ).setString( "owner", "Joe" ).executeUpdate()); - s.createSQLQuery( "delete from PICKUP" ).executeUpdate(); + s.createSQLQuery( "delete from Pickup" ).executeUpdate(); = l =3D s.createQuery("from Vehicle").list(); assertEquals(l.size(),0); Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/te= st/hql/Vehicle.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql= /Vehicle.hbm.xml 2009-11-16 14:06:36 UTC (rev 17990) +++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql= /Vehicle.hbm.xml 2009-11-16 14:12:38 UTC (rev 17991) @@ -26,6 +26,6 @@ = - delete from CAR where owner =3D ? + delete from Car where owner =3D ? \ No newline at end of file Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/te= st/sql/hand/custom/mysql/Mappings.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/sql= /hand/custom/mysql/Mappings.hbm.xml 2009-11-16 14:06:36 UTC (rev 17990) +++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/sql= /hand/custom/mysql/Mappings.hbm.xml 2009-11-16 14:12:38 UTC (rev 17991) @@ -26,9 +26,9 @@ - INSERT INTO ORGANIZATION (NAME, ORGID) VALUES ( UPPER(?), ? = ) - UPDATE ORGANIZATION SET NAME=3DUPPER(?) WHERE ORGID=3D? - DELETE FROM ORGANIZATION WHERE ORGID=3D? + INSERT INTO Organization (NAME, ORGID) VALUES ( UPPER(?), ? = ) + UPDATE Organization SET NAME=3DUPPER(?) WHERE ORGID=3D? + DELETE FROM Organization WHERE ORGID=3D? = @@ -37,9 +37,9 @@ - INSERT INTO PERSON (NAME, PERID) VALUES ( UPPER(?), ? ) - UPDATE PERSON SET NAME=3DUPPER(?) WHERE PERID=3D? - DELETE FROM PERSON WHERE PERID=3D? + INSERT INTO Person (NAME, PERID) VALUES ( UPPER(?), ? ) + UPDATE Person SET NAME=3DUPPER(?) WHERE PERID=3D? + DELETE FROM Person WHERE PERID=3D? = @@ -57,12 +57,12 @@ - INSERT INTO EMPLOYMENT = + INSERT INTO Employment = (EMPLOYEE, EMPLOYER, STARTDATE, REGIONCODE, VALUE, CURRENCY, EMPID) = VALUES (?, ?, now(), UPPER(?), ?, ?, ?) - UPDATE EMPLOYMENT SET ENDDATE=3D?, VALUE=3D?, CURRENCY=3D? W= HERE EMPID=3D? = - DELETE FROM EMPLOYMENT WHERE EMPID=3D? = + UPDATE Employment SET ENDDATE=3D?, VALUE=3D?, CURRENCY=3D? W= HERE EMPID=3D? = + DELETE FROM Employment WHERE EMPID=3D? = = @@ -79,15 +79,15 @@ = - SELECT NAME AS {p.name}, PERID AS {p.id} FROM PERSON WHERE PERID=3D? /*F= OR UPDATE*/ + SELECT NAME AS {p.name}, PERID AS {p.id} FROM Person WHERE PERID=3D? /*F= OR UPDATE*/ = SELECT {org.*}, {emp.*} - FROM ORGANIZATION org - LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID =3D emp.EMPLOYER + FROM Organization org + LEFT OUTER JOIN Employment emp ON org.ORGID =3D emp.EMPLOYER WHERE org.ORGID=3D? = @@ -102,8 +102,8 @@ SELECT DISTINCT org.NAME AS {org.name}, org.ORGID AS {org.id} = - FROM ORGANIZATION org - INNER JOIN EMPLOYMENT e ON e.EMPLOYER =3D org.ORGID + FROM Organization org + INNER JOIN Employment e ON e.EMPLOYER =3D org.ORGID = @@ -111,7 +111,7 @@ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer}, = STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate}, REGIONCODE as {emp.regionCode}, EMPID AS {emp.id} - FROM EMPLOYMENT + FROM Employment WHERE EMPID =3D ? = @@ -119,7 +119,7 @@ SELECT {empcol.*} - FROM EMPLOYMENT empcol + FROM Employment empcol WHERE EMPLOYER =3D :id ORDER BY STARTDATE ASC, EMPLOYEE ASC @@ -140,7 +140,7 @@ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer}, = STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate}, REGIONCODE as {emp.regionCode}, EMPID AS {emp.id}, VALUE, CURRENCY - FROM EMPLOYMENT + FROM Employment WHERE EMPLOYER =3D :id AND ENDDATE IS NULL ORDER BY STARTDATE ASC @@ -186,7 +186,7 @@ CREATE PROCEDURE selectAllEmployments () SELECT EMPLOYEE, EMPLOYER, STARTDATE, ENDDATE, = REGIONCODE, EMPID, VALUE, CURRENCY - FROM EMPLOYMENT + FROM Employment DROP PROCEDURE selectAllEmployments --===============3681104858482549043==-- From hibernate-commits at lists.jboss.org Mon Nov 16 09:33:44 2009 Content-Type: multipart/mixed; boundary="===============9000238262106699362==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17985 - in annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate: cfg and 1 other directories. Date: Mon, 16 Nov 2009 08:01:09 -0500 Message-ID: <200911161301.nAGD19S7029418@svn01.web.mwc.hst.phx2.redhat.com> --===============9000238262106699362== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-16 08:01:09 -0500 (Mon, 16 Nov 2009) New Revision: 17985 Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/annotations/Imm= utable.java annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/AnnotationB= inder.java annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations= /PropertyBinder.java Log: JBPAPP-3068 in MySQL, BLOBS should specify a length/number of bytes for fie= lds in index Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/annotati= ons/Immutable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/annotations/Im= mutable.java 2009-11-14 18:03:16 UTC (rev 17984) +++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/annotations/Im= mutable.java 2009-11-16 13:01:09 UTC (rev 17985) @@ -4,8 +4,15 @@ import java.lang.annotation.*; = /** - * Mark an Entity or a Collection as immutable - * No annotation means the element is mutable + * Mark an Entity or a Collection as immutable. No annotation means the el= ement is mutable. + *

+ * An immutable entity may not be updated by the application. Updates to a= n immutable + * entity will be ignored, but no exception is thrown. @Immutable mu= st be used on root entities only. = + *

+ *

+ * @Immutable placed on a collection makes the collection immutable, = meaning additions and = + * deletions to and from the collection are not allowed. A HibernateExc= eption is thrown in this case. = + *

* * @author Emmanuel Bernard */ Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Anno= tationBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Annotation= Binder.java 2009-11-14 18:03:16 UTC (rev 17984) +++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Annotation= Binder.java 2009-11-16 13:01:09 UTC (rev 17985) @@ -714,7 +714,6 @@ isComponent, propertyAnnotated, propertyAccessor, entityBinder, - null, true, false, mappings ); @@ -1277,7 +1276,7 @@ generatedValue.generator() : BinderHelper.ANNOTATION_STRING_DEFAULT; if ( isComponent ) generatorType =3D "assigned"; //a component must not= have any generator - Type typeAnn =3D property.getAnnotation( Type.class ); + bindId( generatorType, generator, @@ -1288,7 +1287,6 @@ isComponent, propertyAnnotated, propertyAccessor, entityBinder, - typeAnn, false, isIdentifierMapper, mappings ); @@ -1856,7 +1854,7 @@ Map localGenerators, boolean isComposite, boolean isPropertyAnnotated, - String propertyAccessor, EntityBinder entityBinder, Type typeAnn, boole= an isEmbedded, + String propertyAccessor, EntityBinder entityBinder, boolean isEmbedded, boolean isIdentifierMapper, ExtendedMappings mappings ) { /* @@ -1901,7 +1899,7 @@ value.setColumns( columns ); value.setPersistentClassName( persistentClassName ); value.setMappings( mappings ); - value.setExplicitType( typeAnn ); + value.setType( inferredData.getProperty(), inferredData.getClassOrEleme= nt() ); id =3D value.make(); } rootClass.setIdentifier( id ); Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/anno= tations/PropertyBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotation= s/PropertyBinder.java 2009-11-14 18:03:16 UTC (rev 17984) +++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotation= s/PropertyBinder.java 2009-11-16 13:01:09 UTC (rev 17985) @@ -10,6 +10,7 @@ import org.hibernate.annotations.Generated; import org.hibernate.annotations.GenerationTime; import org.hibernate.annotations.NaturalId; +import org.hibernate.annotations.Immutable; import org.hibernate.annotations.OptimisticLock; import org.hibernate.annotations.common.reflection.XClass; import org.hibernate.annotations.common.reflection.XProperty; @@ -73,7 +74,7 @@ public void setColumns(Ejb3Column[] columns) { insertable =3D columns[0].isInsertable(); updatable =3D columns[0].isUpdatable(); - //concsistency is checked later when we know the proeprty name + //consistency is checked later when we know the property name this.columns =3D columns; } = @@ -94,7 +95,10 @@ } = private void validateBind() { - //TODO check necessary params for a bind = + if (property.isAnnotationPresent(Immutable.class)) { + throw new AnnotationException("@Immutable on property not allowed. " + + "Only allowed on entity level or on a collection."); + } = } = private void validateMake() { --===============9000238262106699362==-- From hibernate-commits at lists.jboss.org Mon Nov 16 09:52:30 2009 Content-Type: multipart/mixed; boundary="===============6473413615479183874==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17992 - in core/trunk/annotations/src/test/java/org/hibernate/test/annotations: derivedidentities and 1 other directory. Date: Mon, 16 Nov 2009 09:52:30 -0500 Message-ID: <200911161452.nAGEqUNh016281@svn01.web.mwc.hst.phx2.redhat.com> --===============6473413615479183874== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-16 09:52:30 -0500 (Mon, 16 Nov 2009) New Revision: 17992 Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/deri= vedidentities/ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/deri= vedidentities/Dependent.java core/trunk/annotations/src/test/java/org/hibernate/test/annotations/deri= vedidentities/DependentId.java core/trunk/annotations/src/test/java/org/hibernate/test/annotations/deri= vedidentities/Employee.java core/trunk/annotations/src/test/java/org/hibernate/test/annotations/deri= vedidentities/Employer.java core/trunk/annotations/src/test/java/org/hibernate/test/annotations/deri= vedidentities/EmployerId.java core/trunk/annotations/src/test/java/org/hibernate/test/annotations/deri= vedidentities/MedicalHistory.java core/trunk/annotations/src/test/java/org/hibernate/test/annotations/deri= vedidentities/Person.java Log: HHH-4529 Added some test entities Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/= derivedidentities/Dependent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/Dependent.java (rev 0) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/Dependent.java 2009-11-16 14:52:30 UTC (rev 17992) @@ -0,0 +1,57 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.test.annotations.derivedidentities; + +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.ManyToOne; +import javax.persistence.MapsId; + +/** + * @author Hardy Ferentschik + */ +(a)Entity +public class Dependent { + @EmbeddedId + DependentId id; // id attribute mapped by join column default + + @MapsId("empPK") // maps empPK attribute of embedded id + @ManyToOne + Employee employee; + + public Dependent() { + } + + public Dependent(DependentId id) { + this.id =3D id; + } + + public Employee getEmployee() { + return employee; + } + + public void setEmployee(Employee employee) { + this.employee =3D employee; + } + + public DependentId getId() { + return id; + } +} + + Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/= derivedidentities/DependentId.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/DependentId.java (rev 0) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/DependentId.java 2009-11-16 14:52:30 UTC (rev 17992) @@ -0,0 +1,45 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.test.annotations.derivedidentities; + +import java.io.Serializable; +import javax.persistence.Embeddable; + +/** + * @author Hardy Ferentschik + */ +(a)Embeddable +public class DependentId implements Serializable { + String name; + + long empPK; // corresponds to PK type of Employee + + public DependentId() { + } + + public DependentId(long empPK, String name) { + this.empPK =3D empPK; + this.name =3D name; + } + + public String getName() { + return name; + } +} + + Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/= derivedidentities/Employee.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/Employee.java (rev 0) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/Employee.java 2009-11-16 14:52:30 UTC (rev 17992) @@ -0,0 +1,39 @@ +// $Id:$ +package org.hibernate.test.annotations.derivedidentities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Hardy Ferentschik + */ +(a)Entity +public class Employee { + @Id + @GeneratedValue + long id; + + String name; + + public Employee() { + } + + public Employee( String name) { + this.name =3D name; + } + + public long getId() { + return id; + } + + public String getName() { + return name; + } + + public void setId(long id) { + this.id =3D id; + } +} + + Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/= derivedidentities/Employer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/Employer.java (rev 0) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/Employer.java 2009-11-16 14:52:30 UTC (rev 17992) @@ -0,0 +1,56 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.test.annotations.derivedidentities; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.ManyToOne; + +/** + * @author Hardy Ferentschik + */ +(a)Entity +(a)IdClass(EmployerId.class) +public class Employer { + @Id + String name; + + @Id + @ManyToOne + Employee employee; + + public Employer() { + } + + public Employer(String name) { + this.name =3D name; + } + + public Employee getEmployee() { + return employee; + } + + public void setEmployee(Employee emp) { + this.employee =3D emp; + } + + public String getName() { + return name; + } +} \ No newline at end of file Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/= derivedidentities/EmployerId.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/EmployerId.java (rev 0) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/EmployerId.java 2009-11-16 14:52:30 UTC (rev 17992) @@ -0,0 +1,43 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.test.annotations.derivedidentities; + +import java.io.Serializable; + +/** + * @author Hardy Ferentschik + */ +public class EmployerId implements Serializable { + String name; // matches name of @Id attribute + long employee; // matches name of @Id attribute and type of Employee PK + + public EmployerId() { + } + + public EmployerId(String name) { + this.name =3D name; + } + + public String getName() { + return name; + } + + public void setEmployee(long employee) { + this.employee =3D employee; + } +} \ No newline at end of file Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/= derivedidentities/MedicalHistory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/MedicalHistory.java (rev 0) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/MedicalHistory.java 2009-11-16 14:52:30 UTC (rev 17992) @@ -0,0 +1,56 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.test.annotations.derivedidentities; + +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.OneToOne; + +import org.hibernate.annotations.Entity; + +/** + * @author Hardy Ferentschik + */ +(a)Entity +public class MedicalHistory { + @Id + @OneToOne + @JoinColumn(name=3D"FK") + Person patient; + + @Lob + byte[] xrayData; + + private MedicalHistory() { + } + + public MedicalHistory(Person patient) { + this.patient =3D patient; + } + + public byte[] getXrayData() { + return xrayData; + } + + public void setXrayData(byte[] xrayData) { + this.xrayData =3D xrayData; + } +} + + Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/= derivedidentities/Person.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/Person.java (rev 0) +++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/der= ivedidentities/Person.java 2009-11-16 14:52:30 UTC (rev 17992) @@ -0,0 +1,43 @@ +// $Id:$ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual cont= ributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.test.annotations.derivedidentities; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Hardy Ferentschik + */ +(a)Entity +public class Person { + @Id + private String ssn; + + private Person() { + } + + public Person(String ssn) { + this.ssn =3D ssn; + } + + public String getSsn() { + return ssn; + } +} + + --===============6473413615479183874==-- From hibernate-commits at lists.jboss.org Mon Nov 16 12:02:56 2009 Content-Type: multipart/mixed; boundary="===============3295133545881934558==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17993 - in search/trunk/src: main/java/org/hibernate/search/bridge and 2 other directories. Date: Mon, 16 Nov 2009 12:02:56 -0500 Message-ID: <200911161702.nAGH2uXf009024@svn01.web.mwc.hst.phx2.redhat.com> --===============3295133545881934558== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: epbernard Date: 2009-11-16 12:02:54 -0500 (Mon, 16 Nov 2009) New Revision: 17993 Added: search/trunk/src/main/java/org/hibernate/search/annotations/CalendarBrid= ge.java search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CalendarB= ridge.java search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateResol= utionUtil.java Modified: search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.java search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateBridg= e.java search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.j= ava search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java Log: HSEARCH-328 Add a builtin bridge for Calendar @CalendarBridge (Amin Mohamme= d-Coleman) Added: search/trunk/src/main/java/org/hibernate/search/annotations/Calendar= Bridge.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/annotations/CalendarBri= dge.java (rev 0) +++ search/trunk/src/main/java/org/hibernate/search/annotations/CalendarBri= dge.java 2009-11-16 17:02:54 UTC (rev 17993) @@ -0,0 +1,17 @@ +package org.hibernate.search.annotations; + +import java.lang.annotation.*; + + +/** + * Defines the temporal resolution of a given field + * Calendar are stored as String in GMT + * + * @author Amin Mohammed-Coleman = + */ +(a)Retention( RetentionPolicy.RUNTIME ) +(a)Target( {ElementType.FIELD, ElementType.METHOD} ) +(a)Documented +public @interface CalendarBridge { + Resolution resolution(); +} Modified: search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFact= ory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.ja= va 2009-11-16 14:52:30 UTC (rev 17992) +++ search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.ja= va 2009-11-16 17:02:54 UTC (rev 17993) @@ -31,6 +31,7 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; +import java.util.Calendar; = import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; @@ -42,20 +43,21 @@ import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.Parameter; import org.hibernate.search.annotations.Resolution; -import org.hibernate.search.bridge.builtin.BigDecimalBridge; -import org.hibernate.search.bridge.builtin.BigIntegerBridge; -import org.hibernate.search.bridge.builtin.BooleanBridge; +import org.hibernate.search.bridge.builtin.StringBridge; import org.hibernate.search.bridge.builtin.CharacterBridge; -import org.hibernate.search.bridge.builtin.DateBridge; import org.hibernate.search.bridge.builtin.DoubleBridge; -import org.hibernate.search.bridge.builtin.EnumBridge; import org.hibernate.search.bridge.builtin.FloatBridge; +import org.hibernate.search.bridge.builtin.ShortBridge; import org.hibernate.search.bridge.builtin.IntegerBridge; import org.hibernate.search.bridge.builtin.LongBridge; -import org.hibernate.search.bridge.builtin.ShortBridge; -import org.hibernate.search.bridge.builtin.StringBridge; +import org.hibernate.search.bridge.builtin.BigIntegerBridge; +import org.hibernate.search.bridge.builtin.BigDecimalBridge; +import org.hibernate.search.bridge.builtin.BooleanBridge; +import org.hibernate.search.bridge.builtin.UrlBridge; import org.hibernate.search.bridge.builtin.UriBridge; -import org.hibernate.search.bridge.builtin.UrlBridge; +import org.hibernate.search.bridge.builtin.DateBridge; +import org.hibernate.search.bridge.builtin.CalendarBridge; +import org.hibernate.search.bridge.builtin.EnumBridge; = /** * This factory is responsible for creating and initializing build-in and = custom FieldBridges. @@ -101,9 +103,21 @@ public static final FieldBridge DATE_HOUR =3D new TwoWayString2FieldBridg= eAdaptor( DateBridge.DATE_HOUR ); public static final FieldBridge DATE_MINUTE =3D new TwoWayString2FieldBri= dgeAdaptor( DateBridge.DATE_MINUTE ); public static final FieldBridge DATE_SECOND =3D new TwoWayString2FieldBri= dgeAdaptor( DateBridge.DATE_SECOND ); - public static final TwoWayFieldBridge DATE_MILLISECOND =3D + + public static final FieldBridge CALENDAR_YEAR =3D new TwoWayString2Fie= ldBridgeAdaptor( CalendarBridge.CALENDAR_YEAR ); + public static final FieldBridge CALENDAR_MONTH =3D new TwoWayString2Field= BridgeAdaptor( CalendarBridge.CALENDAR_MONTH ); + public static final FieldBridge CALENDAR_DAY =3D new TwoWayString2FieldBr= idgeAdaptor( CalendarBridge.CALENDAR_DAY ); + public static final FieldBridge CALENDAR_HOUR =3D new TwoWayString2FieldB= ridgeAdaptor( CalendarBridge.CALENDAR_HOUR ); + public static final FieldBridge CALENDAR_MINUTE =3D new TwoWayString2Fiel= dBridgeAdaptor( CalendarBridge.CALENDAR_MINUTE ); + public static final FieldBridge CALENDAR_SECOND =3D new TwoWayString2Fiel= dBridgeAdaptor( CalendarBridge.CALENDAR_SECOND ); + + public static final TwoWayFieldBridge DATE_MILLISECOND =3D new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_MILLISECOND ); = + public static final TwoWayFieldBridge CALENDAR_MILLISECOND =3D + new TwoWayString2FieldBridgeAdaptor( CalendarBridge.CALENDAR_MILLISECON= D ); + + static { builtInBridges.put( Character.class.getName(), CHARACTER ); builtInBridges.put( char.class.getName(), CHARACTER ); @@ -127,6 +141,7 @@ builtInBridges.put( URI.class.getName(), Uri ); = builtInBridges.put( Date.class.getName(), DATE_MILLISECOND ); + builtInBridges.put( Calendar.class.getName(), CALENDAR_MILLISECOND= ); } = /** @@ -193,18 +208,21 @@ bridge =3D doExtractType( bridgeAnn, memberName ); } else if ( member.isAnnotationPresent( org.hibernate.search.annotations.D= ateBridge.class ) ) { - Resolution resolution =3D - member.getAnnotation( org.hibernate.search.annotations.DateBridge.cla= ss ).resolution(); - bridge =3D getDateField( resolution ); + Resolution resolution =3D member.getAnnotation( org.hibernate.search.an= notations.DateBridge.class ).resolution(); + bridge =3D getDateField( resolution ); } + else if ( member.isAnnotationPresent( org.hibernate.search.annotations.C= alendarBridge.class ) ) { + Resolution resolution =3D member.getAnnotation( org.hibernate.= search.annotations.CalendarBridge.class ).resolution(); + bridge =3D getCalendarField( resolution ); + } else { //find in built-ins XClass returnType =3D member.getType(); bridge =3D builtInBridges.get( returnType.getName() ); if ( bridge =3D=3D null && returnType.isEnum() ) { - bridge =3D new TwoWayString2FieldBridgeAdaptor( - new EnumBridge( reflectionManager.toClass( returnType ) ) - ); + @SuppressWarnings( "unchecked" ) + final Class enumClass =3D reflectionManager.toClass( r= eturnType ); + bridge =3D new TwoWayString2FieldBridgeAdaptor( new EnumBridge( enumCl= ass ) ); } } //TODO add classname @@ -272,6 +290,28 @@ } } = + + public static FieldBridge getCalendarField(Resolution resolution) { + switch (resolution) { + case YEAR: + return CALENDAR_YEAR; + case MONTH: + return CALENDAR_MONTH; + case DAY: + return CALENDAR_DAY; + case HOUR: + return CALENDAR_HOUR; + case MINUTE: + return CALENDAR_MINUTE; + case SECOND: + return CALENDAR_SECOND; + case MILLISECOND: + return CALENDAR_MILLISECOND; + default: + throw new AssertionFailure( "Unknown Resolution: " + resolution ); + } + } + /** * Takes in a fieldBridge and will return you a TwoWayFieldBridge instanc= e. * Added: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/Calen= darBridge.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/Calendar= Bridge.java (rev 0) +++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/Calendar= Bridge.java 2009-11-16 17:02:54 UTC (rev 17993) @@ -0,0 +1,73 @@ +package org.hibernate.search.bridge.builtin; + +import org.hibernate.search.annotations.Resolution; +import org.hibernate.search.bridge.ParameterizedBridge; +import org.hibernate.search.bridge.TwoWayStringBridge; +import org.hibernate.util.StringHelper; +import org.hibernate.AssertionFailure; +import org.hibernate.HibernateException; +import org.apache.lucene.document.DateTools; + +import java.util.Date; +import java.util.Calendar; +import java.util.Locale; +import java.util.Map; +import java.text.ParseException; + + +public class CalendarBridge implements TwoWayStringBridge, ParameterizedBr= idge { + = + private DateTools.Resolution resolution; + public static final TwoWayStringBridge CALENDAR_YEAR =3D new CalendarBrid= ge( Resolution.YEAR ); + public static final TwoWayStringBridge CALENDAR_MONTH =3D new CalendarBri= dge( Resolution.MONTH ); + public static final TwoWayStringBridge CALENDAR_DAY =3D new CalendarBridg= e( Resolution.DAY ); + public static final TwoWayStringBridge CALENDAR_HOUR =3D new CalendarBrid= ge( Resolution.HOUR ); + public static final TwoWayStringBridge CALENDAR_MINUTE =3D new CalendarBr= idge( Resolution.MINUTE ); + public static final TwoWayStringBridge CALENDAR_SECOND =3D new CalendarBr= idge( Resolution.SECOND ); + public static final TwoWayStringBridge CALENDAR_MILLISECOND =3D new Calen= darBridge( Resolution.MILLISECOND ); + + + public CalendarBridge() { + } + + public CalendarBridge(Resolution resolution) { + this.resolution =3D DateResolutionUtil.getLuceneResolution( resolution); + } + + public void setParameterValues(Map parameters) { + Object resolution =3D parameters.get( "resolution" ); + Resolution hibResolution; + if ( resolution instanceof String ) { + hibResolution =3D Resolution.valueOf( ( (String) resolution ).toUpperCa= se( Locale.ENGLISH ) ); + } + else { + hibResolution =3D (Resolution) resolution; + } + resolution =3D DateResolutionUtil.getLuceneResolution( hibResolution ); + } + + = + = + public Object stringToObject(String stringValue) { + if ( StringHelper.isEmpty( stringValue )) { + return null; + } + try { + Date date =3D DateTools.stringToDate(stringValue); + Calendar calendar =3D Calendar.getInstance(); + calendar.setTime(date); + return calendar; + } catch (ParseException e) { + throw new HibernateException( "Unable to parse into calendar: = " + stringValue, e ); + } + } + + public String objectToString(Object object) { + if (object =3D=3D null) { + return null; + } + Calendar calendar =3D (Calendar)object; + return DateTools.dateToString(calendar.getTime(),resolution); + } + +} Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/Da= teBridge.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateBrid= ge.java 2009-11-16 14:52:30 UTC (rev 17992) +++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateBrid= ge.java 2009-11-16 17:02:54 UTC (rev 17993) @@ -69,7 +69,7 @@ } = public DateBridge(Resolution resolution) { - setResolution( resolution ); + this.resolution =3D DateResolutionUtil.getLuceneResolution(resolution); } = public Object stringToObject(String stringValue) { @@ -97,35 +97,8 @@ else { hibResolution =3D (Resolution) resolution; } - setResolution( hibResolution ); + this.resolution =3D DateResolutionUtil.getLuceneResolution(hibResolution= ); } = - private void setResolution(Resolution hibResolution) { - switch (hibResolution) { - case YEAR: - this.resolution =3D DateTools.Resolution.YEAR; - break; - case MONTH: - this.resolution =3D DateTools.Resolution.MONTH; - break; - case DAY: - this.resolution =3D DateTools.Resolution.DAY; - break; - case HOUR: - this.resolution =3D DateTools.Resolution.HOUR; - break; - case MINUTE: - this.resolution =3D DateTools.Resolution.MINUTE; - break; - case SECOND: - this.resolution =3D DateTools.Resolution.SECOND; - break; - case MILLISECOND: - this.resolution =3D DateTools.Resolution.MILLISECOND; - break; - default: - throw new AssertionFailure( "Unknown Resolution: " + hibResolution ); - - } - } + = } Added: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateR= esolutionUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateReso= lutionUtil.java (rev 0) +++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateReso= lutionUtil.java 2009-11-16 17:02:54 UTC (rev 17993) @@ -0,0 +1,41 @@ +package org.hibernate.search.bridge.builtin; + +import org.apache.lucene.document.DateTools; +import org.apache.lucene.document.DateTools.Resolution; +import org.hibernate.AssertionFailure; + +public class DateResolutionUtil { + = + private DateResolutionUtil() {} + = + = + public static Resolution getLuceneResolution(org.hibernate.search.annotat= ions.Resolution hibResolution) { + Resolution resolution =3D null; + switch (hibResolution) { + case YEAR: + resolution =3D DateTools.Resolution.YEAR; + break; + case MONTH: + resolution =3D DateTools.Resolution.MONTH; + break; + case DAY: + resolution =3D DateTools.Resolution.DAY; + break; + case HOUR: + resolution =3D DateTools.Resolution.HOUR; + break; + case MINUTE: + resolution =3D DateTools.Resolution.MINUTE; + break; + case SECOND: + resolution =3D DateTools.Resolution.SECOND; + break; + case MILLISECOND: + resolution =3D DateTools.Resolution.MILLISECOND; + break; + default: + throw new AssertionFailure( "Unknown Resolution: " + hibResolution ); + } + return resolution; + } +} Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/Bridg= eTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.= java 2009-11-16 14:52:30 UTC (rev 17992) +++ search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.= java 2009-11-16 17:02:54 UTC (rev 17993) @@ -207,6 +207,55 @@ = } = + + public void testCalendarBridge() throws Exception { + Cloud cloud =3D new Cloud(); + Calendar c =3D GregorianCalendar.getInstance(); + c.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); //for the sake of tests + c.set( 2000, 11, 15, 3, 43, 2 ); + c.set( Calendar.MILLISECOND, 5 ); + + + cloud.setMyCalendar(c); //5 millisecond + cloud.setCalendarDay(c); + cloud.setCalendarHour( c ); + cloud.setCalendarMillisecond( c ); + cloud.setCalendarMinute( c ); + cloud.setCalendarMonth( c ); + cloud.setCalendarSecond( c ); + cloud.setCalendarYear( c ); + org.hibernate.Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist( cloud ); + s.flush(); + tx.commit(); + + tx =3D s.beginTransaction(); + FullTextSession session =3D Search.getFullTextSession( s ); + QueryParser parser =3D new QueryParser( "id", new StandardAnalyzer() ); + Query query; + List result; + + query =3D parser.parse( + "myCalendar:[19900101 TO 20060101]" + + " AND calendarDay:[20001214 TO 2000121501]" + + " AND calendarMonth:[200012 TO 20001201]" + + " AND calendarYear:[2000 TO 200001]" + + " AND calendarHour:[20001214 TO 2000121503]" + + " AND calendarMinute:[20001214 TO 200012150343]" + + " AND calendarSecond:[20001214 TO 20001215034302]" + + " AND calendarMillisecond:[20001214 TO 20001215034302005]" + ); + result =3D session.createFullTextQuery( query ).list(); + assertEquals( "Calendar not found or not property truncated", 1, result.= size() ); + + s.delete( s.get( Cloud.class, cloud.getId() ) ); + tx.commit(); + s.close(); + + } + + protected Class[] getMappings() { return new Class[] { Cloud.class Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java = 2009-11-16 14:52:30 UTC (rev 17992) +++ search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java = 2009-11-16 17:02:54 UTC (rev 17993) @@ -25,21 +25,14 @@ package org.hibernate.search.test.bridge; = import java.util.Date; +import java.util.Calendar; import java.net.URL; import java.net.URI; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; = -import org.hibernate.search.annotations.DateBridge; -import org.hibernate.search.annotations.DocumentId; -import org.hibernate.search.annotations.Field; -import org.hibernate.search.annotations.FieldBridge; -import org.hibernate.search.annotations.Index; -import org.hibernate.search.annotations.Indexed; -import org.hibernate.search.annotations.Parameter; -import org.hibernate.search.annotations.Resolution; -import org.hibernate.search.annotations.Store; +import org.hibernate.search.annotations.*; = /** * @author Emmanuel Bernard @@ -74,7 +67,18 @@ private Class clazz; private URL url; private URI uri; + private Calendar myCalendar; + private Calendar calendarYear; + private Calendar calendarMonth; + private Calendar calendarDay; + private Calendar calendarMinute; + private Calendar calendarSecond; + private Calendar calendarHour; + private Calendar calendarMillisecond; = + + + @Field(index=3DIndex.UN_TOKENIZED, store=3DStore.YES) public URL getUrl() { return url; @@ -328,4 +332,88 @@ public void setChar2(char char2) { this.char2 =3D char2; } + + + @Field(index=3DIndex.UN_TOKENIZED, store=3DStore.YES) + public Calendar getMyCalendar() { + return myCalendar; + } + + public void setMyCalendar(Calendar myCalendar) { + this.myCalendar =3D myCalendar; + } + + @Field(index=3DIndex.UN_TOKENIZED, store=3DStore.YES) + @CalendarBridge(resolution =3D Resolution.YEAR ) + public Calendar getCalendarYear() { + return calendarYear; + } + + public void setCalendarYear(Calendar calendarYear) { + this.calendarYear =3D calendarYear; + } + + @Field(index=3DIndex.UN_TOKENIZED, store=3DStore.YES) + @CalendarBridge( resolution =3D Resolution.MONTH ) + public Calendar getCalendarMonth() { + return calendarMonth; + } + + public void setCalendarMonth(Calendar calendarMonth) { + this.calendarMonth =3D calendarMonth; + } + + @Field(index=3DIndex.UN_TOKENIZED, store=3DStore.YES) + @CalendarBridge( resolution =3D Resolution.DAY ) + public Calendar getCalendarDay() { + return calendarDay; + } + + public void setCalendarDay(Calendar calendarDay) { + this.calendarDay =3D calendarDay; + } + + + + @Field(index=3DIndex.UN_TOKENIZED, store=3DStore.YES) + @CalendarBridge( resolution =3D Resolution.MINUTE ) + public Calendar getCalendarMinute() { + return calendarMinute; + } + + public void setCalendarMinute(Calendar calendarMinute) { + this.calendarMinute =3D calendarMinute; + } + + + @Field(index=3DIndex.UN_TOKENIZED, store=3DStore.YES) + @CalendarBridge( resolution =3D Resolution.HOUR ) + public Calendar getCalendarHour() { + return calendarHour; + } + + public void setCalendarHour(Calendar calendarHour) { + this.calendarHour =3D calendarHour; + } + + + @Field(index=3DIndex.UN_TOKENIZED, store=3DStore.YES) + @CalendarBridge( resolution =3D Resolution.MILLISECOND ) + public Calendar getCalendarMillisecond() { + return calendarMillisecond; + } + + public void setCalendarMillisecond(Calendar calendarMillisecond) { + this.calendarMillisecond =3D calendarMillisecond; + } + + @Field(index=3DIndex.UN_TOKENIZED, store=3DStore.YES) + @CalendarBridge( resolution =3D Resolution.SECOND ) + public Calendar getCalendarSecond() { + return calendarSecond; + } + + public void setCalendarSecond(Calendar calendarSecond) { + this.calendarSecond =3D calendarSecond; + } } --===============3295133545881934558==-- From hibernate-commits at lists.jboss.org Tue Nov 17 00:51:24 2009 Content-Type: multipart/mixed; boundary="===============7025545980692357545==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17994 - core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/mysql. Date: Tue, 17 Nov 2009 00:51:24 -0500 Message-ID: <200911170551.nAH5pOO4031548@svn01.web.mwc.hst.phx2.redhat.com> --===============7025545980692357545== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-17 00:51:24 -0500 (Tue, 17 Nov 2009) New Revision: 17994 Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/t= est/sql/hand/custom/mysql/Mappings.hbm.xml Log: JBPAPP-3067 HHH-4576 - Tests in MySQL using different case for objects as d= efined in configuration Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibe= rnate/test/sql/hand/custom/mysql/Mappings.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/= test/sql/hand/custom/mysql/Mappings.hbm.xml 2009-11-16 17:02:54 UTC (rev 17= 993) +++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/= test/sql/hand/custom/mysql/Mappings.hbm.xml 2009-11-17 05:51:24 UTC (rev 17= 994) @@ -79,7 +79,7 @@ = - SELECT NAME AS {p.name}, PERID AS {p.id} FROM PERSON WHERE PERID=3D? /*F= OR UPDATE*/ + SELECT NAME AS {p.name}, PERID AS {p.id} FROM Person WHERE PERID=3D? /*F= OR UPDATE*/ = --===============7025545980692357545==-- From hibernate-commits at lists.jboss.org Tue Nov 17 04:07:30 2009 Content-Type: multipart/mixed; boundary="===============5585826525577819965==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17995 - core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql. Date: Tue, 17 Nov 2009 04:07:29 -0500 Message-ID: <200911170907.nAH97TdQ003943@svn01.web.mwc.hst.phx2.redhat.com> --===============5585826525577819965== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-17 04:07:29 -0500 (Tue, 17 Nov 2009) New Revision: 17995 Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserL= oadingTest.java Log: JBPAPP-3056 Core - DB2 v9.1 - Test fails due to Invalid use of a parameter = marker. Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/AST= ParserLoadingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParser= LoadingTest.java 2009-11-17 05:51:24 UTC (rev 17994) +++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParser= LoadingTest.java 2009-11-17 09:07:29 UTC (rev 17995) @@ -128,7 +128,12 @@ assertEquals( 1, results.size() ); results =3D s.createQuery( "from Human where name is not null" ).list(); assertEquals( 3, results.size() ); - s.createQuery( "from Human where ? is null" ).setParameter( 0, null ).li= st(); + String query =3D + getDialect() instanceof DB2Dialect ? + "from Human where cast(? as string) is null" : + "from Human where ? is null" + ; + s.createQuery( query ).setParameter( 0, null ).list(); s.getTransaction().commit(); s.close(); = --===============5585826525577819965==-- From hibernate-commits at lists.jboss.org Tue Nov 17 07:16:21 2009 Content-Type: multipart/mixed; boundary="===============6851586685892099818==" MIME-Version: 1.0 From: Joline To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hey hibernate-commits Date: Tue, 17 Nov 2009 07:16:20 -0500 Message-ID: <200911171216.nAHCGK4T031784@lists01.dmz-a.mwc.hst.phx2.redhat.com> --===============6851586685892099818== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Remember where this club is? http://school.obec.go.th/msw/hot.html --===============6851586685892099818==-- From hibernate-commits at lists.jboss.org Tue Nov 17 13:00:05 2009 Content-Type: multipart/mixed; boundary="===============0426994040276155601==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17996 - in search/trunk/src/main: java/org/hibernate/search/backend/impl/jgroups and 1 other directory. Date: Tue, 17 Nov 2009 13:00:05 -0500 Message-ID: <200911171800.nAHI05vO008880@svn01.web.mwc.hst.phx2.redhat.com> --===============0426994040276155601== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: sannegrinovero Date: 2009-11-17 13:00:05 -0500 (Tue, 17 Nov 2009) New Revision: 17996 Modified: search/trunk/src/main/docbook/en-US/modules/architecture.xml search/trunk/src/main/docbook/en-US/modules/configuration.xml search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JGr= oupsBackendQueueProcessorFactory.java Log: HSEARCH-409 Write documentation for JGroups based configuration (Lukasz Mor= en) Modified: search/trunk/src/main/docbook/en-US/modules/architecture.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/docbook/en-US/modules/architecture.xml 2009-11-17= 09:07:29 UTC (rev 17995) +++ search/trunk/src/main/docbook/en-US/modules/architecture.xml 2009-11-17= 18:00:05 UTC (rev 17996) @@ -174,6 +174,15 @@ local copy of the index. = +
+ JGroups + + The JGroups based back end works similarly as the JMS one. De= signed on the same + master/slave pattern, instead of JMS the JGroups toolkit is used as= a replication mechanism. + This back end can be used as an alternative to JMS one when respons= e time is still critical, + but i.e. JNDI service is not available. +
+ Hibernate Search is an extensible architecture. Feel free to d= rop ideas for other third party back ends to hibernate-dev(a)lists.jboss.org. Modified: search/trunk/src/main/docbook/en-US/modules/configuration.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/docbook/en-US/modules/configuration.xml 2009-11-1= 7 09:07:29 UTC (rev 17995) +++ search/trunk/src/main/docbook/en-US/modules/configuration.xml 2009-11-1= 7 18:00:05 UTC (rev 17996) @@ -390,8 +390,8 @@ = Out of the box support for the Apache Lucene back end a= nd the JMS back end. Default to lucene. Suppor= ts - also jms and - blackhole. + also jms, blackhole, + jgroupsMaster and jgroupsSlave. = @@ -442,6 +442,34 @@ lookup the JMS queue from. The queue will be used to post work messages. + = + + hibernate.search.worker.jgroups.clusterName + + Optional for JGroups back end. Defines the name of JGrou= ps channel. + + = + + hibernate.search.worker.jgroups.configurationFi= le + + Optional JGroups network stack configuration. Defines th= e name of a JGroups + configuration file, which must exist on classpath. + + + + hibernate.search.worker.jgroups.configurationXm= l + + Optional JGroups network stack configuration. + Defines a String representing JGroups configuration as XML. + + = + + hibernate.search.worker.jgroups.configurationS= tring + + Optional JGroups network stack configuration. + Provides JGroups configuration in plain text. + +
@@ -578,6 +606,102 @@
= +
+ JGroups Master/Slave configuration + Describes how to configure JGroups Master/Slave back end. + Configuration examples illustrated in JMS Master/Slave configu= ration + section () also apply here, on= ly + a different backend needs to be set. + +
+ Slave nodes + Every index update operation is sent through a JGroups c= hannel to the master node. Index + querying operations are executed on a local index copy. + + JGroups Slave configuration + +### slave configuration +## Backend configuration +hibernate.search.worker.backend =3D jgroupsSlave + + +
+ +
+ Master node + Every index update operation is taken from a JGroups cha= nnel and + executed. The master index is copied on a regular basis. + + JGroups Master configuration + +### master configuration +## Backend configuration +hibernate.search.worker.backend =3D jgroupsMaster + + +
+
+ JGroups channel configuration + Optionally configuration for JGroups transport protocols + (UDP, TCP) and channel name can be defined. It can be applied = to both master and slave nodes. + There are several ways to configure JGroups transport details. + If it is not defined explicity, configuration found in the + flush-udp.xml file is used. + JGroups transport protocols configuration</ti= tle> + <programlisting> +## configuration +#udp.xml file needs to be located in the classpath +hibernate.search.worker.backend.jgroups.configurationFile =3D udp.xml + +#protocol stack configuration provided in XML format +hibernate.search.worker.backend.jgroups.configurationXml =3D + +<config xmlns=3D"urn:org:jgroups" +xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" +xsi:schemaLocation=3D"urn:org:jgroups file:schema/JGroups-2.8.xsd"> +<UDP +mcast_addr=3D"${jgroups.udp.mcast_addr:228.10.10.10}" +mcast_port=3D"${jgroups.udp.mcast_port:45588}" +tos=3D"8" +thread_naming_pattern=3D"pl" +thread_pool.enabled=3D"true" +thread_pool.min_threads=3D"2" +thread_pool.max_threads=3D"8" +thread_pool.keep_alive_time=3D"5000" +thread_pool.queue_enabled=3D"false" +thread_pool.queue_max_size=3D"100" +thread_pool.rejection_policy=3D"Run"/> +<PING timeout=3D"1000" num_initial_members=3D"3"/> +<MERGE2 max_interval=3D"30000" min_interval=3D"10000"/> +<FD_SOCK/> +<FD timeout=3D"3000" max_tries=3D"3"/> +<VERIFY_SUSPECT timeout=3D"1500"/> +<pbcast.STREAMING_STATE_TRANSFER/> +<pbcast.FLUSH timeout=3D"0"/> +</config> + +#protocol stack configuration provided in "old style" jgroups format +hibernate.search.worker.backend.jgroups.configurationString =3D + +UDP(mcast_addr=3D228.1.2.3;mcast_port=3D45566;ip_ttl=3D32):PING(timeout=3D= 3000; +num_initial_members=3D6):FD(timeout=3D5000):VERIFY_SUSPECT(timeout=3D1500): +pbcast.NAKACK(gc_lag=3D10;retransmit_timeout=3D3000):UNICAST(timeout=3D500= 0): +FRAG:pbcast.GMS(join_timeout=3D3000;shun=3Dfalse;print_local_addr=3Dtrue) + + </programlisting> + </example> + <para>Master and slave nodes communicate over JGroups channel + that is identified by this same name. Name of the channe= l can be defined + explicity, if not default <literal>HSearchCluster</liter= al> is used.</para> + <example><title>JGroups channel name configuration + +## Backend configuration +hibernate.search.worker.backend.jgroups.clusterName =3D Hibernate-Search-C= luster + + +
+
+ =
Reader strategy configuration = Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/jgro= ups/JGroupsBackendQueueProcessorFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JG= roupsBackendQueueProcessorFactory.java 2009-11-17 09:07:29 UTC (rev 17995) +++ search/trunk/src/main/java/org/hibernate/search/backend/impl/jgroups/JG= roupsBackendQueueProcessorFactory.java 2009-11-17 18:00:05 UTC (rev 17996) @@ -97,11 +97,11 @@ } = /** - * Reads congiguration and builds channnel with its base. + * Reads configuration and builds channnel with its base. * In order of preference - we first look for an external JGroups file, t= hen a set of XML properties, and * finally the legacy JGroups String properties. * - * @param props configuratuion file + * @param props configuration file */ private void buildChannel(Properties props) { String cfg; --===============0426994040276155601==-- From hibernate-commits at lists.jboss.org Tue Nov 17 18:12:35 2009 Content-Type: multipart/mixed; boundary="===============7702580021983272316==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17997 - core/trunk/core/src/main/java/org/hibernate/engine. Date: Tue, 17 Nov 2009 18:12:14 -0500 Message-ID: <200911172312.nAHNCEe9006860@svn01.web.mwc.hst.phx2.redhat.com> --===============7702580021983272316== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: gbadner Date: 2009-11-17 18:12:09 -0500 (Tue, 17 Nov 2009) New Revision: 17997 Modified: core/trunk/core/src/main/java/org/hibernate/engine/StatefulPersistenceCo= ntext.java Log: HHH-2762 : Added StatefulPersistenceContext.getProxiesByKey() (needed for t= esting non-flushed changes) Modified: core/trunk/core/src/main/java/org/hibernate/engine/StatefulPersis= tenceContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/StatefulPersistenceC= ontext.java 2009-11-17 18:00:05 UTC (rev 17996) +++ core/trunk/core/src/main/java/org/hibernate/engine/StatefulPersistenceC= ontext.java 2009-11-17 23:12:09 UTC (rev 17997) @@ -997,6 +997,10 @@ return entitiesByKey; } = + public Map getProxiesByKey() { + return proxiesByKey; + } + public Map getEntityEntries() { return entityEntries; } --===============7702580021983272316==-- From hibernate-commits at lists.jboss.org Tue Nov 17 18:18:11 2009 Content-Type: multipart/mixed; boundary="===============6249072000018826341==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17998 - in core/trunk/testsuite/src/test/java/org/hibernate/test: nonflushedchanges and 1 other directory. Date: Tue, 17 Nov 2009 18:17:30 -0500 Message-ID: <200911172317.nAHNHUeK007842@svn01.web.mwc.hst.phx2.redhat.com> --===============6249072000018826341== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: gbadner Date: 2009-11-17 18:17:25 -0500 (Tue, 17 Nov 2009) New Revision: 17998 Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= AbstractOperationTestCase.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= Address.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= Competition.hbm.xml core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= Competition.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= Competitor.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= CreateTest.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= DeleteTest.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= Employee.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= Employer.hbm.xml core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= Employer.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= GetLoadTest.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= MergeTest.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= Node.hbm.xml core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= Node.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= NumberedNode.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= OneToOne.hbm.xml core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= OptLockEntity.hbm.xml core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= Person.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= PersonalDetails.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= SaveOrUpdateTest.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= TimestampedEntity.java core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges/= VersionedEntity.java Log: HHH-2762 : new unit tests for SessionImplementor.getNonFlushedChanges()/app= lyNonFlushedChanges() implementation Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/AbstractOperationTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /AbstractOperationTestCase.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /AbstractOperationTestCase.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,130 @@ +package org.hibernate.test.nonflushedchanges; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.hibernate.ConnectionReleaseMode; +import org.hibernate.Session; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import org.hibernate.engine.EntityKey; +import org.hibernate.engine.NonFlushedChanges; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.StatefulPersistenceContext; +import org.hibernate.junit.functional.FunctionalTestCase; +import org.hibernate.test.tm.ConnectionProviderImpl; +import org.hibernate.test.tm.TransactionManagerLookupImpl; +import org.hibernate.transaction.CMTTransactionFactory; +import org.hibernate.util.SerializationHelper; + +/** + * {@inheritDoc} + * + * @author Steve Ebersole, Gail Badner (adapted this from "ops" tests vers= ion) + */ +public abstract class AbstractOperationTestCase extends FunctionalTestCase= { + private Map oldToNewEntityRefs =3D new HashMap(); + + public AbstractOperationTestCase(String name) { + super( name ); + } + + public void configure(Configuration cfg) { + super.configure( cfg ); + cfg.setProperty( Environment.CONNECTION_PROVIDER, ConnectionProviderImpl= .class.getName() ); + cfg.setProperty( Environment.TRANSACTION_MANAGER_STRATEGY, TransactionMa= nagerLookupImpl.class.getName() ); + cfg.setProperty( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory= .class.getName() ); + cfg.setProperty( Environment.AUTO_CLOSE_SESSION, "true" ); + cfg.setProperty( Environment.FLUSH_BEFORE_COMPLETION, "true" ); + cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.= AFTER_STATEMENT.toString() ); + cfg.setProperty( Environment.GENERATE_STATISTICS, "true" ); + cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" ); + } + + public String[] getMappings() { + return new String[] { + "nonflushedchanges/Node.hbm.xml", + "nonflushedchanges/Employer.hbm.xml", + "nonflushedchanges/OptLockEntity.hbm.xml", + "nonflushedchanges/OneToOne.hbm.xml", + "nonflushedchanges/Competition.hbm.xml" + }; + } + + public String getCacheConcurrencyStrategy() { + return null; + } + + protected void clearCounts() { + getSessions().getStatistics().clear(); + } + + protected void assertInsertCount(int expected) { + int inserts =3D ( int ) getSessions().getStatistics().getEntityInsertCou= nt(); + assertEquals( "unexpected insert count", expected, inserts ); + } + + protected void assertUpdateCount(int expected) { + int updates =3D ( int ) getSessions().getStatistics().getEntityUpdateCou= nt(); + assertEquals( "unexpected update counts", expected, updates ); + } + + protected void assertDeleteCount(int expected) { + int deletes =3D ( int ) getSessions().getStatistics().getEntityDeleteCou= nt(); + assertEquals( "unexpected delete counts", expected, deletes ); + } + + protected void assertFetchCount(int count) { + int fetches =3D ( int ) getSessions().getStatistics().getEntityFetchCoun= t(); + assertEquals( count, fetches ); + } + + protected Session applyNonFlushedChangesToNewSessionCloseOldSession(Sessi= on oldSession) { + NonFlushedChanges nfc =3D ( ( SessionImplementor ) oldSession ).getNonFl= ushedChanges(); + byte[] bytes =3D SerializationHelper.serialize( nfc ); + NonFlushedChanges nfc2 =3D ( NonFlushedChanges ) SerializationHelper.des= erialize( bytes ); + Session newSession =3D openSession(); + ( ( SessionImplementor ) newSession ).applyNonFlushedChanges( nfc2 ); + oldToNewEntityRefs.clear(); + for ( Iterator it =3D ( ( SessionImplementor ) oldSession ).getPersisten= ceContext() + .getEntitiesByKey() + .entrySet() + .iterator(); it.hasNext(); ) { + Map.Entry entry =3D ( Map.Entry ) it.next(); + EntityKey entityKey =3D ( EntityKey ) entry.getKey(); + Object oldEntityRef =3D entry.getValue(); + oldToNewEntityRefs.put( + oldEntityRef, ( ( SessionImplementor ) newSession ).getPersistenceCon= text().getEntity( entityKey ) + ); + } + for ( Iterator it =3D ( ( StatefulPersistenceContext ) ( ( SessionImplem= entor ) oldSession ).getPersistenceContext() ) + .getProxiesByKey() + .entrySet() + .iterator(); it.hasNext(); ) { + Map.Entry entry =3D ( Map.Entry ) it.next(); + EntityKey entityKey =3D ( EntityKey ) entry.getKey(); + Object oldProxyRef =3D entry.getValue(); + oldToNewEntityRefs.put( + oldProxyRef, ( ( SessionImplementor ) newSession ).getPersistenceCont= ext().getProxy( entityKey ) + ); + } + + oldSession.clear(); + oldSession.close(); + return newSession; + } + + protected void applyNonFlushedChangesToClearedSession(Session s) { + NonFlushedChanges nfc =3D ( ( SessionImplementor ) s ).getNonFlushedChan= ges(); + byte[] bytes =3D SerializationHelper.serialize( nfc ); + NonFlushedChanges nfc2 =3D ( NonFlushedChanges ) SerializationHelper.des= erialize( bytes ); + s.clear(); + ( ( SessionImplementor ) s ).applyNonFlushedChanges( nfc2 ); + } + + protected Map getOldToNewEntityRefMap() { + return Collections.unmodifiableMap( oldToNewEntityRefs ); + } +} Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Address.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Address.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,67 @@ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; + +/** + * {@inheritDoc} + * + * @author Steve Ebersole, Gail Badner (adapted this from "ops" tests vers= ion) + */ +public class Address implements Serializable { + private Long id; + private String streetAddress; + private String city; + private String country; + private Person resident; + + public Address() { + } + + public Address(String streetAddress, String city, String country, Person = resident) { + this.streetAddress =3D streetAddress; + this.city =3D city; + this.country =3D country; + this.resident =3D resident; + resident.setAddress( this ); + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public String getStreetAddress() { + return streetAddress; + } + + public void setStreetAddress(String streetAddress) { + this.streetAddress =3D streetAddress; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city =3D city; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country =3D country; + } + + public Person getResident() { + return resident; + } + + public void setResident(Person resident) { + this.resident =3D resident; + } +} Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/Competition.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Competition.hbm.xml (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Competition.hbm.xml 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/Competition.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Competition.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Competition.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,32 @@ +//$Id: $ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Emmanuel Bernard, Gail Badner (adapted this from "ops" tests ve= rsion) + */ +public class Competition implements Serializable { + private Integer id; + + private List competitors =3D new ArrayList(); + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public List getCompetitors() { + return competitors; + } + + public void setCompetitors(List competitors) { + this.competitors =3D competitors; + } +} Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/Competitor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Competitor.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Competitor.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,36 @@ +//$Id: $ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; + +/** + * @author Emmanuel Bernard, Gail Badner (adapted this from "ops" tests ve= rsion) + */ +public class Competitor implements Serializable { + public Integer id; + private String name; + + + public Competitor() { + } + + public Competitor(String name) { + this.name =3D name; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/CreateTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /CreateTest.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /CreateTest.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,250 @@ +//$Id: CreateTest.java 10977 2006-12-12 23:28:04Z steve.ebersole(a)jboss.c= om $ +package org.hibernate.test.nonflushedchanges; + +import java.util.ArrayList; +import java.util.Collection; + +import junit.framework.Test; + +import org.hibernate.Hibernate; +import org.hibernate.PersistentObjectException; +import org.hibernate.Session; +import org.hibernate.exception.ConstraintViolationException; +import org.hibernate.junit.functional.FunctionalTestClassTestSuite; +import org.hibernate.test.tm.SimpleJtaTransactionManagerImpl; + +/** + * @author Gavin King, Gail Badner (adapted this from "ops" tests version) + */ +public class CreateTest extends AbstractOperationTestCase { + + public CreateTest(String str) { + super( str ); + } + + public static Test suite() { + return new FunctionalTestClassTestSuite( CreateTest.class ); + } + + public void testNoUpdatesOnCreateVersionedWithCollection() throws Excepti= on { + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + VersionedEntity root =3D new VersionedEntity( "root", "root" ); + VersionedEntity child =3D new VersionedEntity( "c1", "child-1" ); + root.getChildren().add( child ); + child.setParent( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.save( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + assertUpdateCount( 0 ); + assertDeleteCount( 0 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.delete( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertUpdateCount( 0 ); + assertDeleteCount( 2 ); + } + + public void testCreateTree() throws Exception { + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node root =3D new Node( "root" ); + Node child =3D new Node( "child" ); + root.addChild( child ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.persist( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + assertUpdateCount( 0 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + System.out.println( "getting" ); + root =3D ( Node ) s.get( Node.class, "root" ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + Node child2 =3D new Node( "child2" ); + root.addChild( child2 ); + System.out.println( "committing" ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 3 ); + assertUpdateCount( 0 ); + } + + public void testCreateTreeWithGeneratedId() throws Exception { + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode root =3D new NumberedNode( "root" ); + NumberedNode child =3D new NumberedNode( "child" ); + root.addChild( child ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.persist( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + assertUpdateCount( 0 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) s.get( NumberedNode.class, new Long( root.getI= d() ) ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + NumberedNode child2 =3D new NumberedNode( "child2" ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + root.addChild( child2 ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 3 ); + assertUpdateCount( 0 ); + } + + public void testCreateException() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node dupe =3D new Node( "dupe" ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.persist( dupe ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + dupe =3D ( Node ) getOldToNewEntityRefMap().get( dupe ); + s.persist( dupe ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.persist( dupe ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + try { + SimpleJtaTransactionManagerImpl.getInstance().commit(); + assertFalse( true ); + } + catch ( ConstraintViolationException cve ) { + //verify that an exception is thrown! + } + SimpleJtaTransactionManagerImpl.getInstance().rollback(); + + Node nondupe =3D new Node( "nondupe" ); + nondupe.addChild( dupe ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.persist( nondupe ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + try { + SimpleJtaTransactionManagerImpl.getInstance().commit(); + assertFalse( true ); + } + catch ( ConstraintViolationException cve ) { + //verify that an exception is thrown! + } + SimpleJtaTransactionManagerImpl.getInstance().rollback(); + } + + public void testCreateExceptionWithGeneratedId() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode dupe =3D new NumberedNode( "dupe" ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.persist( dupe ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + dupe =3D ( NumberedNode ) getOldToNewEntityRefMap().get( dupe ); + s.persist( dupe ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + try { + s.persist( dupe ); + assertFalse( true ); + } + catch ( PersistentObjectException poe ) { + //verify that an exception is thrown! + } + SimpleJtaTransactionManagerImpl.getInstance().rollback(); + + NumberedNode nondupe =3D new NumberedNode( "nondupe" ); + nondupe.addChild( dupe ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + try { + s.persist( nondupe ); + assertFalse( true ); + } + catch ( PersistentObjectException poe ) { + //verify that an exception is thrown! + } + SimpleJtaTransactionManagerImpl.getInstance().rollback(); + } + + public void testBasic() throws Exception { + Session s; + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + Employer er =3D new Employer(); + Employee ee =3D new Employee(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.persist( ee ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + ee =3D ( Employee ) getOldToNewEntityRefMap().get( ee ); + Collection erColl =3D new ArrayList(); + Collection eeColl =3D new ArrayList(); + erColl.add( ee ); + eeColl.add( er ); + er.setEmployees( erColl ); + ee.setEmployers( eeColl ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + ee =3D ( Employee ) getOldToNewEntityRefMap().get( ee ); + er =3D ( Employer ) ee.getEmployers().iterator().next(); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + er =3D ( Employer ) s.load( Employer.class, er.getId() ); + assertNotNull( er ); + assertFalse( Hibernate.isInitialized( er ) ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + er =3D ( Employer ) getOldToNewEntityRefMap().get( er ); + assertNotNull( er ); + assertFalse( Hibernate.isInitialized( er ) ); + assertNotNull( er.getEmployees() ); + assertEquals( 1, er.getEmployees().size() ); + Employee eeFromDb =3D ( Employee ) er.getEmployees().iterator().next(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + eeFromDb =3D ( Employee ) getOldToNewEntityRefMap().get( eeFromDb ); + assertEquals( ee.getId(), eeFromDb.getId() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } +} \ No newline at end of file Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/DeleteTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /DeleteTest.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /DeleteTest.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,94 @@ +package org.hibernate.test.nonflushedchanges; + +import junit.framework.Test; + +import org.hibernate.Session; +import org.hibernate.junit.functional.FunctionalTestClassTestSuite; +import org.hibernate.test.tm.SimpleJtaTransactionManagerImpl; + +/** + * {@inheritDoc} + * + * @author Steve Ebersole, Gail Badner (adapted this from "ops" tests vers= ion) + */ +public class DeleteTest extends AbstractOperationTestCase { + public DeleteTest(String name) { + super( name ); + } + + public static Test suite() { + return new FunctionalTestClassTestSuite( DeleteTest.class ); + } + + public void testDeleteVersionedWithCollectionNoUpdate() throws Exception { + // test adapted from HHH-1564... + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + VersionedEntity c =3D new VersionedEntity( "c1", "child-1" ); + VersionedEntity p =3D new VersionedEntity( "root", "root" ); + p.getChildren().add( c ); + c.setParent( p ); + s.save( p ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + VersionedEntity loadedParent =3D ( VersionedEntity ) s.get( VersionedEnt= ity.class, "root" ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + loadedParent =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( load= edParent ); + s.delete( loadedParent ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 0 ); + assertUpdateCount( 0 ); + assertDeleteCount( 2 ); + } + + public void testNoUpdateOnDelete() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node node =3D new Node( "test" ); + s.persist( node ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.delete( node ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertUpdateCount( 0 ); + assertInsertCount( 0 ); + } + + public void testNoUpdateOnDeleteWithCollection() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node parent =3D new Node( "parent" ); + Node child =3D new Node( "child" ); + parent.getCascadingChildren().add( child ); + s.persist( parent ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + parent =3D ( Node ) s.get( Node.class, "parent" ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + parent =3D ( Node ) getOldToNewEntityRefMap().get( parent ); + s.delete( parent ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertUpdateCount( 0 ); + assertInsertCount( 0 ); + assertDeleteCount( 2 ); + } +} Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/Employee.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Employee.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Employee.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,35 @@ +//$Id: Employee.java 5686 2005-02-12 07:27:32Z steveebersole $ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; +import java.util.Collection; + + +/** + * Employee in an Employer-Employee relationship + * + * @author Emmanuel Bernard, Gail Badner (adapted this from "ops" tests ve= rsion) + */ + +public class Employee implements Serializable { + private Integer id; + private Collection employers; + + + public Integer getId() { + return id; + } + + public void setId(Integer integer) { + id =3D integer; + } + + + public Collection getEmployers() { + return employers; + } + + public void setEmployers(Collection employers) { + this.employers =3D employers; + } +} Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/Employer.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Employer.hbm.xml (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Employer.hbm.xml 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/Employer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Employer.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Employer.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,44 @@ +//$Id: Employer.java 8670 2005-11-25 17:36:29Z epbernard $ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; +import java.util.Collection; + + +/** + * Employer in a employer-Employee relationship + * + * @author Emmanuel Bernard, Gail Badner (adapted this from "ops" tests ve= rsion) + */ + +public class Employer implements Serializable { + private Integer id; + private Collection employees; + private Integer vers; + + public Integer getVers() { + return vers; + } + + public void setVers(Integer vers) { + this.vers =3D vers; + } + + + public Collection getEmployees() { + return employees; + } + + + public Integer getId() { + return id; + } + + public void setEmployees(Collection set) { + employees =3D set; + } + + public void setId(Integer integer) { + id =3D integer; + } +} Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/GetLoadTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /GetLoadTest.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /GetLoadTest.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,126 @@ +//$Id: GetLoadTest.java 10977 2006-12-12 23:28:04Z steve.ebersole(a)jboss.= com $ +package org.hibernate.test.nonflushedchanges; + +import junit.framework.Test; + +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import org.hibernate.junit.functional.FunctionalTestClassTestSuite; +import org.hibernate.test.tm.SimpleJtaTransactionManagerImpl; + + +/** + * @author Gavin King, Gail Badner (adapted this from "ops" tests version) + */ +public class GetLoadTest extends AbstractOperationTestCase { + + public GetLoadTest(String str) { + super( str ); + } + + public void testGetLoad() throws Exception { + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Employer emp =3D new Employer(); + s.persist( emp ); + Node node =3D new Node( "foo" ); + Node parent =3D new Node( "bar" ); + parent.addChild( node ); + s.persist( parent ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + emp =3D ( Employer ) s.get( Employer.class, emp.getId() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + emp =3D ( Employer ) getOldToNewEntityRefMap().get( emp ); + assertTrue( Hibernate.isInitialized( emp ) ); + assertFalse( Hibernate.isInitialized( emp.getEmployees() ) ); + node =3D ( Node ) s.get( Node.class, node.getName() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + node =3D ( Node ) getOldToNewEntityRefMap().get( node ); + emp =3D ( Employer ) getOldToNewEntityRefMap().get( emp ); + assertTrue( Hibernate.isInitialized( node ) ); + assertFalse( Hibernate.isInitialized( node.getChildren() ) ); + assertFalse( Hibernate.isInitialized( node.getParent() ) ); + assertNull( s.get( Node.class, "xyz" ) ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + emp =3D ( Employer ) s.load( Employer.class, emp.getId() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + emp =3D ( Employer ) getOldToNewEntityRefMap().get( emp ); + emp.getId(); + assertFalse( Hibernate.isInitialized( emp ) ); + node =3D ( Node ) s.load( Node.class, node.getName() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + node =3D ( Node ) getOldToNewEntityRefMap().get( node ); + assertEquals( node.getName(), "foo" ); + assertFalse( Hibernate.isInitialized( node ) ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + emp =3D ( Employer ) s.get( "org.hibernate.test.nonflushedchanges.Employ= er", emp.getId() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + emp =3D ( Employer ) getOldToNewEntityRefMap().get( emp ); + assertTrue( Hibernate.isInitialized( emp ) ); + node =3D ( Node ) s.get( "org.hibernate.test.nonflushedchanges.Node", no= de.getName() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + node =3D ( Node ) getOldToNewEntityRefMap().get( node ); + assertTrue( Hibernate.isInitialized( node ) ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + emp =3D ( Employer ) s.load( "org.hibernate.test.nonflushedchanges.Emplo= yer", emp.getId() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + emp =3D ( Employer ) getOldToNewEntityRefMap().get( emp ); + emp.getId(); + assertFalse( Hibernate.isInitialized( emp ) ); + node =3D ( Node ) s.load( "org.hibernate.test.nonflushedchanges.Node", n= ode.getName() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + emp =3D ( Employer ) getOldToNewEntityRefMap().get( emp ); + node =3D ( Node ) getOldToNewEntityRefMap().get( node ); + assertEquals( node.getName(), "foo" ); + assertFalse( Hibernate.isInitialized( node ) ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertFetchCount( 0 ); + } + + public void testGetAfterDelete() throws Exception { + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Employer emp =3D new Employer(); + s.persist( emp ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.delete( emp ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + emp =3D ( Employer ) s.get( Employee.class, emp.getId() ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertNull( "get did not return null after delete", emp ); + } + + public void configure(Configuration cfg) { + super.configure( cfg ); + cfg.setProperty( Environment.GENERATE_STATISTICS, "true" ); + cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" ); + } + + public static Test suite() { + return new FunctionalTestClassTestSuite( GetLoadTest.class ); + } +} + Property changes on: core/trunk/testsuite/src/test/java/org/hibernate/test/= nonflushedchanges/GetLoadTest.java ___________________________________________________________________ Name: svn:executable + * Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/MergeTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /MergeTest.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /MergeTest.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,844 @@ +//$Id: MergeTest.java 11037 2007-01-09 16:04:16Z steve.ebersole(a)jboss.co= m $ +package org.hibernate.test.nonflushedchanges; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import junit.framework.Test; + +import org.hibernate.Hibernate; +import org.hibernate.NonUniqueObjectException; +import org.hibernate.Session; +import org.hibernate.StaleObjectStateException; +import org.hibernate.criterion.Projections; +import org.hibernate.junit.functional.FunctionalTestClassTestSuite; +import org.hibernate.test.tm.SimpleJtaTransactionManagerImpl; + +/** + * @author Gavin King, Gail Badner (adapted this from "ops" tests version) + */ +public class MergeTest extends AbstractOperationTestCase { + + public MergeTest(String str) { + super( str ); + } + + public static Test suite() { + return new FunctionalTestClassTestSuite( MergeTest.class ); + } + + public void testMergeStaleVersionFails() throws Exception { + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + VersionedEntity entity =3D new VersionedEntity( "entity", "entity" ); + s.persist( entity ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + // make the detached 'entity' reference stale... + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + VersionedEntity entity2 =3D ( VersionedEntity ) s.get( VersionedEntity.c= lass, entity.getId() ); + entity2.setName( "entity-name" ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + // now try to reattch it + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + try { + s.merge( entity ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + entity =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( entity ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + fail( "was expecting staleness error" ); + } + catch ( StaleObjectStateException expected ) { + // expected outcome... + } + finally { + SimpleJtaTransactionManagerImpl.getInstance().rollback(); + } + } + + public void testMergeBidiPrimayKeyOneToOne() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Person p =3D new Person( "steve" ); + new PersonalDetails( "I have big feet", p ); + s.persist( p ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + p.getDetails().setSomePersonalDetail( p.getDetails().getSomePersonalDeta= il() + " and big hands too" ); + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + p =3D ( Person ) s.merge( p ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + p =3D ( Person ) getOldToNewEntityRefMap().get( p ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 0 ); + assertUpdateCount( 1 ); + assertDeleteCount( 0 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.delete( p ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } + + public void testMergeBidiForeignKeyOneToOne() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Person p =3D new Person( "steve" ); + Address a =3D new Address( "123 Main", "Austin", "US", p ); + s.persist( a ); + s.persist( p ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + p.getAddress().setStreetAddress( "321 Main" ); + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + p =3D ( Person ) s.merge( p ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 0 ); + assertUpdateCount( 0 ); // no cascade + assertDeleteCount( 0 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.delete( a ); + s.delete( p ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } + + public void testNoExtraUpdatesOnMerge() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node node =3D new Node( "test" ); + s.persist( node ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + // node is now detached, but we have made no changes. so attempt to mer= ge it + // into this new session; this should cause no updates... + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + node =3D ( Node ) s.merge( node ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertUpdateCount( 0 ); + assertInsertCount( 0 ); + + /////////////////////////////////////////////////////////////////////// + // as a control measure, now update the node while it is detached and + // make sure we get an update as a result... + node.setDescription( "new description" ); + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + node =3D ( Node ) s.merge( node ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + assertUpdateCount( 1 ); + assertInsertCount( 0 ); + /////////////////////////////////////////////////////////////////////// + + cleanup(); + } + + public void testNoExtraUpdatesOnMergeWithCollection() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node parent =3D new Node( "parent" ); + Node child =3D new Node( "child" ); + parent.getChildren().add( child ); + child.setParent( parent ); + s.persist( parent ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + // parent is now detached, but we have made no changes. so attempt to m= erge it + // into this new session; this should cause no updates... + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + parent =3D ( Node ) s.merge( parent ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertUpdateCount( 0 ); + assertInsertCount( 0 ); + + /////////////////////////////////////////////////////////////////////// + // as a control measure, now update the node while it is detached and + // make sure we get an update as a result... + ( ( Node ) parent.getChildren().iterator().next() ).setDescription( "chi= ld's new description" ); + parent.addChild( new Node( "second child" ) ); + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + parent =3D ( Node ) s.merge( parent ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + assertUpdateCount( 1 ); + assertInsertCount( 1 ); + /////////////////////////////////////////////////////////////////////// + + cleanup(); + } + + public void testNoExtraUpdatesOnMergeVersioned() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + VersionedEntity entity =3D new VersionedEntity( "entity", "entity" ); + s.persist( entity ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + // entity is now detached, but we have made no changes. so attempt to m= erge it + // into this new session; this should cause no updates... + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + VersionedEntity mergedEntity =3D ( VersionedEntity ) s.merge( entity ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + mergedEntity =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( merg= edEntity ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertUpdateCount( 0 ); + assertInsertCount( 0 ); + assertEquals( "unexpected version increment", entity.getVersion(), merge= dEntity.getVersion() ); + + + /////////////////////////////////////////////////////////////////////// + // as a control measure, now update the node while it is detached and + // make sure we get an update as a result... + entity.setName( "new name" ); + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + entity =3D ( VersionedEntity ) s.merge( entity ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + assertUpdateCount( 1 ); + assertInsertCount( 0 ); + /////////////////////////////////////////////////////////////////////// + + cleanup(); + } + + public void testNoExtraUpdatesOnMergeVersionedWithCollection() throws Exc= eption { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + VersionedEntity parent =3D new VersionedEntity( "parent", "parent" ); + VersionedEntity child =3D new VersionedEntity( "child", "child" ); + parent.getChildren().add( child ); + child.setParent( parent ); + s.persist( parent ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + // parent is now detached, but we have made no changes. so attempt to m= erge it + // into this new session; this should cause no updates... + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + VersionedEntity mergedParent =3D ( VersionedEntity ) s.merge( parent ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + mergedParent =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( merg= edParent ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertUpdateCount( 0 ); + assertInsertCount( 0 ); + assertEquals( "unexpected parent version increment", parent.getVersion()= , mergedParent.getVersion() ); + VersionedEntity mergedChild =3D ( VersionedEntity ) mergedParent.getChil= dren().iterator().next(); + assertEquals( "unexpected child version increment", child.getVersion(), = mergedChild.getVersion() ); + + /////////////////////////////////////////////////////////////////////// + // as a control measure, now update the node while it is detached and + // make sure we get an update as a result... + mergedParent.setName( "new name" ); + mergedParent.getChildren().add( new VersionedEntity( "child2", "new chil= d" ) ); + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + parent =3D ( VersionedEntity ) s.merge( mergedParent ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + parent =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( parent ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + assertUpdateCount( 1 ); + assertInsertCount( 1 ); + /////////////////////////////////////////////////////////////////////// + + cleanup(); + } + + public void testNoExtraUpdatesOnPersistentMergeVersionedWithCollection() = throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + VersionedEntity parent =3D new VersionedEntity( "parent", "parent" ); + VersionedEntity child =3D new VersionedEntity( "child", "child" ); + parent.getChildren().add( child ); + child.setParent( parent ); + s.persist( parent ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + // parent is now detached, but we have made no changes. so attempt to me= rge it + // into this new session; this should cause no updates... + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + // load parent so that merge will follow entityIsPersistent path + VersionedEntity persistentParent =3D ( VersionedEntity ) s.get( Versione= dEntity.class, parent.getId() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + persistentParent =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( = persistentParent ); + // load children + VersionedEntity persistentChild =3D ( VersionedEntity ) persistentParent= .getChildren().iterator().next(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + persistentParent =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( = persistentParent ); + VersionedEntity mergedParent =3D ( VersionedEntity ) s.merge( persistent= Parent ); // <-- This merge leads to failure + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + mergedParent =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( merg= edParent ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertUpdateCount( 0 ); + assertInsertCount( 0 ); + assertEquals( "unexpected parent version increment", parent.getVersion()= , mergedParent.getVersion() ); + VersionedEntity mergedChild =3D ( VersionedEntity ) mergedParent.getChil= dren().iterator().next(); + assertEquals( "unexpected child version increment", child.getVersion(), = mergedChild.getVersion() ); + + /////////////////////////////////////////////////////////////////////// + // as a control measure, now update the node once it is loaded and + // make sure we get an update as a result... + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + persistentParent =3D ( VersionedEntity ) s.get( VersionedEntity.class, p= arent.getId() ); + persistentParent.setName( "new name" ); + persistentParent.getChildren().add( new VersionedEntity( "child2", "new = child" ) ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + persistentParent =3D ( VersionedEntity ) getOldToNewEntityRefMap().get( = persistentParent ); + persistentParent =3D ( VersionedEntity ) s.merge( persistentParent ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + assertUpdateCount( 1 ); + assertInsertCount( 1 ); + /////////////////////////////////////////////////////////////////////// + + // cleanup(); + } + + public void testPersistThenMergeInSameTxnWithVersion() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + VersionedEntity entity =3D new VersionedEntity( "test", "test" ); + s.persist( entity ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.merge( new VersionedEntity( "test", "test-2" ) ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + + try { + // control operation... + s.saveOrUpdate( new VersionedEntity( "test", "test-3" ) ); + fail( "saveOrUpdate() should fail here" ); + } + catch ( NonUniqueObjectException expected ) { + // expected behavior + } + + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + cleanup(); + } + + public void testPersistThenMergeInSameTxnWithTimestamp() throws Exception= { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + TimestampedEntity entity =3D new TimestampedEntity( "test", "test" ); + s.persist( entity ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.merge( new TimestampedEntity( "test", "test-2" ) ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + + try { + // control operation... + s.saveOrUpdate( new TimestampedEntity( "test", "test-3" ) ); + fail( "saveOrUpdate() should fail here" ); + } + catch ( NonUniqueObjectException expected ) { + // expected behavior + } + + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + cleanup(); + } + + public void testMergeDeepTree() throws Exception { + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node root =3D new Node( "root" ); + Node child =3D new Node( "child" ); + Node grandchild =3D new Node( "grandchild" ); + root.addChild( child ); + child.addChild( grandchild ); + s.merge( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 3 ); + assertUpdateCount( 0 ); + clearCounts(); + + grandchild.setDescription( "the grand child" ); + Node grandchild2 =3D new Node( "grandchild2" ); + child.addChild( grandchild2 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.merge( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( 1 ); + clearCounts(); + + Node child2 =3D new Node( "child2" ); + Node grandchild3 =3D new Node( "grandchild3" ); + child2.addChild( grandchild3 ); + root.addChild( child2 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.merge( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + assertUpdateCount( 0 ); + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.delete( grandchild ); + s.delete( grandchild2 ); + s.delete( grandchild3 ); + s.delete( child ); + s.delete( child2 ); + s.delete( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + } + + public void testMergeDeepTreeWithGeneratedId() throws Exception { + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode root =3D new NumberedNode( "root" ); + NumberedNode child =3D new NumberedNode( "child" ); + NumberedNode grandchild =3D new NumberedNode( "grandchild" ); + root.addChild( child ); + child.addChild( grandchild ); + root =3D ( NumberedNode ) s.merge( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 3 ); + assertUpdateCount( 0 ); + clearCounts(); + + child =3D ( NumberedNode ) root.getChildren().iterator().next(); + grandchild =3D ( NumberedNode ) child.getChildren().iterator().next(); + grandchild.setDescription( "the grand child" ); + NumberedNode grandchild2 =3D new NumberedNode( "grandchild2" ); + child.addChild( grandchild2 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + root =3D ( NumberedNode ) s.merge( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( 1 ); + clearCounts(); + + getSessions().evict( NumberedNode.class ); + + NumberedNode child2 =3D new NumberedNode( "child2" ); + NumberedNode grandchild3 =3D new NumberedNode( "grandchild3" ); + child2.addChild( grandchild3 ); + root.addChild( child2 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + root =3D ( NumberedNode ) s.merge( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + assertUpdateCount( 0 ); + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.createQuery( "delete from NumberedNode where name like 'grand%'" ).exe= cuteUpdate(); + s.createQuery( "delete from NumberedNode where name like 'child%'" ).exe= cuteUpdate(); + s.createQuery( "delete from NumberedNode" ).executeUpdate(); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + } + + public void testMergeTree() throws Exception { + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node root =3D new Node( "root" ); + Node child =3D new Node( "child" ); + root.addChild( child ); + s.persist( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + child =3D ( Node ) root.getChildren().iterator().next(); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + clearCounts(); + + root.setDescription( "The root node" ); + child.setDescription( "The child node" ); + + Node secondChild =3D new Node( "second child" ); + + root.addChild( secondChild ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.merge( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( 2 ); + + cleanup(); + } + + public void testMergeTreeWithGeneratedId() throws Exception { + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode root =3D new NumberedNode( "root" ); + NumberedNode child =3D new NumberedNode( "child" ); + root.addChild( child ); + s.persist( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + child =3D ( NumberedNode ) root.getChildren().iterator().next(); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + clearCounts(); + + root.setDescription( "The root node" ); + child.setDescription( "The child node" ); + + NumberedNode secondChild =3D new NumberedNode( "second child" ); + + root.addChild( secondChild ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.merge( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( 2 ); + + cleanup(); + } + + public void testMergeManaged() throws Exception { + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode root =3D new NumberedNode( "root" ); + s.persist( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + NumberedNode child =3D new NumberedNode( "child" ); + root =3D ( NumberedNode ) s.merge( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + root.addChild( child ); + assertSame( root, s.merge( root ) ); + Object mergedChild =3D root.getChildren().iterator().next(); + assertNotSame( mergedChild, child ); + assertTrue( s.contains( mergedChild ) ); + assertFalse( s.contains( child ) ); + assertEquals( root.getChildren().size(), 1 ); + assertTrue( root.getChildren().contains( mergedChild ) ); + //assertNotSame( mergedChild, s.merge(child) ); //yucky :( + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + mergedChild =3D root.getChildren().iterator().next(); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( 0 ); + + assertEquals( root.getChildren().size(), 1 ); + assertTrue( root.getChildren().contains( mergedChild ) ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + assertEquals( + s.createCriteria( NumberedNode.class ) + .setProjection( Projections.rowCount() ) + .uniqueResult(), + new Long( 2 ) + ); + + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + cleanup(); + } + + public void testMergeManagedUninitializedCollection() throws Exception { + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode root =3D new NumberedNode( "root" ); + root.addChild( new NumberedNode( "child" ) ); + s.persist( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + NumberedNode newRoot =3D new NumberedNode( "root" ); + newRoot.setId( root.getId() ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + root =3D ( NumberedNode ) s.get( NumberedNode.class, root.getId() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + Set managedChildren =3D root.getChildren(); + assertFalse( Hibernate.isInitialized( managedChildren ) ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + managedChildren =3D root.getChildren(); + newRoot.setChildren( managedChildren ); + assertSame( root, s.merge( newRoot ) ); + assertSame( managedChildren, root.getChildren() ); + assertFalse( Hibernate.isInitialized( managedChildren ) ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 0 ); + assertUpdateCount( 0 ); + assertDeleteCount( 0 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + assertEquals( + s.createCriteria( NumberedNode.class ) + .setProjection( Projections.rowCount() ) + .uniqueResult(), + new Long( 2 ) + ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + cleanup(); + } + + public void testMergeManagedInitializedCollection() throws Exception { + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode root =3D new NumberedNode( "root" ); + root.addChild( new NumberedNode( "child" ) ); + s.persist( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + NumberedNode newRoot =3D new NumberedNode( "root" ); + newRoot.setId( root.getId() ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + root =3D ( NumberedNode ) s.get( NumberedNode.class, root.getId() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + Set managedChildren =3D root.getChildren(); + Hibernate.initialize( managedChildren ); + assertTrue( Hibernate.isInitialized( managedChildren ) ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + managedChildren =3D root.getChildren(); + newRoot.setChildren( managedChildren ); + assertSame( root, s.merge( newRoot ) ); + assertSame( managedChildren, root.getChildren() ); + assertTrue( Hibernate.isInitialized( managedChildren ) ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 0 ); + assertUpdateCount( 0 ); + assertDeleteCount( 0 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + assertEquals( + s.createCriteria( NumberedNode.class ) + .setProjection( Projections.rowCount() ) + .uniqueResult(), + new Long( 2 ) + ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + cleanup(); + } + + public void testRecursiveMergeTransient() throws Exception { + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Employer jboss =3D new Employer(); + Employee gavin =3D new Employee(); + jboss.setEmployees( new ArrayList() ); + jboss.getEmployees().add( gavin ); + s.merge( jboss ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + s.flush(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + jboss =3D ( Employer ) s.createQuery( "from Employer e join fetch e.empl= oyees" ).uniqueResult(); + assertTrue( Hibernate.isInitialized( jboss.getEmployees() ) ); + assertEquals( 1, jboss.getEmployees().size() ); + s.clear(); + s.merge( jboss.getEmployees().iterator().next() ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + cleanup(); + } + + public void testDeleteAndMerge() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Employer jboss =3D new Employer(); + s.persist( jboss ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + Employer otherJboss; + otherJboss =3D ( Employer ) s.get( Employer.class, jboss.getId() ); + s.delete( otherJboss ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + jboss.setVers( new Integer( 1 ) ); + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.merge( jboss ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + cleanup(); + } + + public void testMergeManyToManyWithCollectionDeference() throws Exception= { + // setup base data... + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Competition competition =3D new Competition(); + competition.getCompetitors().add( new Competitor( "Name" ) ); + competition.getCompetitors().add( new Competitor() ); + competition.getCompetitors().add( new Competitor() ); + s.persist( competition ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + // the competition graph is now detached: + // 1) create a new List reference to represent the competitors + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + List newComp =3D new ArrayList(); + Competitor originalCompetitor =3D ( Competitor ) competition.getCompetit= ors().get( 0 ); + originalCompetitor.setName( "Name2" ); + newComp.add( originalCompetitor ); + newComp.add( new Competitor() ); + // 2) set that new List reference unto the Competition reference + competition.setCompetitors( newComp ); + // 3) attempt the merge + Competition competition2 =3D ( Competition ) s.merge( competition ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + Competition competition2copy =3D ( Competition ) getOldToNewEntityRefMap= ().get( competition2 ); + + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertFalse( competition =3D=3D competition2 ); + assertFalse( competition2 =3D=3D competition2copy ); + assertFalse( competition.getCompetitors() =3D=3D competition2.getCompeti= tors() ); + assertEquals( 2, competition2.getCompetitors().size() ); + assertEquals( 2, competition2copy.getCompetitors().size() ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + competition =3D ( Competition ) s.get( Competition.class, competition.ge= tId() ); + assertEquals( 2, competition.getCompetitors().size() ); + s.delete( competition ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + cleanup(); + } + + private void cleanup() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + s.createQuery( "delete from NumberedNode where parent is not null" ).exe= cuteUpdate(); + s.createQuery( "delete from NumberedNode" ).executeUpdate(); + + s.createQuery( "delete from Node where parent is not null" ).executeUpda= te(); + s.createQuery( "delete from Node" ).executeUpdate(); + + s.createQuery( "delete from VersionedEntity where parent is not null" ).= executeUpdate(); + s.createQuery( "delete from VersionedEntity" ).executeUpdate(); + s.createQuery( "delete from TimestampedEntity" ).executeUpdate(); + + s.createQuery( "delete from Competitor" ).executeUpdate(); + s.createQuery( "delete from Competition" ).executeUpdate(); + + Iterator itr =3D s.createQuery( "from Employer" ).list().iterator(); + while ( itr.hasNext() ) { + final Employer employer =3D ( Employer ) itr.next(); + s.delete( employer ); + } + + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } +} + Property changes on: core/trunk/testsuite/src/test/java/org/hibernate/test/= nonflushedchanges/MergeTest.java ___________________________________________________________________ Name: svn:executable + * Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/Node.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Node.hbm.xml (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Node.hbm.xml 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property changes on: core/trunk/testsuite/src/test/java/org/hibernate/test/= nonflushedchanges/Node.hbm.xml ___________________________________________________________________ Name: svn:executable + * Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/Node.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Node.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Node.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,89 @@ +//$Id: Node.java 10759 2006-11-08 00:00:53Z steve.ebersole(a)jboss.com $ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; +import java.sql.Date; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Gavin King, Gail Badner (adapted this from "ops" tests version) + */ +public class Node implements Serializable { + + private String name; + private String description; + private Date created; + private Node parent; + private Set children =3D new HashSet(); + private Set cascadingChildren =3D new HashSet(); + + public Node() { + } + + public Node(String name) { + this.name =3D name; + created =3D generateCurrentDate(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description =3D description; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created =3D created; + } + + public Node getParent() { + return parent; + } + + public void setParent(Node parent) { + this.parent =3D parent; + } + + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children =3D children; + } + + public Node addChild(Node child) { + children.add( child ); + child.setParent( this ); + return this; + } + + public Set getCascadingChildren() { + return cascadingChildren; + } + + public void setCascadingChildren(Set cascadingChildren) { + this.cascadingChildren =3D cascadingChildren; + } + + private Date generateCurrentDate() { + // Note : done as java.sql.Date mainly to work around issue with + // MySQL and its lack of milli-second precision on its DATETIME + // and TIMESTAMP datatypes. + return new Date( new java.util.Date().getTime() ); + } +} Property changes on: core/trunk/testsuite/src/test/java/org/hibernate/test/= nonflushedchanges/Node.java ___________________________________________________________________ Name: svn:executable + * Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/NumberedNode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /NumberedNode.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /NumberedNode.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,83 @@ +//$Id: NumberedNode.java 7236 2005-06-20 03:19:34Z oneovthafew $ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Gavin King, Gail Badner (adapted this from "ops" tests version) + */ +public class NumberedNode implements Serializable { + + private long id; + private String name; + private NumberedNode parent; + private Set children =3D new HashSet(); + private String description; + private Date created; + + public NumberedNode() { + super(); + } + + public NumberedNode(String name) { + this.name =3D name; + created =3D new Date(); + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id =3D id; + } + + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children =3D children; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public NumberedNode getParent() { + return parent; + } + + public void setParent(NumberedNode parent) { + this.parent =3D parent; + } + + public NumberedNode addChild(NumberedNode child) { + children.add( child ); + child.setParent( this ); + return this; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description =3D description; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created =3D created; + } +} Property changes on: core/trunk/testsuite/src/test/java/org/hibernate/test/= nonflushedchanges/NumberedNode.java ___________________________________________________________________ Name: svn:executable + * Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/OneToOne.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /OneToOne.hbm.xml (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /OneToOne.hbm.xml 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/OptLockEntity.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /OptLockEntity.hbm.xml (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /OptLockEntity.hbm.xml 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/Person.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Person.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /Person.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,54 @@ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; + +/** + * {@inheritDoc} + * + * @author Steve Ebersole, Gail Badner (adapted this from "ops" tests vers= ion) + */ +public class Person implements Serializable { + private Long id; + private String name; + private Address address; + private PersonalDetails details; + + public Person() { + } + + public Person(String name) { + this.name =3D name; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address =3D address; + } + + public PersonalDetails getDetails() { + return details; + } + + public void setDetails(PersonalDetails details) { + this.details =3D details; + } +} Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/PersonalDetails.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /PersonalDetails.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /PersonalDetails.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,47 @@ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; + +/** + * {@inheritDoc} + * + * @author Steve Ebersole, Gail Badner (adapted this from "ops" tests vers= ion) + */ +public class PersonalDetails implements Serializable { + private Long id; + private String somePersonalDetail; + private Person person; + + public PersonalDetails() { + } + + public PersonalDetails(String somePersonalDetail, Person person) { + this.somePersonalDetail =3D somePersonalDetail; + this.person =3D person; + person.setDetails( this ); + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public String getSomePersonalDetail() { + return somePersonalDetail; + } + + public void setSomePersonalDetail(String somePersonalDetail) { + this.somePersonalDetail =3D somePersonalDetail; + } + + public Person getPerson() { + return person; + } + + public void setPerson(Person person) { + this.person =3D person; + } +} Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/SaveOrUpdateTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /SaveOrUpdateTest.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /SaveOrUpdateTest.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,492 @@ +//$Id: SaveOrUpdateTest.java 10977 2006-12-12 23:28:04Z steve.ebersole(a)j= boss.com $ +package org.hibernate.test.nonflushedchanges; + +import junit.framework.Test; + +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import org.hibernate.criterion.Projections; +import org.hibernate.intercept.FieldInterceptionHelper; +import org.hibernate.junit.functional.FunctionalTestClassTestSuite; +import org.hibernate.proxy.HibernateProxy; +import org.hibernate.test.tm.SimpleJtaTransactionManagerImpl; + +/** + * @author Gavin King, Gail Badner (adapted this from "ops" tests version) + */ +public class SaveOrUpdateTest extends AbstractOperationTestCase { + + public SaveOrUpdateTest(String str) { + super( str ); + } + + public void testSaveOrUpdateDeepTree() throws Exception { + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node root =3D new Node( "root" ); + Node child =3D new Node( "child" ); + Node grandchild =3D new Node( "grandchild" ); + root.addChild( child ); + child.addChild( grandchild ); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + child =3D ( Node ) getOldToNewEntityRefMap().get( child ); + grandchild =3D ( Node ) getOldToNewEntityRefMap().get( grandchild ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 3 ); + assertUpdateCount( 0 ); + clearCounts(); + + grandchild.setDescription( "the grand child" ); + Node grandchild2 =3D new Node( "grandchild2" ); + child.addChild( grandchild2 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( 1 ); + clearCounts(); + + Node child2 =3D new Node( "child2" ); + Node grandchild3 =3D new Node( "grandchild3" ); + child2.addChild( grandchild3 ); + root.addChild( child2 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + assertUpdateCount( 0 ); + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.delete( grandchild ); + s.delete( grandchild2 ); + s.delete( grandchild3 ); + s.delete( child ); + s.delete( child2 ); + s.delete( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } + + public void testSaveOrUpdateDeepTreeWithGeneratedId() throws Exception { + boolean instrumented =3D FieldInterceptionHelper.isInstrumented( new Num= beredNode() ); + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode root =3D new NumberedNode( "root" ); + NumberedNode child =3D new NumberedNode( "child" ); + NumberedNode grandchild =3D new NumberedNode( "grandchild" ); + root.addChild( child ); + child.addChild( grandchild ); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + child =3D ( NumberedNode ) getOldToNewEntityRefMap().get( child ); + grandchild =3D ( NumberedNode ) getOldToNewEntityRefMap().get( grandchil= d ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 3 ); + assertUpdateCount( 0 ); + clearCounts(); + + child =3D ( NumberedNode ) root.getChildren().iterator().next(); + grandchild =3D ( NumberedNode ) child.getChildren().iterator().next(); + grandchild.setDescription( "the grand child" ); + NumberedNode grandchild2 =3D new NumberedNode( "grandchild2" ); + child.addChild( grandchild2 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( instrumented ? 1 : 3 ); + clearCounts(); + + NumberedNode child2 =3D new NumberedNode( "child2" ); + NumberedNode grandchild3 =3D new NumberedNode( "grandchild3" ); + child2.addChild( grandchild3 ); + root.addChild( child2 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + assertUpdateCount( instrumented ? 0 : 4 ); + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.createQuery( "delete from NumberedNode where name like 'grand%'" ).exe= cuteUpdate(); + s.createQuery( "delete from NumberedNode where name like 'child%'" ).exe= cuteUpdate(); + s.createQuery( "delete from NumberedNode" ).executeUpdate(); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } + + public void testSaveOrUpdateTree() throws Exception { + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node root =3D new Node( "root" ); + Node child =3D new Node( "child" ); + root.addChild( child ); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + child =3D ( Node ) getOldToNewEntityRefMap().get( child ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + clearCounts(); + + root.setDescription( "The root node" ); + child.setDescription( "The child node" ); + + Node secondChild =3D new Node( "second child" ); + + root.addChild( secondChild ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( 2 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.createQuery( "delete from Node where parent is not null" ).executeUpda= te(); + s.createQuery( "delete from Node" ).executeUpdate(); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } + + public void testSaveOrUpdateTreeWithGeneratedId() throws Exception { + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode root =3D new NumberedNode( "root" ); + NumberedNode child =3D new NumberedNode( "child" ); + root.addChild( child ); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + child =3D ( NumberedNode ) getOldToNewEntityRefMap().get( child ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 2 ); + clearCounts(); + + root.setDescription( "The root node" ); + child.setDescription( "The child node" ); + + NumberedNode secondChild =3D new NumberedNode( "second child" ); + + root.addChild( secondChild ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( 2 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.createQuery( "delete from NumberedNode where parent is not null" ).exe= cuteUpdate(); + s.createQuery( "delete from NumberedNode" ).executeUpdate(); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } + + public void testSaveOrUpdateManaged() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode root =3D new NumberedNode( "root" ); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + root =3D ( NumberedNode ) s.get( NumberedNode.class, root.getId() ); + NumberedNode child =3D new NumberedNode( "child" ); + root.addChild( child ); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + assertNull( getOldToNewEntityRefMap().get( child ) ); + s.flush(); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + child =3D ( NumberedNode ) getOldToNewEntityRefMap().get( child ); + child =3D ( NumberedNode ) root.getChildren().iterator().next(); + assertTrue( s.contains( child ) ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + child =3D ( NumberedNode ) getOldToNewEntityRefMap().get( child ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertTrue( root.getChildren().contains( child ) ); + assertEquals( root.getChildren().size(), 1 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + assertEquals( + s.createCriteria( NumberedNode.class ) + .setProjection( Projections.rowCount() ) + .uniqueResult(), + new Long( 2 ) + ); + s.delete( root ); + s.delete( child ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } + + + public void testSaveOrUpdateGot() throws Exception { + boolean instrumented =3D FieldInterceptionHelper.isInstrumented( new Num= beredNode() ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + NumberedNode root =3D new NumberedNode( "root" ); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( 0 ); + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 0 ); + assertUpdateCount( instrumented ? 0 : 1 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + root =3D ( NumberedNode ) s.get( NumberedNode.class, new Long( root.getI= d() ) ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + Hibernate.initialize( root.getChildren() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + NumberedNode child =3D new NumberedNode( "child" ); + root.addChild( child ); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( NumberedNode ) getOldToNewEntityRefMap().get( root ); + assertTrue( Hibernate.isInitialized( root.getChildren() ) ); + child =3D ( NumberedNode ) root.getChildren().iterator().next(); + assertTrue( s.contains( child ) ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( instrumented ? 0 : 1 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + assertEquals( + s.createCriteria( NumberedNode.class ) + .setProjection( Projections.rowCount() ) + .uniqueResult(), + new Long( 2 ) + ); + s.delete( root ); + s.delete( child ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } + + public void testSaveOrUpdateGotWithMutableProp() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node root =3D new Node( "root" ); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + assertUpdateCount( 0 ); + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 0 ); + assertUpdateCount( 0 ); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + root =3D ( Node ) s.get( Node.class, "root" ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + Hibernate.initialize( root.getChildren() ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + clearCounts(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + Node child =3D new Node( "child" ); + root.addChild( child ); + s.saveOrUpdate( root ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + child =3D ( Node ) root.getChildren().iterator().next(); + assertTrue( s.contains( child ) ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + root =3D ( Node ) getOldToNewEntityRefMap().get( root ); + child =3D ( Node ) getOldToNewEntityRefMap().get( child ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + assertInsertCount( 1 ); + //assertUpdateCount( 1 ); //note: will fail here if no second-level cache + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + assertEquals( + s.createCriteria( Node.class ) + .setProjection( Projections.rowCount() ) + .uniqueResult(), + new Long( 2 ) + ); + s.delete( root ); + s.delete( child ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } + + public void testEvictThenSaveOrUpdate() throws Exception { + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s =3D openSession(); + Node parent =3D new Node( "1:parent" ); + Node child =3D new Node( "2:child" ); + Node grandchild =3D new Node( "3:grandchild" ); + parent.addChild( child ); + child.addChild( grandchild ); + s.saveOrUpdate( parent ); + s =3D applyNonFlushedChangesToNewSessionCloseOldSession( s ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s1 =3D openSession(); + child =3D ( Node ) s1.load( Node.class, "2:child" ); + s1 =3D applyNonFlushedChangesToNewSessionCloseOldSession( s1 ); + child =3D ( Node ) getOldToNewEntityRefMap().get( child ); + assertTrue( s1.contains( child ) ); + assertFalse( Hibernate.isInitialized( child ) ); + assertTrue( s1.contains( child.getParent() ) ); + assertTrue( Hibernate.isInitialized( child ) ); + assertFalse( Hibernate.isInitialized( child.getChildren() ) ); + assertFalse( Hibernate.isInitialized( child.getParent() ) ); + assertTrue( s1.contains( child ) ); + s1 =3D applyNonFlushedChangesToNewSessionCloseOldSession( s1 ); + // child is an initialized proxy; after serialization, it is + // the proxy is replaced by its implementation + // TODO: find out if this is how this should work... + child =3D ( Node ) getOldToNewEntityRefMap().get( + ( ( HibernateProxy ) child ).getHibernateLazyInitializer().getImplemen= tation() + ); + s1.evict( child ); + assertFalse( s1.contains( child ) ); + assertTrue( s1.contains( child.getParent() ) ); + + javax.transaction.Transaction tx1 =3D SimpleJtaTransactionManagerImpl.ge= tInstance().suspend(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + Session s2 =3D openSession(); + s2.saveOrUpdate( child ); + s2 =3D applyNonFlushedChangesToNewSessionCloseOldSession( s2 ); + child =3D ( Node ) getOldToNewEntityRefMap().get( child ); + assertTrue( s2.contains( child ) ); + assertFalse( s1.contains( child ) ); + assertTrue( s2.contains( child.getParent() ) ); + assertFalse( s1.contains( child.getParent() ) ); + assertFalse( Hibernate.isInitialized( child.getChildren() ) ); + assertFalse( Hibernate.isInitialized( child.getParent() ) ); + assertEquals( 1, child.getChildren().size() ); + assertEquals( "1:parent", child.getParent().getName() ); + assertTrue( Hibernate.isInitialized( child.getChildren() ) ); + assertFalse( Hibernate.isInitialized( child.getParent() ) ); + assertNull( child.getParent().getDescription() ); + assertTrue( Hibernate.isInitialized( child.getParent() ) ); + s1 =3D applyNonFlushedChangesToNewSessionCloseOldSession( s1 ); + s2 =3D applyNonFlushedChangesToNewSessionCloseOldSession( s2 ); + + javax.transaction.Transaction tx2 =3D SimpleJtaTransactionManagerImpl.ge= tInstance().suspend(); + SimpleJtaTransactionManagerImpl.getInstance().resume( tx1 ); + tx1.commit(); + + SimpleJtaTransactionManagerImpl.getInstance().resume( tx2 ); + tx2.commit(); + + SimpleJtaTransactionManagerImpl.getInstance().begin(); + s =3D openSession(); + s.delete( s.get( Node.class, "3:grandchild" ) ); + s.delete( s.get( Node.class, "2:child" ) ); + s.delete( s.get( Node.class, "1:parent" ) ); + SimpleJtaTransactionManagerImpl.getInstance().commit(); + } + + public void configure(Configuration cfg) { + super.configure( cfg ); + cfg.setProperty( Environment.GENERATE_STATISTICS, "true" ); + cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" ); + } + + public String[] getMappings() { + return new String[] { "nonflushedchanges/Node.hbm.xml" }; + } + + public static Test suite() { + return new FunctionalTestClassTestSuite( SaveOrUpdateTest.class ); + } + +} + Property changes on: core/trunk/testsuite/src/test/java/org/hibernate/test/= nonflushedchanges/SaveOrUpdateTest.java ___________________________________________________________________ Name: svn:executable + * Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/TimestampedEntity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /TimestampedEntity.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /TimestampedEntity.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,48 @@ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; +import java.util.Date; + +/** + * todo: describe TimestampedEntity + * + * @author Steve Ebersole, Gail Badner (adapted this from "ops" tests vers= ion) + */ +public class TimestampedEntity implements Serializable { + private String id; + private String name; + private Date timestamp; + + public TimestampedEntity() { + } + + public TimestampedEntity(String id, String name) { + this.id =3D id; + this.name =3D name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp =3D timestamp; + } +} + Added: core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchan= ges/VersionedEntity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /VersionedEntity.java (rev 0) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/nonflushedchanges= /VersionedEntity.java 2009-11-17 23:17:25 UTC (rev 17998) @@ -0,0 +1,67 @@ +package org.hibernate.test.nonflushedchanges; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +/** + * VersionedEntity + * + * @author Steve Ebersole, Gail Badner (adapted this from "ops" tests vers= ion) + */ +public class VersionedEntity implements Serializable { + private String id; + private String name; + private long version; + + private VersionedEntity parent; + private Set children =3D new HashSet(); + + public VersionedEntity() { + } + + public VersionedEntity(String id, String name) { + this.id =3D id; + this.name =3D name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public long getVersion() { + return version; + } + + public void setVersion(long version) { + this.version =3D version; + } + + public VersionedEntity getParent() { + return parent; + } + + public void setParent(VersionedEntity parent) { + this.parent =3D parent; + } + + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children =3D children; + } +} --===============6249072000018826341==-- From hibernate-commits at lists.jboss.org Wed Nov 18 05:33:47 2009 Content-Type: multipart/mixed; boundary="===============0217354828854916737==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r17999 - core/branches/Branch_3_3_2_GA_CP/parent. Date: Wed, 18 Nov 2009 05:33:47 -0500 Message-ID: <200911181033.nAIAXl3J011917@svn01.web.mwc.hst.phx2.redhat.com> --===============0217354828854916737== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-18 05:33:47 -0500 (Wed, 18 Nov 2009) New Revision: 17999 Modified: core/branches/Branch_3_3_2_GA_CP/parent/pom.xml Log: JBPAPP-3115 update HREFs for JDK from jdk1.4 to jdk1.5 Modified: core/branches/Branch_3_3_2_GA_CP/parent/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/parent/pom.xml 2009-11-17 23:17:25 UTC= (rev 17998) +++ core/branches/Branch_3_3_2_GA_CP/parent/pom.xml 2009-11-18 10:33:47 UTC= (rev 17999) @@ -219,8 +219,8 @@ maven-javadoc-plugin - http://java.sun.com/j2se/1.4.2/docs/api/ - http://java.sun.com/j2ee/1.4/docs/api/ + http://java.sun.com/j2se/1.5.0/docs/api/ + http://java.sun.com/javaee/5/docs/api/ --===============0217354828854916737==-- From hibernate-commits at lists.jboss.org Wed Nov 18 05:49:31 2009 Content-Type: multipart/mixed; boundary="===============6768011863500950585==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18000 - core/branches/Branch_3_2_4_SP1_CP. Date: Wed, 18 Nov 2009 05:49:31 -0500 Message-ID: <200911181049.nAIAnV0t013793@svn01.web.mwc.hst.phx2.redhat.com> --===============6768011863500950585== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-18 05:49:30 -0500 (Wed, 18 Nov 2009) New Revision: 18000 Modified: core/branches/Branch_3_2_4_SP1_CP/build.xml Log: JBPAPP-3115 update HREFs for JDK from jdk1.4 to jdk1.5 Modified: core/branches/Branch_3_2_4_SP1_CP/build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/build.xml 2009-11-18 10:33:47 UTC (re= v 17999) +++ core/branches/Branch_3_2_4_SP1_CP/build.xml 2009-11-18 10:49:30 UTC (re= v 18000) @@ -59,7 +59,7 @@ = - + --===============6768011863500950585==-- From hibernate-commits at lists.jboss.org Wed Nov 18 07:05:35 2009 Content-Type: multipart/mixed; boundary="===============0378178661914141430==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18001 - in validator/trunk: hibernate-validator and 2 other directories. Date: Wed, 18 Nov 2009 07:05:35 -0500 Message-ID: <200911181205.nAIC5ZQi026023@svn01.web.mwc.hst.phx2.redhat.com> --===============0378178661914141430== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-18 07:05:34 -0500 (Wed, 18 Nov 2009) New Revision: 18001 Modified: validator/trunk/hibernate-validator/pom.xml validator/trunk/hibernate-validator/readme.txt validator/trunk/hibernate-validator/src/main/assembly/dist.xml validator/trunk/hibernate-validator/src/main/java/org/hibernate/validato= r/xml/ValidationXmlParser.java validator/trunk/hibernate-validator/src/main/java/org/hibernate/validato= r/xml/XmlMappingParser.java validator/trunk/pom.xml Log: HV-272 Removed the jaxb profile and made the dependencies provided Updated the readme and assembly configuration Added enforcer to parent pom to force JDK Modified: validator/trunk/hibernate-validator/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/pom.xml 2009-11-18 10:49:30 UTC (re= v 18000) +++ validator/trunk/hibernate-validator/pom.xml 2009-11-18 12:05:34 UTC (re= v 18001) @@ -44,6 +44,24 @@ = + + javax.xml.bind + jaxb-api + 2.2 + provided + + + com.sun.xml.bind + jaxb-impl + 2.1.12 + provided + + + @@ -131,7 +149,6 @@ test-report - org.apache.maven.plugins maven-shade-plugin @@ -246,6 +263,13 @@ maven-cli-plugin 0.6.3.CR3 + + org.apache.maven.plugins + maven-release-plugin + + javadoc:javadoc org.jboss.maven.plugins:maven-= jdocbook-plugin:2.2.0:resources org.jboss.maven.plugins:maven-jdocbook-plug= in:2.2.0:generate assembly:assembly deploy + + @@ -257,24 +281,4 @@ - - - jaxb - - 1.5 - - - - javax.xml.bind - jaxb-api - 2.1 - - - com.sun.xml.bind - jaxb-impl - 2.1.3 - - - - Modified: validator/trunk/hibernate-validator/readme.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/readme.txt 2009-11-18 10:49:30 UTC = (rev 18000) +++ validator/trunk/hibernate-validator/readme.txt 2009-11-18 12:05:34 UTC = (rev 18001) @@ -16,11 +16,6 @@ is not based on JSR 303. This code can be accessed via = http://anonsvn.jboss.org/repos/hibernate/validator/trunk/hibernate-valid= ator-legacy = - Status - ------ - - This is the first GA release of Hibernate Validator 4. - Documentation ------------- = @@ -41,9 +36,9 @@ Using Hibernate Validator ------------------------- = - - Copy hibernate-validator-*.jar together will all jar files from lib in= to the = - classpath of your application. In case you are running on JDK5 you hav= e to also include - all the jar files from the jdk5 subdirectory. + - In case you use the distribution archive from the download sire, copy = hibernate-validator-*.jar together + with all jar files from lib into the classpath of your application. + In case you are using Java 5 you have to also include all the jar file= s from the jdk5 subdirectory. = or = = @@ -55,7 +50,7 @@ ${project.version} = - Hibernate Validator can be found in this repository: http://repository= .jboss.com/maven2/ = + Hibernate Validator can be found in the JBoss Maven repository: http:/= /repository.jboss.com/maven2/ = Licensing --------- Modified: validator/trunk/hibernate-validator/src/main/assembly/dist.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/main/assembly/dist.xml 2009-11-= 18 10:49:30 UTC (rev 18000) +++ validator/trunk/hibernate-validator/src/main/assembly/dist.xml 2009-11-= 18 12:05:34 UTC (rev 18001) @@ -42,7 +42,7 @@ false lib/jdk5 - runtime + provided javax.xml.bind:jaxb-api com.sun.xml.bind:jaxb-impl Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/v= alidator/xml/ValidationXmlParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validat= or/xml/ValidationXmlParser.java 2009-11-18 10:49:30 UTC (rev 18000) +++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validat= or/xml/ValidationXmlParser.java 2009-11-18 12:05:34 UTC (rev 18001) @@ -124,15 +124,15 @@ } = private void setMappingStreamsFromXml(ValidationConfigType config, Valida= tionBootstrapParameters xmlParameters) { - for ( JAXBElement mappingFileName : config.getConstraintMapping(= ) ) { + for ( String mappingFileName : config.getConstraintMapping() ) { if ( log.isDebugEnabled() ) { log.debug( - "Trying to open input stream for {}.", mappingFileName.getValue() + "Trying to open input stream for {}.", mappingFileName ); } - InputStream in =3D getInputStreamForPath( mappingFileName.getValue() ); + InputStream in =3D getInputStreamForPath( mappingFileName ); if ( in =3D=3D null ) { - throw new ValidationException( "Unable to open input stream for mappin= g file " + mappingFileName.getValue() + "." ); + throw new ValidationException( "Unable to open input stream for mappin= g file " + mappingFileName + "." ); } xmlParameters.mappings.add( in ); } Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/v= alidator/xml/XmlMappingParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validat= or/xml/XmlMappingParser.java 2009-11-18 10:49:30 UTC (rev 18000) +++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validat= or/xml/XmlMappingParser.java 2009-11-18 12:05:34 UTC (rev 18001) @@ -168,10 +168,10 @@ if ( validatedByType.isIncludeExistingValidators() !=3D null && validat= edByType.isIncludeExistingValidators() ) { constraintValidatorClasses.addAll( findConstraintValidatorClasses( ann= otationClass ) ); } - for ( JAXBElement validatorClassName : validatedByType.getValue= () ) { + for ( String validatorClassName : validatedByType.getValue() ) { Class> validatorClass; validatorClass =3D ( Class> ) load= Class( - validatorClassName.getValue(), + validatorClassName, this.getClass() ); = @@ -368,8 +368,8 @@ private List> createGroupSequence(GroupSequenceType groupSequenc= eType, String defaultPackage) { List> groupSequence =3D new ArrayList>(); if ( groupSequenceType !=3D null ) { - for ( JAXBElement groupName : groupSequenceType.getValue() ) { - Class group =3D getClass( groupName.getValue(), defaultPackage ); + for ( String groupName : groupSequenceType.getValue() ) { + Class group =3D getClass( groupName, defaultPackage ); groupSequence.add( group ); } } @@ -601,8 +601,8 @@ } = List> groupList =3D new ArrayList>(); - for ( JAXBElement groupClass : groupsType.getValue() ) { - groupList.add( getClass( groupClass.getValue(), defaultPackage ) ); + for ( String groupClass : groupsType.getValue() ) { + groupList.add( getClass( groupClass, defaultPackage ) ); } return groupList.toArray( new Class[groupList.size()] ); } @@ -614,8 +614,8 @@ } = List> payloadList =3D new ArrayList>(); - for ( JAXBElement groupClass : payloadType.getValue() ) { - Class payload =3D getClass( groupClass.getValue(), defaultPackage ); + for ( String groupClass : payloadType.getValue() ) { + Class payload =3D getClass( groupClass, defaultPackage ); if ( !Payload.class.isAssignableFrom( payload ) ) { throw new ValidationException( "Specified payload class " + payload.ge= tName() + " does not implement javax.validation.Payload" ); } Modified: validator/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/pom.xml 2009-11-18 10:49:30 UTC (rev 18000) +++ validator/trunk/pom.xml 2009-11-18 12:05:34 UTC (rev 18001) @@ -76,6 +76,28 @@ 1.0-beta-2 + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-java + + enforce + + + + + + + + [1.6,) + + + + + @@ -143,7 +165,7 @@ true true true - package site assembly:assembly deploy + deploy --===============0378178661914141430==-- From hibernate-commits at lists.jboss.org Wed Nov 18 08:27:14 2009 Content-Type: multipart/mixed; boundary="===============3460474608345068875==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18002 - validator/trunk/hibernate-validator. Date: Wed, 18 Nov 2009 08:27:14 -0500 Message-ID: <200911181327.nAIDRE8Z010990@svn01.web.mwc.hst.phx2.redhat.com> --===============3460474608345068875== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-18 08:27:14 -0500 (Wed, 18 Nov 2009) New Revision: 18002 Modified: validator/trunk/hibernate-validator/pom.xml Log: HV-273 Modified: validator/trunk/hibernate-validator/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator/pom.xml 2009-11-18 12:05:34 UTC (re= v 18001) +++ validator/trunk/hibernate-validator/pom.xml 2009-11-18 13:27:14 UTC (re= v 18002) @@ -30,7 +30,7 @@ com.googlecode.jtype jtype - 0.1.0 + 0.1.1 = - - - = - - - - = - - - - - - - - - - - - = - - - = - - = - - - - - - - - - - = - - - - - - - - - - - - = - - - - - - - - - - = - - = - - - - - - - - - - - - = - - - - - - - = - - - - - - - - - - - - - - - - - - - = - - - - - - - - Running against db: @{db} - - - - - - - - - - - - = - - - - - - - - - Running against db: @{db} - - - - - - - - - - = - - - - - - - - - - = - - - = - - - - - - - = - - - - - - - - - - - = - - - - - - - - - - - - - = - = - - - = - - - - - = - - - - - - - - - = - Deleted: annotations/branches/v3_4_0_GA_CP/common-build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/common-build.xml 2009-11-24 19:34:57 = UTC (rev 18040) +++ annotations/branches/v3_4_0_GA_CP/common-build.xml 2009-11-24 20:00:11 = UTC (rev 18041) @@ -1,455 +0,0 @@ - - - Common properties and targets for the HibernateExt - project - = - = - - - = - - - - = - = - - - - - - - - - - - - - - - = - - - = - - - - - - - = - - - - - - = - - - = - - - - - - - - - - = - - - - - - - - - - = - - - - - - - - - = - - - - - - - - = - - - - = - - = - - - - - = - - - = - - - - - - - - = - - - - - - - - - - - = - - - - - = - - - - - = - - - - = - - - - - - - - = - - - - - - - - - = - - - - - = - - - - - - - - = - - - = - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - - - - - = - - - - = - = - - - - = - = - - - - - - - = - - - - - - - - - - - - - - - - - - - - - = - - - - - - - - - - - - = - - - - - - - - - = - - - - - = - - - - - = - - = - - - - - - - - - = - - - - - - - - - - - - - - - - - - = - - - - - - - - - = - - - - - - - - - - - - - - - - = - - - - - - - - - - - = - - = - - - - = - - - - - - - - - = - = - - - - - - - - Running against db: @{db} - - - - - - - - - - - - = - - - - - - - - - = - - - - - - - - - - = - - - - - - - - = - - - - = - - - - - - - - - = - - = - - - - = - - - - - - - - - = - Deleted: annotations/branches/v3_4_0_GA_CP/ivy.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/ivy.xml 2009-11-24 19:34:57 UTC (rev = 18040) +++ annotations/branches/v3_4_0_GA_CP/ivy.xml 2009-11-24 20:00:11 UTC (rev = 18041) @@ -1,36 +0,0 @@ - - - - - - - - - - - - - default"/> - default"/> - default"/> - default"/> - default"/> - - - - default"/> - default"/> - - - default"/> - d= efault"/> - default"/> - default"/> - default"/> - default"/> - default"/> - - \ No newline at end of file --===============4509426396780876370==-- From hibernate-commits at lists.jboss.org Tue Nov 24 15:02:13 2009 Content-Type: multipart/mixed; boundary="===============0985686713716611905==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18042 - annotations/branches/v3_4_0_GA_CP. Date: Tue, 24 Nov 2009 15:02:13 -0500 Message-ID: <200911242002.nAOK2DEt020745@svn01.web.mwc.hst.phx2.redhat.com> --===============0985686713716611905== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-24 15:02:13 -0500 (Tue, 24 Nov 2009) New Revision: 18042 Removed: annotations/branches/v3_4_0_GA_CP/lib/ Log: JBPAPP-3150 change the build tool of Hibernate Annotations(eap 5 cp branch) --===============0985686713716611905==-- From hibernate-commits at lists.jboss.org Tue Nov 24 15:02:57 2009 Content-Type: multipart/mixed; boundary="===============5297174044035709712==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18043 - annotations/branches/v3_4_0_GA_CP. Date: Tue, 24 Nov 2009 15:02:56 -0500 Message-ID: <200911242002.nAOK2uEB020858@svn01.web.mwc.hst.phx2.redhat.com> --===============5297174044035709712== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-24 15:02:56 -0500 (Tue, 24 Nov 2009) New Revision: 18043 Modified: annotations/branches/v3_4_0_GA_CP/pom.xml Log: JBPAPP-3150 change the build tool of Hibernate Annotations(eap 5 cp branch) Modified: annotations/branches/v3_4_0_GA_CP/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/pom.xml 2009-11-24 20:02:13 UTC (rev = 18042) +++ annotations/branches/v3_4_0_GA_CP/pom.xml 2009-11-24 20:02:56 UTC (rev = 18043) @@ -1,52 +1,653 @@ - + 4.0.0 org.hibernate hibernate-annotations jar - @version@ + 3.4.0.GA = Hibernate Annotations Annotations metadata for Hibernate http://annotations.hibernate.org = + + Hibernate.org + http://hibernate.org + + - GNU LESSER GENERAL PUBLIC LICENSE - http://www.gnu.org/licenses/lgpl.txt + GNU Lesser General Public License + http://www.gnu.org/licenses/lgpl-2.1.html + See discussion at http://hibernate.org/356.html for more + details. + repo + + JIRA + http://opensource.atlassian.com/projects/hibernate/browse/ANN= + + + scm:svn:http://anonsvn.jboss.org/repos/hibernate/annot= ations/branches/v3_4_0_GA_CP + scm:svn:https://svn.jboss.org/repos/hibernate= /annotations/branches/v3_4_0_GA_CP + http://fisheye.jboss.com/browse/Hibernate/annotations/branche= s/v3_4_0_GA_CP + = org.hibernate + hibernate-core + 3.3.2.GA + + + org.hibernate ejb3-persistence 1.0.2.GA - + org.hibernate hibernate-commons-annotations 3.1.0.GA - - org.hibernate - hibernate-core - 3.3.0.SP1 + + org.slf4j + slf4j-api + ${slf4jVersion} - org.slf4j - slf4j-api - 1.4.2 - - dom4j dom4j 1.6.1 - + + + + + junit + junit + 3.8.1 + test + + + org.slf4j + jcl-over-slf4j + ${slf4jVersion} + test + + + org.slf4j + slf4j-log4j12 + ${slf4jVersion} + test + + + commons-logging + commons-logging + 99.0-does-not-exist + test + + + commons-logging + commons-logging-api + 99.0-does-not-exist + test + + + javassist + javassist + 3.9.0.GA + test + + + cglib + cglib + 2.2 + test + = + + + + + false + src/test/java + + **/*.xml + + + + true + src/test/resources + + + + + org.jboss.maven.plugins + maven-injection-plugin + 1.0.0 + + + compile + + bytecode + + + + + + + ${pom.version} + + + org.hibernate.cfg.annotations.Version + VERSION + > + + + + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-java + + enforce + + + + + [1.5,) + + + (2.0.7,) + + + + + + + + org.jboss.maven.plugins + maven-test-ext-plugin + 1.1.0 + + + + extend + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + org.apache.maven.plugins + maven-jar-plugin + + + false + + true + true + + + jcp.org + 1.0 + Java Persistence + hibernate.org + http://annotations.hibernate.org + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + maven-assembly-plugin + + + src/main/assembly/dist.xml + + + + + org.jboss.maven.plugins + maven-jdocbook-plugin + 2.2.0 + true + + + org.hibernate + hibernate-jdocbook-style + 2.0.0 + jdocbook-style + + + + master.xml + ${basedir}/src/main/docbook + en + + ${basedir}/src/main/docbook/en/= images + + + + pdf + classpath:/xslt/or= g/hibernate/jdocbook/xslt/pdf.xsl + hibernate_annotations_refer= ence.pdf + + + html_single + classpath:/xslt/or= g/hibernate/jdocbook/xslt/xhtml-single.xsl + + index.html + + + html + classpath:/xslt/or= g/hibernate/jdocbook/xslt/xhtml.xsl + + index.html + + + + true + saxon + + + 1.72.0 + - + + + + + make-doc + package + + resources + generate + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + http://java.sun.com/j2se/1.5.0/docs/api/ + http://java.sun.com/javaee/5/docs/api/ + + ${basedir}/src/main/javadoc/jdstyle.css + + + + make-doc + package + + javadoc + + + + + + + + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.4.3 + + = + + org.apache.maven.plugins + maven-jxr-plugin + 2.1 + + + org.apache.maven.plugins + maven-pmd-plugin + 2.2 + + true + 100 + 1.5 + + + + org.codehaus.mojo + taglist-maven-plugin + 2.1 + + + @FIXME + @fixme + FIXME + fixme + @TODO + @todo + TODO + todo + + + + + + org.codehaus.mojo + javancss-maven-plugin + 2.0-beta-2 + + + org.codehaus.mojo + findbugs-maven-plugin + 1.1.1 + + org.hibernate.* + + + + + + + + + + hsqldb + + true + + + + hsqldb + hsqldb + 1.8.0.2 + + + + org.hibernate.dialect.HSQLDialect + org.hsqldb.jdbcDriver + jdbc:hsqldb:target/test/db/hsqldb/hibernate + sa + + + + + + + + h2 + + + org.h2database + h2database + 1.0.20061217 + + + + org.hibernate.dialect.H2Dialect + org.h2.Driver + jdbc:h2:mem:target/test/db/h2/hibernate + sa + + + + + + + + + + mysql5 + + + mysql + mysql-connector-java + 5.0.5 + + + + org.hibernate.dialect.MySQL5InnoDBDialect + com.mysql.jdbc.Driver + jdbc:mysql://vmg08.mw.lab.eng.bos.redhat.com/hibbr330 + hibbr330 + hibbr330 + + + + + + + postgresql823 + + + postgresql + postgresql + 8.2-504 + jdbc3 + + + + org.hibernate.dialect.PostgreSQLDialect + org.postgresql.Driver + jdbc:postgresql://dev01.qa.atl.jboss.com:5432:hibbr330 + hibbr330 + hibbr330 + + + + + + + + + db2v82 + + + com.ibm + db2jcc + 3.1.57 + + + com.ibm + db2jcc_license_cu + 3.1.57 + + + + org.hibernate.dialect.DB2Dialect + com.ibm.db2.jcc.DB2Driver + jdbc:db2://dev32.qa.atl.jboss.com:50000/jbossqa + hibbr330 + hibbr330 + + + + + + + db2v91 + + + com.ibm + db2jcc + 3.1.57 + + + com.ibm + db2jcc_license_cu + 3.1.57 + + + + org.hibernate.dialect.DB2Dialect + com.ibm.db2.jcc.DB2Driver + jdbc:db2://dev67.qa.atl.jboss.com:50000/jbossqa + hibbr330 + hibbr330 + + + + + + + oracle9i + + + com.oracle + ojdbc14 + + 10.0.2.0 + + + + org.hibernate.dialect.Oracle9iDialect + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa + hibbr330 + hibbr330 + + + + + + + oracle10g + + + com.oracle + ojdbc14 + + 10.0.2.0 + + + + org.hibernate.dialect.Oracle10gDialect + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@dev01.qa.atl.jboss.com:1521:qadb01 + hibbr330 + hibbr330 + + + + + + + sybase15 + + + com.sybase + jconnect + 6.0.5 + + + + org.hibernate.dialect.SybaseASE15Dialect + com.sybase.jdbc3.jdbc.SybDriver + jdbc:sybase:Tds:dev77.qa.atl2.redhat.com:5000/hibbr330 + hibbr330 + hibbr330 + + + + + + + mssql2005 + + + com.microsoft.sqlserver + msjdbc + 1.1 + + + + org.hibernate.dialect.SQLServerDialect + com.microsoft.sqlserver.jdbc.SQLServerDriver + jdbc:sqlserver://dev30.qa.atl.jboss.com:3918 + hibbr330 + hibbr330 + 4096 + + + + + + 1.5.8 + \ No newline at end of file --===============5297174044035709712==-- From hibernate-commits at lists.jboss.org Tue Nov 24 15:05:26 2009 Content-Type: multipart/mixed; boundary="===============1588997042094778541==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18044 - annotations/branches/v3_4_0_GA_CP/src. Date: Tue, 24 Nov 2009 15:05:25 -0500 Message-ID: <200911242005.nAOK5Pd0021479@svn01.web.mwc.hst.phx2.redhat.com> --===============1588997042094778541== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-24 15:05:25 -0500 (Tue, 24 Nov 2009) New Revision: 18044 Removed: annotations/branches/v3_4_0_GA_CP/src/filters/ Log: JBPAPP-3150 change the build tool of Hibernate Annotations(eap 5 cp branch) --===============1588997042094778541==-- From hibernate-commits at lists.jboss.org Tue Nov 24 15:21:08 2009 Content-Type: multipart/mixed; boundary="===============1182405276502404732==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18045 - in annotations/branches/v3_4_0_GA_CP/src: main and 20 other directories. Date: Tue, 24 Nov 2009 15:21:07 -0500 Message-ID: <200911242021.nAOKL7fd024633@svn01.web.mwc.hst.phx2.redhat.com> --===============1182405276502404732== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-24 15:21:05 -0500 (Tue, 24 Nov 2009) New Revision: 18045 Added: annotations/branches/v3_4_0_GA_CP/src/main/ annotations/branches/v3_4_0_GA_CP/src/main/assembly/ annotations/branches/v3_4_0_GA_CP/src/main/assembly/dist.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/images/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/images/hibernate_l= ogo_a.png annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/master.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/additional= modules.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/entity.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/setup.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/xml-overri= ding.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/fopdf.xsl annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html.css annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html.xsl annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html_chunk.= xsl annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/images/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/images/hibernate_l= ogo_a.png annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/master.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/entity.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/lucene.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/setup.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/validator.= xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/xml-overri= ding.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/fopdf.xsl annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html.css annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html.xsl annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html_chunk.= xsl annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simhei.ttf annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simhei.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simsun.ttc annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simsun.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/userconfig.= xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/images/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/images/hibernat= e_logo_a.png annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/master.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/entity.= xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/lucene.= xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/setup.x= ml annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/validat= or.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/xml-ove= rriding.xml annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/fopdf.xsl annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html.css annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html.xsl annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html_chu= nk.xsl annotations/branches/v3_4_0_GA_CP/src/main/java/ annotations/branches/v3_4_0_GA_CP/src/main/javadoc/ annotations/branches/v3_4_0_GA_CP/src/main/javadoc/jdstyle.css annotations/branches/v3_4_0_GA_CP/src/main/javadoc/package.html annotations/branches/v3_4_0_GA_CP/src/main/resources/ annotations/branches/v3_4_0_GA_CP/src/main/resources/org/ annotations/branches/v3_4_0_GA_CP/src/main/resources/org/hibernate/ annotations/branches/v3_4_0_GA_CP/src/main/resources/org/hibernate/ejb/ annotations/branches/v3_4_0_GA_CP/src/main/resources/org/hibernate/ejb/o= rm_1_0.xsd Log: JBPAPP-3150 change the build tool of Hibernate Annotations(eap 5 cp branch) Added: annotations/branches/v3_4_0_GA_CP/src/main/assembly/dist.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/assembly/dist.xml = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/assembly/dist.xml 2009-11-24= 20:21:05 UTC (rev 18045) @@ -0,0 +1,43 @@ + + + dist + + + zip + + + + + false + lib + runtime + + + + + + target + . + + *.jar + + + + target/site/apidocs + docs/api + + + target/docbook/publish/en + docs/manual/en + + + . + + true + + **/target/** + + + + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/images/hiberna= te_logo_a.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Property changes on: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/= images/hibernate_logo_a.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/master.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/master.xml = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/master.xml 2009-1= 1-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,77 @@ + + + + + +]> + + + Hibernate Annotations + + Reference Guide + + 3.4.0.GA + + + + + + + + + + + + Preface + + Hibernate, like all other object/relational mapping tools, requi= res + metadata that governs the transformation of data from one representati= on + to the other. In Hibernate 2.x mapping metadata is most of the time + declared in XML text files. Alternatively XDoclet can be used utilizing + Javadoc source code annotations together with a compile time preproces= sor. + + + The same kind of annotation support is now available in the stan= dard + JDK, although more powerful and with better tools support. IntelliJ ID= EA + and Eclipse for example, support auto-completion and syntax highlighti= ng + of JDK 5.0 annotations which are compiled into the bytecode and read at + runtime using reflection. No external XML files are needed. + + The EJB3 specification recognizes the interest and the success of + the transparent object/relational mapping paradigm. It standardizes the + basic APIs and the metadata needed for any object/relational persisten= ce + mechanism. Hibernate EntityManager implements the + programming interfaces and lifecycle rules as defined by the EJB3 + persistence specification and together with Hibernate + Annotations offers a complete (and standalone) EJB3 persist= ence + solution on top of the mature Hibernate core. You may use a combinatio= n of + all three together, annotations without EJB3 programming interfaces and + lifecycle, or even pure native Hibernate, depending on the business and + technical needs of your project. At all times you cann fall back to + Hibernate native APIs, or if required, even to native JDBC and SQL. + + This release of Hibernate Annotations is ba= sed + on the final release of the EJB 3.0 / JPA specification (aka JSR-220) and + supports all its features (including the optional ones). Hibernate + specific features and extensions are also available through + unstandardized, Hibernate specific annotations. While the Hibernate + feature coverage is high, some can not yet be expressed via annotation= s. + The eventual goal is to cover all of them. See the JIRA road map secti= on + for more informations. + + If you are moving from previous Hibernate Annotations versions, + please have a look at Java + Persistence migration guide. + + + &setup; + + &entity; + + &xml-overriding; + + &additionalmodules; + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/additi= onalmodules.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/additiona= lmodules.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/additiona= lmodules.xml 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,120 @@ + + + Additional modules + + Hibernate Annotations mainly focus on persistence metadata. The + project also have a nice integration with two Hibernate modules. + +
+ Hibernate Validator + +
+ Description + + Annotations are a very convenient and elegant way to specify + invariant constraints for a domain model. You can, for example, expr= ess + that a property should never be null, that the account balance shoul= d be + strictly positive, etc. These domain model constraints are declared = in + the bean itself by annotating its properties. A validator can then r= ead + them and check for constraint violations. The validation mechanism c= an + be executed in different layers in your application without having to + duplicate any of these rules (presentation layer, data access layer). + Following the DRY principle, Hibernate Validator has been designed f= or + that purpose. + + Hibernate Validator works at two levels. First, it is able to + check in-memory instances of a class for constraint violations. Seco= nd, + it can apply the constraints to the Hibernate metamodel and incorpor= ate + them into the generated database schema. + + Each constraint annotation is associated to a validator + implementation responsible for checking the constraint on the entity + instance. A validator can also (optionally) apply the constraint to = the + Hibernate metamodel, allowing Hibernate to generate DDL that express= es + the constraint. With the appropriate event listener, you can execute= the + checking operation on inserts and updates done by Hibernate. Hiberna= te + Validator is not limited to use with Hibernate. You can easily use it + anywhere in your application. + + When checking instances at runtime, Hibernate Validator returns + information about constraint violations in an array of + InvalidValue s. Among other information, the + InvalidValue contains an error description + message that can embed the parameter values bundle with the annotati= on + (eg. length limit), and message strings that may be externalized to a + ResourceBundle . +
+ +
+ Integration with Hibernate Annotations + + If Hibernate Validator + (hibernate-validator.jar) is available in the + classpath, Hibernate Annotations will integrate in two ways: + + + + Constraints will be applied to the Data Definition Languag= e. + In other words, the database schema will reflect the constraints + (provided that you use the hbm2ddl tool). + + + + Before an entity change is applied to the database (insert= or + update), the entity is validated. Validation errors, if any, wil= l be + carried over through an + InvalidStateException. + + + + For entities free of validation rules, the runtime performance + cost is null. + + To disable constraint propagation to DDL, set up + hibernate.validator.apply_to_ddl to false in the + configuration file. Such a need is very uncommon and not + recommended. + + To disable pre-entity change validation, set up + hibernate.validator.autoregister_listeners to fal= se + in the configuration file. Such a need is very uncommon and not + recommended. + + Check the Hibernate Validator reference documentation for more + information. +
+
+ +
+ Hibernate Search + +
+ Description + + Full text search engines like Apache + Lucene are a very powerful technology to bring free + text/efficient queries to applications. If suffers several mismatches + when dealing with a object domain model (keeping the index up to dat= e, + mismatch between the index structure and the domain model, querying + mismatch...) Hibernate Search indexes your domain model thanks to a = few + annotations, takes care of the database / index synchronization and + brings you back regular managed objects from free text queries. + Hibernate Search is using Ap= ache + Lucene under the cover. +
+ +
+ Integration with Hibernate Annotations + + Hibernate Search integrates with Hibernate Annotations + transparently provided that hibernate-search.jar is present in the + classpath. If you do not wish to automatically register Hibernate Se= arch + event listeners, you can set + hibernate.search.autoregister_listeners to false. + Such a need is very uncommon and not recommended. + + Check the Hibernate Search reference documentation for more + information. +
+
+
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/entity= .xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/entity.xm= l (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/entity.xm= l 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,3814 @@ + + + Entity Beans + + + Intro + + This section covers EJB 3.0 (aka Java Persistence) entity + annotations and Hibernate-specific extensions. + + + + Mapping with EJB3/JPA Annotations + + EJB3 entities are plain POJOs. Actually they represent the exact + same concept as the Hibernate persistent entities. Their mappings are + defined through JDK 5.0 annotations (an XML descriptor syntax for + overriding is defined in the EJB3 specification). Annotations can be s= plit + in two categories, the logical mapping annotations (allowing you to + describe the object model, the class associations, etc.) and the physi= cal + mapping annotations (describing the physical schema, tables, columns, + indexes, etc). We will mix annotations from both categories in the + following code examples. + + EJB3 annotations are in the javax.persistence.* + package. Most JDK 5 compliant IDE (like Eclipse, IntelliJ IDEA and + Netbeans) can autocomplete annotation interfaces and attributes for you + (even without a specific "EJB3" module, since EJB3 annotations are pla= in + JDK 5 annotations). + + For more and runnable concrete examples read the JBoss EJB 3.0 + tutorial or review the Hibernate Annotations test suite. Most of the u= nit + tests have been designed to represent a concrete example and be a + inspiration source. + + + Declaring an entity bean + + Every bound persistent POJO class is an entity bean and is + declared using the @Entity annotation (at the cla= ss + level): + + +(a)Entity +public class Flight implements Serializable { + Long id; + + @Id + public Long getId() { return id; } + + public void setId(Long id) { this.id =3D id; } +} + + + @Entity declares the class as an entity bean + (i.e. a persistent POJO class), @Id declares the + identifier property of this entity bean. The other mapping declarati= ons + are implicit. This configuration by exception concept is central to = the + new EJB3 specification and a major improvement. The class Flight is + mapped to the Flight table, using the column id as its primary key + column. + + Depending on whether you annotate fields or methods, the access + type used by Hibernate will be field or + property. The EJB3 spec requires that you declare + annotations on the element type that will be accessed, i.e. the gett= er + method if you use property access, the field if y= ou + use field access. Mixing EJB3 annotations in both + fields and methods should be avoided. Hibernate will guess the access + type from the position of @Id or + @EmbeddedId. + + + Defining the table + + @Table is set at the class level; it allo= ws + you to define the table, catalog, and schema names for your entity + bean mapping. If no @Table is defined the defau= lt + values are used: the unqualified class name of the entity. + + +(a)Entity +(a)Table(name=3D"tbl_sky") +public class Sky implements Serializable { +... + + + The @Table element also contains a + schema and a catalog attribu= tes, + if they need to be defined. You can also define unique constraints= to + the table using the @UniqueConstraint annotatio= n in + conjunction with @Table (for a unique constraint + bound to a single column, refer to @Column). + + @Table(name=3D"tbl_sky", + uniqueConstraints =3D {@UniqueConstraint(colum= nNames=3D{"month", "day"})} +) + + A unique constraint is applied to the tuple month, day. Note + that the columnNames array refers to the logical + column names. + + The logical column name is defined by the Hibernate + NamingStrategy implementation. The default EJB3 naming strategy use + the physical column name as the logical column name. Note that this + may be different than the property name (if the column name is + explicit). Unless you override the NamingStrategy, you shouldn't w= orry + about that. + + + + Versioning for optimistic locking + + You can add optimistic locking capability to an entity bean + using the @Version annotation: + + +(a)Entity +public class Flight implements Serializable { +... + @Version + @Column(name=3D"OPTLOCK") + public Integer getVersion() { ... } +} + + The version property will be mapped to the + OPTLOCK column, and the entity manager will use= it + to detect conflicting updates (preventing lost updates you might + otherwise see with the last-commit-wins strategy). + + The version column may be a numeric (the recommended solutio= n) + or a timestamp as per the EJB3 spec. Hibernate support any kind of + type provided that you define and implement the appropriate + UserVersionType. + + The application must not alter the version number set up by + Hibernate in any way. To artificially increase the version number, + check in Hibernate Entity Manager's reference documentation + LockMode.WRITE + + + + + Mapping simple properties + + + Declaring basic property mappings + + Every non static non transient property (field or method) of= an + entity bean is considered persistent, unless you annotate it as + @Transient. Not having an annotation for your + property is equivalent to the appropriate @Basic + annotation. The @Basic annotation allows you to + declare the fetching strategy for a property: + + public transient int counter; //transient property + +private String firstname; //persistent property + +(a)Transient +String getLengthInMeter() { ... } //transient property + +String getName() {... } // persistent property + +(a)Basic +int getLength() { ... } // persistent property + +(a)Basic(fetch =3D FetchType.LAZY) +String getDetailedComment() { ... } // persistent property + +(a)Temporal(TemporalType.TIME) +java.util.Date getDepartureTime() { ... } // persistent property = + +(a)Enumerated(EnumType.STRING) +Starred getNote() { ... } //enum persisted as String in database + + counter, a transient field, and + lengthInMeter, a method annotated as + @Transient, and will be ignored by the entity + manager. name, length, and + firstname properties are mapped persistent and + eagerly fetched (the default for simple properties). The + detailedComment property value will be lazily + fetched from the database once a lazy property of the entity is + accessed for the first time. Usually you don't need to lazy simple + properties (not to be confused with lazy association fetching). + + + To enable property level lazy fetching, your classes have = to + be instrumented: bytecode is added to the original one to enable + such feature, please refer to the Hibernate reference documentat= ion. + If your classes are not instrumented, property level lazy loadin= g is + silently ignored. + + + The recommended alternative is to use the projection capabil= ity + of EJB-QL or Criteria queries. + + EJB3 support property mapping of all basic types supported by + Hibernate (all basic Java types , their respective wrappers and + serializable classes). Hibernate Annotations support out of the box + Enum type mapping either into a ordinal column (saving the enum + ordinal) or a string based column (saving the enum string + representation): the persistence representation, defaulted to ordi= nal, + can be overriden through the @Enumerated annota= tion + as shown in the note property example. + + In core Java APIs, the temporal precision is not defined. Wh= en + dealing with temporal data you might want to describe the expected + precision in database. Temporal data can have DATE, + TIME, or TIMESTAMP precision= (ie + the actual date, only the time, or both). Use the + @Temporal annotation to fine tune that. + + @Lob indicates that the property should be + persisted in a Blob or a Clob depending on the property type: + java.sql.Clob, + Character[], char[] = and + java.lang.String will be persisted in a Clo= b. + java.sql.Blob, Byte[], + byte[] and serializable type will be persis= ted + in a Blob. + + +(a)Lob +public String getFullText() { + return fullText; +} + +(a)Lob = +public byte[] getFullCode() { + return fullCode; +} + + + If the property type implements + java.io.Serializable and is not a basic typ= e, + and if the property is not annotated with @Lob, + then the Hibernate serializable type is + used. + + + + Declaring column attributes + + The column(s) used for a property mapping can be defined usi= ng + the @Column annotation. Use it to override defa= ult + values (see the EJB3 specification for more information on the + defaults). You can use this annotation at the property level for + properties that are: + + + + not annotated at all + + + + annotated with @Basic + + + + annotated with @Version + + + + annotated with @Lob + + + + annotated with @Temporal + + + + annotated with + @org.hibernate.annotations.CollectionOfElements + (for Hibernate only) + + + + +(a)Entity +public class Flight implements Serializable { +... +(a)Column(updatable =3D false, name =3D "flight_name", nullable =3D false,= length=3D50) +public String getName() { ... } + + + The name property is mapped to the + flight_name column, which is not nullable, has a + length of 50 and is not updatable (making the property + immutable). + + This annotation can be applied to regular properties as well= as + @Id or @Version + properties. + + + + + + + + + + + + + + + + + + + + + + + + + @Column( + name=3D"columnName"; + boolean unique() default false; + boolean nullable() default true; + boolean insertable() default true; + boolean updatable() default true; + String columnDefinition() default ""; + String table() default ""; + int length() default 255; + int precision() default 0; // decimal precision + int scale() default 0; // decimal scale + + + + name (optional): the column name + (default to the property name) + + + + unique (optional): set a unique + constraint on this column or not (default false) + + + + nullable (optional): set the column= as + nullable (default true). + + + + insertable (optional): whether or n= ot + the column will be part of the insert statement (default + true) + + + + updatable (optional): whether or not + the column will be part of the update statement (default + true) + + + + columnDefinition (optional): overri= de + the sql DDL fragment for this particular column (non + portable) + + + + table (optional): define the target= ed + table (default primary table) + + + + length (optional= ): + column length (default 255) + + + + precision + (optional): column decimal precision (default 0) + + + + scale (optional): + column decimal scale if useful (default 0) + + + + + + + Embedded objects (aka components) + + It is possible to declare an embedded component inside an en= tity + and even override its column mapping. Component classes have to be + annotated at the class level with the @Embeddable + annotation. It is possible to override the column mapping of an + embedded object for a particular entity using the + @Embedded and @AttributeOverride + annotation in the associated property: + + +(a)Entity +public class Person implements Serializable { + + // Persistent component using defaults + Address homeAddress; + + @Embedded + @AttributeOverrides( { + @AttributeOverride(name=3D"iso2", column =3D @Column(name=3D"b= ornIso2") ), + @AttributeOverride(name=3D"name", column =3D @Column(name=3D"b= ornCountryName") ) + } ) + Country bornIn; + ... +} + + + +(a)Embeddable +public class Address implements Serializable { + String city; + Country nationality; //no overriding here +} + + + +(a)Embeddable +public class Country implements Serializable { + private String iso2; + @Column(name=3D"countryName") private String name; + + public String getIso2() { return iso2; } + public void setIso2(String iso2) { this.iso2 =3D iso2; } + + = + public String getName() { return name; } + public void setName(String name) { this.name =3D name; } + ... +} + + + A embeddable object inherit the access type of its owning en= tity + (note that you can override that using the Hibernate specific + @AccessType annotations (see ). + + The Person entity bean has two component + properties, homeAddress and + bornIn. homeAddress property= has + not been annotated, but Hibernate will guess that it is a persiste= nt + component by looking for the @Embeddable annota= tion + in the Address class. We also override the mapping of a column name + (to bornCountryName) with the + @Embedded and @AttributeOverride + annotations for each mapped attribute of + Country. As you can see, Country + is also a nested component of Address, + again using auto-detection by Hibernate and EJB3 defaults. Overrid= ing + columns of embedded objects of embedded objects is currently not + supported in the EJB3 spec, however, Hibernate Annotations support= s it + through dotted expressions. + + @Embedded + @AttributeOverrides( { + @AttributeOverride(name=3D"city", column =3D @Column(name=3D"f= ld_city") ), + @AttributeOverride(name=3D"nationality= .iso2", column =3D @Column(name=3D"nat_Iso2") ), + @AttributeOverride(name=3D"nationality= .name", column =3D @Column(name=3D"nat_CountryName") ) + //nationality columns in homeAddress are overridden + } ) + Address homeAddress;Hibernate Annotations supports one + more feature that is not explicitly supported by the EJB3 + specification. You can annotate a embedded object with the + @MappedSuperclass annotation to make the superc= lass + properties persistent (see @MappedSuperclass for + more informations). + + While not supported by the EJB3 specification, Hibernate + Annotations allows you to use association annotations in an embedd= able + object (ie @*ToOne nor + @*ToMany). To override the association columns = you + can use @AssociationOverride. + + If you want to have the same embeddable object type twice in= the + same entity, the column name defaulting will not work: at least on= e of + the columns will have to be explicit. Hibernate goes beyond the EJ= B3 + spec and allows you to enhance the defaulting mechanism through the + NamingStrategy. + DefaultComponentSafeNamingStrategy is a sma= ll + improvement over the default EJB3NamingStrategy that allows embedd= ed + objects to be defaulted even if used twice in the same entity. + + + + Non-annotated property defaults + + If a property is not annotated, the following rules + apply: + + + + If the property is of a single type, it is mapped as @Basic = + + + + Otherwise, if the type of the property is annotated as @Embed= dable, it is mapped as @Embedded = + + + + Otherwise, if the type of the property is Serializable, it is= mapped as @Basic in a column holding the object in its serialized version = + + + + Otherwise, if the type of the property is java.sql.Clob or ja= va.sql.Blob, it is mapped as @Lob with the appropriate LobType = + + + + + + + Mapping identifier properties + + The @Id annotation lets you define which + property is the identifier of your entity bean. This property can be= set + by the application itself or be generated by Hibernate (preferred). = You + can define the identifier generation strategy thanks to the + @GeneratedValue annotation: + + + + AUTO - either identity column, sequence or table depending on t= he underlying DB = + + + + TABLE - table holding the id = + + + + IDENTITY - identity column = + + + + SEQUENCE - sequence = + + + + Hibernate provides more id generators than the basic EJB3 ones. + Check for more informations. + + The following example shows a sequence generator using the + SEQ_STORE configuration (see below) + + +(a)Id @GeneratedValue(strategy=3DGenerationType.SEQUENCE, generator=3D"SEQ= _STORE") +public Integer getId() { ... } + + + The next example uses the identity generator: + + +(a)Id @GeneratedValue(strategy=3DGenerationType.IDENTITY) +public Long getId() { ... } + + + The AUTO generator is the preferred type for + portable applications (across several DB vendors). The identifier + generation configuration can be shared for several + @Id mappings with the generator attribute. There = are + several configurations available through + @SequenceGenerator and + @TableGenerator. The scope of a generator can be = the + application or the class. Class-defined generators are not visible + outside the class and can override application level generators. + Application level generators are defined at XML level (see ): + + <table-generator name=3D"EMP_GEN" + table=3D"GENERATOR_TABLE" + pk-column-name=3D"key" + value-column-name=3D"hi" + pk-column-value=3D"EMP" + allocation-size=3D"20"/> + +//and the annotation equivalent + +(a)javax.persistence.TableGenerator( + name=3D"EMP_GEN", + table=3D"GENERATOR_TABLE", + pkColumnName =3D "key", + valueColumnName =3D "hi" + pkColumnValue=3D"EMP", + allocationSize=3D20 +) + +<sequence-generator name=3D"SEQ_GEN" = + sequence-name=3D"my_sequence" + allocation-size=3D"20"/> + +//and the annotation equivalent + +(a)javax.persistence.SequenceGenerator( + name=3D"SEQ_GEN", + sequenceName=3D"my_sequence", + allocationSize=3D20 +) + + + If JPA XML (like META-INF/orm.xml) is use= d to + define thegenerators, EMP_GEN and + SEQ_GEN are application level generators. + EMP_GEN defines a table based id generator using = the + hilo algorithm with a max_lo of 20. The hi value = is + kept in a table "GENERATOR_TABLE". + The information is kept in a row where pkColumnName + "key" is equals to pkColumnValue + "EMP" and column valueColumnName + "hi" contains the the next high value used. + + SEQ_GEN defines a sequence generator using a + sequence named my_sequence. The allocation size u= sed + for this sequence based hilo algorithm is 20. Note that this version= of + Hibernate Annotations does not handle initialValue in + the sequence generator. The default allocation size is 50, so if you + want to use a sequence and pickup the value each time, you must set = the + allocation size to 1. + + + Package level definition is no longer supported by the EJB 3= .0 + specification. However, you can use the + @GenericGenerator at the package level (see ). + + + The next example shows the definition of a sequence generator = in a + class scope: + + +(a)Entity +(a)javax.persistence.SequenceGenerator( + name=3D"SEQ_STORE", + sequenceName=3D"my_sequence" +) +public class Store implements Serializable { + private Long id; + + @Id @GeneratedValue(strategy=3DGenerationType.SEQUENCE, generator=3D"S= EQ_STORE") + public Long getId() { return id; } +} + + + This class will use a sequence named my_sequence and the SEQ_S= TORE + generator is not visible in other classes. Note that you can check t= he + Hibernate Annotations tests in the + org.hibernate.test.annotations.id package for more + examples. + + You can define a composite primary key through several + syntaxes: + + + + annotate the component property as @Id and make the component c= lass @Embeddable = + + + + annotate the component property as @EmbeddedId = + + + + annotate the class as @IdClass and annotate each property of th= e entity involved in the primary key with @Id = + + + + While quite common to the EJB2 developer, + @IdClass is likely new for Hibernate users. The + composite primary key class corresponds to multiple fields or proper= ties + of the entity class, and the names of primary key fields or properti= es + in the primary key class and those of the entity class must match and + their types must be the same. Let's look at an example: + + @Entity +@IdClass(FootballerPk.class) +public class Footballer { + //part of the id key + @Id public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + //part of the id key + @Id public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + public String getClub() { + return club; + } + + public void setClub(String club) { + this.club =3D club; + } + + //appropriate equals() and hashCode() implementation +} + +(a)Embeddable +public class FootballerPk implements Serializable { + //same name and type as in Footballer + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + //same name and type as in Footballer + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + //appropriate equals() and hashCode() implementation +} + + + As you may have seen, @IdClass points to the + corresponding primary key class. + + While not supported by the EJB3 specification, Hibernate allows + you to define associations inside a composite identifier. Simply use= the + regular annotations for that + + @Entity +(a)AssociationOverride( name=3D"id.channel", joinColumns =3D @JoinColumn(n= ame=3D"chan_id") ) +public class TvMagazin { + @EmbeddedId public TvMagazinPk id; + @Temporal(TemporalType.TIME) Date time; +} + +(a)Embeddable +public class TvMagazinPk implements Serializable { + @ManyToOne + public Channel channel; + public String name; + @ManyToOne + public Presenter presenter; +} + + + + + Mapping inheritance + + EJB3 supports the three types of inheritance: + + + + Table per Class Strategy: the <union-class> element in Hi= bernate = + + + + Single Table per Class Hierarchy Strategy: the <subclass>= element in Hibernate = + + + + Joined Subclass Strategy: the <joined-subclass> element i= n Hibernate = + + + + The chosen strategy is declared at the class level of the top + level entity in the hierarchy using the @Inheritance + annotation. + + + Annotating interfaces is currently not supported. + + + + Table per class + + This strategy has many drawbacks (esp. with polymorphic quer= ies + and associations) explained in the EJB3 spec, the Hibernate refere= nce + documentation, Hibernate in Action, and many other places. Hiberna= te + work around most of them implementing this strategy using SQL + UNION queries. It is commonly used for the top level of = an + inheritance hierarchy: + + +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.TABLE_PER_CLASS) +public class Flight implements Serializable { + + + This strategy support one to many associations provided that + they are bidirectional. This strategy does not support the + IDENTITY generator strategy: the id has to be + shared across several tables. Consequently, when using this strate= gy, + you should not use AUTO nor + IDENTITY. + + + + Single table per class hierarchy + + All properties of all super- and subclasses are mapped into = the + same table, instances are distinguished by a special discriminator + column: + + +(a)Entity +(a)Inheritance(strategy=3DInheritanceType.SINGLE_TABLE) +(a)DiscriminatorColumn( + name=3D"planetype", + discriminatorType=3DDiscriminatorType.STRING +) +(a)DiscriminatorValue("Plane") +public class Plane { ... } + +(a)Entity +(a)DiscriminatorValue("A320") +public class A320 extends Plane { ... } + + + Plane is the superclass, it defines t= he + inheritance strategy InheritanceType.SINGLE_TABLE. + It also defines the discriminator column through the + @DiscriminatorColumn annotation, a discriminator + column can also define the discriminator type. Finally, the + @DiscriminatorValue 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 DTYPE. The default + discriminator value is the entity name (as defined in + @Entity.name) for DiscriminatorType.STRING. + A320 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 are implicit. + + @Inheritance and + @DiscriminatorColumn should only be defined at = the + top of the entity hierarchy. + + + + Joined subclasses + + The @PrimaryKeyJoinColumn and + @PrimaryKeyJoinColumns annotations define the + primary key(s) of the joined subclass table: + + +(a)Entity +(a)Inheritance(strategy=3DInheritanceType.JOINED) +public class Boat implements Serializable { ... } + +(a)Entity +public class Ferry extends Boat { ... } + +(a)Entity +(a)PrimaryKeyJoinColumn(name=3D"BOAT_ID") +public class AmericaCupClass extends Boat { ... } + + + All of the above entities use the JOINED + strategy, the Ferry table is joined with the + Boat table using the same primary key names. The + AmericaCupClass table is joined with + Boat using the join condition Boat.id =3D + AmericaCupClass.BOAT_ID. + + + + Inherit properties from superclasses + + This is sometimes useful to share common properties through a + technical or a business superclass without including it as a regul= ar + mapped entity (ie no specific table for this entity). For that pur= pose + you can map them as @MappedSuperclass. + + @MappedSuperclass +public class BaseEntity { + @Basic + @Temporal(TemporalType.TIMESTAMP) + public Date getLastUpdate() { ... } + public String getLastUpdater() { ... } + ... +} + +(a)Entity class Order extends BaseEntity { + @Id public Integer getId() { ... } + ... +} + + In database, this hierarchy will be represented as an + Order table having the id, + lastUpdate and lastUpdater + columns. The embedded superclass property mappings are copied into + their entity subclasses. Remember that the embeddable superclass is + not the root of the hierarchy though. + + + Properties from superclasses not mapped as + @MappedSuperclass are ignored. + + + + The access type (field or methods), is inherited from the = root + entity, unless you use the Hibernate annotation + @AccessType + + + + The same notion can be applied to + @Embeddable objects to persist properties from + their superclasses. You also need to use + @MappedSuperclass to do that (this should not= be + considered as a standard EJB3 feature though) + + + + It is allowed to mark a class as + @MappedSuperclass in the middle of the mapped + inheritance hierarchy. + + + + Any class in the hierarchy non annotated with + @MappedSuperclass nor @Entity + will be ignored. + + + You can override columns defined in entity superclasses at t= he + root entity level using the @AttributeOverride + annotation. + + @MappedSuperclass +public class FlyingObject implements Serializable { + + public int getAltitude() { + return altitude; + } + + @Transient + public int getMetricAltitude() { + return metricAltitude; + } + + @ManyToOne + public PropulsionType getPropulsion() { + return metricAltitude; + } + ... +} + +(a)Entity +(a)AttributeOverride( name=3D"altitude", column =3D @Column(name=3D"fld_al= titude") ) +(a)AssociationOverride( name=3D"propulsion", joinColumns =3D @JoinColumn(n= ame=3D"fld_propulsion_fk") ) +public class Plane extends FlyingObject { + ... +} + + The altitude property will be persisted i= n an + fld_altitude column of table + Plane and the propulsion association will be + materialized in a fld_propulsion_fk foreign key + column. + + You can define @AttributeOverride(s) and + @AssociationOverride(s) on + @Entity classes, + @MappedSuperclass classes and properties pointi= ng + to an @Embeddable object. + + + + + Mapping entity bean associations/relationships + + + One-to-one + + You can associate entity beans through a one-to-one relation= ship + using @OneToOne. There are three cases for + one-to-one associations: either the associated entities share the = same + primary keys values, a foreign key is held by one of the entities + (note that this FK column in the database should be constrained un= ique + to simulate one-to-one multiplicity), or a association table is us= ed + to store the link between the 2 entities (a unique constraint has = to + be defined on each fk to ensure the one to one multiplicity) + + First, we map a real one-to-one association using shared pri= mary + keys: + + +(a)Entity +public class Body { + @Id + public Long getId() { return id; } + + @OneToOne(cascade =3D CascadeType.ALL) + @PrimaryKeyJoinColumn + public Heart getHeart() { + return heart; + } + ... +} + + + +(a)Entity +public class Heart { + @Id + public Long getId() { ...} +} + + + The one to one is marked as true by using the + @PrimaryKeyJoinColumn annotation. + + In the following example, the associated entities are linked + through a foreign key column: + + +(a)Entity +public class Customer implements Serializable { + @OneToOne(cascade =3D CascadeType.ALL) + @JoinColumn(name=3D"passport_fk") + public Passport getPassport() { + ... + } + +(a)Entity +public class Passport implements Serializable { + @OneToOne(mappedBy =3D "passport") + public Customer getOwner() { + ... +} + + + A Customer is linked to a + Passport, with a foreign key column named + passport_fk in the Customer + table. The join column is declared with the + @JoinColumn annotation which looks like the + @Column annotation. It has one more parameters + named referencedColumnName. This parameter decl= ares + the column in the targeted entity that will be used to the join. N= ote + that when using + referencedColumnName to a non + primary key column, the associated class has to be + Serializable. Also note that the + referencedColumnName to a non + primary key column has to be mapped to a property having a single + column (other cases might not work). + + The association may be bidirectional. In a bidirectional + relationship, one of the sides (and only one) has to be the owner:= the + owner is responsible for the association column(s) update. To decl= are + a side as not responsible for the relationshi= p, + the attribute mappedBy is used. + mappedBy refers to the property name of the + association on the owner side. In our case, this is + passport. As you can see, you don't have to (mu= st + not) declare the join column since it has already been declared on= the + owners side. + + If no @JoinColumn is declared on the owner + side, the defaults apply. A join column(s) will be created in the + owner table and its name will be the concatenation of the name of = the + relationship in the owner side, _ (underscore), a= nd + the name of the primary key column(s) in the owned side. In this + example passport_id because the property name is + passport and the column id of Passport + is id. + + The third possibility (using an association table) is very + exotic. + + +(a)Entity +public class Customer implements Serializable { + @OneToOne(cascade =3D CascadeType.ALL) + @JoinTable(name =3D "CustomerPassports", + joinColumns =3D @JoinColumn(name=3D"customer_fk"), + inverseJoinColumns =3D @JoinColumn(name=3D"passport_fk") + ) + public Passport getPassport() { + ... + } + +(a)Entity +public class Passport implements Serializable { + @OneToOne(mappedBy =3D "passport") + public Customer getOwner() { + ... +} + + + A Customer is linked to a + Passport through a association table named + CustomerPassports ; this association table has a + foreign key column named passport_fk pointing to + the Passport table (materialized by the + inverseJoinColumn, and a foreign key column nam= ed + customer_fk pointing to the + Customer table materialized by the + joinColumns attribute. + + You must declare the join table name and the join columns + explicitly in such a mapping. + + + + Many-to-one + + Many-to-one associations are declared at the property level = with + the annotation @ManyToOne: + + +(a)Entity() +public class Flight implements Serializable { + @ManyToOne( cascade =3D {CascadeTyp= e.PERSIST, CascadeType.MERGE} ) + @JoinColumn(name=3D"COMP_ID") + public Company getCompany() { + return company; + } + ... +} + + + The @JoinColumn attribute is optional, the + default value(s) is like in one to one, the concatenation of the n= ame + of the relationship in the owner side, _ + (underscore), and the name of the primary key column in the owned + side. In this example company_id because the + property name is company and the column id of + Company is id. + + @ManyToOne has a parameter named + targetEntity 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. + + +(a)Entity() +public class Flight implements Serializable { + @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}, targetEntity=3DCompanyImpl.class ) + @JoinColumn(name=3D"COMP_ID") + public Company getCompany() { + return company; + } + ... +} + +public interface Company { + ... + + + You can alse map a many to one association through an + association table. This association table described by the + @JoinTable annotation will contains a foreign k= ey + referencing back the entity table (through + @JoinTable.joinColumns) and a a foreign key + referencing the target entity table (through + @JoinTable.inverseJoinColumns). + + +(a)Entity() +public class Flight implements Serializable { + @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE} ) + @JoinTable(name=3D"Flight_Company", + joinColumns =3D @JoinColumn(name=3D"FLIGHT_ID"), + inverseJoinColumns =3D @JoinColumn(name=3D"COMP_ID") + ) + public Company getCompany() { + return company; + } + ... +} + + + + + Collections + + + Overview + + You can map Collection, + List (ie ordered lists, not indexed lists), + Map and Set. The EJB3 + specification describes how to map an ordered list (ie a list + ordered at load time) using + @javax.persistence.OrderBy annotation: this + annotation takes into parameter a list of comma separated (target + entity) properties to order the collection by (eg firstname + asc, age desc), if the string is empty, the collection wi= ll + be ordered by id. For true indexed collections, please refer to = the + . EJB3 allows you to map Maps= using + as a key one of the target entity property using + @MapKey(name=3D"myProperty") (myProperty is a + property name in the target entity). When using + @MapKey (without property name), the target + entity primary key is used. The map key uses the same column as = the + property pointed out: there is no additional column defined to h= old + the map key, and it does make sense since the map key actually + represent a target property. Be aware that once loaded, the key = is + no longer kept in sync with the property, in other words, if you + change the property value, the key will not change automatically= in + your Java model (for true map support please refers to ). Many people confuse + <map> capabilities and + @MapKey ones. These are two different feature= s. + @MapKey still has some limitations, please ch= eck + the forum or the JIRA tracking system for more informations. + + Hibernate has several notions of collections. + + + + + Collections semantics + + + + + + + + + + + Semantic + + java representation + + annotations + + + + + + Bag semantic + + java.util.List, java.util.Collection + + @org.hibernate.annotations.CollectionOfElements or + @OneToMany or @ManyToMany + + + + Bag semantic with primary key (withtout the + limitations of Bag semantic) + + java.util.List, java.util.Collection + + (@org.hibernate.annotations.CollectionOfElements = or + @OneToMany or @ManyToMany) and @CollectionId + + + + List semantic + + java.util.List + + (@org.hibernate.annotations.CollectionOfElements = or + @OneToMany or @ManyToMany) and + @org.hibernate.annotations.IndexColumn + + + + Set semantic + + java.util.Set + + @org.hibernate.annotations.CollectionOfElements or + @OneToMany or @ManyToMany + + + + Map semantic + + java.util.Map + + (@org.hibernate.annotations.CollectionOfElements = or + @OneToMany or @ManyToMany) and (nothing or + @org.hibernate.annotations.MapKey/MapKeyManyToMany for t= rue + map support, OR @javax.persistence.MapKey + + + +
+ + So specifically, java.util.List collections without + @org.hibernate.annotations.IndexColumn are going to be considere= d as + bags. + + Collection of primitive, core type or embedded objects is = not + supported by the EJB3 specification. Hibernate Annotations allows + them however (see ). + + @Entity public class City { + @OneToMany(mappedBy=3D"city") + @OrderBy("streetName") + public List<Street> getStreets() { + return streets; + } +... +} + +(a)Entity public class Street { + public String getStreetName() { + return streetName; + } + + @ManyToOne + public City getCity() { + return city; + } + ... +} + + +(a)Entity +public class Software { + @OneToMany(mappedBy=3D"software") + @MapKey(name=3D"codeName") + public Map<String, Version> getVersions() { + return versions; + } +... +} + +(a)Entity +(a)Table(name=3D"tbl_version") +public class Version { + public String getCodeName() {...} + + @ManyToOne + public Software getSoftware() { ... } +... +} + + So City has a collection of + Streets that are ordered by + streetName (of Street) when + the collection is loaded. Software has a map = of + Versions which key is the + Version codeName. + + Unless the collection is a generic, you will have to define + targetEntity. This is a annotation attribute = that + take the target entity class as a value. +
+ + + One-to-many + + One-to-many associations are declared at the property level + with the annotation @OneToMany. One to many + associations may be bidirectional. + + + Bidirectional + + Since many to one are (almost) always the owner side of a + bidirectional relationship in the EJB3 spec, the one to many + association is annotated by @OneToMany( mappedBy=3D... + ) + + @Entity +public class Troop { + @OneToMany(mappedBy=3D"troop") + public Set<Soldier> getSoldiers() { + ... +} + +(a)Entity +public class Soldier { + @ManyToOne + @JoinColumn(name=3D"troop_fk") + public Troop getTroop() { + ... +} + + Troop has a bidirectional one to = many + relationship with Soldier through the + troop property. You don't have to (must not) + define any physical mapping in the mappedBy + side. + + To map a bidirectional one to many, with the one-to-many + side as the owning side, you have to remove the + mappedBy element and set the many to one + @JoinColumn as insertable and updatable to + false. This solution is obviously not optimized and will produ= ce + some additional UPDATE statements. + + @Entity +public class Troop { + @OneToMany + @JoinColumn(name=3D"troop_fk") //we need to duplicate the physical inf= ormation + public Set<Soldier> getSoldiers() { + ... +} + +(a)Entity +public class Soldier { + @ManyToOne + @JoinColumn(name=3D"troop_fk", insertable=3Dfalse, updatable=3Dfalse) + public Troop getTroop() { + ... +} + + + + Unidirectional + + A unidirectional one to many using a foreign key column = in + the owned entity is not that common and not really recommended= . We + strongly advise you to use a join table for this kind of + association (as explained in the next section). This kind of + association is described through a + @JoinColumn + + +(a)Entity +public class Customer implements Serializable { + @OneToMany(cascade=3DCascadeType.ALL, fetch=3DFetchType.EAGER) + @JoinColumn(name=3D"CUST_ID") + public Set<Ticket> getTickets() { + ... +} + +(a)Entity +public class Ticket implements Serializable { + ... //no bidir +} + + + Customer describes a unidirectional + relationship with Ticket using the join col= umn + CUST_ID. + + + + Unidirectional with join table + + A unidirectional one to many with join table is much + preferred. This association is described through an + @JoinTable. + + +(a)Entity +public class Trainer { + @OneToMany + @JoinTable( + name=3D"TrainedMonkeys", + joinColumns =3D @JoinColumn( name=3D"trainer_id"), + inverseJoinColumns =3D @JoinColumn( name=3D"monkey_id") + ) + public Set<Monkey> getTrainedMonkeys() { + ... +} + +(a)Entity +public class Monkey { + ... //no bidir +} + + + Trainer describes a unidirectional + relationship with Monkey using the join + table TrainedMonkeys, with a foreign key + trainer_id to Trainer + (joinColumns) and a foreign key + monkey_id to Monkey + (inversejoinColumns). + + + + Defaults + + Without describing any physical mapping, a unidirectional + one to many with join table is used. The table name is the + concatenation of the owner table name, _, and= the + other side table name. The foreign key name(s) referencing the + owner table is the concatenation of the owner table, + _, and the owner primary key column(s) name. = The + foreign key name(s) referencing the other side is the + concatenation of the owner property name, _, = and + the other side primary key column(s) name. A unique constraint= is + added to the foreign key referencing the other side table to + reflect the one to many. + + +(a)Entity +public class Trainer { + @OneToMany + public Set<Tiger> getTrainedTigers() { + ... +} + +(a)Entity +public class Tiger { + ... //no bidir +} + + + Trainer describes a unidirectional + relationship with Tiger using the join + table Trainer_Tiger, with a foreign key + trainer_id to Trainer (t= able + name, _, trainer id) and a foreign key + trainedTigers_id to Monkey + (property name, _, Tiger primary column). + + + + + Many-to-many + + + Definition + + A many-to-many association is defined logically using the + @ManyToMany annotation. You also have to + describe the association table and the join conditions using t= he + @JoinTable annotation. If the association is + bidirectional, one side has to be the owner and one side has t= o be + the inverse end (ie. it will be ignored when updating the + relationship values in the association table): + + +(a)Entity +public class Employer implements Serializable { + @ManyToMany( + targetEntity=3Dorg.hibernate.test.metadata.manytomany.Employee.cla= ss, + cascade=3D{CascadeType.PERSIST, CascadeType.MERGE} + ) + @JoinTable( + name=3D"EMPLOYER_EMPLOYEE", + joinColumns=3D@JoinColumn(name=3D"EMPER_ID"), + inverseJoinColumns=3D@JoinColumn(name=3D"EMPEE_ID") + ) + public Collection getEmployees() { + return employees; + } + ... +} + + + +(a)Entity +public class Employee implements Serializable { + @ManyToMany( + cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}, + mappedBy =3D "employees", + targetEntity =3D Employer.class + ) + public Collection getEmployers() { + return employers; + } +} + + + We've already shown the many declarations and the detail= ed + attributes for associations. We'll go deeper in the + @JoinTable description, it defines a + name, an array of join columns (an array in + annotation is defined using { A, B, C }), and an array of inve= rse + join columns. The latter ones are the columns of the associati= on + table which refer to the Employee prima= ry + key (the "other side"). + + As seen previously, the other side don't have to (must n= ot) + describe the physical mapping: a simple + mappedBy argument containing the owner side + property name bind the two. + + + + Default values + + As any other annotations, most values are guessed in a m= any + to many relationship. Without describing any physical mapping = in a + unidirectional many to many the following rules applied. The t= able + name is the concatenation of the owner table name, + _ and the other side table name. The foreign = key + name(s) referencing the owner table is the concatenation of the + owner table name, _ and the owner primary key + column(s). The foreign key name(s) referencing the other side = is + the concatenation of the owner property name, _, + and the other side primary key column(s). These are the same r= ules + used for a unidirectional one to many relationship. + + +(a)Entity +public class Store { + @ManyToMany(cascade =3D CascadeType.PERSIST) + public Set<City> getImplantedIn() { + ... + } +} + +(a)Entity +public class City { + ... //no bidirectional relationship +} + + + A Store_City is used as the join tabl= e. + The Store_id column is a foreign key to the + Store table. The + implantedIn_id column is a foreign key to t= he + City table. + + Without describing any physical mapping in a bidirection= al + many to many the following rules applied. The table name is the + concatenation of the owner table name, _ and = the + other side table name. The foreign key name(s) referencing the + owner table is the concatenation of the other side property na= me, + _, and the owner primary key column(s). The + foreign key name(s) referencing the other side is the + concatenation of the owner property name, _, = and + the other side primary key column(s). These are the same rules + used for a unidirectional one to many relationship. + + +(a)Entity +public class Store { + @ManyToMany(cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}) + public Set<Customer> getCustomers() { + ... + } +} + +(a)Entity +public class Customer { + @ManyToMany(mappedBy=3D"customers") + public Set<Store> getStores() { + ... + } +} + + + A Store_Customer is used as the join + table. The stores_id column is a foreign ke= y to + the Store table. The + customers_id column is a foreign key to the + Customer table. + + +
+ + + Transitive persistence with cascading + + You probably have noticed the cascade + attribute taking an array of CascadeType as= a + value. The cascade concept in EJB3 is very is similar to the + transitive persistence and cascading of operations in Hibernate, b= ut + with slightly different semantics and cascading types: + + + + CascadeType.PERSIST: cascades the persist (create) operation = to associated entities persist() is called or if the entity is managed = + + + + CascadeType.MERGE: cascades the merge operation to associated= entities if merge() is called or if the entity is managed = + + + + CascadeType.REMOVE: cascades the remove operation to associat= ed entities if delete() is called = + + + + CascadeType.REFRESH: cascades the refresh operation to associ= ated entities if refresh() is called = + + + + CascadeType.ALL: all of the above = + + + + + CascadeType.ALL also covers Hibernate specific operations = like + save-update, lock etc... Check for more information + + + Please refer to the chapter 6.3 of the EJB3 specification for + more information on cascading and create/merge semantics. + + + + Association fetching + + You have the ability to either eagerly or lazily fetch + associated entities. The fetch parameter can be= set + to FetchType.LAZY or + FetchType.EAGER. EAGER will = try + to use an outer join select to retrieve the associated object, whi= le + LAZY will only trigger a select when the associ= ated + object is accessed for the first time. @OneToMany + and @ManyToMany associations are defaulted to + LAZY and @OneToOne and + @ManyToOne are defaulted to + EAGER. For more information about static fetchi= ng, + check . + + The recommanded approach is to use LAZY o= nn + all static fetching definitions and override this choice dynamical= ly + through JPA-QL. JPA-QL has a fetch keyword that + allows you to override laziness when doing a particular query. Thi= s is + very useful to improve performance and is decided on a use case to= use + case basis. + +
+ + + Mapping composite primary and foreign keys + + Composite primary keys use a embedded class as the primary key + representation, so you'd use the @Id and + @Embeddable annotations. Alternatively, you can u= se + the @EmbeddedId annotation. Note that the depende= nt + class has to be serializable and implements + equals()/hashCode(). + You can also use @IdClass as described in . + + +(a)Entity +public class RegionalArticle implements Serializable { + + @Id + public RegionalArticlePk getPk() { ... } +} + +(a)Embeddable +public class RegionalArticlePk implements Serializable { ... } + + + or alternatively + + +(a)Entity +public class RegionalArticle implements Serializable { + + @EmbeddedId + public RegionalArticlePk getPk() { ... } +} + +public class RegionalArticlePk implements Serializable { ... } + + + @Embeddable inherit the access type of its + owning entity unless the Hibernate specific annotation + @AccessType is used. Composite foreign keys (if n= ot + using the default sensitive values) are defined on associations using + the @JoinColumns element, which is basically an a= rray + of @JoinColumn. It is considered a good practice = to + express referencedColumnNames explicitly. Otherwi= se, + Hibernate will suppose that you use the same order of columns as in = the + primary key declaration. + + +(a)Entity +public class Parent implements Serializable { + @Id + public ParentPk id; + public int age; + + @OneToMany(cascade=3DCascadeType.ALL) + @JoinColumns ({ + @JoinColumn(name=3D"parentCivility", referencedColumnName =3D "isM= ale"), + @JoinColumn(name=3D"parentLastName", referencedColumnName =3D "las= tName"), + @JoinColumn(name=3D"parentFirstName", referencedColumnName =3D "fi= rstName") + }) + public Set<Child> children; //unidirectional + ... +} + + + +(a)Entity +public class Child implements Serializable { + @Id @GeneratedValue + public Integer id; + + @ManyToOne + @JoinColumns ({ + @JoinColumn(name=3D"parentCivility", referencedColumnName =3D "isM= ale"), + @JoinColumn(name=3D"parentLastName", referencedColumnName =3D "las= tName"), + @JoinColumn(name=3D"parentFirstName", referencedColumnName =3D "fi= rstName") + }) + public Parent parent; //unidirectional +} + + + +(a)Embeddable +public class ParentPk implements Serializable { + String firstName; + String lastName; + ... +} + + + Note the explicit usage of the + referencedColumnName. + + + + Mapping secondary tables + + You can map a single entity bean to several tables using the + @SecondaryTable or + @SecondaryTables class level annotations. To expr= ess + that a column is in a particular table, use the table + parameter of @Column or + @JoinColumn. + + +(a)Entity +(a)Table(name=3D"MainCat") +@SecondaryTables({ + @SecondaryTable(name=3D"Cat1", pkJoinColumns=3D{ + @PrimaryKeyJoinColumn(name=3D"cat_id", referencedColumnName=3D"id") + ), + @SecondaryTable(name=3D"Cat2", uniqueConstraints=3D{@UniqueConstraint(= columnNames=3D{"storyPart2"})}) +}) +public class Cat implements Serializable { + + private Integer id; + private String name; + private String storyPart1; + private String storyPart2; + + @Id @GeneratedValue + public Integer getId() { + return id; + } + + public String getName() { + return name; + } + = + @Column(table=3D"Cat1") + public String getStoryPart1() { + return storyPart1; + } + + @Column(table=3D"Cat2") + public String getStoryPart2() { + return storyPart2; + } + + + In this example, name will be in + MainCat. storyPart1 will be in + Cat1 and storyPart2 will be in + Cat2. Cat1 will be joined to + MainCat using the cat_id as a + foreign key, and Cat2 using id= (ie + the same column name, the MainCat id column has). + Plus a unique constraint on storyPart2 has been + set. + + Check out the JBoss EJB 3 tutorial or the Hibernate Annotations + unit test suite for more examples. + +
+ + + Mapping Queries + + + Mapping JPAQL/HQL queries + + You can map EJBQL/HQL queries using annotations. + @NamedQuery and @NamedQueries = can + be defined at the class level or in a JPA XML file. However their + definitions are global to the session factory/entity manager factory + scope. A named query is defined by its name and the actual query + string. + + <entity-mappings> + <named-query name=3D"plane.getAll"> + <query>select p from Plane p</query> + </named-query> + ... +</entity-mappings> +... + +(a)Entity +(a)NamedQuery(name=3D"night.moreRecentThan", query=3D"select n from Night = n where n.date >=3D :date") +public class Night { + ... +} + +public class MyDao { + doStuff() { + Query q =3D s.getNamedQuery("night.moreRecentThan"); + q.setDate( "date", aMonthAgo ); + List results =3D q.list(); + ... + } + ... +} + + + You can also provide some hints to a query through an array of + QueryHint through a hints + attribute. + + The availabe Hibernate hints are + + + + + Query hints + + + + + + + + + hint + + description + + + + + + org.hibernate.cacheable + + Whether the query should interact with the second lev= el + cache (defualt to false) + + + + org.hibernate.cacheRegion + + Cache region name (default used otherwise) + + + + org.hibernate.timeout + + Query timeout + + + + org.hibernate.fetchSize + + resultset fetch size + + + + org.hibernate.flushMode + + Flush mode used for this query + + + + org.hibernate.cacheMode + + Cache mode used for this query + + + + org.hibernate.readOnly + + Entities loaded by this query should be in read only = mode + or not (default to false) + + + + org.hibernate.comment + + Query comment added to the generated SQL + + + +
+
+ + + Mapping native queries + + You can also map a native query (ie a plain SQL query). To ach= ieve + that, you need to describe the SQL resultset structure using + @SqlResultSetMapping (or + @SqlResultSetMappings if you plan to define sever= al + resulset mappings). Like @NamedQuery, a + @SqlResultSetMapping can be defined at class leve= l or + in a JPA XML file. However its scope is global to the + application. + + As we will see, a resultSetMapping paramete= r is + defined in @NamedNativeQuery, it represents the n= ame + of a defined @SqlResultSetMapping. The resultset + mapping declares the entities retrieved by this native query. Each f= ield + of the entity is bound to an SQL alias (or column name). All fields = of + the entity including the ones of subclasses and the foreign key colu= mns + of related entities have to be present in the SQL query. Field + definitions are optional provided that they map to the same column n= ame + as the one declared on the class property. + + @NamedNativeQuery(name=3D"night&area", que= ry=3D"select night.id nid, night.night_duration, " + + " night.night_date, area.id aid, night.area_id, area.name " + + "from Night night, Area area where night.area_id =3D area.id", resultSetMapping=3D"joinMapping") +(a)SqlResultSetMapping(name=3D"joinMapping", entities=3D{ + @EntityResult(entityClass=3Dorg.hibernate.test.annotations.query.Night= .class, fields =3D { + @FieldResult(name=3D"id", column=3D"nid"), + @FieldResult(name=3D"duration", column=3D"night_duration"), + @FieldResult(name=3D"date", column=3D"night_date"), + @FieldResult(name=3D"area", column=3D"area_id"), + discriminatorColumn=3D"disc" + }), + @EntityResult(entityClass=3Dorg.hibernate.test.annotations.query.Area.= class, fields =3D { + @FieldResult(name=3D"id", column=3D"aid"), + @FieldResult(name=3D"name", column=3D"name") + }) + } +) + + In the above example, the night&area na= med + query use the joinMapping result set mapping. This + mapping returns 2 entities, Night and + Area, each property is declared and associated to= a + column name, actually the column name retrieved by the query. Let's = now + see an implicit declaration of the property / column. + + @Entity +@SqlResultSetMapping(name=3D"implicit", entities= =3D@EntityResult(entityClass=3Dorg.hibernate.test.annotations.query.SpaceSh= ip.class)) +(a)NamedNativeQuery(name=3D"implicitSample", query=3D"select * from SpaceS= hip", resultSetMapping=3D"implicit") +public class SpaceShip { + private String name; + private String model; + private double speed; + + @Id + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Column(name=3D"model_txt") + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed =3D speed; + } +} + + In this example, we only describe the entity member of the res= ult + set mapping. The property / column mappings is done using the entity + mapping values. In this case the model property is + bound to the model_txt column. If the association= to + a related entity involve a composite primary key, a + @FieldResult element should be used for each fore= ign + key column. The @FieldResult name is composed of = the + property name for the relationship, followed by a dot ("."), followe= d by + the name or the field or property of the primary key. + + @Entity +(a)SqlResultSetMapping(name=3D"compositekey", + entities=3D@EntityResult(entityClass=3Dorg.hibernate.test.annotati= ons.query.SpaceShip.class, + fields =3D { + @FieldResult(name=3D"name", column =3D "name"), + @FieldResult(name=3D"model", column =3D "model"), + @FieldResult(name=3D"speed", column =3D "speed"), + @FieldResult(name=3D"captain.f= irstname", column =3D "firstn"), + @FieldResult(name=3D"captain.lastname", column =3D "la= stn"), + @FieldResult(name=3D"dimensions.length", column =3D "l= ength"), + @FieldResult(name=3D"dimensions.width", column =3D "wi= dth") + }), + columns =3D { @ColumnResult(name =3D "surface"), + @ColumnResult(name =3D "volume") } ) + +(a)NamedNativeQuery(name=3D"compositekey", + query=3D"select name, model, speed, lname as lastn, fname as firstn, l= ength, width, length * width as surface from SpaceShip", = + resultSetMapping=3D"compositekey") +} ) +public class SpaceShip { + private String name; + private String model; + private double speed; + private Captain captain; + private Dimensions dimensions; + + @Id + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToOne(fetch=3D FetchType.LAZY) + @JoinColumns( { + @JoinColumn(name=3D"fname", referencedColumnName =3D "firstnam= e"), + @JoinColumn(name=3D"lname", referencedColumnName =3D "lastname= ") + } ) + public Captain getCaptain() { + return captain; + } + + public void setCaptain(Captain captain) { + this.captain =3D captain; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed =3D speed; + } + + public Dimensions getDimensions() { + return dimensions; + } + + public void setDimensions(Dimensions dimensions) { + this.dimensions =3D dimensions; + } +} + +(a)Entity +(a)IdClass(Identity.class) +public class Captain implements Serializable { + private String firstname; + private String lastname; + + @Id + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + @Id + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } +} + + + + If you look at the dimension property, you'll see that Hiber= nate + supports the dotted notation for embedded objects (you can even ha= ve + nested embedded objects). EJB3 implementations do not have to supp= ort + this feature, we do :-) + + + If you retrieve a single entity and if you use the default + mapping, you can use the resultClass attribute + instead of resultSetMapping: + + @NamedNativeQuery(name=3D"im= plicitSample", query=3D"select * from SpaceShip", = + resultClass=3DSpaceShip.class) +public class SpaceShip { + + In some of your native queries, you'll have to return scalar + values, for example when building report queries. You can map them in + the @SqlResultsetMapping through + @ColumnResult. You actually can even mix, entities + and scalar returns in the same native query (this is probably not th= at + common though). + + @SqlResultSetMapping(name=3D= "scalar", columns=3D@ColumnResult(name=3D"dimension")) +(a)NamedNativeQuery(name=3D"scalar", query=3D"select length*width as dimen= sion from SpaceShip", resultSetMapping=3D"scalar") + + An other query hint specific to native queries has been + introduced: org.hibernate.callable which can be t= rue + or false depending on whether the query is a stored procedure or + not. + +
+ + + Hibernate Annotation Extensions + + Hibernate 3.1 offers a variety of additional annotations that you + can mix/match with your EJB 3 entities. They have been designed as a + natural extension of EJB3 annotations. + + To empower the EJB3 capabilities, hibernate provides specific + annotations that match hibernate features. The + org.hibernate.annotations package contains all + these annotations extensions. + + + Entity + + You can fine tune some of the actions done by Hibernate on + entities beyond what the EJB3 spec offers. + + @org.hibernate.annotations.Entity adds + additional metadata that may be needed beyond what is defined in the + standard @Entity + + mutable: whether this entity is mutable or not = + + + + dynamicInsert: allow dynamic SQL for inserts = + + + + dynamicUpdate: allow dynamic SQL for updates = + + + + selectBeforeUpdate: Specifies that Hibernate should never per= form an SQL UPDATE unless it is certain that an object is actually modified= . = + + + + polymorphism: whether the entity polymorphism is of Polymorph= ismType.IMPLICIT (default) or PolymorphismType.EXPLICIT = + + + + optimisticLock: optimistic locking strategy (OptimisticLockTy= pe.VERSION, OptimisticLockType.NONE, OptimisticLockType.DIRTY or Optimistic= LockType.ALL) = + + + + + @javax.persistence.Entity is still mandatory, + @org.hibernate.annotations.Entity is not a replacement. + + + Here are some additional Hibernate annotation extensions + + @org.hibernate.annotations.BatchSize allows= you + to define the batch size when fetching instances of this entity ( eg. + @BatchSize(size=3D4) ). When loading a given enti= ty, + Hibernate will then load all the uninitialized entities of the same = type + in the persistence context up to the batch size. + + @org.hibernate.annotations.Proxy defines the + laziness attributes of the entity. lazy (default to true) define whe= ther + the class is lazy or not. proxyClassName is the interface used to + generate the proxy (default is the class itself). + + @org.hibernate.annotations.Where defines an + optional SQL WHERE clause used when instances of this class is + retrieved. + + @org.hibernate.annotations.Check defines an + optional check constraints defined in the DDL statetement. + + @OnDelete(action=3DOnDeleteAction.CASCADE) = on + joined subclasses: use a SQL cascade delete on deletion instead of t= he + regular Hibernate mechanism. + + @Table(appliesTo=3D"tableName", indexes =3D { + @Index(name=3D"index1", columnNames=3D{"column1", "column2"} ) } ) + creates the defined indexes on the columns of table + tableName. This can be applied on the primary tab= le + or any secondary table. The @Tables annotation al= lows + your to apply indexes on different tables. This annotation is expect= ed + where @javax.persistence.Table or + @javax.persistence.SecondaryTable(s) occurs. + + + @org.hibernate.annotations.Table is a + complement, not a replacement to + @javax.persistence.Table. Especially, if you wa= nt + to change the default name of a table, you must use + @javax.persistence.Table, not + @org.hibernate.annotations.Table. + + + @org.hibernate.annotations.Table can also be + used to define the following elements of secondary tables: + + + + fetch: If set to JOIN, the default, + Hibernate will use an inner join to retrieve a secondary table + defined by a class or its superclasses and an outer join for a + secondary table defined by a subclass. If set to select then + Hibernate will use a sequential select for a secondary table def= ined + on a subclass, which will be issued only if a row turns out to + represent an instance of the subclass. Inner joins will still be + used to retrieve a secondary defined by the class and its + superclasses. + + + + inverse: If true, Hibernate will not tr= y to + insert or update the properties defined by this join. Default to + false. + + + + optional: If enabled (the default), + Hibernate will insert a row only if the properties defined by th= is + join are non-null and will always use an outer join to retrieve = the + properties. + + + + foreignKey: defines the Foreign Key nam= e of + a secondary table pointing back to the primary table. + + + + @Immutable marks an entity or collection as + immutable. An immutable entity may not be updated by the application. + This allows Hibernate to make some minor performance optimizations. + Updates to an immutable entity will be ignored, but no exception is + thrown. @Immutable must be used on root entities + only. @Immutable placed on a collection makes the + collection immutable, meaning additions and deletions to and from the + collection are not allowed. A HibernateException = is + thrown in this case. + + @Persister lets you define your own custom + persistence strategy. You may, for example, specify your own subclas= s of + org.hibernate.persister.EntityPersister or you + might even provide a completely new implementation of the interface + org.hibernate.persister.ClassPersister that + implements persistence via, for example, stored procedure calls, + serialization to flat files or LDAP. + + @Entity +(a)BatchSize(size=3D5) +(a)org.hibernate.annotations.Entity( + selectBeforeUpdate =3D true, + dynamicInsert =3D true, dynamicUpdate =3D true, + optimisticLock =3D OptimisticLockType.ALL, + polymorphism =3D PolymorphismType.EXPLICIT) +(a)Where(clause=3D"1=3D1") +(a)org.hibernate.annotations.Table(name=3D"Forest", indexes =3D { @Index(n= ame=3D"idx", columnNames =3D { "name", "length" } ) } ) +(a)Persister(impl=3DMyEntityPersister.class) +public class Forest { ... }@Entity +(a)Inheritance( + strategy=3DInheritanceType.JOINED +) +public class Vegetable { ... } + +(a)Entity +(a)OnDelete(action=3DOnDeleteAction.CASCADE) +public class Carrot extends Vegetable { ... } + + + + Identifier + + Hibernate Annotations goes beyond the Java Persistence + specification when defining identifiers. + + + Generators + + @org.hibernate.annotations.GenericGenerato= r + and @org.hibernate.annotations.GenericGenerators + allows you to define an Hibernate specific id + generator. + + @Id @GeneratedValue(generator=3D"system-uuid= ") +(a)GenericGenerator(name=3D"system-uuid", strategy =3D "uuid") +public String getId() { + +(a)Id @GeneratedValue(generator=3D"hibseq") +(a)GenericGenerator(name=3D"hibseq", strategy =3D "seqhilo", + parameters =3D { + @Parameter(name=3D"max_lo", value =3D "5"), + @Parameter(name=3D"sequence", value=3D"heybabyhey") + } +) +public Integer getId() { + + strategy is the short name of an Hibernat= e3 + generator strategy or the fully qualified class name of an + IdentifierGenerator implementation. You can= add + some parameters through the parameters + attribute. + + Contrary to their standard counterpart, + @GenericGenerator and + @GenericGenerators can be used in package level + annotations, making them application level generators (just like if + they were in a JPA XML file). + + @GenericGenerators( + { + @GenericGenerator( + name=3D"hibseq", + strategy =3D "seqhilo", + parameters =3D { + @Parameter(name=3D"max_lo", value =3D "5"), + @Parameter(name=3D"sequence", value=3D"heybabyhey") + } + ), + @GenericGenerator(...) + } +) +package org.hibernate.test.model + + + + @NaturalId + + While not used as identifier property, some (group of) + properties represent natural identifier of an entity. This is + especially true when the schema uses the recommended approach of u= sing + surrogate primary key even if a natural business key exists. Hiber= nate + allows to map such natural properties and reuse them in a + Criteria query. The natural identifier is + composed of all the properties marked + @NaturalId. + + @Entity +public class Citizen { + @Id + @GeneratedValue + private Integer id; + private String firstname; + private String lastname; + = + @NaturalId + @ManyToOne + private State state; + + @NaturalId + private String ssn; + ... +} + + + +//and later on query +List results =3D s.createCriteria( Citizen.class ) + .add( Restrictions.naturalId().set( "ssn", "1234" ).set( "= state", ste ) ) + .list(); + + Note that the group of properties representing the natural + identifier have to be unique (Hibernate will generate a unique + constraint if the database schema is generated). + + + + + Property + + + Access type + + The access type is guessed from the position of + @Id or @EmbeddedId in the en= tity + hierarchy. Sub-entities, embedded objects and mapped superclass + inherit the access type from the root entity. + + In Hibernate, you can override the access type to: + + + + use a custom access type strategy + + + + fine tune the access type at the class level or at the + property level + + + + An @AccessType annotation has been introduced to support this + behavior. You can define the access type on + + + + an entity + + + + a superclass + + + + an embeddable object + + + + a property + + + + The access type is overriden for the annotated element, if + overriden on a class, all the properties of the given class inherit + the access type. For root entities, the access type is considered = to + be the default one for the whole hierarchy (overridable at class or + property level). + + If the access type is marked as "property", the getters are + scanned for annotations, if the access type is marked as "field", = the + fields are scanned for annotations. Otherwise the elements marked = with + @Id or @embeddedId are scanned. + + You can override an access type for a property, but the elem= ent + to annotate will not be influenced: for example an entity having + access type field, can annotate a field with + @AccessType("property"), the access type will t= hen + be property for this attribute, the the annotations still have to = be + carried on the field. + + If a superclass or an embeddable object is not annotated, the + root entity access type is used (even if an access type has been + define on an intermediate superclass or embeddable object). The + russian doll principle does not apply. + + @Entity +public class Person implements Serializable { + @Id @GeneratedValue //access type field + Integer id; + + @Embedded + @AttributeOverrides({ + @AttributeOverride(name =3D "iso2", column =3D @Column(name =3D "bornI= so2")), + @AttributeOverride(name =3D "name", column =3D @Column(name =3D "bornC= ountryName")) + }) + Country bornIn; +} + +(a)Embeddable +@AccessType("property") //override acce= ss type for all properties in Country +public class Country implements Serializable { + private String iso2; + private String name; + + public String getIso2() { + return iso2; + } + + public void setIso2(String iso2) { + this.iso2 =3D iso2; + } + + @Column(name =3D "countryName") + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} + + + + + Formula + + Sometimes, you want the Database to do some computation for = you + rather than in the JVM, you might also create some kind of virtual + column. You can use a SQL fragment (aka formula) instead of mappin= g a + property into a column. This kind of property is read only (its va= lue + is calculated by your formula fragment). + + @Formula("obj_length * obj_height * obj_width") +public long getObjectVolume() + + The SQL fragment can be as complex as you want and even incl= ude + subselects. + + + + Type + + @org.hibernate.annotations.Type overrides= the + default hibernate type used: this is generally not necessary since= the + type is correctly inferred by Hibernate. Please refer to the Hiber= nate + reference guide for more informations on the Hibernate types. + + @org.hibernate.annotations.TypeDef and + @org.hibernate.annotations.TypeDefs allows you = to + declare type definitions. These annotations are placed at the clas= s or + package level. Note that these definitions will be global for the + session factory (even at the class level) and that type definition= has + to be defined before any usage. + + @TypeDefs( + { + @TypeDef( + name=3D"caster", + typeClass =3D CasterStringType.class, + parameters =3D { + @Parameter(name=3D"cast", value=3D"lower") + } + ) + } +) +package org.hibernate.test.annotations.entity; + +... +public class Forest { + @Type(type=3D"caster") + public String getSmallText() { + ... +} + + + When using composite user type, you will have to express col= umn + definitions. The @Columns has been introduced f= or + that purpose. + + @Type(type=3D"org.hibernate.test.annotations.entit= y.MonetaryAmountUserType") +(a)Columns(columns =3D { + @Column(name=3D"r_amount"), + @Column(name=3D"r_currency") +}) +public MonetaryAmount getAmount() { + return amount; +} + + +public class MonetaryAmount implements Serializable { + private BigDecimal amount; + private Currency currency; + ... +} + + + + Index + + You can define an index on a particular column using the + @Index annotation on a one column property, the + columnNames attribute will then be ignored + + @Column(secondaryTable=3D"Cat1") +(a)Index(name=3D"story1index") +public String getStoryPart1() { + return storyPart1; +} + + + + @Parent + + When inside an embeddable object, you can define one of the + properties as a pointer back to the owner element. + + @Entity +public class Person { + @Embeddable public Address address; + ... +} + +(a)Embeddable +public class Address { + @Parent public Person owner; + ... +} + + +person =3D=3D person.address.owner + + + + Generated properties + + Some properties are generated at insert or update time by yo= ur + database. Hibernate can deal with such properties and triggers a + subsequent select to read these properties. + + @Entity +public class Antenna { + @Id public Integer id; + @Generated(GenerationTime.ALWAYS) @Column(insertable =3D false, updata= ble =3D false) + public String longitude; + + @Generated(GenerationTime.INSERT) @Column(insertable =3D false) + public String latitude; +} + + Annotate your property as @Generated You = have + to make sure your insertability or updatability does not conflict = with + the generation strategy you have chosen. When GenerationTime.INSER= T is + chosen, the property must not contains insertable columns, when + GenerationTime.ALWAYS is chosen, the property must not contains + insertable nor updatable columns. + + @Version properties cannot be + @Generated(INSERT) by design, it has to be eith= er + NEVER or ALWAYS. + + + + @Target + + Sometimes, the type guessed by reflection is not the one you + want Hibernate to use. This is especially true on components when = an + interface is used. You can use @Target to by pa= ss + the reflection guessing mechanism (very much like the + targetEntity attribute available on + associations. + + @Embedded + @Target(OwnerImpl.class) + public Owner getOwner() { + return owner; + } + + + + + + Optimistic lock + + It is sometimes useful to avoid increasing the version number + even if a given property is dirty (particularly collections). You = can + do that by annotating the property (or collection) with + @OptimisticLock(excluded=3Dtrue). + + More formally, specifies that updates to this property do not + require acquisition of the optimistic lock. + + + + + Inheritance + + SINGLE_TABLE is a very powerful strategy but sometimes, and + especially for legacy systems, you cannot add an additional + discriminator column. For that purpose Hibernate has introduced the + notion of discriminator formula: + @DiscriminatorFormula is a replacement of + @DiscriminatorColumn and use a SQL fragment as a + formula for discriminator resolution (no need to have a dedicated + column). + + @Entity +@DiscriminatorFormula("case when forest_type is nu= ll then 0 else forest_type end") +public class Forest { ... } + + By default, when querying the top entities, Hibernate does not= put + a restriction clause on the discriminator column. This can be + inconvenient if this column contains values not mapped in your hiera= rchy + (through @DiscriminatorValue). To work around that + you can use @ForceDiscriminator (at the class lev= el, + next to @DiscriminatorColumn). Hibernate will then + list the available values when loading the entities. + + You can define the foreign key name generated by Hibernate for + subclass tables in the JOINED inheritance strategy. + + @Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +public abstract class File { ... } + +(a)Entity +(a)ForeignKey(name =3D "FK_DOCU_FILE") +public class Document extends File { + + The foreign key from the Document table to = the + File table will be named + FK_DOCU_FILE. + + + + Single Association related annotations + + By default, when Hibernate cannot resolve the association beca= use + the expected associated element is not in database (wrong id on the + association column), an exception is raised by Hibernate. This might= be + inconvenient for lecacy and badly maintained schemas. You can ask + Hibernate to ignore such elements instead of raising an exception us= ing + the @NotFound annotation. This annotation can be = used + on a @OneToOne (with FK), + @ManyToOne, @OneToMany or + @ManyToMany association. + + @Entity +public class Child { + ... + @ManyToOne + @NotFound(action=3DNotFoundAction.IGNORE) + public Parent getParent() { ... } + ... +} + + Sometimes you want to delegate to your database the deletion of + cascade when a given entity is deleted. + + @Entity +public class Child { + ... + @ManyToOne + @OnDelete(action=3DOnDeleteAction.CASCADE) + public Parent getParent() { ... } + ... +} + + In this case Hibernate generates a cascade delete constraint at + the database level. + + Foreign key constraints, while generated by Hibernate, have a + fairly unreadable name. You can override the constraint name by use + @ForeignKey. + + @Entity +public class Child { + ... + @ManyToOne + @ForeignKey(name=3D"FK_PARENT") + public Parent getParent() { ... } + ... +} + +alter table Child add constraint FK_PARENT foreign key (parent_id) referen= ces Parent + + + Lazy options and fetching modes + + EJB3 comes with the fetch option to define + lazy loading and fetching modes, however Hibernate has a much more + option set in this area. To fine tune the lazy loading and fetching + strategies, some additional annotations have been introduced: + + + + @LazyToOne: defines the lazyness opti= on + on @ManyToOne and @OneToOne + associations. LazyToOneOption can be + PROXY (ie use a proxy based lazy loading), + NO_PROXY (use a bytecode enhancement based = lazy + loading - note that build time bytecode processing is necessar= y) + and FALSE (association not lazy) + + + + @LazyCollection: defines the lazyness + option on @ManyToMany and + @OneToMany associations. LazyCollectionOpti= on + can be TRUE (the collection is lazy and wil= l be + loaded when its state is accessed), EXTRA (= the + collection is lazy and all operations will try to avoid the + collection loading, this is especially useful for huge collect= ions + when loading all the elements is not necessary) and FALSE + (association not lazy) + + + + @Fetch: defines the fetching strategy + used to load the association. FetchMode can= be + SELECT (a select is triggered when the + association needs to be loaded), SUBSELECT + (only available for collections, use a subselect strategy - pl= ease + refers to the Hibernate Reference Documentation for more + information) or JOIN (use a SQL JOIN to load + the association while loading the owner entity). + JOIN overrides any lazy attribute (an + association loaded through a JOIN strategy + cannot be lazy). + + + + The Hibernate annotations overrides the EJB3 fetching + options. + + + Lazy and fetch options equivalent + + + + + Annotations + + Lazy + + Fetch + + + + + + @[One|Many]ToOne](fetch=3DFetchType.LAZY) + + @LazyToOne(PROXY) + + @Fetch(SELECT) + + + + @[One|Many]ToOne](fetch=3DFetchType.EAGER) + + @LazyToOne(FALSE) + + @Fetch(JOIN) + + + + @ManyTo[One|Many](fetch=3DFetchType.LAZY) + + @LazyCollection(TRUE) + + @Fetch(SELECT) + + + + @ManyTo[One|Many](fetch=3DFetchType.EAGER) + + @LazyCollection(FALSE) + + @Fetch(JOIN) + + + +
+
+ + + @Any + + The @Any annotation defines a polymor= phic + association to classes from multiple tables. This type of mapping + always requires more than one column. The first column holds the t= ype + of the associated entity. The remaining columns hold the identifie= r. + It is impossible to specify a foreign key constraint for this kind= of + association, so this is most certainly not meant as the usual way = of + mapping (polymorphic) associations. You should use this only in ve= ry + special cases (eg. audit logs, user session data, etc). + + The @Any annotation describes the column holding the metadata + information. To link the value of the metadata information and an + actual entity type, The @AnyDef and + @AnyDefs annotations are used. + + @Any( metaColumn =3D @Column( name =3D "proper= ty_type" ), fetch=3DFetchType.EAGER ) + @AnyMetaDef( = + idType =3D "integer", = + metaType =3D "string", = + metaValues =3D { + @MetaValue( value =3D "S", targetEntity =3D StringProperty.cla= ss ), + @MetaValue( value =3D "I", targetEntity =3D IntegerProperty.cl= ass ) + } ) + @JoinColumn( name =3D "property_id" ) + public Property getMainProperty() { + return mainProperty; + } + + idType represents the target entiti= es + identifier property type and metaType the + metadata type (usually String). + + Note that @AnyDef can be mutualized a= nd + reused. It is recommended to place it as a package metadata in this + case. + + //on a package +(a)AnyMetaDef( name=3D"property" = + idType =3D "integer", = + metaType =3D "string", = + metaValues =3D { + @MetaValue( value =3D "S", targetEntity =3D StringProperty.class ), + @MetaValue( value =3D "I", targetEntity =3D IntegerProperty.class ) + } ) +package org.hibernate.test.annotations.any; + + +//in a class + @Any( metaDef=3D"property", metaColumn =3D @Column( name =3D "property= _type" ), fetch=3DFetchType.EAGER ) + @JoinColumn( name =3D "property_id" ) + public Property getMainProperty() { + return mainProperty; + } + +
+ + + Collection related annotations + + + Enhance collection settings + + It is possible to set + + the batch size for collections using @BatchSize = + + + + the where clause, using @Where (applied on the target entit= y) or @WhereJoinTable (applied on the association table) = + + + + the check clause, using @Check = + + + + the SQL order by clause, using @OrderBy = + + + + the delete cascade strategy through @OnDelete(action=3DOnDe= leteAction.CASCADE) = + + + + the collection immutability using @Immutable: if set specif= ies that the elements of the collection never change (a minor performance o= ptimization in some cases) = + + + + a custom collection persister (ie the persistence stra= tegy + used) using @Persister: the class must + implement + org.hibernate.persister.collectionCollectionPersi= ster + + + + You can also declare a sort comparator. Use the + @Sort annotation. Expressing the comparator type + you want between unsorted, natural or custom comparator. If you wa= nt + to use your own comparator implementation, you'll also have to exp= ress + the implementation class using the comparator + attribute. Note that you need to use either a + SortedSet or a SortedMap + interface. + + @OneToMany(cascade=3DCascadeType.ALL, fetch=3D= FetchType.EAGER) + @JoinColumn(name=3D"CUST_ID") + @Sort(type =3D SortType.COMPARATOR, comparator =3D TicketComparator.cl= ass) + @Where(clause=3D"1=3D1") + @OnDelete(action=3DOnDeleteAction.CASCADE) + public SortedSet<Ticket> getTickets() { + return tickets; + } + + Please refer to the previous descriptions of these annotatio= ns + for more informations. + + Foreign key constraints, while generated by Hibernate, have a + fairly unreadable name. You can override the constraint name by use + @ForeignKey. Note that this annotation has to be + placed on the owning side of the relationship, + inverseName referencing to the other side + constraint. + + @Entity +public class Woman { + ... + @ManyToMany(cascade =3D {CascadeType.ALL}) + @ForeignKey(name =3D "TO_WOMAN_FK", inverseNam= e =3D "TO_MAN_FK") + public Set<Man> getMens() { + return mens; + } +} + +alter table Man_Woman add constraint TO_WOMAN_FK foreign key (woman_id) re= ferences Woman +alter table Man_Woman add constraint TO_MAN_FK foreign key (man_id) refere= nces Man + + + + Extra collection types + + + List + + Beyond EJB3, Hibernate Annotations supports true + List and Array. Map + your collection the same way as usual and add the + @IndexColumn. This annotation allows you to + describe the column that will hold the index. You can also decla= re + the index value in DB that represent the first element (aka as b= ase + index). The usual value is 0 or + 1. + + @OneToMany(cascade =3D CascadeType.ALL) +(a)IndexColumn(name =3D "drawer_position", base=3D1) +public List<Drawer> getDrawers() { + return drawers; +} + + + If you forgot to set @IndexColumn, the + bag semantic is applied. If you want the bag semantic without = the + limitations of it, consider using + @CollectionId. + + + + + Map + + Hibernate Annotations also supports true Map mappings, if + @javax.persistence.MapKey is not set, hiberna= te + will map the key element or embeddable object in its/their own + columns. To override the default columns, you can use + @org.hibernate.annotations.MapKey if your key= is + a basic type (defaulted to mapkey) or an + embeddable object, or you can use + @org.hibernate.annotations.MapKeyManyToMany if + your key is an entity. + + Both @org.hibernate.annotations.MapKey = and + @org.hibernate.annotations.MapKeyManyToMany + allows you to override the target element to be used. This is + especially useful if your collection does not use generics (or if + you use interfaces). + + @CollectionOfElements(targetElement =3D Size= Impl.class) + @MapKeyManyToMany(targetEntity =3D LuggageImpl= .class) + private Map<Luggage, Size> sizePerLuggage =3D new HashMap<Lug= gage, Size>(); + + + + + + Bidirectional association with indexed collections + + A bidirectional association where one end is an indexed + collection (ie. represented as a @IndexColumn, + @org.hibernate.annotations.MapKey or + @org.hibernate.annotations.MapKeyManyToMany) + requires special consideration. If a property on the associated + class explicitly maps the indexed value, the use of + mappedBy is permitted: + + @Entity +public class Parent { + @OneToMany(mappedBy=3D"parent") + @org.hibernate.annotations.IndexColumn(name=3D"order") + private List<Child> children; + ... +} + +(a)Entity +public class Child { + ... + //the index column is mapped as a property in the associated entity + @Column(name=3D"order") + private int order; + + @ManyToOne + @JoinColumn(name=3D"parent_id", nullable=3Dfalse) + private Parent parent; + ... +} + + But, if there is no such property on the child class, we c= an't + think of the association as truly bidirectional (there is + information available at one end of the association that is not + available at the other end: the index). In this case, we can't m= ap + the collection as mappedBy. Instead, we could= use + the following mapping: + + @Entity +public class Parent { + @OneToMany + @org.hibernate.annotations.IndexColumn(name=3D"order") + @JoinColumn(name=3D"parent_id", nullable=3Dfalse) + private List<Child> children; + ... +} + +(a)Entity +public class Child { + ... + @ManyToOne + @JoinColumn(name=3D"parent_id", insertable=3Dfalse, updatable=3Dfalse,= nullable=3Dfalse) + private Parent parent; + ... +} + + Note that in this mapping, the collection-valued end of the + association is responsible for updating the foreign key. + + + + Bag with primary key + + Another interesting feature is the ability to define a + surrogate primary key to a bag collection. This remove pretty mu= ch + all of the drawbacks of bags: update and removal are efficient, = more + than one EAGER bag per query or per entity. T= his + primary key will be contained in a additional column of your + collection table but will not be visible to the Java application. + @CollectionId is used to mark a collection as id bag, it also al= low + to override the primary key column(s), the primary key type and = the + generator strategy. The strategy can be identity, + or any defined generator name of your application. + + @Entity +(a)TableGenerator(name=3D"ids_generator", table=3D"IDS") +public class Passport { + ... + + @ManyToMany(cascade =3D CascadeType.ALL) + @JoinTable(name=3D"PASSPORT_VISASTAMP") + @CollectionId( + columns =3D @Column(name=3D"COLLECTION_ID"), = + type=3D@Type(type=3D"long"), = + generator =3D "ids_generator" + ) + private Collection<Stamp> visaStamp =3D new ArrayList(); + ... +} + + + + Collection of element or composite elements + + Hibernate Annotations also supports collections of core ty= pes + (Integer, String, Enums, ...), collections of embeddable objects= and + even arrays of primitive types. This is known as collection of + elements. + + A collection of elements has to be annotated as + @CollectionOfElements (as a replacement of + @OneToMany) To define the collection table, t= he + @JoinTable annotation is used on the associat= ion + property, joinColumns defines the join columns + between the entity primary table and the collection table + (inverseJoincolumn is useless and should be left empty). For + collection of core types or array of primitive types, you can + override the element column definition using a + @Column on the association property. You can = also + override the columns of a collection of embeddable object using + @AttributeOverride. To reach the collection + element, you need to append "element" to the attribute override = name + (eg "element" for core types, or "element.serial" for the serial + property of an embeddable element). To reach the index/key of a + collection, append "key" instead. + + @Entity +public class Boy { + private Integer id; + private Set<String> nickNames =3D new HashSet<String>(); + private int[] favoriteNumbers; + private Set<Toy> favoriteToys =3D new HashSet<Toy>(); + private Set<Character> characters =3D new HashSet<Character&g= t;(); + + @Id @GeneratedValue + public Integer getId() { + return id; + } + + @CollectionOfElements + public Set<String> getNickNames() { + return nickNames; + } + + @CollectionOfElements + @JoinTable( + table=3D@Table(name=3D"BoyFavoriteNumbers"), + joinColumns =3D @JoinColumn(name=3D"BoyId") + ) + @Column(name=3D"favoriteNumber", nullable=3Dfalse) + @IndexColumn(name=3D"nbr_index") + public int[] getFavoriteNumbers() { + return favoriteNumbers; + } + + @CollectionOfElements + @AttributeOverride( name=3D"element.serial", column=3D@Column(name=3D"= serial_nbr") ) + public Set<Toy> getFavoriteToys() { + return favoriteToys; + } + + @CollectionOfElements + public Set<Character> getCharacters() { + return characters; + } + ... +} + +public enum Character { + GENTLE, + NORMAL, + AGGRESSIVE, + ATTENTIVE, + VIOLENT, + CRAFTY +} + +(a)Embeddable +public class Toy { + public String name; + public String serial; + public Boy owner; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getSerial() { + return serial; + } + + public void setSerial(String serial) { + this.serial =3D serial; + } + + @Parent + public Boy getOwner() { + return owner; + } + + public void setOwner(Boy owner) { + this.owner =3D owner; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final Toy toy =3D (Toy) o; + + if ( !name.equals( toy.name ) ) return false; + if ( !serial.equals( toy.serial ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D name.hashCode(); + result =3D 29 * result + serial.hashCode(); + return result; + } +} + + On a collection of embeddable objects, the embeddable obje= ct + can have a property annotated with @Parent. T= his + property will then point back to the entity containing the + collection. + + + Previous versions of Hibernate Annotations used the + @OneToMany to mark a collection of elements. + Due to semantic inconsistencies, we've introduced the annotati= on + @CollectionOfElements. Marking collections = of + elements the old way still work but is considered deprecated a= nd + is going to be unsupported in future releases + + + + + @ManyToAny + + @ManyToAny allows polymorphic + associations to classes from multiple tables. This type of mappi= ng + always requires more than one column. The first column holds the + type of the associated entity. The remaining columns hold the + identifier. It is impossible to specify a foreign key constraint= for + this kind of association, so this is most certainly not meant as= the + usual way of mapping (polymorphic) associations. You should use = this + only in very special cases (eg. audit logs, user session data, + etc). + + @ManyToAny( + metaColumn =3D @Column( name =3D "property_type" ) ) + @AnyMetaDef( = + idType =3D "integer", = + metaType =3D "string", + metaValues =3D { + @MetaValue( value =3D "S", targetEntity =3D StringProperty.cla= ss ), + @MetaValue( value =3D "I", targetEntity =3D IntegerProperty.cl= ass ) } ) + @Cascade( { org.hibernate.annotations.CascadeType.ALL } ) + @JoinTable( name =3D "obj_properties", joinColumns =3D @JoinColumn( na= me =3D "obj_id" ), + inverseJoinColumns =3D @JoinColumn( name =3D "property_id" ) ) + public List<Property> getGeneralProperties() { + + Like @Any, + @ManyToAny can use named + @AnyDefs, see for more info. + + + + + + Cascade + + Hibernate offers more operations than the Java Persistence + specification. You can use the @Cascade annotatio= n to + cascade the following operations: + + + + PERSIST + + + + MERGE + + + + REMOVE + + + + REFRESH + + + + DELETE + + + + SAVE_UPDATE + + + + REPLICATE + + + + DELETE_ORPHAN + + + + LOCK + + + + EVICT + + + + This is especially useful for SAVE_UPDATE + (which is the operation cascaded at flush time if you use plain + Hibernate Annotations - Hibernate EntityManager cascade + PERSIST at flush time as per the specification). + DELETE_ORPHAN applies only to @OneToMany + associations, and indicates that the + delete()/remove() operation should be appli= ed + to any child object that is removed from the association. In other + words, if a child is dereferenced by a persistent parent and if + DELETE_ORPHAN is used, the "orphaned" child is + deleted. + + @OneToMany( cascade =3D {CascadeType.PERSIST, Cascad= eType.MERGE} ) +(a)Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, + org.hibernate.annotations.CascadeType.DELETE_ORPHAN}) +public Collection<Employer> getEmployers() + + It is recommended to use @Cascade to compliment @*To*(cascade= =3D...) + as shown in the previous example. + + + + Cache + + In order to optimize your database accesses, you can activate = the + so called second level cache of Hibernate. This cache is configurabl= e on + a per entity and per collection basis. + + @org.hibernate.annotations.Cache defines the + caching strategy and region of a given second level cache. This + annotation can be applied on the root entity (not the sub entities),= and + on the collections. + + @Entity +(a)Cache(usage =3D CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Forest { ... } + + @OneToMany(cascade=3DCascadeType.ALL, fetch=3DFe= tchType.EAGER) + @JoinColumn(name=3D"CUST_ID") + @Cache(usage =3D CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + public SortedSet<Ticket> getTickets() { + return tickets; + } + + + + + + + + + + + + + @Cache( + CacheConcurrencyStrategy usage(); + String region() default ""; + String include() default "all"; +) + + + + usage: the given cache concurrency strategy (NONE, + READ_ONLY, NONSTRICT_READ_WRITE, READ_WRITE, TRANSACTIONAL) + + + + region (optional): the cache region (default to the fqcn= of + the class or the fq role name of the collection) + + + + include (optional): all to include all + properties, non-lazy to only include non lazy properties (defa= ult + all). + + + + + + + Filters + + Hibernate has the ability to apply arbitrary filters on top of + your data. Those filters are applied at runtime on a given session. + First, you need to define them. + + @org.hibernate.annotations.FilterDef or + @FilterDefs define filter definition(s) used by + filter(s) using the same name. A filter definition has a name() and = an + array of parameters(). A parameter will allow you to adjust the beha= vior + of the filter at runtime. Each parameter is defined by a + @ParamDef which has a name and a type. You can al= so + define a defaultCondition() parameter for a given + @FilterDef to set the default condition to use wh= en + none are defined in each individual @Filter. A + @FilterDef(s) can be defined at the class or pack= age + level. + + We now need to define the SQL filter clause applied to either = the + entity load or the collection load. @Filter is us= ed + and placed either on the entity or the collection element + + @Entity +(a)FilterDef(name=3D"minLength", parameters=3D@ParamDef( name=3D"minLength= ", type=3D"integer" ) ) +(a)Filters( { + @Filter(name=3D"betweenLength", condition=3D":minLength <=3D length= and :maxLength >=3D length"), + @Filter(name=3D"minLength", condition=3D":minLength <=3D length") +} ) +public class Forest { ... } + + When the collection use an association table as a relational + representation, you might want to apply the filter condition to the + association table itself or to the target entity table. To apply the + constraint on the target entity, use the regular + @Filter annotation. However, if you wan to target= the + association table, use the @FilterJoinTable + annotation. + + @OneToMany + @JoinTable + //filter on the target entity table + @Filter(name=3D"betweenLength", condition=3D":minLength <=3D length= and :maxLength >=3D length") + //filter on the association table + @FilterJoinTable(name=3D"security", condition=3D":userlevel >=3D re= quredLevel") + public Set<Forest> getForests() { ... } + + + + Queries + + Since Hibernate has more features on named queries than the one + defined in the EJB3 specification, + @org.hibernate.annotations.NamedQuery, + @org.hibernate.annotations.NamedQueries, + @org.hibernate.annotations.NamedNativeQuery and + @org.hibernate.annotations.NamedNativeQueries have + been introduced. They add some attributes to the standard version and + can be used as a replacement: + + + + flushMode: define the query flush mode (Always, Auto, Comm= it + or Manual) + + + + cacheable: whether the query should be cached or not + + + + cacheRegion: cache region used if the query is cached + + + + fetchSize: JDBC statement fetch size for this query + + + + timeout: query time out + + + + callable: for native queries only, to be set to true for + stored procedures + + + + comment: if comments are activated, the comment seen when = the + query is sent to the database. + + + + cacheMode: Cache interaction mode (get, ignore, normal, pu= t or + refresh) + + + + readOnly: whether or not the elements retrievent from the + query are in read only mode. + + + + Those hints can be set in a standard + @javax.persistence.NamedQuery annotations through= the + detyped @QueryHint. Another key advantage is the + ability to set those annotations at a package level. + + + + Custom SQL for CRUD operations + + Hibernate gives you the ability to override every single SQL + statement generated. We have seen native SQL query usage already, but + you can also override the SQL statement used to load or change the s= tate + of entities. + + @Entity +(a)Table(name=3D"CHAOS") +@SQLInsert( sql=3D"INSERT INTO CHAOS(size, name, n= ickname, id) VALUES(?,upper(?),?,?)") +(a)SQLUpdate( sql=3D"UPDATE CHAOS SET size =3D ?, name =3D upper(?), nickn= ame =3D ? WHERE id =3D ?") +(a)SQLDelete( sql=3D"DELETE CHAOS WHERE id =3D ?") +(a)SQLDeleteAll( sql=3D"DELETE CHAOS") +@Loader(namedQuery =3D "chaos") +(a)NamedNativeQuery(name=3D"chaos", query=3D"select id, size, name, lower(= nickname ) as nickname from CHAOS where id=3D ?", resultClass =3D Chaos.cl= ass) +public class Chaos { + @Id + private Long id; + private Long size; + private String name; + private String nickname; + + @SQLInsert, @SQLUpdate, + @SQLDelete, @SQLDeleteAll + respectively override the INSERT statement, UPDATE statement, DELETE + statement, DELETE statement to remove all entities. + + If you expect to call a store procedure, be sure to set the + callable attribute to true + (@SQLInsert(callable=3Dtrue, ...)). + + To check that the execution happens correctly, Hibernate allows + you to define one of those three strategies: + + + + NONE: no check is performed: the store procedure is expect= ed + to fail upon issues + + + + COUNT: use of rowcount to check that the update is + successful + + + + PARAM: like COUNT but using an output parameter rather that + the standard mechanism + + + + To define the result check style, use the check + parameter (@SQLUpdate(check=3DResultCheckStyle.COUNT, + ...)). + + You can also override the SQL load statement by a native SQL q= uery + or a HQL query. You just have to refer to a named query with the + @Loader annotation. + + You can use the exact same set of annotations to override the + collection related statements. + + @OneToMany +(a)JoinColumn(name=3D"chaos_fk") +@SQLInsert( sql=3D"UPDATE CASIMIR_PARTICULE SET ch= aos_fk =3D ? where id =3D ?") +(a)SQLDelete( sql=3D"UPDATE CASIMIR_PARTICULE SET chaos_fk =3D null where = id =3D ?") +private Set<CasimirParticle> particles =3D new HashSet<CasimirPar= ticle>(); + + The parameters order is important and is defined by the order + Hibernate handle properties. You can see the expected order by enabl= ing + debug logging for the org.hibernate.persister.entity + level. With this level enabled Hibernate will print out the static S= QL + that is used to create, update, delete etc. entities. (To see the + expected sequence, remember to not include your custom SQL through + annotations as that will override the Hibernate generated static + sql.) + + Overriding SQL statements for secondary tables is also possible + using @org.hibernate.annotations.Table and either= (or + all) attributes sqlInsert, + sqlUpdate, sqlDelete: + + @Entity +(a)SecondaryTables({ + @SecondaryTable(name =3D "`Cat nbr1`"), + @SecondaryTable(name =3D "Cat2"}) +(a)org.hibernate.annotations.Tables( { + @Table(appliesTo =3D "Cat", comment =3D "My cat table" ), + @Table(appliesTo =3D "Cat2", foreignKey =3D @ForeignKey(name=3D"FK_CAT= 2_CAT"), fetch =3D FetchMode.SELECT, + sqlInsert=3D@SQLInsert(sql=3D"insert into = Cat2(storyPart2, id) values(upper(?), ?)") ) +} ) +public class Cat implements Serializable { + + The previous example also show that you can give a comment to a + given table (promary or secondary): This comment will be used for DDL + generation. + + + + Tuplizer + + org.hibernate.tuple.Tuplizer, and its + sub-interfaces, are responsible for managing a particular representa= tion + of a piece of data, given that representation's + org.hibernate.EntityMode. If a given piece of dat= a is + thought of as a data structure, then a tuplizer is the thing which k= nows + how to create such a data structure and how to extract values from a= nd + inject values into such a data structure. For example, for the POJO + entity mode, the correpsonding tuplizer knows how create the POJO + through its constructor and how to access the POJO properties using = the + defined property accessors. There are two high-level types of Tupliz= ers, + represented by the + org.hibernate.tuple.EntityTuplizer and + org.hibernate.tuple.ComponentTuplizer interfa= ces. + EntityTuplizers are responsible for managing the above mentioned + contracts in regards to entities, while + ComponentTuplizers do the same for components. + Check the Hibernate reference documentation for more information. + + To define tuplixer in annotations, simply use the + @Tuplizer annotation on the according element + + @Entity +@Tuplizer(impl =3D DynamicEntityTuplizer.class) +public interface Cuisine { + @Id + @GeneratedValue + public Long getId(); + public void setId(Long id); + + public String getName(); + public void setName(String name); + + @Tuplizer(impl =3D DynamicComponentTuplizer.cl= ass) + public Country getCountry(); + public void setCountry(Country country); + + +} + +
+
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/setup.= xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/setup.xml= (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/setup.xml= 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,213 @@ + + + Setting up an annotations project</ti= tle> + + <section id=3D"setup-requirements" revision=3D"2"> + <title>Requirements + + + + Download + and unpack the Hibernate Annotations distribution from the Hiberna= te + website. + + + + This release requires Hibernate Core 3.3 and + above. + + + + This release is known to work on Hibernate Core 3.3.0.SP1 + + + + Make sure you have JDK 5.0 installed or above. You can of co= urse + continue using XDoclet and get some of the benefits of + annotation-based metadata with older JDK versions. Note that this + document only describes JDK 5.0 annotations and you have to refer = to + the XDoclet documentation for more information. + + +
+ +
+ Configuration + + First, set up your classpath (after you have created a new proje= ct + in your favorite IDE): + + Copy all Hibernate3 core and required 3rd party library fi= les + (see lib/README.txt in Hibernate). + + + + Copy hibernate-annotations.jar, + lib/hibernate-comons-annotations.jar and + lib/ejb3-persistence.jar from the Hibernate + Annotations distribution to your classpath as well. + + + + If you wish to use Hibernate Validator, do= wnload + it from the Hibernate website and add + hibernate-validator.jar in your classpath. + + If you wish to use Hibernate Search, download= it + from the Hibernate website and add + hibernate-search.jar and + lucene-core-x.y.z.jar in your classpath. + + We also recommend a small wrapper class to startup Hibernate in a + static initializer block, known as HibernateUtil. + You might have seen this class in various forms in other areas of the + Hibernate documentation. For Annotation support you have to enhance th= is + helper class as follows: package hello; + +import org.hibernate.*; +import org.hibernate.cfg.*; +import test.*; +import test.animals.Dog; + +public class HibernateUtil { + +private static final SessionFactory sessionFactory; + + static { + try { + + sessionFactory =3D new AnnotationConfi= guration() + configure().buildSessionFactory(); + } catch (Throwable ex) { + // Log exception! + throw new ExceptionInInitializerError(ex); + } + } + + public static Session getSession() + throws HibernateException { + return sessionFactory.openSession(); + } +} + + + Interesting here is the use of + AnnotationConfiguration. The packages and annot= ated + classes are declared in your regular XML configuration file (usually + hibernate.cfg.xml). Here is the equivalent of the + above declaration: + + <!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> + + <hibernate-configuration> + <session-factory> + <mapping package=3D"test.animals"/&= gt; + <mapping class=3D"test.Flight"/> + <mapping class=3D"test.Sky"/> + <mapping class=3D"test.Person"/> + <mapping class=3D"test.animals.Dog"/> + <mapping resource=3D"test/animals/o= rm.xml"/> + </session-factory> + </hibernate-configuration> + + + Note that you can mix the hbm.xml use and the new annotation one. + The resource element can be either an hbm file or an EJB3 XML deployme= nt + descriptor. The distinction is transparent for your configuration + process. + + Alternatively, you can define the annotated classes and packages + using the programmatic API + + sessionFactory =3D new AnnotationConfiguration() + .addPackage("test.animals") //the fully qualified pack= age name + .addAnnotatedClass(Flight.class) + .addAnnotatedClass(Sky.class) + .addAnnotatedClass(Person.class) + .addAnnotatedClass(Dog.class) + .addResource("test/animals/orm= .xml") + configure()..buildSessionFactory(); + + You can also use the Hibernate EntityManager which has its own + configuration mechanism. Please refer to this project documentation for + more details. + + There is no other difference in the way you use Hibernate APIs w= ith + annotations, except for this startup routine change or in the + configuration file. You can use your favorite configuration method for + other properties ( hibernate.properties, + hibernate.cfg.xml, programmatic APIs, etc). You c= an + even mix annotated persistent classes and classic + hbm.cfg.xml declarations with the same + SessionFactory. You can however not declare a c= lass + several times (whether annotated or through hbm.xml). You cannot mix + configuration strategies (hbm vs annotations) in a mapped entity hiera= rchy + either. + + To ease the migration process from hbm files to annotations, the + configuration mechanism detects the mapping duplication between + annotations and hbm files. HBM files are then prioritized over annotat= ed + metadata on a class to class basis. You can change the priority using + hibernate.mapping.precedence property. The default = is + hbm, class, changing it to class, + hbm will prioritize the annotated classes over hbm files whe= n a + conflict occurs. +
+ +
+ Properties + + Asides from the Hibernate core properties, Hibernate Annotations + reacts to the following one +
+ +
+ Logging + + Hibernate Annotations utilizes Simple Logging Facade for Java (= SLF4J) + in order to log various system events. SLF4J can direct your logging + output to several logging frameworks (NOP, Simple, log4j version 1.2, = JDK + 1.4 logging, JCL or logback) depending on your chosen binding. In orde= r to + setup logging properly you will need slf4j-api.jar in + your classpath together with the jar file for your preferred binding - + slf4j-log4j12.jar in the case of Log4J. See the S= LF4J + documentation for more + detail. + + The logging categories interesting for Hibernate Annotations + are: + + + Hibernate Annotations Log Categories + + + + + Category + + Function + + + + + + org.hibernate.cfg + + Log all configuration related events (not only + annotations). + + + +
+ + For further category configuration refer to the Logging + in the Hibernate Core documentation. +
+ Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/xml-ov= erriding.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/xml-overr= iding.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/modules/xml-overr= iding.xml 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,402 @@ + + + Overriding metadata through XML + + The primary target for metadata in EJB3 is annotations, but the EJ= B3 + specification provides a way to override or replace the annotation defin= ed + metadata through an XML deployment descriptor. In the current release on= ly + pure EJB3 annotations overriding are supported. If you wish to use Hiber= nate + specific features in some entities, you'll have to either use annotation= s or + fallback to hbm files. You can of course mix and match annotated entities + and entities describes in hbm files. + + The unit test suite shows some additional XML file samples. + +
+ Principles + + The XML deployment descriptor structure has been designed to ref= lect + the annotations one. So if you know the annotations structure, using t= he + XML schema will be straightforward for you. + + You can define one ot more XML files describing your metadata, t= hese + files will be merged by the overriding engine. + +
+ Global level metadata + + You can define global level metadata available for all XML fil= es. + You must not define these metadata more than once per deployment. + + <?xml version=3D"1.0" encoding=3D"UTF-8"?> + +<entity-mappings = + xmlns=3D"http://java.sun.com/xml/ns/persistence/orm" + xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm orm_1_0= .xsd" + version=3D"1.0"> + + <persistence-unit-metadata> + <xml-mapping-metadata-complete/> + <persistence-unit-defaults> + <schema>myschema</schema> + <catalog>mycatalog</catalog> + <cascade-persist/> + </persistence-unit-defaults> + </persistence-unit-metadata> + + xml-mapping-metadata-complete means that all + entity, mapped-superclasses and embeddable metadata should be picked= up + from XML (ie ignore annotations). + + schema / catalog will override all default + definitions of schema and catalog in the metadata (both XML and + annotations). + + cascade-persist means that all associations + have PERSIST as a cascade type. We recommend you to not use this + feature. +
+ +
+ Entity level metadata + + You can either define or override metadata informations on a g= iven + entity. + + + + + + + + + + + + + + + + + + + + + + + + + <?xml version=3D"1.0" encoding=3D"UTF-8"?> + +<entity-mappings = + xmlns=3D"http://java.sun.com/xml/ns/persistence/orm" + xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm orm_1_0= .xsd" + version=3D"1.0"> + + <package>org.hibernate.test.annotations.reflection</package&g= t; + <entity class=3D"Administration" access=3D"PROPERTY" metadata-compl= ete=3D"true"> + <table name=3D"tbl_admin"> + <unique-constraint> + <column-name>firstname</column-name> + <column-name>lastname</column-name> + </unique-constraint> + </table> + <secondary-table name=3D"admin2"> + <primary-key-join-column name=3D"admin_id" referenced-colum= n-name=3D"id"/> + <unique-constraint> + <column-name>address</column-name> + </unique-constraint> + </secondary-table> + <id-class class=3D"SocialSecurityNumber"/> + <inheritance strategy=3D"JOINED"/> + <sequence-generator name=3D"seqhilo" sequence-name=3D"seqhilo"/= > + <table-generator name=3D"table" table=3D"tablehilo"/> + ... + </entity> + + <entity class=3D"PostalAdministration"> + <primary-key-join-column name=3D"id"/> + ... + </entity> +</entity-mappings> + + + + entity-mappings: entity-mappings is t= he + root element for all XML files. You must declare the xml schem= a, + the schema file is included in the hibernate-annotations.jar f= ile, + no internet access will be processed by Hibernate + Annotations. + + + + package (optional): default package u= sed + for all non qualified class names in the given deployment + descriptor file. + + + + entity: desribes an entity. + + metadata-complete defines whether the + metadata description for this element is complete or not (in o= ther + words, if annotations present at the class level should be + considered or not). + + An entity has to have a class attribu= te + refering the java class the metadata applies on. + + You can overrides entity name through the + name attribute, if none is defined and if an + @Entity.name is present, then it is used + (provided that metadata complete is not set). + + For metadata complete (see below) element, you can defin= e an + access (either FIELD or + PROPERTY (default)). For non medatada compl= ete + element, if access is not defined, the @Id + position will lead position, if access is + defined, the value is used. + + + + table: you can declare table properti= es + (name, schema, catalog), if none is defined, the java annotati= on + is used. + + You can define one or several unique constraints as seen= in + the example + + + + secondary-table: defines a secondary + table very much like a regular table except that you can define + the primary key / foreign key column(s) through the + primary-key-join-column element. On non + metadata complete, annotation secondary tables are used only if + there is no secondary-table definition, + annotations are ignored otherwise. + + + + id-class: defines the id class in a + similar way @IdClass does + + + + inheritance: defines the inheritance + strategy (JOINED, + TABLE_PER_CLASS, + SINGLE_TABLE), Available only at the root + entity level + + + + sequence-generator: defines a sequence + generator + + + + table-generator: defines a table + generator + + + + primary-key-join-column: + defines the primary key join column for sub entities when JOIN= ED + inheritance strategy is used + + + + + + + + + + + + + + + + + + <?xml version=3D"1.0" encoding=3D"UTF-8"?> + +<entity-mappings = + xmlns=3D"http://java.sun.com/xml/ns/persistence/orm" + xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm orm_1_0= .xsd" + version=3D"1.0"> + + <package>org.hibernate.test.annotations.reflection</package&g= t; + <entity class=3D"Music" access=3D"PROPERTY" metadata-complete=3D"tr= ue"> + <discriminator-value>Generic</discriminator-value> + <discriminator-column length=3D"34"/> + ... + </entity> + + <entity class=3D"PostalAdministration"> + <primary-key-join-column name=3D"id"/> + <named-query name=3D"adminById"> + <query>select m from Administration m where m.id =3D :id= </query> + <hint name=3D"org.hibernate.timeout" value=3D"200"/> + </named-query> + <named-native-query name=3D"allAdmin" result-set-mapping=3D"adm= inrs"> + <query>select *, count(taxpayer_id) as taxPayerNumber = + from Administration, TaxPayer + where taxpayer_admin_id =3D admin_id group by ...</query> + <hint name=3D"org.hibernate.timeout" value=3D"200"/> + </named-native-query> + <sql-result-set-mapping name=3D"adminrs"> + <entity-result entity-class=3D"Administration"> + <field-result name=3D"name" column=3D"fld_name"/> + </entity-result> + <column-result name=3D"taxPayerNumber"/> + </sql-result-set-mapping> + <attribute-override name=3D"ground"> + <column name=3D"fld_ground" unique=3D"true" scale=3D"2"/> + </attribute-override> + <association-override name=3D"referer"> + <join-column name=3D"referer_id" referenced-column-name=3D"= id"/> + </association-override> + ... + </entity> +</entity-mappings> + + + + discriminator-value / + discriminator-column: defines the discriminator value + and the column holding it when the SINGLE_TABLE inheritance + strategy is chosen + + + + named-query: defines named queries and + possibly the hints associated to them. Those definitions are + additive to the one defined in annotations, if two definitions + have the same name, the XML one has priority. + + + + named-native-query: defines an named + native query and its sql result set mapping. Alternatively, you + can define the result-class. Those definiti= ons + are additive to the one defined in annotations, if two definit= ions + have the same name, the XML one has priority. + + + + sql-result-set-mapping: describes the + result set mapping structure. You can define both entity and + column mappings. Those definitions are additive to the one def= ined + in annotations, if two definitions have the same name, the XML= one + has priority + + + + attribute-override / + association-override: defines a column or join column + overriding. This overriding is additive to the one defined in + annotations + + + + + Same applies for <embeddable> and + <mapped-superclass>. +
+ +
+ Property level metadata + + You can of course defines XML overriding for properties. If + metadata complete is defined, then additional properties (ie at the = Java + level) will be ignored. Otherwise, once you start overriding a prope= rty, + all annotations on the given property are ignored. All property level + metadata behave in entity/attributes, + mapped-superclass/attributes or + embeddable/attributes. + + <attributes> + <id name=3D"id"> + <column name=3D"fld_id"/> + <generated-value generator=3D"generator" strategy=3D"SEQUEN= CE"/> + <temporal>DATE</temporal> + <sequence-generator name=3D"generator" sequence-name=3D"seq= "/> + </id> + <version name=3D"version"/> + <embedded name=3D"embeddedObject"> + <attribute-override name"subproperty"> + <column name=3D"my_column"/> + </attribute-override> + </embedded> + <basic name=3D"status" optional=3D"false"> + <enumerated>STRING</enumerated> + </basic> + <basic name=3D"serial" optional=3D"true"> + <column name=3D"serialbytes"/> + <lob/> + </basic> + <basic name=3D"terminusTime" fetch=3D"LAZY"> + <temporal>TIMESTAMP</temporal> + </basic> + </attributes> + + You can override a property through id, + embedded-id, version, + embedded and basic. Each of th= ese + elements can have subelements accordingly: lob, + temporal, enumerated, + column. +
+ +
+ Association level metadata + + You can define XML overriding for associations. All association + level metadata behave in entity/attributes, + mapped-superclass/attributes or + embeddable/attributes. + + <attributes> + <one-to-many name=3D"players" fetch=3D"EAGER"> + <map-key name=3D"name"/> + <join-column name=3D"driver"/> + <join-column name=3D"number"/> + </one-to-many> + <many-to-many name=3D"roads" target-entity=3D"Administration"&g= t; + <order-by>maxSpeed</order-by> + <join-table name=3D"bus_road"> + <join-column name=3D"driver"/> + <join-column name=3D"number"/> + <inverse-join-column name=3D"road_id"/> + <unique-constraint> + <column-name>driver</column-name> + <column-name>number</column-name> + </unique-constraint> + </join-table> + </many-to-many> + <many-to-many name=3D"allTimeDrivers" mapped-by=3D"drivenBuses"= > + </attributes> + + You can override an association through + one-to-many, one-to-one, + many-to-one, and many-to-many. + Each of these elements can have subelements accordingly: + join-table (which can have + join-columns and + inverse-join-columns), + join-columns, + map-key, and order-by. + mapped-by and target-entity ca= n be + defined as attributes when it makes sense. Once again the structure = is + reflects the annotations structure. You can find all semantic + informations in the chapter describing annotations. +
+
+
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/fopdf.x= sl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/fopdf.xsl = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/fopdf.xsl = 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,519 @@ + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + Version: + + + + + + + + + + + + + + + + + + + + + + + + + -5em + -5em + + + + + + + + + + + + + + + Hibernate + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + = + + + + + + + + + + + + + + + + + + bold + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 0 + + 1 + + + + + + book toc + + = + + 3 + = + + + + + + = + + 5mm + 10mm + 10mm + + 15mm + 10mm + 0mm + + 18mm + 18mm + + + 0pc + + + + + 11 + + + 1.4 + + + + + + + 0.8em + + + + + + 17.4cm + + + + 4pt + 4pt + 4pt + 4pt + + = + + 0.1pt + 0.1pt + + + + + 1 + + + + + + + + + + + + + + + + + + + + = + + = + + + left + bold + + + pt + + + + + + + + + + + + = + + + bold + + + pt + + false + 0.4em + 0.6em + 0.8em + + + + = + + + 1em + 1em + 1em + 0.1em + 0.1em + 0.1em + #444444 + solid + 0.1pt + 0.5em + 0.5em + 0.5em + 0.5em + 0.5em + 0.5em + + + + 1 + + #F0F0F0 + + + + + + 1 + + + 90 + + + 0 + + + + + + + + + ( + + ) + + + + + + + + + figure after + example before + equation before + table before + procedure before + + = + + + 0.8em + 0.8em + 0.8em + 0.1em + 0.1em + 0.1em + + + + + + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html.css =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html.css = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html.css 2= 009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,97 @@ +A { + color: #003399; +} + +A:active { + color: #003399; +} + +A:visited { + color: #888888; +} + +P, OL, UL, LI, DL, DT, DD, BLOCKQUOTE { + color: #000000; +} + +TD, TH, SPAN { + color: #000000; +} + +BLOCKQUOTE { + margin-right: 0px; +} + + +H1, H2, H3, H4, H5, H6 { + color: #000000; + font-weight:500; + margin-top:10px; + padding-top:15px; +} + +TABLE { + border-collapse: collapse; + border-spacing:0; + border: 1px thin black; + empty-cells: hide; +} + +TD { + padding: 4pt; +} + +H1 { font-size: 150%; } +H2 { font-size: 140%; } +H3 { font-size: 110%; font-weight: bold; } +H4 { font-size: 110%; font-weight: bold;} +H5 { font-size: 100%; font-style: italic; } +H6 { font-size: 100%; font-style: italic; } + +TT { +font-size: 90%; + font-family: "Courier New", Courier, monospace; + color: #000000; +} + +PRE { +font-size: 100%; + padding: 5px; + border-style: solid; + border-width: 1px; + border-color: #CCCCCC; + background-color: #F4F4F4; +} + +UL, OL, LI { + list-style: disc; +} + +HR { + width: 100%; + height: 1px; + background-color: #CCCCCC; + border-width: 0px; + padding: 0px; + color: #CCCCCC; +} + +.variablelist { = + padding-top: 10; = + padding-bottom:10; = + margin:0; +} + +.itemizedlist, UL { = + padding-top: 0; = + padding-bottom:0; = + margin:0; = +} + +.term { = + font-weight:bold; +} + + + + = Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html.xsl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html.xsl = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html.xsl 2= 009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,84 @@ + + + + + +]> + + + = + + + = + + ../shared/css/html.css + + + 1 + 0 + 1 + 0 + + = + + + + book toc + + = + + 3 + = + = + + + 1 + + + + + + + 0 + + + 90 + + = + + + + figure after + example before + equation before + table before + procedure before + = + = + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html_ch= unk.xsl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html_chunk= .xsl (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/en/styles/html_chunk= .xsl 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,86 @@ + + + + + +]> + + + = + + + = + + '5' + '1' + ../shared/css/html.css + + + 1 + 0 + 1 + 0 + = + = + + + + book toc + + = + + 3 + + = + + + 1 + + + = + = + + + 0 + + + 90 + + = + + + + figure after + example before + equation before + table before + procedure before + = + = + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/images/hiberna= te_logo_a.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Property changes on: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/= images/hibernate_logo_a.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/master.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/master.xml = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/master.xml 2009-1= 1-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,82 @@ + + + + + + +]> + + + Hibernate Annotations + + Guide de r=EF=BF=BDf=EF=BF=BDrence + + 3.2.0.GA + + + + + + + + + + + + Pr=EF=BF=BDface + Traducteur(s): Vincent Ricard + + Hibernate, comme tous les autres outils de mapping objet/relatio= nnel, + n=EF=BF=BDcessite des m=EF=BF=BDta-donn=EF=BF=BDes qui r=EF=BF=BDgisse= nt la transformation des donn=EF=BF=BDes + d'une repr=EF=BF=BDsentation vers l'autre (et vice versa). Dans Hibern= ate 2.x, les + m=EF=BF=BDta-donn=EF=BF=BDes de mapping sont la plupart du temps d=EF= =BF=BDclar=EF=BF=BDes dans des fichiers + XML. Une autre option est XDoclet, qui utilise les annotations du code= source + Javadoc et un pr=EF=BF=BDprocesseur au moment de la compilation. Le m= =EF=BF=BDme genre + d'annotation est maintenant disponible avec le JDK standard, quoique p= lus + puissant et mieux pris en charge par les outils. IntelliJ IDEA et Ecli= pse, + par exemple, prennent en charge la compl=EF=BF=BDtion automatique et l= a coloration + syntaxique des annotations du JDK 5.0. Les annotations sont compil=EF= =BF=BDes en + bytecode et lues au moment de l'ex=EF=BF=BDcution (dans le cas d'Hiber= nate, au + d=EF=BF=BDmarrage) en utilisant la r=EF=BF=BDflexion, donc pas besoin = de fichiers XML + externes. + + La sp=EF=BF=BDcification EJB3 reconna=EF=BF=BDt l'int=EF=BF=BDr= =EF=BF=BDt et le succ=EF=BF=BDs du paradigme + du mapping objet/relationnel transparent. La sp=EF=BF=BDcification EJB= 3 standardise + les APIs de base et les m=EF=BF=BDta-donn=EF=BF=BDes requises par n'im= porte quel m=EF=BF=BDcanisme + de persistance objet/relationnel. Hibernate EntityManager + impl=EF=BF=BDmente les interfaces de programmation et les r=EF=BF=BDgl= es de cycle de vie + telles que d=EF=BF=BDfinies par la sp=EF=BF=BDcification de persistanc= e EJB3. Avec + Hibernate Annotations, ce wrapper impl=EF=BF=BDme= nte une + solution de persistance EJB3 compl=EF=BF=BDte (et autonome) au-dessus = du noyau + mature d'Hibernate. Vous pouvez utiliser soit les trois ensembles, soi= t les + annotations sans le cycle de vie et les interfaces de programmations E= JB3, + ou m=EF=BF=BDme Hibernate tout seul, selon les besoins techniques et f= onctionnels + de votre projet. Vous pouvez =EF=BF=BD tout moment recourir aux APIs n= atives + d'Hibernate ou m=EF=BF=BDme, si besoin est, =EF=BF=BD celles de JDBC e= t au SQL. + + Cette version est bas=EF=BF=BDe sur la derni=EF=BF=BDre version = de la sp=EF=BF=BDcification + EJB 3.0 / JPA (alias JSP-220) et prend en charge toutes les fonctionna= lit=EF=BF=BDs + de la sp=EF=BF=BDcification (dont certaines optionnelles). La plupart = des + fonctionnalit=EF=BF=BDs d'Hibernate et des extensions sont aussi dispo= nibles =EF=BF=BD + travers des annotations sp=EF=BF=BDcifiques =EF=BF=BD Hibernate. Bien = que la couverture + d'Hibernate en termes de fonctionnalit=EF=BF=BDs soit maintenant tr=EF= =BF=BDs grande, + certaines sont encore manquantes. Le but ultime est de tout couvrir. V= oir la + section JIRA "road map" pour plus d'informations. + + Si vous utilisiez une version pr=EF=BF=BDc=EF=BF=BDdente d'Hiber= nate Annotations, + veuillez regarder http://www.hibernate.org/371.html pour un= guide + de migration. + + + &setup; + + &entity; + + &xml-overriding; + + &validator; + + &lucene; + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/entity= .xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/entity.xm= l (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/entity.xm= l 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,3458 @@ + + + Entity Beans + + + Introduction + + Cette section couvre les annotations entity bean EJB 3.0 (alias = JPA) + et les extensions sp=EF=BF=BDcifiques =EF=BF=BD Hibernate. + + + + Mapping avec les annotations EJB3/JPA + + Les entit=EF=BF=BDs EJB3 sont des POJOs ordinaires. En fait, ils + repr=EF=BF=BDsentent exactement le m=EF=BF=BDme concept que les entit= =EF=BF=BDs de persistance + Hibernate. Leur mapping est d=EF=BF=BDfini =EF=BF=BD travers les annot= ations du JDK 5.0 + (une syntaxe de descripteur XML pour la surcharge est d=EF=BF=BDfinie = dans la + sp=EF=BF=BDcification EJB3). Les annotations peuvent =EF=BF=BDtre divi= s=EF=BF=BDes en deux + cat=EF=BF=BDgories, les annotations de mapping logique (vous permettan= t de d=EF=BF=BDcrire + le mod=EF=BF=BDle objet, les associations de classe, etc) et les annot= ations de + mapping physique (d=EF=BF=BDcrivant le sch=EF=BF=BDma physique, les ta= bles, les colonnes, + les index, etc). Nous m=EF=BF=BDlangerons les annotations des deux cat= =EF=BF=BDgories dans + les exemples de code. + + Les annotations EJB3 sont dans le package + javax.persistence.*. La plupart des IDE compatibles= JDK 5 + (comme Eclipse, IntelliJ IDEA et Netbeans) peuvent auto-compl=EF=BF=BD= ter les + interfaces et les attributes d'annotation pour vous (m=EF=BF=BDme sans= module "EJB3" + sp=EF=BF=BDcifique, puisque les annotations EJB3 sont des annotations = ordinaires de + JDK 5). + + Pour plus d'exemples concrets, lisez le tutorial EJB 3.0 de JBos= s ou + parcourez la suite de tests d'Hibernate Annotations. La plupart des te= sts + unitaires ont =EF=BF=BDt=EF=BF=BD con=EF=BF=BDus pour repr=EF=BF=BDsen= ter un exemple concret et =EF=BF=BDtre une + source d'inspiration. + + + D=EF=BF=BDclarer un entity bean + + Chaque classe POJO persistante li=EF=BF=BDe est un entity bean= et est + d=EF=BF=BDclar=EF=BF=BDe en utilisant l'annotation @Entity<= /literal> (au niveau + de la classe) : + + +(a)Entity +public class Flight implements Serializable { + Long id; + + @Id + public Long getId() { return id; } + + public void setId(Long id) { this.id =3D id; } +} + + + @Entity d=EF=BF=BDclare la classe comme un = entity bean + (ie une classe POJO persistante), @Id d=EF=BF=BDc= lare la + propri=EF=BF=BDt=EF=BF=BD identifiante de cet entity bean. Les autre= s d=EF=BF=BDclarations de + mapping sont implicites. Ce concept de d=EF=BF=BDclaration par excep= tion est + un composant essentiel de la nouvelle sp=EF=BF=BDcification EJB3 et = une + am=EF=BF=BDlioration majeure. La classe Flight est mapp=EF=BF=BDe su= r la table Flight, en + utilisant la colonne id comme colonne de la clef primaire. + + Selon que vous annotez des champs ou des m=EF=BF=BDthodes, le = type d'acc=EF=BF=BDs + utilis=EF=BF=BD par Hibernate sera field ou + property. La sp=EF=BF=BDcification EJB3 exige que= vous + d=EF=BF=BDclariez les annotations sur le type d'=EF=BF=BDl=EF=BF=BDm= ent qui sera acc=EF=BF=BDd=EF=BF=BD, + c'est-=EF=BF=BD-dire le getter si vous utilisez l'acc=EF=BF=BDs + property, le champ si vous utilisez l'acc=EF=BF= =BDs + field. M=EF=BF=BDlanger des EJB3 annotations dans= les champs et + les m=EF=BF=BDthodes devrait =EF=BF=BDtre =EF=BF=BDvit=EF=BF=BD. Hib= ernate devinera le type d'acc=EF=BF=BDs de + l'identifiant =EF=BF=BD partir de la position d'@Id ou + d'@EmbeddedId. + + + D=EF=BF=BDfinir la table + + @Table est positionn=EF=BF=BDe au niveau = de la classe ; + cela vous permet de d=EF=BF=BDfinir le nom de la table, du catalog= ue et du + sch=EF=BF=BDma pour le mapping de votre entity bean. Si aucune + @Table n'est d=EF=BF=BDfinie les valeurs par d= =EF=BF=BDfaut sont + utilis=EF=BF=BDes : le nom de la classe de l'entit=EF=BF=BD (sans = le nom de + package). + + +(a)Entity +(a)Table(name=3D"tbl_sky") +public class Sky implements Serializable { +... + + + L'=EF=BF=BDl=EF=BF=BDment @Table contient= aussi un attribut + schema et un attribut catalog, + si vous avez besoin de les d=EF=BF=BDfinir. Vous pouvez aussi d=EF= =BF=BDfinir des + contraintes d'unicit=EF=BF=BD sur la table en utilisant l'annotati= on + @UniqueConstraint en conjonction avec + @Table (pour une contrainte d'unicit=EF=BF=BD n= 'impliquant + qu'une seule colonne, r=EF=BF=BDf=EF=BF=BDrez-vous =EF=BF=BD @Column). + + @Table(name=3D"tbl_sky", + uniqueConstraints =3D {@UniqueConstraint(colum= nNames=3D{"month", "day"})} +) + + Une contrainte d'unicit=EF=BF=BD est appliqu=EF=BF=BDe au tu= ple {month, day}. + Notez que le tableau columnNames fait r=EF=BF= =BDf=EF=BF=BDrence aux + noms logiques des colonnes. + + Le nom logique d'une colonne est d=EF=BF=BDfini par l'impl= =EF=BF=BDmentation + de NamingStrategy d'Hibernate. La strat=EF=BF=BDgie de nommage EJB= 3 par d=EF=BF=BDfaut + utilise le nom de colonne physique comme nom de colonne logique. N= otez + qu'il peut =EF=BF=BDtre diff=EF=BF=BDrent du nom de la propri=EF= =BF=BDt=EF=BF=BD (si le nom de colonne + est explicite). A moins que vous surchargiez la strat=EF=BF=BDgie = de nommage, + vous ne devriez pas vous soucier de =EF=BF=BDa. + + + + Versionner pour un contr=EF=BF=BDle de concurrence optimist= e + + Vous pouvez ajouter un contr=EF=BF=BDle de concurrence optim= iste =EF=BF=BD un + entity bean en utilisant l'annotation + @Version : + + +(a)Entity +public class Flight implements Serializable { +... + @Version + @Column(name=3D"OPTLOCK") + public Integer getVersion() { ... } +} + + La propri=EF=BF=BDt=EF=BF=BD de version sera mapp=EF=BF=BDe = sur la colonne + OPTLOCK, et le gestionnaire d'entit=EF=BF=BDs l= 'utilisera + pour d=EF=BF=BDtecter des conflits lors des mises =EF=BF=BD jour (= pr=EF=BF=BDvenant des pertes + de donn=EF=BF=BDes lors de mises =EF=BF=BD jours que vous pourriez= voir avec la + strat=EF=BF=BDgie du last-commit-wins). + + La colonne de version peut =EF=BF=BDtre un num=EF=BF=BDrique= (solution + recommand=EF=BF=BDe) ou un timestamp comme pour la sp=EF=BF=BDcifi= cation EJB3. Hibernate + prend en charge n'importe quel type fourni que vous d=EF=BF=BDfini= ssez et + impl=EF=BF=BDmentez avec la classe UserVersionType + appropri=EF=BF=BDe. + + + + + Mapping de simples propri=EF=BF=BDt=EF=BF=BDs + + + D=EF=BF=BDclarer des mappings de propri=EF=BF=BDt=EF=BF=BDs= =EF=BF=BDl=EF=BF=BDmentaires + + Chaque propri=EF=BF=BDt=EF=BF=BD (champ ou m=EF=BF=BDthode) = non statique non transient + d'un entity bean est consid=EF=BF=BDr=EF=BF=BDe persistante, =EF= =BF=BD moins que vous l'annotiez + comme @Transient. Ne pas avoir d'annotation pour + votre propri=EF=BF=BDt=EF=BF=BD est =EF=BF=BDquivalent =EF=BF=BD l= 'annotation @Basic. + L'annotation @Basic vous permet de d=EF=BF=BDcl= arer la + strat=EF=BF=BDgie de r=EF=BF=BDcup=EF=BF=BDration pour une propri= =EF=BF=BDt=EF=BF=BD : + + public transient int counter; // propri=EF=BF=BDt= =EF=BF=BD transient + +private String firstname; // propri=EF=BF=BDt=EF=BF=BD persistante + +(a)Transient +String getLengthInMeter() { ... } // propri=EF=BF=BDt=EF=BF=BD transient + +String getName() {... } // propri=EF=BF=BDt=EF=BF=BD persistante + +(a)Basic +int getLength() { ... } // propri=EF=BF=BDt=EF=BF=BD persistante + +(a)Basic(fetch =3D FetchType.LAZY) +String getDetailedComment() { ... } // propri=EF=BF=BDt=EF=BF=BD persistan= te + +(a)Temporal(TemporalType.TIME) +java.util.Date getDepartureTime() { ... } // propri=EF=BF=BDt=EF=BF=BD per= sistante + +(a)Enumerated(EnumType.STRING) +Starred getNote() { ... } // enum persist=EF=BF=BDe en tant que String dan= s la base de donn=EF=BF=BDes + + counter, un champ transient, et + lengthInMeter, une m=EF=BF=BDthode annot=EF=BF= =BDe comme + @Transient, seront ignor=EF=BF=BDs par le gesti= onnaire + d'entit=EF=BF=BDs. Les propri=EF=BF=BDt=EF=BF=BDs name, + length, et firstname sont ma= pp=EF=BF=BDes + comme persistantes et =EF=BF=BD charger imm=EF=BF=BDdiatement (ce = sont les valeurs + par d=EF=BF=BDfaut pour les propri=EF=BF=BDt=EF=BF=BDs simples). L= a valeur de la propri=EF=BF=BDt=EF=BF=BD + detailedComment sera charg=EF=BF=BDe =EF=BF=BD = partir de la base de + donn=EF=BF=BDes d=EF=BF=BDs que la propri=EF=BF=BDt=EF=BF=BD de l'= entit=EF=BF=BD sera acc=EF=BF=BDd=EF=BF=BDe pour la premi=EF=BF=BDre + fois. En g=EF=BF=BDn=EF=BF=BDral vous n'avez pas besoin de marquer= de simples propri=EF=BF=BDt=EF=BF=BDs + comme "=EF=BF=BD charger =EF=BF=BD la demande" (NdT: lazy) (=EF=BF= =BD ne pas confondre avec la + r=EF=BF=BDcup=EF=BF=BDration d'association "lazy"). + + + Pour activer la r=EF=BF=BDcup=EF=BF=BDration =EF=BF=BD la = demande au niveau de la + propri=EF=BF=BDt=EF=BF=BD, vos classes doivent =EF=BF=BDtre inst= rument=EF=BF=BDes : du bytecode est + ajout=EF=BF=BD au code original pour activer cette fonctionnalit= =EF=BF=BD, veuillez + vous r=EF=BF=BDf=EF=BF=BDrer =EF=BF=BD la documentation de r=EF= =BF=BDf=EF=BF=BDrence d'Hibernate. Si vos + classes ne sont pas instrument=EF=BF=BDes, le chargement =EF=BF= =BD la demande au + niveau de la propri=EF=BF=BDt=EF=BF=BD est silencieusement ignor= =EF=BF=BD. + + + L'alternative recommand=EF=BF=BDe est d'utiliser la capacit= =EF=BF=BD de projection + de JPA-QL ou des requ=EF=BF=BDtes Criteria. + + EJB3 prend en charge le mapping de propri=EF=BF=BDt=EF=BF=BD= de tous les types + =EF=BF=BDl=EF=BF=BDmentaires pris en charge par Hibernate (tous le= s types de base Java, + leur wrapper respectif et les classes s=EF=BF=BDrialisables). Hibe= rnate + Annotations prend en charge le mapping des types Enum soit vers une + colonne ordinale (en stockant le num=EF=BF=BDro ordinal de l'enum)= , soit vers + une colonne de type cha=EF=BF=BDne de caract=EF=BF=BDres (en stock= ant la cha=EF=BF=BDne de + caract=EF=BF=BDres repr=EF=BF=BDsentant l'enum) : la repr=EF=BF=BD= sentation de la persistance, + par d=EF=BF=BDfaut ordinale, peut =EF=BF=BDtre surcharg=EF=BF=BDe = gr=EF=BF=BDce =EF=BF=BD l'annotation + @Enumerated comme montr=EF=BF=BD avec la propri= =EF=BF=BDt=EF=BF=BD + note de l'exemple. + + Dans les APIs core de Java, la pr=EF=BF=BDcision temporelle = n'est pas + d=EF=BF=BDfinie. Lors du traitement de donn=EF=BF=BDes temporelles= vous pourriez vouloir + d=EF=BF=BDcrire la pr=EF=BF=BDcision attendue dans la base de donn= =EF=BF=BDes. Les donn=EF=BF=BDes + temporelles peuvent avoir une pr=EF=BF=BDcision de type D= ATE, + TIME, ou TIMESTAMP (c'est-= =EF=BF=BD-dire + seulement la date, seulement l'heure, ou les deux). Utilisez + l'annotation @Temporal pour ajuster cela. + + @Lob indique que la propri=EF=BF=BDt=EF= =BF=BD devrait =EF=BF=BDtre + persist=EF=BF=BDe dans un Blob ou un Clob selon son type : + java.sql.Clob, + Character[], char[] = et + java.lang.String seront persist=EF=BF=BDs d= ans un Clob. + java.sql.Blob, Byte[], + byte[] et les types s=EF=BF=BDrialisables = seront + persist=EF=BF=BDs dans un Blob. + + +(a)Lob +public String getFullText() { + return fullText; +} + +(a)Lob +public byte[] getFullCode() { + return fullCode; +} + + + Si le type de la propri=EF=BF=BDt=EF=BF=BD impl=EF=BF=BDmente + java.io.Serializable et n'est pas un type de + base, et si la propri=EF=BF=BDt=EF=BF=BD n'est pas annot=EF=BF=BDe= avec @Lob, + alors le type Hibernate serializable est + utilis=EF=BF=BD. + + + + D=EF=BF=BDclarer des attributs de colonne + + La(les) colonne(s) utilis=EF=BF=BDe(s) pour mapper une propr= i=EF=BF=BDt=EF=BF=BD peuvent + =EF=BF=BDtre d=EF=BF=BDfinies en utilisant l'annotation @= Column. + Utilisez-la pour surcharger les valeurs par d=EF=BF=BDfaut (voir la + sp=EF=BF=BDcification EJB3 pour plus d'informations sur les valeur= s par d=EF=BF=BDfaut). + Vous pouvez utilisez cette annotation au niveau de la propri=EF=BF= =BDt=EF=BF=BD pour + celles qui sont : + + + + pas du tout annot=EF=BF=BDes + + + + annot=EF=BF=BDes avec @Basic + + + + annot=EF=BF=BDes avec @Version + + + + annot=EF=BF=BDes avec @Lob + + + + annot=EF=BF=BDes avec @Temporal + + + + annot=EF=BF=BDes avec + @org.hibernate.annotations.CollectionOfElements + (pour Hibernate uniquement) + + + + +(a)Entity +public class Flight implements Serializable { +... +(a)Column(updatable =3D false, name =3D "flight_name", nullable =3D false,= length=3D50) +public String getName() { ... } + + + La propri=EF=BF=BDt=EF=BF=BD name est map= p=EF=BF=BDe sur la colonne + flight_name, laquelle ne peut pas avoir de vale= ur + nulle, a une longueur de 50 et ne peut pas =EF=BF=BDtre mise =EF= =BF=BD jour (rendant + la propri=EF=BF=BDt=EF=BF=BD immuable). + + Cette annotation peut =EF=BF=BDtre appliqu=EF=BF=BDe aux pro= pri=EF=BF=BDt=EF=BF=BDs habituelles + ainsi qu'aux propri=EF=BF=BDt=EF=BF=BDs @Id ou + @Version. + + + + + + + + + + + + + + + + + + + + + + + + + @Column( + name=3D"columnName"; + boolean unique() default false; + boolean nullable() default true; + boolean insertable() default true; + boolean updatable() default true; + String columnDefinition() default ""; + String table() default ""; + int length() default 255; + int precision() default 0; // decimal precision + int scale() default 0; // decimal scale + + + + name (optionnel) : le nom de la col= onne + (par d=EF=BF=BDfaut le nom de la propri=EF=BF=BDt=EF=BF=BD)<= /para> + + + + unique (optionnel) : indique si la = colonne + fait partie d'une contrainte d'unicit=EF=BF=BD ou non (par d= =EF=BF=BDfaut + false) + + + + nullable (optionnel) : indique si la + colonne peut avoir une valeur nulle (par d=EF=BF=BDfaut fals= e). + + + + insertable (optionnel) : indique si= la + colonne fera partie de la commande insert (par d=EF=BF=BDfau= t true) + + + + updatable (optionnel) : indique si = la + colonne fera partie de la commande update (par d=EF=BF=BDfau= t true) + + + + columnDefinition (optionnel) : surc= harge + le fragment DDL sql pour cette colonne en particulier (non + portable) + + + + table (optionnel) : d=EF=BF=BDfinit= la table + cible (par d=EF=BF=BDfaut la table principale) + + + + length (optionne= l) : + longueur de la colonne (par d=EF=BF=BDfaut 255) + + + + precision + (optionnel) : pr=EF=BF=BDcision d=EF=BF=BDcimale de la colon= ne (par d=EF=BF=BDfaut + 0) + + + + scale (optionnel= ) : + =EF=BF=BDchelle d=EF=BF=BDcimale de la colonne si n=EF=BF=BD= cessaire (par d=EF=BF=BDfaut 0) + + + + + + + Objets embarqu=EF=BF=BDs (alias composants) + + Il est possible de d=EF=BF=BDclarer un composant embarqu=EF= =BF=BD =EF=BF=BD l'int=EF=BF=BDrieur + d'une entit=EF=BF=BD et m=EF=BF=BDme de surcharger le mapping de s= es colonnes. Les + classes de composant doivent =EF=BF=BDtre annot=EF=BF=BDes au nive= au de la classe avec + l'annotation @Embeddable. Il est possible de + surcharger le mapping de colonne d'un objet embarqu=EF=BF=BD pour = une entit=EF=BF=BD + particuli=EF=BF=BDre en utilisant les annotations + @Embedded et @AttributeOverride + sur la propri=EF=BF=BDt=EF=BF=BD associ=EF=BF=BDe : + + +(a)Entity +public class Person implements Serializable { + + // Composant persistant utilisant les valeurs par d=EF=BF=BDfaut + Address homeAddress; + + @Embedded + @AttributeOverrides( { + @AttributeOverride(name=3D"iso2", column =3D @Column(name=3D"b= ornIso2") ), + @AttributeOverride(name=3D"name", column =3D @Column(name=3D"b= ornCountryName") ) + } ) + Country bornIn; + ... +} + + + +(a)Embeddable +public class Address implements Serializable { + String city; + Country nationality; // par de surcharge ici +} + + + +(a)Embeddable +public class Country implements Serializable { + private String iso2; + @Column(name=3D"countryName") private String name; + + public String getIso2() { return iso2; } + public void setIso2(String iso2) { this.iso2 =3D iso2; } + + + public String getName() { return name; } + public void setName(String name) { this.name =3D name; } + ... +} + + + Un objet embarquable h=EF=BF=BDrite du type d'acc=EF=BF=BDs = de son entit=EF=BF=BD + d'appartenance (notez que vous pouvez surcharger cela en utilisant= les + annotations sp=EF=BF=BDcifiques =EF=BF=BD Hibernate @Acce= ssType, + voir ). + + L'entity bean Person a deux propri=EF=BF= =BDt=EF=BF=BDs + composant, homeAddress et + bornIn. La propri=EF=BF=BDt=EF=BF=BD h= omeAddress + n'a pas =EF=BF=BDt=EF=BF=BD annot=EF=BF=BDe, mais Hibernate devine= ra que c'est un composant + persistant en cherchant l'annotation @Embeddable + dans la classe Address. Nous surchargeons aussi le mapping d'un no= m de + colonne (pour bornCountryName) avec les annotat= ions + @Embedded et @AttributeOverride + pour chaque attribut mapp=EF=BF=BD de Country. = Comme vous + pouvez le voir, Country est aussi un composant + imbriqu=EF=BF=BD de Address, utilisant de nouve= au la + d=EF=BF=BDtection automatique d'Hibernate et les valeurs par d=EF= =BF=BDfaut EJB3. + Surcharger des colonnes d'objets embarqu=EF=BF=BDs d'objets (eux-m= =EF=BF=BDmes) + embarqu=EF=BF=BDs n'est actuellement pas pris en charge par la sp= =EF=BF=BDcification + EJB3, cependant, Hibernate Annotations le prend en charge =EF=BF= =BD travers des + expressions s=EF=BF=BDpar=EF=BF=BDes par des points. + + @Embedded + @AttributeOverrides( { + @AttributeOverride(name=3D"city", column =3D @Column(name=3D"f= ld_city") ), + @AttributeOverride(name=3D"nationality= .iso2", column =3D @Column(name=3D"nat_Iso2") ), + @AttributeOverride(name=3D"nationality= .name", column =3D @Column(name=3D"nat_CountryName") ) + // les colonnes de nationality dans homeAddress sont surcharg= =EF=BF=BDes + } ) + Address homeAddress;Hibernate Annotations prend en ch= arge + une fonctionnalit=EF=BF=BD de plus qui n'est pas explicitement pri= se en charge + par la sp=EF=BF=BDcification EJB3. Vous pouvez annoter un objet em= barqu=EF=BF=BD avec + l'annotation + @MappedSuperclass pour rendre les propri=EF=BF= =BDt=EF=BF=BDs de la + classe parente persistantes (voir @MappedSuperclass + pour plus d'informations). + + Alors que ce n'est pas pris en charge par la sp=EF=BF=BDcifi= cation EJB3, + Hibernate Annotations vous permet d'utiliser les annotations + d'association dans un objet embarquable (ie @*ToOne + ou @*ToMany). Pour surcharger les colonnes de + l'association vous pouvez utiliser + @AssociationOverride. + + Si vous voulez avoir le m=EF=BF=BDme type d'objet embarquabl= e deux fois + dans la m=EF=BF=BDme entit=EF=BF=BD, le nom de colonne par d=EF=BF= =BDfaut ne fonctionnera pas : + au moins une des colonnes devra =EF=BF=BDtre explicit=EF=BF=BDe. H= ibernate va au-del=EF=BF=BD + de la sp=EF=BF=BDcification EJB3 et vous permet d'am=EF=BF=BDliore= r le m=EF=BF=BDcanisme par + d=EF=BF=BDfaut avec NamingStrategy. + DefaultComponentSafeNamingStrategy est une = petite + am=EF=BF=BDlioration par rapport =EF=BF=BD la strat=EF=BF=BDgie pa= r d=EF=BF=BDfaut + EJB3NamingStrategy qui permet aux objets + embarqu=EF=BF=BDs de fonctionner avec leur valeur par d=EF=BF=BDfa= ut m=EF=BF=BDme s'ils sont + utilis=EF=BF=BDs deux fois dans la m=EF=BF=BDme entit=EF=BF=BD. + + + + Valeurs par d=EF=BF=BDfaut des propri=EF=BF=BDt=EF=BF=BDs n= on annot=EF=BF=BDes + + Si une propri=EF=BF=BDt=EF=BF=BD n'est pas annot=EF=BF=BDe, = les r=EF=BF=BDgles suivantes + s'appliquent : + + + + Si la propri=EF=BF=BDt=EF=BF=BD est de type simple, elle est m= app=EF=BF=BDe comme @Basic + + + + Sinon, si le type de la propri=EF=BF=BDt=EF=BF=BD est annot=EF= =BF=BD comme @Embeddable, + elle est mapp=EF=BF=BDe comme @Embedded + + + + Sinon, si le type de la propri=EF=BF=BDt=EF=BF=BD est Serializ= able, elle est mapp=EF=BF=BDe + comme @Basic vers une colonne contenant l'objet sous sa forme + s=EF=BF=BDrialis=EF=BF=BDe + + + + Sinon, si le type de la propri=EF=BF=BDt=EF=BF=BD est java.s= ql.Clob ou + java.sql.Blob, elle est mapp=EF=BF=BDe comme @Lob avec le Lo= bType + appropri=EF=BF=BD + + + + + + + Mapper des propri=EF=BF=BDt=EF=BF=BDs identifiantes + + L'annotation @Id vous permet de d=EF=BF=BDf= inir quelle + propri=EF=BF=BDt=EF=BF=BD identifie votre entity bean. Cette propri= =EF=BF=BDt=EF=BF=BD peut =EF=BF=BDtre + positionn=EF=BF=BDe par l'application elle-m=EF=BF=BDme ou g=EF=BF= =BDn=EF=BF=BDr=EF=BF=BDe par Hibernate + (pr=EF=BF=BDf=EF=BF=BDr=EF=BF=BD). Vous pouvez d=EF=BF=BDfinir la st= rat=EF=BF=BDgie de g=EF=BF=BDn=EF=BF=BDration de l'identifiant + gr=EF=BF=BDce =EF=BF=BD l'annotation @GeneratedValue : + + + + AUTO - soit la colonne identity, soit la s=EF=BF=BDquence, soit= la table + selon la base de donn=EF=BF=BDes sous-jacente + + + + TABLE - table contenant l'id + + + + IDENTITY - colonne identity + + + + SEQUENCE - s=EF=BF=BDquence + + + + Hibernate fournit plus de g=EF=BF=BDn=EF=BF=BDrateurs d'identi= fiant que les simples + g=EF=BF=BDn=EF=BF=BDrateurs EJB3. V=EF=BF=BDrifiez pour plus + d'informations. + + L'exemple suivant montre un g=EF=BF=BDn=EF=BF=BDrateur par s= =EF=BF=BDquence utilisant la + configuration SEQ_STORE (voir plus bas) : + + +(a)Id @GeneratedValue(strategy=3DGenerationType.SEQUENCE, generator=3D"SEQ= _STORE") +public Integer getId() { ... } + + + L'exemple suivant utilise le g=EF=BF=BDn=EF=BF=BDrateur identi= ty : + + +(a)Id @GeneratedValue(strategy=3DGenerationType.IDENTITY) +public Long getId() { ... } + + + Le g=EF=BF=BDn=EF=BF=BDrateur AUTO est le t= ype pr=EF=BF=BDf=EF=BF=BDr=EF=BF=BD pour les + applications portables (vers diff=EF=BF=BDrentes base de donn=EF=BF= =BDes). La + configuration de la g=EF=BF=BDn=EF=BF=BDration d'identifiant peut = =EF=BF=BDtre partag=EF=BF=BDe par + diff=EF=BF=BDrents mappings @Id avec l'attribut d= u g=EF=BF=BDn=EF=BF=BDrateur. + Il y a diff=EF=BF=BDrentes configurations disponibles avec + @SequenceGenerator et + @TableGenerator. La port=EF=BF=BDe d'un g=EF=BF= =BDn=EF=BF=BDrateur peut =EF=BF=BDtre + l'application ou la classe. Les g=EF=BF=BDn=EF=BF=BDrateurs d=EF=BF= =BDfinis dans les classes ne + sont pas visibles =EF=BF=BD l'ext=EF=BF=BDrieur de la classe et peuv= ent surcharger les + g=EF=BF=BDn=EF=BF=BDrateurs de niveau applicatif. Les g=EF=BF=BDn=EF= =BF=BDrateurs de niveau applicatif + sont d=EF=BF=BDfinis au niveau XML (voir + ) : + + <table-generator name=3D"EMP_GEN" + table=3D"GENERATOR_TABLE" + pk-column-name=3D"key" + value-column-name=3D"hi" + pk-column-value=3D"EMP" + allocation-size=3D"20"/> + +// et l'annotation =EF=BF=BDquivalente + +(a)javax.persistence.TableGenerator( + name=3D"EMP_GEN", + table=3D"GENERATOR_TABLE", + pkColumnName =3D "key", + valueColumnName =3D "hi" + pkColumnValue=3D"EMP", + allocationSize=3D20 +) + +<sequence-generator name=3D"SEQ_GEN" + sequence-name=3D"my_sequence" + allocation-size=3D"20"/> + +// et l'annotation =EF=BF=BDquivalente + +(a)javax.persistence.SequenceGenerator( + name=3D"SEQ_GEN", + sequenceName=3D"my_sequence", + allocationSize=3D20 +) + + + Si JPA XML (comme META-INF/orm.xml) est u= tilis=EF=BF=BD + pour d=EF=BF=BDfinir les g=EF=BF=BDn=EF=BF=BDrateurs, EMP_G= EN et + SEQ_GEN sont des g=EF=BF=BDn=EF=BF=BDrateurs de n= iveau applicatif. + EMP_GEN d=EF=BF=BDfinit un g=EF=BF=BDn=EF=BF=BDra= teur d'identifiant bas=EF=BF=BD sur + une table utilisant l'algorithme hilo avec un max_lo de + 20. La valeur haute est conserv=EF=BF=BDe dans une table + "GENERATOR_TABLE". L'information est gard=EF=BF= =BDe dans une + ligne o=EF=BF=BD la colonne pkColumnName ("clef")= est =EF=BF=BDgale =EF=BF=BD + pkColumnValue "EMP" et une col= onne + valueColumnName "hi" contient = la + prochaine valeur haute utilis=EF=BF=BDe. + + SEQ_GEN d=EF=BF=BDfinit un g=EF=BF=BDn=EF= =BF=BDrateur par s=EF=BF=BDquence + utilisant une s=EF=BF=BDquence nomm=EF=BF=BDe my_sequence. La taille + d'allocation utilis=EF=BF=BDe pour cet algorithme hilo bas=EF=BF=BD = sur une s=EF=BF=BDquence est + 20. Notez que cette version d'Hibernate Annotations ne g=EF=BF=BDre = pas + initialValue dans le g=EF=BF=BDn=EF=BF=BDrateur p= ar s=EF=BF=BDquence. + La taille par d=EF=BF=BDfaut de l'allocation est 50, donc si vous vo= ulez utiliser + une s=EF=BF=BDquence et r=EF=BF=BDcup=EF=BF=BDrer la valeur chaque f= ois, vous devez positionner + la taille de l'allocation =EF=BF=BD 1. + + + La d=EF=BF=BDfinition au niveau package n'est plus prise en = charge par la + sp=EF=BF=BDcification EJB 3.0. Vous pouvez cependant utiliser + @GenericGenerator au niveau du package (voir ). + + + Le prochain exemple montre la d=EF=BF=BDfinition d'un g=EF=BF= =BDn=EF=BF=BDrateur par + s=EF=BF=BDquence dans la port=EF=BF=BDe d'une classe : + + +(a)Entity +(a)javax.persistence.SequenceGenerator( + name=3D"SEQ_STORE", + sequenceName=3D"my_sequence" +) +public class Store implements Serializable { + private Long id; + + @Id @GeneratedValue(strategy=3DGenerationType.SEQUENCE, generator=3D"S= EQ_STORE") + public Long getId() { return id; } +} + + + Cette classe utilisera une s=EF=BF=BDquence nomm=EF=BF=BDe my_= sequence et le + g=EF=BF=BDn=EF=BF=BDrateur SEQ_STORE n'est pas visible dans les autr= es classes. Notez que + vous pouvez regarder les tests unitaires d'Hibernate Annotations dan= s le + package org.hibernate.test.metadata.id pour plus d'exemples. + + Vous pouvez d=EF=BF=BDfinir une clef primaire compos=EF=BF=BDe= =EF=BF=BD travers diff=EF=BF=BDrentes + syntaxes : + + + + annote la propri=EF=BF=BDt=EF=BF=BD du composant comme @Id et r= end la classe du + composant @Embeddable + + + + annote la propri=EF=BF=BDt=EF=BF=BD du composant comme @Embedde= dId + + + + annote la classe comme @IdClass et annote chaque propri=EF=BF= =BDt=EF=BF=BD de + l'entit=EF=BF=BD impliqu=EF=BF=BDe dans la clef primaire avec @= Id + + + + Bien qu'assez commun pour le d=EF=BF=BDveloppeur EJB2, + @IdClass est probablement nouveau pour les utilis= ateurs + d'Hibernate. La classe de la clef primaire compos=EF=BF=BDe correspo= nd aux + multiples champs ou propri=EF=BF=BDt=EF=BF=BDs de l'entit=EF=BF=BD ;= de plus, les noms des champs + ou propri=EF=BF=BDt=EF=BF=BDs de la clef primaire et ceux de l'entit= =EF=BF=BD doivent + correspondre ; et enfin, leur type doit =EF=BF=BDtre le m=EF=BF=BDme= . Regardons un + exemple : + + @Entity +@IdClass(FootballerPk.class) +public class Footballer { + // partie de la clef + @Id public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + // partie de la clef + @Id public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + public String getClub() { + return club; + } + + public void setClub(String club) { + this.club =3D club; + } + + // impl=EF=BF=BDmentation appropri=EF=BF=BDe de equals() et hashCode() +} + +(a)Embeddable +public class FootballerPk implements Serializable { + // m=EF=BF=BDme nom et m=EF=BF=BDme type que dans Footballer + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + // m=EF=BF=BDme nom et m=EF=BF=BDme type que dans Footballer + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + // impl=EF=BF=BDmentation appropri=EF=BF=BDe de equals() et hashCode() +} + + + Comme vous pouvez le voir, @IdClass pointe = vers + la classe de la clef primaire correspondante. + + Bien que ce ne soit pas pris en charge par la sp=EF=BF=BDcific= ation EJB3, + Hibernate vous permet de d=EF=BF=BDfinir des associations =EF=BF=BD = l'int=EF=BF=BDrieur d'un + identifiant compos=EF=BF=BD. Pour cela, utilisez simplement les anno= tations + habituelles. + + @Entity +(a)AssociationOverride( name=3D"id.channel", joinColumns =3D @JoinColumn(n= ame=3D"chan_id") ) +public class TvMagazin { + @EmbeddedId public TvMagazinPk id; + @Temporal(TemporalType.TIME) Date time; +} + +(a)Embeddable +public class TvMagazinPk implements Serializable { + @ManyToOne + public Channel channel; + public String name; + @ManyToOne + public Presenter presenter; +} + + + + + Mapper l'h=EF=BF=BDritage + + EJB3 prend en charge les trois types d'h=EF=BF=BDritage : + + + + Strat=EF=BF=BDgie d'une table par classe concr=EF=BF=BDte : l'= =EF=BF=BDl=EF=BF=BDment + <union-class> dans Hibernate + + + + Strat=EF=BF=BDgie d'une seule table par hi=EF=BF=BDrarchie de = classe : l'=EF=BF=BDl=EF=BF=BDment + <subclass> dans Hibernate + + + + Strat=EF=BF=BDgie d'une table par classe fille : l'=EF=BF=BDl= =EF=BF=BDment + <joined-subclass> dans Hibernate + + + + La strat=EF=BF=BDgie choisie est d=EF=BF=BDclar=EF=BF=BDe au n= iveau de la classe de l'entit=EF=BF=BD + la plus haute dans la hi=EF=BF=BDrarhie en utilisant l'annotation + @Inheritance. + + + Annoter des interfaces n'est pour le moment pas pris en + charge. + + + + Une table par classe concr=EF=BF=BDte + + Cette strat=EF=BF=BDgie a beaucoup d'inconv=EF=BF=BDnients (= surtout avec les + requ=EF=BF=BDtes polymorphiques et les associations) expliqu=EF=BF= =BDs dans la + sp=EF=BF=BDcification EJB3, la documentation de r=EF=BF=BDf=EF=BF= =BDrence d'Hibernate, Hibernate + in Action, et plusieurs autres endroits. Hibernate en contourne la + plupart en impl=EF=BF=BDmentant cette strat=EF=BF=BDgie en utilisa= nt des requ=EF=BF=BDtes + SQL UNION. Elle est habituellement utilis=EF=BF= =BDe pour le + niveau le plus haut d'une hi=EF=BF=BDrarchie d'h=EF=BF=BDritage :<= /para> + + +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.TABLE_PER_CLASS) +public class Flight implements Serializable { + + + Cette strat=EF=BF=BDgie prend en charge les associations de = un vers + plusieurs bidirectionnelles. Cette strat=EF=BF=BDgie ne prend pas = en charge + la strat=EF=BF=BDgie de g=EF=BF=BDn=EF=BF=BDrateur IDENTI= TY : l'identifiant + doit =EF=BF=BDtre partag=EF=BF=BD par plusieurs tables. Par cons= =EF=BF=BDquent, lors de + l'utilisation de cette strat=EF=BF=BDgie, vous ne devriez pas util= isez + AUTO ni IDENTITY. + + + + Une seule table par hi=EF=BF=BDrarchie de classe + + Toutes les propri=EF=BF=BDt=EF=BF=BDs de toutes les classes = parentes et classes + filles sont mapp=EF=BF=BDes dans la m=EF=BF=BDme table, les instan= ces sont diff=EF=BF=BDrenci=EF=BF=BDes + par une colonne sp=EF=BF=BDciale discriminante : + + +(a)Entity +(a)Inheritance(strategy=3DInheritanceType.SINGLE_TABLE) +(a)DiscriminatorColumn( + name=3D"planetype", + discriminatorType=3DDiscriminatorType.STRING +) +(a)DiscriminatorValue("Plane") +public class Plane { ... } + +(a)Entity +(a)DiscriminatorValue("A320") +public class A320 extends Plane { ... } + + + Plane est la classe parente, elle d= =EF=BF=BDfinit + la strat=EF=BF=BDgie d'h=EF=BF=BDritage InheritanceType.S= INGLE_TABLE. + Elle d=EF=BF=BDfinit aussi la colonne discriminante avec l'annotat= ion + @DiscriminatorColumn, une colonne discriminante= peut + aussi d=EF=BF=BDfinir le type du discriminant. Finalement, l'annot= ation + @DiscriminatorValue d=EF=BF=BDfinit la valeur u= tilis=EF=BF=BDe pour + diff=EF=BF=BDrencier une classe dans la hi=EF=BF=BDrarchie. Tous c= es attributs ont des + valeurs par d=EF=BF=BDfaut sens=EF=BF=BDes. Le nom par d=EF=BF=BDf= aut de la colonne + discriminante est DTYPE. La valeur discriminant= e par + d=EF=BF=BDfaut est le nom de l'entit=EF=BF=BD (comme d=EF=BF=BDfin= i dans + @Entity.name) avec le type + DiscriminatorType.STRING. A320 + est une classe fille ; vous devez seulement d=EF=BF=BDfinir la val= eur + discriminante si vous ne voulez pas utiliser la valeur par d=EF=BF= =BDfaut. La + strat=EF=BF=BDgie et le type du discriminant sont implicites. + + @Inheritance et + @DiscriminatorColumn devraient seulement =EF=BF= =BDtre + d=EF=BF=BDfinies sur l'entit=EF=BF=BD la plus haute de la hi=EF=BF= =BDrarchie. + + + + Une table par classe fille + + Les annotations @PrimaryKeyJoinColumn et + @PrimaryKeyJoinColumns d=EF=BF=BDfinissent la (= les) clef(s) + primaire(s) de la table de la classe fille jointe : + + +(a)Entity +(a)Inheritance(strategy=3DInheritanceType.JOINED) +public class Boat implements Serializable { ... } + +(a)Entity +public class Ferry extends Boat { ... } + +(a)Entity +(a)PrimaryKeyJoinColumn(name=3D"BOAT_ID") +public class AmericaCupClass extends Boat { ... } + + + Toutes les entit=EF=BF=BDs ci-dessus utilisent la strat=EF= =BF=BDgie + JOINED, la table Ferry est j= ointe + avec la table Boat en utilisant les m=EF=BF=BDm= es noms de + clef primaire. La table AmericaCupClass est joi= nte + avec Boat en utilisant la condition de jointure + Boat.id =3D AmericaCupClass.BOAT_ID. + + + + H=EF=BF=BDritage de propri=EF=BF=BDt=EF=BF=BDs des classes = parentes + + Il est parfois utile de partager des propri=EF=BF=BDt=EF=BF= =BDs communes =EF=BF=BD travers + une classe technique ou m=EF=BF=BDtier sans l'inclure comme une en= tit=EF=BF=BD + habituelle (c'est-=EF=BF=BD-dire aucune table sp=EF=BF=BDcifique p= our cette entit=EF=BF=BD). + Pour cela, vous pouvez les mapper comme + @MappedSuperclass. + + @MappedSuperclass +public class BaseEntity { + @Basic + @Temporal(TemporalType.TIMESTAMP) + public Date getLastUpdate() { ... } + public String getLastUpdater() { ... } + ... +} + +(a)Entity class Order extends BaseEntity { + @Id public Integer getId() { ... } + ... +} + + En base de donn=EF=BF=BDes, cette hi=EF=BF=BDrarchie sera re= pr=EF=BF=BDsent=EF=BF=BDe comme une + table Order ayant les colonnes id, + lastUpdate et lastUpdater. + Les mappings de propri=EF=BF=BDt=EF=BF=BD de la classe parente emb= arqu=EF=BF=BDe sont copi=EF=BF=BDs + dans les classes filles de l'entit=EF=BF=BD. Souvenez-vous que la = classe parente + embarquable n'est cependant pas la racine de la hi=EF=BF=BDrarchie= . + + + Les propri=EF=BF=BDt=EF=BF=BDs des classes parentes non ma= pp=EF=BF=BDes comme + @MappedSuperclass sont ignor=EF=BF=BDes. + + + + Le type d'acc=EF=BF=BDs (champ ou m=EF=BF=BDthode) est h= =EF=BF=BDrit=EF=BF=BD de l'entit=EF=BF=BD + racine, =EF=BF=BD moins que vous utilisiez l'annotation Hibernate + @AccessType. + + + + La m=EF=BF=BDme notion peut =EF=BF=BDtre appliqu=EF=BF=BDe= aux objets + @Embeddable pour persister des propri=EF=BF= =BDt=EF=BF=BDs de leurs + classes parentes. Vous avez aussi besoin d'utiliser + @MappedSuperclass pour faire =EF=BF=BDa (cepe= ndant cela ne + devrait pas =EF=BF=BDtre consid=EF=BF=BDr=EF=BF=BD comme une fon= ctionnalit=EF=BF=BD EJB3 + standard). + + + + Il est permis de marquer une classe comme + @MappedSuperclass dans le milieu d'une hi=EF= =BF=BDrarchie + d'h=EF=BF=BDritage mapp=EF=BF=BDe. + + + + Toute classe de la hi=EF=BF=BDrarchie non annot=EF=BF=BDe = avec + @MappedSuperclass ou @Entity + sera ignor=EF=BF=BDe. + + + Vous pouvez surcharger des colonnes d=EF=BF=BDfinies dans de= s entit=EF=BF=BDs + parentes au niveau de l'entit=EF=BF=BD racine en utilisant l'annot= ation + @AttributeOverride. + + @MappedSuperclass +public class FlyingObject implements Serializable { + + public int getAltitude() { + return altitude; + } + + @Transient + public int getMetricAltitude() { + return metricAltitude; + } + + @ManyToOne + public PropulsionType getPropulsion() { + return metricAltitude; + } + ... +} + +(a)Entity +(a)AttributeOverride( name=3D"altitude", column =3D @Column(name=3D"fld_al= titude") ) +(a)AssociationOverride( name=3D"propulsion", joinColumns =3D @JoinColumn(n= ame=3D"fld_propulsion_fk") ) +public class Plane extends FlyingObject { + ... +} + + La propri=EF=BF=BDt=EF=BF=BD altitude ser= a persist=EF=BF=BDe dans la + colonne fld_altitude de la table + Plane et l'association propulsion + sera mat=EF=BF=BDrialis=EF=BF=BDe dans la colonne de clef =EF=BF= =BDtrang=EF=BF=BDre + fld_propulsion_fk. + + Vous pouvez d=EF=BF=BDfinir @AttributeOverride(s) et + @AssociationOverride(s) sur des classes + @Entity, des classes + @MappedSuperclass et des propri=EF=BF=BDt=EF=BF= =BDs pointant vers un + objet @Embeddable. + + + + + Mapper des associations/relations d'entity beans + + + One-to-one + + Vous pouvez associer des entity beans avec une relation one-= to-one + en utilisant @OneToOne. Il y a trois cas pour l= es + associations one-to-one : soit les entit=EF=BF=BDs associ=EF=BF=BD= es partagent les m=EF=BF=BDmes + valeurs de clef primaire, soit une clef =EF=BF=BDtrang=EF=BF=BDre = est d=EF=BF=BDtenue par une + des entit=EF=BF=BDs (notez que cette colonne de clef =EF=BF=BDtran= g=EF=BF=BDre dans la base de + donn=EF=BF=BDes devrait =EF=BF=BDtre avoir une contrainte d'unicit= =EF=BF=BD pour simuler la + cardinalit=EF=BF=BD one-to-one), soit une table d'association est = utilis=EF=BF=BDe pour + stocker le lien entre les 2 entit=EF=BF=BDs (une contrainte d'unic= it=EF=BF=BD doit =EF=BF=BDtre + d=EF=BF=BDfinie sur chaque clef =EF=BF=BDtrang=EF=BF=BDre pour ass= urer la cardinalit=EF=BF=BD un =EF=BF=BD + un). + + Tout d'abord, nous mappons une v=EF=BF=BDritable association= one-to-one en + utilisant des clefs primaires partag=EF=BF=BDes : + + +(a)Entity +public class Body { + @Id + public Long getId() { return id; } + + @OneToOne(cascade =3D CascadeType.ALL) + @PrimaryKeyJoinColumn + public Heart getHeart() { + return heart; + } + ... +} + + + +(a)Entity +public class Heart { + @Id + public Long getId() { ...} +} + + + L'association un =EF=BF=BD un est activ=EF=BF=BDe en utilisa= nt l'annotation + @PrimaryKeyJoinColumn. + + Dans l'exemple suivant, les entit=EF=BF=BDs associ=EF=BF=BDe= s sont li=EF=BF=BDes =EF=BF=BD travers + une clef =EF=BF=BDtrang=EF=BF=BDre : + + +(a)Entity +public class Customer implements Serializable { + @OneToOne(cascade =3D CascadeType.ALL) + @JoinColumn(name=3D"passport_fk") + public Passport getPassport() { + ... + } + +(a)Entity +public class Passport implements Serializable { + @OneToOne(mappedBy =3D "passport") + public Customer getOwner() { + ... +} + + + Un Customer est li=EF=BF=BD =EF=BF=BD= un + Passport, avec une colonne de clef =EF=BF= =BDtrang=EF=BF=BDre + nomm=EF=BF=BDe passport_fk dans la table + Customer. La colonne de jointure est d=EF=BF=BD= clar=EF=BF=BDe avec + l'annotation @JoinColumn qui ressemble =EF=BF= =BD l'annotation + @Column. Elle a un param=EF=BF=BDtre de plus no= mm=EF=BF=BD + referencedColumnName. Ce param=EF=BF=BDtre d=EF= =BF=BDclare la colonne + dans l'entit=EF=BF=BD cible qui sera utilis=EF=BF=BDe pour la join= ture. Notez que lors + de l'utilisation de referencedColumnName vers u= ne + colonne qui ne fait pas partie de la clef primaire, la classe asso= ci=EF=BF=BDe + doit =EF=BF=BDtre Serializable. Notez aussi= que + referencedColumnName doit =EF=BF=BDtre mapp=EF= =BF=BD sur une + propri=EF=BF=BDt=EF=BF=BD ayant une seule colonne lorsqu'elle poin= te vers une colonne + qui ne fait pas partie de la clef primaire (d'autres cas pourraien= t ne + pas fonctionnner). + + L'association peut =EF=BF=BDtre bidirectionnelle. Dans une r= elation + bidirectionnelle, une des extr=EF=BF=BDmit=EF=BF=BDs (et seulement= une) doit =EF=BF=BDtre la + propri=EF=BF=BDtaire : la propri=EF=BF=BDtaire est responsable de = la mise =EF=BF=BD jour des + colonnes de l'association. Pour d=EF=BF=BDclarer une extr=EF=BF=BD= mit=EF=BF=BD comme + non responsable de la relation, l'attribut + mappedBy est utilis=EF=BF=BD. + mappedBy r=EF=BF=BDf=EF=BF=BDrence le nom de la= propri=EF=BF=BDt=EF=BF=BD de + l'association du c=EF=BF=BDt=EF=BF=BD du propri=EF=BF=BDtaire. Dan= s notre cas, c'est + passport. Comme vous pouvez le voir, vous ne de= vez + (absolument) pas d=EF=BF=BDclarer la colonne de jointure puisqu'el= le a d=EF=BF=BDj=EF=BF=BD =EF=BF=BDt=EF=BF=BD + d=EF=BF=BDclar=EF=BF=BDe du c=EF=BF=BDt=EF=BF=BD du propri=EF=BF= =BDtaire. + + Si aucune @JoinColumn n'est d=EF=BF=BDcla= r=EF=BF=BDe du c=EF=BF=BDt=EF=BF=BD du + propri=EF=BF=BDtaire, les valeurs par d=EF=BF=BDfaut s'appliquent.= Une(des) colonne(s) + de jointure sera(ont) cr=EF=BF=BD=EF=BF=BDe(s) dans la table propr= i=EF=BF=BDtaire, et son(leur) + nom sera la concat=EF=BF=BDnation du nom de la relation du c=EF=BF= =BDt=EF=BF=BD propri=EF=BF=BDtaire, + _ (underscore), et le nom de la (des) colonne(s) = de la + clef primaire du propri=EF=BF=BDtaire. Dans cet exemple + passport_id parce que le nom de la propri=EF=BF= =BDt=EF=BF=BD est + passport et la colonne identifiante de + Passport est id. + + La troisi=EF=BF=BDme possibilit=EF=BF=BD (utilisant une tabl= e d'association) est + tr=EF=BF=BDs exotique. + + +(a)Entity +public class Customer implements Serializable { + @OneToOne(cascade =3D CascadeType.ALL) + @JoinTable(name =3D "CustomerPassports", + joinColumns =3D @JoinColumn(name=3D"customer_fk"), + inverseJoinColumns =3D @JoinColumn(name=3D"passport_fk") + ) + public Passport getPassport() { + ... + } + +(a)Entity +public class Passport implements Serializable { + @OneToOne(mappedBy =3D "passport") + public Customer getOwner() { + ... +} + + + Un Customer est li=EF=BF=BD =EF=BF=BD= un + Passport =EF=BF=BD travers une table d'asso= ciation + nomm=EF=BF=BDe CustomerPassports ; cette table = d'association + a une colonne de clef =EF=BF=BDtrang=EF=BF=BDre nomm=EF=BF=BDe passport_fk + pointant vers la table Passport (mat=EF=BF=BDri= alis=EF=BF=BDe par + l'attribut inverseJoinColumn), et une colonne d= e clef + =EF=BF=BDtrang=EF=BF=BDre nomm=EF=BF=BDe customer_fk pointant vers la table + Customer (mat=EF=BF=BDrialis=EF=BF=BDe par l'at= tribut + joinColumns). + + Vous devez d=EF=BF=BDclarer le nom de la table de jointure e= t les colonnes + de jointure explicitement dans un tel mapping. + + + + Many-to-one + + Les associations Many-to-one sont d=EF=BF=BDclar=EF=BF=BDes = au niveau de la + propri=EF=BF=BDt=EF=BF=BD avec l'annotation @ManyToOne : + + +(a)Entity() +public class Flight implements Serializable { + @ManyToOne( cascade =3D {CascadeTyp= e.PERSIST, CascadeType.MERGE} ) + @JoinColumn(name=3D"COMP_ID") + public Company getCompany() { + return company; + } + ... +} + + + L'attribut @JoinColumn est optionnel, la = valeur + par d=EF=BF=BDfaut est comme l'association un =EF=BF=BD un, la con= cat=EF=BF=BDnation du nom + de la relation du c=EF=BF=BDt=EF=BF=BD propri=EF=BF=BDtaire, _ + (underscore), et le nom de la colonne de la clef primaire du c=EF= =BF=BDt=EF=BF=BD + propri=EF=BF=BDtaire. Dans cet exemple, company_id parce que + le nom de la propri=EF=BF=BDt=EF=BF=BD est company et la colonne + identifiante de Company est id. + + @ManyToOne a un param=EF=BF=BDtre nomm=EF= =BF=BD + targetEntity qui d=EF=BF=BDcrit le nom de l'ent= it=EF=BF=BD cible. + G=EF=BF=BDn=EF=BF=BDralement, vous ne devriez pas avoir besoin de = ce param=EF=BF=BDtre puisque + la valeur par d=EF=BF=BDfaut (le type de la propri=EF=BF=BDt=EF=BF= =BD qui stocke l'association) + est correcte dans la plupart des cas. Il est cependant utile lorsq= ue + vous souhaitez retourner une interface plut=EF=BF=BDt qu'une entit= =EF=BF=BD + normale. + + +(a)Entity() +public class Flight implements Serializable { + @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}, targetEntity=3DCompanyImpl.class ) + @JoinColumn(name=3D"COMP_ID") + public Company getCompany() { + return company; + } + ... +} + +public interface Company { + ... + + + Vous pouvez sinon mapper une association plusieurs =EF=BF=BD= un avec une + table d'association. Cette association d=EF=BF=BDcrite par l'annot= ation + @JoinTable contiendra une clef =EF=BF=BDtrang= =EF=BF=BDre r=EF=BF=BDf=EF=BF=BDren=EF=BF=BDant + la table de l'entit=EF=BF=BD (avec + @JoinTable.joinColumns) et une clef =EF=BF=BDtr= ang=EF=BF=BDre + r=EF=BF=BDf=EF=BF=BDren=EF=BF=BDant la table de l'entit=EF=BF=BD c= ible (avec + @JoinTable.inverseJoinColumns). + + +(a)Entity() +public class Flight implements Serializable { + @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE} ) + @JoinTable(name=3D"Flight_Company", + joinColumns =3D @JoinColumn(name=3D"FLIGHT_ID"), + inverseJoinColumns =3D @JoinColumn(name=3D"COMP_ID") + ) + public Company getCompany() { + return company; + } + ... +} + + + + + Collections + + + Vue d'ensemble + + Vous pouvez mapper des Collections,= des + Lists (ie des listes ordonn=EF=BF=BDes, pas d= es listes + index=EF=BF=BDes), des Maps et des + Sets. La sp=EF=BF=BDcification EJB3 d=EF= =BF=BDcrit comment + mapper une liste ordonn=EF=BF=BDe (ie une liste ordonn=EF=BF=BDe= au chargement) en + utilisant l'annotation @javax.persistence.OrderBy : + pour ordonner la collection, cette annotation prend en param=EF= =BF=BDtre une + liste de propri=EF=BF=BDt=EF=BF=BDs (de l'entit=EF=BF=BD cible) = s=EF=BF=BDpar=EF=BF=BDes par des virgules + (p. ex. firstname asc, age desc) ; si la cha=EF=BF= =BDne de + caract=EF=BF=BDres est vide, la collection sera ordonn=EF=BF=BDe= par les identifiants. + Pour le moment @OrderBy fonctionne seulement = sur + des collections n'ayant pas de table d'association. Pour les + v=EF=BF=BDritables collections index=EF=BF=BDes, veuillez vous r= =EF=BF=BDf=EF=BF=BDrer =EF=BF=BD + . EJB3 vous permet de mapper = des + Maps en utilisant comme clef une des propri= =EF=BF=BDt=EF=BF=BDs de + l'entit=EF=BF=BD cible avec @MapKey(name=3D"myProperty"= ) + (myProperty est un nom de propri=EF=BF=BDt=EF=BF=BD de l'entit= =EF=BF=BD cible). Lorsque vous + utilisez @MapKey sans nom de propri=EF=BF=BDt= =EF=BF=BD, la clef + primaire de l'entit=EF=BF=BD cible est utilis=EF=BF=BDe. La clef= de la map utilise la + m=EF=BF=BDme colonne que celle point=EF=BF=BDe par la propri=EF= =BF=BDt=EF=BF=BD : il n'y a pas de + colonne suppl=EF=BF=BDmentaire d=EF=BF=BDfinie pour la clef de l= a map, et c'est normal + puisque la clef de la map repr=EF=BF=BDsente en fait un propri= =EF=BF=BDt=EF=BF=BD de la cible. + Faites attention qu'une fois charg=EF=BF=BDe, la clef n'est plus= synchronis=EF=BF=BDe + avec la propri=EF=BF=BDt=EF=BF=BD, en d'autres mots, si vous mod= ifiez la valeur de la + propri=EF=BF=BDt=EF=BF=BD, la clef ne sera pas chang=EF=BF=BDe a= utomatiquement dans votre + mod=EF=BF=BDle Java (pour une v=EF=BF=BDritable prise en charge = des maps veuillez vous + r=EF=BF=BDf=EF=BF=BDrer =EF=BF=BD ). Beaucoup de gens + confondent les capacit=EF=BF=BDs de <map> et celles + de @MapKey. Ce sont deux fonctionnalit=EF=BF= =BDs + diff=EF=BF=BDrentes. @MapKey a encore quelque= s limitations, + veuillez vous r=EF=BF=BDf=EF=BF=BDrer au forum ou au syst=EF=BF= =BDme de suivi de bogues JIRA + pour plus d'informations. + + Hibernate a plusieurs notions de collections. + + + + + S=EF=BF=BDmantique des collections + + + + + + + + + + + S=EF=BF=BDmantique + + Repr=EF=BF=BDsentation Java + + Annotations + + + + + + S=EF=BF=BDmantique de Bag + + java.util.List, java.util.Collection + + @org.hibernate.annotations.CollectionOfElements ou + @OneToMany ou @ManyToMany + + + + S=EF=BF=BDmantique de Bag avec une clef primaire = (sans les + limitations de la s=EF=BF=BDmantique de Bag) + + java.util.List, java.util.Collection + + (@org.hibernate.annotations.CollectionOfElements = ou + @OneToMany ou @ManyToMany) et @CollectionId + + + + S=EF=BF=BDmantique de List + + java.util.List + + (@org.hibernate.annotations.CollectionOfElements = ou + @OneToMany ou @ManyToMany) et + @org.hibernate.annotations.IndexColumn + + + + S=EF=BF=BDmantique de Set + + java.util.Set + + @org.hibernate.annotations.CollectionOfElements ou + @OneToMany ou @ManyToMany + + + + S=EF=BF=BDmantique de Map + + java.util.Map + + (@org.hibernate.annotations.CollectionOfElements = ou + @OneToMany ou @ManyToMany) et (rien ou + @org.hibernate.annotations.MapKey/MapKeyManyToMany pour = une + v=EF=BF=BDritable prise en charge des maps, ou + @javax.persistence.MapKey + + + +
+ + Donc sp=EF=BF=BDcifiquement, les collections java.util.L= ist sans + @org.hibernate.annotations.IndexColumn vont =EF=BF=BDtre consid= =EF=BF=BDr=EF=BF=BDes commes + des bags. + + Les collections de types primitifs, de types core ou d'obj= ets + embarqu=EF=BF=BDs ne sont pas prises en charge par la sp=EF=BF= =BDcification EJB3. + Cependant Hibernate Annotations les autorise + (voir ). + + @Entity public class City { + @OneToMany(mappedBy=3D"city") + @OrderBy("streetName") + public List<Street> getStreets() { + return streets; + } +... +} + +(a)Entity public class Street { + public String getStreetName() { + return streetName; + } + + @ManyToOne + public City getCity() { + return city; + } + ... +} + + +(a)Entity +public class Software { + @OneToMany(mappedBy=3D"software") + @MapKey(name=3D"codeName") + public Map<String, Version> getVersions() { + return versions; + } +... +} + +(a)Entity +(a)Table(name=3D"tbl_version") +public class Version { + public String getCodeName() {...} + + @ManyToOne + public Software getSoftware() { ... } +... +} + + Donc City a une collection de + Streets qui sont ordonn=EF=BF=BDes par + streetName (de Street) lor= sque + la collection est charg=EF=BF=BDe. Software a= une map de + Versions dont la clef est + codeName de Version. + + A moins que la collection soit une "generic", vous devrez + d=EF=BF=BDfinir targetEntity. C'est un attrib= ut de + l'annotation qui prend comme valeur la classe de l'entit=EF=BF= =BD + cible. +
+ + + One-to-many + + Les associations one-to-many sont d=EF=BF=BDclar=EF=BF=BDe= s au niveau propri=EF=BF=BDt=EF=BF=BD + avec l'annotation @OneToMany. Les association= s un + =EF=BF=BD plusieurs peuvent =EF=BF=BDtre bidirectionnelles. + + + Relation bidirectionnelle + + Puisque les associations plusieurs =EF=BF=BD un sont (pr= esque) + toujours l'extr=EF=BF=BDmit=EF=BF=BD propri=EF=BF=BDtaire de l= a relation bidirectionnelle + dans la sp=EF=BF=BDcification EJB3, l'association un =EF=BF=BD= plusieurs est + annot=EF=BF=BDe par @OneToMany(mappedBy=3D...). + + @Entity +public class Troop { + @OneToMany(mappedBy=3D"troop") + public Set<Soldier> getSoldiers() { + ... +} + +(a)Entity +public class Soldier { + @ManyToOne + @JoinColumn(name=3D"troop_fk") + public Troop getTroop() { + ... +} + + Troop a une relation bidirectionn= elle + un =EF=BF=BD plusieurs avec Soldier =EF=BF= =BD travers la + propri=EF=BF=BDt=EF=BF=BD troop. Vous ne de= vez pas d=EF=BF=BDfinir + de mapping physique =EF=BF=BD l'extr=EF=BF=BDmit=EF=BF=BD de + mappedBy. + + Pour mapper une relation bidirectionnelle un =EF=BF=BD p= lusieurs, avec + l'extr=EF=BF=BDmit=EF=BF=BD one-to-many comme extr=EF=BF=BDmit= =EF=BF=BD propri=EF=BF=BDtaire, vous devez + enlever l'=EF=BF=BDl=EF=BF=BDment mappedBy = et marquer + l'annotation @JoinColumn de l'extr=EF=BF=BD= mit=EF=BF=BD plusieurs + =EF=BF=BD un comme ne pouvant pas =EF=BF=BDtre ins=EF=BF=BDr= =EF=BF=BDe et ni mise =EF=BF=BD jour. Cette + solution n'est certainement pas optimis=EF=BF=BDe et produira = quelques + commandes UPDATE suppl=EF=BF=BDmentaires. + + @Entity +public class Troop { + @OneToMany + @JoinColumn(name=3D"troop_fk") // nous avons besoin de dupliquer l'inf= ormation physique + public Set<Soldier> getSoldiers() { + ... +} + +(a)Entity +public class Soldier { + @ManyToOne + @JoinColumn(name=3D"troop_fk", insertable=3Dfalse, updatable=3Dfalse) + public Troop getTroop() { + ... +} + + + + Relation unidirectionnelle + + Une relation un =EF=BF=BD plusieurs unidirectionnelle ut= ilisant une + colonne de clef =EF=BF=BDtrang=EF=BF=BDre de l'entit=EF=BF=BD = propri=EF=BF=BDtaire n'est pas si + commune, r=EF=BF=BDellement recommand=EF=BF=BDe. Nous vous con= seillons + fortement d'utiliser une table de jointure pour cette sorte + d'association (comme expliqu=EF=BF=BD dans la prochaine sectio= n). Cette + sorte d'association est d=EF=BF=BDcrite =EF=BF=BD travers + @JoinColumn. + + +(a)Entity +public class Customer implements Serializable { + @OneToMany(cascade=3DCascadeType.ALL, fetch=3DFetchType.EAGER) + @JoinColumn(name=3D"CUST_ID") + public Set<Ticket> getTickets() { + ... +} + +(a)Entity +public class Ticket implements Serializable { + ... // pas de relation bidirectionnelle +} + + + Customer d=EF=BF=BDcrit une relation + unidirectionnelle avec Ticket en utilisant = la + colonne de jointure CUST_ID. + + + + Relation unidirectionnel avec une table de jointure</ti= tle> + + <para>Une relation unidirectionnelle un =EF=BF=BD plusieurs av= ec une table + de jointure est largement pr=EF=BF=BDf=EF=BF=BDr=EF=BF=BDe. Ce= tte association est d=EF=BF=BDcrite + =EF=BF=BD travers l'annotation <literal>@JoinTable</literal>.<= /para> + + <programlisting> +(a)Entity +public class Trainer { + @OneToMany + @JoinTable( + name=3D"TrainedMonkeys", + joinColumns =3D @JoinColumn( name=3D"trainer_id"), + inverseJoinColumns =3D @JoinColumn( name=3D"monkey_id") + ) + public Set<Monkey> getTrainedMonkeys() { + ... +} + +(a)Entity +public class Monkey { + ... // pas de relation bidirectionnelle +} + </programlisting> + + <para><literal>Trainer</literal> d=EF=BF=BDcrit une relation + unidirectionelle avec <classname>Monkey</classname> en utilisa= nt la + table de jointure <classname>TrainedMonkeys</classname>, avec = une + clef =EF=BF=BDtrang=EF=BF=BDre <literal>trainer_id</literal> v= ers + <literal>Trainer</literal> (<literal>joinColumns</literal>) et= une + clef =EF=BF=BDtrang=EF=BF=BDre <literal>monkey_id</literal> ve= rs + <literal>Monkey</literal> + (<literal>inversejoinColumns</literal>).</para> + </sect5> + + <sect5 id=3D"entity-mapping-association-collection-manytomany-de= fault" + revision=3D"1"> + <title>Valeurs par d=EF=BF=BDfaut + + Si aucun mapping physique n'est d=EF=BF=BDclar=EF=BF=BD,= une relation + unidirectionnelle un vers plusieurs utilise une table de joint= ure. + Le nom de la table est la concat=EF=BF=BDnation du nom de la t= able + propri=EF=BF=BDtaire, _, et le nom de la tabl= e de l'autre + extr=EF=BF=BDmit=EF=BF=BD. Le nom des colonnes de la clef =EF= =BF=BDtrang=EF=BF=BDre r=EF=BF=BDf=EF=BF=BDren=EF=BF=BDant la + table propri=EF=BF=BDtaire est la concat=EF=BF=BDnation de la = table propri=EF=BF=BDtaire, + _, et le nom des colonnes de la clef primaire= . Le + nom des colonnes de la clef =EF=BF=BDtrang=EF=BF=BDre r=EF=BF= =BDf=EF=BF=BDren=EF=BF=BDant l'autre extr=EF=BF=BDmit=EF=BF=BD + est la concat=EF=BF=BDnation du nom de la propri=EF=BF=BDt=EF= =BF=BD du propri=EF=BF=BDtaire, + _, et le nom des colonnes de la clef primaire= de + l'autre extr=EF=BF=BDmit=EF=BF=BD. Une contrainte d'unicit=EF= =BF=BD est ajout=EF=BF=BDe sur la + clef =EF=BF=BDtrang=EF=BF=BDre r=EF=BF=BDf=EF=BF=BDren=EF=BF= =BDant la table de l'autre extr=EF=BF=BDmit=EF=BF=BD pour + r=EF=BF=BDfl=EF=BF=BDter le un =EF=BF=BD plusieurs. + + +(a)Entity +public class Trainer { + @OneToMany + public Set<Tiger> getTrainedTigers() { + ... +} + +(a)Entity +public class Tiger { + ... // non bidirectionnelle +} + + + Trainer d=EF=BF=BDcrit une relati= on + unidirectionnelle avec Tiger utilisant = la + table de jointure Trainer_Tiger, avec une c= lef + =EF=BF=BDtrang=EF=BF=BDre trainer_id vers + Trainer (nom de la table, _, + identifiant de trainer) et une clef =EF=BF=BDtrang=EF=BF=BDre + trainedTigers_id vers Monkey + (nom de la propri=EF=BF=BDt=EF=BF=BD, _, colo= nne de la clef + primaire de Tiger). + + + + + Many-to-many + + + D=EF=BF=BDfinition + + Une association many-to-many est d=EF=BF=BDfinie logique= ment en + utilisant l'annotation @ManyToMany. Vous de= vez + aussi d=EF=BF=BDcrire la table d'association et les conditions= de jointure + en utilisant l'annotation @JoinTable. Si + l'association est bidirectionnelle, une extr=EF=BF=BDmit=EF=BF= =BD doit =EF=BF=BDtre la + propri=EF=BF=BDtaire et l'autre doit =EF=BF=BDtre marqu=EF=BF= =BDe comme "inverse" (ie + qu'elle sera ignor=EF=BF=BDe lors de la mise =EF=BF=BD jour de= s valeurs de la + relation dans la table d'association) : + + +(a)Entity +public class Employer implements Serializable { + @ManyToMany( + targetEntity=3Dorg.hibernate.test.metadata.manytomany.Employee.cla= ss, + cascade=3D{CascadeType.PERSIST, CascadeType.MERGE} + ) + @JoinTable( + name=3D"EMPLOYER_EMPLOYEE", + joinColumns=3D@JoinColumn(name=3D"EMPER_ID"), + inverseJoinColumns=3D@JoinColumn(name=3D"EMPEE_ID") + ) + public Collection getEmployees() { + return employees; + } + ... +} + + + +(a)Entity +public class Employee implements Serializable { + @ManyToMany( + cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}, + mappedBy =3D "employees", + targetEntity =3D Employer.class + ) + public Collection getEmployers() { + return employers; + } +} + + + Nous avons d=EF=BF=BDj=EF=BF=BD montr=EF=BF=BD les d=EF= =BF=BDclarations des relations + "many" et d=EF=BF=BDtaill=EF=BF=BD les attributs de ces associ= ations. Allons + plus en profondeur dans la description de + @JoinTable ; elle d=EF=BF=BDfinit un + name, un tableau de colonnes de jointure (un + tableau dans une annotation est d=EF=BF=BDfini par {A, B, C}),= et un tableau + de colonnes de jointure inverse. Ces derni=EF=BF=BDres sont le= s colonnes + de la table d'association qui r=EF=BF=BDf=EF=BF=BDrencent la c= lef primaire de + Employee ("l'autre extr=EF=BF=BDmit=EF= =BF=BD"). + + Comme vu pr=EF=BF=BDc=EF=BF=BDdemment, l'autre extr=EF= =BF=BDmit=EF=BF=BD ne doit pas d=EF=BF=BDcrire + le mapping physique : un simple argument + mappedBy contenant le nom de la propri=EF= =BF=BDt=EF=BF=BD de + l'extr=EF=BF=BDmit=EF=BF=BD propri=EF=BF=BDtaire suffit =EF=BF= =BD relier les deux. + + + + Valeurs par d=EF=BF=BDfaut + + Comme d'autres annotations, la plupart des valeurs d'une + relation plusieurs =EF=BF=BD plusieurs sont inf=EF=BF=BDr=EF= =BF=BDes. Si aucun mapping + physique n'est d=EF=BF=BDcrit dans une relation plusieurs =EF= =BF=BD plusieurs + unidirectionnelle, alors les r=EF=BF=BDgles suivantes s'appliq= uent. Le nom + de la table est la concat=EF=BF=BDnation du nom de la table pr= opri=EF=BF=BDtaire, + _ et le nom de la table de l'autre extr=EF=BF= =BDmit=EF=BF=BD. Le + nom des colonnes de la clef =EF=BF=BDtrang=EF=BF=BDre r=EF=BF= =BDf=EF=BF=BDren=EF=BF=BDant la table + propri=EF=BF=BDtaire est la concat=EF=BF=BDnation du nom de la= table propri=EF=BF=BDtaire, + _ et le nom des colonnes de la clef primaire + de cette table. Le nom des colonnes de la clef =EF=BF=BDtrang= =EF=BF=BDre r=EF=BF=BDf=EF=BF=BDren=EF=BF=BDant + l'autre extr=EF=BF=BDmit=EF=BF=BD est la concat=EF=BF=BDnation= du nom de la propri=EF=BF=BDt=EF=BF=BD du + propri=EF=BF=BDtaire, _ et le nom des colonne= s de la + clef primaire de l'autre extr=EF=BF=BDmit=EF=BF=BD. Ce sont le= s m=EF=BF=BDmes r=EF=BF=BDgles que + celles utilis=EF=BF=BDes pour une relation un =EF=BF=BD plusie= urs + unidirectionnelle. + + +(a)Entity +public class Store { + @ManyToMany(cascade =3D CascadeType.PERSIST) + public Set<City> getImplantedIn() { + ... + } +} + +(a)Entity +public class City { + ... // pas de relation bidirectionnelle +} + + + La table Store_City est utilis=EF=BF= =BDe comme + table de jointure. La colonne Store_id est + une clef =EF=BF=BDtrang=EF=BF=BDre vers la table Stor= e. La + colonne implantedIn_id est une clef =EF=BF= =BDtrang=EF=BF=BDre + vers la table City. + + Si aucun mapping physique n'est d=EF=BF=BDcrit dans une = relation + plusieurs =EF=BF=BD plusieurs bidirectionnelle, alors les r=EF= =BF=BDgles suivantes + s'appliquent. Le nom de la table est la concat=EF=BF=BDnation = du nom de la + table propri=EF=BF=BDtaire, _ et le nom de la= table de + l'autre extr=EF=BF=BDmit=EF=BF=BD. Le nom des colonnes de la c= lef =EF=BF=BDtrang=EF=BF=BDre + r=EF=BF=BDf=EF=BF=BDren=EF=BF=BDant la table propri=EF=BF=BDta= ire est la concat=EF=BF=BDnation du nom de la + propri=EF=BF=BDt=EF=BF=BD de l'autre extr=EF=BF=BDmit=EF=BF=BD= , _ et le nom des + colonnes de la clef primaire du propri=EF=BF=BDtaire. Le nom d= es colonnes de + la clef =EF=BF=BDtrang=EF=BF=BDre r=EF=BF=BDf=EF=BF=BDren=EF= =BF=BDant l'autre extr=EF=BF=BDmit=EF=BF=BD est la concat=EF=BF=BDnation + du nom de la propri=EF=BF=BDt=EF=BF=BD du propri=EF=BF=BDtaire= , _ et le nom + des colonnes de la clef primaire de l'autre extr=EF=BF=BDmit= =EF=BF=BD. Ce sont les + m=EF=BF=BDmes r=EF=BF=BDgles que celles utilis=EF=BF=BDes pour= une relation un =EF=BF=BD plusieurs + unidirectionnelle. + + +(a)Entity +public class Store { + @ManyToMany(cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}) + public Set<Customer> getCustomers() { + ... + } +} + +(a)Entity +public class Customer { + @ManyToMany(mappedBy=3D"customers") + public Set<Store> getStores() { + ... + } +} + + + La table Store_Customer est utilis=EF= =BF=BDe comme + table de jointure. La colonne stores_id est= une + clef =EF=BF=BDtrang=EF=BF=BDre vers la table Store. La colonne + customers_id est une clef =EF=BF=BDtrang=EF= =BF=BDre vers la table + Customer. + + +
+ + + Persistance transitive avec les op=EF=BF=BDrations en casca= de + + Vous avez probablement remarqu=EF=BF=BD l'attribut + cascade prenant comme valeur un tableau de + CascadeTypes. Le concept de cascade dans EJ= B3 est + similaire =EF=BF=BD la persistance transitive et les op=EF=BF=BDra= tions en cascade dans + Hibernate, mais avec une s=EF=BF=BDmantique l=EF=BF=BDg=EF=BF=BDre= ment diff=EF=BF=BDrente et les types + de cascade suivants : + + + + CascadeType.PERSIST : effectue en cascade l'op=EF=BF=BDration= de + persistance (cr=EF=BF=BDation) sur les entit=EF=BF=BDs associ= =EF=BF=BDes si persist() est + appel=EF=BF=BDe ou si l'entit=EF=BF=BD est supervis=EF=BF=BDe= (par le gestionnaire + d'entit=EF=BF=BDs) + + + + CascadeType.MERGE : effectue en cascade l'op=EF=BF=BDration d= e fusion sur + les entit=EF=BF=BDs associ=EF=BF=BDes si merge() est app=EF= =BF=BDl=EF=BF=BDe ou si l'entit=EF=BF=BD est + supervis=EF=BF=BDe + + + + CascadeType.REMOVE : effectue en cascade l'op=EF=BF=BDration = de + suppression sur les entit=EF=BF=BDs associ=EF=BF=BDes si dele= te() est appel=EF=BF=BDe + + + + CascadeType.REFRESH : effectue en cascade l'op=EF=BF=BDration= de + rafra=EF=BF=BDchissement sur les entit=EF=BF=BDs associ=EF=BF= =BDes si refresh() est appel=EF=BF=BDe + + + + CascadeType.ALL : tous ceux du dessus + + + + Veullez vous r=EF=BF=BDf=EF=BF=BDrer au chapitre 6.3 de la s= p=EF=BF=BDcification EJB3 pour + plus d'informations sur les op=EF=BF=BDrations en cascade et la s= =EF=BF=BDmantique des + op=EF=BF=BDrations de cr=EF=BF=BDation/fusion. + + + + R=EF=BF=BDcup=EF=BF=BDration d'associations + + Vous avez la possibilit=EF=BF=BD de r=EF=BF=BDcup=EF=BF=BDre= r les entit=EF=BF=BDs associ=EF=BF=BDes soit + imm=EF=BF=BDdiatement ("eager"), soit =EF=BF=BD la demande ("lazy"= ). Le param=EF=BF=BDtre + fetch peut =EF=BF=BDtre positionn=EF=BF=BD =EF= =BF=BD + FetchType.LAZY ou =EF=BF=BD + FetchType.EAGER. EAGER essai= era + d'utiliser une jointure externe pour rappatrier l'objet associ=EF= =BF=BD, + alors que LAZY est la valeur par d=EF=BF=BDfaut= et rapportera + les donn=EF=BF=BDes lorsque l'objet associ=EF=BF=BD sera acc=EF=BF= =BDd=EF=BF=BD pour la premi=EF=BF=BDre fois. + JPA-QL a aussi un mot clef fetch qui vous perme= t de + surcharger le type de r=EF=BF=BDcup=EF=BF=BDration pour une requ= =EF=BF=BDte particuli=EF=BF=BDre. C'est + tr=EF=BF=BDs utile pour am=EF=BF=BDliorer les performances et d=EF= =BF=BDcider au cas par + cas. + +
+ + + Mapper des clefs primaires et =EF=BF=BDtrang=EF=BF=BDres comp= os=EF=BF=BDes + + Les clefs primaires compos=EF=BF=BDes utilisent une classe emb= arqu=EF=BF=BDe comme + repr=EF=BF=BDsentation de la clef primaire, donc vous devriez utilis= er les + annotations @Id et @Embeddable. + Alternativement, vous pouvez utiliser l'annotation + @EmbeddedId. Notez que la classe d=EF=BF=BDpendan= te doit =EF=BF=BDtre + s=EF=BF=BDrialisable et implementer + equals()/hashCode(). + Vous pouvez aussi utiliser @IdClass comme d=EF=BF= =BDcrit dans + . + + +(a)Entity +public class RegionalArticle implements Serializable { + + @Id + public RegionalArticlePk getPk() { ... } +} + +(a)Embeddable +public class RegionalArticlePk implements Serializable { ... } + + + ou alternativement + + +(a)Entity +public class RegionalArticle implements Serializable { + + @EmbeddedId + public RegionalArticlePk getPk() { ... } +} + +public class RegionalArticlePk implements Serializable { ... } + + + @Embeddable h=EF=BF=BDrite le type d'acc=EF= =BF=BDs de son entit=EF=BF=BD + d'appartenance =EF=BF=BD moins que l'annotation sp=EF=BF=BDcifique H= ibernate + @AccessType soit utilis=EF=BF=BDe. Les clefs =EF= =BF=BDtrang=EF=BF=BDres + compos=EF=BF=BDes (si les valeurs par d=EF=BF=BDfaut ne sont pas uti= lis=EF=BF=BDes) sont d=EF=BF=BDfinies + sur les associations en utilisant l'=EF=BF=BDl=EF=BF=BDment + @JoinColumns, lequel est simplement un tableau de + @JoinColumns. Il est consid=EF=BF=BDr=EF=BF=BD co= mme une bonne pratique + d'exprimer referencedColumnNames explicitement. S= inon, + Hibernate supposera que vous utilisez le m=EF=BF=BDme ordre de colon= nes que dans + la d=EF=BF=BDclaration de la clef primaire. + + +(a)Entity +public class Parent implements Serializable { + @Id + public ParentPk id; + public int age; + + @OneToMany(cascade=3DCascadeType.ALL) + @JoinColumns ({ + @JoinColumn(name=3D"parentCivility", referencedColumnName =3D "isM= ale"), + @JoinColumn(name=3D"parentLastName", referencedColumnName =3D "las= tName"), + @JoinColumn(name=3D"parentFirstName", referencedColumnName =3D "fi= rstName") + }) + public Set<Child> children; //unidirectionnelle + ... +} + + + +(a)Entity +public class Child implements Serializable { + @Id @GeneratedValue + public Integer id; + + @ManyToOne + @JoinColumns ({ + @JoinColumn(name=3D"parentCivility", referencedColumnName =3D "isM= ale"), + @JoinColumn(name=3D"parentLastName", referencedColumnName =3D "las= tName"), + @JoinColumn(name=3D"parentFirstName", referencedColumnName =3D "fi= rstName") + }) + public Parent parent; // unidirectionnelle +} + + + +(a)Embeddable +public class ParentPk implements Serializable { + String firstName; + String lastName; + ... +} + + + Notez l'usage explicite de + referencedColumnName. + + + + Mapper des tables secondaires + + Vous pouvez mapper un simple entity bean vers plusieurs tables= en + utilisant les annotations de niveau classe + @SecondaryTable ou + @SecondaryTables. Pour dire qu'une colonne est da= ns + une table particuli=EF=BF=BDre, utlisez le param=EF=BF=BDtre table de + @Column ou @JoinColumn. + + +(a)Entity +(a)Table(name=3D"MainCat") +@SecondaryTables({ + @SecondaryTable(name=3D"Cat1", pkJoinColumns=3D{ + @PrimaryKeyJoinColumn(name=3D"cat_id", referencedColumnName=3D"id") + ), + @SecondaryTable(name=3D"Cat2", uniqueConstraints=3D{@UniqueConstraint(= columnNames=3D{"storyPart2"})}) +}) +public class Cat implements Serializable { + + private Integer id; + private String name; + private String storyPart1; + private String storyPart2; + + @Id @GeneratedValue + public Integer getId() { + return id; + } + + public String getName() { + return name; + } + + @Column(table=3D"Cat1") + public String getStoryPart1() { + return storyPart1; + } + + @Column(table=3D"Cat2") + public String getStoryPart2() { + return storyPart2; + } + + + Dans cet exemple, name sera dans + MainCat. storyPart1 sera dans + Cat1 et storyPart2 sera dans + Cat2. Cat1 sera joint =EF=BF= =BD + MainCat avec cat_id comme clef + =EF=BF=BDtrang=EF=BF=BDre, et Cat2 avec = id (ie + le m=EF=BF=BDme nom de colonne que la colonne identifiante de + MainCat). De plus, une contrainte d'unicit=EF=BF= =BD sur + storyPart2 a =EF=BF=BDt=EF=BF=BD renseign=EF=BF= =BDe. + + Regardez le tutoriel EJB3 de JBoss ou la suite de tests + unitaires d'Hibernate Annotations pour plus d'exemples. + +
+ + + Mapper des requ=EF=BF=BDtes + + + Mapper des requ=EF=BF=BDtes JPAQL/HQL + + Vous pouvez mapper des requ=EF=BF=BDtes JPA-QL/HQL en utilisan= t les + annotations. @NamedQuery et + @NamedQueries peuvent =EF=BF=BDtre d=EF=BF=BDfini= es au niveau de la + classe ou dans un fichier JPA XML. Cependant, leurs d=EF=BF=BDfiniti= ons sont + globales au scope de la session factory/entity manager factory. Une + requ=EF=BF=BDte nomm=EF=BF=BDe est d=EF=BF=BDfinie par son nom et la= cha=EF=BF=BDne de caract=EF=BF=BDres de la + requ=EF=BF=BDte r=EF=BF=BDelle. + + <entity-mappings> + <named-query name=3D"plane.getAll"> + <query>select p from Plane p</query> + </named-query> + ... +</entity-mappings> +... + +(a)Entity +(a)NamedQuery(name=3D"night.moreRecentThan", query=3D"select n from Night = n where n.date >=3D :date") +public class Night { + ... +} + +public class MyDao { + doStuff() { + Query q =3D s.getNamedQuery("night.moreRecentThan"); + q.setDate( "date", aMonthAgo ); + List results =3D q.list(); + ... + } + ... +} + + + Vous pouvez aussi fournir des indications de fonctionnement = =EF=BF=BD une + requ=EF=BF=BDte =EF=BF=BD travers un tableau de QueryHints avec + l'attribut hints. + + Les indications de fonctionnement Hibernate disponibles + sont : + + + + + Indications de fonctionnement d'une requ=EF=BF=BDte + + + + + + + + + Indication + + description + + + + + + org.hibernate.cacheable + + Indique si la requ=EF=BF=BDte devrait interagir avec = le cache de + second niveau (par d=EF=BF=BDfaut =EF=BF=BD false) + + + + org.hibernate.cacheRegion + + Nom de la r=EF=BF=BDgion du cache (si ind=EF=BF=BDfin= ie, la valeur par + d=EF=BF=BDfaut est utilis=EF=BF=BDe) + + + + org.hibernate.timeout + + Timeout des requ=EF=BF=BDtes + + + + org.hibernate.fetchSize + + Taille des result sets par fetch + + + + org.hibernate.flushMode + + Mode de flush utilis=EF=BF=BD pour cette requ=EF=BF= =BDte + + + + org.hibernate.cacheMode + + Mode de cache utilis=EF=BF=BD pour cette requ=EF=BF= =BDte + + + + org.hibernate.readOnly + + Indique si les entit=EF=BF=BDs charg=EF=BF=BDes par c= ette requ=EF=BF=BDte devraient + =EF=BF=BDtre en lecture seule ou pas (par d=EF=BF=BDfaut =EF= =BF=BD false) + + + + org.hibernate.comment + + Commentaire de la requ=EF=BF=BDte, ajout=EF=BF=BD au = SQL g=EF=BF=BDn=EF=BF=BDr=EF=BF=BD + + + +
+
+ + + Mapper des requ=EF=BF=BDtes natives + + Vous pouvez aussi mapper une requ=EF=BF=BDte native (ie une re= qu=EF=BF=BDte SQL). + Pour ce faire, vous devez d=EF=BF=BDcrire la structure de l'ensemble= de r=EF=BF=BDsultat + SQL en utilisant @SqlResultSetMapping (ou + @SqlResultSetMappings si vous pr=EF=BF=BDvoyez de= d=EF=BF=BDfinir + plusieurs mappings de r=EF=BF=BDsultats). Comme @NamedQuery= , un + @SqlResultSetMapping peut =EF=BF=BDtre d=EF=BF=BD= fini au niveau de la + classe ou dans un fichier XML JPA. Cependant sa port=EF=BF=BDe est g= lobale =EF=BF=BD + l'application. + + Comme vous le verrez, un param=EF=BF=BDtre de + resultSetMapping est d=EF=BF=BDfini dans + @NamedNativeQuery, il repr=EF=BF=BDsente le nom du + @SqlResultSetMapping d=EF=BF=BDfini. Le mapping d= e l'ensemble + des r=EF=BF=BDsultats d=EF=BF=BDclare les entit=EF=BF=BDs r=EF=BF=BD= cup=EF=BF=BDr=EF=BF=BDes par cette requ=EF=BF=BDte native. + Chaque champ de l'entit=EF=BF=BD est li=EF=BF=BD =EF=BF=BD un alias = SQL (nom de colonne). Tous les + champs de l'entit=EF=BF=BD (dont ceux des classes filles) et les col= onnes des + clefs =EF=BF=BDtrang=EF=BF=BDres relatives aux entit=EF=BF=BDs doive= nt =EF=BF=BDtre pr=EF=BF=BDsents dans la + requ=EF=BF=BDte SQL. Les d=EF=BF=BDfinitions des champs sont optionn= elles, si elles ne + sont pas fournies, elles mappent le m=EF=BF=BDme nom de colonne que = celui d=EF=BF=BDclar=EF=BF=BD + sur la propri=EF=BF=BDt=EF=BF=BD de la classe. + + @NamedNativeQuery(name=3D"night&area", que= ry=3D"select night.id nid, night.night_duration, " + + " night.night_date, area.id aid, night.area_id, area.name " + + "from Night night, Area area where night.area_id =3D area.id", resultSetMapping=3D"joinMapping") +(a)SqlResultSetMapping(name=3D"joinMapping", entities=3D{ + @EntityResult(entityClass=3Dorg.hibernate.test.annotations.query.Night= .class, fields =3D { + @FieldResult(name=3D"id", column=3D"nid"), + @FieldResult(name=3D"duration", column=3D"night_duration"), + @FieldResult(name=3D"date", column=3D"night_date"), + @FieldResult(name=3D"area", column=3D"area_id"), + discriminatorColumn=3D"disc" + }), + @EntityResult(entityClass=3Dorg.hibernate.test.annotations.query.Area.= class, fields =3D { + @FieldResult(name=3D"id", column=3D"aid"), + @FieldResult(name=3D"name", column=3D"name") + }) + } +) + + Dans l'exemple ci-dessus, la requ=EF=BF=BDte nomm=EF=BF=BDe + night&area utilise le mapping de r=EF=BF=BDsu= ltats + joinMapping. Ce mapping retourne 2 entit=EF=BF=BD= s, + Night et Area, chaque propri= =EF=BF=BDt=EF=BF=BD est + d=EF=BF=BDclar=EF=BF=BDe et associ=EF=BF=BDe =EF=BF=BD un nom de col= onne, en fait le nom de colonne + r=EF=BF=BDcup=EF=BF=BDr=EF=BF=BD par la requ=EF=BF=BDte. Voyons main= tenant une d=EF=BF=BDclaration implicite de + mapping propri=EF=BF=BDt=EF=BF=BD/colonne. + + @Entity +@SqlResultSetMapping(name=3D"implicit", entities= =3D@EntityResult(entityClass=3Dorg.hibernate.test.annotations.query.SpaceSh= ip.class)) +(a)NamedNativeQuery(name=3D"implicitSample", query=3D"select * from SpaceS= hip", resultSetMapping=3D"implicit") +public class SpaceShip { + private String name; + private String model; + private double speed; + + @Id + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Column(name=3D"model_txt") + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed =3D speed; + } +} + + Dans cet exemple, nous d=EF=BF=BDcrivons seulement le membre d= e l'entit=EF=BF=BD du + mapping de r=EF=BF=BDsultats. Le mapping de propri=EF=BF=BDt=EF=BF= =BD/colonne est fait en + utilisant les valeurs de mapping de l'entit=EF=BF=BD. Dans ce cas, l= a propri=EF=BF=BDt=EF=BF=BD + model est li=EF=BF=BDe =EF=BF=BD la colonne + model_txt. Si l'association =EF=BF=BD une entit= =EF=BF=BD concern=EF=BF=BDe + implique une clef primaire compos=EF=BF=BDe, un =EF=BF=BDl=EF=BF=BDm= ent + @FieldResult devrait =EF=BF=BDtre utilis=EF=BF=BD= pour chaque colonne + de la clef =EF=BF=BDtrang=EF=BF=BDre. Le nom de @FieldResul= t est + compos=EF=BF=BD du nom de la propri=EF=BF=BDt=EF=BF=BD pour la relat= ion, suivi par un point ("."), + suivi par le nom ou le champ ou la propri=EF=BF=BDt=EF=BF=BD de la c= lef primaire. + + @Entity +(a)SqlResultSetMapping(name=3D"compositekey", + entities=3D@EntityResult(entityClass=3Dorg.hibernate.test.annotati= ons.query.SpaceShip.class, + fields =3D { + @FieldResult(name=3D"name", column =3D "name"), + @FieldResult(name=3D"model", column =3D "model"), + @FieldResult(name=3D"speed", column =3D "speed"), + @FieldResult(name=3D"captain.f= irstname", column =3D "firstn"), + @FieldResult(name=3D"captain.lastname", column =3D "la= stn"), + @FieldResult(name=3D"dimensions.length", column =3D "l= ength"), + @FieldResult(name=3D"dimensions.width", column =3D "wi= dth") + }), + columns =3D { @ColumnResult(name =3D "surface"), + @ColumnResult(name =3D "volume") } ) + +(a)NamedNativeQuery(name=3D"compositekey", + query=3D"select name, model, speed, lname as lastn, fname as firstn, l= ength, width, length * width as surface from SpaceShip", + resultSetMapping=3D"compositekey") +} ) +public class SpaceShip { + private String name; + private String model; + private double speed; + private Captain captain; + private Dimensions dimensions; + + @Id + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToOne(fetch=3D FetchType.LAZY) + @JoinColumns( { + @JoinColumn(name=3D"fname", referencedColumnName =3D "firstnam= e"), + @JoinColumn(name=3D"lname", referencedColumnName =3D "lastname= ") + } ) + public Captain getCaptain() { + return captain; + } + + public void setCaptain(Captain captain) { + this.captain =3D captain; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed =3D speed; + } + + public Dimensions getDimensions() { + return dimensions; + } + + public void setDimensions(Dimensions dimensions) { + this.dimensions =3D dimensions; + } +} + +(a)Entity +(a)IdClass(Identity.class) +public class Captain implements Serializable { + private String firstname; + private String lastname; + + @Id + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + @Id + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } +} + + + + Si vous regardez la propri=EF=BF=BDt=EF=BF=BD dimension, vou= s verrez qu'Hibernate + prend en charge la notation avec les points pour les objets embarq= u=EF=BF=BDs + (vous pouvez m=EF=BF=BDme avoir des objets embarqu=EF=BF=BDs imbri= qu=EF=BF=BDs). Les + impl=EF=BF=BDmentations EJB3 n'ont pas =EF=BF=BD prendre en charge= cette fonctionnalit=EF=BF=BD, + mais nous le faisons :-) + + + Si vous r=EF=BF=BDcup=EF=BF=BDrez une simple entit=EF=BF=BD et= si vous utilisez le mapping + par d=EF=BF=BDfaut, vous pouvez utiliser l'attribut resultC= lass + =EF=BF=BD la place de resultSetMapping : + + @NamedNativeQuery(name=3D"im= plicitSample", query=3D"select * from SpaceShip", + resultClass=3DSpaceShip.class) +public class SpaceShip { + + Dans certaines de vos requ=EF=BF=BDtes natives, vous devrez re= tourner des + valeurs scalaires, par exemple lors de la construction de requ=EF=BF= =BDtes de + rapport. Vous pouvez les mapper dans + @SqlResultsetMapping avec + @ColumnResult. En fait, vous pouvez m=EF=BF=BDme = m=EF=BF=BDlanger des + retours d'entit=EF=BF=BDs et de valeurs scalaires dans la m=EF=BF=BD= me requ=EF=BF=BDte native (ce + n'est cependant probablement pas commun). + + @SqlResultSetMapping(name=3D= "scalar", columns=3D@ColumnResult(name=3D"dimension")) +(a)NamedNativeQuery(name=3D"scalar", query=3D"select length*width as dimen= sion from SpaceShip", resultSetMapping=3D"scalar") + + Une autre indication de fonctionnement sp=EF=BF=BDcifique aux = requ=EF=BF=BDtes + natives a =EF=BF=BDt=EF=BF=BD pr=EF=BF=BDsent=EF=BF=BDe : o= rg.hibernate.callable + laquelle peut =EF=BF=BDtre =EF=BF=BD true ou =EF=BF=BD false fausse = selon que la requ=EF=BF=BDte est une + proc=EF=BF=BDdure stock=EF=BF=BDe ou pas. + +
+ + + Extensions d'Hibernate Annotation + + Hibernate 3.1 offre une vari=EF=BF=BDt=EF=BF=BD d'annotations su= ppl=EF=BF=BDmentaires que vous + pouvez m=EF=BF=BDlanger/faire correspondre avec des entit=EF=BF=BDs EJ= B3. Elles ont =EF=BF=BDt=EF=BF=BD + con=EF=BF=BDues comme une extension naturelle aux annotations EJB3. + + Pour aller plus loin que les capacit=EF=BF=BDs d'EJB3, Hibernate= fournit des + annotations sp=EF=BF=BDcifiques qui correspondent aux fonctionnalit=EF= =BF=BDs d'Hibernate. + Le package org.hibernate.annotations contient t= outes + ces extensions d'annotations. + + + Entit=EF=BF=BD + + Vous pouvez finement param=EF=BF=BDtrer certaines des actions = faites par + Hibernate sur les entit=EF=BF=BDs au-del=EF=BF=BD de ce qu'offre la = sp=EF=BF=BDcification + EJB3. + + @org.hibernate.annotations.Entity ajout= e des + m=EF=BF=BDta-donn=EF=BF=BDes suppl=EF=BF=BDmentaires qui peuvent =EF= =BF=BDtre n=EF=BF=BDcessaires au-del=EF=BF=BD de ce + qui est d=EF=BF=BDfini dans l'annotation @Entity + standard : + + mutable : indique si l'entit=EF=BF=BD est modifiable ou non + + + + dynamicInsert : autorise le SQL dynamique pour les insertions + + + + dynamicUpdate : autorise le SQL dynamique pour les mise =EF= =BF=BD jour + + + + selectBeforeUpdate : sp=EF=BF=BDcifie qu'Hibernate ne devrait= jamais + ex=EF=BF=BDcuter un UPDATE SQL =EF=BF=BD moins qu'il ne soit = certain qu'un objet + est r=EF=BF=BDellement modifi=EF=BF=BD + + + + polymorphism : indique si le polymorphisme d'entit=EF=BF=BD e= st de type + PolymorphismType.IMPLICIT (valeur par d=EF=BF=BDfaut) ou + PolymorphismType.EXPLICIT + + + + persister : autorise la surcharge de l'impl=EF=BF=BDmentation= de + persistance fournie par d=EF=BF=BDfaut + + + + optimisticLock : strat=EF=BF=BDgie de verrouillage optmiste + (OptimisticLockType.VERSION, + OptimisticLockType.NONE, OptimisticLockType.DIRTY ou + OptimisticLockType.ALL) + + + + + @javax.persistence.Entity est encore obligatoire, + @org.hibernate.annotations.Entity ne la remplace pas. + + + Voici quelques extensions d'annotations Hibernate + suppl=EF=BF=BDmentaires. + + @org.hibernate.annotations.BatchSize vous p= ermet + de d=EF=BF=BDfinir la taille du batch lors de la r=EF=BF=BDcup=EF=BF= =BDration d'instances de + cette entit=EF=BF=BD (p. ex. @BatchSize(size=3D4)= ). Lors du + chargement d'une entit=EF=BF=BD donn=EF=BF=BDe, Hibernate chargera a= lors toutes les + entit=EF=BF=BDs non initialis=EF=BF=BDes du m=EF=BF=BDme type dans l= e contexte de la persistance + jusqu'=EF=BF=BD la taille du batch. + + @org.hibernate.annotations.Proxy d=EF=BF=BD= finit les + attributs de chargement de l'entit=EF=BF=BD. lazy (valeur par d=EF= =BF=BDfaut) d=EF=BF=BDfinit si + la classe est charg=EF=BF=BDe =EF=BF=BD la demande ou non. proxyClas= sName est l'interface + utilis=EF=BF=BDe pour g=EF=BF=BDn=EF=BF=BDrer le proxy (par d=EF=BF= =BDfaut, la classe elle-m=EF=BF=BDme). + + @org.hibernate.annotations.Where d=EF=BF=BD= finit une + clause WHERE SQL optionnelle utilis=EF=BF=BDe lorsque des instances = de cette + classe sont r=EF=BF=BDcup=EF=BF=BDr=EF=BF=BDes. + + @org.hibernate.annotations.Check d=EF=BF=BD= clare une + contrainte de v=EF=BF=BDrification optionnelle d=EF=BF=BDfinie dans = l'expression + DDL. + + @OnDelete(action=3DOnDeleteAction.CASCADE) = sur des + classes filles jointes : utilise une commande SQL DELETE en cascade = lors + de la suppression plut=EF=BF=BDt que le m=EF=BF=BDcanisme habituel d= 'Hibernate. + + @Table(appliesTo=3D"tableName", indexes =3D { + @Index(name=3D"index1", columnNames=3D{"column1", "column2"} ) } ) + cr=EF=BF=BDe les index d=EF=BF=BDfinis sur les colonnes de la table + tableName. Cela peut s'appliquer sur une table pr= imaire + ou une table secondaire. L'annotation @Tables vous + permet d'avoir des index sur des tables diff=EF=BF=BDrentes. Cette a= nnotation est + attendue l=EF=BF=BD o=EF=BF=BD @javax.persistence.Table ou + @javax.persistence.SecondaryTable(s) sont + d=EF=BF=BDclar=EF=BF=BDes. + + + @org.hibernate.annotations.Table est un + compl=EF=BF=BDment, pas un remplacement de + @javax.persistence.Table. Surtout, si vous souh= aitez + changer le nom par d=EF=BF=BDfaut d'une table, vous devez utiliser + @javax.persistence.Table, pas + @org.hibernate.annotations.Table. + + + @Entity +(a)BatchSize(size=3D5) +(a)org.hibernate.annotations.Entity( + selectBeforeUpdate =3D true, + dynamicInsert =3D true, dynamicUpdate =3D true, + optimisticLock =3D OptimisticLockType.ALL, + polymorphism =3D PolymorphismType.EXPLICIT) +(a)Where(clause=3D"1=3D1") +(a)org.hibernate.annotations.Table(name=3D"Forest", indexes =3D { @Index(n= ame=3D"idx", columnNames =3D { "name", "length" } ) } ) +public class Forest { ... }@Entity +(a)Inheritance( + strategy=3DInheritanceType.JOINED +) +public class Vegetable { ... } + +(a)Entity +(a)OnDelete(action=3DOnDeleteAction.CASCADE) +public class Carrot extends Vegetable { ... } + + + + Identifiant + + @org.hibernate.annotations.GenericGenerator= vous + permet de d=EF=BF=BDfinir un g=EF=BF=BDn=EF=BF=BDrateur d'identifian= ts Hibernate + sp=EF=BF=BDcifique. + + @Id @GeneratedValue(generator=3D"system-uuid") +(a)GenericGenerator(name=3D"system-uuid", strategy =3D "uuid") +public String getId() { + +(a)Id @GeneratedValue(generator=3D"hibseq") +(a)GenericGenerator(name=3D"hibseq", strategy =3D "seqhilo", + parameters =3D { + @Parameter(name=3D"max_lo", value =3D "5"), + @Parameter(name=3D"sequence", value=3D"heybabyhey") + } +) +public Integer getId() { + + strategy est le nom court de la strat=EF=BF= =BDgie du + g=EF=BF=BDn=EF=BF=BDrateur Hibernate3 ou le nom pleinement qualifi= =EF=BF=BD de la classe d'une + impl=EF=BF=BDmentation de IdentifierGenerator= . Vous pouvez + ajouter des param=EF=BF=BDtres avec l'attribut + parameters. + + Contrairement =EF=BF=BD son pendant standard, + @GenericGenerator peut =EF=BF=BDte utilis=EF=BF= =BDe dans les + annotations au niveau du package, en faisant ainsi un g=EF=BF=BDn=EF= =BF=BDrateur de niveau + applicatif (comme s'il =EF=BF=BDtait dans un fichier JPA XML). + + @GenericGenerator(name=3D"hibseq", strategy =3D "seq= hilo", + parameters =3D { + @Parameter(name=3D"max_lo", value =3D "5"), + @Parameter(name=3D"sequence", value=3D"heybabyhey") + } +) +package org.hibernate.test.model + + + + Propri=EF=BF=BDt=EF=BF=BD + + + Type d'acc=EF=BF=BDs + + Le type d'acc=EF=BF=BDs est d=EF=BF=BDduit de la position de + @Id ou de @EmbeddedId dans la + hi=EF=BF=BDrarchie de l'entit=EF=BF=BD. Les entit=EF=BF=BDs filles= , les objets embarqu=EF=BF=BDs et les + entit=EF=BF=BDs parentes mapp=EF=BF=BDs h=EF=BF=BDritent du type d= 'acc=EF=BF=BDs de l'entit=EF=BF=BD + racine. + + Dans Hibernate, vous pouvez surcharger le type d'acc=EF=BF= =BDs + pour : + + + + utiliser une strat=EF=BF=BDgie d'acc=EF=BF=BDs personnal= is=EF=BF=BDe + + + + param=EF=BF=BDtrer finement le type d'acc=EF=BF=BDs au n= iveau de la classe ou + au niveau de la propri=EF=BF=BDt=EF=BF=BD + + + + Une annocation @AccessType a =EF=BF=BDt=EF=BF=BD pr=EF=BF=BD= sent=EF=BF=BDe pour prendre en charge + ce comportement. Vous pouvez d=EF=BF=BDfinir le type d'acc=EF=BF= =BDs sur : + + + + une entit=EF=BF=BD + + + + une classe parente + + + + un objet embarqu=EF=BF=BD + + + + une propri=EF=BF=BDt=EF=BF=BD + + + + Le type d'acc=EF=BF=BDs est surcharg=EF=BF=BD pour l'=EF=BF= =BDl=EF=BF=BDment annot=EF=BF=BD, si surcharg=EF=BF=BD + sur une classe, toutes les propri=EF=BF=BDt=EF=BF=BDs de la classe= donn=EF=BF=BDe h=EF=BF=BDritent du + type d'acc=EF=BF=BDs. Pour les entit=EF=BF=BDs racines, le type d'= acc=EF=BF=BDs est consid=EF=BF=BDr=EF=BF=BD + par d=EF=BF=BDfaut comme celui de la hi=EF=BF=BDrarchie enti=EF=BF= =BDre (surchargeable au niveau + de la classe ou de la propri=EF=BF=BDt=EF=BF=BD). + + Si le type d'acc=EF=BF=BDs est marqu=EF=BF=BD comme "propri= =EF=BF=BDt=EF=BF=BD", les getters sont + parcourus pour examiner les annotations, si le type d'acc=EF=BF=BD= s est marqu=EF=BF=BD + comme "champ", ce sont les champs qui sont parcourus pour les + annotations. Sinon les =EF=BF=BDl=EF=BF=BDments marqu=EF=BF=BDs av= ec @Id ou @embeddedId sont + scann=EF=BF=BDs. + + Vous pouvez surcharger une type d'acc=EF=BF=BDs pour une pro= pri=EF=BF=BDt=EF=BF=BD, mais + l'=EF=BF=BDl=EF=BF=BDment annot=EF=BF=BD ne sera pas influenc=EF= =BF=BD : par exemple, une entit=EF=BF=BD ayant + un type d'acc=EF=BF=BDs field, peut annoter un = champ avec + @AccessType("property"), le type d'acc=EF=BF=BD= s sera alors + "property" pour cet attribut, des annotations devront encore =EF= =BF=BDtre + port=EF=BF=BDes sur les champs. + + Si une classe parente ou un objet embarquable n'est pas anno= t=EF=BF=BD, le + type d'acc=EF=BF=BDs de l'entit=EF=BF=BD racine est utilis=EF=BF= =BD (m=EF=BF=BDme si un type d'acc=EF=BF=BDs a + =EF=BF=BDt=EF=BF=BD d=EF=BF=BDfini sur une classe parente ou un ob= jet embarquable + interm=EF=BF=BDdiaire). Le principe de la poup=EF=BF=BDe russe ne = s'applique pas. + + @Entity +public class Person implements Serializable { + @Id @GeneratedValue // type d'acc=EF=BF=BDs "champ" + Integer id; + + @Embedded + @AttributeOverrides({ + @AttributeOverride(name =3D "iso2", column =3D @Column(name =3D "bornI= so2")), + @AttributeOverride(name =3D "name", column =3D @Column(name =3D "bornC= ountryName")) + }) + Country bornIn; +} + +(a)Embeddable +@AccessType("property") // surcharge le= type d'acc=EF=BF=BDs pour toutes les propri=EF=BF=BDt=EF=BF=BDs dans Count= ry +public class Country implements Serializable { + private String iso2; + private String name; + + public String getIso2() { + return iso2; + } + + public void setIso2(String iso2) { + this.iso2 =3D iso2; + } + + @Column(name =3D "countryName") + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} + + + + + Formule + + Parfois, vous voulez effectuer certains calculs par la base = de + donn=EF=BF=BDes plut=EF=BF=BDt que par la JVM, ou vous pourriez au= ssi vouloir cr=EF=BF=BDer une + sorte de colonne virtuelle. Vous pouvez utilisez un fragment SQL (= alias + une formule) plut=EF=BF=BDt que de mapper un propri=EF=BF=BDt=EF= =BF=BD sur une colonne. Cette + sorte de propri=EF=BF=BDt=EF=BF=BD est en lecture seule (sa valeur= est calcul=EF=BF=BDe par + votre formule). + + @Formula("obj_length * obj_height * obj_width") +public long getObjectVolume() + + Le fragment SQL peut =EF=BF=BDtre aussi complexe que vous le= souhaitez, + m=EF=BF=BDme avec des sous-selects inclus. + + + + Type + + @org.hibernate.annotations.Type surcharge= le + type Hibernate utilis=EF=BF=BD par d=EF=BF=BDfaut : ce n'est g=EF= =BF=BDn=EF=BF=BDralement pas n=EF=BF=BDcessaire + puisque le type est correctement inf=EF=BF=BDr=EF=BF=BD par Hibern= ate. Veuillez vous + r=EF=BF=BDf=EF=BF=BDrer au guide de r=EF=BF=BDf=EF=BF=BDrence Hibe= rnate pour plus d'informations sur les + types Hibernate. + + @org.hibernate.annotations.TypeDef et + @org.hibernate.annotations.TypeDefs vous permet= tent + de d=EF=BF=BDclarer des d=EF=BF=BDfinitions de type. Ces annotatio= ns sont plac=EF=BF=BDes au + niveau de la classe ou du package. Notez que ces d=EF=BF=BDfinitio= ns seront + globales pour la session factory (m=EF=BF=BDme au niveau de la cla= sse) et que la + d=EF=BF=BDfinition du type doit =EF=BF=BDtre d=EF=BF=BDfinie avant= n'importe quelle + utilisation. + + @TypeDefs( + { + @TypeDef( + name=3D"caster", + typeClass =3D CasterStringType.class, + parameters =3D { + @Parameter(name=3D"cast", value=3D"lower") + } + ) + } +) +package org.hibernate.test.annotations.entity; + +... +public class Forest { + @Type(type=3D"caster") + public String getSmallText() { + ... +} + + + Lors de l'utilisation d'un type utilisateur compos=EF=BF=BD,= vous devrez + exprimer les d=EF=BF=BDfinitions des colonnes. L'annotation + @Columns a =EF=BF=BDt=EF=BF=BD mise en place da= ns ce but. + + @Type(type=3D"org.hibernate.test.annotations.entit= y.MonetaryAmountUserType") +(a)Columns(columns =3D { + @Column(name=3D"r_amount"), + @Column(name=3D"r_currency") +}) +public MonetaryAmount getAmount() { + return amount; +} + + +public class MonetaryAmount implements Serializable { + private BigDecimal amount; + private Currency currency; + ... +} + + + + Index + + Vous pouvez d=EF=BF=BDfinir un index sur une colonne particu= li=EF=BF=BDre en + utilisant l'annotation @Index sur une propri=EF= =BF=BDt=EF=BF=BD d'une + colonne, l'attribut columnNames sera ignor=EF=BF=BD. + + @Column(secondaryTable=3D"Cat1") +(a)Index(name=3D"story1index") +public String getStoryPart1() { + return storyPart1; +} + + + + @Parent + + A l'int=EF=BF=BDrieur d'un objet embarquable, vous pouvez d= =EF=BF=BDfinir + une des propri=EF=BF=BDt=EF=BF=BDs comme un pointeur vers l'=EF=BF= =BDl=EF=BF=BDment + propri=EF=BF=BDtaire. + + @Entity +public class Person { + @Embeddable public Address address; + ... +} + +(a)Embeddable +public class Address { + @Parent public Person owner; + ... +} + + +person =3D=3D person.address.owner + + + + Propri=EF=BF=BDt=EF=BF=BDs g=EF=BF=BDn=EF=BF=BDr=EF=BF=BDes= + + Certaines propri=EF=BF=BDt=EF=BF=BDs sont g=EF=BF=BDn=EF=BF= =BDr=EF=BF=BDes au moment de l'insertion ou de + la mise =EF=BF=BD jour par votre base de donn=EF=BF=BDes. Hibernat= e peut traiter de + telles propri=EF=BF=BDt=EF=BF=BDs et d=EF=BF=BDclencher un select = subs=EF=BF=BDquent pour lire ces + propri=EF=BF=BDt=EF=BF=BDs. + + @Entity +public class Antenna { + @Id public Integer id; + @Generated(GenerationTime.ALWAYS) @Column(insertable =3D false, updata= ble =3D false) + public String longitude; + + @Generated(GenerationTime.INSERT) @Column(insertable =3D false) + public String latitude; +} + + Quand vous annotez votre propri=EF=BF=BDt=EF=BF=BD avec + @Generated, vous devez vous assurer que l'inser= tion + et la mise =EF=BF=BD jour n'entreront pas en conflit avec la strat= =EF=BF=BDgie de + g=EF=BF=BDn=EF=BF=BDration que vous avez choisie. Lorsque Generati= onTime.INSERT est + choisi, la propri=EF=BF=BDt=EF=BF=BD ne doit pas contenir de colon= nes ins=EF=BF=BDrables ; + lorsque GenerationTime.ALWAYS est choisi, la propri=EF=BF=BDt=EF= =BF=BD ne doit pas + contenir de colonnes qui puissent =EF=BF=BDtre ins=EF=BF=BDr=EF=BF= =BDes ou mises =EF=BF=BD jour. + + Les propri=EF=BF=BDt=EF=BF=BDs @Version n= e peuvent pas (par + conception) =EF=BF=BDtre @Generated(INSERT), el= les doivent + =EF=BF=BDtre NEVER ou ALWAYS= . + + + + + H=EF=BF=BDritage + + SINGLE_TABLE est une strat=EF=BF=BDgie tr=EF=BF=BDs puissante = mais parfois, et + surtout pour des syst=EF=BF=BDmes pr=EF=BF=BD-existants, vous ne pou= vez pas ajouter une + colonne discriminante suppl=EF=BF=BDmentaire. Pour cela Hibernate a = mis en place + la notion de formule discriminante : + @DiscriminatorFormula est une rempla=EF=BF=BDcant= de + @DiscriminatorColumn et utilise un fragment SQL e= n tant + que formule pour la r=EF=BF=BDsolution du discriminant (pas besoin d= 'avoir une + colonne d=EF=BF=BDdi=EF=BF=BDe). + + @Entity +(a)DiscriminatorForumla("case when forest_type is null then 0 else forest_= type end") +public class Forest { ... } + + Par d=EF=BF=BDfaut, lors du requ=EF=BF=BDtage sur les entit=EF= =BF=BDs les plus hautes, + Hibernate ne met pas de restriction sur la colonne discriminante. Ce= ci + peut =EF=BF=BDtre un inconv=EF=BF=BDnient si cette colonne contient = des valeurs qui ne sont + pas mapp=EF=BF=BDes dans votre hi=EF=BF=BDrarchie (avec + @DiscriminatorValue). Pour contourner ca, vous po= uvez + utilser @ForceDiscriminator (au niveau de la clas= se, + =EF=BF=BD c=EF=BF=BDt=EF=BF=BD de @DiscriminatorColumn). Hibernate listera + alors les valeurs disponibles lors du chargement des entit=EF=BF=BDs= . + + + + Annotations concernant les simples associations + + Par d=EF=BF=BDfaut, lorsqu'Hibernate ne peut pas r=EF=BF=BDsou= dre l'association + parce que l'=EF=BF=BDl=EF=BF=BDment associ=EF=BF=BD attendu n'est pa= s dans la base de donn=EF=BF=BDes + (mauvais identifiant sur la colonne de l'association), une exception= est + lev=EF=BF=BDe par Hibernate. Cela pourrait =EF=BF=BDtre un inconv=EF= =BF=BDnient pour des sch=EF=BF=BDmas + pr=EF=BF=BD-existants et mal maintenus. Vous pouvez demander =EF=BF= =BD Hibernate d'ignorer + de tels =EF=BF=BDl=EF=BF=BDments plut=EF=BF=BDt que de lever une exc= eption en utilisant + l'annotation @NotFound. Cette annotation peut =EF= =BF=BDtre + utilis=EF=BF=BDe sur une association @OneToOne (a= vec une clef + =EF=BF=BDtrang=EF=BF=BDre), @ManyToOne, = @OneToMany + ou @ManyToMany. + + @Entity +public class Child { + ... + @ManyToOne + @NotFound(action=3DNotFoundAction.IGNORE) + public Parent getParent() { ... } + ... +} + + Parfois vous voulez d=EF=BF=BDl=EF=BF=BDguer =EF=BF=BD votre b= ase de donn=EF=BF=BDes la suppression + en cascade lorsqu'une entit=EF=BF=BD donn=EF=BF=BDe est supprim=EF= =BF=BDe. + + @Entity +public class Child { + ... + @ManyToOne + @OnDelete(action=3DOnDeleteAction.CASCADE) + public Parent getParent() { ... } + ... +} + + Dans ce cas, Hibernate g=EF=BF=BDn=EF=BF=BDre une contrainte d= e suppression en + cascade au niveau de la base de donn=EF=BF=BDes. + + Les contraintes de clef =EF=BF=BDtrang=EF=BF=BDre, bien que g= =EF=BF=BDn=EF=BF=BDr=EF=BF=BDes par Hibernate, + ont un nom justement illisible. Vous pouvez surcharger le nom de la + contrainte par l'utilisation de @ForeignKey. + + @Entity +public class Child { + ... + @ManyToOne + @ForeignKey(name=3D"FK_PARENT") + public Parent getParent() { ... } + ... +} + +alter table Child add constraint FK_PARENT foreign key (parent_id) referen= ces Parent + + + Options de chargement et modes de r=EF=BF=BDcup=EF=BF=BDrat= ion + + EJB3 arrive avec l'option fetch pour d=EF= =BF=BDfinir + le chargement =EF=BF=BD la demande et les modes de r=EF=BF=BDcup= =EF=BF=BDration, cependant + Hibernate a beaucoup plus d'options dans ce domaine. Pour finement + param=EF=BF=BDtrer le chargement =EF=BF=BD la demande et les strat= =EF=BF=BDgies de r=EF=BF=BDcup=EF=BF=BDration, + quelques annotations suppl=EF=BF=BDmentaires ont =EF=BF=BDt=EF=BF= =BD mises en place : + + + + @LazyToOne : d=EF=BF=BDfinit l'option= de chargement + =EF=BF=BD la demande sur les associations @ManyToOne<= /literal> et + @OneToOne. LazyToOneOption + peut =EF=BF=BDtre PROXY (ie utiliser un cha= rgement =EF=BF=BD la + demande bas=EF=BF=BD sur un proxy), NO_PROXY (utilise + un chargement =EF=BF=BD la demande sur l'ajout de bytecode - n= otez qu'un + temps de construction du bytecode est n=EF=BF=BDcessaire) et + FALSE (association sans chargement =EF=BF= =BD la + demande) ; + + + + @LazyCollection : d=EF=BF=BDfinit l'o= ption de + chargement =EF=BF=BD la demande sur les associations + @ManyToMany et @OneToMany. + LazyCollectionOption peut =EF=BF=BDtre TRUE= (la + collection est charg=EF=BF=BDe =EF=BF=BD la demande lorsque so= n =EF=BF=BDtat est acc=EF=BF=BDd=EF=BF=BD), + EXTRA (la collection est charg=EF=BF=BDe = =EF=BF=BD la demande et + toutes les op=EF=BF=BDrations essaieront d'=EF=BF=BDviter le c= hargement de la + collection, c'est surtout utile pour de grosses collections lo= rsque + le chargement de tous les =EF=BF=BDl=EF=BF=BDments n'est pas n= =EF=BF=BDcessaire) et + FALSE (association sans chargement =EF=BF= =BD la + demande) ; + + + + @Fetch : d=EF=BF=BDfinit une strat=EF= =BF=BDgie de + r=EF=BF=BDcup=EF=BF=BDration utilis=EF=BF=BDe pour charger l'a= ssociation. + FetchMode peut =EF=BF=BDtre + SELECT (un select est d=EF=BF=BDclench=EF= =BF=BD lorsque + l'association a besoin d'=EF=BF=BDtre charg=EF=BF=BDe), SUBSELECT + (disponible uniquement pour des collections, utilise une strat= =EF=BF=BDgie + de sous select - veuillez vous r=EF=BF=BDf=EF=BF=BDrer =EF=BF= =BD la documentation de + r=EF=BF=BDf=EF=BF=BDrence d'Hibernate pour plus d'informations= ) ou + JOIN (utilise un JOIN SQL pour charger + l'association lors du chargement de l'entit=EF=BF=BD propri=EF= =BF=BDtaire). + JOIN surcharge n'importe quel attribut de + chargement =EF=BF=BD la demande (une association charg=EF=BF= =BDe avec la strat=EF=BF=BDgie + JOIN ne peut pas =EF=BF=BDtre charg=EF=BF= =BDe =EF=BF=BD la + demande). + + + + Les annotations Hibernate surchargent les options de r=EF=BF= =BDcup=EF=BF=BDration + EJB3. + + + Chargement =EF=BF=BD la demande et options de r=EF=BF=BDc= up=EF=BF=BDration + =EF=BF=BDquivalentes + + + + + Annotations + + Chargement =EF=BF=BD la demande + + R=EF=BF=BDcup=EF=BF=BDration + + + + + + @[One|Many]ToOne](fetch=3DFetchType.LAZY) + + @LazyToOne(PROXY) + + @Fetch(SELECT) + + + + @[One|Many]ToOne](fetch=3DFetchType.EAGER) + + @LazyToOne(FALSE) + + @Fetch(JOIN) + + + + @ManyTo[One|Many](fetch=3DFetchType.LAZY) + + @LazyCollection(TRUE) + + @Fetch(SELECT) + + + + @ManyTo[One|Many](fetch=3DFetchType.EAGER) + + @LazyCollection(FALSE) + + @Fetch(JOIN) + + + +
+
+
+ + + Annotations concernant les collections + + + Am=EF=BF=BDliorer les configurations des collections + + Il est possible de configurer : + + la taille des batchs pour les collections en utilisant @Bat= chSize + + + + la clause where, en utilisant @Where (appliqu=EF=BF=BDe =EF= =BF=BD l'entit=EF=BF=BD cible) + ou @WhereJoinTable (appliqu=EF=BF=BDe =EF=BF=BD la table de= l'association) + + + + la clause de v=EF=BF=BDrification, en utilsant @Check + + + + la clause SQL order by, en utilisant @OrderBy + + + + la strat=EF=BF=BDgie de suppression en cascade avec + @OnDelete(action=3DOnDeleteAction.CASCADE) + + + + Vous pouvez aussi d=EF=BF=BDclarer un comparateur de tri, ut= ilisez + l'annotation @Sort. Exprimez le type de compara= teur + que vous voulez entre "non tri=EF=BF=BD" (NdT : unsorted), "ordre = naturel" + (NdT : natural) ou un comparateur personnalis=EF=BF=BD. Si vous vo= ulez utilisez + votre propre impl=EF=BF=BDmentation de comparateur, vous devrez in= diquer la + classe d'impl=EF=BF=BDmentation en utilisant l'attribut + comparator. Notez que vous avez besoin d'utilis= er + l'interface SortedSet ou + SortedMap. + + @OneToMany(cascade=3DCascadeType.ALL, fetch=3D= FetchType.EAGER) + @JoinColumn(name=3D"CUST_ID") + @Sort(type =3D SortType.COMPARATOR, comparator =3D TicketComparator.cl= ass) + @Where(clause=3D"1=3D1") + @OnDelete(action=3DOnDeleteAction.CASCADE) + public SortedSet<Ticket> getTickets() { + return tickets; + } + + Veuillez vous r=EF=BF=BDf=EF=BF=BDrer aux descriptions pr=EF= =BF=BDc=EF=BF=BDdentes de ces + annotations pour plus d'informations. + + Les contraintes de clef =EF=BF=BDtrang=EF=BF=BDre, bien que = g=EF=BF=BDn=EF=BF=BDr=EF=BF=BDes par + Hibernate, ont un nom illisible. Vous pouvez surcharger le nom de = la + contrainte en utilisant @ForeignKey. Notez que = cette + annotation doit =EF=BF=BDtre plac=EF=BF=BDe du c=EF=BF=BDt=EF=BF= =BD poss=EF=BF=BDdant la relation, + inverseName r=EF=BF=BDf=EF=BF=BDren=EF=BF=BDant= la contrainte de l'autre + c=EF=BF=BDt=EF=BF=BD. + + @Entity +public class Woman { + ... + @ManyToMany(cascade =3D {CascadeType.ALL}) + @ForeignKey(name =3D "TO_WOMAN_FK", inverseNam= e =3D "TO_MAN_FK") + public Set<Man> getMens() { + return mens; + } +} + +alter table Man_Woman add constraint TO_WOMAN_FK foreign key (woman_id) re= ferences Woman +alter table Man_Woman add constraint TO_MAN_FK foreign key (man_id) refere= nces Man + + + + Types de collection extra + + + List + + Outre EJB3, Hibernate Annotations prend en charge les v=EF= =BF=BDritables + List et Array. Map= pez + votre collection de la m=EF=BF=BDme mani=EF=BF=BDre que d'habitu= de et ajoutez + l'annotation @IndexColumn. Cette annotation v= ous + permet de d=EF=BF=BDcrire la colonne qui contiendra l'index. Vou= s pouvez aussi + d=EF=BF=BDclarer la valeur de l'index en base de donn=EF=BF=BDes= qui repr=EF=BF=BDsente le + premier =EF=BF=BDl=EF=BF=BDment (alias index de base). La valeur= habituelle est + 0 ou 1. + + @OneToMany(cascade =3D CascadeType.ALL) +(a)IndexColumn(name =3D "drawer_position", base=3D1) +public List<Drawer> getDrawers() { + return drawers; +} + + + Si vous oubliez de positionner + @IndexColumn, la s=EF=BF=BDmantique du bag = est appliqu=EF=BF=BDe. + Si vous voulez la s=EF=BF=BDmantique du bag sans ses limitatio= ns, consid=EF=BF=BDrez + l'utilisation de @CollectionId. + + + + + Map + + Hibernate Annotations prend aussi en charge le mapping de + v=EF=BF=BDritables Maps, si @javax.persistence.MapKey n'est + pas positionn=EF=BF=BDe, Hibernate mappera l'=EF=BF=BDl=EF=BF=BD= ment clef ou l'objet + embarquable dans ses propres colonnes. Pour surcharger les colon= nes + par d=EF=BF=BDfaut, vous pouvez utiliser + @org.hibernate.annotations.MapKey si votre cl= ef est + un type de base (par d=EF=BF=BDfaut =EF=BF=BD mapkey) ou un objet + embarquable, ou vous pouvez utiliser + @org.hibernate.annotations.MapKeyManyToMany si + votre clef est une entit=EF=BF=BD. + + + + Associations bidirectionnelle avec des collections index= =EF=BF=BDes + + Une association bidirectionnelle o=EF=BF=BD une extr=EF=BF= =BDmit=EF=BF=BD est + repr=EF=BF=BDsent=EF=BF=BDe comme une @IndexColumn ou une + @org.hibernate.annotations.MapKey[ManyToMany] + requiert une consid=EF=BF=BDration sp=EF=BF=BDciale. S'il y a un= e propri=EF=BF=BDt=EF=BF=BD de la + classe enfante qui mappe la colonne de l'index, pas de probl=EF= =BF=BDme, nous + pouvons continuer en utilisant mappedBy sur le + mapping de la collection : + + @Entity +public class Parent { + @OneToMany(mappedBy=3D"parent") + @org.hibernate.annotations.MapKey(columns=3D@Column(name=3D"name")) + private Map<String, Child> children; + ... +} + +(a)Entity +public class Child { + ... + @Basic + private String name; + + @ManyToOne + @JoinColumn(name=3D"parent_id", nullable=3Dfalse) + private Parent parent; + ... +} + + Mais s'il n'y a pas de telle propri=EF=BF=BDt=EF=BF=BD sur= la classe enfante, + nous ne pouvons pas penser que l'association est vraiment + bidirectionnelle (il y a des informations disponibles =EF=BF=BD = une extr=EF=BF=BDmit=EF=BF=BD + qui ne sont pas disponibles =EF=BF=BD l'autre). Dans ce cas, nou= s ne pouvons + pas mapper la collection avec mappedBy. A la = place, + nous pourrions utiliser le mapping suivant : + + @Entity +public class Parent { + @OneToMany + @org.hibernate.annotations.MapKey(columns=3D@Column(name=3D"name")) + @JoinColumn(name=3D"parent_id", nullable=3Dfalse) + private Map<String, Child> children; + ... +} + +(a)Entity +public class Child { + ... + @ManyToOne + @JoinColumn(name=3D"parent_id", insertable=3Dfalse, updatable=3Dfalse,= nullable=3Dfalse) + private Parent parent; + ... +} + + Notez que dans ce mapping, l'extr=EF=BF=BDmit=EF=BF=BD de = l'association dont la + valeur est une collection est responsable des mises =EF=BF=BD jo= ur pour la + clef =EF=BF=BDtrang=EF=BF=BDre. + + + + Bag avec une clef primaire + + Une autre fonctionnalit=EF=BF=BD int=EF=BF=BDressante est = la possibilit=EF=BF=BD de + d=EF=BF=BDfinir une clef primaire subrog=EF=BF=BDe =EF=BF=BD une= collection bag. Ceci enl=EF=BF=BDve + pas mal d'inconv=EF=BF=BDnients des bags : mise =EF=BF=BD jour e= t suppression + sont efficaces, plus d'un bag EAGER par requ= =EF=BF=BDte ou + par entit=EF=BF=BD. Cette clef primaire sera contenue dans une c= olonne + suppl=EF=BF=BDmentaire de votre table de collection mais ne sea = pas visible + par l'application Java. @CollectionId est utilis=EF=BF=BDe pour = marquer une + collection comme "id bag", ca permet aussi de surcharger les col= onnes + de la clef primaire, le type de la clef primaire et la strat=EF= =BF=BDgie du + g=EF=BF=BDn=EF=BF=BDrateur. La strat=EF=BF=BDgie peut =EF=BF=BDt= re identity, ou + n'importe quel nom de g=EF=BF=BDn=EF=BF=BDrateur d=EF=BF=BDfini = de votre application. + + @Entity +(a)TableGenerator(name=3D"ids_generator", table=3D"IDS") +public class Passport { + ... + + @ManyToMany(cascade =3D CascadeType.ALL) + @JoinTable(name=3D"PASSPORT_VISASTAMP") + @CollectionId( + columns =3D @Column(name=3D"COLLECTION_ID"), + type=3D@Type(type=3D"long"), + generator =3D "ids_generator" + ) + private Collection<Stamp> visaStamp =3D new ArrayList(); + ... +} + + + + Collection d'=EF=BF=BDl=EF=BF=BDments ou d'=EF=BF=BDl=EF= =BF=BDments compos=EF=BF=BDs + + Hibernate Annotations prend aussi en charge les collection= s de + types core (Integer, String, Enums, ...), les collections d'obje= ts + embarquables et m=EF=BF=BDme les tableaux de types primitifs. Ce= sont des + collections d'=EF=BF=BDl=EF=BF=BDments. + + Une collection d'=EF=BF=BDl=EF=BF=BDments doit =EF=BF=BDtr= e annot=EF=BF=BDe comme + @CollectionOfElements (en tant que rempla=EF= =BF=BDant de + @OneToMany). Pour d=EF=BF=BDfinir la table de= la + collection, l'annotation @JoinTable est utili= s=EF=BF=BDe + sur la propri=EF=BF=BDt=EF=BF=BD de l'association, join= Columns + d=EF=BF=BDfinit les colonnes de jointure entre la table de l'ent= it=EF=BF=BD primaire + et la table de la collection (inverseJoincolumn est inutile et + devrait =EF=BF=BDtre laiss=EF=BF=BD =EF=BF=BD vide). Pour une co= llection de types core ou un + tableau de types primitifs, vous pouvez surcharger la d=EF=BF=BD= finition de la + colonne de l'=EF=BF=BDl=EF=BF=BDment en utilisant @Colu= mn sur la + propri=EF=BF=BDt=EF=BF=BD de l'association. Vous pouvez aussi su= rcharger les colonnes + d'une collection d'objets embarquables en utilisant + @AttributeOverride. Pour atteindre l'=EF=BF= =BDl=EF=BF=BDment de la + collection, vous avez besoin d'ajouter "element" au nom de l'att= ribut + surcharg=EF=BF=BD (p. ex. "element" pour les types core, ou "ele= ment.serial" + pour la propri=EF=BF=BDt=EF=BF=BD serial d'un =EF=BF=BDl=EF=BF= =BDment embarqu=EF=BF=BD). Pour atteindre + l'index/clef d'une collection, ajoutez "key" =EF=BF=BD la place.= + + @Entity +public class Boy { + private Integer id; + private Set<String> nickNames =3D new HashSet<String>(); + private int[] favoriteNumbers; + private Set<Toy> favoriteToys =3D new HashSet<Toy>(); + private Set<Character> characters =3D new HashSet<Character&g= t;(); + + @Id @GeneratedValue + public Integer getId() { + return id; + } + + @CollectionOfElements + public Set<String> getNickNames() { + return nickNames; + } + + @CollectionOfElements + @JoinTable( + table=3D@Table(name=3D"BoyFavoriteNumbers"), + joinColumns =3D @JoinColumn(name=3D"BoyId") + ) + @Column(name=3D"favoriteNumber", nullable=3Dfalse) + @IndexColumn(name=3D"nbr_index") + public int[] getFavoriteNumbers() { + return favoriteNumbers; + } + + @CollectionOfElements + @AttributeOverride( name=3D"element.serial", column=3D@Column(name=3D"= serial_nbr") ) + public Set<Toy> getFavoriteToys() { + return favoriteToys; + } + + @CollectionOfElements + public Set<Character> getCharacters() { + return characters; + } + ... +} + +public enum Character { + GENTLE, + NORMAL, + AGGRESSIVE, + ATTENTIVE, + VIOLENT, + CRAFTY +} + +(a)Embeddable +public class Toy { + public String name; + public String serial; + public Boy owner; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getSerial() { + return serial; + } + + public void setSerial(String serial) { + this.serial =3D serial; + } + + @Parent + public Boy getOwner() { + return owner; + } + + public void setOwner(Boy owner) { + this.owner =3D owner; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final Toy toy =3D (Toy) o; + + if ( !name.equals( toy.name ) ) return false; + if ( !serial.equals( toy.serial ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D name.hashCode(); + result =3D 29 * result + serial.hashCode(); + return result; + } +} + + Sur une collection d'objets embarquables, l'objet embarqua= ble + peut avoir une propri=EF=BF=BDt=EF=BF=BD annot=EF=BF=BDe avec @Parent. + Cette propri=EF=BF=BDt=EF=BF=BD pointera alors vers l'entit=EF= =BF=BD contenant la + collection. + + + Les versions pr=EF=BF=BDc=EF=BF=BDdentes d'Hibernate Ann= otations utilisaient + @OneToMany pour marquer une collection + d'=EF=BF=BDl=EF=BF=BDments. Suite =EF=BF=BD des incoh=EF=BF=BD= rences s=EF=BF=BDmantiques, nous avons mis en + place l'annotation @CollectionOfElements. P= our + marquer des collections d'=EF=BF=BDl=EF=BF=BDments, l'ancienne= fa=EF=BF=BDon fonctionne + encore mais elle est consid=EF=BF=BDr=EF=BF=BDe comme "depreca= ted" et ne sera plus + prise en charge dans les futures versions. + + + + + + + Cache + + Pour optimiser vos acc=EF=BF=BDs =EF=BF=BD la base de donn=EF= =BF=BDes, vous pouvez activer + le cache de second niveau d'Hibernate. Ce cache est configurable par + entit=EF=BF=BD et par collection. + + @org.hibernate.annotations.Cache d=EF=BF=BD= finit la + strat=EF=BF=BDgie de cache et la r=EF=BF=BDgion du cache de second n= iveau donn=EF=BF=BD. Cette + annotation peut =EF=BF=BDtre appliqu=EF=BF=BDe =EF=BF=BD une entit= =EF=BF=BD racine (pas les entit=EF=BF=BDs + filles), et sur les collections. + + @Entity +(a)Cache(usage =3D CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Forest { ... } + + @OneToMany(cascade=3DCascadeType.ALL, fetch=3DFe= tchType.EAGER) + @JoinColumn(name=3D"CUST_ID") + @Cache(usage =3D CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + public SortedSet<Ticket> getTickets() { + return tickets; + } + + + + + + + + + + + + + @Cache( + CacheConcurrencyStrategy usage(); + String region() default ""; + String include() default "all"; +) + + + + usage : la strat=EF=BF=BDgie de concurrence du cache don= n=EF=BF=BD (NONE, + READ_ONLY, NONSTRICT_READ_WRITE, READ_WRITE, TRANSACTIONAL) ;<= /para> + + + + region (optionnel) : la r=EF=BF=BDgion du cache (par d= =EF=BF=BDfaut le nom + complet de la classe avec le nom du package, ou le nom complet= du + r=EF=BF=BDle de la collection) ; + + + + include (optionnel) : "all" pour incl= ure + toutes les propri=EF=BF=BDt=EF=BF=BDs, "non-lazy" pour inclure= seulement les + propri=EF=BF=BDt=EF=BF=BDs qui ne sont pas charg=EF=BF=BDes = =EF=BF=BD la demande (valeur par + d=EF=BF=BDfaut : all). + + + + + + + Filtres + + Hibernate a la capacit=EF=BF=BD d'appliquer des filtres arbitr= aires =EF=BF=BD la + partie sup=EF=BF=BDrieure de vos donn=EF=BF=BDes. Ces filtres sont a= ppliqu=EF=BF=BDs au moment de + l'ex=EF=BF=BDcution sur une session donn=EF=BF=BDe. Vous avez tout d= 'abord besoin de les + d=EF=BF=BDfinir. + + @org.hibernate.annotations.FilterDef ou + @FilterDefs d=EF=BF=BDclarent des d=EF=BF=BDfinit= ions de filtre + utilis=EF=BF=BDes par les filtres ayant le m=EF=BF=BDme nom. Une d= =EF=BF=BDfinition de filtre a + un name() et un tableau de parameters(). Un param=EF=BF=BDtre vous p= ermettra + d'ajuster le comportement du filtre au moment de l'ex=EF=BF=BDcution= . Chaque + param=EF=BF=BDtre est d=EF=BF=BDfini par une @ParamDef qui a un nom et + un type. Vous pouvez aussi d=EF=BF=BDfinir un param=EF=BF=BDtre defa= ultCondition() pour + une @ParamDef donn=EF=BF=BDe pour positionner la = condition par + d=EF=BF=BDfaut =EF=BF=BD utiliser lorsqu'aucune n'est d=EF=BF=BDfini= e dans chaque + @Filter individuelle. Une @FilterDef + peut =EF=BF=BDtre d=EF=BF=BDfinie au niveau de la classe ou du packa= ge. + + Nous avons besoin de d=EF=BF=BDfinir la clause du filtre SQL a= ppliqu=EF=BF=BD au + chargement de l'entit=EF=BF=BD ou au chargement de la collection. + @Filter est utilis=EF=BF=BDe et plac=EF=BF=BDe su= r l'entit=EF=BF=BD ou + l'=EF=BF=BDl=EF=BF=BDment de la collection. + + @Entity +(a)FilterDef(name=3D"minLength", parameters=3D@ParamDef( name=3D"minLength= ", type=3D"integer" ) ) +(a)Filters( { + @Filter(name=3D"betweenLength", condition=3D":minLength <=3D length= and :maxLength >=3D length"), + @Filter(name=3D"minLength", condition=3D":minLength <=3D length") +} ) +public class Forest { ... } + + Lorsque la collection utilise une table d'association comme + repr=EF=BF=BDsentation relationnelle, vous pourriez vouloir applique= r la condition + du filtre =EF=BF=BD la table de l'association elle-m=EF=BF=BDme ou = =EF=BF=BD la table de l'entit=EF=BF=BD + cible. Pour appliquer la contrainte sur l'entit=EF=BF=BD cible, util= isez + l'annotation habituelle @Filter. Cependant, si vo= us + voulez ciblez la table d'association, utilisez l'annotation + @FilterJoinTable. + + @OneToMany + @JoinTable + // filtre sur la table de l'entit=EF=BF=BD cible + @Filter(name=3D"betweenLength", condition=3D":minLength <=3D length= and :maxLength >=3D length") + // filtre sur la table d'association + @FilterJoinTable(name=3D"security", condition=3D":userlevel >=3D re= quredLevel") + public Set<Forest> getForests() { ... } + + + + Requ=EF=BF=BDte + + Puisqu'Hibernate a plus de fonctionnalit=EF=BF=BDs sur les req= u=EF=BF=BDtes nomm=EF=BF=BDes + que d=EF=BF=BDfinies dans la sp=EF=BF=BDcification EJB3, + @org.hibernate.annotations.NamedQuery, + @org.hibernate.annotations.NamedQueries, + @org.hibernate.annotations.NamedNativeQuery et + @org.hibernate.annotations.NamedNativeQueries ont= =EF=BF=BDt=EF=BF=BD + mis en place. Elles ajoutent des attributs =EF=BF=BD la version stan= dard et + peuvent =EF=BF=BDtre utilis=EF=BF=BDes comme rempla=EF=BF=BDant : + + + + flushMode : d=EF=BF=BDfinit le mode de flush de la requ=EF= =BF=BDte (Always, + Auto, Commit ou Manual) + + + + cacheable : indique si la requ=EF=BF=BDte devrait =EF=BF= =BDtre cach=EF=BF=BDe ou + non + + + + cacheRegion : r=EF=BF=BDgion du cache utilis=EF=BF=BDe si = la requ=EF=BF=BDte est + cach=EF=BF=BDe + + + + fetchSize : taille de l'expression de r=EF=BF=BDcup=EF=BF= =BDration JDBC pour + cette requ=EF=BF=BDte + + + + timeout : timeout de la requ=EF=BF=BDte + + + + callable : pour les requ=EF=BF=BDtes natives seulement, me= ttre =EF=BF=BD true + pour les proc=EF=BF=BDdures stock=EF=BF=BDes + + + + comment : si les commentaires sont activ=EF=BF=BDs, le com= mentaire vu + lorsque la requ=EF=BF=BDte est envoy=EF=BF=BDe vers la base de d= onn=EF=BF=BDes + + + + cacheMode : mode d'int=EF=BF=BDraction du cache (get, igno= re, normal, + put ou refresh) + + + + readOnly : indique si les =EF=BF=BDl=EF=BF=BDments r=EF=BF= =BDcup=EF=BF=BDr=EF=BF=BDs =EF=BF=BD partir de la + requ=EF=BF=BDte sont en lecture seule ou pas + + + + Ces indications de fonctionnement peuvent =EF=BF=BDtre positio= nn=EF=BF=BDes sur + les annotations standards @javax.persistence.NamedQuery + avec l'annotation @QueryHint. Un autre avantage c= lef + est la possibilit=EF=BF=BD de positionner ces annotations au niveau = du + package. + +
+
Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/lucene= .xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/lucene.xm= l (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/lucene.xm= l 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,197 @@ + + + Int=EF=BF=BDgration de Lucene avec Hibernate + + Lucene est une biblioth=EF=BF=BDque de la fondation Apache fournis= sant un moteur + de recherche en Java hautement performant. Hibernate Annotations inclut = un + ensemble d'annotations qui vous permettent de marquer n'importe quel obj= et + du mod=EF=BF=BDle de donn=EF=BF=BDes comme indexable et de laisser Hiber= nate maintenir un + index Lucene de toutes les instances persist=EF=BF=BDes via Hibernate. + + Hibernate Lucene est un projet en cours et de nouvelles fonctionna= lit=EF=BF=BDs + sont en pr=EF=BF=BDparation. Donc attendez-vous =EF=BF=BD certains chang= ements avec les + versions ult=EF=BF=BDrieures. + +
+ Mapper les entit=EF=BF=BDs sur l'index + + Tout d'abord, nous devons d=EF=BF=BDclarer une classe persistant= e comme + =EF=BF=BDtant indexable. Ceci se fait en annotant la classe avec + @Indexed : + + @Entity +(a)Indexed(index=3D"indexes/essays") +public class Essay { + ... +} + + L'attribut index indique =EF=BF=BD Hibernate = quel est le + nom du r=EF=BF=BDpertoire Lucene (en g=EF=BF=BDn=EF=BF=BDral un r=EF= =BF=BDpertoire de votre syst=EF=BF=BDme de + fichiers). Si vous souhaitez d=EF=BF=BDfinir un r=EF=BF=BDpertoire de = d=EF=BF=BDpart pour tous vos + index Lucene, vous pouvez utiliser la propri=EF=BF=BDt=EF=BF=BD + hibernate.lucene.default.indexDir dans votre fichie= r de + configuration. + + Les index Lucene contiennent quatre types de champs : + keyword, text, + unstored et unindexed. Hiber= nate + Annotations fournit des annotations pour marquer une propri=EF=BF=BDt= =EF=BF=BD d'une entit=EF=BF=BD + comme =EF=BF=BDtant d'un des trois premiers types. + + @Entity +(a)Indexed(index=3D"indexes/essays") +public class Essay { + ... + + @Id + @Keyword(id=3Dtrue) + public Long getId() { return id; } + + @Text(name=3D"Abstract") + public String getSummary() { return summary; } + + @Lob + @Unstored + public String getText() { return text; } + +} + + Ces annotations d=EF=BF=BDfinissent un index avec trois champs : + id, Abstract et + text. Notez que par d=EF=BF=BDfaut le nom du champ = n'a plus de + majuscules, en suivant la sp=EF=BF=BDcification JavaBean. + + Note : vous devez sp=EF=BF=BDcifier + @Keyword(id=3Dtrue) sur la propri=EF=BF=BDt=EF=BF= =BD identifiante de + votre entit=EF=BF=BD. + + Lucene a la notion of boost factor. C'est un + moyen de donner plus de poids =EF=BF=BD un champ ou =EF=BF=BD un =EF= =BF=BDl=EF=BF=BDment index=EF=BF=BD durant la + proc=EF=BF=BDdure d'indexation. Vous pouvez utiliser @Boost au + niveau du champ ou de la classe. + + La classe analyste utilis=EF=BF=BDe pour indexer les =EF=BF=BDl= =EF=BF=BDments est + configurable par la propri=EF=BF=BDt=EF=BF=BD + hibernate.lucene.analyzer. Si aucune n'est d=EF=BF= =BDfinie, + org.apache.lucene.analysis.standard.StandardAnalyzer + est utilis=EF=BF=BDe par d=EF=BF=BDfaut. +
+ +
+ Configuration + +
+ Configuration du directory + + Lucene a une notion de Directory o=EF=BF=BD l'index est stock= =EF=BF=BD. + L'impl=EF=BF=BDmentation de Directory peut =EF=BF=BDtre personnalis= =EF=BF=BDe mais Lucene arrive, + avec deux impl=EF=BF=BDmentations pr=EF=BF=BDtes =EF=BF=BD l'emploi = compl=EF=BF=BDtes, une sur un syst=EF=BF=BDme + de fichiers et une en m=EF=BF=BDmoire. Hibernate Lucene a la notion = de + DirectoryProvider qui g=EF=BF=BDre la configurati= on et + l'initialisation du Directory Lucene. + + + Liste des Directory Providers int=EF=BF=BDgr=EF=BF=BDs</tit= le> + + <tgroup cols=3D"3"> + <thead> + <row> + <entry align=3D"center">Classe</entry> + + <entry align=3D"center">Description</entry> + + <entry align=3D"center">Propri=EF=BF=BDt=EF=BF=BDs</entry> + </row> + </thead> + + <tbody> + <row> + <entry>org.hibernate.lucene.store.FSDirectoryProvider</entry> + + <entry>Directory base sur le syst=EF=BF=BDme de fichiers. Le= r=EF=BF=BDpertoire + utilis=EF=BF=BD sera + <indexBase>/<<literal>@Index.name</literal>></en= try> + + <entry><literal>indexBase</literal> : r=EF=BF=BDpertoire de = d=EF=BF=BDpart</entry> + </row> + + <row> + <entry>org.hibernate.lucene.store.RAMDirectoryProvider</entr= y> + + <entry>Directory utilisant la m=EF=BF=BDmoire, le directory = sera + uniquement identifi=EF=BF=BD par l'=EF=BF=BDl=EF=BF=BDment + <literal>@Index.name</literal></entry> + + <entry>aucune</entry> + </row> + </tbody> + </tgroup> + </table> + + <para>Si les directory providers int=EF=BF=BDgr=EF=BF=BDs ne r=EF=BF= =BDpondent pas =EF=BF=BD vos besoins, + vous pouvez =EF=BF=BDcrire votre propre directory provider en impl= =EF=BF=BDmentant + l'interface + <classname>org.hibernate.store.DirectoryProvider</classname>.</para> + + <para>Chaque entit=EF=BF=BD index=EF=BF=BDe est associ=EF=BF=BDe =EF= =BF=BD un index Lucene (un index peut + =EF=BF=BDtre partag=EF=BF=BD par diff=EF=BF=BDrentes entit=EF=BF=BDs= mais ce n'est pas le cas en g=EF=BF=BDn=EF=BF=BDral). + Vous pouvez configurer l'index =EF=BF=BD travers des propri=EF=BF=BD= t=EF=BF=BDs pr=EF=BF=BDfix=EF=BF=BDes par + <literal><literal>hibernate.lucene.<indexname></literal></lite= ral>. + Les propri=EF=BF=BDt=EF=BF=BDs par d=EF=BF=BDfaut h=EF=BF=BDrit=EF= =BF=BDes par tous les index peuvent =EF=BF=BDtre + d=EF=BF=BDfinies en utilisant le pr=EF=BF=BDfixe hibernate.lucene.de= fault.</para> + + <para>Pour d=EF=BF=BDfinir le directory provider d'un index donn=EF= =BF=BD, utilisez + <literal>hibernate.lucene.<indexname>.directory_provider</lite= ral>.</para> + + <programlisting>hibernate.lucene.default.directory_provider org.hibe= rnate.lucene.store.FSDirectoryProvider +hibernate.lucene.default.indexDir=3D/usr/lucene/indexes + +hibernate.lucene.Rules.directory_provider org.hibernate.lucene.store.RAMDi= rectoryProvider +</programlisting> + + <para>appliqu=EF=BF=BD =EF=BF=BD</para> + + <programlisting>@Indexed(name=3D"Status") +public class Status { ... } + +(a)Indexed(name=3D"Rules") +public class Rule { ... }</programlisting> + + <para>Ceci cr=EF=BF=BDera un directory syst=EF=BF=BDme de fichiers d= ans + <filename>/usr/lucene/indexes/Status</filename> o=EF=BF=BD les entit= =EF=BF=BDs Status + seront index=EF=BF=BDes, et utilisera un directory m=EF=BF=BDmoire n= omm=EF=BF=BD + <literal>Rules</literal> o=EF=BF=BD les entit=EF=BF=BDs Rule seront = index=EF=BF=BDes.</para> + + <para>Donc vous pouvez facilement d=EF=BF=BDfinir des r=EF=BF=BDgles= g=EF=BF=BDn=EF=BF=BDrales comme le + directory provider et le r=EF=BF=BDpertoire de d=EF=BF=BDpart, et su= rcharger ces valeurs + par d=EF=BF=BDfaut plus tard pour chaque index.</para> + + <para>En =EF=BF=BDcrivant votre propre DirectoryProvider, vous pouve= z aussi + b=EF=BF=BDn=EF=BF=BDficier de ce m=EF=BF=BDcanisme de configuration.= </para> + </section> + + <section id=3D"lucene-configuration-event"> + <title>Activer l'indexation automatique + + Finalement, nous activons le LuceneEventListener + pour les trois =EF=BF=BDv=EF=BF=BDnements Hibernate qui ont lieu apr= =EF=BF=BDs que les changements + sont valid=EF=BF=BDs dans la base de donn=EF=BF=BDes. + + <hibernate-configuration> + ... + <event type=3D"post-commit-update" + <listener + class=3D"org.hibernate.lucene.event.LuceneEventListener"/> + </event> + <event type=3D"post-commit-insert" + <listener + class=3D"org.hibernate.lucene.event.LuceneEventListener"/> + </event> + <event type=3D"post-commit-delete" + <listener + class=3D"org.hibernate.lucene.event.LuceneEventListener"/> + </event> +</hibernate-configuration> + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/setup.= xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/setup.xml= (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/setup.xml= 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,158 @@ + + + Configurer un projet avec des annotat= ions + +
+ Pr=EF=BF=BDrequis + + + + T=EF=BF=BDl=EF=BF=BDchargez et installez la distribution Hib= ernate Annotations =EF=BF=BD + partir du site web d'Hibernate. + + + + Cette version requiert Hibernate 3.2.0.GA ou + sup=EF=BF=BDrieur. N'utilisez pas cette version d'Hibernate Annota= tions avec + une version plus ancienne d'Hibernate 3.x ! + + + + Cette version est connue pour fonctionner avec le noyau 3.2.= 0.CR5 + et 3.2.0.GA d'Hibernate. + + + + Assurez-vous que vous avez le JDK 5.0 d'install=EF=BF=BD. Vo= us pouvez + bien s=EF=BF=BDr continuer =EF=BF=BD utiliser XDoclet et avoir cer= tains des avantages + des m=EF=BF=BDta-donn=EF=BF=BDes bas=EF=BF=BDes sur les annotation= s avec des versions plus + anciennes du JDK. Notez que ce document d=EF=BF=BDcrit seulement l= es annotations + du JDK 5.0 et que vous devez vous r=EF=BF=BDf=EF=BF=BDrer =EF=BF= =BD la documentation de XDoclet + pour plus d'informations. + + +
+ +
+ Configuration + + Tout d'abord, param=EF=BF=BDtrez votre classpath (apr=EF=BF=BDs = avoir cr=EF=BF=BDer un nouveau + projet dans votre IDE favori) : + + Copiez toutes les biblioth=EF=BF=BDques du noyau Hibernate= 3 et toutes + les biblioth=EF=BF=BDques tierces requises (voir lib/README.txt = dans + Hibernate). + + + + Copiez aussi hibernate-annotations.jar et + lib/ejb3-persistence.jar de la distribution + Hibernate Annotations dans votre classpath. + + + + Pour utiliser , ajouter le fich= ier jar + de lucene. + + + + Nous recommandons aussi un petit wrapper pour d=EF=BF=BDmarrer H= ibernate dans + un bloc statique d'initialisation, connu en tant que + HibernateUtil. Vous pourriez avoir vu cette cla= sse + sous diverses formes dans d'autres parties de la documentation Hiberna= te. + Pour prendre en charge Annotation vous devez modifier cette classe d'a= ide + de la mani=EF=BF=BDre suivante :package hello; + +import org.hibernate.*; +import org.hibernate.cfg.*; +import test.*; +import test.animals.Dog; + +public class HibernateUtil { + +private static final SessionFactory sessionFactory; + + static { + try { + + sessionFactory =3D new AnnotationConfi= guration().buildSessionFactory(); + } catch (Throwable ex) { + // Log exception! + throw new ExceptionInInitializerError(ex); + } + } + + public static Session getSession() + throws HibernateException { + return sessionFactory.openSession(); + } +} + + + La partie int=EF=BF=BDressante ici est l'utilisation de + AnnotationConfiguration. Les packages et les cl= asses + annot=EF=BF=BDes sont d=EF=BF=BDclar=EF=BF=BDs dans votre fichier de c= onfiguration XML habituel + (g=EF=BF=BDn=EF=BF=BDralement hibernate.cfg.xml).= Voici un =EF=BF=BDquivalent + de la d=EF=BF=BDclaration ci-dessus : + + <!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> + + <hibernate-configuration> + <session-factory> + <mapping package=3D"test.animals"/&= gt; + <mapping class=3D"test.Flight"/> + <mapping class=3D"test.Sky"/> + <mapping class=3D"test.Person"/> + <mapping class=3D"test.animals.Dog"/> + <mapping resource=3D"test/animals/o= rm.xml"/> + </session-factory> + </hibernate-configuration> + + + Notez que vous pouvez m=EF=BF=BDlanger l'utilisation du fichier = hbm.xml et + celle des annotations. L'=EF=BF=BDl=EF=BF=BDment de ressource peut =EF= =BF=BDtre un fichier hbm ou + un descripteur de d=EF=BF=BDploiement XML EJB3. Cette distinction est = transparente + pour votre proc=EF=BF=BDdure de configuration. + + Alternativement, vous pouvez d=EF=BF=BDfinir les classes annot= =EF=BF=BDes et des + packages en utilisant l'API : + + sessionFactory =3D new AnnotationConfiguration() + .addPackage("test.animals") // le nom complet du packa= ge + .addAnnotatedClass(Flight.class) + .addAnnotatedClass(Sky.class) + .addAnnotatedClass(Person.class) + .addAnnotatedClass(Dog.class) + .addResource("test/animals/orm= .xml") + .buildSessionFactory(); + + Vous pouvez aussi utiliser Hibernate EntityManager qui a son pro= pre + m=EF=BF=BDcanisme de configuration. Veullez vous r=EF=BF=BDf=EF=BF=BDr= er =EF=BF=BD la documentation de ce + projet pour plus de d=EF=BF=BDtails. + + Il n'y a pas d'autres diff=EF=BF=BDrences dans la fa=EF=BF=BDon = d'utiliser les APIs + d'Hibernate, except=EF=BF=BD ce changement de routine de d=EF=BF=BDmar= rage ou le fichier + de configuration. Vous pouvez utiliser votre m=EF=BF=BDthode de config= uration + favorite pour d'autres propri=EF=BF=BDt=EF=BF=BDs (hibernate= .properties, + hibernate.cfg.xml, utilisation des APIs, etc). Vo= us + pouvez m=EF=BF=BDme m=EF=BF=BDlanger les classes persistantes annot=EF= =BF=BDes et des d=EF=BF=BDclarations + hbm.cfg.xml classiques avec la m=EF=BF=BDme + SessionFactory. Vous ne pouvez cependant pas d= =EF=BF=BDclarer + une classe plusieurs fois (soit avec les annotations, soit avec un fic= hier + hbm.xml). Vous ne pouvez pas non plus m=EF=BF=BDlanger des strat=EF=BF= =BDgies de + configuration (hbm vs annotations) dans une hi=EF=BF=BDrarchie d'entit= =EF=BF=BDs + mapp=EF=BF=BDes. + + Pour faciliter la proc=EF=BF=BDdure de migration de fichiers hbm= vers les + annotations, le m=EF=BF=BDcanisme de configuration d=EF=BF=BDtecte la = duplication de mappings + entre les annotations et les fichiers hbm. Les classes d=EF=BF=BDcrite= s dans les + fichiers hbm se voient alors affecter une priorit=EF=BF=BD plus grande= que les + classes annot=EF=BF=BDes. Vous pouvez changer cette priorit=EF=BF=BD a= vec la propri=EF=BF=BDt=EF=BF=BD + hibernate.mapping.precedence. La valeur par d=EF=BF= =BDfaut est : + hbm, class ; la changer en : class, hbm + donne alors la priorit=EF=BF=BD aux classes annot=EF=BF=BDes lorsqu'un= conflit + survient. +
+
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/valida= tor.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/validator= .xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/validator= .xml 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,569 @@ + + + Hibernate Validator + + Les annotations sont une mani=EF=BF=BDre tr=EF=BF=BDs commode et = =EF=BF=BDl=EF=BF=BDgante pour sp=EF=BF=BDcifier + des contraintes invariantes sur un mod=EF=BF=BDle de donn=EF=BF=BDes. Vo= us pouvez, par + exemple, indiquer qu'une propri=EF=BF=BDt=EF=BF=BD ne devrait pas =EF=BF= =BDtre nulle, que le solde + d'un compte devrait =EF=BF=BDtre strictement positif, etc. Ces contraint= es de mod=EF=BF=BDle + de donn=EF=BF=BDes sont d=EF=BF=BDclar=EF=BF=BDes dans le bean lui-m=EF= =BF=BDme en annotant ses propri=EF=BF=BDt=EF=BF=BDs. + Un validateur peut alors les lire et v=EF=BF=BDrifier les violations de = contraintes. + Le m=EF=BF=BDcanisme de validation peut =EF=BF=BDtre ex=EF=BF=BDcut=EF= =BF=BD dans diff=EF=BF=BDrentes couches de + votre application (pr=EF=BF=BDsentation, acc=EF=BF=BDs aux donn=EF=BF=BD= es) sans devoir dupliquer + ces r=EF=BF=BDgles. Hibernate Validator a =EF=BF=BDt=EF=BF=BD con=EF=BF= =BDu dans ce but. + + Hibernate Validator fonctionne sur deux niveaux. D'abord, il est c= apable + de v=EF=BF=BDrifier des violations de contraintes sur les instances d'un= e classe en + m=EF=BF=BDmoire. Ensuite, il peut appliquer les contraintes au m=EF=BF= =BDta-mod=EF=BF=BDle d'Hibernate + et les incorporer au sch=EF=BF=BDma de base de donn=EF=BF=BDes g=EF=BF= =BDn=EF=BF=BDr=EF=BF=BD. + + Chaque annotation de contrainte est associ=EF=BF=BDe =EF=BF=BD l'i= mpl=EF=BF=BDmentation du + validateur responsable de v=EF=BF=BDrifier la contrainte sur l'instance = de l'entit=EF=BF=BD. + Un validateur peut aussi (optionnellement) appliquer la contrainte au + m=EF=BF=BDta-mod=EF=BF=BDle d'Hibernate, permettant =EF=BF=BD Hibernate = de g=EF=BF=BDn=EF=BF=BDrer le DDL qui + exprime la contrainte. Avec le listener d'=EF=BF=BDv=EF=BF=BDnements app= ropri=EF=BF=BD, vous pouvez + ex=EF=BF=BDcuter l'op=EF=BF=BDration de v=EF=BF=BDrification lors des in= sertions et des mises =EF=BF=BD jour + effectu=EF=BF=BDes par Hibernate. Hibernate Validator n'est pas limit=EF= =BF=BD =EF=BF=BD Hibernate. + Vous pouvez facilement l'utiliser n'importe o=EF=BF=BD dans votre applic= ation. + + Lors de la v=EF=BF=BDrification des instances =EF=BF=BD l'ex=EF=BF= =BDcution, Hibernate Validator + retourne des informations =EF=BF=BD propos des violations de contraintes= dans un + tableau de InvalidValues. Parmi d'autres informat= ions, + InvalidValue contient un message de description + d'erreur qui peut inclure les valeurs des param=EF=BF=BDtres associ=EF= =BF=BDs =EF=BF=BD l'annotation + (p. ex. la limite de taille), et des cha=EF=BF=BDnes de caract=EF=BF=BDr= es qui peuvent =EF=BF=BDtre + externalis=EF=BF=BDes avec un ResourceBundle. + + + Contraintes + + + Qu'est-ce qu'une contrainte ? + + Une contrainte est repr=EF=BF=BDsent=EF=BF=BDe par une annotat= ion. Une contrainte a + g=EF=BF=BDn=EF=BF=BDralement des attributs utilis=EF=BF=BDs pour par= am=EF=BF=BDtrer les limites des + contraintes. La contrainte s'applique =EF=BF=BD l'=EF=BF=BDl=EF=BF= =BDment annot=EF=BF=BD. + + + + Contraintes int=EF=BF=BDgr=EF=BF=BDes + + Hibernate Validator arrive avec des contraintes int=EF=BF=BDgr= =EF=BF=BDes, + lesquelles couvrent la plupart des v=EF=BF=BDrifications de donn=EF= =BF=BDes de base. Comme + nous le verrons plus tard, vous n'=EF=BF=BDtes pas limit=EF=BF=BD = =EF=BF=BD celles-ci, vous pouvez + =EF=BF=BDcrire vos propres contraintes en une minute. + +
+ Contraintes int=EF=BF=BDgr=EF=BF=BDes + + + + + + + Annotation + + S'applique =EF=BF=BD + + V=EF=BF=BDrification =EF=BF=BD l'ex=EF=BF=BDcution + + Impact sur les m=EF=BF=BDta-donn=EF=BF=BDes d'Hiberna= te + + + + + + @Length(min=3D, max=3D) + + propri=EF=BF=BDt=EF=BF=BD (String) + + v=EF=BF=BDrifie si la longueur de la cha=EF=BF=BDne d= e caract=EF=BF=BDres est + comprise dans l'intervalle + + la longueur de la colonne sera positionn=EF=BF=BDe = =EF=BF=BD max + + + + @Max(value=3D) + + propri=EF=BF=BDt=EF=BF=BD (nombre ou cha=EF=BF=BDne d= e caract=EF=BF=BDres repr=EF=BF=BDsentant un + nombre) + + v=EF=BF=BDrifie si la valeur est inf=EF=BF=BDrieure o= u =EF=BF=BDgale =EF=BF=BD max + + ajoute une contrainte de v=EF=BF=BDrification sur la + colonne + + + + @Min(value=3D) + + propri=EF=BF=BDt=EF=BF=BD (nombre ou cha=EF=BF=BDne d= e caract=EF=BF=BDres repr=EF=BF=BDsentant un + nombre) + + v=EF=BF=BDrifie si la valeur est sup=EF=BF=BDrieure o= u =EF=BF=BDgale =EF=BF=BD max + + ajoute une contrainte de v=EF=BF=BDrification sur la + colonne + + + + @NotNull + + propri=EF=BF=BDt=EF=BF=BD + + v=EF=BF=BDrifie si la valeur n'est pas nulle + + les colonnes sont marqu=EF=BF=BDes "not null" + + + + @Past + + propri=EF=BF=BDt=EF=BF=BD (Date ou Calendar) + + v=EF=BF=BDrifie si la date est dans le pass=EF=BF=BD<= /entry> + + ajoute une contrainte de v=EF=BF=BDrification sur la + colonne + + + + @Future + + propri=EF=BF=BDt=EF=BF=BD (Date ou Calendar) + + v=EF=BF=BDrifie si la date est dans le futur + + aucun + + + + @Pattern(regex=3D"regexp", flag=3D) + + propri=EF=BF=BDt=EF=BF=BD (String) + + v=EF=BF=BDrifie si la propri=EF=BF=BDt=EF=BF=BD corre= spond =EF=BF=BD l'expression + rationnelle donn=EF=BF=BDe (pour "flag", voir + java.util.regex.Pattern) + + aucun + + + + @Range(min=3D, max=3D) + + propri=EF=BF=BDt=EF=BF=BD (nombre ou cha=EF=BF=BDne d= e caract=EF=BF=BDres repr=EF=BF=BDsentant un + nombre) + + v=EF=BF=BDrifie si la valeur est comprise entre min e= t max + (inclus) + + ajoute une contrainte de v=EF=BF=BDrification sur la + colonne + + + + @Size(min=3D, max=3D) + + propri=EF=BF=BDt=EF=BF=BD (tableau, collection, map)<= /entry> + + v=EF=BF=BDrifie si la taille de l'=EF=BF=BDl=EF=BF=BD= ment est comprise entre min et + max (inclus) + + aucun + + + + @AssertFalse + + propri=EF=BF=BDt=EF=BF=BD + + v=EF=BF=BDrifie que la m=EF=BF=BDthode est =EF=BF=BDv= alu=EF=BF=BDe =EF=BF=BD faux (utile pour les + contraintes exprim=EF=BF=BDes dans le code plut=EF=BF=BDt qu= e dans les + annotations) + + aucun + + + + @AssertTrue + + propri=EF=BF=BDt=EF=BF=BD + + v=EF=BF=BDrifie que la m=EF=BF=BDthode est =EF=BF=BDv= alu=EF=BF=BDe =EF=BF=BD vrai (utile pour les + contraintes exprim=EF=BF=BDes dans le code plut=EF=BF=BDt qu= e dans les + annotations) + + aucun + + + + @Valid + + propri=EF=BF=BDt=EF=BF=BD (objet) + + ex=EF=BF=BDcute la validation r=EF=BF=BDcursivement s= ur l'objet associ=EF=BF=BD. + Si l'objet est une Collection ou un tableau, les =EF=BF=BDl= =EF=BF=BDments sont + valid=EF=BF=BDs r=EF=BF=BDcursivement. Si l'objet est une Ma= p, les =EF=BF=BDl=EF=BF=BDments + valeur sont valid=EF=BF=BDs r=EF=BF=BDcursivement. + + aucun + + + + @Email + + propri=EF=BF=BDt=EF=BF=BD (String) + + v=EF=BF=BDrifie si la cha=EF=BF=BDne de caract=EF=BF= =BDres est conforme =EF=BF=BD la + sp=EF=BF=BDcification d'une adresse e-mail + + aucun + + + +
+ + + + Messages d'erreur + + Hibernate Validator arrive avec un ensemble de messages d'erre= ur par + d=EF=BF=BDfaut traduits dans environ dix langues (si la v=EF=BF=BDtr= e n'en fait pas + partie, veuillez nous envoyer un patch). Vous pouvez surcharger ces + messages en cr=EF=BF=BDant un ValidatorMessages.properties= + (ou ValidatorMessages_loc.properties) et en + surchargeant les clefs dont vous avez besoin. Vous pouvez m=EF=BF=BD= me ajouter + votre propre ensemble de messages suppl=EF=BF=BDmentaire lorsque vou= s =EF=BF=BDcrivez + vos annotations de validation. Si Hibernate Validator ne peut pas tr= ouver + une clef =EF=BF=BD partir de votre resourceBundle ou de votre Valida= torMessage, + il se repliera sur les valeurs int=EF=BF=BDgr=EF=BF=BDes par d=EF=BF= =BDfaut. + + Alternativement vous pouvez fournir un + ResourceBundle pendant la v=EF=BF=BDrificatio= n par + programmation des r=EF=BF=BDgles de validation sur un bean, ou si vo= us voulez un + m=EF=BF=BDcanisme d'interpolation compl=EF=BF=BDtement diff=EF=BF=BD= rent, vous pouvez fournir une + impl=EF=BF=BDmentation de + org.hibernate.validator.MessageInterpolator (lise= z la + JavaDoc pour plus d'informations). + + + + Ecrire vos propres contraintes + + Etendre l'ensemble de contraintes int=EF=BF=BDgr=EF=BF=BDes es= t extr=EF=BF=BDment facile. + N'importe quelle contrainte est constitu=EF=BF=BDe deux morceaux : le + descripteur de contrainte (l'annotation) et le + validateur de contrainte (la classe + d'impl=EF=BF=BDmentation). Voici un simple descripteur personnalis= =EF=BF=BD : + + @ValidatorClass(CapitalizedValidator.class) +(a)Target(METHOD) +(a)Retention(RUNTIME) +(a)Documented +public @interface Capitalized { + CapitalizeType type() default Capitalize.FIRST; + String message() default "has incorrect capitalization"; +} + + type est un param=EF=BF=BDtre d=EF=BF=BDcri= vant comment la + propri=EF=BF=BDt=EF=BF=BD devrait =EF=BF=BDtre mise en majuscule. Ce= ci est un param=EF=BF=BDtre + utilisateur compl=EF=BF=BDtement d=EF=BF=BDpendant du fonctionnement= de + l'annotation. + + message est la cha=EF=BF=BDne de caract=EF= =BF=BDres par d=EF=BF=BDfaut + utilis=EF=BF=BDe pour d=EF=BF=BDcrire la violation de contrainte et = est obligatoire. Vous + pouvez mettre la cha=EF=BF=BDne de caract=EF=BF=BDres dans le code o= u bien l'externaliser + en partie ou compl=EF=BF=BDtement avec le m=EF=BF=BDcanisme Resource= Bundle Java. Les + valeurs des param=EF=BF=BDtres sont inject=EF=BF=BDes =EF=BF=BD l'in= t=EF=BF=BDrieur du message quand + la cha=EF=BF=BDne de caract=EF=BF=BDres {parameter} est trouv=EF=BF=BDe (dans + notre exemple Capitalization is not {type} g=EF= =BF=BDn=EF=BF=BDrerait + Capitalization is not FIRST), externaliser toute = la + cha=EF=BF=BDne dans ValidatorMessages.properties est + consid=EF=BF=BDr=EF=BF=BD comme une bonne pratique. Voir . + + @ValidatorClass(CapitalizedValidator.class) +(a)Target(METHOD) +(a)Retention(RUNTIME) +(a)Documented +public @interface Capitalized { + CapitalizeType type() default Capitalize.FIRST; + String message() default "{validator.capitalized}"; +} + +... +#in ValidatorMessages.properties +validator.capitalized=3DCapitalization is not {type} + + Comme vous pouvez le voir la notation {} est r=EF=BF=BDcursive= . + + Pour lier un descripteur =EF=BF=BD l'impl=EF=BF=BDmentation de= son validateur, nous + utilisons la m=EF=BF=BDta-annotation @ValidatorClass. Le + param=EF=BF=BDtre de la classe du validateur doit nommer une classe = qui impl=EF=BF=BDmente + Validator<ConstraintAnnotation>. + + Nous devons maintenant impl=EF=BF=BDmenter le validateur (ie + l'impl=EF=BF=BDmentation v=EF=BF=BDrifiant la r=EF=BF=BDgle). Une im= pl=EF=BF=BDmentation de validation + peut v=EF=BF=BDrifier la valeur d'une propri=EF=BF=BDt=EF=BF=BD (en = impl=EF=BF=BDmentant + PropertyConstraint) et/ou peut modifier les + m=EF=BF=BDta-donn=EF=BF=BDes de mapping d'Hibernate pour exprimer la= contrainte au niveau + de la base de donn=EF=BF=BDes (en impl=EF=BF=BDmentant + PersistentClassConstraint). + + public class CapitalizedValidator + implements Validator<Capitalized>, PropertyConstraint { + private CapitalizeType type; + + // partie du contrat de Validator<Annotation>, + // permet d'obtenir et d'utiliser les valeurs de l'annotation + public void initialize(Capitalized parameters) { + type =3D parameters.type(); + } + + // partie du contrat de la contrainte de la propri=EF=BF=BDt=EF=BF=BD + public boolean isValid(Object value) { + if (value=3D=3Dnull) return true; + if ( !(value instanceof String) ) return false; + String string =3D (String) value; + if (type =3D=3D CapitalizeType.ALL) { + return string.equals( string.toUpperCase() ); + } + else { + String first =3D string.substring(0,1); + return first.equals( first.toUpperCase(); + } + } +} + + La m=EF=BF=BDthode isValid() devrait retour= ner false si + la contrainte a =EF=BF=BDt=EF=BF=BD viol=EF=BF=BDe. Pour plus d'exem= ples, r=EF=BF=BDf=EF=BF=BDrez-vous aux + impl=EF=BF=BDmentations int=EF=BF=BDgr=EF=BF=BDes du validateur. + + Nous avons seulement vu la validation au niveau propri=EF=BF= =BDt=EF=BF=BD, mais vous + pouvez =EF=BF=BDcrire une annotation de validation au niveau d'un be= an. Plut=EF=BF=BDt + que de recevoir l'instance de retour d'une propri=EF=BF=BDt=EF=BF=BD= , le bean lui-m=EF=BF=BDme + sera pass=EF=BF=BD au validateur. Pour activer la v=EF=BF=BDrificati= on de validation, + annotez juste le bean lui-m=EF=BF=BDme. Un petit exemple peut =EF=BF= =BDtre trouv=EF=BF=BD dans la + suite de tests unitaires. + + + + Annoter votre mod=EF=BF=BDle de donn=EF=BF=BDes + + Maintenant que vous vous =EF=BF=BDtes familiaris=EF=BF=BDs ave= c les annotations, la + syntaxe devrait =EF=BF=BDtre connue. + + public class Address { + private String line1; + private String line2; + private String zip; + private String state; + private String country; + private long id; + + // une cha=EF=BF=BDne non nulle de 20 caract=EF=BF=BDres maximum + @Length(max=3D20) + @NotNull + public String getCountry() { + return country; + } + + // une cha=EF=BF=BDne de caract=EF=BF=BDres non nulle + @NotNull + public String getLine1() { + return line1; + } + + // pas de contrainte + public String getLine2() { + return line2; + } + + // une cha=EF=BF=BDne non nulle de 3 caract=EF=BF=BDres maximum + @Length(max=3D3) @NotNull + public String getState() { + return state; + } + + // une cha=EF=BF=BDne non nulle de 5 caract=EF=BF=BDres maximum repr= =EF=BF=BDsentant un nombre + // si la cha=EF=BF=BDne de caract=EF=BF=BDres est plus longue, le mess= age sera recherch=EF=BF=BD + // dans le resource bundle avec la clef 'long' + @Length(max=3D5, message=3D"{long}") + @Pattern(regex=3D"[0-9]+") + @NotNull + public String getZip() { + return zip; + } + + // devrait toujours =EF=BF=BDtre vrai + @AssertTrue + public boolean isValid() { + return true; + } + + // un nombre entre 1 et 2000 + @Id @Min(1) + @Range(max=3D2000) + public long getId() { + return id; + } +} + + Bien que l'exemple montre seulement la validation de propri=EF= =BF=BDt=EF=BF=BDs + publiques, vous pouvez aussi annoter des champs avec n'importe quelle + visibilit=EF=BF=BD. + + @MyBeanConstraint(max=3D45) +public class Dog { + @AssertTrue private boolean isMale; + @NotNull protected String getName() { ... }; + ... +} + + Vous pouvez aussi annoter des inferfaces. Hibernate Validator + v=EF=BF=BDrifiera toutes les classes parentes et les interfaces h=EF= =BF=BDrit=EF=BF=BDes ou + impl=EF=BF=BDment=EF=BF=BDes par un bean donn=EF=BF=BD pour lire les= annotations appropri=EF=BF=BDes du + validateur. + + public interface Named { + @NotNull String getName(); + ... +} + +public class Dog implements Named { + + @AssertTrue private boolean isMale; + + public String getName() { ... }; + +} + + La propri=EF=BF=BDt=EF=BF=BD "name" sera v=EF=BF=BDrifi=EF=BF= =BDe pour la nullit=EF=BF=BD lorsque le bean + Dog sera valid=EF=BF=BD. + + + + + Utiliser le framework Validator + + Hibernate Validator est destin=EF=BF=BD =EF=BF=BD =EF=BF=BDtre u= tilis=EF=BF=BD pour impl=EF=BF=BDmenter une + validation de donn=EF=BF=BDes =EF=BF=BD plusieurs couches, o=EF=BF=BD = nous exprimons des contraintes + =EF=BF=BD un seul endroit (le mod=EF=BF=BDle de donn=EF=BF=BDes annot= =EF=BF=BD) et les appliquons aux + diff=EF=BF=BDrents niveaux de l'application. + + + Validation au niveau du sch=EF=BF=BDma de la base de donn=EF= =BF=BDes + + Par d=EF=BF=BDfaut, Hibernate Annotations traduira les contrai= ntes que vous + avez d=EF=BF=BDfinies sur vos entit=EF=BF=BDs en m=EF=BF=BDta-donn= =EF=BF=BDes de mapping. Par exemple, si + une propri=EF=BF=BDt=EF=BF=BD de votre entit=EF=BF=BD est annot=EF= =BF=BDe avec + @NotNull, ses colonnes seront d=EF=BF=BDclar=EF= =BF=BDes comme + not null dans le sch=EF=BF=BDma DDL g=EF=BF=BDn= =EF=BF=BDr=EF=BF=BD par + Hibernate. + + + + La validation bas=EF=BF=BDe sur les =EF=BF=BDv=EF=BF=BDnement= s Hibernate + + Hibernate Validator a deux listeners d'=EF=BF=BDv=EF=BF=BDneme= nts Hibernate + int=EF=BF=BDgr=EF=BF=BDs. Quand un PreInsertEvent= ou un + PreUpdateEvent survient, les listeners v=EF=BF=BD= rifieront + toutes les contraintes de l'instance de l'entit=EF=BF=BD et l=EF=BF= =BDveront une exception + si une contrainte est viol=EF=BF=BDe. Fondamentalement, les objets s= eront v=EF=BF=BDrifi=EF=BF=BDs + avant les insertions et avant les mises =EF=BF=BD jour effectu=EF=BF= =BDes par Hibernate. + C'est le plus commode et la mani=EF=BF=BDre la plus simple d'activer= le processus + de validation. Sur une violation de contrainte, l'=EF=BF=BDv=EF=BF= =BDnement l=EF=BF=BDvera une + exception d'ex=EF=BF=BDcution InvalidStateException (NdT : + c'est une RuntimeException) laquelle contient un tableau + d'InvalidValues d=EF=BF=BDcrivant chaque =EF=BF= =BDchec. + + <hibernate-configuration> + ... + <event type=3D"pre-update"> + <listener + class=3D"org.hibernate.validator.event.ValidatePreUpdateEventLis= tener"/> + </event> + <event type=3D"pre-insert"> + <listener + class=3D"org.hibernate.validator.event.ValidatePreInsertEventLis= tener"/> + </event> +</hibernate-configuration> + + + Lors de l'utilisation d'Hibernate Entity Manager, le framewo= rk + Validation est activ=EF=BF=BD par d=EF=BF=BDfaut. Si les beans ne = sont pas annot=EF=BF=BDs avec + des annotations de validation, il n'y a pas de co=EF=BF=BDt en ter= me de + performance. + + + + + La validation au niveau applicatif + + Hibernate Validator peut =EF=BF=BDtre utilis=EF=BF=BD n'import= e o=EF=BF=BD dans le code de + votre application. + + ClassValidator personValidator =3D new ClassValidato= r( Person.class ); +ClassValidator addressValidator =3D new ClassValidator( Address.class, Res= ourceBundle.getBundle("messages", Locale.ENGLISH) ); + +InvalidValue[] validationMessages =3D addressValidator.getInvalidValues(ad= dress); + + Les deux premi=EF=BF=BDres lignes pr=EF=BF=BDparent Hibernate = Validator pour la + v=EF=BF=BDrification de classes. La premi=EF=BF=BDre s'appuie sur le= s messages d'erreur + int=EF=BF=BDgr=EF=BF=BDs =EF=BF=BD Hibernate Validator (voir + ), la seconde utilis= e un + resource bundle pour ses messages. Il est consid=EF=BF=BDr=EF=BF=BD = comme une bonne + pratique d'ex=EF=BF=BDcuter ces lignes une fois et de cacher les ins= tances de + validateur. + + La troisi=EF=BF=BDme ligne valide en fait l'instance + Address et retourne un tableau + d'InvalidValues. Votre logique applicative sera a= lors + capable de r=EF=BF=BDagir aux =EF=BF=BDchecs. + + Vous pouvez aussi v=EF=BF=BDrifier une propri=EF=BF=BDt=EF=BF= =BD particuli=EF=BF=BDre plut=EF=BF=BDt que + tout le bean. Ceci pourrait =EF=BF=BDtre utile lors d'interactions a= vec + l'utilisateur propri=EF=BF=BDt=EF=BF=BD par propri=EF=BF=BDt=EF=BF= =BD. + + ClassValidator addressValidator =3D new ClassValidat= or( Address.class, ResourceBundle.getBundle("messages", Locale.ENGLISH) ); + +// r=EF=BF=BDcup=EF=BF=BDre seulement les valeurs invalides de la propri= =EF=BF=BDt=EF=BF=BD "city" +InvalidValue[] validationMessages =3D addressValidator.getInvalidValues(ad= dress, "city"); + +// r=EF=BF=BDcup=EF=BF=BDre seulement les valeurs potentielles invalides d= e la propri=EF=BF=BDt=EF=BF=BD "city" +InvalidValue[] validationMessages =3D addressValidator.getPotentialInvalid= Values("city", "Paris") + + + + Informations de validation + + Comme un transporteur d'informations de validation, Hibernate + fournit un tableau d'InvalidValues. Chaque + InvalidValue a un groupe de m=EF=BF=BDthodes d=EF= =BF=BDcrivant les + probl=EF=BF=BDmes individuels. + + getBeanClass() r=EF=BF=BDcup=EF=BF=BD= re le type du bean + ayant =EF=BF=BDchou=EF=BF=BD. + + getBean() r=EF=BF=BDcup=EF=BF=BDre l'= instance du bean ayant + =EF=BF=BDchou=EF=BF=BD (s'il y en a, c'est-=EF=BF=BD-dire pas lors d= e l'utilisation de + getPotentianInvalidValues()). + + getValue() r=EF=BF=BDcup=EF=BF=BDre l= a valeur ayant + =EF=BF=BDchou=EF=BF=BDe. + + getMessage() r=EF=BF=BDcup=EF=BF=BDre= le message d'erreur + internationalis=EF=BF=BD. + + getRootBean() r=EF=BF=BDcup=EF=BF=BDr= e l'instance du bean + racine ayant g=EF=BF=BDn=EF=BF=BDr=EF=BF=BD le probl=EF=BF=BDme (uti= le en conjonction avec + @Valid), est nulle si getPotentianInvalidValues()= est + utilis=EF=BF=BDe. + + getPropertyPath() r=EF=BF=BDcup=EF=BF=BDre = le chemin (s=EF=BF=BDpar=EF=BF=BD par + des points) de la propri=EF=BF=BDt=EF=BF=BD ayant =EF=BF=BDchou=EF= =BF=BDe =EF=BF=BD partir du bean racine. + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/xml-ov= erriding.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/xml-overr= iding.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/modules/xml-overr= iding.xml 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,413 @@ + + + Surcharger des m=EF=BF=BDta-donn=EF=BF=BDes =EF=BF=BD travers du = XML + + La cible primaire pour les m=EF=BF=BDta-donn=EF=BF=BDes dans EJB3 = sont les annotations, + mais la sp=EF=BF=BDcification EJB3 fournit un moyen de surcharger ou rem= placer les + m=EF=BF=BDta-donn=EF=BF=BDes d=EF=BF=BDfinies par des annotations =EF=BF= =BD travers un descripteur de + d=EF=BF=BDploiement XML. Dans la version courante, seule la surcharge de= s annotations + pure EJB3 est prise en charge. Si vous souhaitez utiliser des caract=EF= =BF=BDristiques + sp=EF=BF=BDcifiques =EF=BF=BD Hibernate dans des entit=EF=BF=BDs, vous d= evrez utiliser les annotations + ou vous replier sur les fichiers hbm. Vous pouvez bien s=EF=BF=BDr m=EF= =BF=BDlanger et faire + correspondre des entit=EF=BF=BDs annot=EF=BF=BDes et des entit=EF=BF=BDs= d=EF=BF=BDcrites dans des fichiers + hbm. + + La suite de test unitaires montre des exemples suppl=EF=BF=BDmenta= ires de + fichier XML. + +
+ Principes + + La structure du descripteur de d=EF=BF=BDploiement XML a =EF=BF= =BDt=EF=BF=BD con=EF=BF=BDue pour + refl=EF=BF=BDter celle des annotations. Donc si vous connaissez la str= ucture des + annotations, utiliser le sch=EF=BF=BDma XML sera facile pour vous. + + Vous pouvez d=EF=BF=BDfinir un ou plusieurs fichiers XML d=EF=BF= =BDcrivant vos + m=EF=BF=BDta-donn=EF=BF=BDes, ces fichiers seront fusionn=EF=BF=BDs pa= r le moteur de surcharge. + +
+ M=EF=BF=BDta-donn=EF=BF=BDes de niveau global + + Vous pouvez d=EF=BF=BDfinir des m=EF=BF=BDta-donn=EF=BF=BDes d= e niveau global disponibles + pour tous les fichiers XML. Vous ne devez pas d=EF=BF=BDfinir ces m= =EF=BF=BDta-donn=EF=BF=BDes + plus d'une fois par d=EF=BF=BDploiement. + + <?xml version=3D"1.0" encoding=3D"UTF-8"?> + +<entity-mappings + xmlns=3D"http://java.sun.com/xml/ns/persistence/orm" + xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm orm_1_0= .xsd" + version=3D"1.0"> + + <persistence-unit-metadata> + <xml-mapping-metadata-complete/> + <persistence-unit-defaults> + <schema>myschema</schema> + <catalog>mycatalog</catalog> + <cascade-persist/> + </persistence-unit-defaults> + </persistence-unit-metadata> + + xml-mapping-metadata-complete signifie que = toutes + les entit=EF=BF=BDs, classes m=EF=BF=BDres mapp=EF=BF=BDes et m=EF= =BF=BDta-donn=EF=BF=BDes devraient =EF=BF=BDtre + r=EF=BF=BDcup=EF=BF=BDr=EF=BF=BDes =EF=BF=BD partir du XML (c'est-= =EF=BF=BD-dire ignorer les annotations). + + schema / catalog surchargera toutes les + d=EF=BF=BDfinitions par d=EF=BF=BDfaut de sch=EF=BF=BDma et de catal= ogue dans les m=EF=BF=BDta-donn=EF=BF=BDes + (XML et annotations). + + cascade-persist signifie que toutes les + associations ont PERSIST comme type de cascade. Nous vous recommando= ns de + ne pas utiliser cette fonctionnalit=EF=BF=BD. +
+ +
+ M=EF=BF=BDta-donn=EF=BF=BDes de niveau entit=EF=BF=BD + + Vous pouvez d=EF=BF=BDfinir ou surcharger des informations de = m=EF=BF=BDta-donn=EF=BF=BDes + sur une entit=EF=BF=BD donn=EF=BF=BDe. + + + + + + + + + + + + + + + + + + + + + + + + + <?xml version=3D"1.0" encoding=3D"UTF-8"?> + +<entity-mappings + xmlns=3D"http://java.sun.com/xml/ns/persistence/orm" + xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm orm_1_0= .xsd" + version=3D"1.0"> + + <package>org.hibernate.test.annotations.reflection</package&g= t; + <entity class=3D"Administration" access=3D"PROPERTY" metadata-compl= ete=3D"true"> + <table name=3D"tbl_admin"> + <unique-constraint> + <column-name>firstname</column-name> + <column-name>lastname</column-name> + </unique-constraint> + </table> + <secondary-table name=3D"admin2"> + <primary-key-join-column name=3D"admin_id" referenced-colum= n-name=3D"id"/> + <unique-constraint> + <column-name>address</column-name> + </unique-constraint> + </secondary-table> + <id-class class=3D"SocialSecurityNumber"/> + <inheritance strategy=3D"JOINED"/> + <sequence-generator name=3D"seqhilo" sequence-name=3D"seqhilo"/= > + <table-generator name=3D"table" table=3D"tablehilo"/> + ... + </entity> + + <entity class=3D"PostalAdministration"> + <primary-key-join-column name=3D"id"/> + ... + </entity> +</entity-mappings> + + + + entity-mappings : entity-mappings est + l'=EF=BF=BDl=EF=BF=BDment racine pour tous les fichiers XML. V= ous devez d=EF=BF=BDclarer le + sch=EF=BF=BDma xml, le fichier du sch=EF=BF=BDma est inclus da= ns le fichier + hibernate-annotations.jar, aucun acc=EF=BF=BDs =EF=BF=BD inter= net ne sera effectu=EF=BF=BD + par Hibernate Annotations. + + + + package (optionnel) : package par d= =EF=BF=BDfaut + utilis=EF=BF=BD pour tous les noms de classes sans package dan= s le fichier + de descripteur de d=EF=BF=BDploiement donn=EF=BF=BD. + + + + entity : d=EF=BF=BDcrit une entit=EF= =BF=BD. + + metadata-complete d=EF=BF=BDfinit si = la description + des m=EF=BF=BDta-donn=EF=BF=BDes pour cet =EF=BF=BDl=EF=BF=BDm= ent est compl=EF=BF=BDte ou pas (en d'autres + mots, si les annotations pr=EF=BF=BDsentes au niveau de la cla= sse devraient + =EF=BF=BDtre prises en compte ou pas). + + Une entit=EF=BF=BD doit avoir un attribut class= + r=EF=BF=BDf=EF=BF=BDren=EF=BF=BDant une classe java =EF=BF=BD = laquelle s'applique les + m=EF=BF=BDta-donn=EF=BF=BDes. + + Vous pouvez surcharger un nom d'entit=EF=BF=BD avec l'at= tribut + name, si aucun n'est d=EF=BF=BDfini et si u= ne annotation + @Entity.name est pr=EF=BF=BDsente, alors el= le est + utilis=EF=BF=BDe (et =EF=BF=BDtablit que les m=EF=BF=BDta-donn= =EF=BF=BDes ne sont pas + compl=EF=BF=BDtes). + + Pour un =EF=BF=BDl=EF=BF=BDment avec des m=EF=BF=BDta-do= nn=EF=BF=BDes compl=EF=BF=BDtes (voir + ci-dessous), vous pouvez d=EF=BF=BDfinir un attribut + access (soit FIELD, soit + PROPERTY (valeur par d=EF=BF=BDfaut)). Pour= un =EF=BF=BDl=EF=BF=BDment + avec des m=EF=BF=BDta-donn=EF=BF=BDes incompl=EF=BF=BDtes, si = access + n'est pas d=EF=BF=BDfini, la position de @Id permettra de le d= =EF=BF=BDterminer, si + access est d=EF=BF=BDfini, sa valeur est ut= ilis=EF=BF=BDe. + + + + table : vous pouvez d=EF=BF=BDclarer = des propri=EF=BF=BDt=EF=BF=BDs + de table (nom, sch=EF=BF=BDma, catalogue), si aucune n'est d= =EF=BF=BDfinie, + l'annotation java est utilis=EF=BF=BDe. + + Vous pouvez d=EF=BF=BDfinir une ou plusieurs contraintes= d'unicit=EF=BF=BD + comme dans l'exemple. + + + + secondary-table : d=EF=BF=BDfinit une= table + secondaire tr=EF=BF=BDs semblable =EF=BF=BD une table habituel= le except=EF=BF=BD que vous + pouvez d=EF=BF=BDfinir les colonnes de clef primaire / clef = =EF=BF=BDtrang=EF=BF=BDre avec + l'=EF=BF=BDl=EF=BF=BDment primary-key-join-column. Sur des + m=EF=BF=BDta-donn=EF=BF=BDes incompl=EF=BF=BDtes, les annotati= ons de table secondaire sont + utilis=EF=BF=BDes seulement s'il n'y a pas de seconda= ry-table + de d=EF=BF=BDfini, sinon les annotations sont ignor=EF=BF=BDes= . + + + + id-class : d=EF=BF=BDfinit la classe = identifiante + comme le fait @IdClass. + + + + inheritance : d=EF=BF=BDfinit la stra= t=EF=BF=BDgie + d'h=EF=BF=BDritage (JOINED, + TABLE_PER_CLASS, + SINGLE_TABLE) ; disponible seulement au niv= eau de + l'=EF=BF=BDl=EF=BF=BDment racine. + + + + sequence-generator : d=EF=BF=BDfinit = un g=EF=BF=BDn=EF=BF=BDrateur + de s=EF=BF=BDquence. + + + + table-generator : d=EF=BF=BDfinit un = g=EF=BF=BDn=EF=BF=BDrateur de + table. + + + + primary-key-join-column : + d=EF=BF=BDfinit la colonne de jointure sur la clef primaire po= ur les + entit=EF=BF=BDs filles lorsque la strat=EF=BF=BDgie d'h=EF=BF= =BDritage utilis=EF=BF=BDe est + JOINED. + + + + + + + + + + + + + + + + + + <?xml version=3D"1.0" encoding=3D"UTF-8"?> + +<entity-mappings + xmlns=3D"http://java.sun.com/xml/ns/persistence/orm" + xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm orm_1_0= .xsd" + version=3D"1.0"> + + <package>org.hibernate.test.annotations.reflection</package&g= t; + <entity class=3D"Music" access=3D"PROPERTY" metadata-complete=3D"tr= ue"> + <discriminator-value>Generic</discriminator-value> + <discriminator-column length=3D"34"/> + ... + </entity> + + <entity class=3D"PostalAdministration"> + <primary-key-join-column name=3D"id"/> + <named-query name=3D"adminById"> + <query>select m from Administration m where m.id =3D :id= </query> + <hint name=3D"org.hibernate.timeout" value=3D"200"/> + </named-query> + <named-native-query name=3D"allAdmin" result-set-mapping=3D"adm= inrs"> + <query>select *, count(taxpayer_id) as taxPayerNumber + from Administration, TaxPayer + where taxpayer_admin_id =3D admin_id group by ...</query> + <hint name=3D"org.hibernate.timeout" value=3D"200"/> + </named-native-query> + <sql-result-set-mapping name=3D"adminrs"> + <entity-result entity-class=3D"Administration"> + <field-result name=3D"name" column=3D"fld_name"/> + </entity-result> + <column-result name=3D"taxPayerNumber"/> + </sql-result-set-mapping> + <attribute-override name=3D"ground"> + <column name=3D"fld_ground" unique=3D"true" scale=3D"2"/> + </attribute-override> + <association-override name=3D"referer"> + <join-column name=3D"referer_id" referenced-column-name=3D"= id"/> + </association-override> + ... + </entity> +</entity-mappings> + + + + discriminator-value / + discriminator-column : d=EF=BF=BDfinissent la colonn= e et la valeur + discriminantes lorsque la strat=EF=BF=BDgie d'h=EF=BF=BDritage= choisie est + SINGLE_TABLE. + + + + named-query : d=EF=BF=BDfinit les req= u=EF=BF=BDtes nomm=EF=BF=BDes + et potentiellement les indices qui leur sont associ=EF=BF=BDs.= Ces + d=EF=BF=BDfinitions sont ajout=EF=BF=BDes =EF=BF=BD celles d= =EF=BF=BDfinies dans les annotations, + si deux d=EF=BF=BDfinitions ont le m=EF=BF=BDme nom, la versio= n XML a la + priorit=EF=BF=BD. + + + + named-native-query : d=EF=BF=BDfinit = une requ=EF=BF=BDte + SQL nomm=EF=BF=BDe et le mapping de son r=EF=BF=BDsultat. Alte= rnativement, vous + pouvez d=EF=BF=BDfinir result-class. Ces d= =EF=BF=BDfinitions + sont ajout=EF=BF=BDes =EF=BF=BD celles definies dans les annot= ations, si deux + d=EF=BF=BDfinitions ont le m=EF=BF=BDme nom, la version XML a = la priorit=EF=BF=BD. + + + + sql-result-set-mapping : d=EF=BF=BDcr= it la + structure du mapping des r=EF=BF=BDsultats. Vous pouvez d=EF= =BF=BDfinir des mappings + de colonnes et d'entit=EF=BF=BD. Ces d=EF=BF=BDfinitions sont = ajout=EF=BF=BDes =EF=BF=BD celles + d=EF=BF=BDfinies dans les annotations, si deux d=EF=BF=BDfinit= ions ont le m=EF=BF=BDme nom, + la version XML a la priorit=EF=BF=BD. + + + + attribute-override / + association-override : surcharge la d=EF=BF=BDfiniti= on d'une + colonne ou d'une colonne de jointure. Cette surcharge est ajou= t=EF=BF=BDe =EF=BF=BD + celle d=EF=BF=BDfinie dans les annotations. + + + + + La m=EF=BF=BDme chose s'applique =EF=BF=BD <embedd= able> et + <mapped-superclass>. +
+ +
+ M=EF=BF=BDta-donn=EF=BF=BDes de niveau propri=EF=BF=BDt=EF=BF= =BD + + Vous pouvez bien s=EF=BF=BDr d=EF=BF=BDfinir des surcharges XM= L pour des propri=EF=BF=BDt=EF=BF=BDs. + Si les m=EF=BF=BDta-donn=EF=BF=BDes sont d=EF=BF=BDfinies comme inco= mpl=EF=BF=BDtes, alors les propri=EF=BF=BDt=EF=BF=BDs + suppl=EF=BF=BDmentaires (c'est-=EF=BF=BD-dire au niveau Java) seront= ignor=EF=BF=BDes. Toutes les + m=EF=BF=BDta-donn=EF=BF=BDes de niveau propri=EF=BF=BDt=EF=BF=BD son= t d=EF=BF=BDfinies par + entity/attributes, + mapped-superclass/attributes ou + embeddable/attributes. + + <attributes> + <id name=3D"id"> + <column name=3D"fld_id"/> + <generated-value generator=3D"generator" strategy=3D"SEQUEN= CE"/> + <temporal>DATE</temporal> + <sequence-generator name=3D"generator" sequence-name=3D"seq= "/> + </id> + <version name=3D"version"/> + <embedded name=3D"embeddedObject"> + <attribute-override name"subproperty"> + <column name=3D"my_column"/> + </attribute-override> + </embedded> + <basic name=3D"status" optional=3D"false"> + <enumerated>STRING</enumerated> + </basic> + <basic name=3D"serial" optional=3D"true"> + <column name=3D"serialbytes"/> + <lob/> + </basic> + <basic name=3D"terminusTime" fetch=3D"LAZY"> + <temporal>TIMESTAMP</temporal> + </basic> + </attributes> + + Vous pouvez surcharger une propri=EF=BF=BDt=EF=BF=BD avec id, + embedded-id, version, + embedded et basic. Chacun de c= es + =EF=BF=BDl=EF=BF=BDments peuvent avoir des sous-=EF=BF=BDl=EF=BF=BDm= ents : lob, + temporal, enumerated, + column. +
+ +
+ M=EF=BF=BDta-donn=EF=BF=BDes au niveau association + + Vous pouvez d=EF=BF=BDfinir des surcharges XML pour les associ= ations. Toutes + les m=EF=BF=BDta-donn=EF=BF=BDes de niveau association sont d=EF=BF= =BDfinies par + entity/attributes, + mapped-superclass/attributes ou + embeddable/attributes. + + <attributes> + <one-to-many name=3D"players" fetch=3D"EAGER"> + <map-key name=3D"name"/> + <join-column name=3D"driver"/> + <join-column name=3D"number"/> + </one-to-many> + <many-to-many name=3D"roads" target-entity=3D"Administration"&g= t; + <order-by>maxSpeed</order-by> + <join-table name=3D"bus_road"> + <join-column name=3D"driver"/> + <join-column name=3D"number"/> + <inverse-join-column name=3D"road_id"/> + <unique-constraint> + <column-name>driver</column-name> + <column-name>number</column-name> + </unique-constraint> + </join-table> + </many-to-many> + <many-to-many name=3D"allTimeDrivers" mapped-by=3D"drivenBuses"= > + </attributes> + + Vous pouvez surcharger une association avec + one-to-many, one-to-one, + many-to-one, et many-to-many. + Chacun de ces =EF=BF=BDl=EF=BF=BDments peut avoir des sous-=EF=BF=BD= l=EF=BF=BDments : + join-table (qui peut avoir des + join-columns et des + inverse-join-columns), + join-columns, + map-key, et order-by. + mapped-by et target-entity peu= vent + =EF=BF=BDtre d=EF=BF=BDfinis en tant qu'attributs lorsque cela a du = sens. Une fois de plus + la structure est le reflet de la structure des annotations. Vous pou= vez + trouver toutes les informations de s=EF=BF=BDmantique dans le chapit= re d=EF=BF=BDcrivant + les annotations. +
+
+
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/fopdf.x= sl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/fopdf.xsl = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/fopdf.xsl = 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,519 @@ + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + Version: + + + + + + + + + + + + + + + + + + + + + + + + + -5em + -5em + + + + + + + + + + + + + + + Hibernate + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + = + + + + + + + + + + + + + + + + + + bold + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 0 + + 1 + + + + + + book toc + + = + + 3 + = + + + + + + = + + 5mm + 10mm + 10mm + + 15mm + 10mm + 0mm + + 18mm + 18mm + + + 0pc + + + + + 11 + + + 1.4 + + + + + + + 0.8em + + + + + + 17.4cm + + + + 4pt + 4pt + 4pt + 4pt + + = + + 0.1pt + 0.1pt + + + + + 1 + + + + + + + + + + + + + + + + + + + + = + + = + + + left + bold + + + pt + + + + + + + + + + + + = + + + bold + + + pt + + false + 0.4em + 0.6em + 0.8em + + + + = + + + 1em + 1em + 1em + 0.1em + 0.1em + 0.1em + #444444 + solid + 0.1pt + 0.5em + 0.5em + 0.5em + 0.5em + 0.5em + 0.5em + + + + 1 + + #F0F0F0 + + + + + + 1 + + + 90 + + + 0 + + + + + + + + + ( + + ) + + + + + + + + + figure after + example before + equation before + table before + procedure before + + = + + + 0.8em + 0.8em + 0.8em + 0.1em + 0.1em + 0.1em + + + + + + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html.css =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html.css = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html.css 2= 009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,97 @@ +A { + color: #003399; +} + +A:active { + color: #003399; +} + +A:visited { + color: #888888; +} + +P, OL, UL, LI, DL, DT, DD, BLOCKQUOTE { + color: #000000; +} + +TD, TH, SPAN { + color: #000000; +} + +BLOCKQUOTE { + margin-right: 0px; +} + + +H1, H2, H3, H4, H5, H6 { + color: #000000; + font-weight:500; + margin-top:10px; + padding-top:15px; +} + +TABLE { + border-collapse: collapse; + border-spacing:0; + border: 1px thin black; + empty-cells: hide; +} + +TD { + padding: 4pt; +} + +H1 { font-size: 150%; } +H2 { font-size: 140%; } +H3 { font-size: 110%; font-weight: bold; } +H4 { font-size: 110%; font-weight: bold;} +H5 { font-size: 100%; font-style: italic; } +H6 { font-size: 100%; font-style: italic; } + +TT { +font-size: 90%; + font-family: "Courier New", Courier, monospace; + color: #000000; +} + +PRE { +font-size: 100%; + padding: 5px; + border-style: solid; + border-width: 1px; + border-color: #CCCCCC; + background-color: #F4F4F4; +} + +UL, OL, LI { + list-style: disc; +} + +HR { + width: 100%; + height: 1px; + background-color: #CCCCCC; + border-width: 0px; + padding: 0px; + color: #CCCCCC; +} + +.variablelist { = + padding-top: 10; = + padding-bottom:10; = + margin:0; +} + +.itemizedlist, UL { = + padding-top: 0; = + padding-bottom:0; = + margin:0; = +} + +.term { = + font-weight:bold; +} + + + + = Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html.xsl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html.xsl = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html.xsl 2= 009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,84 @@ + + + + + +]> + + + = + + + = + + ../shared/css/html.css + + + 1 + 0 + 1 + 0 + + = + + + + book toc + + = + + 3 + = + = + + + 1 + + + + + + + 0 + + + 90 + + = + + + + figure after + example before + equation before + table before + procedure before + = + = + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html_ch= unk.xsl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html_chunk= .xsl (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/fr/styles/html_chunk= .xsl 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,86 @@ + + + + + +]> + + + = + + + = + + '5' + '1' + ../shared/css/html.css + + + 1 + 0 + 1 + 0 + = + = + + + + book toc + + = + + 3 + + = + + + 1 + + + = + = + + + 0 + + + 90 + + = + + + + figure after + example before + equation before + table before + procedure before + = + = + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simhei.= ttf =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Property changes on: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_= cn/fop/simhei.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simhei.= xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simhei.xml= (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simhei.xml= 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,2 @@ + +SimHei00859= -1400-140996= 8553300TYPE0CIDFontType20<= bf us=3D"8251" ue=3D"8251" gi=3D"262"/><= bf us=3D"8725" ue=3D"8725" gi=3D"812"/>= <= bf us=3D"9660" ue=3D"9661" gi=3D"873"/><= bf us=3D"18847" ue=3D"18847" gi=3D"21962"/><= bf us=3D"65506" ue=3D"65506" gi=3D"967"/><= wx w=3D"500"/><= wx w=3D"500"/>= = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = <= /multibyte-extras> \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simsun.= ttc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Property changes on: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_= cn/fop/simsun.ttc ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simsun.= xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simsun.xml= (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/simsun.xml= 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,2 @@ + +SimSun00859= -1400-140996= 8553300SimSunTYPE0CIDFontType20<= bf us=3D"165" ue=3D"166" gi=3D"22025"/><= bf us=3D"328" ue=3D"328" gi=3D"123"/>= = <= bf us=3D"8470" ue=3D"8470" gi=3D"264"/><= bf us=3D"8735" ue=3D"8735" gi=3D"813"/><= bf us=3D"8895" ue=3D"8895" gi=3D"818"/><= bf us=3D"9678" ue=3D"9679" gi=3D"444"/><= bf us=3D"12449" ue=3D"12534" gi=3D"553"/>= <= bf us=3D"63893" ue=3D"63893" gi=3D"21884"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/><= wx w=3D"500"/>= = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ! = = = = = ! = = = = = = = = = = = = ! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < wx w=3D"1000"/>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/usercon= fig.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/userconfig= .xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/fop/userconfig= .xml 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + = + + + + + + + + + + + + = + = + = + = + + + = + = + = + = + + + + + + + + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/images/hibe= rnate_logo_a.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Property changes on: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_= cn/images/hibernate_logo_a.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/master.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/master.xml = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/master.xml 200= 9-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,294 @@ + + + + + + +]> + + + Hibernate Annotations + + =E5=8F=82=E8=80=83=E6=96=87=E6=A1=A3 + + 3.2.0 CR1 + + + + + + + + + + + + =E5=89=8D=E8=A8=80 + + WARNING! This is a translated version of the English Hibernate + reference documentation. The translated version might not be up to dat= e! + However, the differences should only be very minor. Consult the English + reference documentation if you are missing information or encounter a + translation error. If you like to contribute to a particular translati= on, + contact us on the Hibernate developer mailing list. + + Translator(s): RedSaga Translate Team =E6=BB=A1=E6=B1=9F=E7=BA= =A2=E7=BF=BB=E8=AF=91=E5=9B=A2=E9=98=9F + <caoxg(a)yahoo.com> + + + =E7=BF=BB=E8=AF=91=E8=AF=B4=E6=98=8E + + =E6=9C=AC=E6=96=87=E6=A1=A3=E7=9A=84=E7=BF=BB=E8=AF=91=E6=98= =AF=E5=9C=A8=E7=BD=91=E7=BB=9C=E4=B8=8A=E5=8D=8F=E4=BD=9C=E8=BF=9B=E8=A1=8C= =E7=9A=84=EF=BC=8C=E4=B9=9F=E4=BC=9A=E4=B8=8D=E6=96=AD=E6=A0=B9=E6=8D=AEHib= ernate=E7=9A=84=E5=8D=87=E7=BA=A7=E8=BF=9B=E8=A1=8C=E6=9B=B4=E6=96=B0=E3=80= =82=E6=8F=90=E4=BE=9B=E6=AD=A4=E6=96=87=E6=A1=A3=E7=9A=84=E7=9B=AE=E7=9A=84= =E6=98=AF=E4=B8=BA=E4=BA=86=E5=87=8F=E7=BC=93=E5=AD=A6=E4=B9=A0Hibernate=E7= =9A=84=E5=9D=A1=E5=BA=A6=EF=BC=8C=E8=80=8C=E9=9D=9E=E4=BB=A3=E6=9B=BF=E5=8E= =9F=E6=96=87=E6=A1=A3=E3=80=82=E6=88=91=E4=BB=AC=E5=BB=BA=E8=AE=AE=E6=89=80= =E6=9C=89=E6=9C=89=E8=83=BD=E5=8A=9B=E7=9A=84=E8=AF=BB=E8=80=85=E9=83=BD=E7= =9B=B4=E6=8E=A5=E9=98=85=E8=AF=BB=E8=8B=B1=E6=96=87=E5=8E=9F=E6=96=87=E3=80= =82=E8=8B=A5=E6=82=A8=E5=AF=B9=E7=BF=BB=E8=AF=91=E6=9C=89=E5=BC=82=E8=AE=AE= =EF=BC=8C=E6=88=96=E5=8F=91=E7=8E=B0=E7=BF=BB=E8=AF=91=E9=94=99=E8=AF=AF=EF= =BC=8C=E6=95=AC=E8=AF=B7=E4=B8=8D=E5=90=9D=E8=B5=90=E6=95=99=EF=BC=8C=E6=8A= =A5=E5=91=8A=E5=88=B0=E5=A6=82=E4=B8=8B=E5=9C=B0=E5=9D=80=EF=BC=9Ahttp://wi= ki.redsaga.com/confluence/display/HART/Home + + + Hibernate Annotation v3=E7=BF=BB=E8=AF=91=E5=9B=A2=E9=98=9F= + + + + + + + + + + + + + + + =E5=BA=8F=E5=8F=B7 + + =E6=A0=87=E9=A2=98 + + =E4=B8=AD=E6=96=87=E6=A0=87=E9=A2=98= + + =E7=BF=BB=E8=AF=91 + + 1=E5=AE=A1 + + 2=E5=AE=A1 + + + + + + -- + + Contents + + =E7=9B=AE=E5=BD=95 + + Liu Chang + + + + + + + + #1 + + Setting up an annotations projec + + =E5=88=9B=E5=BB=BA=E4=B8=80=E4=B8=AA=E6=B3=A8=E8=A7= =A3=E9=A1=B9=E7=9B=AE + + melthaw + + Zheng Shuai + + superq + + + + #2 + + Entity Beans-Introduction + + =E5=AE=9E=E4=BD=93Bean-=E7=AE=80=E4=BB=8B + + melthaw + + Zheng Shuai + + superq + + + + #3 + + Entity Beans-Mapping with EJB3 Annotations + + =E5=AE=9E=E4=BD=93Bean-=E7=94=A8EJB3=E6=B3=A8=E8=A7= =A3=E8=BF=9B=E8=A1=8C=E6=98=A0=E5=B0=84 + + melthaw + + Zheng Shuai + + superq, Liu Chang, Sean Chan + + + + #4 + + Entity Beans-Mapping Queries + + =E5=AE=9E=E4=BD=93Bean-=E6=98=A0=E5=B0=84=E6=9F=A5=E8= =AF=A2 + + melthaw + + Zheng Shuai + + superq, Liu Chang, Sean Chan + + + + #5 + + Entity Beans-Hibernate Annotation Extensions + + =E5=AE=9E=E4=BD=93Bean-Hibernate=E7=8B=AC=E6=9C=89=E7= =9A=84=E6=B3=A8=E8=A7=A3=E6=89=A9=E5=B1=95 + + Sean Chan + + morning + + melthaw + + + + #6 + + Overriding metadata through XML + + =E9=80=9A=E8=BF=87XML=E8=A6=86=E5=86=99=E5=85=83=E6= =95=B0=E6=8D=AE + + icess + + melthaw + + Sean Chan + + + + #7 + + Hibernate Validator + + Hibernate=E9=AA=8C=E8=AF=81=E5=99=A8 + + DigitalSonic + + morning + + melthaw + + + + #8 + + Hibernate Lucene Integration + + Hibernate=E4=B8=8ELucene=E9=9B=86=E6=88=90 + + mochow + + morning + + melthaw + + + + #9 + + Appendix:Glossary + + =E9=99=84=E5=BD=95:=E6=9C=AF=E8=AF=AD=E8=A1=A8 + + mochow + + Liu Chang + + =E6=9B=B9=E6=99=93=E9=92=A2 + + + +
+ + =E5=85=B3=E4=BA=8E=E6=88=91=E4=BB=AC + + + + =E6=BB=A1=E6=B1=9F=E7=BA=A2.=E5=BC=80=E6=BA=90, http://www= .redsaga.com + + + =E4=BB=8E=E6=88=90=E7=AB=8B=E4=B9=8B=E5=88=9D=E5=B0=B1= =E8=87=B4=E5=8A=9B=E4=BA=8EJava=E5=BC=80=E6=94=BE=E6=BA=90=E4=BB=A3=E7=A0= =81=E5=9C=A8=E4=B8=AD=E5=9B=BD=E7=9A=84=E4=BC=A0=E6=92=AD=E4=B8=8E=E5=8F=91= =E5=B1=95,=E4=B8=8E=E5=9B=BD=E5=86=85=E5=A4=9A=E4=B8=AAJava=E5=9B=A2=E4=BD= =93=E5=8F=8A=E5=87=BA=E7=89=88=E7=A4=BE=E6=9C=89=E6=B7=B1=E5=85=A5=E4=BA=A4= =E6=B5=81=E3=80=82=E5=9D=9A=E6=8C=81=E5=B0=91=E8=AF=B4=E5=A4=9A=E5=81=9A=E7= =9A=84=E5=8E=9F=E5=88=99=EF=BC=8C=E7=9B=AE=E5=89=8D=E6=9C=89=E4=B8=A4=E4=B8= =AA=E5=9B=A2=E9=98=9F=EF=BC=8C=E2=80=9COpenDoc=E5=9B=A2=E9=98=9F=E2=80=9D= =E4=B8=8E=E2=80=9C=E7=BF=BB=E8=AF=91=E5=9B=A2=E9=98=9F=E2=80=9D=EF=BC=8C=E6= =9C=AC=E7=BF=BB=E8=AF=91=E6=96=87=E6=A1=A3=E5=8D=B3=E4=B8=BA=E7=BF=BB=E8=AF= =91=E5=9B=A2=E9=98=9F=E4=BD=9C=E5=93=81=E3=80=82OpenDoc=E5=9B=A2=E9=98=9F= =E5=B7=B2=E7=BB=8F=E6=8E=A8=E5=87=BA=E5=8C=85=E6=8B=ACHibernate=E3=80=81iBa= tis=E3=80=81Spring=E3=80=81WebWork=E7=9A=84=E5=A4=9A=E4=BB=BD=E5=BC=80=E6= =94=BE=E6=96=87=E6=A1=A3=EF=BC=8C=E5=B9=B6=E4=BA=8E2005=E5=B9=B45=E6=9C=88= =E5=9C=A8Hibernate=E5=BC=80=E6=94=BE=E6=96=87=E6=A1=A3=E5=9F=BA=E7=A1=80=E4= =B8=8A=E6=89=A9=E5=85=85=E6=88=90=E4=B9=A6=EF=BC=8C=E5=87=BA=E7=89=88=E4=BA= =86=E5=8E=9F=E5=88=9B=E4=B9=A6=E7=B1=8D=EF=BC=9A=E3=80=8A=E6=B7=B1=E5=85=A5= =E6=B5=85=E5=87=BAHibernate=E3=80=8B=EF=BC=8C=E6=9C=AC=E4=B9=A6400=E4=BD=99= =E9=A1=B5=EF=BC=8C=E9=80=82=E5=90=88=E5=90=84=E4=B8=AA=E5=B1=82=E6=AC=A1=E7= =9A=84Hibernate=E7=94=A8=E6=88=B7=E3=80=82(http://www.redsaga.com/hibernate= _book.html)=E6=95=AC=E8=AF=B7=E6=94=AF=E6=8C=81=E3=80=82 + + + + + =E8=87=B4=E8=B0=A2 + + + =E5=9C=A8=E6=88=91=E4=BB=AC=E7=BF=BB=E8=AF=91Hibernate + Annotation=E5=8F=82=E8=80=83=E6=96=87=E6=A1=A3=E7=9A=84=E5=90= =8C=E6=97=B6=EF=BC=8C=E8=BF=98=E6=9C=89=E4=B8=80=E4=BD=8D=E7=83=AD=E5=BF=83= =E7=9A=84=E6=9C=8B=E5=8F=8B=E4=B9=9F=E5=9C=A8=E8=BF=9B=E8=A1=8C=E7=9D=80=E5= =90=8C=E6=A0=B7=E7=9A=84=E5=B7=A5=E4=BD=9C=EF=BC=8C=E8=BF=99=E4=BD=8D=E6=9C= =8B=E5=8F=8B=E5=B0=B1=E6=98=AFicess(=E5=86=B0=E9=9B=A8)=EF=BC=8C=E7=94=B1ic= ess=E7=BF=BB=E8=AF=91=E7=9A=84=E4=B8=AD=E6=96=87=E7=89=88=E7=9A=84=E5=9C=B0= =E5=9D=80=EF=BC=9A + http://icess.my.china.com/hibernate/a/ref/index.htm + + + +
+ + + =E7=89=88=E6=9D=83=E5=A3=B0=E6=98=8E + + Hibernate=E8=8B=B1=E6=96=87=E6=96=87=E6=A1=A3=E5=B1=9E=E4=BA= =8EHibernate=E5=8F=91=E8=A1=8C=E5=8C=85=E7=9A=84=E4=B8=80=E9=83=A8=E5=88=86= =EF=BC=8C=E9=81=B5=E5=BE=AALGPL=E5=8D=8F=E8=AE=AE=E3=80=82=E6=9C=AC=E7=BF= =BB=E8=AF=91=E7=89=88=E6=9C=AC=E5=90=8C=E6=A0=B7=E9=81=B5=E5=BE=AALGPL=E5= =8D=8F=E8=AE=AE=E3=80=82=E5=8F=82=E4=B8=8E=E7=BF=BB=E8=AF=91=E7=9A=84=E8=AF= =91=E8=80=85=E4=B8=80=E8=87=B4=E5=90=8C=E6=84=8F=E6=94=BE=E5=BC=83=E9=99=A4= =E7=BD=B2=E5=90=8D=E6=9D=83=E5=A4=96=E5=AF=B9=E6=9C=AC=E7=BF=BB=E8=AF=91=E7= =89=88=E6=9C=AC=E7=9A=84=E5=85=B6=E5=AE=83=E6=9D=83=E5=88=A9=E8=A6=81=E6=B1= =82=E3=80=82 + + =E6=82=A8=E5=8F=AF=E4=BB=A5=E8=87=AA=E7=94=B1=E9=93=BE=E6=8E= =A5=E3=80=81=E4=B8=8B=E8=BD=BD=E3=80=81=E4=BC=A0=E6=92=AD=E6=AD=A4=E6=96=87= =E6=A1=A3=EF=BC=8C=E6=88=96=E8=80=85=E6=94=BE=E7=BD=AE=E5=9C=A8=E6=82=A8=E7= =9A=84=E7=BD=91=E7=AB=99=E4=B8=8A=EF=BC=8C=E7=94=9A=E8=87=B3=E4=BD=9C=E4=B8= =BA=E4=BA=A7=E5=93=81=E7=9A=84=E4=B8=80=E9=83=A8=E5=88=86=E5=8F=91=E8=A1=8C= =E3=80=82=E4=BD=86=E5=89=8D=E6=8F=90=E6=98=AF=E5=BF=85=E9=A1=BB=E4=BF=9D=E8= =AF=81=E5=85=A8=E6=96=87=E5=AE=8C=E6=95=B4=E8=BD=AC=E8=BD=BD=EF=BC=8C=E5=8C= =85=E6=8B=AC=E5=AE=8C=E6=95=B4=E7=9A=84=E7=89=88=E6=9D=83=E4=BF=A1=E6=81=AF= =E5=92=8C=E4=BD=9C=E8=AF=91=E8=80=85=E5=A3=B0=E6=98=8E=EF=BC=8C=E5=B9=B6=E4= =B8=8D=E8=83=BD=E8=BF=9D=E5=8F=8DLGPL=E5=8D=8F=E8=AE=AE=E3=80=82=E8=BF=99= =E9=87=8C=E2=80=9C=E5=AE=8C=E6=95=B4=E2=80=9D=E7=9A=84=E5=90=AB=E4=B9=89=E6= =98=AF=EF=BC=8C=E4=B8=8D=E8=83=BD=E8=BF=9B=E8=A1=8C=E4=BB=BB=E4=BD=95=E5=88= =A0=E9=99=A4/=E5=A2=9E=E6=B7=BB/=E6=B3=A8=E8=A7=A3=E3=80=82=E8=8B=A5=E6=9C= =89=E5=88=A0=E9=99=A4/=E5=A2=9E=E6=B7=BB/=E6=B3=A8=E8=A7=A3=EF=BC=8C=E5=BF= =85=E9=A1=BB=E9=80=90=E6=AE=B5=E6=98=8E=E7=A1=AE=E5=A3=B0=E6=98=8E=E9=82=A3= =E4=BA=9B=E9=83=A8=E5=88=86=E5=B9=B6=E9=9D=9E=E6=9C=AC=E6=96=87=E6=A1=A3=E7= =9A=84=E4=B8=80=E9=83=A8=E5=88=86=E3=80=82 + +
+ + + =E5=89=8D=E8=A8=80 + + =E6=AD=A3=E5=A6=82=E5=85=B6=E4=BB=96=E7=9A=84ORM=E5=B7=A5=E5=85= =B7,Hibernate=E5=90=8C=E6=A0=B7=E9=9C=80=E8=A6=81=E5=85=83=E6=95=B0=E6=8D= =AE=E6=9D=A5=E6=8E=A7=E5=88=B6=E5=9C=A8=E4=B8=8D=E5=90=8C=E6=95=B0=E6=8D=AE= =E8=A1=A8=E8=BE=BE=E5=BD=A2=E5=BC=8F=E4=B9=8B=E9=97=B4=E7=9A=84=E8=BD=AC=E5= =8C=96. =E5=9C=A8Hibernate + 2.x=E9=87=8C,=E5=A4=9A=E6=95=B0=E6=83=85=E5=86=B5=E4=B8=8B=E8=A1=A8=E7= =A4=BA=E6=98=A0=E5=B0=84=E5=85=B3=E7=B3=BB=E7=9A=84=E5=85=83=E6=95=B0=E6=8D= =AE=E4=BF=9D=E5=AD=98=E5=9C=A8XML=E6=96=87=E6=9C=AC=E6=96=87=E4=BB=B6=E4=B8= =AD. + =E8=BF=98=E6=9C=89=E4=B8=80=E7=A7=8D=E6=96=B9=E5=BC=8F=E5=B0=B1=E6=98= =AFXdoclet,=E5=AE=83=E5=8F=AF=E4=BB=A5=E5=9C=A8=E7=BC=96=E8=AF=91=E6=97=B6= =E5=88=A9=E7=94=A8Javadoc=E4=B8=AD=E7=9A=84=E6=BA=90=E7=A0=81=E6=B3=A8=E9= =87=8A=E4=BF=A1=E6=81=AF=E6=9D=A5=E8=BF=9B=E8=A1=8C=E9=A2=84=E5=A4=84=E7=90= =86. + =E7=8E=B0=E5=9C=A8=E6=96=B0=E7=9A=84JDK=E6=A0=87=E5=87=86=EF=BC=88JDK1= .5=E4=BB=A5=E4=B8=8A=EF=BC=89=E4=B9=9F=E6=94=AF=E6=8C=81=E7=B1=BB=E4=BC=BC= =E7=9A=84=E6=B3=A8=E8=A7=A3=E5=8A=9F=E8=83=BD,=E4=BD=86=E7=9B=B8=E6=AF=94= =E4=B9=8B=E4=B8=8B=E5=BE=88=E5=A4=9A=E5=B7=A5=E5=85=B7=E5=AF=B9=E6=AD=A4=E6= =8F=90=E4=BE=9B=E4=BA=86=E6=9B=B4=E5=BC=BA=E5=A4=A7=E6=9B=B4=E5=A5=BD=E7=94= =A8=E7=9A=84=E6=94=AF=E6=8C=81. =E4=BB=A5IntelliJ + IDEA=E5=92=8CEclipse=E4=B8=BA=E4=BE=8B,=E8=BF=99=E4=BA=9BIDE=E5=B7=A5= =E5=85=B7=E4=B8=BAJDK 5.0=E6=B3=A8=E8=A7=A3=E5=8A=9F=E8=83=BD=E6=8F=90=E4= =BE=9B=E4=BA=86=E8=87=AA=E5=8A=A8=E5=AE=8C=E6=88=90=E5=92=8C=E8=AF=AD=E6=B3= =95=E9=AB=98=E4=BA=AE=E5=8A=9F=E8=83=BD. =E6=B3=A8=E8=A7=A3=E8=A2=AB=E7=9B= =B4=E6=8E=A5=E7=BC=96=E8=AF=91=E5=88=B0=E5=AD=97=E8=8A=82=E7=A0=81=E9=87=8C= ,=E5=B9=B6 + =E5=9C=A8=E8=BF=90=E8=A1=8C=E6=97=B6=EF=BC=88=E5=AF=B9=E4=BA=8EHiberna= te=E6=9D=A5=E8=AE=B2=E5=B0=B1=E6=98=AF=E5=90=AF=E5=8A=A8=E7=9A=84=E6=97=B6= =E5=80=99=EF=BC=89=E9=80=9A=E8=BF=87=E5=8F=8D=E5=B0=84=E8=AF=BB=E5=8F=96=E8= =BF=99=E4=BA=9B=E6=B3=A8=E8=A7=A3, =E5=9B=A0=E6=AD=A4=E5=A4=96=E9=83=A8XML= =E6=96=87=E4=BB=B6=E5=B0=B1=E4=B8=8D=E5=86=8D=E9=9C=80=E8=A6=81=E4=BA=86. + + EJB3=E8=A7=84=E8=8C=83=E6=9C=80=E7=BB=88=E8=AE=A4=E5=8F=AF=E4=BA= =86=E9=80=8F=E6=98=8E=E5=8C=96ORM=E7=9A=84=E6=88=90=E5=8A=9F=E8=8C=83=E4=BE= =8B=E4=BB=A5=E5=8F=8A=E5=B8=82=E5=9C=BA=E5=AF=B9=E4=BA=8E=E8=BF=99=E7=A7=8D= =E6=8A=80=E6=9C=AF=E7=9A=84=E5=85=B4=E8=B6=A3. + EJB3=E8=A7=84=E8=8C=83=E6=A0=87=E5=87=86=E5=8C=96=E4=BA=86ORM=E7=9A=84= =E5=9F=BA=E7=A1=80API=E8=80=8C=E4=B8=94=E5=9C=A8=E4=BB=BB=E4=BD=95ORM=E6=8C= =81=E4=B9=85=E5=8C=96=E6=9C=BA=E5=88=B6=E4=B8=AD=E4=BD=BF=E7=94=A8=E5=85=83= =E6=95=B0=E6=8D=AE. Hibernate + EntityManager=E5=AE=9E=E7=8E=B0=E4=BA=86EJB3=E6=8C=81=E4=B9= =85=E5=8C=96=E8=A7=84=E8=8C=83=E4=B8=AD=E5=AE=9A=E4=B9=89=E7=9A=84=E7=BC=96= =E7=A8=8B=E6=8E=A5=E5=8F=A3=E5=92=8C=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F=E8= =A7=84=E5=88=99. =E5=9C=A8Hibernate + Core=E7=9A=84=E5=9F=BA=E7=A1=80=E4=B8=8A=E5=86=8D=E7=BB=93= =E5=90=88 Hibernate + Annotations=E5=B0=B1=E5=AE=9E=E7=8E=B0=E4=BA=86=E4=B8=80=E5= =A5=97=E5=AE=8C=E6=95=B4(=E5=B9=B6=E4=B8=94=E7=8B=AC=E7=AB=8B)=E7=9A=84EJB3= =E6=8C=81=E4=B9=85=E5=8C=96=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88. + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E7=BB=93=E5=90=88=E4=B8=89=E8=80=85=E6=9D= =A5=E4=BD=BF=E7=94=A8,=E4=B9=9F=E5=8F=AF=E4=BB=A5=E6=8A=9B=E5=BC=80EJB3=E7= =BC=96=E7=A8=8B=E6=8E=A5=E5=8F=A3=E5=92=8C=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C= =9F=E8=A7=84=E5=88=99=E8=80=8C=E7=8B=AC=E7=AB=8B=E4=BD=BF=E7=94=A8=E6=B3=A8= =E8=A7=A3, =E7=94=9A=E8=87=B3=E5=8F=AA=E5=8D=95=E7=8B=AC=E4=BD=BF=E7=94=A8<= emphasis>Hibernate + Core. =E8=BF=99=E4=BA=9B=E9=83=BD=E5=8F=96=E5=86=B3=E4=BA= =8E=E9=A1=B9=E7=9B=AE=E7=9A=84=E5=95=86=E4=B8=9A=E5=92=8C=E6=8A=80=E6=9C=AF= =E4=B8=8A=E7=9A=84=E5=AE=9E=E9=99=85=E9=9C=80=E6=B1=82. Hibernate=E5=85=81= =E8=AE=B8=E4=BD=A0=E7=9B=B4=E6=8E=A5=E4=BD=BF=E7=94=A8native APIs,=E5=A6=82= =E6=9E=9C=E6=9C=89=E9=9C=80=E8=A6=81, + =E7=94=9A=E8=87=B3=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5=E6=93=8D=E4=BD= =9CJDBC=E5=92=8CSQL. + + =E6=B3=A8=E6=84=8F=E6=9C=AC=E6=96=87=E6=A1=A3=E5=9F=BA=E4=BA=8EH= ibernate Annotations=E7=9A=84=E9=A2=84=E8=A7=88=E7=89=88(=E9=81=B5=E4=BB=8E= EJB 3.0/JSR-220=E6=9C=80=E7=BB=88=E8=8D=89=E6=A1=88). + =E8=BF=99=E4=B8=AA=E7=89=88=E6=9C=AC=E5=92=8C=E6=96=B0=E8=A7=84=E8=8C= =83=E4=B8=AD=E5=AE=9A=E4=B9=89=E7=9A=84=E6=9C=80=E7=BB=88=E6=A6=82=E5=BF=B5= =E5=B7=B2=E7=BB=8F=E9=9D=9E=E5=B8=B8=E6=8E=A5=E8=BF=91=E4=BA=86.=E6=88=91= =E4=BB=AC=E7=9A=84=E7=9B=AE=E6=A0=87=E6=98=AF=E6=8F=90=E4=BE=9B=E4=B8=80=E5= =A5=97=E5=AE=8C=E6=95=B4=E7=9A=84ORM=E6=B3=A8=E8=A7=A3, + =E5=8C=85=E6=8B=ACEJB3=E7=9A=84=E6=A0=87=E5=87=86=E6=B3=A8=E8=A7=A3=E4= =BB=A5=E5=8F=8AHibernate3=E7=9A=84=E6=89=A9=E5=B1=95=EF=BC=88=E5=90=8E=E8= =80=85=E6=98=AFEJB3=E8=A7=84=E8=8C=83=E4=B8=AD=E6=B2=A1=E6=9C=89=E6=B6=89= =E5=8F=8A=E5=88=B0=E7=9A=84=EF=BC=89. =E6=9C=80=E7=BB=88=E9=80=9A=E8=BF=87= =E6=B3=A8=E8=A7=A3=E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=AE=8C=E6=88=90=E4=BB=BB=E4= =BD=95=E5=8F=AF=E8=83=BD=E7=9A=84=E6=98=A0=E5=B0=84.=E8=AF=A6=E6=83=85=E5= =8F=82=E8=80=83. + + EJB3=E6=9C=80=E7=BB=88=E8=8D=89=E6=A1=88=E4=BF=AE=E6=94=B9=E4=BA= =86=E9=83=A8=E5=88=86=E6=B3=A8=E8=A7=A3, + http://www.hibernate.org/371.html=E6=8F=90=E4=BE=9B=E4=BA=86=E4=BB=8E= =E4=B8=8A=E4=B8=80=E4=B8=AA=E7=89=88=E6=9C=AC=E5=88=B0=E6=9C=80=E6=96=B0=E7= =89=88=E6=9C=AC=E7=9A=84=E8=BF=81=E7=A7=BB=E6=8C=87=E5=8D=97. + + + &setup; + + &entity; + + &xml-overriding; + + &validator; + + &lucene; + + + =E6=9C=AF=E8=AF=AD=E8=A1=A8 + + Redsaga=E7=9A=84wiki=E4=B8=8A=E7=BB=B4=E6=8A=A4=E4=BA=86=E6=9C= =AC=E6=96=87=E7=BF=BB=E8=AF=91=E8=BF=87=E7=A8=8B=E4=B8=AD=E6=89=80=E5=8F=82= =E7=85=A7=E7=9A=84=E4=B8=AD=E8=8B=B1=E6=96=87=E5=AF=B9=E7=85=A7=E7=9A=84=E6= =9C=AF=E8=AF=AD=E8=A1=A8,=E5=9C=B0=E5=9D=80:http://wiki.redsaga.com/conflue= nce/display/HART/glossary. + +
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/ent= ity.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/entity= .xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/entity= .xml 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,2857 @@ + + + =E5=AE=9E=E4=BD=93Bean + + + =E7=AE=80=E4=BB=8B + + =E6=9C=AC=E7=AB=A0=E5=86=85=E5=AE=B9=E8=A6=86=E7=9B=96=E4=BA=86E= JB3.0=E5=AE=9E=E4=BD=93bean=E7=9A=84=E6=B3=A8=E8=A7=A3=E8=A7=84=E8=8C=83=E4= =BB=A5=E5=8F=8AHibernate=E7=89=B9=E6=9C=89=E7=9A=84=E6=89=A9=E5=B1=95. + + + + =E7=94=A8EJB3=E6=B3=A8=E8=A7=A3=E8=BF=9B=E8=A1=8C=E6=98=A0=E5= =B0=84 + + =E7=8E=B0=E5=9C=A8EJB3=E5=AE=9E=E4=BD=93Bean=E6=98=AF=E7=BA=AF= =E7=B2=B9=E7=9A=84POJO.=E5=AE=9E=E9=99=85=E4=B8=8A=E8=BF=99=E8=A1=A8=E8=BE= =BE=E4=BA=86=E5=92=8CHibernate=E6=8C=81=E4=B9=85=E5=8C=96=E5=AE=9E=E4=BD=93= =E5=AF=B9=E8=B1=A1=E5=90=8C=E6=A0=B7=E7=9A=84=E6=A6=82=E5=BF=B5. + =E5=AE=83=E4=BB=AC=E7=9A=84=E6=98=A0=E5=B0=84=E9=83=BD=E9=80=9A=E8=BF=87J= DK5.0=E6=B3=A8=E8=A7=A3=E6=9D=A5=E5=AE=9A=E4=B9=89(EJB3=E8=A7=84=E8=8C=83= =E4=B8=AD=E7=9A=84XML=E6=8F=8F=E8=BF=B0=E8=AF=AD=E6=B3=95=E8=87=B3=E4=BB=8A= =E8=BF=98=E6=B2=A1=E6=9C=89=E6=9C=80=E7=BB=88=E5=AE=9A=E4=B8=8B=E6=9D=A5). + =E6=B3=A8=E8=A7=A3=E5=88=86=E4=B8=BA=E4=B8=A4=E4=B8=AA=E9=83=A8=E5=88=86,= =E5=88=86=E5=88=AB=E6=98=AF=E9=80=BB=E8=BE=91=E6=98=A0=E5=B0=84=E6=B3=A8=E8= =A7=A3=E5=92=8C=E7=89=A9=E7=90=86=E6=98=A0=E5=B0=84=E6=B3=A8=E8=A7=A3, + =E9=80=9A=E8=BF=87=E9=80=BB=E8=BE=91=E6=98=A0=E5=B0=84=E6=B3=A8=E8=A7=A3= =E5=8F=AF=E4=BB=A5=E6=8F=8F=E8=BF=B0=E5=AF=B9=E8=B1=A1=E6=A8=A1=E5=9E=8B,= =E7=B1=BB=E4=B9=8B=E9=97=B4=E7=9A=84=E5=85=B3=E7=B3=BB=E7=AD=89=E7=AD=89, + =E8=80=8C=E7=89=A9=E7=90=86=E6=98=A0=E5=B0=84=E6=B3=A8=E8=A7=A3=E5=88=99= =E6=8F=8F=E8=BF=B0=E4=BA=86=E7=89=A9=E7=90=86=E7=9A=84schema,=E8=A1=A8,=E5= =88=97,=E7=B4=A2=E5=BC=95=E7=AD=89=E7=AD=89. + =E4=B8=8B=E9=9D=A2=E6=88=91=E4=BB=AC=E5=9C=A8=E4=BB=A3=E7=A0=81=E4=B8=AD= =E5=B0=86=E6=B7=B7=E5=90=88=E4=BD=BF=E7=94=A8=E8=BF=99=E4=B8=A4=E7=A7=8D=E7= =B1=BB=E5=9E=8B=E7=9A=84=E6=B3=A8=E8=A7=A3. + + EJB3=E6=B3=A8=E8=A7=A3=E7=9A=84API=E5=AE=9A=E4=B9=89=E5=9C=A8javax.persistence.*=E5=8C=85=E9=87=8C=E9=9D=A2. + =E5=A4=A7=E9=83=A8=E5=88=86=E5=92=8CJDK5=E5=85=BC=E5=AE=B9=E7=9A=84IDE(= =E8=B1=A1Eclipse, IntelliJ IDEA =E5=92=8CNetbeans=E7=AD=89=E7=AD=89)=E9=83= =BD=E6=8F=90=E4=BE=9B=E4=BA=86=E6=B3=A8=E8=A7=A3=E6=8E=A5=E5=8F=A3=E5=92=8C= =E5=B1=9E=E6=80=A7=E7=9A=84=E8=87=AA=E5=8A=A8=E5=AE=8C=E6=88=90=E5=8A=9F=E8= =83=BD. + (=E8=BF=99=E4=BA=9B=E4=B8=8D=E9=9C=80=E8=A6=81IDE=E6=8F=90=E4=BE=9B=E7=89= =B9=E5=88=AB=E7=9A=84EJB3=E6=94=AF=E6=8C=81=E6=A8=A1=E5=9D=97,=E5=9B=A0=E4= =B8=BAEJB3=E6=B3=A8=E8=A7=A3=E6=98=AF=E6=A0=87=E5=87=86=E7=9A=84JDK5=E6=B3= =A8=E8=A7=A3) + + =E8=AF=B7=E9=98=85=E8=AF=BBJBoss EJB 3.0=E6=8C=87=E5=8D=97=E6=88= =96=E8=80=85=E7=9B=B4=E6=8E=A5=E9=98=85=E8=AF=BBHibernate Annotations=E6=B5= =8B=E8=AF=95=E4=BB=A3=E7=A0=81=E4=BB=A5=E8=8E=B7=E5=8F=96=E6=9B=B4=E5=A4=9A= =E7=9A=84=E5=8F=AF=E8=BF=90=E8=A1=8C=E5=AE=9E=E4=BE=8B.Hibernate Annotation= s=E6=8F=90=E4=BE=9B=E7=9A=84=E5=A4=A7=E9=83=A8=E5=88=86=E5=8D=95=E5=85=83= =E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81=E9=83=BD=E6=BC=94=E7=A4=BA=E4=BA=86=E5= =AE=9E=E9=99=85=E7=9A=84=E4=BE=8B=E5=AD=90,=E6=98=AF=E4=B8=80=E4=B8=AA=E8= =8E=B7=E5=8F=96=E7=81=B5=E6=84=9F=E7=9A=84=E5=A5=BD=E5=9C=B0=E6=96=B9. + + + =E5=A3=B0=E6=98=8E=E5=AE=9E=E4=BD=93bean + + =E6=AF=8F=E4=B8=80=E4=B8=AA=E6=8C=81=E4=B9=85=E5=8C=96POJO=E7= =B1=BB=E9=83=BD=E6=98=AF=E4=B8=80=E4=B8=AA=E5=AE=9E=E4=BD=93bean,=E8=BF=99= =E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87=E5=9C=A8=E7=B1=BB=E7=9A=84=E5=AE=9A=E4= =B9=89=E4=B8=AD=E4=BD=BF=E7=94=A8@Entity=E6=B3=A8=E8=A7= =A3=E6=9D=A5=E8=BF=9B=E8=A1=8C=E5=A3=B0=E6=98=8E: + + +(a)Entity +public class Flight implements Serializable { + Long id; + + @Id + public Long getId() { return id; } + + public void setId(Long id) { this.id =3D id; } +} + + + =E9=80=9A=E8=BF=87@Entity=E6=B3=A8=E8=A7=A3= =E5=B0=86=E4=B8=80=E4=B8=AA=E7=B1=BB=E5=A3=B0=E6=98=8E=E4=B8=BA=E4=B8=80=E4= =B8=AA=E5=AE=9E=E4=BD=93bean(=E5=8D=B3=E4=B8=80=E4=B8=AA=E6=8C=81=E4=B9=85= =E5=8C=96POJO=E7=B1=BB), + @Id=E6=B3=A8=E8=A7=A3=E5=88=99=E5=A3=B0=E6=98=8E=E4= =BA=86=E8=AF=A5=E5=AE=9E=E4=BD=93bean=E7=9A=84=E6=A0=87=E8=AF=86=E5=B1=9E= =E6=80=A7. + =E5=85=B6=E4=BB=96=E7=9A=84=E6=98=A0=E5=B0=84=E5=AE=9A=E4=B9=89=E6=98= =AF=E9=9A=90=E5=BC=8F=E7=9A=84.=E8=BF=99=E7=A7=8D=E4=BB=A5=E9=9A=90=E5=BC= =8F=E6=98=A0=E5=B0=84=E4=B8=BA=E4=B8=BB=E4=BD=93,=E4=BB=A5=E6=98=BE=E5=BC= =8F=E6=98=A0=E5=B0=84=E4=B8=BA=E4=BE=8B=E5=A4=96=E7=9A=84=E9=85=8D=E7=BD=AE= =E6=96=B9=E5=BC=8F=E5=9C=A8=E6=96=B0=E7=9A=84EJ3=E8=A7=84=E8=8C=83=E4=B8=AD= =E5=A4=84=E4=BA=8E=E9=9D=9E=E5=B8=B8=E9=87=8D=E8=A6=81=E7=9A=84=E4=BD=8D=E7= =BD=AE, + =E5=92=8C=E4=BB=A5=E5=89=8D=E7=9A=84=E7=89=88=E6=9C=AC=E7=9B=B8=E6=AF= =94=E6=9C=89=E4=BA=86=E8=B4=A8=E7=9A=84=E9=A3=9E=E8=B7=83. + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E8=BF=99=E6=AE=B5=E4=BB=A3=E7=A0=81=E4=B8= =AD=EF=BC=9AFlight=E7=B1=BB=E6=98=A0=E5=B0=84=E5=88=B0Flight=E8=A1=A8,=E5= =B9=B6=E4=BD=BF=E7=94=A8id=E5=88=97=E4=BD=9C=E4=B8=BA=E4=B8=BB=E9=94=AE=E5= =88=97. + + + =E5=9C=A8=E5=AF=B9=E4=B8=80=E4=B8=AA=E7=B1=BB=E8=BF=9B=E8=A1= =8C=E6=B3=A8=E8=A7=A3=E6=97=B6,=E4=BD=A0=E5=8F=AF=E4=BB=A5=E9=80=89=E6=8B= =A9=E5=AF=B9=E5=AE=83=E7=9A=84=E7=9A=84=E5=B1=9E=E6=80=A7=E6=88=96=E8=80=85= =E6=96=B9=E6=B3=95=E8=BF=9B=E8=A1=8C=E6=B3=A8=E8=A7=A3,=E6=A0=B9=E6=8D=AE= =E4=BD=A0=E7=9A=84=E9=80=89=E6=8B=A9,Hibernate=E7=9A=84=E8=AE=BF=E9=97=AE= =E7=B1=BB=E5=9E=8B=E5=88=86=E5=88=AB=E4=B8=BA + field=E6=88=96property. + EJ3=E8=A7=84=E8=8C=83=E8=A6=81=E6=B1=82=E5=9C=A8=E9=9C=80=E8=A6=81=E8= =AE=BF=E9=97=AE=E7=9A=84=E5=85=83=E7=B4=A0=E4=B8=8A=E8=BF=9B=E8=A1=8C=E6=B3= =A8=E8=A7=A3=E5=A3=B0=E6=98=8E,=E4=BE=8B=E5=A6=82,=E5=A6=82=E6=9E=9C=E8=AE= =BF=E9=97=AE=E7=B1=BB=E5=9E=8B=E4=B8=BA + property=E5=B0=B1=E8=A6=81=E5=9C=A8getter=E6=96=B9= =E6=B3=95=E4=B8=8A=E8=BF=9B=E8=A1=8C=E6=B3=A8=E8=A7=A3=E5=A3=B0=E6=98=8E, + =E5=A6=82=E6=9E=9C=E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B=E4=B8=BA field=E5=B0=B1=E8=A6=81=E5=9C=A8=E5=AD=97=E6=AE=B5=E4=B8=8A=E8= =BF=9B=E8=A1=8C=E6=B3=A8=E8=A7=A3=E5=A3=B0=E6=98=8E.=E5=BA=94=E8=AF=A5=E5= =B0=BD=E9=87=8F=E9=81=BF=E5=85=8D=E6=B7=B7=E5=90=88=E4=BD=BF=E7=94=A8=E8=BF= =99=E4=B8=A4=E7=A7=8D=E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B. + Hibernate=E6=A0=B9=E6=8D=AE@Id =E6=88=96 @E= mbeddedId=E7=9A=84=E4=BD=8D=E7=BD=AE=E6=9D=A5=E5=88=A4=E6=96=AD= =E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B. + + + =E5=AE=9A=E4=B9=89=E8=A1=A8(Table) + + @Table=E6=98=AF=E7=B1=BB=E4=B8=80=E7=BA= =A7=E7=9A=84=E6=B3=A8=E8=A7=A3, + =E9=80=9A=E8=BF=87@Table=E6=B3=A8=E8=A7=A3=E5=8F=AF= =E4=BB=A5=E4=B8=BA=E5=AE=9E=E4=BD=93bean=E6=98=A0=E5=B0=84=E6=8C=87=E5=AE= =9A=E8=A1=A8(table),=E7=9B=AE=E5=BD=95(catalog)=E5=92=8Cschema=E7=9A=84=E5= =90=8D=E5=AD=97. + =E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E5=AE=9A=E4=B9=89@Table,=E9=82=A3=E4=B9=88=E7=B3=BB=E7=BB=9F=E8=87=AA=E5=8A=A8=E4=BD=BF=E7= =94=A8=E9=BB=98=E8=AE=A4=E5=80=BC=EF=BC=9A=E5=AE=9E=E4=BD=93=E7=9A=84=E7=9F= =AD=E7=B1=BB=E5=90=8D(=E4=B8=8D=E9=99=84=E5=B8=A6=E5=8C=85=E5=90=8D). + + +(a)Entity +(a)Table(name=3D"tbl_sky") +public class Sky implements Serializable { +... + + + @Table=E5=85=83=E7=B4=A0=E5=8C=85=E6=8B= =AC=E4=BA=86=E4=B8=80=E4=B8=AAschema + =E5=92=8C=E4=B8=80=E4=B8=AA catalog=E5=B1=9E=E6=80=A7= ,=E5=A6=82=E6=9E=9C=E9=9C=80=E8=A6=81=E5=8F=AF=E4=BB=A5=E6=8C=87=E5=AE=9A= =E7=9B=B8=E5=BA=94=E7=9A=84=E5=80=BC. + =E7=BB=93=E5=90=88=E4=BD=BF=E7=94=A8@UniqueConstraint= =E6=B3=A8=E8=A7=A3=E5=8F=AF=E4=BB=A5=E5=AE=9A=E4=B9=89=E8=A1=A8=E7=9A=84=E5= =94=AF=E4=B8=80=E7=BA=A6=E6=9D=9F(unique constraint) + (=E5=AF=B9=E4=BA=8E=E7=BB=91=E5=AE=9A=E5=88=B0=E5=8D=95=E5=88=97=E7=9A= =84=E5=94=AF=E4=B8=80=E7=BA=A6=E6=9D=9F,=E8=AF=B7=E5=8F=82=E8=80=83@Column=E6=B3=A8=E8=A7=A3) + + + @Table(name=3D"tbl_sky", + uniqueConstraints =3D {@UniqueConstraint(col= umnNames=3D{"month", "day"})} + ) + + =E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8= =AD,=E5=9C=A8month=E5=92=8Cday=E8=BF=99=E4=B8=A4=E4=B8=AA=E5=AD=97=E6=AE=B5= =E4=B8=8A=E5=AE=9A=E4=B9=89=E5=94=AF=E4=B8=80=E7=BA=A6=E6=9D=9F. + =E6=B3=A8=E6=84=8FcolumnNames=E6=95=B0=E7=BB=84=E4=B8= =AD=E7=9A=84=E5=80=BC=E6=8C=87=E7=9A=84=E6=98=AF=E9=80=BB=E8=BE=91=E5=88=97= =E5=90=8D. + + Hibernate=E5=9C=A8NamingStrategy=E7=9A=84=E5=AE=9E=E7=8E= =B0=E4=B8=AD=E5=AE=9A=E4=B9=89=E4=BA=86=E9=80=BB=E8=BE=91=E5=88=97=E5=90=8D. + =E9=BB=98=E8=AE=A4=E7=9A=84EJB3=E5=91=BD=E5=90=8D=E7=AD=96=E7=95=A5=E5= =B0=86=E7=89=A9=E7=90=86=E5=AD=97=E6=AE=B5=E5=90=8D=E5=BD=93=E4=BD=9C=E9=80= =BB=E8=BE=91=E5=AD=97=E6=AE=B5=E5=90=8D=E6=9D=A5=E4=BD=BF=E7=94=A8. + =E6=B3=A8=E6=84=8F=E8=AF=A5=E5=AD=97=E6=AE=B5=E5=90=8D=E5=92=8C=E5=AE=83= =E5=AF=B9=E5=BA=94=E7=9A=84=E5=B1=9E=E6=80=A7=E5=90=8D=E5=8F=AF=E8=83=BD=E4= =B8=8D=E5=90=8C(=E5=A6=82=E6=9E=9C=E5=AD=97=E6=AE=B5=E5=90=8D=E6=98=AF=E6= =98=BE=E5=BC=8F=E6=8C=87=E5=AE=9A=E7=9A=84=E8=AF=9D). + =E9=99=A4=E9=9D=9E=E4=BD=A0=E9=87=8D=E5=86=99=E4=BA=86NamingStrategy,=E5= =90=A6=E5=88=99=E4=B8=8D=E7=94=A8=E6=8B=85=E5=BF=83=E8=BF=99=E4=BA=9B=E5=8C= =BA=E5=88=AB.. + + + + =E4=B9=90=E8=A7=82=E9=94=81=E5=AE=9A=E7=89=88=E6=9C=AC=E6= =8E=A7=E5=88=B6 + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=9C=A8=E5=AE=9E=E4=BD=93bean= =E4=B8=AD=E4=BD=BF=E7=94=A8@Version=E6=B3=A8=E8=A7=A3,= =E9=80=9A=E8=BF=87=E8=BF=99=E7=A7=8D=E6=96=B9=E5=BC=8F=E5=8F=AF=E6=B7=BB=E5= =8A=A0=E5=AF=B9=E4=B9=90=E8=A7=82=E9=94=81=E5=AE=9A=E7=9A=84=E6=94=AF=E6=8C= =81: + + +(a)Entity +public class Flight implements Serializable { +... + @Version + @Column(name=3D"OPTLOCK") + public Integer getVersion() { ... } +} + + =E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8= =AD,version=E5=B1=9E=E6=80=A7=E5=B0=86=E6=98=A0=E5=B0=84=E5=88=B0 = OPTLOCK=E5=88=97, + entity manager=E4=BD=BF=E7=94=A8=E8=AF=A5=E5=AD=97=E6=AE=B5=E6=9D=A5=E6= =A3=80=E6=B5=8B=E6=9B=B4=E6=96=B0=E5=86=B2=E7=AA=81(=E9=98=B2=E6=AD=A2=E6= =9B=B4=E6=96=B0=E4=B8=A2=E5=A4=B1,=E8=AF=B7=E5=8F=82=E8=80=83last-commit-wi= ns=E7=AD=96=E7=95=A5). + + =E6=A0=B9=E6=8D=AEEJB3=E8=A7=84=E8=8C=83,version=E5=88=97=E5= =8F=AF=E4=BB=A5=E6=98=AFnumeric=E7=B1=BB=E5=9E=8B(=E6=8E=A8=E8=8D=90=E6=96= =B9=E5=BC=8F)=E4=B9=9F=E5=8F=AF=E4=BB=A5=E6=98=AFtimestamp=E7=B1=BB=E5=9E= =8B. + Hibernate=E6=94=AF=E6=8C=81=E4=BB=BB=E4=BD=95=E8=87=AA=E5=AE=9A=E4=B9=89= =E7=B1=BB=E5=9E=8B,=E5=8F=AA=E8=A6=81=E8=AF=A5=E7=B1=BB=E5=9E=8B=E5=AE=9E= =E7=8E=B0=E4=BA=86UserVersionType. + + + + + =E6=98=A0=E5=B0=84=E7=AE=80=E5=8D=95=E5=B1=9E=E6=80=A7 + + + =E5=A3=B0=E6=98=8E=E5=9F=BA=E6=9C=AC=E7=9A=84=E5=B1=9E=E6= =80=A7=E6=98=A0=E5=B0=84 + + Every non static non transient property (field or method) of= an + entity bean is considered persistent, unless you annotate it as + @Transient. Not having an annotation for your + property is equivalent to the appropriate @Basic + annotation. The @Basic annotation allows you to + declare the fetching strategy for a property: + + =E5=AE=9E=E4=BD=93bean=E4=B8=AD=E6=89=80=E6=9C=89=E7=9A=84= =E9=9D=9Estatic=E9=9D=9Etransient=E7=9A=84=E5=B1=9E=E6=80=A7=E9=83=BD=E5=8F= =AF=E4=BB=A5=E8=A2=AB=E6=8C=81=E4=B9=85=E5=8C=96, + =E9=99=A4=E9=9D=9E=E4=BD=A0=E5=B0=86=E5=85=B6=E6=B3=A8=E8=A7=A3=E4=B8=BA= @Transient.=E6=89=80=E6=9C=89=E6=B2=A1=E6=9C=89=E5=AE=9A= =E4=B9=89=E6=B3=A8=E8=A7=A3=E7=9A=84=E5=B1=9E=E6=80=A7=E7=AD=89=E4=BB=B7=E4= =BA=8E=E5=9C=A8=E5=85=B6=E4=B8=8A=E9=9D=A2=E6=B7=BB=E5=8A=A0=E4=BA=86@Basic= =E6=B3=A8=E8=A7=A3. + =E9=80=9A=E8=BF=87 @Basic=E6=B3=A8=E8=A7=A3=E5=8F=AF= =E4=BB=A5=E5=A3=B0=E6=98=8E=E5=B1=9E=E6=80=A7=E7=9A=84=E8=8E=B7=E5=8F=96=E7= =AD=96=E7=95=A5(fetch strategy)=EF=BC=9A + + public transient int counter; //transient property + +private String firstname; //persistent property + +(a)Transient +String getLengthInMeter() { ... } //transient property + +String getName() {... } // persistent property + +(a)Basic +int getLength() { ... } // persistent property + +(a)Basic(fetch =3D FetchType.LAZY) +String getDetailedComment() { ... } // persistent property + +(a)Temporal(TemporalType.TIME) +java.util.Date getDepartureTime() { ... } // persistent property = + +(a)Enumerated(EnumType.STRING) +Starred getNote() { ... } //enum persisted as String in database + + =E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8= =AD,counter=E6=98=AF=E4=B8=80=E4=B8=AAtransient=E7=9A=84= =E5=AD=97=E6=AE=B5, + lengthInMeter=E7=9A=84getter=E6=96=B9=E6=B3=95=E8=A2= =AB=E6=B3=A8=E8=A7=A3=E4=B8=BA@Transient, = + entity manager=E5=B0=86=E5=BF=BD=E7=95=A5=E8=BF=99=E4=BA=9B=E5=AD=97=E6= =AE=B5=E5=92=8C=E5=B1=9E=E6=80=A7. + =E8=80=8Cname,length,firs= tname + =E8=BF=99=E5=87=A0=E4=B8=AA=E5=B1=9E=E6=80=A7=E5=88=99=E6=98=AF=E8=A2=AB= =E5=AE=9A=E4=B9=89=E4=B8=BA=E5=8F=AF=E6=8C=81=E4=B9=85=E5=8C=96=E5=92=8C=E5= =8F=AF=E8=8E=B7=E5=8F=96=E7=9A=84.=E5=AF=B9=E4=BA=8E=E7=AE=80=E5=8D=95=E5= =B1=9E=E6=80=A7=E6=9D=A5=E8=AF=B4,=E9=BB=98=E8=AE=A4=E7=9A=84=E8=8E=B7=E5= =8F=96=E6=96=B9=E5=BC=8F=E6=98=AF=E5=8D=B3=E6=97=B6=E8=8E=B7=E5=8F=96(early= fetch). + =E5=BD=93=E4=B8=80=E4=B8=AA=E5=AE=9E=E4=BD=93Bean=E7=9A=84=E5=AE=9E=E4= =BE=8B=E8=A2=AB=E5=88=9B=E5=BB=BA=E6=97=B6,Hibernate=E4=BC=9A=E5=B0=86=E8= =BF=99=E4=BA=9B=E5=B1=9E=E6=80=A7=E7=9A=84=E5=80=BC=E4=BB=8E=E6=95=B0=E6=8D= =AE=E5=BA=93=E4=B8=AD=E6=8F=90=E5=8F=96=E5=87=BA=E6=9D=A5,=E4=BF=9D=E5=AD= =98=E5=88=B0Bean=E7=9A=84=E5=B1=9E=E6=80=A7=E9=87=8C. + =E4=B8=8E=E5=8D=B3=E6=97=B6=E8=8E=B7=E5=8F=96=E7=9B=B8=E5=AF=B9=E5=BA=94= =E7=9A=84=E6=98=AF=E5=BB=B6=E8=BF=9F=E8=8E=B7=E5=8F=96(lazy fetch).=E5=A6= =82=E6=9E=9C=E4=B8=80=E4=B8=AA=E5=B1=9E=E6=80=A7=E7=9A=84=E8=8E=B7=E5=8F=96= =E6=96=B9=E5=BC=8F=E6=98=AF=E5=BB=B6=E8=BF=9F=E8=8E=B7=E5=8F=96 + (=E6=AF=94=E5=A6=82=E4=B8=8A=E9=9D=A2=E4=BE=8B=E5=AD=90=E4=B8=AD=E7=9A= =84detailedComment=E5=B1=9E=E6=80=A7), + Hibernate=E5=9C=A8=E5=88=9B=E5=BB=BA=E4=B8=80=E4=B8=AA=E5=AE=9E=E4=BD=93= Bean=E7=9A=84=E5=AE=9E=E4=BE=8B=E6=97=B6,=E4=B8=8D=E4=BC=9A=E5=8D=B3=E6=97= =B6=E5=B0=86=E8=BF=99=E4=B8=AA=E5=B1=9E=E6=80=A7=E7=9A=84=E5=80=BC=E4=BB=8E= =E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=AD=E8=AF=BB=E5=87=BA. + =E5=8F=AA=E6=9C=89=E5=9C=A8=E8=AF=A5=E5=AE=9E=E4=BD=93Bean=E7=9A=84=E8= =BF=99=E4=B8=AA=E5=B1=9E=E6=80=A7=E7=AC=AC=E4=B8=80=E6=AC=A1=E8=A2=AB=E8=B0= =83=E7=94=A8=E6=97=B6,Hibernate=E6=89=8D=E4=BC=9A=E5=8E=BB=E8=8E=B7=E5=8F= =96=E5=AF=B9=E5=BA=94=E7=9A=84=E5=80=BC. + =E9=80=9A=E5=B8=B8=E4=BD=A0=E4=B8=8D=E9=9C=80=E8=A6=81=E5=AF=B9=E7=AE=80= =E5=8D=95=E5=B1=9E=E6=80=A7=E8=AE=BE=E7=BD=AE=E5=BB=B6=E8=BF=9F=E8=8E=B7=E5= =8F=96(lazy simple property),=E5=8D=83=E4=B8=87=E4=B8=8D=E8=A6=81=E5=92=8C= =E5=BB=B6=E8=BF=9F=E5=85=B3=E8=81=94=E8=8E=B7=E5=8F=96(lazy association fet= ch)=E6=B7=B7=E6=B7=86=E4=BA=86 + (=E8=AF=91=E6=B3=A8:=E8=BF=99=E9=87=8C=E6=8C=87=E4=B8=8D=E8=A6=81=E6=8A= =8Alazy simple property=E5=92=8Clazy association fetch=E6=B7=B7=E6=B7=86=E4= =BA=86). + + + + =E4=B8=BA=E4=BA=86=E5=90=AF=E7=94=A8=E5=B1=9E=E6=80=A7=E7= =BA=A7=E7=9A=84=E5=BB=B6=E8=BF=9F=E8=8E=B7=E5=8F=96,=E4=BD=A0=E7=9A=84=E7= =B1=BB=E5=BF=85=E9=A1=BB=E7=BB=8F=E8=BF=87=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90= =86(instrumented)=EF=BC=9A + =E5=AD=97=E8=8A=82=E7=A0=81=E5=B0=86=E8=A2=AB=E7=BB=87=E5=85=A5=E5=8E= =9F=E5=A7=8B=E7=B1=BB=E4=B8=AD=E6=9D=A5=E5=AE=9E=E7=8E=B0=E5=BB=B6=E8=BF=9F= =E8=8E=B7=E5=8F=96=E5=8A=9F=E8=83=BD, + =E8=AF=A6=E6=83=85=E5=8F=82=E8=80=83Hibernate=E5=8F=82=E8=80=83=E6=96= =87=E6=A1=A3.=E5=A6=82=E6=9E=9C=E4=B8=8D=E5=AF=B9=E7=B1=BB=E6=96=87=E4=BB= =B6=E8=BF=9B=E8=A1=8C=E5=AD=97=E8=8A=82=E7=A0=81=E7=89=B9=E6=AE=8A=E5=A4=84= =E7=90=86, + =E9=82=A3=E4=B9=88=E5=B1=9E=E6=80=A7=E7=BA=A7=E7=9A=84=E5=BB=B6=E8=BF= =9F=E8=8E=B7=E5=8F=96=E5=B0=86=E8=A2=AB=E5=BF=BD=E7=95=A5. + + + =E6=8E=A8=E8=8D=90=E7=9A=84=E6=9B=BF=E4=BB=A3=E6=96=B9=E6=A1= =88=E6=98=AF=E4=BD=BF=E7=94=A8EJB-QL=E6=88=96=E8=80=85Criteria=E6=9F=A5=E8= =AF=A2=E7=9A=84=E6=8A=95=E5=BD=B1(projection)=E5=8A=9F=E8=83=BD. + + Hibernate=E5=92=8CEJB3=E9=83=BD=E6=94=AF=E6=8C=81=E6=89=80= =E6=9C=89=E5=9F=BA=E6=9C=AC=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=B1=9E=E6=80=A7=E6= =98=A0=E5=B0=84. + =E8=BF=99=E4=BA=9B=E5=9F=BA=E6=9C=AC=E7=B1=BB=E5=9E=8B=E5=8C=85=E6=8B=AC= =E6=89=80=E6=9C=89=E7=9A=84Java=E5=9F=BA=E6=9C=AC=E7=B1=BB=E5=9E=8B,=E5=8F= =8A=E5=85=B6=E5=90=84=E8=87=AA=E7=9A=84wrapper=E7=B1=BB=E5=92=8Cserializabl= e=E7=B1=BB. + Hibernate Annotations=E8=BF=98=E6=94=AF=E6=8C=81=E5=B0=86=E5=86=85=E7=BD= =AE=E7=9A=84=E6=9E=9A=E4=B8=BE=E7=B1=BB=E5=9E=8B=E6=98=A0=E5=B0=84=E5=88=B0= =E4=B8=80=E4=B8=AA=E9=A1=BA=E5=BA=8F=E5=88=97(=E4=BF=9D=E5=AD=98=E4=BA=86= =E7=9B=B8=E5=BA=94=E7=9A=84=E5=BA=8F=E5=88=97=E5=80=BC) + =E6=88=96=E4=B8=80=E4=B8=AA=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=B1=BB=E5=9E=8B= =E7=9A=84=E5=88=97(=E4=BF=9D=E5=AD=98=E7=9B=B8=E5=BA=94=E7=9A=84=E5=AD=97= =E7=AC=A6=E4=B8=B2).=E9=BB=98=E8=AE=A4=E6=98=AF=E4=BF=9D=E5=AD=98=E6=9E=9A= =E4=B8=BE=E7=9A=84=E5=BA=8F=E5=88=97=E5=80=BC, + =E4=BD=86=E6=98=AF=E4=BD=A0=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87= @Enumerated=E6=B3=A8=E8=A7=A3=E6=9D=A5=E8=BF=9B=E8=A1=8C=E8=B0=83= =E6=95=B4(=E8=A7=81=E4=B8=8A=E9=9D=A2=E4=BE=8B=E5=AD=90=E4=B8=AD=E7=9A=84no= te=E5=B1=9E=E6=80=A7). + + =E5=9C=A8=E6=A0=B8=E5=BF=83=E7=9A=84Java API=E4=B8=AD=E5=B9= =B6=E6=B2=A1=E6=9C=89=E5=AE=9A=E4=B9=89=E6=97=B6=E9=97=B4=E7=B2=BE=E5=BA=A6= (temporal precision). + =E5=9B=A0=E6=AD=A4=E5=A4=84=E7=90=86=E6=97=B6=E9=97=B4=E7=B1=BB=E5=9E=8B= =E6=95=B0=E6=8D=AE=E6=97=B6,=E4=BD=A0=E8=BF=98=E9=9C=80=E8=A6=81=E5=AE=9A= =E4=B9=89=E5=B0=86=E5=85=B6=E5=AD=98=E5=82=A8=E5=9C=A8=E6=95=B0=E6=8D=AE=E5= =BA=93=E4=B8=AD=E6=89=80=E9=A2=84=E6=9C=9F=E7=9A=84=E7=B2=BE=E5=BA=A6. + =E5=9C=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=AD,=E8=A1=A8=E7=A4=BA=E6=97= =B6=E9=97=B4=E7=B1=BB=E5=9E=8B=E7=9A=84=E6=95=B0=E6=8D=AE=E6=9C=89= DATE, TIME, = + =E5=92=8C TIMESTAMP=E4=B8=89=E7=A7=8D=E7=B2=BE=E5=BA= =A6(=E5=8D=B3=E5=8D=95=E7=BA=AF=E7=9A=84=E6=97=A5=E6=9C=9F,=E6=97=B6=E9=97= =B4,=E6=88=96=E8=80=85=E4=B8=A4=E8=80=85=E5=85=BC=E5=A4=87). + =E5=8F=AF=E4=BD=BF=E7=94=A8@Temporal=E6=B3=A8=E8=A7= =A3=E6=9D=A5=E8=B0=83=E6=95=B4=E7=B2=BE=E5=BA=A6. + + @Lob=E6=B3=A8=E8=A7=A3=E8=A1=A8=E7=A4=BA= =E5=B1=9E=E6=80=A7=E5=B0=86=E8=A2=AB=E6=8C=81=E4=B9=85=E5=8C=96=E4=B8=BABlo= b=E6=88=96=E8=80=85Clob=E7=B1=BB=E5=9E=8B, + =E5=85=B7=E4=BD=93=E5=8F=96=E5=86=B3=E4=BA=8E=E5=B1=9E=E6=80=A7=E7=9A=84= =E7=B1=BB=E5=9E=8B, + java.sql.Clob, = + Character[], + char[] =E5=92=8C = + java.lang.String=E8=BF=99=E4=BA=9B=E7=B1=BB=E5=9E= =8B=E7=9A=84=E5=B1=9E=E6=80=A7=E9=83=BD=E8=A2=AB=E6=8C=81=E4=B9=85=E5=8C=96= =E4=B8=BAClob=E7=B1=BB=E5=9E=8B, + =E8=80=8Cjava.sql.Blob, = + Byte[], = + byte[] =E5=92=8C + serializable=E7=B1=BB=E5=9E=8B=E5=88=99=E8=A2=AB=E6=8C=81=E4=B9=85=E5=8C= =96=E4=B8=BABlob=E7=B1=BB=E5=9E=8B. + + +(a)Lob +public String getFullText() { + return fullText; +} + +(a)Lob = +public byte[] getFullCode() { + return fullCode; +} + + + =E5=A6=82=E6=9E=9C=E6=9F=90=E4=B8=AA=E5=B1=9E=E6=80=A7=E5=AE= =9E=E7=8E=B0=E4=BA=86java.io.Serializable=E5=90=8C= =E6=97=B6=E4=B9=9F=E4=B8=8D=E6=98=AF=E5=9F=BA=E6=9C=AC=E7=B1=BB=E5=9E=8B, + =E5=B9=B6=E4=B8=94=E6=B2=A1=E6=9C=89=E5=9C=A8=E8=AF=A5=E5=B1=9E=E6=80=A7= =E4=B8=8A=E4=BD=BF=E7=94=A8@Lob=E6=B3=A8=E8=A7=A3, + =E9=82=A3=E4=B9=88Hibernate=E5=B0=86=E4=BD=BF=E7=94=A8=E8=87=AA=E5=B8=A6= =E7=9A=84serializable=E7=B1=BB=E5=9E=8B. + + + + + =E5=A3=B0=E6=98=8E=E5=88=97=E5=B1=9E=E6=80=A7 + + =E4=BD=BF=E7=94=A8 @Column =E6=B3=A8=E8= =A7=A3=E5=8F=AF=E5=B0=86=E5=B1=9E=E6=80=A7=E6=98=A0=E5=B0=84=E5=88=B0=E5=88= =97. + =E4=BD=BF=E7=94=A8=E8=AF=A5=E6=B3=A8=E8=A7=A3=E6=9D=A5=E8=A6=86=E7=9B=96= =E9=BB=98=E8=AE=A4=E5=80=BC(=E5=85=B3=E4=BA=8E=E9=BB=98=E8=AE=A4=E5=80=BC= =E8=AF=B7=E5=8F=82=E8=80=83EJB3=E8=A7=84=E8=8C=83). + =E5=9C=A8=E5=B1=9E=E6=80=A7=E7=BA=A7=E4=BD=BF=E7=94=A8=E8=AF=A5=E6=B3=A8= =E8=A7=A3=E7=9A=84=E6=96=B9=E5=BC=8F=E5=A6=82=E4=B8=8B=EF=BC=9A + + + + =E4=B8=8D=E8=BF=9B=E8=A1=8C=E6=B3=A8=E8=A7=A3 + + + + =E5=92=8C @Basic=E4=B8=80=E8=B5=B7=E4= =BD=BF=E7=94=A8 + + + + =E5=92=8C @Version=E4=B8=80=E8=B5=B7= =E4=BD=BF=E7=94=A8 + + + + =E5=92=8C @Lob=E4=B8=80=E8=B5=B7=E4= =BD=BF=E7=94=A8 + + + + =E5=92=8C @Temporal=E4=B8=80=E8=B5=B7= =E4=BD=BF=E7=94=A8 + + + + =E5=92=8C + @org.hibernate.annotations.CollectionOfElements=E4=B8=80=E8=B5=B7=E4=BD=BF=E7=94=A8 + (=E5=8F=AA=E9=92=88=E5=AF=B9Hibernate ) + + + + + +(a)Entity +public class Flight implements Serializable { +... +(a)Column(updatable =3D false, name =3D "flight_name", nullable =3D false,= length=3D50) +public String getName() { ... } + + + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD= =90=E4=B8=AD,name=E5=B1=9E=E6=80=A7=E6=98=A0=E5=B0=84=E5= =88=B0flight_name=E5=88=97. + =E8=AF=A5=E5=AD=97=E6=AE=B5=E4=B8=8D=E5=85=81=E8=AE=B8=E4=B8=BA=E7=A9=BA= ,=E9=95=BF=E5=BA=A6=E4=B8=BA50,=E5=B9=B6=E4=B8=94=E6=98=AF=E4=B8=8D=E5=8F= =AF=E6=9B=B4=E6=96=B0=E7=9A=84(=E4=B9=9F=E5=B0=B1=E6=98=AF=E5=B1=9E=E6=80= =A7=E5=80=BC=E6=98=AF=E4=B8=8D=E5=8F=98=E7=9A=84). + + =E4=B8=8A=E9=9D=A2=E8=BF=99=E4=BA=9B=E6=B3=A8=E8=A7=A3=E5=8F= =AF=E4=BB=A5=E8=A2=AB=E5=BA=94=E7=94=A8=E5=88=B0=E6=AD=A3=E8=A7=84=E5=B1=9E= =E6=80=A7=E4=B8=8A=E4=BE=8B=E5=A6=82@Id =E6=88=96@Version=E5=B1=9E=E6=80=A7. + + + + + + + + + + + + + + + + + + + + + + + + + @Column( + name=3D"columnName"; + boolean unique() default false; + boolean nullable() default true; + boolean insertable() default true; + boolean updatable() default true; + String columnDefinition() default ""; + String table() default ""; + int length() default 255; + int precision() default 0; // decimal precision + int scale() default 0; // decimal scale + + + + name =E5=8F=AF=E9=80=89,=E5=88=97= =E5=90=8D(=E9=BB=98=E8=AE=A4=E5=80=BC=E6=98=AF=E5=B1=9E=E6=80=A7=E5=90=8D)<= /para> + + + + unique =E5=8F=AF=E9=80=89,=E6=98=AF= =E5=90=A6=E5=9C=A8=E8=AF=A5=E5=88=97=E4=B8=8A=E8=AE=BE=E7=BD=AE=E5=94=AF=E4= =B8=80=E7=BA=A6=E6=9D=9F(=E9=BB=98=E8=AE=A4=E5=80=BCfalse) + + + + nullable =E5=8F=AF=E9=80=89,=E6=98= =AF=E5=90=A6=E8=AE=BE=E7=BD=AE=E8=AF=A5=E5=88=97=E7=9A=84=E5=80=BC=E5=8F=AF= =E4=BB=A5=E4=B8=BA=E7=A9=BA(=E9=BB=98=E8=AE=A4=E5=80=BCfalse) + + + + insertable =E5=8F=AF=E9=80=89,=E8= =AF=A5=E5=88=97=E6=98=AF=E5=90=A6=E4=BD=9C=E4=B8=BA=E7=94=9F=E6=88=90=E7=9A= =84insert=E8=AF=AD=E5=8F=A5=E4=B8=AD=E7=9A=84=E4=B8=80=E4=B8=AA=E5=88=97(= =E9=BB=98=E8=AE=A4=E5=80=BCtrue) + + + + updatable =E5=8F=AF=E9=80=89,=E8=AF= =A5=E5=88=97=E6=98=AF=E5=90=A6=E4=BD=9C=E4=B8=BA=E7=94=9F=E6=88=90=E7=9A=84= update=E8=AF=AD=E5=8F=A5=E4=B8=AD=E7=9A=84=E4=B8=80=E4=B8=AA=E5=88=97(=E9= =BB=98=E8=AE=A4=E5=80=BCtrue) + + + + columnDefinition =E5=8F=AF=E9=80=89= : =E4=B8=BA=E8=BF=99=E4=B8=AA=E7=89=B9=E5=AE=9A=E5=88=97=E8=A6=86=E7=9B=96S= QL DDL=E7=89=87=E6=AE=B5 (=E8=BF=99=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4=E6= =97=A0=E6=B3=95=E5=9C=A8=E4=B8=8D=E5=90=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E9=97= =B4=E7=A7=BB=E6=A4=8D) + + + + table =E5=8F=AF=E9=80=89,=E5=AE=9A= =E4=B9=89=E5=AF=B9=E5=BA=94=E7=9A=84=E8=A1=A8(=E9=BB=98=E8=AE=A4=E4=B8=BA= =E4=B8=BB=E8=A1=A8) + + + + length =E5=8F=AF= =E9=80=89,=E5=88=97=E9=95=BF=E5=BA=A6(=E9=BB=98=E8=AE=A4=E5=80=BC255) + + + + precision + =E5=8F=AF=E9=80=89,=E5=88=97=E5=8D=81=E8=BF=9B=E5=88=B6=E7= =B2=BE=E5=BA=A6(decimal precision)(=E9=BB=98=E8=AE=A4=E5=80=BC0) + + + + scale = + =E5=8F=AF=E9=80=89,=E5=A6=82=E6=9E=9C=E5=88=97=E5=8D=81=E8= =BF=9B=E5=88=B6=E6=95=B0=E5=80=BC=E8=8C=83=E5=9B=B4(decimal scale)=E5=8F=AF= =E7=94=A8,=E5=9C=A8=E6=AD=A4=E8=AE=BE=E7=BD=AE(=E9=BB=98=E8=AE=A4=E5=80=BC0= ) + + + + + + + =E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1(=E5=8F=88=E5= =90=8D=E7=BB=84=E4=BB=B6) + + =E5=9C=A8=E5=AE=9E=E4=BD=93=E4=B8=AD=E5=8F=AF=E4=BB=A5=E5=AE= =9A=E4=B9=89=E4=B8=80=E4=B8=AA=E5=B5=8C=E5=85=A5=E5=BC=8F=E7=BB=84=E4=BB=B6= (embedded component), + =E7=94=9A=E8=87=B3=E8=A6=86=E7=9B=96=E8=AF=A5=E5=AE=9E=E4=BD=93=E4=B8=AD= =E5=8E=9F=E6=9C=89=E7=9A=84=E5=88=97=E6=98=A0=E5=B0=84. + =E7=BB=84=E4=BB=B6=E7=B1=BB=E5=BF=85=E9=A1=BB=E5=9C=A8=E7=B1=BB=E4=B8=80= =E7=BA=A7=E5=AE=9A=E4=B9=89@Embeddable=E6=B3=A8=E8=A7=A3. + =E5=9C=A8=E7=89=B9=E5=AE=9A=E7=9A=84=E5=AE=9E=E4=BD=93=E7=9A=84=E5=85=B3= =E8=81=94=E5=B1=9E=E6=80=A7=E4=B8=8A=E4=BD=BF=E7=94=A8@Embedded=E5=92=8C + @AttributeOverride=E6=B3=A8=E8=A7=A3=E5=8F=AF=E4=BB= =A5=E8=A6=86=E7=9B=96=E8=AF=A5=E5=B1=9E=E6=80=A7=E5=AF=B9=E5=BA=94=E7=9A=84= =E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1=E7=9A=84=E5=88=97=E6=98=A0=E5= =B0=84=EF=BC=9A + + +(a)Entity +public class Person implements Serializable { + + // Persistent component using defaults + Address homeAddress; + + @Embedded + @AttributeOverrides( { + @AttributeOverride(name=3D"iso2", column =3D @Column(name=3D"b= ornIso2") ), + @AttributeOverride(name=3D"name", column =3D @Column(name=3D"b= ornCountryName") ) + } ) + Country bornIn; + ... +} + + + +(a)Embeddable +public class Address implements Serializable { + String city; + Country nationality; //no overriding here +} + + + +(a)Embeddable +public class Country implements Serializable { + private String iso2; + @Column(name=3D"countryName") private String name; + + public String getIso2() { return iso2; } + public void setIso2(String iso2) { this.iso2 =3D iso2; } + + = + public String getName() { return name; } + public void setName(String name) { this.name =3D name; } + ... +} + + + =E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1=E7=BB=A7=E6=89= =BF=E5=85=B6=E6=89=80=E5=B1=9E=E5=AE=9E=E4=BD=93=E4=B8=AD=E5=AE=9A=E4=B9=89= =E7=9A=84=E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B + (=E6=B3=A8=E6=84=8F:=E8=BF=99=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87=E4=BD= =BF=E7=94=A8Hibernate=E6=8F=90=E4=BE=9B=E7=9A=84@AccessType=E6=B3=A8=E8=A7=A3=E6=9D=A5=E8=A6=86=E7=9B=96=E5=8E=9F=E6=9C=89=E5=80=BC= )(=E8=AF=B7=E5=8F=82=E8=80=83 ). + + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E7=9A=84=E4=BE=8B=E5=AD=90=E4=B8= =AD,=E5=AE=9E=E4=BD=93bean Person =E6=9C=89=E4=B8=A4=E4= =B8=AA=E7=BB=84=E4=BB=B6=E5=B1=9E=E6=80=A7, + =E5=88=86=E5=88=AB=E6=98=AFhomeAddress=E5=92=8CbornIn. = + =E6=88=91=E4=BB=AC=E5=8F=AF=E4=BB=A5=E7=9C=8B=E5=88=B0homeAddre= ss =E5=B1=9E=E6=80=A7=E5=B9=B6=E6=B2=A1=E6=9C=89=E6=B3=A8=E8=A7= =A3. + =E4=BD=86=E6=98=AFHibernate=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8B=E5=85=B6= =E5=AF=B9=E5=BA=94=E7=9A=84Address=E7=B1=BB=E4=B8=AD=E7=9A=84@Embe= ddable=E6=B3=A8=E8=A7=A3, + =E5=B9=B6=E5=B0=86=E5=85=B6=E7=9C=8B=E4=BD=9C=E4=B8=80=E4=B8=AA=E6=8C=81= =E4=B9=85=E5=8C=96=E7=BB=84=E4=BB=B6.=E5=AF=B9=E4=BA=8ECountry=E4=B8=AD=E5= =B7=B2=E6=98=A0=E5=B0=84=E7=9A=84=E5=B1=9E=E6=80=A7, + =E5=88=99=E4=BD=BF=E7=94=A8@Embedded=E5=92=8C@AttributeOverride + =E6=B3=A8=E8=A7=A3=E6=9D=A5=E8=A6=86=E7=9B=96=E5=8E=9F= =E6=9D=A5=E6=98=A0=E5=B0=84=E7=9A=84=E5=88=97=E5=90=8D. + =E6=AD=A3=E5=A6=82=E4=BD=A0=E6=89=80=E7=9C=8B=E5=88=B0=E7=9A=84, Address=E5=AF=B9=E8=B1=A1=E4=B8=AD=E8=BF=98=E5=86=85=E5=B5=8C= =E4=BA=86Country=E5=AF=B9=E8=B1=A1, + =E8=BF=99=E9=87=8C=E5=92=8ChomeAddress=E4=B8=80=E6=A0= =B7=E4=BD=BF=E7=94=A8=E4=BA=86Hibernate=E5=92=8CEJB3=E8=87=AA=E5=8A=A8=E6= =A3=80=E6=B5=8B=E6=9C=BA=E5=88=B6. + =E7=9B=AE=E5=89=8DEJB3=E8=A7=84=E8=8C=83=E8=BF=98=E4=B8=8D=E6=94=AF=E6= =8C=81=E8=A6=86=E7=9B=96=E5=A4=9A=E5=B1=82=E5=B5=8C=E5=A5=97(=E5=8D=B3=E5= =B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1=E4=B8=AD=E8=BF=98=E5=8C=85=E6=8B= =AC=E5=85=B6=E4=BB=96=E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1)=E7=9A= =84=E5=88=97=E6=98=A0=E5=B0=84. + =E4=B8=8D=E8=BF=87Hibernate=E9=80=9A=E8=BF=87=E5=9C=A8=E8=A1=A8=E8=BE=BE= =E5=BC=8F=E4=B8=AD=E4=BD=BF=E7=94=A8"."=E7=AC=A6=E5=8F=B7=E8=A1=A8=E8=BE=BE= =E5=BC=8F=E6=8F=90=E4=BE=9B=E4=BA=86=E5=AF=B9=E6=AD=A4=E7=89=B9=E5=BE=81=E7= =9A=84=E6=94=AF=E6=8C=81. + + @Embedded + @AttributeOverrides( { + @AttributeOverride(name=3D"city", column =3D @Column(name=3D"f= ld_city") ), + @AttributeOverride(name=3D"nationality= .iso2", column =3D @Column(name=3D"nat_Iso2") ), + @AttributeOverride(name=3D"nationality= .name", column =3D @Column(name=3D"nat_CountryName") ) + //nationality columns in homeAddress are overridden + } ) + Address homeAddress; + Hibernate=E6=B3=A8=E8=A7=A3=E6=94=AF=E6=8C=81=E5=BE=88=E5=A4=9AEJB3=E8=A7= =84=E8=8C=83=E4=B8=AD=E6=B2=A1=E6=9C=89=E6=98=8E=E7=A1=AE=E5=AE=9A=E4=B9=89= =E7=9A=84=E7=89=B9=E6=80=A7. + =E4=BE=8B=E5=A6=82,=E5=8F=AF=E4=BB=A5=E5=9C=A8=E5=B5=8C=E5=85=A5=E5=BC=8F= =E5=AF=B9=E8=B1=A1=E4=B8=8A=E6=B7=BB=E5=8A=A0 @MappedSuperclass=E6=B3=A8=E8=A7=A3, + =E8=BF=99=E6=A0=B7=E5=8F=AF=E4=BB=A5=E5=B0=86=E5=85=B6=E7=88=B6=E7=B1=BB= =E7=9A=84=E5=B1=9E=E6=80=A7=E6=8C=81=E4=B9=85(=E8=AF=A6=E6=83=85=E8=AF=B7= =E6=9F=A5=E9=98=85@MappedSuperclass). + + Hibernate=E7=8E=B0=E5=9C=A8=E6=94=AF=E6=8C=81=E5=9C=A8=E5=B5= =8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1=E4=B8=AD=E4=BD=BF=E7=94=A8=E5=85=B3= =E8=81=94=E6=B3=A8=E8=A7=A3(=E5=A6=82@*ToOne=E5=92=8C@*ToMany). + =E8=80=8CEJB3=E8=A7=84=E8=8C=83=E5=B0=9A=E4=B8=8D=E6=94=AF=E6=8C=81=E8= =BF=99=E6=A0=B7=E7=9A=84=E7=94=A8=E6=B3=95=E3=80=82=E4=BD=A0=E5=8F=AF=E4=BB= =A5=E4=BD=BF=E7=94=A8 @AssociationOverride=E6=B3=A8=E8= =A7=A3=E6=9D=A5=E8=A6=86=E5=86=99=E5=85=B3=E8=81=94=E5=88=97. + + + =E5=9C=A8=E5=90=8C=E4=B8=80=E4=B8=AA=E5=AE=9E=E4=BD=93=E4=B8= =AD=E4=BD=BF=E7=94=A8=E4=B8=A4=E4=B8=AA=E5=90=8C=E7=B1=BB=E5=9E=8B=E7=9A=84= =E5=B5=8C=E5=85=A5=E5=AF=B9=E8=B1=A1, + =E5=85=B6=E9=BB=98=E8=AE=A4=E5=88=97=E5=90=8D=E6=98=AF=E6=97=A0=E6=95=88= =E7=9A=84:=E8=87=B3=E5=B0=91=E8=A6=81=E5=AF=B9=E5=85=B6=E4=B8=AD=E4=B8=80= =E4=B8=AA=E8=BF=9B=E8=A1=8C=E6=98=8E=E7=A1=AE=E5=A3=B0=E6=98=8E. + Hibernate=E5=9C=A8=E8=BF=99=E6=96=B9=E9=9D=A2=E8=B5=B0=E5=9C=A8=E4=BA=86= EJB3=E8=A7=84=E8=8C=83=E7=9A=84=E5=89=8D=E9=9D=A2, + Hibernate=E6=8F=90=E4=BE=9B=E4=BA=86NamingStrategy, =E5=9C=A8=E4=BD=BF=E7=94=A8Hibernate=E6=97=B6, = + =E9=80=9A=E8=BF=87NamingStrategy=E4=BD=A0=E5=8F= =AF=E4=BB=A5=E5=AF=B9=E9=BB=98=E8=AE=A4=E7=9A=84=E6=9C=BA=E5=88=B6=E8=BF=9B= =E8=A1=8C=E6=89=A9=E5=B1=95. = + DefaultComponentSafeNamingStrategy + =E5=9C=A8=E9=BB=98=E8=AE=A4=E7=9A=84EJB3NamingStrategy=E4=B8=8A=E8=BF=9B= =E8=A1=8C=E4=BA=86=E5=B0=8F=E5=B0=8F=E7=9A=84=E6=8F=90=E5=8D=87, + =E5=85=81=E8=AE=B8=E5=9C=A8=E5=90=8C=E4=B8=80=E5=AE=9E=E4=BD=93=E4=B8=AD= =E4=BD=BF=E7=94=A8=E4=B8=A4=E4=B8=AA=E5=90=8C=E7=B1=BB=E5=9E=8B=E7=9A=84=E5= =B5=8C=E5=85=A5=E5=AF=B9=E8=B1=A1=E8=80=8C=E6=97=A0=E9=A1=BB=E9=A2=9D=E5=A4= =96=E7=9A=84=E5=A3=B0=E6=98=8E. + + + + + =E6=97=A0=E6=B3=A8=E8=A7=A3=E4=B9=8B=E5=B1=9E=E6=80=A7=E7= =9A=84=E9=BB=98=E8=AE=A4=E5=80=BC + + =E5=A6=82=E6=9E=9C=E6=9F=90=E5=B1=9E=E6=80=A7=E6=B2=A1=E6=9C= =89=E6=B3=A8=E8=A7=A3,=E8=AF=A5=E5=B1=9E=E6=80=A7=E5=B0=86=E9=81=B5=E5=AE= =88=E4=B8=8B=E9=9D=A2=E7=9A=84=E8=A7=84=E5=88=99: + + + + =E5=A6=82=E6=9E=9C=E5=B1=9E=E6=80=A7=E4=B8=BA=E5=8D=95=E4=B8= =80=E7=B1=BB=E5=9E=8B,=E5=88=99=E6=98=A0=E5=B0=84=E4=B8=BA@Basic = + + + + =E5=90=A6=E5=88=99,=E5=A6=82=E6=9E=9C=E5=B1=9E=E6=80=A7=E5=AF= =B9=E5=BA=94=E7=9A=84=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89=E4=BA=86@Embeddab= le=E6=B3=A8=E8=A7=A3,=E5=88=99=E6=98=A0=E5=B0=84=E4=B8=BA@Embedded = + + + + =E5=90=A6=E5=88=99,=E5=A6=82=E6=9E=9C=E5=B1=9E=E6=80=A7=E5=AF= =B9=E5=BA=94=E7=9A=84=E7=B1=BB=E5=9E=8B=E5=AE=9E=E7=8E=B0=E4=BA=86Serializa= ble, + =E5=88=99=E5=B1=9E=E6=80=A7=E8=A2=AB=E6=98=A0=E5=B0=84=E4=B8=BA@Basic= =E5=B9=B6=E5=9C=A8=E4=B8=80=E4=B8=AA=E5=88=97=E4=B8=AD=E4=BF=9D=E5=AD=98=E8= =AF=A5=E5=AF=B9=E8=B1=A1=E7=9A=84serialized=E7=89=88=E6=9C=AC + + + + =E5=90=A6=E5=88=99,=E5=A6=82=E6=9E=9C=E8=AF=A5=E5=B1=9E=E6=80= =A7=E7=9A=84=E7=B1=BB=E5=9E=8B=E4=B8=BAjava.sql.Clob =E6=88=96 java.sql.Blo= b,=E5=88=99=E4=BD=9C=E4=B8=BA@Lob=E5=B9=B6=E6=98=A0=E5=B0=84=E5=88=B0=E9=80= =82=E5=BD=93=E7=9A=84LobType. + + + + + + + + =E6=98=A0=E5=B0=84=E4=B8=BB=E9=94=AE=E5=B1=9E=E6=80=A7 + + =E4=BD=BF=E7=94=A8@Id=E6=B3=A8=E8=A7=A3=E5= =8F=AF=E4=BB=A5=E5=B0=86=E5=AE=9E=E4=BD=93bean=E4=B8=AD=E7=9A=84=E6=9F=90= =E4=B8=AA=E5=B1=9E=E6=80=A7=E5=AE=9A=E4=B9=89=E4=B8=BA=E6=A0=87=E8=AF=86=E7= =AC=A6(identifier). + =E8=AF=A5=E5=B1=9E=E6=80=A7=E7=9A=84=E5=80=BC=E5=8F=AF=E4=BB=A5=E9=80= =9A=E8=BF=87=E5=BA=94=E7=94=A8=E8=87=AA=E8=BA=AB=E8=BF=9B=E8=A1=8C=E8=AE=BE= =E7=BD=AE, + =E4=B9=9F=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87Hiberante=E7=94=9F=E6=88= =90(=E6=8E=A8=E8=8D=90). + =E4=BD=BF=E7=94=A8 @GeneratedValue=E6=B3=A8=E8=A7=A3= =E5=8F=AF=E4=BB=A5=E5=AE=9A=E4=B9=89=E8=AF=A5=E6=A0=87=E8=AF=86=E7=AC=A6=E7= =9A=84=E7=94=9F=E6=88=90=E7=AD=96=E7=95=A5: + + + + + AUTO - =E5=8F=AF=E4=BB=A5=E6=98=AFidentity column=E7=B1=BB=E5= =9E=8B,=E6=88=96=E8=80=85sequence=E7=B1=BB=E5=9E=8B=E6=88=96=E8=80=85table= =E7=B1=BB=E5=9E=8B,=E5=8F=96=E5=86=B3=E4=BA=8E=E4=B8=8D=E5=90=8C=E7=9A=84= =E5=BA=95=E5=B1=82=E6=95=B0=E6=8D=AE=E5=BA=93. = + + + + TABLE - =E4=BD=BF=E7=94=A8=E8=A1=A8=E4=BF=9D=E5=AD=98id=E5=80= =BC + + + + IDENTITY - identity column + + + + SEQUENCE - sequence = + + + + =E5=92=8CEJB3=E8=A7=84=E8=8C=83=E7=9B=B8=E6=AF=94,Hibernate=E6= =8F=90=E4=BE=9B=E4=BA=86=E6=9B=B4=E5=A4=9A=E7=9A=84id=E7=94=9F=E6=88=90=E5= =99=A8.=E8=AF=A6=E6=83=85=E8=AF=B7=E6=9F=A5=E9=98=85 . + + + =E4=B8=8B=E9=9D=A2=E7=9A=84=E4=BE=8B=E5=AD=90=E5=B1=95=E7=A4= =BA=E4=BA=86=E4=BD=BF=E7=94=A8SEQ_STORE=E9=85=8D=E7=BD=AE=E7=9A=84sequence= =E7=94=9F=E6=88=90=E5=99=A8 + + +(a)Id @GeneratedValue(strategy=3DGenerationType.SEQUENCE, generator=3D"SEQ= _STORE") +public Integer getId() { ... } + + + =E4=B8=8B=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=BD= =BF=E7=94=A8=E7=9A=84=E6=98=AFidentity=E7=94=9F=E6=88=90=E5=99=A8 + + +(a)Id @GeneratedValue(strategy=3DGenerationType.IDENTITY) +public Long getId() { ... } + + + AUTO=E7=94=9F=E6=88=90=E5=99=A8=E9=80=82=E7= =94=A8=E4=BA=8E=E5=8F=AF=E7=A7=BB=E6=A4=8D=E7=9A=84=E5=BA=94=E7=94=A8(=E5= =9C=A8=E5=A4=9A=E4=B8=AADB=E9=97=B4=E5=88=87=E6=8D=A2). + =E5=A4=9A=E4=B8=AA@Id=E5=8F=AF=E4=BB=A5=E5=85=B1=E4= =BA=AB=E5=90=8C=E4=B8=80=E4=B8=AAidentifier=E7=94=9F=E6=88=90=E5=99=A8,=E5= =8F=AA=E8=A6=81=E6=8A=8Agenerator=E5=B1=9E=E6=80=A7=E8=AE=BE=E6=88=90=E7=9B= =B8=E5=90=8C=E7=9A=84=E5=80=BC=E5=B0=B1=E5=8F=AF=E4=BB=A5=E4=BA=86. + =E9=80=9A=E8=BF=87@SequenceGenerator =E5=92=8C@TableGenerator,=E4=BD=A0=E5=8F=AF=E4=BB=A5=E9=85=8D=E7=BD=AE= =E4=B8=8D=E5=90=8C=E7=9A=84identifier=E7=94=9F=E6=88=90=E5=99=A8. = + =E6=AF=8F=E4=B8=80=E4=B8=AAidentifier=E7=94=9F=E6=88=90=E5=99=A8=E9=83= =BD=E6=9C=89=E8=87=AA=E5=B7=B1=E7=9A=84=E9=80=82=E7=94=A8=E8=8C=83=E5=9B=B4= ,=E5=8F=AF=E4=BB=A5=E6=98=AF=E5=BA=94=E7=94=A8=E7=BA=A7(application level)= =E5=92=8C=E7=B1=BB=E4=B8=80=E7=BA=A7(class level). = + =E7=B1=BB=E4=B8=80=E7=BA=A7=E7=9A=84=E7=94=9F=E6=88=90=E5=99=A8=E5=9C= =A8=E5=A4=96=E9=83=A8=E6=98=AF=E4=B8=8D=E5=8F=AF=E8=A7=81=E7=9A=84, + =E8=80=8C=E4=B8=94=E7=B1=BB=E4=B8=80=E7=BA=A7=E7=9A=84=E7=94=9F=E6=88= =90=E5=99=A8=E5=8F=AF=E4=BB=A5=E8=A6=86=E7=9B=96=E5=BA=94=E7=94=A8=E7=BA=A7= =E7=9A=84=E7=94=9F=E6=88=90=E5=99=A8. + =E5=BA=94=E7=94=A8=E7=BA=A7=E7=9A=84=E7=94=9F=E6=88=90=E5=99=A8=E5=88= =99=E5=AE=9A=E4=B9=89=E5=9C=A8=E5=8C=85=E4=B8=80=E7=BA=A7(package level)(= =E5=A6=82package-info.java): + + +(a)javax.persistence.TableGenerator( + name=3D"EMP_GEN", + table=3D"GENERATOR_TABLE", + pkColumnName =3D "key", + valueColumnName =3D "hi" + pkColumnValue=3D"EMP", + allocationSize=3D20 +) +(a)javax.persistence.SequenceGenerator( + name=3D"SEQ_GEN", + sequenceName=3D"my_sequence" +) +package org.hibernate.test.metadata; + + + + =E5=A6=82=E6=9E=9C=E5=9C=A8org.hibernate.test.metadata=E5=8C=85=E4=B8=8B=E9=9D=A2=E7=9A=84 + package-info.java=E6=96=87=E4=BB=B6=E7=94=A8=E4= =BA=8E=E5=88=9D=E5=A7=8B=E5=8C=96EJB=E9=85=8D=E7=BD=AE, + =E9=82=A3=E4=B9=88=E8=AF=A5=E6=96=87=E4=BB=B6=E4=B8=AD=E5=AE=9A=E4=B9= =89=E7=9A=84 EMP_GEN + =E5=92=8CSEQ_GEN=E9=83=BD=E6=98=AF=E5=BA=94=E7=94=A8= =E7=BA=A7=E7=9A=84=E7=94=9F=E6=88=90=E5=99=A8. = + EMP_GEN=E5=AE=9A=E4=B9=89=E4=BA=86=E4=B8=80=E4=B8= =AA=E4=BD=BF=E7=94=A8hilo=E7=AE=97=E6=B3=95 + (max_lo=E4=B8=BA20)=E7=9A=84id=E7=94=9F=E6=88=90=E5=99=A8(=E8=AF=A5=E7= =94=9F=E6=88=90=E5=99=A8=E5=B0=86id=E7=9A=84=E4=BF=A1=E6=81=AF=E5=AD=98=E5= =9C=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84=E6=9F=90=E4=B8=AA=E8=A1=A8=E4=B8= =AD.). + id=E7=9A=84hi=E5=80=BC=E4=BF=9D=E5=AD=98=E5=9C=A8GENERATOR_TAB= LE=E4=B8=AD. + =E5=9C=A8=E8=AF=A5=E8=A1=A8=E4=B8=AD pkColumnName= "key"=E7=AD=89=E4=BB=B7=E4=BA=8E + pkColumnValue "EMP", + =E8=80=8CvalueColumnName "hi"= =E4=B8=AD=E5=AD=98=E5=82=A8=E7=9A=84=E6=98=AF=E4=B8=8B=E4=B8=80=E4=B8=AA=E8= =A6=81=E4=BD=BF=E7=94=A8=E7=9A=84=E6=9C=80=E5=A4=A7=E5=80=BC. + + + SEQ_GEN=E5=88=99=E5=AE=9A=E4=B9=89=E4=BA=86= =E4=B8=80=E4=B8=AAsequence =E7=94=9F=E6=88=90=E5=99=A8, + =E5=85=B6=E5=AF=B9=E5=BA=94=E7=9A=84sequence=E5=90=8D=E4=B8=BA my_sequence. + =E6=B3=A8=E6=84=8F=E7=9B=AE=E5=89=8DHibernate Annotations=E8=BF=98=E4= =B8=8D=E6=94=AF=E6=8C=81sequence =E7=94=9F=E6=88=90=E5=99=A8=E4=B8=AD=E7=9A= =84 + initialValue=E5=92=8C allocationSize=E5=8F=82=E6=95=B0. + + =E4=B8=8B=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E5=B1= =95=E7=A4=BA=E4=BA=86=E5=AE=9A=E4=B9=89=E5=9C=A8=E7=B1=BB=E8=8C=83=E5=9B=B4= (class scope)=E7=9A=84sequence=E7=94=9F=E6=88=90=E5=99=A8: + + +(a)Entity +(a)javax.persistence.SequenceGenerator( + name=3D"SEQ_STORE", + sequenceName=3D"my_sequence" +) +public class Store implements Serializable { + private Long id; + + @Id @GeneratedValue(strategy=3DGenerationType.SEQUENCE, generator=3D"S= EQ_STORE") + public Long getId() { return id; } +} + + + =E5=9C=A8=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8=AD,Store= =E7=B1=BB=E4=BD=BF=E7=94=A8=E5=90=8D=E4=B8=BAmy_sequence=E7=9A=84sequence,= =E5=B9=B6=E4=B8=94SEQ_STORE =E7=94=9F=E6=88=90=E5=99=A8=E5=AF=B9=E4=BA=8E= =E5=85=B6=E4=BB=96=E7=B1=BB=E6=98=AF=E4=B8=8D=E5=8F=AF=E8=A7=81=E7=9A=84. + =E6=B3=A8=E6=84=8F=E5=9C=A8org.hibernate.test.metadata.id=E5=8C=85= =E4=B8=8B=E7=9A=84=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81=E6=9C=89=E6=9B=B4=E5= =A4=9A=E6=BC=94=E7=A4=BAHibernate Annotations=E7=94=A8=E6=B3=95=E7=9A=84=E4= =BE=8B=E5=AD=90.. + + =E4=B8=8B=E9=9D=A2=E6=98=AF=E5=AE=9A=E4=B9=89=E7=BB=84=E5=90= =88=E4=B8=BB=E9=94=AE=E7=9A=84=E5=87=A0=E7=A7=8D=E8=AF=AD=E6=B3=95: + + + + =E5=B0=86=E7=BB=84=E4=BB=B6=E7=B1=BB=E6=B3=A8=E8=A7=A3=E4=B8=BA= @Embeddable,=E5=B9=B6=E5=B0=86=E7=BB=84=E4=BB=B6=E7=9A=84=E5=B1=9E=E6=80=A7= =E6=B3=A8=E8=A7=A3=E4=B8=BA@Id + + + + =E5=B0=86=E7=BB=84=E4=BB=B6=E7=9A=84=E5=B1=9E=E6=80=A7=E6=B3=A8= =E8=A7=A3=E4=B8=BA@EmbeddedId + + + + =E5=B0=86=E7=B1=BB=E6=B3=A8=E8=A7=A3=E4=B8=BA@IdClass,=E5=B9=B6= =E5=B0=86=E8=AF=A5=E5=AE=9E=E4=BD=93=E4=B8=AD=E6=89=80=E6=9C=89=E5=B1=9E=E4= =BA=8E=E4=B8=BB=E9=94=AE=E7=9A=84=E5=B1=9E=E6=80=A7=E9=83=BD=E6=B3=A8=E8=A7= =A3=E4=B8=BA@Id = + + + + =E5=AF=B9=E4=BA=8EEJB2=E7=9A=84=E5=BC=80=E5=8F=91=E4=BA=BA=E5= =91=98=E6=9D=A5=E8=AF=B4 @IdClass=E6=98=AF=E5=BE=88=E5= =B8=B8=E8=A7=81=E7=9A=84, + =E4=BD=86=E6=98=AF=E5=AF=B9=E4=BA=8EHibernate=E7=9A=84=E7=94=A8=E6=88= =B7=E6=9D=A5=E8=AF=B4=E5=B0=B1=E6=98=AF=E4=B8=80=E4=B8=AA=E5=B4=AD=E6=96=B0= =E7=9A=84=E7=94=A8=E6=B3=95. + =E7=BB=84=E5=90=88=E4=B8=BB=E9=94=AE=E7=B1=BB=E5=AF=B9=E5=BA=94=E4=BA= =86=E4=B8=80=E4=B8=AA=E5=AE=9E=E4=BD=93=E7=B1=BB=E4=B8=AD=E7=9A=84=E5=A4=9A= =E4=B8=AA=E5=AD=97=E6=AE=B5=E6=88=96=E5=B1=9E=E6=80=A7, + =E8=80=8C=E4=B8=94=E4=B8=BB=E9=94=AE=E7=B1=BB=E4=B8=AD=E7=94=A8=E4=BA= =8E=E5=AE=9A=E4=B9=89=E4=B8=BB=E9=94=AE=E7=9A=84=E5=AD=97=E6=AE=B5=E6=88=96= =E5=B1=9E=E6=80=A7=E5=92=8C + =E5=AE=9E=E4=BD=93=E7=B1=BB=E4=B8=AD=E5=AF=B9=E5=BA=94=E7=9A=84=E5=AD= =97=E6=AE=B5=E6=88=96=E5=B1=9E=E6=80=A7=E5=9C=A8=E7=B1=BB=E5=9E=8B=E4=B8=8A= =E5=BF=85=E9=A1=BB=E4=B8=80=E8=87=B4.=E4=B8=8B=E9=9D=A2=E6=88=91=E4=BB=AC= =E7=9C=8B=E4=B8=80=E4=B8=AA=E4=BE=8B=E5=AD=90: + + @Entity +@IdClass(FootballerPk.class) +public class Footballer { + //part of the id key + @Id public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + //part of the id key + @Id public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + public String getClub() { + return club; + } + + public void setClub(String club) { + this.club =3D club; + } + + //appropriate equals() and hashCode() implementation +} + +(a)Embeddable +public class FootballerPk implements Serializable { + //same name and type as in Footballer + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + //same name and type as in Footballer + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + //appropriate equals() and hashCode() implementation +} + + + + =E5=A6=82=E4=B8=8A, @IdClass=E6=8C=87=E5=90= =91=E5=AF=B9=E5=BA=94=E7=9A=84=E4=B8=BB=E9=94=AE=E7=B1=BB. + + Hibernate=E6=94=AF=E6=8C=81=E5=9C=A8=E7=BB=84=E5=90=88=E6=A0=87= =E8=AF=86=E7=AC=A6=E4=B8=AD=E5=AE=9A=E4=B9=89=E5=85=B3=E8=81=94(=E5=B0=B1= =E5=83=8F=E4=BD=BF=E7=94=A8=E6=99=AE=E9=80=9A=E7=9A=84=E6=B3=A8=E8=A7=A3=E4= =B8=80=E6=A0=B7),=E8=80=8CEJB3=E8=A7=84=E8=8C=83=E5=B9=B6=E4=B8=8D=E6=94=AF= =E6=8C=81=E6=AD=A4=E7=B1=BB=E7=94=A8=E6=B3=95. + + + @Entity +(a)AssociationOverride( name=3D"id.channel", joinColumns =3D @JoinColumn(n= ame=3D"chan_id") ) +public class TvMagazin { + @EmbeddedId public TvMagazinPk id; + @Temporal(TemporalType.TIME) Date time; +} + +(a)Embeddable +public class TvMagazinPk implements Serializable { + @ManyToOne + public Channel channel; + public String name; + @ManyToOne + public Presenter presenter; +} + + + + + + =E6=98=A0=E5=B0=84=E7=BB=A7=E6=89=BF=E5=85=B3=E7=B3=BB + + EJB3=E6=94=AF=E6=8C=81=E4=B8=89=E7=A7=8D=E7=B1=BB=E5=9E=8B=E7= =9A=84=E7=BB=A7=E6=89=BF=E6=98=A0=E5=B0=84: + + + + =E6=AF=8F=E4=B8=AA=E7=B1=BB=E4=B8=80=E5=BC=A0=E8=A1=A8(Table p= er class)=E7=AD=96=E7=95=A5: =E5=9C=A8Hibernate=E4=B8=AD=E5=AF=B9=E5=BA=94&= lt;union-class>=E5=85=83=E7=B4=A0: + + + + =E6=AF=8F=E4=B8=AA=E7=B1=BB=E5=B1=82=E6=AC=A1=E7=BB=93=E6=9E=84=E4=B8= =80=E5=BC=A0=E8=A1=A8(Single table per class hierarchy)=E7=AD=96=E7=95=A5:= =E5=9C=A8Hibernate=E4=B8=AD=E5=AF=B9=E5=BA=94<subclass>=E5=85=83=E7= =B4=A0 + + + + =E8=BF=9E=E6=8E=A5=E7=9A=84=E5=AD=90=E7=B1=BB(Joined subclasses)=E7= =AD=96=E7=95=A5:=E5=9C=A8Hibernate=E4=B8=AD=E5=AF=B9=E5=BA=94 <joined-su= bclass>=E5=85=83=E7=B4=A0 + + + + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E7=94=A8 @Inheritance= =E6=B3=A8=E8=A7=A3=E6=9D=A5=E5=AE=9A=E4=B9=89=E6=89=80=E9=80=89=E6=8B=A9=E7= =9A=84=E7=AD=96=E7=95=A5. + =E8=BF=99=E4=B8=AA=E6=B3=A8=E8=A7=A3=E9=9C=80=E8=A6=81=E5=9C=A8=E6= =AF=8F=E4=B8=AA=E7=B1=BB=E5=B1=82=E6=AC=A1=E7=BB=93=E6=9E=84(class hierarch= y) =E6=9C=80=E9=A1=B6=E7=AB=AF=E7=9A=84=E5=AE=9E=E4=BD=93=E7=B1=BB=E4=B8=8A= =E4=BD=BF=E7=94=A8. + + + + =E7=9B=AE=E5=89=8D=E8=BF=98=E4=B8=8D=E6=94=AF=E6=8C=81=E5=9C= =A8=E6=8E=A5=E5=8F=A3=E4=B8=8A=E8=BF=9B=E8=A1=8C=E6=B3=A8=E8=A7=A3. + + + + =E6=AF=8F=E4=B8=AA=E7=B1=BB=E4=B8=80=E5=BC=A0=E8=A1=A8</tit= le> + + <para> + =E8=BF=99=E7=A7=8D=E7=AD=96=E7=95=A5=E6=9C=89=E5=BE=88=E5=A4=9A=E7=BC=BA= =E7=82=B9(=E4=BE=8B=E5=A6=82:=E5=A4=9A=E6=80=81=E6=9F=A5=E8=AF=A2=E5=92=8C= =E5=85=B3=E8=81=94),EJB3=E8=A7=84=E8=8C=83, Hibernate=E5=8F=82=E8=80=83=E6= =89=8B=E5=86=8C, = + Hibernate in Action,=E4=BB=A5=E5=8F=8A=E5=85=B6=E4=BB=96=E8=AE=B8=E5=A4= =9A=E5=9C=B0=E6=96=B9=E9=83=BD=E5=AF=B9=E6=AD=A4=E8=BF=9B=E8=A1=8C=E4=BA=86= =E6=8F=8F=E8=BF=B0=E5=92=8C=E8=A7=A3=E9=87=8A. + Hibernate=E4=BD=BF=E7=94=A8<literal>SQL UNION</literal>=E6=9F=A5=E8=AF= =A2=E6=9D=A5=E5=AE=9E=E7=8E=B0=E8=BF=99=E7=A7=8D=E7=AD=96=E7=95=A5. + =E9=80=9A=E5=B8=B8=E4=BD=BF=E7=94=A8=E5=9C=BA=E5=90=88=E6=98=AF=E5=9C=A8= =E4=B8=80=E4=B8=AA=E7=BB=A7=E6=89=BF=E5=B1=82=E6=AC=A1=E7=BB=93=E6=9E=84=E7= =9A=84=E9=A1=B6=E7=AB=AF:</para> + + <programlisting> +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.TABLE_PER_CLASS) +public class Flight implements Serializable { + </programlisting> + + <para> + =E8=BF=99=E7=A7=8D=E7=AD=96=E7=95=A5=E6=94=AF=E6=8C=81=E5=8F=8C=E5=90=91= =E7=9A=84=E4=B8=80=E5=AF=B9=E5=A4=9A=E5=85=B3=E8=81=94. + =E8=BF=99=E9=87=8C=E4=B8=8D=E6=94=AF=E6=8C=81<literal>IDENTITY</literal>= =E7=94=9F=E6=88=90=E5=99=A8=E7=AD=96=E7=95=A5,=E5=9B=A0=E4=B8=BAid=E5=BF=85= =E9=A1=BB=E5=9C=A8=E5=A4=9A=E4=B8=AA=E8=A1=A8=E9=97=B4=E5=85=B1=E4=BA=AB. + =E5=BD=93=E7=84=B6,=E4=B8=80=E6=97=A6=E4=BD=BF=E7=94=A8=E8=BF=99=E7=A7= =8D=E7=AD=96=E7=95=A5=E5=B0=B1=E6=84=8F=E5=91=B3=E7=9D=80=E4=BD=A0=E4=B8=8D= =E8=83=BD=E4=BD=BF=E7=94=A8 + <literal>AUTO </literal>=E7=94=9F=E6=88=90=E5=99=A8=E5=92=8C<literal>IDE= NTITY</literal>=E7=94=9F=E6=88=90=E5=99=A8. + </para> + </sect3> + + <sect3> + <title>=E6=AF=8F=E4=B8=AA=E7=B1=BB=E5=B1=82=E6=AC=A1=E7=BB=93=E6= =9E=84=E4=B8=80=E5=BC=A0=E8=A1=A8 + + =E6=95=B4=E4=B8=AA=E7=BB=A7=E6=89=BF=E5=B1=82=E6=AC=A1=E7=BB= =93=E6=9E=84=E4=B8=AD=E7=9A=84=E7=88=B6=E7=B1=BB=E5=92=8C=E5=AD=90=E7=B1=BB= =E7=9A=84=E6=89=80=E6=9C=89=E5=B1=9E=E6=80=A7=E9=83=BD=E6=98=A0=E5=B0=84=E5= =88=B0=E5=90=8C=E4=B8=80=E4=B8=AA=E8=A1=A8=E4=B8=AD, + =E4=BB=96=E4=BB=AC=E7=9A=84=E5=AE=9E=E4=BE=8B=E9=80=9A=E8=BF=87=E4=B8=80= =E4=B8=AA=E8=BE=A8=E5=88=AB=E7=AC=A6(discriminator)=E5=88=97=E6=9D=A5=E5=8C= =BA=E5=88=86.: + + +(a)Entity +(a)Inheritance(strategy=3DInheritanceType.SINGLE_TABLE) +(a)DiscriminatorColumn( + name=3D"planetype", + discriminatorType=3DDiscriminatorType.STRING +) +(a)DiscriminatorValue("Plane") +public class Plane { ... } + +(a)Entity +(a)DiscriminatorValue("A320") +public class A320 extends Plane { ... } + + + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD= =90=E4=B8=AD,Plane=E6=98=AF=E7=88=B6=E7=B1=BB,=E5=9C= =A8=E8=BF=99=E4=B8=AA=E7=B1=BB=E9=87=8C=E9=9D=A2=E5=B0=86=E7=BB=A7=E6=89=BF= =E7=AD=96=E7=95=A5=E5=AE=9A=E4=B9=89=E4=B8=BA + InheritanceType.SINGLE_TABLE,=E5=B9=B6=E9=80=9A=E8=BF= =87 + @DiscriminatorColumn=E6=B3=A8=E8=A7=A3=E5=AE=9A=E4=B9= =89=E4=BA=86=E8=BE=A8=E5=88=AB=E7=AC=A6=E5=88=97(=E8=BF=98=E5=8F=AF=E4=BB= =A5=E5=AE=9A=E4=B9=89=E8=BE=A8=E5=88=AB=E7=AC=A6=E7=9A=84=E7=B1=BB=E5=9E=8B= ). + =E6=9C=80=E5=90=8E,=E5=AF=B9=E4=BA=8E=E7=BB=A7=E6=89=BF=E5=B1=82=E6=AC= =A1=E7=BB=93=E6=9E=84=E4=B8=AD=E7=9A=84=E6=AF=8F=E4=B8=AA=E7=B1=BB,@DiscriminatorValue=E6=B3=A8=E8=A7=A3=E6=8C=87=E5=AE=9A=E4=BA=86= =E7=94=A8=E6=9D=A5=E8=BE=A8=E5=88=AB=E8=AF=A5=E7=B1=BB=E7=9A=84=E5=80=BC. + =E8=BE=A8=E5=88=AB=E7=AC=A6=E5=88=97=E7=9A=84=E5=90=8D=E5=AD=97=E9=BB=98= =E8=AE=A4=E4=B8=BA DTYPE,=E5=85=B6=E9=BB=98=E8=AE=A4=E5= =80=BC=E4=B8=BA=E5=AE=9E=E4=BD=93=E5=90=8D(=E5=9C=A8@Entity.name=E4=B8=AD=E5=AE=9A=E4=B9=89)=EF=BC=8C=E5=85=B6=E7=B1=BB=E5=9E=8B + =E4=B8=BADiscriminatorType.STRING. + A320=E6=98=AF=E5=AD=90=E7=B1=BB,=E5=A6=82=E6=9E= =9C=E4=B8=8D=E6=83=B3=E4=BD=BF=E7=94=A8=E9=BB=98=E8=AE=A4=E7=9A=84=E8=BE=A8= =E5=88=AB=E7=AC=A6,=E5=8F=AA=E9=9C=80=E8=A6=81=E6=8C=87=E5=AE=9A=E7=9B=B8= =E5=BA=94=E7=9A=84=E5=80=BC=E5=8D=B3=E5=8F=AF. + =E5=85=B6=E4=BB=96=E7=9A=84=E5=A6=82=E7=BB=A7=E6=89=BF=E7=AD=96=E7=95=A5= ,=E8=BE=A8=E5=88=AB=E6=A0=87=E5=BF=97=E5=AD=97=E6=AE=B5=E7=9A=84=E7=B1=BB= =E5=9E=8B=E9=83=BD=E6=98=AF=E8=87=AA=E5=8A=A8=E8=AE=BE=E5=AE=9A=E7=9A=84. + + @Inheritance =E5=92=8C + @DiscriminatorColumn =E6=B3=A8=E8=A7=A3=E5=8F= =AA=E8=83=BD=E7=94=A8=E4=BA=8E=E5=AE=9E=E4=BD=93=E5=B1=82=E6=AC=A1=E7=BB=93= =E6=9E=84=E7=9A=84=E9=A1=B6=E7=AB=AF. + + + + + =E8=BF=9E=E6=8E=A5=E7=9A=84=E5=AD=90=E7=B1=BB + + =E5=BD=93=E6=AF=8F=E4=B8=AA=E5=AD=90=E7=B1=BB=E6=98=A0=E5=B0= =84=E5=88=B0=E4=B8=80=E4=B8=AA=E8=A1=A8=E6=97=B6, @PrimaryKeyJoin= Column + =E5=92=8C@PrimaryKeyJoinColumns + =E6=B3=A8=E8=A7=A3=E5=AE=9A=E4=B9=89=E4=BA=86=E6=AF=8F=E4=B8=AA=E5=AD=90= =E7=B1=BB=E8=A1=A8=E5=85=B3=E8=81=94=E5=88=B0=E7=88=B6=E7=B1=BB=E8=A1=A8=E7= =9A=84=E4=B8=BB=E9=94=AE: + + +(a)Entity +(a)Inheritance(strategy=3DInheritanceType.JOINED) +public class Boat implements Serializable { ... } + +(a)Entity +public class Ferry extends Boat { ... } + +(a)Entity +(a)PrimaryKeyJoinColumn(name=3D"BOAT_ID") +public class AmericaCupClass extends Boat { ... } + + + =E4=BB=A5=E4=B8=8A=E6=89=80=E6=9C=89=E5=AE=9E=E4=BD=93=E9=83= =BD=E4=BD=BF=E7=94=A8=E4=BA=86JOINED=E7=AD=96=E7=95=A5, = + Ferry=E8=A1=A8=E5=92=8CBoat=E8=A1= =A8=E4=BD=BF=E7=94=A8=E5=90=8C=E5=90=8D=E7=9A=84=E4=B8=BB=E9=94=AE. + =E8=80=8CAmericaCupClass=E8=A1=A8=E5=92=8CBo= at=E8=A1=A8=E4=BD=BF=E7=94=A8=E4=BA=86=E6=9D=A1=E4=BB=B6 + Boat.id =3D AmericaCupClass.BOAT_ID=E8=BF=9B=E8=A1=8C=E5=85= =B3=E8=81=94. + + + + + =E4=BB=8E=E7=88=B6=E7=B1=BB=E7=BB=A7=E6=89=BF=E7=9A=84=E5= =B1=9E=E6=80=A7 + + =E6=9C=89=E6=97=B6=E5=80=99=E9=80=9A=E8=BF=87=E4=B8=80=E4=B8= =AA(=E6=8A=80=E6=9C=AF=E4=B8=8A=E6=88=96=E4=B8=9A=E5=8A=A1=E4=B8=8A)=E7=88= =B6=E7=B1=BB=E5=85=B1=E4=BA=AB=E4=B8=80=E4=BA=9B=E5=85=AC=E5=85=B1=E5=B1=9E= =E6=80=A7=E6=98=AF=E5=BE=88=E6=9C=89=E7=94=A8=E7=9A=84, + =E5=90=8C=E6=97=B6=E8=BF=98=E4=B8=8D=E7=94=A8=E5=B0=86=E8=AF=A5=E7=88=B6= =E7=B1=BB=E4=BD=9C=E4=B8=BA=E6=98=A0=E5=B0=84=E7=9A=84=E5=AE=9E=E4=BD=93(= =E4=B9=9F=E5=B0=B1=E6=98=AF=E8=AF=A5=E5=AE=9E=E4=BD=93=E6=B2=A1=E6=9C=89=E5= =AF=B9=E5=BA=94=E7=9A=84=E8=A1=A8). + =E8=BF=99=E4=B8=AA=E6=97=B6=E5=80=99=E4=BD=A0=E9=9C=80=E8=A6=81=E4=BD=BF= =E7=94=A8@MappedSuperclass=E6=B3=A8=E8=A7=A3=E6=9D=A5=E8= =BF=9B=E8=A1=8C=E6=98=A0=E5=B0=84. + + @MappedSuperclass +public class BaseEntity { + @Basic + @Temporal(TemporalType.TIMESTAMP) + public Date getLastUpdate() { ... } + public String getLastUpdater() { ... } + ... +} + +(a)Entity class Order extends BaseEntity { + @Id public Integer getId() { ... } + ... +} + + =E5=9C=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=AD,=E4=B8=8A=E9= =9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8=AD=E7=9A=84=E7=BB=A7=E6=89= =BF=E7=9A=84=E5=B1=82=E6=AC=A1=E7=BB=93=E6=9E=84=E6=9C=80=E7=BB=88=E4=BB=A5= Order=E8=A1=A8=E7=9A=84=E5=BD=A2=E5=BC=8F=E5=87=BA=E7=8E= =B0, + =E8=AF=A5=E8=A1=A8=E6=8B=A5=E6=9C=89id, last= Update =E5=92=8C + lastUpdater=E4=B8=89=E4=B8=AA=E5=88=97.=E7=88=B6=E7= =B1=BB=E4=B8=AD=E7=9A=84=E5=B1=9E=E6=80=A7=E6=98=A0=E5=B0=84=E5=B0=86=E5=A4= =8D=E5=88=B6=E5=88=B0=E5=85=B6=E5=AD=90=E7=B1=BB=E5=AE=9E=E4=BD=93. + =E6=B3=A8=E6=84=8F=E8=BF=99=E7=A7=8D=E6=83=85=E5=86=B5=E4=B8=8B=E7=9A=84= =E7=88=B6=E7=B1=BB=E4=B8=8D=E5=86=8D=E5=A4=84=E5=9C=A8=E7=BB=A7=E6=89=BF=E5= =B1=82=E6=AC=A1=E7=BB=93=E6=9E=84=E7=9A=84=E9=A1=B6=E7=AB=AF. + + + + =E6=B3=A8=E6=84=8F,=E6=B2=A1=E6=9C=89=E6=B3=A8=E8=A7=A3=E4= =B8=BA@MappedSuperclass=E7=9A=84=E7=88=B6=E7=B1=BB=E4=B8= =AD=E7=9A=84=E5=B1=9E=E6=80=A7=E5=B0=86=E8=A2=AB=E5=BF=BD=E7=95=A5. + + + + + =E9=99=A4=E9=9D=9E=E6=98=BE=E5=BC=8F=E4=BD=BF=E7=94=A8Hibe= rnate annotation=E4=B8=AD=E7=9A=84@AccessType=E6=B3=A8= =E8=A7=A3, + =E5=90=A6=E5=88=99=E5=B0=86=E4=BB=8E=E7=BB=A7=E6=89=BF=E5=B1=82=E6=AC= =A1=E7=BB=93=E6=9E=84=E7=9A=84=E6=A0=B9=E5=AE=9E=E4=BD=93=E4=B8=AD=E7=BB=A7= =E6=89=BF=E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B(=E5=8C=85=E6=8B=AC=E5=AD=97= =E6=AE=B5=E6=88=96=E6=96=B9=E6=B3=95) + + + + + =E8=BF=99=E5=AF=B9=E4=BA=8E@Embeddable= =E5=AF=B9=E8=B1=A1=E7=9A=84=E7=88=B6=E7=B1=BB=E4=B8=AD=E7=9A=84=E5=B1=9E=E6= =80=A7=E6=8C=81=E4=B9=85=E5=8C=96=E5=90=8C=E6=A0=B7=E6=9C=89=E6=95=88. + =E5=8F=AA=E9=9C=80=E8=A6=81=E4=BD=BF=E7=94=A8@MappedSuperclas= s=E6=B3=A8=E8=A7=A3=E5=8D=B3=E5=8F=AF + (=E8=99=BD=E7=84=B6=E8=BF=99=E7=A7=8D=E6=96=B9=E5=BC=8F=E4=B8=8D=E4=BC= =9A=E7=BA=B3=E5=85=A5EJB3=E6=A0=87=E5=87=86) + + + + + + =E5=8F=AF=E4=BB=A5=E5=B0=86=E5=A4=84=E5=9C=A8=E5=9C=A8=E6= =98=A0=E5=B0=84=E7=BB=A7=E6=89=BF=E5=B1=82=E6=AC=A1=E7=BB=93=E6=9E=84=E7=9A= =84=E4=B8=AD=E9=97=B4=E4=BD=8D=E7=BD=AE=E7=9A=84=E7=B1=BB=E6=B3=A8=E8=A7=A3= =E4=B8=BA@MappedSuperclass. + + + + + =E5=9C=A8=E7=BB=A7=E6=89=BF=E5=B1=82=E6=AC=A1=E7=BB=93=E6= =9E=84=E4=B8=AD=E4=BB=BB=E4=BD=95=E6=B2=A1=E6=9C=89=E8=A2=AB=E6=B3=A8=E8=A7= =A3=E4=B8=BA@MappedSuperclass + =E6=88=96@Entity=E7=9A=84=E7=B1=BB=E9=83=BD=E5=B0= =86=E8=A2=AB=E5=BF=BD=E7=95=A5. + + + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87 @AttributeOverrid= e=E6=B3=A8=E8=A7=A3=E8=A6=86=E7=9B=96=E5=AE=9E=E4=BD=93=E7=88=B6= =E7=B1=BB=E4=B8=AD=E7=9A=84=E5=AE=9A=E4=B9=89=E7=9A=84=E5=88=97. + =E8=BF=99=E4=B8=AA=E6=B3=A8=E8=A7=A3=E5=8F=AA=E8=83=BD=E5=9C=A8=E7=BB=A7= =E6=89=BF=E5=B1=82=E6=AC=A1=E7=BB=93=E6=9E=84=E7=9A=84=E9=A1=B6=E7=AB=AF=E4= =BD=BF=E7=94=A8. + + @MappedSuperclass +public class FlyingObject implements Serializable { + + public int getAltitude() { + return altitude; + } + + @Transient + public int getMetricAltitude() { + return metricAltitude; + } + + @ManyToOne + public PropulsionType getPropulsion() { + return metricAltitude; + } + ... +} + +(a)Entity +(a)AttributeOverride( name=3D"altitude", column =3D @Column(name=3D"fld_al= titude") ) +(a)AssociationOverride( name=3D"propulsion", joinColumns =3D @JoinColumn(n= ame=3D"fld_propulsion_fk") ) +public class Plane extends FlyingObject { + ... +} + + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4= =B8=AD,altitude=E5=B1=9E=E6=80=A7=E7=9A=84=E5=80=BC=E6= =9C=80=E7=BB=88=E5=B0=86=E6=8C=81=E4=B9=85=E5=8C=96=E5=88=B0Plane<= /literal> + =E8=A1=A8=E7=9A=84fld_altitude=E5=88=97.=E8=80=8C=E5= =90=8D=E4=B8=BApropulsion=E7=9A=84=E5=85=B3=E8=81=94=E5=88=99=E4=BF=9D=E5= =AD=98=E5=9C=A8fld_propulsion_fk=E5=A4=96=E9=97=B4=E5=88= =97. + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E4=B8=BA@Entity=E5=92=8C@MappedSuperclass=E6=B3=A8=E8=A7=A3=E7=9A=84= =E7=B1=BB + =E4=BB=A5=E5=8F=8A=E9=82=A3=E4=BA=9B=E5=AF=B9=E8=B1=A1=E4=B8=BA= @Embeddable=E7=9A=84=E5=B1=9E=E6=80=A7=E5=AE=9A=E4=B9=89 + @AttributeOverride=E5=92=8C@AssociationOverr= ide. + + + + + + =E6=98=A0=E5=B0=84=E5=AE=9E=E4=BD=93Bean=E7=9A=84=E5=85=B3=E8= =81=94=E5=85=B3=E7=B3=BB + + + =E4=B8=80=E5=AF=B9=E4=B8=80(One-to-one) + + =E4=BD=BF=E7=94=A8@OneToOne=E6=B3=A8=E8=A7=A3= =E5=8F=AF=E4=BB=A5=E5=BB=BA=E7=AB=8B=E5=AE=9E=E4=BD=93bean=E4=B9=8B=E9=97= =B4=E7=9A=84=E4=B8=80=E5=AF=B9=E4=B8=80=E7=9A=84=E5=85=B3=E8=81=94. + =E4=B8=80=E5=AF=B9=E4=B8=80=E5=85=B3=E8=81=94=E6=9C=89=E4=B8=89=E7=A7=8D= =E6=83=85=E5=86=B5=EF=BC=9A + =E4=B8=80=E6=98=AF=E5=85=B3=E8=81=94=E7=9A=84=E5=AE=9E=E4=BD=93=E9=83=BD= =E5=85=B1=E4=BA=AB=E5=90=8C=E6=A0=B7=E7=9A=84=E4=B8=BB=E9=94=AE, + =E4=BA=8C=E6=98=AF=E5=85=B6=E4=B8=AD=E4=B8=80=E4=B8=AA=E5=AE=9E=E4=BD=93= =E9=80=9A=E8=BF=87=E5=A4=96=E9=94=AE=E5=85=B3=E8=81=94=E5=88=B0=E5=8F=A6=E4= =B8=80=E4=B8=AA=E5=AE=9E=E4=BD=93=E7=9A=84=E4=B8=BB=E9=94=AE + (=E6=B3=A8=E6=84=8F=E8=A6=81=E6=A8=A1=E6=8B=9F=E4=B8=80=E5=AF=B9=E4=B8= =80=E5=85=B3=E8=81=94=E5=BF=85=E9=A1=BB=E5=9C=A8=E5=A4=96=E9=94=AE=E5=88=97= =E4=B8=8A=E6=B7=BB=E5=8A=A0=E5=94=AF=E4=B8=80=E7=BA=A6=E6=9D=9F). + =E4=B8=89=E6=98=AF=E9=80=9A=E8=BF=87=E5=85=B3=E8=81=94=E8=A1=A8=E6=9D=A5= =E4=BF=9D=E5=AD=98=E4=B8=A4=E4=B8=AA=E5=AE=9E=E4=BD=93=E4=B9=8B=E9=97=B4=E7= =9A=84=E8=BF=9E=E6=8E=A5=E5=85=B3=E7=B3=BB + (=E6=B3=A8=E6=84=8F=E8=A6=81=E6=A8=A1=E6=8B=9F=E4=B8=80=E5=AF=B9=E4=B8= =80=E5=85=B3=E8=81=94=E5=BF=85=E9=A1=BB=E5=9C=A8=E6=AF=8F=E4=B8=80=E4=B8=AA= =E5=A4=96=E9=94=AE=E4=B8=8A=E6=B7=BB=E5=8A=A0=E5=94=AF=E4=B8=80=E7=BA=A6=E6= =9D=9F). + + =E9=A6=96=E5=85=88,=E6=88=91=E4=BB=AC=E9=80=9A=E8=BF=87=E5= =85=B1=E4=BA=AB=E4=B8=BB=E9=94=AE=E6=9D=A5=E8=BF=9B=E8=A1=8C=E4=B8=80=E5=AF= =B9=E4=B8=80=E5=85=B3=E8=81=94=E6=98=A0=E5=B0=84: + + +(a)Entity +public class Body { + @Id + public Long getId() { return id; } + + @OneToOne(cascade =3D CascadeType.ALL) + @PrimaryKeyJoinColumn + public Heart getHeart() { + return heart; + } + ... +} + + + +(a)Entity +public class Heart { + @Id + public Long getId() { ...} +} + + + =E4=B8=8A=E9=9D=A2=E7=9A=84=E4=BE=8B=E5=AD=90=E9=80=9A=E8=BF=87=E4= =BD=BF=E7=94=A8=E6=B3=A8=E8=A7=A3@PrimaryKeyJoinColumn= =E5=AE=9A=E4=B9=89=E4=BA=86=E4=B8=80=E5=AF=B9=E4=B8=80=E5=85=B3=E8=81=94. + + =E4=B8=8B=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=BD=BF=E7= =94=A8=E5=A4=96=E9=94=AE=E5=88=97=E8=BF=9B=E8=A1=8C=E5=AE=9E=E4=BD=93=E7=9A= =84=E5=85=B3=E8=81=94. + + +(a)Entity +public class Customer implements Serializable { + @OneToOne(cascade =3D CascadeType.ALL) + @JoinColumn(name=3D"passport_fk") + public Passport getPassport() { + ... + } + +(a)Entity +public class Passport implements Serializable { + @OneToOne(mappedBy =3D "passport") + public Customer getOwner() { + ... +} + + + =E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8= =AD,Customer =E9=80=9A=E8=BF=87Customer + =E8=A1=A8=E4=B8=AD=E5=90=8D=E4=B8=BA=E7=9A=84passport_fk =E5=A4=96=E9=94=AE=E5=88=97=E5=92=8C Passport=E5= =85=B3=E8=81=94. + @JoinColumn=E6=B3=A8=E8=A7=A3=E5=AE=9A=E4=B9=89=E4=BA= =86=E8=81=94=E6=8E=A5=E5=88=97(join column). + =E8=AF=A5=E6=B3=A8=E8=A7=A3=E5=92=8C@Column=E6=B3=A8= =E8=A7=A3=E6=9C=89=E7=82=B9=E7=B1=BB=E4=BC=BC, + =E4=BD=86=E6=98=AF=E5=A4=9A=E4=BA=86=E4=B8=80=E4=B8=AA=E5=90=8D=E4=B8=BA= referencedColumnName=E7=9A=84=E5=8F=82=E6=95=B0. + =E8=AF=A5=E5=8F=82=E6=95=B0=E5=AE=9A=E4=B9=89=E4=BA=86=E6=89=80=E5=85=B3= =E8=81=94=E7=9B=AE=E6=A0=87=E5=AE=9E=E4=BD=93=E4=B8=AD=E7=9A=84=E8=81=94=E6= =8E=A5=E5=88=97. + =E6=B3=A8=E6=84=8F,=E5=BD=93referencedColumnName=E5=85=B3=E8=81=94=E5=88=B0=E9=9D=9E=E4=B8=BB=E9=94=AE=E5=88= =97=E7=9A=84=E6=97=B6=E5=80=99, + =E5=85=B3=E8=81=94=E7=9A=84=E7=9B=AE=E6=A0=87=E7=B1=BB=E5=BF=85=E9=A1=BB= =E5=AE=9E=E7=8E=B0Serializable, + =E8=BF=98=E8=A6=81=E6=B3=A8=E6=84=8F=E7=9A=84=E6=98=AF=E6=89=80=E6=98=A0= =E5=B0=84=E7=9A=84=E5=B1=9E=E6=80=A7=E5=AF=B9=E5=BA=94=E5=8D=95=E4=B8=AA=E5= =88=97(=E5=90=A6=E5=88=99=E6=98=A0=E5=B0=84=E6=97=A0=E6=95=88). + + + =E4=B8=80=E5=AF=B9=E4=B8=80=E5=85=B3=E8=81=94=E5=8F=AF=E8=83= =BD=E6=98=AF=E5=8F=8C=E5=90=91=E7=9A=84.=E5=9C=A8=E5=8F=8C=E5=90=91=E5=85= =B3=E8=81=94=E4=B8=AD, + =E6=9C=89=E4=B8=94=E4=BB=85=E6=9C=89=E4=B8=80=E7=AB=AF=E6=98=AF=E4=BD=9C= =E4=B8=BA=E4=B8=BB=E4=BD=93(owner)=E7=AB=AF=E5=AD=98=E5=9C=A8=E7=9A=84=EF= =BC=9A=E4=B8=BB=E4=BD=93=E7=AB=AF=E8=B4=9F=E8=B4=A3=E7=BB=B4=E6=8A=A4=E8=81= =94=E6=8E=A5=E5=88=97(=E5=8D=B3=E6=9B=B4=E6=96=B0). + =E5=AF=B9=E4=BA=8E=E4=B8=8D=E9=9C=80=E8=A6=81=E7=BB=B4=E6=8A=A4=E8=BF=99= =E7=A7=8D=E5=85=B3=E7=B3=BB=E7=9A=84=E4=BB=8E=E8=A1=A8=E5=88=99=E9=80=9A=E8= =BF=87mappedBy=E5=B1=9E=E6=80=A7=E8=BF=9B=E8=A1=8C=E5=A3=B0=E6=98=8E. + mappedBy=E7=9A=84=E5=80=BC=E6=8C=87=E5=90=91=E4=B8=BB= =E4=BD=93=E7=9A=84=E5=85=B3=E8=81=94=E5=B1=9E=E6=80=A7. + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8=AD= ,mappedBy=E7=9A=84=E5=80=BC=E4=B8=BA passport. + =E6=9C=80=E5=90=8E,=E4=B8=8D=E5=BF=85=E4=B9=9F=E4=B8=8D=E8=83=BD=E5=86= =8D=E5=9C=A8=E8=A2=AB=E5=85=B3=E8=81=94=E7=AB=AF(owned side)=E5=AE=9A=E4=B9= =89=E8=81=94=E6=8E=A5=E5=88=97=E4=BA=86,=E5=9B=A0=E4=B8=BA=E5=B7=B2=E7=BB= =8F=E5=9C=A8=E4=B8=BB=E4=BD=93=E7=AB=AF=E8=BF=9B=E8=A1=8C=E4=BA=86=E5=A3=B0= =E6=98=8E. + + =E5=A6=82=E6=9E=9C=E5=9C=A8=E4=B8=BB=E4=BD=93=E6=B2=A1=E6=9C=89=E5= =A3=B0=E6=98=8E@JoinColumn,=E7=B3=BB=E7=BB=9F=E8=87=AA= =E5=8A=A8=E8=BF=9B=E8=A1=8C=E5=A4=84=E7=90=86=EF=BC=9A + =E5=9C=A8=E4=B8=BB=E8=A1=A8(owner table)=E4=B8=AD=E5=B0=86=E5=88=9B=E5= =BB=BA=E8=81=94=E6=8E=A5=E5=88=97, + =E5=88=97=E5=90=8D=E4=B8=BA=EF=BC=9A=E4=B8=BB=E4=BD=93=E7=9A=84=E5=85=B3= =E8=81=94=E5=B1=9E=E6=80=A7=E5=90=8D=EF=BC=8B=E4=B8=8B=E5=88=92=E7=BA=BF=EF= =BC=8B=E8=A2=AB=E5=85=B3=E8=81=94=E7=AB=AF=E7=9A=84=E4=B8=BB=E9=94=AE=E5=88= =97=E5=90=8D. + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8=AD= =E6=98=AFpassport_id, + =E5=9B=A0=E4=B8=BACustomer=E4=B8=AD=E5=85=B3=E8=81=94= =E5=B1=9E=E6=80=A7=E5=90=8D=E4=B8=BApassport, + Passport=E7=9A=84=E4=B8=BB=E9=94=AE=E6=98=AF= id. + + The third possibility (using an association table) is very + exotic. + + =E7=AC=AC=E4=B8=89=E7=A7=8D=E6=96=B9=E5=BC=8F=E4=B9=9F=E8=AE= =B8=E6=98=AF=E6=9C=80=E5=8F=A6=E7=B1=BB=E7=9A=84(=E9=80=9A=E8=BF=87=E5=85= =B3=E8=81=94=E8=A1=A8). + + +(a)Entity +public class Customer implements Serializable { + @OneToOne(cascade =3D CascadeType.ALL) + @JoinTable(name =3D "CustomerPassports", + joinColumns =3D @JoinColumn(name=3D"customer_fk"), + inverseJoinColumns =3D @JoinColumn(name=3D"passport_fk") + ) + public Passport getPassport() { + ... + } + +(a)Entity +public class Passport implements Serializable { + @OneToOne(mappedBy =3D "passport") + public Customer getOwner() { + ... +} + + + Customer=E9=80=9A=E8=BF=87=E5=90=8D= =E4=B8=BA CustomerPassports=E7=9A=84=E5=85=B3=E8=81=94= =E8=A1=A8=E5=92=8C + Passport=E5=85=B3=E8=81=94; =E8=AF=A5=E5=85= =B3=E8=81=94=E8=A1=A8=E6=8B=A5=E6=9C=89=E5=90=8D=E4=B8=BApassport_= fk=E7=9A=84=E5=A4=96=E9=94=AE=E5=88=97,=E8=AF=A5 + =E5=A4=96=E9=94=AE=E6=8C=87=E5=90=91Passport=E8=A1=A8= ,=E8=AF=A5=E4=BF=A1=E6=81=AF=E5=AE=9A=E4=B9=89=E4=B8=BAinverseJoin= Column=E7=9A=84=E5=B1=9E=E6=80=A7=E5=80=BC, + =E8=80=8Ccustomer_fk=E5=A4=96=E9=94=AE=E5=88=97=E6=8C= =87=E5=90=91Customer=E8=A1=A8, + =E8=AF=A5=E4=BF=A1=E6=81=AF=E5=AE=9A=E4=B9=89=E4=B8=BA joinColu= mns=E7=9A=84=E5=B1=9E=E6=80=A7=E5=80=BC. + + =E8=BF=99=E7=A7=8D=E5=85=B3=E8=81=94=E5=8F=AF=E8=83=BD=E6=98= =AF=E5=8F=8C=E5=90=91=E7=9A=84.=E5=9C=A8=E5=8F=8C=E5=90=91=E5=85=B3=E8=81= =94=E4=B8=AD, + =E6=9C=89=E4=B8=94=E4=BB=85=E6=9C=89=E4=B8=80=E7=AB=AF=E6=98=AF=E4=BD=9C= =E4=B8=BA=E4=B8=BB=E4=BD=93=E7=AB=AF=E5=AD=98=E5=9C=A8=E7=9A=84=EF=BC=9A=E4= =B8=BB=E4=BD=93=E7=AB=AF=E8=B4=9F=E8=B4=A3=E7=BB=B4=E6=8A=A4=E8=81=94=E6=8E= =A5=E5=88=97(=E5=8D=B3=E6=9B=B4=E6=96=B0). + =E5=AF=B9=E4=BA=8E=E4=B8=8D=E9=9C=80=E8=A6=81=E7=BB=B4=E6=8A=A4=E8=BF=99= =E7=A7=8D=E5=85=B3=E7=B3=BB=E7=9A=84=E4=BB=8E=E8=A1=A8=E5=88=99=E9=80=9A=E8= =BF=87mappedBy=E5=B1=9E=E6=80=A7=E8=BF=9B=E8=A1=8C=E5=A3=B0=E6=98=8E. + mappedBy=E7=9A=84=E5=80=BC=E6=8C=87=E5=90=91=E4=B8=BB= =E4=BD=93=E7=9A=84=E5=85=B3=E8=81=94=E5=B1=9E=E6=80=A7. + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8=AD= ,mappedBy=E7=9A=84=E5=80=BC=E4=B8=BA passport. + =E6=9C=80=E5=90=8E,=E4=B8=8D=E5=BF=85=E4=B9=9F=E4=B8=8D=E8=83=BD=E5=86= =8D=E5=9C=A8=E8=A2=AB=E5=85=B3=E8=81=94=E7=AB=AF(owned side)=E5=AE=9A=E4=B9= =89=E8=81=94=E6=8E=A5=E5=88=97=E4=BA=86,=E5=9B=A0=E4=B8=BA=E5=B7=B2=E7=BB= =8F=E5=9C=A8=E4=B8=BB=E4=BD=93=E7=AB=AF=E8=BF=9B=E8=A1=8C=E4=BA=86=E5=A3=B0= =E6=98=8E. + + =E4=BD=A0=E5=BF=85=E9=A1=BB=E6=98=8E=E7=A1=AE=E5=AE=9A=E4=B9=89=E5= =85=B3=E8=81=94=E8=A1=A8=E5=90=8D=E5=92=8C=E5=85=B3=E8=81=94=E5=88=97=E5=90= =8D. + + + + + =E5=A4=9A=E5=AF=B9=E4=B8=80(Many-to-one) + + =E5=9C=A8=E5=AE=9E=E4=BD=93=E5=B1=9E=E6=80=A7=E4=B8=80=E7=BA= =A7=E4=BD=BF=E7=94=A8@ManyToOne=E6=B3=A8=E8=A7=A3=E6=9D= =A5=E5=AE=9A=E4=B9=89=E5=A4=9A=E5=AF=B9=E4=B8=80=E5=85=B3=E8=81=94: + + +(a)Entity() +public class Flight implements Serializable { + @ManyToOne( cascade =3D {CascadeTyp= e.PERSIST, CascadeType.MERGE} ) + @JoinColumn(name=3D"COMP_ID") + public Company getCompany() { + return company; + } + ... +} + + + =E5=85=B6=E4=B8=AD@JoinColumn=E6=98=AF=E5= =8F=AF=E9=80=89=E7=9A=84,=E5=85=B3=E8=81=94=E5=AD=97=E6=AE=B5=E9=BB=98=E8= =AE=A4=E5=80=BC=E5=92=8C=E4=B8=80=E5=AF=B9=E4=B8=80 + (one to one)=E5=85=B3=E8=81=94=E7=9A=84=E6=83=85=E5=86=B5=E7=9B=B8=E4=BC= =BC, + =E5=88=97=E5=90=8D=E4=B8=BA=EF=BC=9A=E4=B8=BB=E4=BD=93=E7=9A=84=E5=85=B3= =E8=81=94=E5=B1=9E=E6=80=A7=E5=90=8D=EF=BC=8B=E4=B8=8B=E5=88=92=E7=BA=BF=EF= =BC=8B=E8=A2=AB=E5=85=B3=E8=81=94=E7=AB=AF=E7=9A=84=E4=B8=BB=E9=94=AE=E5=88= =97=E5=90=8D. + =E5=9C=A8=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8=AD=E6=98=AF= company_id, + =E5=9B=A0=E4=B8=BA=E5=85=B3=E8=81=94=E7=9A=84=E5=B1=9E=E6=80=A7=E6=98=AF= company, + Company=E7=9A=84=E4=B8=BB=E9=94=AE=E6=98=AFi= d. + + @ManyToOne=E6=B3=A8=E8=A7=A3=E6=9C=89=E4=B8=80= =E4=B8=AA=E5=90=8D=E4=B8=BAtargetEntity=E7=9A=84=E5=8F= =82=E6=95=B0, + =E8=AF=A5=E5=8F=82=E6=95=B0=E5=AE=9A=E4=B9=89=E4=BA=86=E7=9B=AE=E6=A0=87= =E5=AE=9E=E4=BD=93=E5=90=8D.=E9=80=9A=E5=B8=B8=E4=B8=8D=E9=9C=80=E8=A6=81= =E5=AE=9A=E4=B9=89=E8=AF=A5=E5=8F=82=E6=95=B0, + =E5=9B=A0=E4=B8=BA=E5=9C=A8=E5=A4=A7=E9=83=A8=E5=88=86=E6=83=85=E5=86=B5= =E4=B8=8B=E9=BB=98=E8=AE=A4=E5=80=BC(=E8=A1=A8=E7=A4=BA=E5=85=B3=E8=81=94= =E5=85=B3=E7=B3=BB=E7=9A=84=E5=B1=9E=E6=80=A7=E7=B1=BB=E5=9E=8B)=E5=B0=B1= =E5=8F=AF=E4=BB=A5=E5=BE=88=E5=A5=BD=E7=9A=84=E6=BB=A1=E8=B6=B3=E8=A6=81=E6= =B1=82=E4=BA=86. + =E4=B8=8D=E8=BF=87=E4=B8=8B=E9=9D=A2=E8=BF=99=E7=A7=8D=E6=83=85=E5=86=B5= =E4=B8=8B=E8=BF=99=E4=B8=AA=E5=8F=82=E6=95=B0=E5=B0=B1=E6=98=BE=E5=BE=97=E6= =9C=89=E6=84=8F=E4=B9=89=E4=BA=86=EF=BC=9A=E4=BD=BF=E7=94=A8=E6=8E=A5=E5=8F= =A3=E4=BD=9C=E4=B8=BA=E8=BF=94=E5=9B=9E=E5=80=BC=E8=80=8C=E4=B8=8D=E6=98=AF= =E5=B8=B8=E8=A7=81=E7=9A=84=E5=AE=9E=E4=BD=93. + + +(a)Entity() +public class Flight implements Serializable { + @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}, targetEntity=3DCompanyImpl.class ) + @JoinColumn(name=3D"COMP_ID") + public Company getCompany() { + return company; + } + ... +} + +public interface Company { + ... + + + =E5=AF=B9=E4=BA=8E=E5=A4=9A=E5=AF=B9=E4=B8=80=E4=B9=9F=E5=8F= =AF=E4=BB=A5=E9=80=9A=E8=BF=87=E5=85=B3=E8=81=94=E8=A1=A8=E7=9A=84=E6=96=B9= =E5=BC=8F=E6=9D=A5=E6=98=A0=E5=B0=84=E3=80=82 + =E9=80=9A=E8=BF=87@JoinTable=E6=B3=A8=E8=A7=A3=E5=8F= =AF=E5=AE=9A=E4=B9=89=E5=85=B3=E8=81=94=E8=A1=A8=EF=BC=8C + =E8=AF=A5=E5=85=B3=E8=81=94=E8=A1=A8=E5=8C=85=E5=90=AB=E4=BA=86=E6=8C=87= =E5=9B=9E=E5=AE=9E=E4=BD=93=E8=A1=A8=E7=9A=84=E5=A4=96=E9=94=AE(=E9=80=9A= =E8=BF=87@JoinTable.joinColumns) + =E4=BB=A5=E5=8F=8A=E6=8C=87=E5=90=91=E7=9B=AE=E6=A0=87=E5=AE=9E=E4=BD=93= =E8=A1=A8=E7=9A=84=E5=A4=96=E9=94=AE(=E9=80=9A=E8=BF=87@JoinTable.= inverseJoinColumns). + + +(a)Entity() +public class Flight implements Serializable { + @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE} ) + @JoinTable(name=3D"Flight_Company", + joinColumns =3D @JoinColumn(name=3D"FLIGHT_ID"), + inverseJoinColumns =3D @JoinColumn(name=3D"COMP_ID") + ) + public Company getCompany() { + return company; + } + ... +} + + + + + =E9=9B=86=E5=90=88=E7=B1=BB=E5=9E=8B + + + =E6=A6=82=E5=86=B5 + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=AF=B9 Collection= ,List + (=E6=8C=87=E6=9C=89=E5=BA=8F=E5=88=97=E8=A1=A8, =E8=80=8C=E4=B8=8D=E6= =98=AF=E7=B4=A2=E5=BC=95=E5=88=97=E8=A1=A8), + Map=E5=92=8CSet=E8=BF=99=E5= =87=A0=E7=A7=8D=E7=B1=BB=E5=9E=8B=E8=BF=9B=E8=A1=8C=E6=98=A0=E5=B0=84. + EJB3=E8=A7=84=E8=8C=83=E5=AE=9A=E4=B9=89=E4=BA=86=E6=80=8E=E4=B9=88=E6= =A0=B7=E4=BD=BF=E7=94=A8@javax.persistence.OrderBy + =E6=B3=A8=E8=A7=A3=E6=9D=A5=E5=AF=B9=E6=9C=89=E5=BA=8F=E5=88=97=E8=A1= =A8=E8=BF=9B=E8=A1=8C=E6=98=A0=E5=B0=84=EF=BC=9A + =E8=AF=A5=E6=B3=A8=E8=A7=A3=E6=8E=A5=E5=8F=97=E7=9A=84=E5=8F=82=E6=95= =B0=E6=A0=BC=E5=BC=8F=EF=BC=9A=E7=94=A8=E9=80=97=E5=8F=B7=E9=9A=94=E5=BC=80= =E7=9A=84(=E7=9B=AE=E6=A0=87=E5=AE=9E=E4=BD=93)=E5=B1=9E=E6=80=A7=E5=90=8D= =E5=8F=8A=E6=8E=92=E5=BA=8F=E6=8C=87=E4=BB=A4, + =E5=A6=82firstname asc, age desc,=E5=A6=82=E6=9E=9C=E8=AF= =A5=E5=8F=82=E6=95=B0=E4=B8=BA=E7=A9=BA,=E5=88=99=E9=BB=98=E8=AE=A4=E4=BB= =A5id=E5=AF=B9=E8=AF=A5=E9=9B=86=E5=90=88=E8=BF=9B=E8=A1=8C=E6=8E=92=E5=BA= =8F. + =E5=A6=82=E6=9E=9C=E6=9F=90=E4=B8=AA=E9=9B=86=E5=90=88=E5=9C=A8= =E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=AD=E5=AF=B9=E5=BA=94=E4=B8=80=E4=B8=AA=E5= =85=B3=E8=81=94=E8=A1=A8(association table)=E7=9A=84=E8=AF=9D,=E4=BD=A0=E4= =B8=8D=E8=83=BD=E5=9C=A8=E8=BF=99=E4=B8=AA=E9=9B=86=E5=90=88=E5=B1=9E=E6=80= =A7=E4=B8=8A=E9=9D=A2=E4=BD=BF=E7=94=A8@OrderBy=E6=B3=A8=E8=A7=A3. + =E5=AF=B9=E4=BA=8E=E8=BF=99=E7=A7=8D=E6=83=85=E5=86=B5=E7=9A=84=E5=A4= =84=E7=90=86=E6=96=B9=E6=B3=95,=E8=AF=B7=E5=8F=82=E8=80=83. + EJB3 =E5=85=81=E8=AE=B8=E4=BD=A0=E5=88=A9=E7=94=A8=E7=9B=AE=E6=A0=87= =E5=AE=9E=E4=BD=93=E7=9A=84=E4=B8=80=E4=B8=AA=E5=B1=9E=E6=80=A7=E4=BD=9C=E4= =B8=BAMap=E7=9A=84key, + =E8=BF=99=E4=B8=AA=E5=B1=9E=E6=80=A7=E5=8F=AF=E4=BB=A5=E7=94=A8@MapKey(name=3D"myProperty")=E6=9D=A5=E5=A3=B0=E6=98=8E. + =E5=A6=82=E6=9E=9C=E4=BD=BF=E7=94=A8@MapKey=E6=B3= =A8=E8=A7=A3=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=8D=E6=8F=90=E4=BE=9B=E5=B1=9E= =E6=80=A7=E5=90=8D, + =E7=B3=BB=E7=BB=9F=E9=BB=98=E8=AE=A4=E4=BD=BF=E7=94=A8=E7=9B=AE=E6=A0= =87=E5=AE=9E=E4=BD=93=E7=9A=84=E4=B8=BB=E9=94=AE. + map=E7=9A=84key=E4=BD=BF=E7=94=A8=E5=92=8C=E5=B1=9E=E6=80=A7=E7=9B=B8= =E5=90=8C=E7=9A=84=E5=88=97=EF=BC=9A=E4=B8=8D=E9=9C=80=E8=A6=81=E4=B8=BAmap= key=E5=AE=9A=E4=B9=89=E4=B8=93=E7=94=A8=E7=9A=84=E5=88=97=EF=BC=8C=E5=9B= =A0=E4=B8=BAmap key=E5=AE=9E=E9=99=85=E4=B8=8A=E5=B0=B1=E8=A1=A8=E8=BE=BE= =E4=BA=86=E4=B8=80=E4=B8=AA=E7=9B=AE=E6=A0=87=E5=B1=9E=E6=80=A7=E3=80=82 + =E6=B3=A8=E6=84=8F=E4=B8=80=E6=97=A6=E5=8A=A0=E8=BD=BD,key=E4=B8=8D=E5= =86=8D=E5=92=8C=E5=B1=9E=E6=80=A7=E4=BF=9D=E6=8C=81=E5=90=8C=E6=AD=A5, + =E4=B9=9F=E5=B0=B1=E6=98=AF=E8=AF=B4,=E5=A6=82=E6=9E=9C=E4=BD=A0=E6=94= =B9=E5=8F=98=E4=BA=86=E8=AF=A5=E5=B1=9E=E6=80=A7=E7=9A=84=E5=80=BC,=E5=9C= =A8=E4=BD=A0=E7=9A=84Java=E6=A8=A1=E5=9E=8B=E4=B8=AD=E7=9A=84key=E4=B8=8D= =E4=BC=9A=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0 + (=E8=AF=B7=E5=8F=82=E8=80=83). + =E5=BE=88=E5=A4=9A=E4=BA=BA=E8=A2=AB<map>=E5= =92=8C@MapKey=E5=BC=84=E7=B3=8A=E6=B6=82=E4=BA=86=E3=80= =82 + =E5=85=B6=E4=BB=96=E5=AE=83=E4=BB=AC=E6=9C=89=E4=B8=A4=E7=82=B9=E5=8C= =BA=E5=88=AB.@MapKey=E7=9B=AE=E5=89=8D=E8=BF=98=E6=9C=89= =E4=B8=80=E4=BA=9B=E9=99=90=E5=88=B6,=E8=AF=A6=E6=83=85=E8=AF=B7=E6=9F=A5= =E7=9C=8B=E8=AE=BA=E5=9D=9B=E6=88=96=E8=80=85 + =E6=88=91=E4=BB=AC=E7=9A=84JIRA=E7=BC=BA=E9=99=B7=E7=B3=BB=E7=BB=9F=E3= =80=82 + + + =E6=B3=A8=E6=84=8F=E4=B8=80=E6=97=A6=E5=8A=A0=E8=BD=BD,key=E4=B8=8D=E5= =86=8D=E5=92=8C=E5=B1=9E=E6=80=A7=E4=BF=9D=E6=8C=81=E5=90=8C=E6=AD=A5, + =E4=B9=9F=E5=B0=B1=E6=98=AF=E8=AF=B4,=E5=A6=82=E6=9E=9C=E4=BD=A0=E6=94= =B9=E5=8F=98=E4=BA=86=E8=AF=A5=E5=B1=9E=E6=80=A7=E7=9A=84=E5=80=BC,=E5=9C= =A8=E4=BD=A0=E7=9A=84Java=E6=A8=A1=E5=9E=8B=E4=B8=AD=E7=9A=84key=E4=B8=8D= =E4=BC=9A=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0. + (Hibernate 3=E4=B8=ADMap=E6=94=AF=E6=8C=81=E7=9A=84=E6=96=B9=E5=BC=8F= =E5=9C=A8=E5=BD=93=E5=89=8D=E7=9A=84=E5=8F=91=E5=B8=83=E7=89=88=E4=B8=AD=E8= =BF=98=E6=9C=AA=E5=BE=97=E5=88=B0=E6=94=AF=E6=8C=81). + + Hibernate=E5=B0=86=E9=9B=86=E5=90=88=E5=88=86=E4=BB=A5=E4= =B8=8B=E5=87=A0=E7=B1=BB. + + + + + =E9=9B=86=E5=90=88=E8=AF=AD=E4=B9=89 + + + + + + + + + + + =E8=AF=AD=E4=B9=89 + + Java=E5=AE=9E=E7=8E=B0=E7=B1=BB + + =E6=B3=A8=E8=A7=A3 + + + + + + Bag =E8=AF=AD=E4=B9=89 + + java.util.List, java.util.Collection + + @org.hibernate.annotations.CollectionOfElements = =E6=88=96 + @OneToMany =E6=88=96 @ManyToMany + + + + List =E8=AF=AD=E4=B9=89 + + java.util.List + + (@org.hibernate.annotations.CollectionOfElements = =E6=88=96 + @OneToMany =E6=88=96 @ManyToMany) = + =E4=BB=A5=E5=8F=8A + @org.hibernate.annotations.IndexColumn + + + + Set =E8=AF=AD=E4=B9=89 + + java.util.Set + + @org.hibernate.annotations.CollectionOfElements = =E6=88=96 + @OneToMany =E6=88=96 @ManyToMany + + + + Map =E8=AF=AD=E4=B9=89 + + java.util.Map + + (@org.hibernate.annotations.CollectionOfElements = =E6=88=96 + @OneToMany =E6=88=96 @ManyToMany) + =E4=BB=A5=E5=8F=8A + (=E7=A9=BA = + =E6=88=96 + @org.hibernate.annotations.MapKey/MapKeyManyToMany(=E6= =94=AF=E6=8C=81=E7=9C=9F=E6=AD=A3=E7=9A=84map), = + =E6=88=96 + @javax.persistence.MapKey + = + + + +
+ + + =E4=BB=8E=E4=B8=8A=E9=9D=A2=E5=8F=AF=E4=BB=A5=E6=98=8E=E7=A1=AE=E5=9C= =B0=E7=9C=8B=E5=88=B0,=E6=B2=A1=E6=9C=89@org.hibernate.annotations.IndexCol= umn = + =E6=B3=A8=E8=A7=A3=E7=9A=84java.util.List=E9=9B=86=E5=90=88=E5=B0=86= =E8=A2=AB=E7=9C=8B=E4=BD=9Cbag=E7=B1=BB. + + + EJB3=E8=A7=84=E8=8C=83=E4=B8=8D=E6=94=AF=E6=8C=81=E5=8E=9F= =E5=A7=8B=E7=B1=BB=E5=9E=8B,=E6=A0=B8=E5=BF=83=E7=B1=BB=E5=9E=8B,=E5=B5=8C= =E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1=E7=9A=84=E9=9B=86=E5=90=88.=E4=BD=86= =E6=98=AFHibernate=E5=AF=B9=E6=AD=A4=E6=8F=90=E4=BE=9B=E4=BA=86=E6=94=AF=E6= =8C=81 + (=E8=AF=A6=E6=83=85=E5=8F=82=E8=80=83 ). + + @Entity public class City { + @OneToMany(mappedBy=3D"city") + @OrderBy("streetName") + public List<Street> getStreets() { + return streets; + } +... +} + +(a)Entity public class Street { + public String getStreetName() { + return streetName; + } + + @ManyToOne + public City getCity() { + return city; + } + ... +} + + +(a)Entity +public class Software { + @OneToMany(mappedBy=3D"software") + @MapKey(name=3D"codeName") + public Map<String, Version> getVersions() { + return versions; + } +... +} + +(a)Entity +(a)Table(name=3D"tbl_version") +public class Version { + public String getCodeName() {...} + + @ManyToOne + public Software getSoftware() { ... } +... +} + + =E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4= =B8=AD,City + =E4=B8=AD=E5=8C=85=E6=8B=AC=E4=BA=86=E4=BB=A5streetName=E6=8E=92=E5=BA=8F=E7=9A=84Street=E7=9A=84=E9=9B=86= =E5=90=88. + =E8=80=8CSoftware=E4=B8=AD=E5=8C=85=E6=8B=AC=E4=BA= =86=E4=BB=A5codeName=E4=BD=9C=E4=B8=BA + key=E5=92=8C=E4=BB=A5Version=E4=BD=9C=E4=B8=BA=E5= =80=BC=E7=9A=84Map. + + =E9=99=A4=E9=9D=9E=E9=9B=86=E5=90=88=E4=B8=BAgeneric=E7=B1=BB=E5= =9E=8B,=E5=90=A6=E5=88=99=E4=BD=A0=E9=9C=80=E8=A6=81=E6=8C=87=E5=AE=9AtargetEntity. + =E8=BF=99=E4=B8=AA=E6=B3=A8=E8=A7=A3=E5=B1=9E=E6=80=A7=E6=8E=A5=E5=8F= =97=E7=9A=84=E5=8F=82=E6=95=B0=E4=B8=BA=E7=9B=AE=E6=A0=87=E5=AE=9E=E4=BD=93= =E7=9A=84class. +
+ + + =E4=B8=80=E5=AF=B9=E5=A4=9A(One-to-many) + + =E5=9C=A8=E5=B1=9E=E6=80=A7=E7=BA=A7=E4=BD=BF=E7=94=A8 @OneToMany=E6=B3=A8=E8=A7=A3=E5=8F=AF=E5=AE=9A=E4=B9=89=E4= =B8=80=E5=AF=B9=E5=A4=9A=E5=85=B3=E8=81=94.=E4=B8=80=E5=AF=B9=E5=A4=9A=E5= =85=B3=E8=81=94=E5=8F=AF=E4=BB=A5=E6=98=AF=E5=8F=8C=E5=90=91=E5=85=B3=E8=81= =94. + + + =E5=8F=8C=E5=90=91(Bidirectional) + + =E5=9C=A8EJB3=E8=A7=84=E8=8C=83=E4=B8=AD=E5=A4=9A=E5=AF= =B9=E4=B8=80=E8=BF=99=E7=AB=AF=E5=87=A0=E4=B9=8E=E6=80=BB=E6=98=AF=E5=8F=8C= =E5=90=91=E5=85=B3=E8=81=94=E4=B8=AD=E7=9A=84=E4=B8=BB=E4=BD=93(owner)=E7= =AB=AF, + =E8=80=8C=E4=B8=80=E5=AF=B9=E5=A4=9A=E8=BF=99=E7=AB=AF=E7=9A=84=E5=85= =B3=E8=81=94=E6=B3=A8=E8=A7=A3=E4=B8=BA@OneToMany( mappedBy=3D... + ) + + @Entity +public class Troop { + @OneToMany(mappedBy=3D"troop") + public Set<Soldier> getSoldiers() { + ... +} + +(a)Entity +public class Soldier { + @ManyToOne + @JoinColumn(name=3D"troop_fk") + public Troop getTroop() { + ... +} + + Troop =E9=80=9A=E8=BF=87troop = + =E5=B1=9E=E6=80=A7=E5=92=8CSoldier=E5=BB=BA=E7=AB=8B= =E4=BA=86=E4=B8=80=E5=AF=B9=E5=A4=9A=E7=9A=84=E5=8F=8C=E5=90=91=E5=85=B3=E8= =81=94. + =E5=9C=A8mappedBy=E7=AB=AF=E4=B8=8D=E5=BF=85=E4=B9= =9F=E4=B8=8D=E8=83=BD=E5=86=8D=E5=AE=9A=E4=B9=89=E4=BB=BB=E4=BD=95=E7=89=A9= =E7=90=86=E6=98=A0=E5=B0=84 + + =E5=AF=B9=E4=BA=8E=E4=B8=80=E5=AF=B9=E5=A4=9A=E7=9A=84= =E5=8F=8C=E5=90=91=E6=98=A0=E5=B0=84,=E5=A6=82=E6=9E=9C=E8=A6=81=E4=B8=80= =E5=AF=B9=E5=A4=9A=E8=BF=99=E4=B8=80=E7=AB=AF=E7=BB=B4=E6=8A=A4=E5=85=B3=E8= =81=94=E5=85=B3=E7=B3=BB, + =E4=BD=A0=E9=9C=80=E8=A6=81=E5=88=A0=E9=99=A4mappedBy=E5=85=83=E7=B4=A0=E5=B9=B6=E5=B0=86=E5=A4=9A=E5=AF=B9=E4=B8=80=E8=BF=99= =E7=AB=AF=E7=9A=84 + @JoinColumn=E7=9A=84insertable=E5=92=8Cupdatable=E8= =AE=BE=E7=BD=AE=E4=B8=BAfalse. + =E5=BE=88=E6=98=8E=E6=98=BE,=E8=BF=99=E7=A7=8D=E6=96=B9=E6=A1=88=E4=B8= =8D=E4=BC=9A=E5=BE=97=E5=88=B0=E4=BB=80=E4=B9=88=E6=98=8E=E6=98=BE=E7=9A=84= =E4=BC=98=E5=8C=96,=E8=80=8C=E4=B8=94=E8=BF=98=E4=BC=9A=E5=A2=9E=E5=8A=A0= =E4=B8=80=E4=BA=9B=E9=99=84=E5=8A=A0=E7=9A=84UPDATE=E8=AF=AD=E5=8F=A5. + + @Entity +public class Troop { + @OneToMany + @JoinColumn(name=3D"troop_fk") //we need to duplicate the physical inf= ormation + public Set<Soldier> getSoldiers() { + ... +} + +(a)Entity +public class Soldier { + @ManyToOne + @JoinColumn(name=3D"troop_fk", insertable=3Dfalse, updatable=3Dfalse) + public Troop getTroop() { + ... +} + + + + =E5=8D=95=E5=90=91(Unidirectional) + + =E9=80=9A=E8=BF=87=E5=9C=A8=E8=A2=AB=E6=8B=A5=E6=9C=89=E7=9A=84= =E5=AE=9E=E4=BD=93=E7=AB=AF(owned entity)=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8= =AA=E5=A4=96=E9=94=AE=E5=88=97=E6=9D=A5=E5=AE=9E=E7=8E=B0=E4=B8=80=E5=AF=B9= =E5=A4=9A=E5=8D=95=E5=90=91=E5=85=B3=E8=81=94=E6=98=AF=E5=BE=88=E5=B0=91=E8= =A7=81=E7=9A=84,=E4=B9=9F=E6=98=AF=E4=B8=8D=E6=8E=A8=E8=8D=90=E7=9A=84. + =E6=88=91=E4=BB=AC=E5=BC=BA=E7=83=88=E5=BB=BA=E8=AE=AE=E9=80=9A=E8=BF= =87=E4=B8=80=E4=B8=AA=E8=81=94=E6=8E=A5=E8=A1=A8(join table)=E6=9D=A5=E5=AE= =9E=E7=8E=B0=E8=BF=99=E7=A7=8D=E5=85=B3=E8=81=94(=E4=B8=8B=E4=B8=80=E8=8A= =82=E4=BC=9A=E5=AF=B9=E6=AD=A4=E8=BF=9B=E8=A1=8C=E8=A7=A3=E9=87=8A). + =E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87@JoinColumn=E6= =B3=A8=E8=A7=A3=E6=9D=A5=E6=8F=8F=E8=BF=B0=E8=BF=99=E7=A7=8D=E5=8D=95=E5=90= =91=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB. + + +(a)Entity +public class Customer implements Serializable { + @OneToMany(cascade=3DCascadeType.ALL, fetch=3DFetchType.EAGER) + @JoinColumn(name=3D"CUST_ID") + public Set<Ticket> getTickets() { + ... +} + +(a)Entity +public class Ticket implements Serializable { + ... //no bidir +} + + + Customer =E9=80=9A=E8=BF=87 + CUST_ID=E5=88=97=E5=92=8CTicket = =E5=BB=BA=E7=AB=8B=E4=BA=86=E5=8D=95=E5=90=91=E5=85=B3=E8=81=94=E5=85=B3=E7= =B3=BB. + + + + + =E9=80=9A=E8=BF=87=E5=85=B3=E8=81=94=E8=A1=A8=E5=A4=84= =E7=90=86=E5=8D=95=E5=90=91=E5=85=B3=E8=81=94 + + =E9=80=9A=E8=BF=87=E8=81=94=E6=8E=A5=E8=A1=A8=E5=A4=84= =E7=90=86=E5=8D=95=E5=90=91=E4=B8=80=E5=AF=B9=E5=A4=9A=E5=85=B3=E8=81=94=E6= =98=AF=E9=A6=96=E9=80=89=E6=96=B9=E5=BC=8F.=E8=BF=99=E7=A7=8D=E5=85=B3=E8= =81=94=E9=80=9A=E8=BF=87@JoinTable=E6=B3=A8=E8=A7=A3=E6= =9D=A5=E8=BF=9B=E8=A1=8C=E6=8F=8F=E8=BF=B0. + + +(a)Entity +public class Trainer { + @OneToMany + @JoinTable( + name=3D"TrainedMonkeys", + joinColumns =3D @JoinColumn( name=3D"trainer_id"), + inverseJoinColumns =3D @JoinColumn( name=3D"monkey_id") + ) + public Set<Monkey> getTrainedMonkeys() { + ... +} + +(a)Entity +public class Monkey { + ... //no bidir +} + + + =E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8=AD,<= literal>Trainer=E9=80=9A=E8=BF=87 + TrainedMonkeys=E8=A1=A8=E5=92=8C + Monkey =E5=BB=BA=E7=AB=8B=E4=BA=86=E5=8D=95=E5= =90=91=E5=85=B3=E8=81=94. = + =E5=85=B6=E4=B8=AD=E5=A4=96=E9=94=AEtrainer_id=E5=85= =B3=E8=81=94=E5=88=B0Trainer + (joinColumns), + =E8=80=8C=E5=A4=96=E9=94=AEmonkey_id=E5=85=B3=E8=81= =94=E5=88=B0 Monkey + (inversejoinColumns). + + + + =E9=BB=98=E8=AE=A4=E5=A4=84=E7=90=86=E6=9C=BA=E5=88=B6<= /title> + + <para>=E9=80=9A=E8=BF=87=E8=81=94=E6=8E=A5=E8=A1=A8=E6=9D=A5= =E5=BB=BA=E7=AB=8B=E5=8D=95=E5=90=91=E4=B8=80=E5=AF=B9=E5=A4=9A=E5=85=B3=E8= =81=94=E4=B8=8D=E9=9C=80=E8=A6=81=E6=8F=8F=E8=BF=B0=E4=BB=BB=E4=BD=95=E7=89= =A9=E7=90=86=E6=98=A0=E5=B0=84. + =E8=A1=A8=E5=90=8D=E7=94=B1=E4=BB=A5=E4=B8=8B=E4=B8=89=E4=B8= =AA=E9=83=A8=E5=88=86=E7=BB=84=E6=88=90:=E4=B8=BB=E8=A1=A8(owner table)=E8= =A1=A8=E5=90=8D+=E4=B8=8B=E5=88=92=E7=BA=BF+=E4=BB=8E=E8=A1=A8(the other si= de table)=E8=A1=A8=E5=90=8D. + =E6=8C=87=E5=90=91=E4=B8=BB=E8=A1=A8=E7=9A=84=E5=A4=96=E9=94= =AE=E5=90=8D=EF=BC=9A=E4=B8=BB=E8=A1=A8=E8=A1=A8=E5=90=8D+=E4=B8=8B=E5=88= =92=E7=BA=BF+=E4=B8=BB=E8=A1=A8=E4=B8=BB=E9=94=AE=E5=88=97=E5=90=8D + =E6=8C=87=E5=90=91=E4=BB=8E=E8=A1=A8=E7=9A=84=E5=A4=96=E9=94= =AE=E5=90=8D=EF=BC=9A=E4=B8=BB=E8=A1=A8=E6=89=80=E5=AF=B9=E5=BA=94=E5=AE=9E= =E4=BD=93=E7=9A=84=E5=B1=9E=E6=80=A7=E5=90=8D+=E4=B8=8B=E5=88=92=E7=BA=BF+= =E4=BB=8E=E8=A1=A8=E4=B8=BB=E9=94=AE=E5=88=97=E5=90=8D + =E6=8C=87=E5=90=91=E4=BB=8E=E8=A1=A8=E7=9A=84=E5=A4=96=E9=94= =AE=E5=AE=9A=E4=B9=89=E4=B8=BA=E5=94=AF=E4=B8=80=E7=BA=A6=E6=9D=9F,=E7=94= =A8=E6=9D=A5=E8=A1=A8=E7=A4=BA=E4=B8=80=E5=AF=B9=E5=A4=9A=E7=9A=84=E5=85=B3= =E8=81=94=E5=85=B3=E7=B3=BB.</para> + + <programlisting> +(a)Entity +public class Trainer { + @OneToMany + public Set<Tiger> getTrainedTigers() { + ... +} + +(a)Entity +public class Tiger { + ... //no bidir +} + </programlisting> + + <para>=E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90= =E4=B8=AD,<classname>Trainer</classname>=E5=92=8C<classname>Tiger</classnam= e> + =E9=80=9A=E8=BF=87=E8=81=94=E6=8E=A5=E8=A1=A8 <literal>Trainer_Tiger</l= iteral>=E5=BB=BA=E7=AB=8B=E5=8D=95=E5=90=91=E5=85=B3=E8=81=94=E5=85=B3=E7= =B3=BB, + =E5=85=B6=E4=B8=AD=E5=A4=96=E9=94=AE<literal>trainer_id</literal>=E5=85= =B3=E8=81=94=E5=88=B0<literal>Trainer</literal> + (=E4=B8=BB=E8=A1=A8=E8=A1=A8=E5=90=8D, <keycap>_</keycap>(=E4=B8=8B=E5= =88=92=E7=BA=BF), trainer id), + =E8=80=8C=E5=A4=96=E9=94=AE<literal>trainedTigers_id</literal>=E5=85=B3= =E8=81=94=E5=88=B0<literal>Tiger</literal> + (=E5=B1=9E=E6=80=A7=E5=90=8D=E7=A7=B0, <keycap>_</keycap>(=E4=B8=8B=E5= =88=92=E7=BA=BF), Tiger=E8=A1=A8=E7=9A=84=E4=B8=BB=E9=94=AE=E5=88=97=E5=90= =8D).</para> + + </sect5> + </sect4> + + <sect4> + <title>=E5=A4=9A=E5=AF=B9=E5=A4=9A(Many-to-many) + + + =E5=AE=9A=E4=B9=89 + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87@M= anyToMany=E6=B3=A8=E8=A7=A3=E5=8F=AF=E5=AE=9A=E4=B9=89=E7=9A=84= =E5=A4=9A=E5=AF=B9=E5=A4=9A=E5=85=B3=E8=81=94. + =E5=90=8C=E6=97=B6,=E4=BD=A0=E4=B9=9F=E9=9C=80=E8=A6=81=E9=80=9A=E8=BF= =87=E6=B3=A8=E8=A7=A3@JoinTable=E6=8F=8F=E8=BF=B0=E5=85= =B3=E8=81=94=E8=A1=A8=E5=92=8C=E5=85=B3=E8=81=94=E6=9D=A1=E4=BB=B6. + =E5=A6=82=E6=9E=9C=E6=98=AF=E5=8F=8C=E5=90=91=E5=85=B3=E8=81=94,=E5=85= =B6=E4=B8=AD=E4=B8=80=E6=AE=B5=E5=BF=85=E9=A1=BB=E5=AE=9A=E4=B9=89=E4=B8=BA= owner,=E5=8F=A6=E4=B8=80=E7=AB=AF=E5=BF=85=E9=A1=BB=E5=AE=9A=E4=B9=89=E4=B8= =BAinverse(=E5=9C=A8=E5=AF=B9=E5=85=B3=E8=81=94=E8=A1=A8=E8=BF=9B=E8=A1=8C= =E6=9B=B4=E6=96=B0=E6=93=8D=E4=BD=9C=E6=97=B6=E8=BF=99=E4=B8=80=E7=AB=AF=E5= =B0=86=E8=A2=AB=E5=BF=BD=E7=95=A5): + + +(a)Entity +public class Employer implements Serializable { + @ManyToMany( + targetEntity=3Dorg.hibernate.test.metadata.manytomany.Employee.cla= ss, + cascade=3D{CascadeType.PERSIST, CascadeType.MERGE} + ) + @JoinTable( + name=3D"EMPLOYER_EMPLOYEE", + joinColumns=3D@JoinColumn(name=3D"EMPER_ID"), + inverseJoinColumns=3D@JoinColumn(name=3D"EMPEE_ID") + ) + public Collection getEmployees() { + return employees; + } + ... +} + + + +(a)Entity +public class Employee implements Serializable { + @ManyToMany( + cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}, + mappedBy =3D "employees", + targetEntity =3D Employer.class + ) + public Collection getEmployers() { + return employers; + } +} + + + =E8=87=B3=E6=AD=A4,=E6=88=91=E4=BB=AC=E5=B7=B2=E7=BB=8F= =E5=B1=95=E7=A4=BA=E4=BA=86=E5=BE=88=E5=A4=9A=E8=B7=9F=E5=85=B3=E8=81=94=E6= =9C=89=E5=85=B3=E7=9A=84=E5=A3=B0=E6=98=8E=E5=AE=9A=E4=B9=89=E4=BB=A5=E5=8F= =8A=E5=B1=9E=E6=80=A7=E7=BB=86=E8=8A=82. + =E4=B8=8B=E9=9D=A2=E6=88=91=E4=BB=AC=E5=B0=86=E6=B7=B1=E5=85=A5=E4=BB= =8B=E7=BB=8D@JoinTable=E6=B3=A8=E8=A7=A3,=E8=AF=A5=E6=B3= =A8=E8=A7=A3=E5=AE=9A=E4=B9=89=E4=BA=86=E8=81=94=E6=8E=A5=E8=A1=A8=E7=9A=84= =E8=A1=A8=E5=90=8D, + =E8=81=94=E6=8E=A5=E5=88=97=E6=95=B0=E7=BB=84(=E6=B3=A8=E8=A7=A3=E4=B8= =AD=E5=AE=9A=E4=B9=89=E6=95=B0=E7=BB=84=E7=9A=84=E6=A0=BC=E5=BC=8F=E4=B8=BA= { A, B, C }), + =E4=BB=A5=E5=8F=8Ainverse=E8=81=94=E6=8E=A5=E5=88=97=E6=95=B0=E7=BB=84. + =E5=90=8E=E8=80=85=E6=98=AF=E5=85=B3=E8=81=94=E8=A1=A8=E4=B8=AD=E5=85= =B3=E8=81=94=E5=88=B0Employee=E4=B8=BB=E9=94=AE=E7= =9A=84=E5=88=97(the "other side"). + + =E6=AD=A3=E5=A6=82=E5=89=8D=E9=9D=A2=E6=89=80=E7=A4=BA,= =E8=A2=AB=E5=85=B3=E8=81=94=E7=AB=AF=E4=B8=8D=E5=BF=85=E4=B9=9F=E4=B8=8D=E8= =83=BD=E6=8F=8F=E8=BF=B0=E7=89=A9=E7=90=86=E6=98=A0=E5=B0=84: = + =E5=8F=AA=E9=9C=80=E8=A6=81=E4=B8=80=E4=B8=AA=E7=AE=80=E5=8D=95=E7=9A= =84mappedBy=E5=8F=82=E6=95=B0,=E8=AF=A5=E5=8F=82=E6=95= =B0=E5=8C=85=E5=90=AB=E4=BA=86=E4=B8=BB=E4=BD=93=E7=AB=AF=E7=9A=84=E5=B1=9E= =E6=80=A7=E5=90=8D,=E8=BF=99=E6=A0=B7=E5=B0=B1=E7=BB=91=E5=AE=9A=E5=8F=8C= =E6=96=B9=E7=9A=84=E5=85=B3=E7=B3=BB. + + + + =E9=BB=98=E8=AE=A4=E5=80=BC + + =E5=92=8C=E5=85=B6=E4=BB=96=E8=AE=B8=E5=A4=9A=E6=B3=A8=E8=A7=A3= =E4=B8=80=E6=A0=B7,=E5=9C=A8=E5=A4=9A=E5=AF=B9=E5=A4=9A=E5=85=B3=E8=81=94= =E4=B8=AD=E5=BE=88=E5=A4=9A=E5=80=BC=E6=98=AF=E8=87=AA=E5=8A=A8=E7=94=9F=E6= =88=90. + =E5=BD=93=E5=8F=8C=E5=90=91=E5=A4=9A=E5=AF=B9=E5=A4=9A=E5=85=B3=E8=81= =94=E4=B8=AD=E6=B2=A1=E6=9C=89=E5=AE=9A=E4=B9=89=E4=BB=BB=E4=BD=95=E7=89=A9= =E7=90=86=E6=98=A0=E5=B0=84=E6=97=B6,Hibernate=E6=A0=B9=E6=8D=AE=E4=BB=A5= =E4=B8=8B=E8=A7=84=E5=88=99=E7=94=9F=E6=88=90=E7=9B=B8=E5=BA=94=E7=9A=84=E5= =80=BC. + =E5=85=B3=E8=81=94=E8=A1=A8=E5=90=8D:=E4=B8=BB=E8=A1=A8=E8=A1=A8=E5=90= =8D+_=E4=B8=8B=E5=88=92=E7=BA=BF+=E4=BB=8E=E8=A1=A8=E8=A1= =A8=E5=90=8D, + =E5=85=B3=E8=81=94=E5=88=B0=E4=B8=BB=E8=A1=A8=E7=9A=84=E5=A4=96=E9=94= =AE=E5=90=8D:=E4=B8=BB=E8=A1=A8=E5=90=8D+_=E4=B8=8B=E5=88= =92=E7=BA=BF+=E4=B8=BB=E8=A1=A8=E4=B8=AD=E7=9A=84=E4=B8=BB=E9=94=AE=E5=88= =97=E5=90=8D. + =E5=85=B3=E8=81=94=E5=88=B0=E4=BB=8E=E8=A1=A8=E7=9A=84=E5=A4=96=E9=94= =AE=E5=90=8D:=E4=B8=BB=E8=A1=A8=E4=B8=AD=E7=94=A8=E4=BA=8E=E5=85=B3=E8=81= =94=E7=9A=84=E5=B1=9E=E6=80=A7=E5=90=8D+_=E4=B8=8B=E5=88= =92=E7=BA=BF+=E4=BB=8E=E8=A1=A8=E7=9A=84=E4=B8=BB=E9=94=AE=E5=88=97=E5=90= =8D. + =E4=BB=A5=E4=B8=8A=E8=A7=84=E5=88=99=E5=AF=B9=E4=BA=8E=E5=8F=8C=E5=90= =91=E4=B8=80=E5=AF=B9=E5=A4=9A=E5=85=B3=E8=81=94=E5=90=8C=E6=A0=B7=E6=9C=89= =E6=95=88. + + +(a)Entity +public class Store { + @ManyToMany(cascade =3D CascadeType.PERSIST) + public Set<City> getImplantedIn() { + ... + } +} + +(a)Entity +public class City { + ... //no bidirectional relationship +} + + + =E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90= =E4=B8=AD,Store_Table=E4=BD=9C=E4=B8=BA=E8=81=94=E6=8E= =A5=E8=A1=A8. = + Store_id=E5=88=97=E6=98=AF=E8=81=94=E6=8E=A5=E5=88= =B0Store=E8=A1=A8=E7=9A=84=E5=A4=96=E9=94=AE. + =E8=80=8CimplantedIn_id=E5=88=97=E5=88=99=E8=81=94= =E6=8E=A5=E5=88=B0City=E8=A1=A8. + + =E5=BD=93=E5=8F=8C=E5=90=91=E5=A4=9A=E5=AF=B9=E5=A4=9A= =E5=85=B3=E8=81=94=E4=B8=AD=E6=B2=A1=E6=9C=89=E5=AE=9A=E4=B9=89=E4=BB=BB=E4= =BD=95=E7=89=A9=E7=90=86=E6=98=A0=E5=B0=84=E6=97=B6, Hibernate=E6=A0=B9=E6= =8D=AE=E4=BB=A5=E4=B8=8B=E8=A7=84=E5=88=99=E7=94=9F=E6=88=90=E7=9B=B8=E5=BA= =94=E7=9A=84=E5=80=BC + =E5=85=B3=E8=81=94=E8=A1=A8=E5=90=8D: :=E4=B8=BB=E8=A1=A8=E8= =A1=A8=E5=90=8D+_=E4=B8=8B=E5=88=92=E7=BA=BF+=E4=BB=8E=E8= =A1=A8=E8=A1=A8=E5=90=8D, + =E5=85=B3=E8=81=94=E5=88=B0=E4=B8=BB=E8=A1=A8=E7=9A=84=E5=A4= =96=E9=94=AE=E5=90=8D:=E4=BB=8E=E8=A1=A8=E7=94=A8=E4=BA=8E=E5=85=B3=E8=81= =94=E7=9A=84=E5=B1=9E=E6=80=A7=E5=90=8D+_=E4=B8=8B=E5=88= =92=E7=BA=BF+=E4=B8=BB=E8=A1=A8=E4=B8=AD=E7=9A=84=E4=B8=BB=E9=94=AE=E5=88= =97=E5=90=8D. + =E5=85=B3=E8=81=94=E5=88=B0=E4=BB=8E=E8=A1=A8=E7=9A=84=E5=A4= =96=E9=94=AE=E5=90=8D:=E4=B8=BB=E8=A1=A8=E7=94=A8=E4=BA=8E=E5=85=B3=E8=81= =94=E7=9A=84=E5=B1=9E=E6=80=A7=E5=90=8D+_=E4=B8=8B=E5=88= =92=E7=BA=BF+=E4=BB=8E=E8=A1=A8=E7=9A=84=E4=B8=BB=E9=94=AE=E5=88=97=E5=90= =8D. + =E4=BB=A5=E4=B8=8A=E8=A7=84=E5=88=99=E5=AF=B9=E4=BA=8E=E5=8F= =8C=E5=90=91=E4=B8=80=E5=AF=B9=E5=A4=9A=E5=85=B3=E8=81=94=E5=90=8C=E6=A0=B7= =E6=9C=89=E6=95=88. + + +(a)Entity +public class Store { + @ManyToMany(cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}) + public Set<Customer> getCustomers() { + ... + } +} + +(a)Entity +public class Customer { + @ManyToMany(mappedBy=3D"customers") + public Set<Store> getStores() { + ... + } +} + + + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B= =E5=AD=90=E4=B8=AD,Store_Customer=E4=BD=9C=E4=B8=BA=E8= =81=94=E6=8E=A5=E8=A1=A8. = + stores_id=E5=88=97=E6=98=AF=E8=81=94=E6=8E=A5=E5=88= =B0Store=E8=A1=A8=E7=9A=84=E5=A4=96=E9=94=AE, + =E8=80=8Ccustomers_id=E5=88=97=E8=81=94=E6=8E=A5=E5= =88=B0City=E8=A1=A8. + + + +
+ + + + =E7=94=A8cascading=E5=AE=9E=E7=8E=B0=E4=BC=A0=E6=92=AD=E6= =80=A7=E6=8C=81=E4=B9=85=E5=8C=96(Transitive persistence) + + =E4=B9=9F=E8=AE=B8=E4=BD=A0=E5=B7=B2=E7=BB=8F=E6=B3=A8=E6=84= =8F=E5=88=B0=E4=BA=86cascade=E5=B1=9E=E6=80=A7=E6=8E=A5= =E5=8F=97=E7=9A=84=E5=80=BC=E4=B8=BACascadeType=E6= =95=B0=E7=BB=84. + =E5=9C=A8EJB3=E4=B8=AD=E7=9A=84cascade=E7=9A=84=E6=A6=82=E5=BF=B5=E5=92= =8CHibernate=E4=B8=AD=E7=9A=84=E4=BC=A0=E6=92=AD=E6=80=A7=E6=8C=81=E4=B9=85= =E5=8C=96=E4=BB=A5=E5=8F=8Acascade=E6=93=8D=E4=BD=9C=E9=9D=9E=E5=B8=B8=E7= =B1=BB=E4=BC=BC, + =E4=BD=86=E6=98=AF=E5=9C=A8=E8=AF=AD=E4=B9=89=E4=B8=8A=E6=9C=89=E7=BB=86= =E5=BE=AE=E7=9A=84=E5=8C=BA=E5=88=AB,=E6=94=AF=E6=8C=81=E7=9A=84cascade=E7= =B1=BB=E5=9E=8B=E4=B9=9F=E6=9C=89=E7=82=B9=E5=8C=BA=E5=88=AB: + + + + CascadeType.PERSIST: =E5=A6=82=E6=9E=9C=E4=B8=80=E4=B8=AA=E5= =AE=9E=E4=BD=93=E6=98=AF=E5=8F=97=E7=AE=A1=E7=8A=B6=E6=80=81, =E6=88=96=E8= =80=85=E5=BD=93persist()=E5=87=BD=E6=95=B0=E8=A2=AB=E8=B0=83=E7=94=A8=E6=97= =B6, =E8=A7=A6=E5=8F=91=E7=BA=A7=E8=81=94=E5=88=9B=E5=BB=BA(create)=E6=93= =8D=E4=BD=9C + + + + CascadeType.MERGE: =E5=A6=82=E6=9E=9C=E4=B8=80=E4=B8=AA=E5=AE= =9E=E4=BD=93=E6=98=AF=E5=8F=97=E7=AE=A1=E7=8A=B6=E6=80=81, =E6=88=96=E8=80= =85=E5=BD=93merge()=E5=87=BD=E6=95=B0=E8=A2=AB=E8=B0=83=E7=94=A8=E6=97=B6, = =E8=A7=A6=E5=8F=91=E7=BA=A7=E8=81=94=E5=90=88=E5=B9=B6(merge)=E6=93=8D=E4= =BD=9C + + + + CascadeType.REMOVE: =E5=BD=93delete()=E5=87=BD=E6=95=B0=E8=A2= =AB=E8=B0=83=E7=94=A8=E6=97=B6, =E8=A7=A6=E5=8F=91=E7=BA=A7=E8=81=94=E5=88= =A0=E9=99=A4(remove)=E6=93=8D=E4=BD=9C + + + + CascadeType.REFRESH: =E5=BD=93refresh()=E5=87=BD=E6=95=B0=E8= =A2=AB=E8=B0=83=E7=94=A8=E6=97=B6, =E8=A7=A6=E5=8F=91=E7=BA=A7=E8=81=94=E6= =9B=B4=E6=96=B0(refresh)=E6=93=8D=E4=BD=9C + + + + CascadeType.ALL: =E4=BB=A5=E4=B8=8A=E5=85=A8=E9=83=A8 + + + + =E5=85=B3=E4=BA=8Ecascading, create/merge=E7=9A=84=E8=AF=AD=E4=B9= =89=E8=AF=B7=E5=8F=82=E8=80=83EJB3=E8=A7=84=E8=8C=83=E7=9A=846.3=E7=AB=A0= =E8=8A=82. + + + + =E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB=E8=8E=B7=E5=8F=96</tit= le> + + <para>=E9=80=9A=E8=BF=87Hibernate=E4=BD=A0=E5=8F=AF=E4=BB=A5=E8=8E= =B7=E5=BE=97=E7=9B=B4=E6=8E=A5=E6=88=96=E8=80=85=E5=BB=B6=E8=BF=9F=E8=8E=B7= =E5=8F=96=E5=85=B3=E8=81=94=E5=AE=9E=E4=BD=93=E7=9A=84=E5=8A=9F=E8=83=BD. + <literal>fetch</literal>=E5=8F=82=E6=95=B0=E5=8F=AF=E4=BB=A5=E8=AE=BE=E7= =BD=AE=E4=B8=BA<literal>FetchType.LAZY</literal> = + =E6=88=96=E8=80=85 <literal>FetchType.EAGER</literal>. + <literal>EAGER</literal>=E9=80=9A=E8=BF=87<literal>outer join select</li= teral>=E7=9B=B4=E6=8E=A5=E8=8E=B7=E5=8F=96=E5=85=B3=E8=81=94=E7=9A=84=E5=AF= =B9=E8=B1=A1, + =E8=80=8C<literal>LAZY</literal>(=E9=BB=98=E8=AE=A4=E5=80=BC)=E5=9C=A8= =E7=AC=AC=E4=B8=80=E6=AC=A1=E8=AE=BF=E9=97=AE=E5=85=B3=E8=81=94=E5=AF=B9=E8= =B1=A1=E7=9A=84=E6=97=B6=E5=80=99=E6=89=8D=E4=BC=9A=E8=A7=A6=E5=8F=91=E7=9B= =B8=E5=BA=94=E7=9A=84select=E6=93=8D=E4=BD=9C. + EJBQL=E6=8F=90=E4=BE=9B=E4=BA=86<literal>fetch</literal>=E5=85=B3=E9=94= =AE=E5=AD=97,=E8=AF=A5=E5=85=B3=E9=94=AE=E5=AD=97=E5=8F=AF=E4=BB=A5=E5=9C= =A8=E8=BF=9B=E8=A1=8C=E7=89=B9=E6=AE=8A=E6=9F=A5=E8=AF=A2=E7=9A=84=E6=97=B6= =E5=80=99=E8=A6=86=E7=9B=96=E9=BB=98=E8=AE=A4=E5=80=BC. + =E8=BF=99=E5=AF=B9=E4=BA=8E=E6=8F=90=E9=AB=98=E6=80=A7=E8=83=BD=E6=9D=A5= =E8=AF=B4=E9=9D=9E=E5=B8=B8=E6=9C=89=E6=95=88,=E5=BA=94=E8=AF=A5=E6=A0=B9= =E6=8D=AE=E5=AE=9E=E9=99=85=E7=9A=84=E7=94=A8=E4=BE=8B=E6=9D=A5=E5=88=A4=E6= =96=AD=E6=98=AF=E5=90=A6=E9=80=89=E6=8B=A9fetch=E5=85=B3=E9=94=AE=E5=AD=97.= </para> + </sect3> + </sect2> + + <sect2> + <title>=E6=98=A0=E5=B0=84=E5=A4=8D=E5=90=88=E4=B8=BB=E9=94=AE=E4=B8= =8E=E5=A4=96=E9=94=AE + + =E7=BB=84=E5=90=88=E4=B8=BB=E9=94=AE=E4=BD=BF=E7=94=A8=E4=B8= =80=E4=B8=AA=E5=8F=AF=E5=B5=8C=E5=85=A5=E7=9A=84=E7=B1=BB=E4=BD=9C=E4=B8=BA= =E4=B8=BB=E9=94=AE=E8=A1=A8=E7=A4=BA,=E5=9B=A0=E6=AD=A4=E4=BD=A0=E9=9C=80= =E8=A6=81=E4=BD=BF=E7=94=A8@Id + =E5=92=8C@Embeddable=E4=B8=A4=E4=B8=AA=E6=B3=A8=E8= =A7=A3. + =E8=BF=98=E6=9C=89=E4=B8=80=E7=A7=8D=E6=96=B9=E5=BC=8F=E6=98=AF=E4=BD= =BF=E7=94=A8@EmbeddedId=E6=B3=A8=E8=A7=A3.=E6=B3=A8=E6= =84=8F=E6=89=80=E4=BE=9D=E8=B5=96=E7=9A=84=E7=B1=BB=E5=BF=85=E9=A1=BB=E5=AE= =9E=E7=8E=B0 + serializable=E4=BB=A5=E5=8F=8A=E5=AE=9E=E7=8E=B0equals()/hashCode()=E6=96=B9=E6=B3=95. + =E4=BD=A0=E4=B9=9F=E5=8F=AF=E4=BB=A5=E5=A6=82=E4=B8=80=E7=AB=A0=E4=B8=AD=E6=8F=8F=E8=BF=B0=E7=9A=84=E5=8A= =9E=E6=B3=95=E4=BD=BF=E7=94=A8@IdClass=E6=B3=A8=E8=A7=A3= . + + +(a)Entity +public class RegionalArticle implements Serializable { + + @Id + public RegionalArticlePk getPk() { ... } +} + +(a)Embeddable +public class RegionalArticlePk implements Serializable { ... } + + + =E6=88=96=E8=80=85 + + +(a)Entity +public class RegionalArticle implements Serializable { + + @EmbeddedId + public RegionalArticlePk getPk() { ... } +} + +public class RegionalArticlePk implements Serializable { ... } + + + @Embeddable =E6=B3=A8=E8=A7=A3=E9=BB=98=E8= =AE=A4=E7=BB=A7=E6=89=BF=E4=BA=86=E5=85=B6=E6=89=80=E5=B1=9E=E5=AE=9E=E4=BD= =93=E7=9A=84=E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B, + =E9=99=A4=E9=9D=9E=E6=98=BE=E5=BC=8F=E4=BD=BF=E7=94=A8=E4=BA=86Hibernat= e=E7=9A=84@AccessType=E6=B3=A8=E8=A7=A3(=E8=BF=99=E4=B8= =AA=E6=B3=A8=E8=A7=A3=E4=B8=8D=E6=98=AFEJB3=E6=A0=87=E5=87=86=E7=9A=84=E4= =B8=80=E9=83=A8=E5=88=86). + =E8=80=8C@JoinColumns,=E5=8D=B3@JoinColumn<= /literal>=E6=95=B0=E7=BB=84, + =E5=AE=9A=E4=B9=89=E4=BA=86=E5=85=B3=E8=81=94=E7=9A=84=E7=BB=84=E5=90= =88=E5=A4=96=E9=94=AE(=E5=A6=82=E6=9E=9C=E4=B8=8D=E4=BD=BF=E7=94=A8=E7=BC= =BA=E7=9C=81=E5=80=BC=E7=9A=84=E8=AF=9D). + =E6=98=BE=E5=BC=8F=E6=8C=87=E6=98=8EreferencedColumnNames=E6=98=AF=E4=B8=80=E4=B8=AA=E5=A5=BD=E7=9A=84=E5=AE=9E=E8=B7=B5=E6=96= =B9=E5=BC=8F, + =E5=90=A6=E5=88=99,Hibernate=E8=AE=A4=E4=B8=BA=E4=BD=A0=E4=BD=BF=E7=94= =A8=E7=9A=84=E5=88=97=E9=A1=BA=E5=BA=8F=E5=92=8C=E4=B8=BB=E9=94=AE=E5=A3=B0= =E6=98=8E=E7=9A=84=E9=A1=BA=E5=BA=8F=E4=B8=80=E8=87=B4. + + +(a)Entity +public class Parent implements Serializable { + @Id + public ParentPk id; + public int age; + + @OneToMany(cascade=3DCascadeType.ALL) + @JoinColumns ({ + @JoinColumn(name=3D"parentCivility", referencedColumnName =3D "isM= ale"), + @JoinColumn(name=3D"parentLastName", referencedColumnName =3D "las= tName"), + @JoinColumn(name=3D"parentFirstName", referencedColumnName =3D "fi= rstName") + }) + public Set<Child> children; //unidirectional + ... +} + + + +(a)Entity +public class Child implements Serializable { + @Id @GeneratedValue + public Integer id; + + @ManyToOne + @JoinColumns ({ + @JoinColumn(name=3D"parentCivility", referencedColumnName =3D "isM= ale"), + @JoinColumn(name=3D"parentLastName", referencedColumnName =3D "las= tName"), + @JoinColumn(name=3D"parentFirstName", referencedColumnName =3D "fi= rstName") + }) + public Parent parent; //unidirectional +} + + + +(a)Embeddable +public class ParentPk implements Serializable { + String firstName; + String lastName; + ... +} + + + =E6=B3=A8=E6=84=8F=E4=B8=8A=E9=9D=A2=E7=9A=84 referenced= ColumnName=E6=98=BE=E5=BC=8F=E4=BD=BF=E7=94=A8=E6=96=B9=E5=BC=8F.= +
+ + + =E6=98=A0=E5=B0=84=E4=BA=8C=E7=BA=A7=E8=A1=A8(secondary table= s) + + =E4=BD=BF=E7=94=A8=E7=B1=BB=E4=B8=80=E7=BA=A7=E7=9A=84 @SecondaryTable =E6=88=96 = + @SecondaryTables =E6=B3=A8=E8=A7=A3=E5=8F=AF=E4=BB= =A5=E5=AE=9E=E7=8E=B0=E5=8D=95=E4=B8=AA=E5=AE=9E=E4=BD=93=E5=88=B0=E5=A4=9A= =E4=B8=AA=E8=A1=A8=E7=9A=84=E6=98=A0=E5=B0=84. + =E4=BD=BF=E7=94=A8 @Column =E6=88=96=E8=80=85 @JoinColumn + =E6=B3=A8=E8=A7=A3=E4=B8=AD=E7=9A=84 table =E5=8F=82= =E6=95=B0=E5=8F=AF=E6=8C=87=E5=AE=9A=E6=9F=90=E4=B8=AA=E5=88=97=E6=89=80=E5= =B1=9E=E7=9A=84=E7=89=B9=E5=AE=9A=E8=A1=A8. + + +(a)Entity +(a)Table(name=3D"MainCat") +@SecondaryTables({ + @SecondaryTable(name=3D"Cat1", pkJoinColumns=3D{ + @PrimaryKeyJoinColumn(name=3D"cat_id", referencedColumnName=3D"id") + ), + @SecondaryTable(name=3D"Cat2", uniqueConstraints=3D{@UniqueConstraint(= columnNames=3D{"storyPart2"})}) +}) +public class Cat implements Serializable { + + private Integer id; + private String name; + private String storyPart1; + private String storyPart2; + + @Id @GeneratedValue + public Integer getId() { + return id; + } + + public String getName() { + return name; + } + = + @Column(table=3D"Cat1") + public String getStoryPart1() { + return storyPart1; + } + + @Column(table=3D"Cat2") + public String getStoryPart2() { + return storyPart2; + } + + + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD= =90=E4=B8=AD,name=E4=BF=9D=E5=AD=98=E5=9C=A8Mai= nCat=E8=A1=A8=E4=B8=AD, + storyPart1=E4=BF=9D=E5=AD=98=E5=9C=A8Cat1=E8=A1=A8=E4=B8=AD, + storyPart2=E4=BF=9D=E5=AD=98=E5=9C=A8Cat2=E8=A1=A8=E4=B8=AD. + Cat1=E8=A1=A8=E9=80=9A=E8=BF=87=E5=A4=96=E9=94=AEcat_id=E5=92=8CMainCat=E8=A1=A8=E5=85=B3= =E8=81=94, + Cat2=E8=A1=A8=E9=80=9A=E8=BF=87id= =E5=88=97=E5=92=8CMainCat=E8=A1=A8=E5=85=B3=E8=81=94 + (=E5=92=8CMainCat=E7=9A=84id=E5= =88=97=E5=90=8C=E5=90=8D). + =E5=AF=B9storyPart2=E5=88=97=E8=BF=98=E5=AE=9A=E4=B9= =89=E4=BA=86=E5=94=AF=E4=B8=80=E7=BA=A6=E6=9D=9F. + + =E5=9C=A8JBoss EJB 3=E6=8C=87=E5=8D=97=E5=92=8CHibernate Annot= ations=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81=E4=B8=AD=E8=BF= =98=E6=9C=89=E6=9B=B4=E5=A4=9A=E7=9A=84=E4=BE=8B=E5=AD=90. + +
+ + + =E6=98=A0=E5=B0=84=E6=9F=A5=E8=AF=A2 + + + =E6=98=A0=E5=B0=84EJBQL/HQL=E6=9F=A5=E8=AF=A2 + + =E4=BD=BF=E7=94=A8=E6=B3=A8=E8=A7=A3=E8=BF=98=E5=8F=AF=E4=BB= =A5=E6=98=A0=E5=B0=84EJBQL/HQL=E6=9F=A5=E8=AF=A2. + @NamedQuery =E5=92=8C@NamedQueries=E6=98=AF=E5=8F=AF=E4=BD=BF=E7=94=A8=E5=9C=A8=E7=B1=BB=E5=92=8C=E5=8C=85= =E4=B8=8A=E7=9A=84=E6=B3=A8=E8=A7=A3. + =E4=BD=86=E6=98=AF=E5=AE=83=E4=BB=AC=E7=9A=84=E5=AE=9A=E4=B9=89=E5=9C= =A8session factory/entity manager factory=E8=8C=83=E5=9B=B4=E4=B8=AD=E6=98= =AF=E9=83=BD=E5=8F=AF=E8=A7=81=E7=9A=84. + =E5=91=BD=E5=90=8D=E5=BC=8F=E6=9F=A5=E8=AF=A2=E9=80=9A=E8=BF=87=E5=AE= =83=E7=9A=84=E5=90=8D=E5=AD=97=E5=92=8C=E5=AE=9E=E9=99=85=E7=9A=84=E6=9F=A5= =E8=AF=A2=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=9D=A5=E5=AE=9A=E4=B9=89. + + +javax.persistence.NamedQueries( + @javax.persistence.NamedQuery(name=3D"plane.getAll", query=3D"select p= from Plane p") +) +package org.hibernate.test.annotations.query; + +... + +(a)Entity +(a)NamedQuery(name=3D"night.moreRecentThan", query=3D"select n from Night = n where n.date >=3D :date") +public class Night { + ... +} + +public class MyDao { + doStuff() { + Query q =3D s.getNamedQuery("night.moreRecentThan"); + q.setDate( "date", aMonthAgo ); + List results =3D q.list(); + ... + } + ... +} + + + =E8=BF=98=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87=E5=AE=9A=E4=B9= =89 QueryHint =E6=95=B0=E7=BB=84=E7=9A=84hints<= /literal> + =E5=B1=9E=E6=80=A7=E4=B8=BA=E6=9F=A5=E8=AF=A2=E6=8F=90=E4=BE=9B=E4=B8= =80=E4=BA=9Bhint=E4=BF=A1=E6=81=AF. + + =E4=B8=8B=E9=9D=A2=E6=98=AF=E7=9B=AE=E5=89=8D=E5=8F=AF=E4=BB= =A5=E4=BD=BF=E7=94=A8=E7=9A=84=E4=B8=80=E4=BA=9BHibernate hint=EF=BC=9A + + + + + Query hints + + + + + + + + + hint + + description + + + + + + org.hibernate.cacheable + + =E6=9F=A5=E8=AF=A2=E6=98=AF=E5=90=A6=E4=B8=8E=E4=BA= =8C=E7=BA=A7=E7=BC=93=E5=AD=98=E4=BA=A4=E4=BA=92(=E9=BB=98=E8=AE=A4=E5=80= =BC=E4=B8=BAfalse) + + + + + org.hibernate.cacheRegion + + =E8=AE=BE=E7=BD=AE=E7=BC=93=E5=AD=98=E5=8C=BA=E5=90= =8D=E7=A7=B0 (=E9=BB=98=E8=AE=A4=E4=B8=BAotherwise) + + + + org.hibernate.timeout + + =E6=9F=A5=E8=AF=A2=E8=B6=85=E6=97=B6=E8=AE=BE=E5=AE= =9A + + + + org.hibernate.fetchSize + + =E6=89=80=E8=8E=B7=E5=8F=96=E7=9A=84=E7=BB=93=E6=9E= =9C=E9=9B=86(resultset)=E5=A4=A7=E5=B0=8F + + + + org.hibernate.flushMode + + =E6=9C=AC=E6=AC=A1=E6=9F=A5=E8=AF=A2=E6=89=80=E7=94= =A8=E7=9A=84=E5=88=B7=E6=96=B0=E6=A8=A1=E5=BC=8F + + + + org.hibernate.cacheMode + + =E6=9C=AC=E6=AC=A1=E6=9F=A5=E8=AF=A2=E6=89=80=E7=94= =A8=E7=9A=84=E7=BC=93=E5=AD=98=E6=A8=A1=E5=BC=8F + + + + org.hibernate.readOnly + + =E6=98=AF=E5=90=A6=E5=B0=86=E6=9C=AC=E6=AC=A1=E6=9F= =A5=E8=AF=A2=E6=89=80=E5=8A=A0=E8=BD=BD=E7=9A=84=E5=AE=9E=E4=BD=93=E8=AE=BE= =E4=B8=BA=E5=8F=AA=E8=AF=BB(=E9=BB=98=E8=AE=A4=E4=B8=BAfalse) + + + + + org.hibernate.comment + + =E5=B0=86=E6=9F=A5=E8=AF=A2=E6=B3=A8=E9=87=8A=E6=B7= =BB=E5=8A=A0=E5=85=A5=E6=89=80=E7=94=9F=E6=88=90=E7=9A=84SQL + + + +
+
+ + + =E6=98=A0=E5=B0=84=E6=9C=AC=E5=9C=B0=E5=8C=96=E6=9F=A5=E8=AF= =A2 + + =E4=BD=A0=E8=BF=98=E5=8F=AF=E4=BB=A5=E6=98=A0=E5=B0=84=E6=9C= =AC=E5=9C=B0=E5=8C=96=E6=9F=A5=E8=AF=A2(=E4=B9=9F=E5=B0=B1=E6=98=AF=E6=99= =AE=E9=80=9ASQL=E6=9F=A5=E8=AF=A2). + =E4=B8=8D=E8=BF=87=E8=BF=99=E9=9C=80=E8=A6=81=E4=BD=A0=E4=BD=BF=E7=94= =A8@SqlResultSetMapping=E6=B3=A8=E8=A7=A3=E6=9D=A5=E6=8F= =8F=E8=BF=B0SQL=E7=9A=84resultset=E7=9A=84=E7=BB=93=E6=9E=84 + (=E5=A6=82=E6=9E=9C=E4=BD=A0=E6=89=93=E7=AE=97=E5=AE=9A=E4=B9=89=E5=A4= =9A=E4=B8=AA=E7=BB=93=E6=9E=9C=E9=9B=86=E6=98=A0=E5=B0=84=EF=BC=8C=E5=8F=AF= =E6=98=AF=E4=BD=BF=E7=94=A8@SqlResultSetMappings). + @SqlResultSetMapping=E5=92=8C@NamedQuery, + @SqlResultSetMapping=E4=B8=80=E6=A0=B7,=E5=8F=AF=E4= =BB=A5=E5=AE=9A=E4=B9=89=E5=9C=A8=E7=B1=BB=E5=92=8C=E5=8C=85=E4=B8=80=E7=BA= =A7. + =E4=BD=86=E6=98=AF@SqlResultSetMapping=E7=9A=84=E4= =BD=9C=E7=94=A8=E5=9F=9F=E4=B8=BA=E5=BA=94=E7=94=A8=E7=BA=A7. + =E4=B8=8B=E9=9D=A2=E6=88=91=E4=BB=AC=E4=BC=9A=E7=9C=8B=E5=88=B0,@NamedNativeQuery =E6=B3=A8=E8=A7=A3=E4=B8=AD + resultSetMapping=E5=8F=82=E6=95=B0=E5=80=BC=E4=B8=BA= @SqlResultSetMapping=E7=9A=84=E5=90=8D=E5=AD=97. + =E7=BB=93=E6=9E=9C=E9=9B=86=E6=98=A0=E5=B0=84=E5=AE=9A=E4=B9=89=E4=BA= =86=E9=80=9A=E8=BF=87=E6=9C=AC=E5=9C=B0=E5=8C=96=E6=9F=A5=E8=AF=A2=E8=BF=94= =E5=9B=9E=E5=80=BC=E5=92=8C=E5=AE=9E=E4=BD=93=E7=9A=84=E6=98=A0=E5=B0=84. + =E8=AF=A5=E5=AE=9E=E4=BD=93=E4=B8=AD=E7=9A=84=E6=AF=8F=E4=B8=80=E4=B8= =AA=E5=AD=97=E6=AE=B5=E9=83=BD=E7=BB=91=E5=AE=9A=E5=88=B0SQL=E7=BB=93=E6=9E= =9C=E9=9B=86=E4=B8=AD=E7=9A=84=E6=9F=90=E4=B8=AA=E5=88=97=E4=B8=8A. + =E8=AF=A5=E5=AE=9E=E4=BD=93=E7=9A=84=E6=89=80=E6=9C=89=E5=AD=97=E6=AE= =B5=E5=8C=85=E6=8B=AC=E5=AD=90=E7=B1=BB=E7=9A=84=E6=89=80=E6=9C=89=E5=AD=97= =E6=AE=B5=E4=BB=A5=E5=8F=8A + =E5=85=B3=E8=81=94=E5=AE=9E=E4=BD=93=E7=9A=84=E5=A4=96=E9=94=AE=E5=88= =97=E9=83=BD=E5=BF=85=E9=A1=BB=E5=9C=A8SQL=E6=9F=A5=E8=AF=A2=E4=B8=AD=E6=9C= =89=E5=AF=B9=E5=BA=94=E7=9A=84=E5=AE=9A=E4=B9=89. + =E5=A6=82=E6=9E=9C=E5=AE=9E=E4=BD=93=E4=B8=AD=E7=9A=84=E5=B1=9E=E6=80= =A7=E5=92=8CSQL=E6=9F=A5=E8=AF=A2=E4=B8=AD=E7=9A=84=E5=88=97=E5=90=8D=E7=9B= =B8=E5=90=8C,=E8=BF=99=E7=A7=8D=E6=83=85=E5=86=B5=E4=B8=8B=E5=8F=AF=E4=BB= =A5=E4=B8=8D=E8=BF=9B=E8=A1=8C=E5=AE=9A=E4=B9=89=E5=AD=97=E6=AE=B5=E6=98=A0= =E5=B0=84. + + @NamedNativeQuery(name=3D"night&area", que= ry=3D"select night.id nid, night.night_duration, " + + " night.night_date, area.id aid, night.area_id, area.name " + + "from Night night, Area area where night.area_id =3D area.id", resultSetMapping=3D"joinMapping") +(a)SqlResultSetMapping(name=3D"joinMapping", entities=3D{ + @EntityResult(entityClass=3Dorg.hibernate.test.annotations.query.Night= .class, fields =3D { + @FieldResult(name=3D"id", column=3D"nid"), + @FieldResult(name=3D"duration", column=3D"night_duration"), + @FieldResult(name=3D"date", column=3D"night_date"), + @FieldResult(name=3D"area", column=3D"area_id"), + discriminatorColumn=3D"disc" + }), + @EntityResult(entityClass=3Dorg.hibernate.test.annotations.query.Area.= class, fields =3D { + @FieldResult(name=3D"id", column=3D"aid"), + @FieldResult(name=3D"name", column=3D"name") + }) + } +) + + =E5=9C=A8=E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD= =90=E4=B8=AD,=E5=90=8D=E4=B8=BAnight&area=E7=9A=84= =E6=9F=A5=E8=AF=A2 + =E5=92=8CjoinMapping=E7=BB=93=E6=9E=9C=E9=9B=86=E6= =98=A0=E5=B0=84=E5=AF=B9=E5=BA=94. + =E8=AF=A5=E6=98=A0=E5=B0=84=E8=BF=94=E5=9B=9E=E4=B8=A4=E4=B8=AA=E5=AE= =9E=E4=BD=93,=E5=88=86=E5=88=AB=E4=B8=BANight = + =E5=92=8CArea,=E5=85=B6=E4=B8=AD=E6=AF=8F=E4=B8=AA= =E5=B1=9E=E6=80=A7=E9=83=BD=E5=92=8C=E4=B8=80=E4=B8=AA=E5=88=97=E5=85=B3=E8= =81=94, + =E5=88=97=E5=90=8D=E9=80=9A=E8=BF=87=E6=9F=A5=E8=AF=A2=E8=8E=B7=E5=8F= =96.=E4=B8=8B=E9=9D=A2=E6=88=91=E4=BB=AC=E7=9C=8B=E4=B8=80=E4=B8=AA=E9=9A= =90=E5=BC=8F=E5=A3=B0=E6=98=8E=E5=B1=9E=E6=80=A7=E5=92=8C=E5=88=97=E6=98=A0= =E5=B0=84=E5=85=B3=E7=B3=BB=E7=9A=84=E4=BE=8B=E5=AD=90. + + @Entity +@SqlResultSetMapping(name=3D"implicit", entities= =3D@EntityResult(entityClass=3Dorg.hibernate.test.annotations.query.SpaceSh= ip.class)) +(a)NamedNativeQuery(name=3D"implicitSample", query=3D"select * from SpaceS= hip", resultSetMapping=3D"implicit") +public class SpaceShip { + private String name; + private String model; + private double speed; + + @Id + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Column(name=3D"model_txt") + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed =3D speed; + } +} + + =E5=9C=A8=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8=AD,=E6=88= =91=E4=BB=AC=E5=8F=AA=E9=9C=80=E8=A6=81=E5=AE=9A=E4=B9=89=E7=BB=93=E6=9E=9C= =E9=9B=86=E6=98=A0=E5=B0=84=E4=B8=AD=E7=9A=84=E5=AE=9E=E4=BD=93=E6=88=90=E5= =91=98. + =E5=B1=9E=E6=80=A7=E5=92=8C=E5=88=97=E5=90=8D=E4=B9=8B=E9=97=B4=E7=9A= =84=E6=98=A0=E5=B0=84=E5=80=9F=E5=8A=A9=E5=AE=9E=E4=BD=93=E4=B8=AD=E5=8C=85= =E5=90=AB=E6=98=A0=E5=B0=84=E4=BF=A1=E6=81=AF=E6=9D=A5=E5=AE=8C=E6=88=90. + =E5=9C=A8=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8=AD,model=E5=B1=9E=E6=80=A7=E7=BB=91=E5=AE=9A=E5=88=B0model_txt=E5=88=97. + =E5=A6=82=E6=9E=9C=E5=92=8C=E7=9B=B8=E5=85=B3=E5=AE=9E=E4=BD=93=E7=9A= =84=E5=85=B3=E8=81=94=E8=AE=BE=E8=AE=A1=E5=88=B0=E7=BB=84=E5=90=88=E4=B8=BB= =E9=94=AE, + =E9=82=A3=E4=B9=88=E5=BA=94=E8=AF=A5=E4=BD=BF=E7=94=A8@FieldRe= sult=E6=B3=A8=E8=A7=A3=E6=9D=A5=E5=AE=9A=E4=B9=89=E6=AF=8F=E4=B8= =AA=E5=A4=96=E9=94=AE=E5=88=97. + @FieldResult=E7=9A=84=E5=90=8D=E5=AD=97=E7=94=B1=E4= =BB=A5=E4=B8=8B=E5=87=A0=E9=83=A8=E5=88=86=E7=BB=84=E6=88=90=EF=BC=9A + =E5=AE=9A=E4=B9=89=E8=BF=99=E7=A7=8D=E5=85=B3=E7=B3=BB=E7=9A=84=E5=B1= =9E=E6=80=A7=E5=90=8D=E5=AD=97+"."=EF=BC=8B=E4=B8=BB=E9=94=AE=E5=90=8D=E6= =88=96=E4=B8=BB=E9=94=AE=E5=88=97=E6=88=96=E4=B8=BB=E9=94=AE=E5=B1=9E=E6=80= =A7. + + @Entity +(a)SqlResultSetMapping(name=3D"compositekey", + entities=3D@EntityResult(entityClass=3Dorg.hibernate.test.annotati= ons.query.SpaceShip.class, + fields =3D { + @FieldResult(name=3D"name", column =3D "name"), + @FieldResult(name=3D"model", column =3D "model"), + @FieldResult(name=3D"speed", column =3D "speed"), + @FieldResult(name=3D"captain.f= irstname", column =3D "firstn"), + @FieldResult(name=3D"captain.lastname", column =3D "la= stn"), + @FieldResult(name=3D"dimensions.length", column =3D "l= ength"), + @FieldResult(name=3D"dimensions.width", column =3D "wi= dth") + }), + columns =3D { @ColumnResult(name =3D "surface"), + @ColumnResult(name =3D "volume") } ) + +(a)NamedNativeQuery(name=3D"compositekey", + query=3D"select name, model, speed, lname as lastn, fname as firstn, l= ength, width, length * width as surface from SpaceShip", = + resultSetMapping=3D"compositekey") +} ) +public class SpaceShip { + private String name; + private String model; + private double speed; + private Captain captain; + private Dimensions dimensions; + + @Id + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToOne(fetch=3D FetchType.LAZY) + @JoinColumns( { + @JoinColumn(name=3D"fname", referencedColumnName =3D "firstnam= e"), + @JoinColumn(name=3D"lname", referencedColumnName =3D "lastname= ") + } ) + public Captain getCaptain() { + return captain; + } + + public void setCaptain(Captain captain) { + this.captain =3D captain; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed =3D speed; + } + + public Dimensions getDimensions() { + return dimensions; + } + + public void setDimensions(Dimensions dimensions) { + this.dimensions =3D dimensions; + } +} + +(a)Entity +(a)IdClass(Identity.class) +public class Captain implements Serializable { + private String firstname; + private String lastname; + + @Id + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + @Id + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } +} + + + + + =E8=A7=82=E5=AF=9Fdimension=E5=B1=9E=E6=80=A7=E4=BD=A0=E4=BC=9A=E5= =8F=91=E7=8E=B0Hibernate=E6=94=AF=E6=8C=81=E7=94=A8"."=E7=AC=A6=E5=8F=B7=E6= =9D=A5=E8=A1=A8=E7=A4=BA=E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1. + EJB3=E5=AE=9E=E7=8E=B0=E4=B8=8D=E5=BF=85=E6=94=AF=E6=8C=81=E8=BF=99=E4= =B8=AA=E7=89=B9=E5=BE=81,=E4=BD=86=E6=98=AF=E6=88=91=E4=BB=AC=E5=81=9A=E5= =88=B0=E4=BA=86:-) + + + =E5=A6=82=E6=9E=9C=E6=9F=A5=E8=AF=A2=E8=BF=94=E5=9B=9E=E7=9A= =84=E6=98=AF=E5=8D=95=E4=B8=AA=E5=AE=9E=E4=BD=93,=E6=88=96=E8=80=85=E4=BD= =A0=E6=89=93=E7=AE=97=E4=BD=BF=E7=94=A8=E7=B3=BB=E7=BB=9F=E9=BB=98=E8=AE=A4= =E7=9A=84=E6=98=A0=E5=B0=84, + =E8=BF=99=E7=A7=8D=E6=83=85=E5=86=B5=E4=B8=8B=E5=8F=AF=E4=BB=A5=E4=B8= =8D=E4=BD=BF=E7=94=A8resultSetMapping + =E8=80=8C=E6=98=AF=E4=BD=BF=E7=94=A8resultClass=E5= =B1=9E=E6=80=A7: + + @NamedNativeQuery(name=3D"im= plicitSample", query=3D"select * from SpaceShip", = + resultClass=3DSpaceShip.class) +public class SpaceShip { + + =E6=9F=90=E4=BA=9B=E6=9C=AC=E5=9C=B0=E6=9F=A5=E8=AF=A2=E8=BF= =94=E5=9B=9E=E7=9A=84=E6=98=AFscalar=E5=80=BC,=E4=BE=8B=E5=A6=82=E6=8A=A5= =E8=A1=A8=E6=9F=A5=E8=AF=A2. + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87@ColumnResult=E5=B0=86=E5=85=B6=E6=98=A0=E5=B0=84=E5=88=B0 + @SqlResultsetMapping=E4=B8=8A. + =E7=94=9A=E8=87=B3=E8=BF=98=E5=8F=AF=E4=BB=A5=E5=9C=A8=E5=90=8C=E4=B8= =80=E4=B8=AA=E6=9C=AC=E5=9C=B0=E6=9F=A5=E8=AF=A2=E7=9A=84=E7=BB=93=E6=9E=9C= =E4=B8=AD=E6=B7=B7=E5=90=88=E5=AE=9E=E4=BD=93=E5=92=8Cscalar=E7=B1=BB=E5=9E= =8B(=E4=B8=8D=E8=BF=87=E8=BF=99=E7=A7=8D=E6=83=85=E5=86=B5=E6=AF=94=E8=BE= =83=E5=B0=91=E8=A7=81). + + @SqlResultSetMapping(name=3D= "scalar", columns=3D@ColumnResult(name=3D"dimension")) +(a)NamedNativeQuery(name=3D"scalar", query=3D"select length*width as dimen= sion from SpaceShip", resultSetMapping=3D"scalar") + + =E6=9C=AC=E5=9C=B0=E6=9F=A5=E8=AF=A2=E4=B8=AD=E8=BF=98=E6=9C= =89=E5=8F=A6=E5=A4=96=E4=B8=80=E4=B8=AAhint=E5=B1=9E=E6=80=A7=EF=BC=9A + org.hibernate.callable. + =E8=BF=99=E4=B8=AA=E5=B1=9E=E6=80=A7=E7=9A=84=E5=B8=83=E5=B0=94=E5=8F= =98=E9=87=8F=E5=80=BC=E8=A1=A8=E6=98=8E=E8=BF=99=E4=B8=AA=E6=9F=A5=E8=AF=A2= =E6=98=AF=E5=90=A6=E6=98=AF=E4=B8=80=E4=B8=AA=E5=AD=98=E5=82=A8=E8=BF=87=E7= =A8=8B. + +
+ + + Hibernate=E7=8B=AC=E6=9C=89=E7=9A=84=E6=B3=A8=E8=A7=A3=E6=89=A9= =E5=B1=95 + + Hibernate 3.1 =E6=8F=90=E4=BE=9B=E4=BA=86=E5=A4=9A=E7=A7=8D=E9= =99=84=E5=8A=A0=E7=9A=84=E6=B3=A8=E8=A7=A3,=E8=BF=99=E4=BA=9B=E6=B3=A8=E8= =A7=A3=E5=8F=AF=E4=BB=A5=E4=B8=8EEJB3=E7=9A=84=E5=AE=9E=E4=BD=93=E6=B7=B7= =E5=90=88/=E5=8C=B9=E9=85=8D=E4=BD=BF=E7=94=A8. + =E4=BB=96=E4=BB=AC=E8=A2=AB=E8=AE=BE=E8=AE=A1=E6=88=90EJB3=E6=B3=A8=E8= =A7=A3=E7=9A=84=E8=87=AA=E7=84=B6=E6=89=A9=E5=B1=95. + + =E4=B8=BA=E4=BA=86=E5=BC=BA=E5=8C=96EJB3=E7=9A=84=E8=83=BD=E5=8A= =9B,Hibernate=E6=8F=90=E4=BE=9B=E4=BA=86=E4=B8=8E=E5=85=B6=E8=87=AA=E8=BA= =AB=E7=89=B9=E6=80=A7=E7=9B=B8=E5=90=BB=E5=90=88=E7=9A=84=E7=89=B9=E6=AE=8A= =E6=B3=A8=E8=A7=A3. + org.hibernate.annotations=E5=8C=85=E5=B7=B2=E5= =8C=85=E5=90=AB=E4=BA=86=E6=89=80=E6=9C=89=E7=9A=84=E8=BF=99=E4=BA=9B=E6=B3= =A8=E8=A7=A3=E6=89=A9=E5=B1=95. + + + =E5=AE=9E=E4=BD=93 + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=9C=A8EJB3=E8=A7=84=E8=8C=83=E6= =89=80=E8=83=BD=E6=8F=90=E4=BE=9B=E7=9A=84=E8=83=BD=E5=8A=9B=E4=B9=8B=E5=A4= =96,=E5=B0=B1Hibernate=E5=AF=B9=E5=AE=9E=E4=BD=93=E6=89=80=E5=81=9A=E7=9A= =84=E4=B8=80=E4=BA=9B=E6=93=8D=E4=BD=9C=E8=BF=9B=E8=A1=8C=E4=BC=98=E5=8C=96= . + + @org.hibernate.annotations.Entity + =E8=BF=BD=E5=8A=A0=E4=BA=86=E5=8F=AF=E8=83=BD=E9=9C=80=E8=A6=81=E7= =9A=84=E9=A2=9D=E5=A4=96=E7=9A=84=E5=85=83=E6=95=B0=E6=8D=AE, + =E8=80=8C=E8=BF=99=E4=BA=9B=E5=85=83=E6=95=B0=E6=8D=AE=E8=B6=85=E5= =87=BA=E4=BA=86=E6=A0=87=E5=87=86@Entity =E4=B8=AD=E6=89= =80=E5=AE=9A=E4=B9=89=E7=9A=84=E5=85=83=E6=95=B0=E6=8D=AE. = + + + mutable: =E6=AD=A4=E5=AE=9E=E4=BD=93=E6=98=AF=E5=90=A6=E4=B8= =BA=E5=8F=AF=E5=8F=98=E7=9A=84 + + + + dynamicInsert: =E7=94=A8=E5=8A=A8=E6=80=81SQL=E6=96=B0=E5=A2= =9E + + + + dynamicUpdate: =E7=94=A8=E5=8A=A8=E6=80=81SQL=E6=9B=B4=E6=96= =B0 + + + + selectBeforeUpdate: =E6=8C=87=E6=98=8EHibernate=E4=BB=8E=E4= =B8=8D=E8=BF=90=E8=A1=8CSQL UPDATE=E9=99=A4=E9=9D=9E=E8=83=BD=E7=A1=AE=E5= =AE=9A=E5=AF=B9=E8=B1=A1=E7=9A=84=E7=A1=AE=E5=B7=B2=E8=A2=AB=E4=BF=AE=E6=94= =B9 + + + + polymorphism: (=E6=8C=87=E5=87=BA)=E5=AE=9E=E4=BD=93=E5=A4=9A= =E6=80=81=E6=98=AFPolymorphismType.IMPLICIT(=E9=BB=98=E8=AE=A4)=E8=BF=98=E6= =98=AFPolymorphismType.EXPLICIT = + + + + persister:=E5=85=81=E8=AE=B8=E5=AF=B9=E9=BB=98=E8=AE=A4=E6=8C= =81=E4=B9=85=E5=AE=9E=E7=8E=B0(persister implementation)=E7=9A=84=E8=A6=86= =E7=9B=96 + = + + + optimisticLock: =E4=B9=90=E8=A7=82=E9=94=81=E7=AD=96=E7=95=A5= (OptimisticLockType.VERSION, OptimisticLockType.NONE, OptimisticLockType.DI= RTY=E6=88=96OptimisticLockType.ALL) + + + + + + + + @javax.persistence.Entity=E4=BB=8D=E6=98=AF=E5=BF=85=E9=80=89=E7=9A=84= (mandatory), + @org.hibernate.annotations.Entity=E4=B8=8D=E6=98=AF=E5=8F=96=E4=BB=A3= =E5=93=81. + + + + + =E4=BB=A5=E4=B8=8B=E6=98=AF=E4=B8=80=E4=BA=9B=E9=99=84=E5=8A= =A0=E7=9A=84Hibernate=E6=B3=A8=E8=A7=A3=E6=89=A9=E5=B1=95=EF=BC=9A + + @org.hibernate.annotations.BatchSize = + =E5=85=81=E8=AE=B8=E4=BD=A0=E5=AE=9A=E4=B9=89=E6=89=B9=E9=87=8F=E8=8E=B7= =E5=8F=96=E8=AF=A5=E5=AE=9E=E4=BD=93=E7=9A=84=E5=AE=9E=E4=BE=8B=E6=95=B0=E9= =87=8F(=E5=A6=82=EF=BC=9A@BatchSize(size=3D4)). + =E5=BD=93=E5=8A=A0=E8=BD=BD=E4=B8=80=E7=89=B9=E5=AE=9A=E7=9A=84=E5= =AE=9E=E4=BD=93=E6=97=B6,Hibernate=E5=B0=86=E5=8A=A0=E8=BD=BD=E5=9C=A8=E6= =8C=81=E4=B9=85=E4=B8=8A=E4=B8=8B=E6=96=87=E4=B8=AD=E6=9C=AA=E7=BB=8F=E5=88= =9D=E5=A7=8B=E5=8C=96=E7=9A=84=E5=90=8C=E7=B1=BB=E5=9E=8B=E5=AE=9E=E4=BD=93= ,=E7=9B=B4=E8=87=B3=E6=89=B9=E9=87=8F=E6=95=B0=E9=87=8F(=E4=B8=8A=E9=99=90)= . + + @org.hibernate.annotations.Proxy + =E5=AE=9A=E4=B9=89=E4=BA=86=E5=AE=9E=E4=BD=93=E7=9A=84=E5=BB=B6=E8= =BF=9F=E5=B1=9E=E6=80=A7.Lazy(=E9=BB=98=E8=AE=A4=E4=B8=BAtrue)=E5=AE=9A=E4= =B9=89=E4=BA=86=E7=B1=BB=E6=98=AF=E5=90=A6=E4=B8=BA=E5=BB=B6=E8=BF=9F(=E5= =8A=A0=E8=BD=BD). + proxyClassName=E6=98=AF=E7=94=A8=E6=9D=A5=E7=94=9F=E6=88=90=E4=BB=A3= =E7=90=86=E7=9A=84=E6=8E=A5=E5=8F=A3(=E9=BB=98=E8=AE=A4=E4=B8=BA=E8=AF=A5= =E7=B1=BB=E6=9C=AC=E8=BA=AB). + + @org.hibernate.annotations.Where + =E5=AE=9A=E4=B9=89=E4=BA=86=E5=BD=93=E8=8E=B7=E5=8F=96=E7=B1=BB=E5=AE=9E= =E4=BE=8B=E6=97=B6=E6=89=80=E7=94=A8=E7=9A=84SQL WHERE=E5=AD=90=E5=8F=A5(= =E8=AF=A5SQL WHERE=E5=AD=90=E5=8F=A5=E4=B8=BA=E5=8F=AF=E9=80=89). + + @org.hibernate.annotations.Check + =E5=AE=9A=E4=B9=89=E4=BA=86=E5=9C=A8DDL=E8=AF=AD=E5=8F=A5=E4=B8=AD= =E5=AE=9A=E4=B9=89=E7=9A=84=E5=90=88=E6=B3=95=E6=80=A7=E6=A3=80=E6=9F=A5=E7= =BA=A6=E6=9D=9F(=E8=AF=A5=E7=BA=A6=E6=9D=9F=E4=B8=BA=E5=8F=AF=E9=80=89). + + @OnDelete(action=3DOnDeleteAction.CASCADE) + =E5=AE=9A=E4=B9=89=E4=BA=8E=E8=A2=AB=E8=BF=9E=E6=8E=A5=E7=9A=84=E5= =AD=90=E7=B1=BB(joined subclass)=EF=BC=9A=E5=9C=A8=E5=88=A0=E9=99=A4=E6=97= =B6=E4=BD=BF=E7=94=A8SQL=E7=BA=A7=E8=BF=9E=E5=88=A0=E9=99=A4,=E8=80=8C=E9= =9D=9E=E9=80=9A=E5=B8=B8=E7=9A=84Hibernate=E5=88=A0=E9=99=A4=E6=9C=BA=E5=88= =B6. + + @Table(name=3D"tableName", indexes =3D { + @Index(name=3D"index1", columnNames=3D{"column1", "column2"} ) } ) + =E5=9C=A8tableName=E8=A1=A8=E7=9A=84=E5=88=97=E4=B8= =8A=E5=88=9B=E5=BB=BA=E5=AE=9A=E4=B9=89=E5=A5=BD=E7=9A=84=E7=B4=A2=E5=BC=95. + =E8=AF=A5=E6=B3=A8=E8=A7=A3=E5=8F=AF=E4=BB=A5=E8=A2=AB=E5=BA=94=E7=94= =A8=E4=BA=8E=E5=85=B3=E9=94=AE=E8=A1=A8=E6=88=96=E8=80=85=E6=98=AF=E5=85=B6= =E4=BB=96=E6=AC=A1=E8=A6=81=E7=9A=84=E8=A1=A8. + @Tables =E6=B3=A8=E8=A7=A3=E5=85=81=E8=AE=B8=E4= =BD=A0=E5=9C=A8=E4=B8=8D=E5=90=8C=E7=9A=84=E8=A1=A8=E4=B8=8A=E5=BA=94=E7=94= =A8=E7=B4=A2=E5=BC=95. + =E6=AD=A4=E6=B3=A8=E8=A7=A3=E9=A2=84=E6=9C=9F=E5=9C=A8=E4=BD=BF=E7= =94=A8 + @javax.persistence.Table=E6=88=96 + @javax.persistence.SecondaryTable=E7=9A=84=E5=9C= =B0=E6=96=B9=E4=B8=AD=E5=87=BA=E7=8E=B0. + + + + @org.hibernate.annotations.Table =E6=98=AF=E5=AF=B9 + @javax.persistence.Table=E7=9A=84=E8=A1=A5=E5= =85=85=E8=80=8C=E4=B8=8D=E6=98=AF=E5=AE=83=E7=9A=84=E6=9B=BF=E4=BB=A3=E5=93= =81. + =E7=89=B9=E5=88=AB=E6=98=AF=E5=BD=93=E4=BD=A0=E6=89=93=E7=AE=97=E6=94=B9= =E5=8F=98=E8=A1=A8=E5=90=8D=E7=9A=84=E9=BB=98=E8=AE=A4=E5=80=BC=E7=9A=84=E6= =97=B6=E5=80=99=EF=BC=8C=E4=BD=A0=E5=BF=85=E9=A1=BB=E4=BD=BF=E7=94=A8@javax.persistence.Table, + =E8=80=8C=E4=B8=8D=E6=98=AF@org.hibernate.annotations.Table. + + + @Entity +(a)BatchSize(size=3D5) +(a)org.hibernate.annotations.Entity( + selectBeforeUpdate =3D true, + dynamicInsert =3D true, dynamicUpdate =3D true, + optimisticLock =3D OptimisticLockType.ALL, + polymorphism =3D PolymorphismType.EXPLICIT) +(a)Where(clause=3D"1=3D1") +(a)org.hibernate.annotations.Table(name=3D"Forest", indexes =3D { @Index(n= ame=3D"idx", columnNames =3D { "name", "length" } ) } ) +public class Forest { ... }@Entity +(a)Inheritance( + strategy=3DInheritanceType.JOINED +) +public class Vegetable { ... } + +(a)Entity +(a)OnDelete(action=3DOnDeleteAction.CASCADE) +public class Carrot extends Vegetable { ... } + + + + =E6=A0=87=E8=AF=86=E7=AC=A6 + + @org.hibernate.annotations.GenericGenerator<= /literal> + =E5=85=81=E8=AE=B8=E4=BD=A0=E5=AE=9A=E4=B9=89=E4=B8=80=E4=B8=AAHiber= nate=E7=89=B9=E5=AE=9A=E7=9A=84id=E7=94=9F=E6=88=90=E5=99=A8. + + @Id @GeneratedValue(generator=3D"system-uuid") +(a)GenericGenerator(name=3D"system-uuid", strategy =3D "uuid") +public String getId() { + +(a)Id @GeneratedValue(generator=3D"hibseq") +(a)GenericGenerator(name=3D"hibseq", strategy =3D "seqhilo", + parameters =3D { + @Parameter(name=3D"max_lo", value =3D "5"), + @Parameter(name=3D"sequence", value=3D"heybabyhey") + } +) +public Integer getId() { + + strategy=E5=8F=AF=E4=BB=A5=E6=98=AFHibernate3=E7= =94=9F=E6=88=90=E5=99=A8=E7=AD=96=E7=95=A5=E7=9A=84=E7=AE=80=E7=A7=B0, + =E6=88=96=E8=80=85=E6=98=AF=E4=B8=80=E4=B8=AAIdentifierGenerat= or=E5=AE=9E=E7=8E=B0=E7=9A=84(=E5=B8=A6=E5=8C=85=E8=B7=AF=E5=BE= =84=E7=9A=84)=E5=85=A8=E9=99=90=E5=AE=9A=E7=B1=BB=E5=90=8D. + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87parameters=E5=B1=9E=E6=80=A7=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=BA=9B=E5=8F=82=E6=95=B0.<= /para> + + + + =E5=B1=9E=E6=80=A7 + + + =E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B + + =E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B=E6=98=AF=E6=A0=B9=E6=8D=AE@Id=E6=88=96@EmbeddedId + =E5=9C=A8=E5=AE=9E=E4=BD=93=E7=BB=A7=E6=89=BF=E5=B1=82=E6=AC=A1=E4=B8=AD= =E6=89=80=E5=A4=84=E7=9A=84=E4=BD=8D=E7=BD=AE=E6=8E=A8=E6=BC=94=E8=80=8C=E5= =BE=97=E7=9A=84.=E5=AD=90=E5=AE=9E=E4=BD=93(Sub-entities), + =E5=86=85=E5=B5=8C=E5=AF=B9=E8=B1=A1=E5=92=8C=E8=A2=AB=E6=98=A0=E5=B0=84= =E7=9A=84=E7=88=B6=E7=B1=BB=E5=9D=87=E7=BB=A7=E6=89=BF=E4=BA=86=E6=A0=B9=E5= =AE=9E=E4=BD=93(root entity)=E7=9A=84=E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B.<= /para> + + =E5=9C=A8Hibernate=E4=B8=AD,=E4=BD=A0=E5=8F=AF=E4=BB=A5=E6=8A=8A=E8= =AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B=E8=A6=86=E7=9B=96=E6=88=90=EF=BC=9A + + + + =E4=BD=BF=E7=94=A8=E5=AE=9A=E5=88=B6=E7=9A=84=E8=AE=BF= =E9=97=AE=E7=B1=BB=E5=9E=8B=E7=AD=96=E7=95=A5 + + + + =E4=BC=98=E5=8C=96=E7=B1=BB=E7=BA=A7=E6=88=96=E5=B1=9E= =E6=80=A7=E7=BA=A7=E7=9A=84=E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B + + + + =E4=B8=BA=E6=94=AF=E6=8C=81=E8=BF=99=E7=A7=8D=E8=A1=8C=E4=B8= =BA,Hibernate=E5=BC=95=E5=85=A5=E4=BA=86@AccessType=E6=B3=A8=E8=A7=A3.=E4= =BD=A0=E5=8F=AF=E4=BB=A5=E5=AF=B9=E4=BB=A5=E4=B8=8B=E5=85=83=E7=B4=A0=E5=AE= =9A=E4=B9=89=E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B=EF=BC=9A + + + + =E5=AE=9E=E4=BD=93 + + + + =E7=88=B6=E7=B1=BB + + + + =E5=8F=AF=E5=86=85=E5=B5=8C=E7=9A=84=E5=AF=B9=E8=B1=A1 + + + + =E5=B1=9E=E6=80=A7 + + + + =E8=A2=AB=E6=B3=A8=E8=A7=A3=E5=85=83=E7=B4=A0=E7=9A=84=E8=AE=BF=E9= =97=AE=E7=B1=BB=E5=9E=8B=E4=BC=9A=E8=A2=AB=E8=A6=86=E7=9B=96,=E8=8B=A5=E8= =A6=86=E7=9B=96=E6=98=AF=E5=9C=A8=E7=B1=BB=E4=B8=80=E7=BA=A7=E4=B8=8A,=E5= =88=99=E6=89=80=E6=9C=89=E7=9A=84=E5=B1=9E=E6=80=A7=E7=BB=A7=E6=89=BF=E8=AE= =BF=E9=97=AE=E7=B1=BB=E5=9E=8B. + =E5=AF=B9=E4=BA=8E=E6=A0=B9=E5=AE=9E=E4=BD=93,=E5=85=B6=E8=AE=BF=E9=97= =AE=E7=B1=BB=E5=9E=8B=E4=BC=9A=E8=A2=AB=E8=AE=A4=E4=B8=BA=E6=98=AF=E6=95=B4= =E4=B8=AA=E7=BB=A7=E6=89=BF=E5=B1=82=E6=AC=A1=E4=B8=AD=E7=9A=84=E7=BC=BA=E7= =9C=81=E8=AE=BE=E7=BD=AE(=E5=8F=AF=E5=9C=A8=E7=B1=BB=E6=88=96=E5=B1=9E=E6= =80=A7=E4=B8=80=E7=BA=A7=E8=A6=86=E7=9B=96). + + =E8=8B=A5=E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B=E8=A2=AB=E6=A0=87=E4= =BB=A5"property",=E5=88=99Hibernate=E4=BC=9A=E6=89=AB=E6=8F=8Fgetter=E6=96= =B9=E6=B3=95=E7=9A=84=E6=B3=A8=E8=A7=A3,=E8=8B=A5=E8=AE=BF=E9=97=AE=E7=B1= =BB=E5=9E=8B=E8=A2=AB=E6=A0=87=E4=BB=A5"field", + =E5=88=99=E6=89=AB=E6=8F=8F=E5=AD=97=E6=AE=B5=E7=9A=84=E6=B3=A8=E8=A7=A3= .=E5=90=A6=E5=88=99,=E6=89=AB=E6=8F=8F=E6=A0=87=E4=B8=BA@Id=E6=88=96@embedd= edId=E7=9A=84=E5=85=83=E7=B4=A0. + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E8=A6=86=E7=9B=96=E6=9F=90=E4=B8=AA=E5= =B1=9E=E6=80=A7(property)=E7=9A=84=E8=AE=BF=E9=97=AE=E7=B1=BB=E5=9E=8B,=E4= =BD=86=E6=98=AF=E5=8F=97=E6=B3=A8=E8=A7=A3=E7=9A=84=E5=85=83=E7=B4=A0=E5=B0= =86=E4=B8=8D=E5=8F=97=E5=BD=B1=E5=93=8D=EF=BC=9A + =E4=BE=8B=E5=A6=82=E4=B8=80=E4=B8=AA=E5=85=B7=E6=9C=89field=E8=AE=BF=E9= =97=AE=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=AE=9E=E4=BD=93,(=E6=88=91=E4=BB=AC)=E5= =8F=AF=E4=BB=A5=E5=B0=86=E6=9F=90=E4=B8=AA=E5=AD=97=E6=AE=B5=E6=A0=87=E6=B3= =A8=E4=B8=BA @AccessType("property"), + =E5=88=99=E8=AF=A5=E5=AD=97=E6=AE=B5=E7=9A=84=E8=AE=BF=E9=97=AE=E7=B1= =BB=E5=9E=8B=E9=9A=8F=E4=B9=8B=E5=B0=86=E6=88=90=E4=B8=BAproperty,=E4=BD=86= =E6=98=AF=E5=85=B6=E4=BB=96=E5=AD=97=E6=AE=B5=E4=B8=8A=E4=BE=9D=E7=84=B6=E9= =9C=80=E8=A6=81=E6=90=BA=E5=B8=A6=E6=B3=A8=E8=A7=A3. + + =E8=8B=A5=E7=88=B6=E7=B1=BB=E6=88=96=E5=8F=AF=E5=86=85=E5=B5=8C=E7= =9A=84=E5=AF=B9=E8=B1=A1=E6=B2=A1=E6=9C=89=E8=A2=AB=E6=B3=A8=E8=A7=A3,=E5= =88=99=E4=BD=BF=E7=94=A8=E6=A0=B9=E5=AE=9E=E4=BD=93=E7=9A=84=E8=AE=BF=E9=97= =AE=E7=B1=BB=E5=9E=8B(=E5=8D=B3=E4=BD=BF=E5=B7=B2=E7=BB=8F=E5=9C=A8=E9=9D= =9E=E7=9B=B4=E7=B3=BB=E7=88=B6=E7=B1=BB=E6=88=96=E5=8F=AF=E5=86=85=E5=B5=8C= =E5=AF=B9=E8=B1=A1=E4=B8=8A=E5=AE=9A=E4=B9=89=E4=BA=86=E8=AE=BF=E9=97=AE=E7= =B1=BB=E5=9E=8B). + =E6=AD=A4=E6=97=B6=E4=BF=84=E7=BD=97=E6=96=AF=E5=A5=97=E5=A8=83(Russian= doll)=E5=8E=9F=E7=90=86=E5=B0=B1=E4=B8=8D=E5=86=8D=E9=80=82=E7=94=A8.(=E8= =AF=91=E6=B3=A8=EF=BC=9A=E4=BF=84=E7=BD=97=E6=96=AF=E5=A5=97=E5=A8=83(=D0= =BC=D0=B0=D1=82=D1=80=D1=91=D1=88=D0=BA=D0=B0=E6=88=96 =D0=BC=D0=B0=D1=82= =D1=80=D0=B5=D1=88=D0=BA=D0=B0)=E6=98=AF=E4=BF=84=E7=BD=97=E6=96=AF=E7=89= =B9=E4=BA=A7=E6=9C=A8=E5=88=B6=E7=8E=A9=E5=85=B7, + =E4=B8=80=E8=88=AC=E7=94=B1=E5=A4=9A=E4=B8=AA=E4=B8=80=E6=A0=B7=E5=9B= =BE=E6=A1=88=E7=9A=84=E7=A9=BA=E5=BF=83=E6=9C=A8=E5=A8=83=E5=A8=83=E4=B8=80= =E4=B8=AA=E5=A5=97=E4=B8=80=E4=B8=AA=E7=BB=84=E6=88=90,=E6=9C=80=E5=A4=9A= =E5=8F=AF=E8=BE=BE=E5=8D=81=E5=A4=9A=E4=B8=AA,=E9=80=9A=E5=B8=B8=E4=B8=BA= =E5=9C=86=E6=9F=B1=E5=BD=A2,=E5=BA=95=E9=83=A8=E5=B9=B3=E5=9D=A6=E5=8F=AF= =E4=BB=A5=E7=9B=B4=E7=AB=8B.) + +@Entity +public class Person implements Serializable { + @Id @GeneratedValue //access type field + Integer id; + + @Embedded + @AttributeOverrides({ + @AttributeOverride(name =3D "iso2", column =3D @Column(name =3D "bornI= so2")), + @AttributeOverride(name =3D "name", column =3D @Column(name =3D "bornC= ountryName")) + }) + Country bornIn; +} + +(a)Embeddable +@AccessType("property") //override acce= ss type for all properties in Country +public class Country implements Serializable { + private String iso2; + private String name; + + public String getIso2() { + return iso2; + } + + public void setIso2(String iso2) { + this.iso2 =3D iso2; + } + + @Column(name =3D "countryName") + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} + + + + + =E5=85=AC=E5=BC=8F + + =E6=9C=89=E6=97=B6=E5=80=99,=E4=BD=A0=E6=83=B3=E8=AE=A9=E6=95=B0= =E6=8D=AE=E5=BA=93,=E8=80=8C=E9=9D=9EJVM,=E6=9D=A5=E6=9B=BF=E4=BD=A0=E5=AE= =8C=E6=88=90=E4=B8=80=E4=BA=9B=E8=AE=A1=E7=AE=97,=E4=B9=9F=E5=8F=AF=E8=83= =BD=E6=83=B3=E5=88=9B=E5=BB=BA=E6=9F=90=E7=A7=8D=E8=99=9A=E6=8B=9F=E5=88=97. + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8SQL=E7=89=87=E6=AE=B5(=E4= =BA=A6=E7=A7=B0=E4=B8=BA=E5=85=AC=E5=BC=8F),=E8=80=8C=E4=B8=8D=E6=98=AF=E5= =B0=86=E5=B1=9E=E6=80=A7=E6=98=A0=E5=B0=84=E5=88=B0(=E7=89=A9=E7=90=86)=E5= =88=97. =E8=BF=99=E7=A7=8D=E5=B1=9E=E6=80=A7=E6=98=AF=E5=8F=AA=E8=AF=BB=E7= =9A=84(=E5=B1=9E=E6=80=A7=E5=80=BC=E7=94=B1=E5=85=AC=E6=B1=82=E5=BE=97). + = + @Formula("obj_length * obj_height * obj_width") + public long getObjectVolume() + = + = + SQL=E7=89=87=E6=AE=B5=E5=8F=AF=E4=BB=A5=E6=98=AF=E4=BB=BB=E6=84=8F= =E5=A4=8D=E6=9D=82=E7=9A=84,=E7=94=9A=E8=87=B3=E5=8F=AF=E5=8C=85=E5=90=AB= =E5=AD=90=E6=9F=A5=E8=AF=A2. + + + + =E7=B1=BB=E5=9E=8B + + @org.hibernate.annotations.Type + =E8=A6=86=E7=9B=96=E4=BA=86Hibernate=E6=89=80=E7=94=A8=E7=9A=84=E9=BB=98= =E8=AE=A4=E7=B1=BB=E5=9E=8B=EF=BC=9A=E8=BF=99=E9=80=9A=E5=B8=B8=E4=B8=8D=E6= =98=AF=E5=BF=85=E9=A1=BB=E7=9A=84,=E5=9B=A0=E4=B8=BA=E7=B1=BB=E5=9E=8B=E5= =8F=AF=E4=BB=A5=E7=94=B1Hibernate=E6=AD=A3=E7=A1=AE=E6=8E=A8=E5=BE=97. + =E5=85=B3=E4=BA=8EHibernate=E7=B1=BB=E5=9E=8B=E7=9A=84=E8=AF=A6=E7=BB=86= =E4=BF=A1=E6=81=AF,=E8=AF=B7=E5=8F=82=E8=80=83Hibernate=E4=BD=BF=E7=94=A8= =E6=89=8B=E5=86=8C. + + @org.hibernate.annotations.TypeDef =E5=92= =8C + @org.hibernate.annotations.TypeDefs=E5=85=81=E8=AE= =B8=E4=BD=A0=E6=9D=A5=E5=A3=B0=E6=98=8E=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89. + =E8=BF=99=E4=BA=9B=E6=B3=A8=E8=A7=A3=E8=A2=AB=E7=BD=AE=E4=BA=8E=E7=B1=BB= =E6=88=96=E5=8C=85=E4=B8=80=E7=BA=A7.=E6=B3=A8=E6=84=8F,=E5=AF=B9session fa= ctory=E6=9D=A5=E8=AF=B4, + =E8=BF=99=E4=BA=9B=E5=AE=9A=E4=B9=89=E5=B0=86=E6=98=AF=E5=85=A8=E5=B1=80= =E7=9A=84(=E5=8D=B3=E4=BD=BF=E5=AE=9A=E4=B9=89=E4=BA=8E=E7=B1=BB=E4=B8=80= =E7=BA=A7),=E5=B9=B6=E4=B8=94=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89=E5=BF=85= =E9=A1=BB=E5=85=88=E4=BA=8E=E4=BB=BB=E4=BD=95=E4=BD=BF=E7=94=A8. + + @TypeDefs( + { + @TypeDef( + name=3D"caster", + typeClass =3D CasterStringType.class, + parameters =3D { + @Parameter(name=3D"cast", value=3D"lower") + } + ) + } +) +package org.hibernate.test.annotations.entity; + +... +public class Forest { + @Type(type=3D"caster") + public String getSmallText() { + ... +} + + + =E5=BD=93=E4=BD=BF=E7=94=A8=E7=BB=84=E5=90=88=E7=9A=84=E7=94= =A8=E6=88=B7=E8=87=AA=E5=AE=9A=E4=B9=89=E7=B1=BB=E5=9E=8B=E6=97=B6,=E4=BD= =A0=E5=BF=85=E9=A1=BB=E8=87=AA=E5=B7=B1=E8=A1=A8=E7=A4=BA=E5=88=97=E7=9A=84= =E5=AE=9A=E4=B9=89. +@Columns=E5=B0=B1=E6=98=AF=E4=B8=BA=E4=BA=86=E6=AD=A4= =E7=9B=AE=E7=9A=84=E8=80=8C=E5=BC=95=E5=85=A5=E7=9A=84. +@Type(type=3D"org.hibernate.test.annotations.entity.Moneta= ryAmountUserType") +(a)Columns(columns =3D { + @Column(name=3D"r_amount"), + @Column(name=3D"r_currency") +}) +public MonetaryAmount getAmount() { + return amount; +} + + +public class MonetaryAmount implements Serializable { + private BigDecimal amount; + private Currency currency; + ... +} + + + + =E7=B4=A2=E5=BC=95 + + =E9=80=9A=E8=BF=87=E5=9C=A8=E5=88=97=E5=B1=9E=E6=80=A7(prope= rty)=E4=B8=8A=E4=BD=BF=E7=94=A8@Index=E6=B3=A8=E8=A7=A3, + =E5=8F=AF=E4=BB=A5=E5=9C=A8=E7=89=B9=E5=AE=9A=E5=88=97=E4=B8=8A=E5=AE=9A= =E4=B9=89=E7=B4=A2=E5=BC=95,columnNames=E5=B1=9E=E6=80=A7(attribute)=E5=B0= =86=E9=9A=8F=E4=B9=8B=E8=A2=AB=E5=BF=BD=E7=95=A5. + + @Column(secondaryTable=3D"Cat1") +(a)Index(name=3D"story1index") +public String getStoryPart1() { + return storyPart1; +} + + + + @Parent + + =E5=9C=A8=E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1=E5=86=85=E9= =83=A8,=E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=9C=A8=E9=82=A3=E4=BA=9B=E6=8C=87=E5= =90=91=E8=AF=A5=E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1=E6=89=80=E5=B1= =9E=E5=85=83=E7=B4=A0=E7=9A=84=E5=B1=9E=E6=80=A7=E4=B8=8A=E5=AE=9A=E4=B9=89= =E8=AF=A5=E6=B3=A8=E8=A7=A3. + + @Entity +public class Person { + @Embeddable public Address address; + ... +} + +(a)Embeddable +public class Address { + @Parent public Person owner; + ... +} + + +person =3D=3D person.address.owner + + + + =E7=94=9F=E6=88=90=E7=9A=84=E5=B1=9E=E6=80=A7 + + + =E6=9F=90=E4=BA=9B=E5=B1=9E=E6=80=A7=E5=8F=AF=E4=BB=A5=E5=9C=A8=E5=AF=B9= =E6=95=B0=E6=8D=AE=E5=BA=93=E5=81=9A=E6=8F=92=E5=85=A5=E6=88=96=E6=9B=B4=E6= =96=B0=E6=93=8D=E4=BD=9C=E7=9A=84=E6=97=B6=E5=80=99=E7=94=9F=E6=88=90. + Hibernate=E8=83=BD=E5=A4=9F=E5=A4=84=E7=90=86=E8=BF=99=E6=A0=B7=E7=9A=84= =E5=B1=9E=E6=80=A7,=E5=B9=B6=E8=A7=A6=E5=8F=91=E4=B8=80=E4=B8=AA=E5=90=8E= =E7=BB=AD=E7=9A=84=E6=9F=A5=E8=AF=A2=E6=9D=A5=E8=AF=BB=E5=8F=96=E8=BF=99=E4= =BA=9B=E5=B1=9E=E6=80=A7. + + + @Entity +public class Antenna { + @Id public Integer id; + @Generated(GenerationTime.ALWAYS) @Column(insertable =3D false, updata= ble =3D false) + public String longitude; + + @Generated(GenerationTime.INSERT) @Column(insertable =3D false) + public String latitude; +} + + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=B0=86=E5=B1=9E=E6=80=A7=E6=B3=A8=E8=A7=A3= =E4=B8=BA@Generated. + =E4=BD=86=E6=98=AF=E4=BD=A0=E8=A6=81=E6=B3=A8=E6=84=8Finsertability=E5= =92=8Cupdatability=E4=B8=8D=E8=A6=81=E5=92=8C=E4=BD=A0=E9=80=89=E6=8B=A9=E7= =9A=84=E7=94=9F=E6=88=90=E7=AD=96=E7=95=A5=E5=86=B2=E7=AA=81. + =E5=A6=82=E6=9E=9C=E9=80=89=E6=8B=A9=E4=BA=86GenerationTime.INSERT,=E8= =AF=A5=E5=B1=9E=E6=80=A7=E4=B8=8D=E8=83=BD=E5=8C=85=E5=90=ABinsertable=E5= =88=97, + =E5=A6=82=E6=9E=9C=E9=80=89=E6=8B=A9=E4=BA=86GenerationTime.ALWAYS,=E8= =AF=A5=E5=B1=9E=E6=80=A7=E4=B8=8D=E8=83=BD=E5=8C=85=E5=90=ABinsertable=E5= =92=8Cupdatable=E5=88=97. + + @Version=E5=B1=9E=E6=80=A7=E4=B8=8D=E5=8F= =AF=E4=BB=A5=E4=B8=BA + @Generated(INSERT)(=E8=AE=BE=E8=AE=A1=E6=97=B6)= , =E5=8F=AA=E8=83=BD=E6=98=AF + NEVER=E6=88=96ALWAYS. + + + + + + =E7=BB=A7=E6=89=BF + + SINGLE_TABLE =E6=98=AF=E4=B8=AA=E5=8A=9F=E8=83=BD=E5=BC=BA=E5= =A4=A7=E7=9A=84=E7=AD=96=E7=95=A5,=E4=BD=86=E6=9C=89=E6=97=B6,=E7=89=B9=E5= =88=AB=E5=AF=B9=E9=81=97=E7=95=99=E7=B3=BB=E7=BB=9F=E8=80=8C=E8=A8=80, + =E6=98=AF=E6=97=A0=E6=B3=95=E5=8A=A0=E5=85=A5=E4=B8=80=E4=B8=AA=E9=A2=9D= =E5=A4=96=E7=9A=84=E8=BE=A8=E5=88=AB=E7=AC=A6=E5=88=97. + =E7=94=B1=E6=AD=A4,Hibernate=E5=BC=95=E5=85=A5=E4=BA=86=E8=BE=A8=E5=88= =AB=E7=AC=A6=E5=85=AC=E5=BC=8F(discriminator formula)=E7=9A=84=E6=A6=82=E5= =BF=B5=EF=BC=9A + @DiscriminatorFormula=E6=98=AF@Discriminator= Column=E7=9A=84=E6=9B=BF=E4=BB=A3=E5=93=81, + =E5=AE=83=E4=BD=BF=E7=94=A8SQL=E7=89=87=E6=AE=B5=E4=BD=9C=E4=B8=BA=E8=BE= =A8=E5=88=AB=E7=AC=A6=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=E7=9A=84=E5=85=AC= =E5=BC=8F( =E4=B8=8D=E9=9C=80=E8=A6=81=E6=9C=89=E4=B8=80=E4=B8=AA=E4=B8=93= =E9=97=A8=E7=9A=84=E5=AD=97=E6=AE=B5). + + @Entity +(a)DiscriminatorForumla("case when forest_type is null then 0 else forest_= type end") +public class Forest { ... } + + + + =E5=85=B3=E4=BA=8E=E5=8D=95=E4=B8=AA=E5=85=B3=E8=81=94=E5=85= =B3=E7=B3=BB=E7=9A=84=E6=B3=A8=E8=A7=A3 + + =E9=BB=98=E8=AE=A4=E6=83=85=E5=86=B5=E4=B8=8B,=E5=BD=93=E9=A2= =84=E6=9C=9F=E7=9A=84=E8=A2=AB=E5=85=B3=E8=81=94=E5=85=83=E7=B4=A0=E4=B8=8D= =E5=9C=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=AD(=E5=85=B3=E4=B9=8E=E5=85=B3= =E8=81=94=E5=88=97=E7=9A=84=E9=94=99=E8=AF=AFid),=E8=87=B4=E4=BD=BFHiberant= e=E6=97=A0=E6=B3=95=E8=A7=A3=E5=86=B3=E5=85=B3=E8=81=94=E6=80=A7=E9=97=AE= =E9=A2=98=E6=97=B6,Hibernate=E5=B0=B1=E4=BC=9A=E6=8A=9B=E5=87=BA=E5=BC=82= =E5=B8=B8. + =E8=BF=99=E5=AF=B9=E9=81=97=E7=95=99schema=E5=92=8C=E5=8E=86=E7=BB= =8F=E6=8B=99=E5=8A=A3=E7=BB=B4=E6=8A=A4=E7=9A=84schema=E8=80=8C=E8=A8=80,= =E8=BF=99=E6=88=96=E6=9C=89=E8=AE=B8=E5=A4=9A=E4=B8=8D=E4=BE=BF. + =E6=AD=A4=E6=97=B6,=E4=BD=A0=E5=8F=AF=E7=94=A8 @NotFound =E6=B3=A8=E8=A7=A3=E8=AE=A9Hibernate=E7=95=A5=E8=BF=87=E8=BF=99=E6= =A0=B7=E7=9A=84=E5=85=83=E7=B4=A0=E8=80=8C=E4=B8=8D=E6=98=AF=E6=8A=9B=E5=87= =BA=E5=BC=82=E5=B8=B8. + =E8=AF=A5=E6=B3=A8=E8=A7=A3=E5=8F=AF=E7=94=A8=E4=BA=8E @One= ToOne (=E6=9C=89=E5=A4=96=E9=94=AE)=E3=80=81 @ManyToOne= =E3=80=81 = + @OneToMany =E6=88=96 @ManyToMany =E5=85=B3=E8=81=94. + + @Entity +public class Child { + ... + @ManyToOne + @NotFound(action=3DNotFoundAction.IGNORE) + public Parent getParent() { ... } + ... +} + + + =E6=9C=89=E6=97=B6=E5=80=99=E5=88=A0=E9=99=A4=E6=9F=90=E5=AE=9E=E4=BD= =93=E7=9A=84=E6=97=B6=E5=80=99=E9=9C=80=E8=A6=81=E8=A7=A6=E5=8F=91=E6=95=B0= =E6=8D=AE=E5=BA=93=E7=9A=84=E7=BA=A7=E8=81=94=E5=88=A0=E9=99=A4. + + @Entity +public class Child { + ... + @ManyToOne + @OnDelete(action=3DOnDeleteAction.CASCADE) + public Parent getParent() { ... } + ... +} + + =E4=B8=8A=E9=9D=A2=E8=BF=99=E4=B8=AA=E4=BE=8B=E5=AD=90=E4=B8= =AD,Hibernate=E5=B0=86=E7=94=9F=E6=88=90=E4=B8=80=E4=B8=AA=E6=95=B0=E6=8D= =AE=E5=BA=93=E7=BA=A7=E7=9A=84=E7=BA=A7=E8=81=94=E5=88=A0=E9=99=A4=E7=BA=A6= =E6=9D=9F. + + + =E5=BB=B6=E8=BF=9F=E9=80=89=E9=A1=B9=E5=92=8C=E8=8E=B7=E5= =8F=96=E6=A8=A1=E5=BC=8F + + + EJB3=E4=B8=BA=E5=BB=B6=E8=BF=9F=E5=8A=A0=E8=BD=BD=E5=92=8C=E8=8E=B7=E5= =8F=96=E6=A8=A1=E5=BC=8F=E6=8F=90=E4=BE=9B=E4=BA=86fetch= =E9=80=89=E9=A1=B9,=E8=80=8CHibernate + =E8=BF=99=E6=96=B9=E9=9D=A2=E6=8F=90=E4=BE=9B=E4=BA=86=E6=9B=B4=E4=B8=B0= =E5=AF=8C=E7=9A=84=E9=80=89=E9=A1=B9=E9=9B=86.=E4=B8=BA=E4=BA=86=E6=9B=B4= =E5=A5=BD=E7=9A=84=E8=B0=83=E6=95=B4=E5=BB=B6=E8=BF=9F=E5=8A=A0=E8=BD=BD=E5= =92=8C=E8=8E=B7=E5=8F=96=E7=AD=96=E7=95=A5,Hibernate=E5=BC=95=E5=85=A5=E4= =BA=86 + =E4=B8=80=E4=BA=9B=E9=99=84=E5=8A=A0=E7=9A=84=E6=B3=A8=E8=A7=A3: + + + + @LazyToOne: =E5=AE=9A=E4=B9=89=E4=BA= =86 + @ManyToOne =E5=92=8C @OneToOne + =E5=85=B3=E8=81=94=E7=9A=84=E5=BB=B6=E8=BF=9F=E9=80=89=E9=A1= =B9. LazyToOneOption =E5=8F=AF=E4=BB=A5=E6=98=AF + PROXY (=E4=BE=8B=E5=A6=82:=E5=9F=BA=E4=BA= =8E=E4=BB=A3=E7=90=86=E7=9A=84=E5=BB=B6=E8=BF=9F=E5=8A=A0=E8=BD=BD), + NO_PROXY (=E4=BE=8B=E5=A6=82:=E5=9F=BA=E4= =BA=8E=E5=AD=97=E8=8A=82=E7=A0=81=E5=A2=9E=E5=BC=BA=E7=9A=84=E5=BB=B6=E8=BF= =9F=E5=8A=A0=E8=BD=BD - =E6=B3=A8=E6=84=8F=E9=9C=80=E8=A6=81=E5=9C=A8=E6=9E= =84=E5=BB=BA=E6=9C=9F=E5=A4=84=E7=90=86=E5=AD=97=E8=8A=82=E7=A0=81) + =E5=92=8C FALSE (=E9=9D=9E=E5=BB=B6=E8=BF= =9F=E5=8A=A0=E8=BD=BD=E7=9A=84=E5=85=B3=E8=81=94) + + + + @LazyCollection: =E5=AE=9A=E4=B9=89= =E4=BA=86 + @ManyToMany=E5=92=8C + @OneToMany =E5=85=B3=E8=81=94=E7=9A=84=E5= =BB=B6=E8=BF=9F=E9=80=89=E9=A1=B9. LazyCollectionOption + =E5=8F=AF=E4=BB=A5=E6=98=AFTRUE (=E9=9B=86= =E5=90=88=E5=85=B7=E6=9C=89=E5=BB=B6=E8=BF=9F=E6=80=A7,=E5=8F=AA=E6=9C=89= =E5=9C=A8=E8=AE=BF=E9=97=AE=E7=9A=84=E6=97=B6=E5=80=99=E6=89=8D=E5=8A=A0=E8= =BD=BD), = + EXTRA (=E9=9B=86=E5=90=88=E5=85=B7=E6=9C=89=E5=BB=B6= =E8=BF=9F=E6=80=A7,=E5=B9=B6=E4=B8=94=E6=89=80=E6=9C=89=E7=9A=84=E6=93=8D= =E4=BD=9C=E9=83=BD=E4=BC=9A=E5=B0=BD=E9=87=8F=E9=81=BF=E5=85=8D=E5=8A=A0=E8= =BD=BD=E9=9B=86=E5=90=88, + =E5=AF=B9=E4=BA=8E=E4=B8=80=E4=B8=AA=E5=B7=A8=E5=A4=A7=E7=9A=84=E9=9B= =86=E5=90=88=E7=89=B9=E5=88=AB=E6=9C=89=E7=94=A8,=E5=9B=A0=E4=B8=BA=E8=BF= =99=E6=A0=B7=E7=9A=84=E9=9B=86=E5=90=88=E4=B8=AD=E7=9A=84=E5=85=83=E7=B4=A0= =E6=B2=A1=E6=9C=89=E5=BF=85=E8=A6=81=E5=85=A8=E9=83=A8=E5=8A=A0=E8=BD=BD)= =E5=92=8C FALSE + (=E9=9D=9E=E5=BB=B6=E8=BF=9F=E5=8A=A0=E8=BD=BD=E7=9A=84=E5=85= =B3=E8=81=94) + + + + @Fetch: = + =E5=AE=9A=E4=B9=89=E4=BA=86=E5=8A=A0=E8=BD=BD=E5=85=B3=E8=81=94=E5=85= =B3=E7=B3=BB=E7=9A=84=E8=8E=B7=E5=8F=96=E7=AD=96=E7=95=A5. FetchMo= de =E5=8F=AF=E4=BB=A5=E6=98=AF + SELECT (=E5=9C=A8=E9=9C=80=E8=A6=81=E5=8A= =A0=E8=BD=BD=E5=85=B3=E8=81=94=E7=9A=84=E6=97=B6=E5=80=99=E8=A7=A6=E5=8F=91= select=E6=93=8D=E4=BD=9C), = + SUBSELECT + (=E5=8F=AA=E5=AF=B9=E9=9B=86=E5=90=88=E6=9C=89=E6=95=88,=E4=BD= =BF=E7=94=A8=E4=BA=86=E5=AD=90=E6=9F=A5=E8=AF=A2=E7=AD=96=E7=95=A5,=E8=AF= =A6=E6=83=85=E5=8F=82=E8=80=83Hibernate=E5=8F=82=E8=80=83=E6=96=87=E6=A1=A3= ) or = + JOIN (=E5=9C=A8=E5=8A=A0=E8=BD=BD=E4=B8=BB=E5=AE=9E= =E4=BD=93(owner entity)=E7=9A=84=E6=97=B6=E5=80=99=E4=BD=BF=E7=94=A8SQL JOI= N=E6=9D=A5=E5=8A=A0=E8=BD=BD=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB). + JOIN =E5=B0=86=E8=A6=86=E5=86=99=E4=BB=BB= =E4=BD=95=E5=BB=B6=E8=BF=9F=E5=B1=9E=E6=80=A7 = + (=E9=80=9A=E8=BF=87JOIN=E7=AD=96=E7=95=A5=E5=8A=A0= =E8=BD=BD=E7=9A=84=E5=85=B3=E8=81=94=E5=B0=86=E4=B8=8D=E5=86=8D=E5=85=B7=E6= =9C=89=E5=BB=B6=E8=BF=9F=E6=80=A7). + + + + The Hibernate annotations overrides the EJB3 fetching + options. + + Hibernate=E6=B3=A8=E8=A7=A3=E8=A6=86=E5=86=99=E4=BA=86EJB3=E6=8F= =90=E4=BE=9B=E7=9A=84=E8=8E=B7=E5=8F=96(fetch)=E9=80=89=E9=A1=B9. + + + =E5=BB=B6=E8=BF=9F=E5=92=8C=E8=8E=B7=E5=8F=96=E9=80=89=E9= =A1=B9=E7=9A=84=E7=AD=89=E6=95=88=E6=B3=A8=E8=A7=A3 + + + + + Annotations + + Lazy + + Fetch + + + + + + @[One|Many]ToOne](fetch=3DFetchType.LAZY) + + @LazyToOne(PROXY) + + @Fetch(SELECT) + + + + @[One|Many]ToOne](fetch=3DFetchType.EAGER) + + @LazyToOne(FALSE) + + @Fetch(JOIN) + + + + @ManyTo[One|Many](fetch=3DFetchType.LAZY) + + @LazyCollection(TRUE) + + @Fetch(SELECT) + + + + @ManyTo[One|Many](fetch=3DFetchType.EAGER) + + @LazyCollection(FALSE) + + @Fetch(JOIN) + + + +
+
+ + +
+ + + =E5=85=B3=E4=BA=8E=E9=9B=86=E5=90=88=E7=B1=BB=E5=9E=8B=E7=9A= =84=E6=B3=A8=E8=A7=A3 + + + =E5=8F=82=E6=95=B0=E6=B3=A8=E8=A7=A3 + + =E4=BB=A5=E4=B8=8B=E6=98=AF=E5=8F=AF=E8=83=BD=E7=9A=84=E8=AE= =BE=E7=BD=AE=E6=96=B9=E5=BC=8F + + =E7=94=A8@BatchSizebatch=E8=AE=BE=E7=BD=AE=E9=9B=86=E5=90= =88=E7=9A=84batch=E5=A4=A7=E5=B0=8F = + + + + =E7=94=A8@Where=E6=B3=A8=E8=A7=A3=E8=AE=BE=E7=BD=AEWhere=E5= =AD=90=E5=8F=A5 + + + + =E7=94=A8=E6=B3=A8=E8=A7=A3@Check=E6=9D=A5=E8=AE=BE=E7=BD= =AEcheck=E5=AD=90=E5=8F=A5 + + + + =E7=94=A8=E6=B3=A8=E8=A7=A3@OrderBy=E6=9D=A5=E8=AE=BE=E7=BD= =AESQL=E7=9A=84order by=E5=AD=90=E5=8F=A5 + + + + =E5=88=A9=E7=94=A8@OnDelete(action=3DOnDeleteAction.CASCADE= ) =E6=B3=A8=E8=A7=A3=E8=AE=BE=E7=BD=AE=E7=BA=A7=E8=BF=9E=E5=88=A0=E9=99=A4= =E7=AD=96=E7=95=A5 + + + + =E4=BD=A0=E4=B9=9F=E5=8F=AF=E4=BB=A5=E5=88=A9=E7=94=A8@Sort=E6=B3=A8=E8=A7=A3=E5=AE=9A=E4=B9=89=E4=B8=80=E4=B8=AA=E6= =8E=92=E5=BA=8F=E6=AF=94=E8=BE=83=E5=99=A8(sort comparator), + =E8=A1=A8=E6=98=8E=E5=B8=8C=E6=9C=9B=E7=9A=84=E6=AF=94=E8=BE=83=E5=99=A8= =E7=B1=BB=E5=9E=8B,=E6=97=A0=E5=BA=8F=E3=80=81=E8=87=AA=E7=84=B6=E9=A1=BA= =E5=BA=8F=E6=88=96=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8E=92=E5=BA=8F,=E4=B8=89= =E8=80=85=E6=8B=A9=E4=B8=80.=E8=8B=A5=E4=BD=A0=E6=83=B3=E7=94=A8=E4=BD=A0= =E8=87=AA=E5=B7=B1=E5=AE=9E=E7=8E=B0=E7=9A=84comparator, + =E4=BD=A0=E8=BF=98=E9=9C=80=E8=A6=81=E5=88=A9=E7=94=A8comparato= r=E5=B1=9E=E6=80=A7(attribute)=E6=8C=87=E6=98=8E=E5=AE=9E=E7=8E= =B0=E7=B1=BB. + + @OneToMany(cascade=3DCascadeType.ALL, fetch=3D= FetchType.EAGER) + @JoinColumn(name=3D"CUST_ID") + @Sort(type =3D SortType.COMPARATOR, comparator =3D TicketComparator.cl= ass) + @Where(clause=3D"1=3D1") + @OnDelete(action=3DOnDeleteAction.CASCADE) + public SortedSet<Ticket> getTickets() { + return tickets; + } + + =E5=85=B3=E4=BA=8E=E8=BF=99=E4=BA=9B=E6=B3=A8=E8=A7=A3=E6=9B= =B4=E8=AF=A6=E7=BB=86=E7=9A=84=E4=BF=A1=E6=81=AF,=E8=AF=B7=E5=8F=82=E9=98= =85=E6=AD=A4=E5=89=8D=E7=9A=84=E6=8F=8F=E8=BF=B0. + + + + + =E6=9B=B4=E5=A4=9A=E7=9A=84=E9=9B=86=E5=90=88=E7=B1=BB=E5= =9E=8B + + =E6=AF=94EJB3=E6=9B=B4=E8=83=9C=E4=B8=80=E7=AD=B9=E7=9A=84= =E6=98=AF,Hibernate Annotations=E6=94=AF=E6=8C=81=E7=9C=9F=E6=AD=A3=E7=9A= =84 + List=E5=92=8CArray. + =E6=98=A0=E5=B0=84=E9=9B=86=E5=90=88=E7=9A=84=E6=96=B9=E5=BC=8F=E5=92= =8C=E4=BB=A5=E5=89=8D=E5=AE=8C=E5=85=A8=E4=B8=80=E6=A0=B7,=E5=8F=AA=E4=B8= =8D=E8=BF=87=E8=A6=81=E6=96=B0=E5=A2=9E@IndexColumn=E6= =B3=A8=E8=A7=A3. + =E8=AF=A5=E6=B3=A8=E8=A7=A3=E5=85=81=E8=AE=B8=E4=BD=A0=E6=8C=87=E6=98= =8E=E5=AD=98=E6=94=BE=E7=B4=A2=E5=BC=95=E5=80=BC=E7=9A=84=E5=AD=97=E6=AE=B5= .=E4=BD=A0=E8=BF=98=E5=8F=AF=E4=BB=A5=E5=AE=9A=E4=B9=89=E4=BB=A3=E8=A1=A8= =E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=AD=E9=A6=96=E4=B8=AA=E5=85=83=E7=B4=A0=E7= =9A=84=E7=B4=A2=E5=BC=95=E5=80=BC(=E4=BA=A6=E7=A7=B0=E4=B8=BA=E7=B4=A2=E5= =BC=95=E5=9F=BA=E6=95=B0). + =E5=B8=B8=E8=A7=81=E5=8F=96=E5=80=BC=E4=B8=BA0=E6=88= =961. + + @OneToMany(cascade =3D CascadeType.ALL) +(a)IndexColumn(name =3D "drawer_position", base=3D1) +public List<Drawer> getDrawers() { + return drawers; +} + + + =E5=81=87=E5=A6=82=E4=BD=A0=E5=BF=98=E4=BA=86=E8=AE=BE=E7= =BD=AE@IndexColumn, + Hibernate=E4=BC=9A=E9=87=87=E7=94=A8=E5=8C=85(bag)=E8=AF=AD=E4=B9=89(= =E8=AF=91=E6=B3=A8=EF=BC=9A=E5=8D=B3=E5=85=81=E8=AE=B8=E9=87=8D=E5=A4=8D=E5= =85=83=E7=B4=A0=E7=9A=84=E6=97=A0=E5=BA=8F=E9=9B=86=E5=90=88). + + + Hibernate=E6=B3=A8=E8=A7=A3=E6=94=AF=E6=8C=81true Map=E6=98= =A0=E5=B0=84, + =E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E8=AE=BE=E7=BD=AE@javax.pe= rsistence.MapKey, + hibernate=E5=B0=86key=E5=85=83=E7=B4=A0=E6=88=96=E5=B5=8C=E5=85=A5=E5=BC= =8F=E5=AF=B9=E8=B1=A1=E7=9B=B4=E6=8E=A5=E6=98=A0=E5=B0=84=E5=88=B0=E4=BB=96= =E4=BB=AC=E6=89=80=E5=B1=9E=E7=9A=84=E5=88=97. + =E8=A6=81=E8=A6=86=E5=86=99=E9=BB=98=E8=AE=A4=E7=9A=84=E5=88=97,=E5=8F= =AF=E4=BB=A5=E4=BD=BF=E7=94=A8=E4=BB=A5=E4=B8=8B=E6=B3=A8=E8=A7=A3: + @org.hibernate.annotations.MapKey=E9=80=82=E7=94=A8= =E7=9A=84key=E4=B8=BA=E5=9F=BA=E6=9C=AC=E7=B1=BB=E5=9E=8B=E6=88=96=E8=80=85= =E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1, + @org.hibernate.annotations.MapKey=E9=80=82=E7=94=A8= =E7=9A=84key=E4=B8=BA=E5=AE=9E=E4=BD=93. + + + Hibernate Annotations=E8=BF=98=E6=94=AF=E6=8C=81=E6=A0=B8=E5= =BF=83=E7=B1=BB=E5=9E=8B=E9=9B=86=E5=90=88(Integer, String, Enums, ......)= =E3=80=81 + =E5=8F=AF=E5=86=85=E5=B5=8C=E5=AF=B9=E8=B1=A1=E7=9A=84=E9=9B=86=E5=90=88= ,=E7=94=9A=E8=87=B3=E5=9F=BA=E6=9C=AC=E7=B1=BB=E5=9E=8B=E6=95=B0=E7=BB=84.= =E8=BF=99=E5=B0=B1=E6=98=AF=E6=89=80=E8=B0=93=E7=9A=84=E5=85=83=E7=B4=A0=E9= =9B=86=E5=90=88. + + =E5=85=83=E7=B4=A0=E9=9B=86=E5=90=88=E5=8F=AF=E7=94=A8@Colle= ctionOfElements=E6=9D=A5=E6=B3=A8=E8=A7=A3(=E4=BD=9C=E4=B8=BA@OneToMany=E7= =9A=84=E6=9B=BF=E4=BB=A3). + =E4=B8=BA=E4=BA=86=E5=AE=9A=E4=B9=89=E9=9B=86=E5=90=88=E8=A1=A8(=E8=AF= =91=E6=B3=A8=EF=BC=9A=E5=8D=B3=E5=AD=98=E6=94=BE=E9=9B=86=E5=90=88=E5=85=83= =E7=B4=A0=E7=9A=84=E8=A1=A8,=E4=B8=8E=E4=B8=8B=E9=9D=A2=E6=8F=90=E5=88=B0= =E7=9A=84=E4=B8=BB=E8=A1=A8=E5=AF=B9=E5=BA=94),=E8=A6=81=E5=9C=A8=E5=85=B3= =E8=81=94=E5=B1=9E=E6=80=A7=E4=B8=8A=E4=BD=BF=E7=94=A8@JoinTable=E6=B3=A8= =E8=A7=A3, + joinColumns=E5=AE=9A=E4=B9=89=E4=BA=86=E4=BB=8B=E4=B9=8E=E5=AE=9E=E4=BD= =93=E4=B8=BB=E8=A1=A8=E4=B8=8E=E9=9B=86=E5=90=88=E8=A1=A8=E4=B9=8B=E9=97=B4= =E7=9A=84=E8=BF=9E=E6=8E=A5=E5=AD=97=E6=AE=B5(inverseJoincolumn=E6=98=AF=E6= =97=A0=E6=95=88=E7=9A=84=E4=B8=94=E5=85=B6=E5=80=BC=E5=BA=94=E4=B8=BA=E7=A9= =BA). + =E5=AF=B9=E4=BA=8E=E6=A0=B8=E5=BF=83=E7=B1=BB=E5=9E=8B=E7=9A=84=E9=9B=86= =E5=90=88=E6=88=96=E5=9F=BA=E6=9C=AC=E7=B1=BB=E5=9E=8B=E6=95=B0=E7=BB=84,= =E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=9C=A8=E5=85=B3=E8=81=94=E5=B1=9E=E6=80=A7=E4= =B8=8A=E7=94=A8@Column=E6=9D=A5=E8=A6=86=E7=9B=96=E5=AD= =98=E6=94=BE=E5=85=83=E7=B4=A0=E5=80=BC=E7=9A=84=E5=AD=97=E6=AE=B5=E7=9A=84= =E5=AE=9A=E4=B9=89. + =E4=BD=A0=E8=BF=98=E5=8F=AF=E4=BB=A5=E7=94=A8@AttributeOverride= =E6=9D=A5=E8=A6=86=E7=9B=96=E5=AD=98=E6=94=BE=E5=8F=AF=E5=86=85= =E5=B5=8C=E5=AF=B9=E8=B1=A1=E7=9A=84=E5=AD=97=E6=AE=B5=E7=9A=84=E5=AE=9A=E4= =B9=89. + =E8=A6=81=E8=AE=BF=E9=97=AE=E9=9B=86=E5=90=88=E5=85=83=E7=B4=A0,=E9=9C= =80=E8=A6=81=E5=B0=86=E8=AF=A5=E6=B3=A8=E8=A7=A3=E7=9A=84name=E5=B1=9E=E6= =80=A7=E5=80=BC=E8=AE=BE=E7=BD=AE=E4=B8=BA"element"("element"=E7=94=A8=E4= =BA=8E=E6=A0=B8=E5=BF=83=E7=B1=BB=E5=9E=8B,=E8=80=8C"element.serial" + =E7=94=A8=E4=BA=8E=E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1=E7=9A=84= serial=E5=B1=9E=E6=80=A7).=E8=A6=81=E8=AE=BF=E9=97=AE=E9=9B=86=E5=90=88=E7= =9A=84index/key,=E5=88=99=E5=B0=86=E8=AF=A5=E6=B3=A8=E8=A7=A3=E7=9A=84name= =E5=B1=9E=E6=80=A7=E5=80=BC=E8=AE=BE=E7=BD=AE=E4=B8=BA"key". + + + @Entity +public class Boy { + private Integer id; + private Set<String> nickNames =3D new HashSet<String>(); + private int[] favoriteNumbers; + private Set<Toy> favoriteToys =3D new HashSet<Toy>(); + private Set<Character> characters =3D new HashSet<Character&g= t;(); + + @Id @GeneratedValue + public Integer getId() { + return id; + } + + @CollectionOfElements + public Set<String> getNickNames() { + return nickNames; + } + + @CollectionOfElements + @JoinTable( + table=3D@Table(name=3D"BoyFavoriteNumbers"), + joinColumns =3D @JoinColumn(name=3D"BoyId") + ) + @Column(name=3D"favoriteNumber", nullable=3Dfalse) + @IndexColumn(name=3D"nbr_index") + public int[] getFavoriteNumbers() { + return favoriteNumbers; + } + + @CollectionOfElements + @AttributeOverride( name=3D"element.serial", column=3D@Column(name=3D"= serial_nbr") ) + public Set<Toy> getFavoriteToys() { + return favoriteToys; + } + + @CollectionOfElements + public Set<Character> getCharacters() { + return characters; + } + ... +} + +public enum Character { + GENTLE, + NORMAL, + AGGRESSIVE, + ATTENTIVE, + VIOLENT, + CRAFTY +} + +(a)Embeddable +public class Toy { + public String name; + public String serial; + public Boy owner; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getSerial() { + return serial; + } + + public void setSerial(String serial) { + this.serial =3D serial; + } + + @Parent + public Boy getOwner() { + return owner; + } + + public void setOwner(Boy owner) { + this.owner =3D owner; + } + + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final Toy toy =3D (Toy) o; + + if ( !name.equals( toy.name ) ) return false; + if ( !serial.equals( toy.serial ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D name.hashCode(); + result =3D 29 * result + serial.hashCode(); + return result; + } +} + + + =E5=9C=A8=E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1=E7=9A=84=E9=9B=86= =E5=90=88=E4=B8=AD,=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8 @Parent=E6=B3=A8=E8=A7=A3=E5=B5=8C=E5=85=A5=E5=BC=8F=E5=AF=B9=E8=B1=A1=E7= =9A=84=E6=9F=90=E5=B1=9E=E6=80=A7. + =E8=AF=A5=E5=B1=9E=E6=80=A7=E6=8C=87=E5=90=91=E8=AF=A5=E5=B5=8C=E5=85=A5= =E5=BC=8F=E5=AF=B9=E8=B1=A1=E6=89=80=E5=B1=9E=E7=9A=84=E9=9B=86=E5=90=88=E5= =AE=9E=E4=BD=93. + + + =E6=97=A7=E7=89=88=E7=9A=84Hibernate Annotations=E7=94=A8@OneToMany=E6=9D=A5=E6=A0=87=E8=AF=86=E9=9B=86=E5=90=88=E5=85= =83=E7=B4=A0. + =E7=94=B1=E4=BA=8E=E8=AF=AD=E4=B9=89=E7=9F=9B=E7=9B=BE,=E6=88=91=E4=BB= =AC=E5=BC=95=E5=85=A5=E4=BA=86@CollectionOfElements=E6= =B3=A8=E8=A7=A3. + =E7=94=A8@OneToMany=E6=9D=A5=E6=A0=87=E8=AF=86=E9=9B= =86=E5=90=88=E5=85=83=E7=B4=A0=E7=9A=84=E8=BF=99=E7=A7=8D=E6=97=A7=E6=9C=89= =E6=96=B9=E5=BC=8F=E7=9B=AE=E5=89=8D=E5=B0=9A=E6=9C=89=E6=95=88, + =E4=BD=86=E6=98=AF=E4=B8=8D=E6=8E=A8=E8=8D=90=E4=BD=BF=E7=94=A8,=E8=80= =8C=E4=B8=94=E5=9C=A8=E4=BB=A5=E5=90=8E=E7=9A=84=E5=8F=91=E5=B8=83=E7=89=88= =E6=9C=AC=E4=B8=AD=E4=B8=8D=E5=86=8D=E6=94=AF=E6=8C=81=E8=BF=99=E7=A7=8D=E6= =96=B9=E5=BC=8F. + + + + + + =E7=BC=93=E5=AD=98 + + =E4=B8=BA=E4=BA=86=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E5=BA= =93=E8=AE=BF=E9=97=AE,=E4=BD=A0=E5=8F=AF=E4=BB=A5=E6=BF=80=E6=B4=BB=E6=89= =80=E8=B0=93=E7=9A=84Hibernate=E4=BA=8C=E7=BA=A7=E7=BC=93=E5=AD=98.=E8=AF= =A5=E7=BC=93=E5=AD=98=E6=98=AF=E5=8F=AF=E4=BB=A5=E6=8C=89=E6=AF=8F=E4=B8=AA= =E5=AE=9E=E4=BD=93=E5=92=8C=E9=9B=86=E5=90=88=E8=BF=9B=E8=A1=8C=E9=85=8D=E7= =BD=AE=E7=9A=84. + + @org.hibernate.annotations.Cache=E5=AE=9A= =E4=B9=89=E4=BA=86=E7=BC=93=E5=AD=98=E7=AD=96=E7=95=A5=E5=8F=8A=E7=BB=99=E5= =AE=9A=E7=9A=84=E4=BA=8C=E7=BA=A7=E7=BC=93=E5=AD=98=E7=9A=84=E8=8C=83=E5=9B= =B4. + =E6=AD=A4=E6=B3=A8=E8=A7=A3=E9=80=82=E7=94=A8=E4=BA=8E=E6=A0=B9=E5=AE=9E= =E4=BD=93(=E9=9D=9E=E5=AD=90=E5=AE=9E=E4=BD=93),=E8=BF=98=E6=9C=89=E9=9B=86= =E5=90=88. + + @Entity +(a)Cache(usage =3D CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Forest { ... } + + @OneToMany(cascade=3DCascadeType.ALL, fetch=3DFe= tchType.EAGER) + @JoinColumn(name=3D"CUST_ID") + @Cache(usage =3D CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + public SortedSet<Ticket> getTickets() { + return tickets; + } + + + + + + + + + + + + + @Cache( + CacheConcurrencyStrategy usage(); + String region() default ""; + String include() default "all"; +) + + + + usage: =E7=BB=99=E5=AE=9A=E7=BC=93=E5=AD=98=E7=9A=84=E5= =B9=B6=E5=8F=91=E7=AD=96=E7=95=A5(NONE, + READ_ONLY, NONSTRICT_READ_WRITE, READ_WRITE, TRANSACTIONAL) + + + + region (=E5=8F=AF=E9=80=89=E7=9A=84)=EF=BC=9A=E7=BC=93= =E5=AD=98=E8=8C=83=E5=9B=B4(=E9=BB=98=E8=AE=A4=E4=B8=BA=E7=B1=BB=E7=9A=84= =E5=85=A8=E9=99=90=E5=AE=9A=E7=B1=BB=E5=90=8D=E6=88=96=E6=98=AF=E9=9B=86=E5= =90=88=E7=9A=84=E5=85=A8=E9=99=90=E5=AE=9A=E8=A7=92=E8=89=B2=E5=90=8D) + + + + include (=E5=8F=AF=E9=80=89=E7=9A=84)= =EF=BC=9A=E5=80=BC=E4=B8=BAall=E6=97=B6=E5=8C=85=E6=8B=AC=E4=BA=86=E6=89=80= =E6=9C=89=E7=9A=84=E5=B1=9E=E6=80=A7(proterty), + =E4=B8=BAnon-lazy=E6=97=B6=E4=BB=85=E5=90=AB=E9=9D=9E=E5=BB=B6= =E8=BF=9F=E5=B1=9E=E6=80=A7(=E9=BB=98=E8=AE=A4=E5=80=BC=E4=B8=BAall) + + + + + + + + =E8=BF=87=E6=BB=A4=E5=99=A8 + + Hibernate=E5=85=B7=E6=9C=89=E6=95=B0=E6=8D=AE=E8=BF=87=E6=BB= =A4=E5=99=A8=E7=9A=84=E6=A6=82=E5=BF=B5,=E5=8F=AF=E5=9C=A8=E8=BF=90=E8=A1= =8C=E6=9C=9F=E5=BA=94=E7=94=A8=E4=BA=8E=E4=B8=80=E4=B8=AA=E7=BB=99=E5=AE=9A= =E7=9A=84session.=E8=BF=87=E6=BB=A4=E5=99=A8=E9=9C=80=E8=A6=81=E4=BA=8B=E5= =85=88=E5=AE=9A=E4=B9=89=E5=A5=BD. + + @org.hibernate.annotations.FilterDef =E6=88= =96 + @FilterDefs =E5=AE=9A=E4=B9=89=E8=BF=87=E6=BB=A4= =E5=99=A8=E5=A3=B0=E6=98=8E,=E4=B8=BA=E5=90=8C=E5=90=8D=E8=BF=87=E6=BB=A4= =E5=99=A8=E6=89=80=E7=94=A8. + =E8=BF=87=E6=BB=A4=E5=99=A8=E5=A3=B0=E6=98=8E=E5=B8=A6=E6=9C=89=E4= =B8=80=E4=B8=AAname()=E5=92=8C=E4=B8=80=E4=B8=AAparameters()=E6=95=B0=E7=BB= =84,@ParamDef=E5=8C=85=E5=90=ABname=E5=92=8Ctype, + =E4=BD=A0=E8=BF=98=E5=8F=AF=E4=BB=A5=E4=B8=BA=E7=BB=99=E5=AE=9A=E7= =9A=84@filterDef=E5=AE=9A=E4=B9=89=E4=B8=80=E4=B8=AAdefa= ultCondition()=E5=8F=82=E6=95=B0, + =E5=BD=93@Filter=E4=B8=AD=E6=B2=A1=E6=9C=89=E4=BB= =BB=E4=BD=95=E5=AE=9A=E4=B9=89=E6=97=B6,=E5=8F=AF=E4=BD=BF=E7=94=A8=E8=AF= =A5=E5=8F=82=E6=95=B0=E5=AE=9A=E4=B9=89=E7=BC=BA=E7=9C=81=E6=9D=A1=E4=BB=B6. + @FilterDef (s)=E5=8F=AF=E4=BB=A5=E5=9C=A8=E7=B1=BB= =E6=88=96=E5=8C=85=E4=B8=80=E7=BA=A7=E8=BF=9B=E8=A1=8C=E5=AE=9A=E4=B9=89. + + =E7=8E=B0=E5=9C=A8=E6=88=91=E4=BB=AC=E6=9D=A5=E5=AE=9A=E4=B9= =89=E5=BA=94=E7=94=A8=E4=BA=8E=E5=AE=9E=E4=BD=93=E6=88=96=E9=9B=86=E5=90=88= =E5=8A=A0=E8=BD=BD=E6=97=B6=E7=9A=84SQL=E8=BF=87=E6=BB=A4=E5=99=A8=E5=AD=90= =E5=8F=A5.=E6=88=91=E4=BB=AC=E4=BD=BF=E7=94=A8@Filter,= =E5=B9=B6=E5=B0=86=E5=85=B6=E7=BD=AE=E4=BA=8E=E5=AE=9E=E4=BD=93=E6=88=96=E9= =9B=86=E5=90=88=E5=85=83=E7=B4=A0=E4=B8=8A. + + @Entity +(a)FilterDef(name=3D"minLength", parameters=3D@ParamDef( name=3D"minLength= ", type=3D"integer" ) ) +(a)Filters( { + @Filter(name=3D"betweenLength", condition=3D":minLength <=3D length= and :maxLength >=3D length"), + @Filter(name=3D"minLength", condition=3D":minLength <=3D length") +} ) +public class Forest { ... } + + = + + + =E6=9F=A5=E8=AF=A2 + + =E7=94=B1=E4=BA=8EHibernate=E5=BC=95=E5=85=A5=E4=BA=86 + @org.hibernate.annotations.NamedQuery, + @org.hibernate.annotations.NamedQueries, + @org.hibernate.annotations.NamedNativeQuery =E5= =92=8C + @org.hibernate.annotations.NamedNativeQueries =E5= =91=BD=E5=90=8D=E5=BC=8F=E6=9F=A5=E8=AF=A2, + =E5=9B=A0=E6=AD=A4Hibernate=E5=9C=A8=E5=91=BD=E5=90=8D=E5=BC=8F=E6= =9F=A5=E8=AF=A2=E4=B8=8A=E6=AF=94EBJ3=E8=A7=84=E8=8C=83=E4=B8=AD=E6=89=80= =E5=AE=9A=E4=B9=89=E7=9A=84=E5=91=BD=E5=90=8D=E5=BC=8F=E6=9F=A5=E8=AF=A2=E6= =8F=90=E4=BE=9B=E4=BA=86=E6=9B=B4=E5=A4=9A=E7=9A=84=E7=89=B9=E6=80=A7. + =E4=BB=96=E4=BB=AC=E5=9C=A8=E6=A0=87=E5=87=86=E7=89=88=E4=B8=AD=E6= =B7=BB=E5=8A=A0=E4=BA=86=E5=8F=AF=E4=BD=9C=E4=B8=BA=E6=9B=BF=E4=BB=A3=E5=93= =81=E7=9A=84=E4=B8=80=E4=BA=9B=E5=B1=9E=E6=80=A7(attributes): + + + + flushMode: =E5=AE=9A=E4=B9=89=E6=9F=A5=E8=AF=A2=E7=9A=84= =E5=88=B7=E6=96=B0=E6=A8=A1=E5=BC=8F(Always, Auto, Commit=E6=88=96Manual) + + + + cacheable: =E6=9F=A5=E8=AF=A2=E8=AF=A5=E4=B8=8D=E8=AF=A5= =E8=A2=AB=E7=BC=93=E5=AD=98 + + + + cacheRegion: =E8=8B=A5=E6=9F=A5=E8=AF=A2=E5=B7=B2=E8=A2=AB= =E7=BC=93=E5=AD=98=E6=97=B6=E6=89=80=E7=94=A8=E7=BC=93=E5=AD=98=E7=9A=84=E8= =8C=83=E5=9B=B4 + + + + fetchSize: =E9=92=88=E5=AF=B9=E8=AF=A5=E6=9F=A5=E8=AF=A2= =E7=9A=84JDBC statement=E5=8D=95=E6=AC=A1=E8=8E=B7=E5=8F=96=E8=AE=B0=E5=BD= =95=E7=9A=84=E6=95=B0=E7=9B=AE + + + + timeout: =E6=9F=A5=E8=AF=A2=E8=B6=85=E6=97=B6 + + + + callable: =E4=BB=85=E7=94=A8=E4=BA=8E=E6=9C=AC=E5=9C=B0=E5= =8C=96=E6=9F=A5=E8=AF=A2(native query),=E5=AF=B9=E4=BA=8E=E5=AD=98=E5=82=A8= =E8=BF=87=E7=A8=8B=E8=AE=BE=E4=B8=BAtrue + + + + comment: =E4=B8=80=E6=97=A6=E6=BF=80=E6=B4=BB=E6=B3=A8=E9= =87=8A=E5=8A=9F=E8=83=BD,=E6=88=91=E4=BB=AC=E4=BC=9A=E5=9C=A8=E5=90=91=E6= =95=B0=E6=8D=AE=E5=BA=93=E4=BA=A4=E9=80=81=E6=9F=A5=E8=AF=A2=E8=AF=B7=E6=B1= =82=E6=97=B6=E7=9C=8B=E5=88=B0=E6=B3=A8=E9=87=8A + + + + cacheMode: =E7=BC=93=E5=AD=98=E4=BA=A4=E6=8A=A4=E6=A8=A1= =E5=BC=8F(get, ignore,normal,=E6=88=96refresh) + + + + readOnly: =E4=B8=8D=E7=AE=A1=E6=98=AF=E5=90=A6=E4=BB=8E=E6= =9F=A5=E8=AF=A2=E8=8E=B7=E5=8F=96=E5=85=83=E7=B4=A0=E9=83=BD=E6=98=AF=E5=9C= =A8=E5=8F=AA=E8=AF=BB=E6=A8=A1=E5=BC=8F=E4=B8=8B + + + + =E6=B3=A8=E6=84=8F,EJB3=E5=B7=B2=E5=85=AC=E5=BC=80=E7=9A=84=E6= =9C=80=E7=BB=88=E8=8D=89=E6=A1=88=E4=B8=AD=E5=BC=95=E5=85=A5=E4=BA=86@QueryHint=E7=9A=84=E6=A6=82=E5=BF=B5, + =E8=BF=99=E5=8F=AF=E8=83=BD=E6=98=AF=E5=AE=9A=E4=B9=89hints=E6=9B=B4= =E5=A5=BD=E7=9A=84=E6=96=B9=E6=B3=95. + +
+ +
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/luc= ene.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/lucene= .xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/lucene= .xml 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,86 @@ + + + Hibernate=E4=B8=8ELucene=E9=9B=86=E6=88=90 + + Lucene=E6=98=AF=E4=B8=80=E4=B8=AA=E9=AB=98=E6=80=A7=E8=83=BD=E7=9A= =84java=E6=90=9C=E7=B4=A2=E5=BC=95=E6=93=8E=E5=BA=93=EF=BC=8C=E5=8F=AF=E4= =BB=A5=E4=BB=8E Apache=E8=BD=AF=E4=BB=B6=E5=9F=BA=E9=87=91=E7=BB=84=E7=BB= =87=E8=8E=B7=E5=8F=96=E3=80=82 + Hibernate Annotations=E5=8C=85=E6=8B=AC=E4=B8=80=E4=B8=AA=E6=B3=A8=E8=A7= =A3=E5=8C=85=EF=BC=8C=E5=AE=83=E5=85=81=E8=AE=B8=E6=8A=8A=E4=BB=BB=E4=BD=95= =E5=9F=9F=E6=A8=A1=E5=9E=8B=E5=AF=B9=E8=B1=A1=E6=A0=87=E8=AE=B0=E4=B8=BA=E5= =8F=AF=E7=B4=A2=E5=BC=95=E7=9A=84=EF=BC=8C + =E5=B9=B6=E4=B8=94=E5=AF=B9=E4=BB=BB=E4=BD=95=E7=BB=8F=E7=94=B1Hibernate= =E8=BF=9B=E8=A1=8C=E6=8C=81=E7=BB=AD=E5=8C=96=E7=9A=84=E5=AE=9E=E4=BE=8B=EF= =BC=8CHibernate =E9=83=BD=E4=BC=9A=E4=B8=BA=E4=B9=8B=E7=BB=B4=E6=8A=A4=E4= =B8=80=E4=B8=AA=E5=AF=B9=E5=BA=94=E7=9A=84Lucene=E7=B4=A2=E5=BC=95=E3=80=82= + + + =E4=BD=BF=E7=94=A8Lucene=E4=B8=BA=E5=AE=9E=E4=BD=93=E5=BB=BA=E7= =AB=8B=E7=B4=A2=E5=BC=95 + + + =E6=B3=A8=E8=A7=A3=E9=A2=86=E5=9F=9F=E6=A8=A1=E5=9E=8B + + =E9=A6=96=E5=85=88=EF=BC=8C=E5=BF=85=E9=A1=BB=E5=B0=86=E4=B8= =80=E4=B8=AA=E6=8C=81=E4=B9=85=E7=B1=BB=E5=A3=B0=E6=98=8E=E4=B8=BA + @Indexed: + + @Entity +(a)Indexed(index=3D"indexes/essays") +public class Essay { + ... +} + + =E5=B1=9E=E6=80=A7index=E6=98=AF=E5=91=8A= =E8=AF=89Hibernate=EF=BC=8C Lucene=E7=B4=A2=E5=BC=95=E4=BF=A1=E6=81=AF=E6= =89=80=E5=9C=A8=E7=9A=84=E4=BD=8D=E7=BD=AE=EF=BC=88=E4=BD=A0=E6=96=87=E4=BB= =B6=E7=B3=BB=E7=BB=9F=E7=9A=84=E6=9F=90=E4=B8=AA=E7=9B=AE=E5=BD=95=EF=BC=89= =E3=80=82 + =E5=A6=82=E6=9E=9C=E4=BD=A0=E6=83=B3=E4=B8=BA=E6=89=80=E6=9C=89=E7=9A= =84Lucene=E7=B4=A2=E5=BC=95=E5=AE=9A=E4=B9=89=E4=B8=80=E4=B8=AA=E6=A0=B9=E7= =9B=AE=E5=BD=95=EF=BC=8C=E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=9C=A8=E9=85=8D=E7=BD= =AE=E6=96=87=E4=BB=B6=E4=B8=AD=E7=94=A8=E5=B1=9E=E6=80=A7hibernate= .lucene.index_dir=E8=BF=9B=E8=A1=8C=E9=85=8D=E7=BD=AE=E3=80=82 + + + Lucene=E7=B4=A2=E5=BC=95=E5=8C=85=E6=8B=AC=E5=9B=9B=E7=A7=8D= =E5=AD=97=E6=AE=B5=EF=BC=9Akeyword =E5=AD=97=E6=AE=B5= =EF=BC=8Ctext + =E5=AD=97=E6=AE=B5=EF=BC=8Cunstored=E5=AD=97=E6= =AE=B5=E5=92=8Cunindexed=E5=AD=97=E6=AE=B5=E3=80=82 + Hibernate=E6=B3=A8=E8=A7=A3=E6=8F=90=E4=BE=9B=E4=BA=86=E5=B0=86=E5= =AE=9E=E4=BD=93=E5=B1=9E=E6=80=A7=E6=A0=87=E8=AE=B0=E4=B8=BA=E5=89=8D=E4=B8= =89=E7=A7=8D=E8=A2=AB=E7=B4=A2=E5=BC=95=E5=AD=97=E6=AE=B5=E7=9A=84=E6=B3=A8= =E8=A7=A3=E3=80=82 + + @Entity +(a)Indexed(index=3D"indexes/essays") +public class Essay { + ... + + @Id + @Keyword(id=3Dtrue) + public Long getId() { return id; } + = + @Text(name=3D"Abstract") + public String getSummary() { return summary; } + = + @Lob + @Unstored + public String getText() { return text; } + = +} + + =E8=BF=99=E4=BA=9B=E6=B3=A8=E8=A7=A3=E5=AE=9A=E4=B9=89=E4=BA= =86=E4=B8=80=E4=B8=AA=E5=B8=A6=E6=9C=89=E4=B8=89=E4=B8=AA=E5=AD=97=E6=AE=B5= =E7=9A=84=E7=B4=A2=E5=BC=95: + Id, Abstract =E5=92=8C + Text. + + =E6=B3=A8=E6=84=8F:=E4=BD=A0=E5=BF=85=E9=A1=BB=E5=9C=A8=E4=BD= =A0=E7=9A=84=E5=AE=9E=E4=BD=93=E7=B1=BB=E7=9A=84=E6=A0=87=E5=BF=97=E5=B1=9E= =E6=80=A7=E4=B8=8A=E6=8C=87=E5=AE=9A + @Keyword(id=3Dtrue) . + + =E7=94=A8=E4=BA=8E=E5=AF=B9=E5=85=83=E7=B4=A0=E5=BB=BA=E7=AB=8B= =E7=B4=A2=E5=BC=95=E7=9A=84=E5=88=86=E6=9E=90=E5=99=A8=E7=B1=BB=E6=98=AF=E5= =8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87hibernate.lucene.analyzer=E5=B1=9E=E6=80=A7=E8=BF=9B=E8=A1=8C=E9=85=8D=E7=BD=AE=E7=9A=84=E3=80=82 + =E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E5=AE=9A=E4=B9=89=EF=BC=8C=E5=88= =99=E6=8A=8A org.apache.lucene.analysis.standard.StandardAnalyze= r=E4=BD=9C=E4=B8=BA=E7=BC=BA=E7=9C=81=E3=80=82 + + + + + =E5=90=AF=E7=94=A8=E8=87=AA=E5=8A=A8=E7=B4=A2=E5=BC=95 + + =E6=88=91=E4=BB=AC=E6=BF=80=E6=B4=BB=E7=94=A8=E4=BA=8E=E5=B8= =A7=E5=90=AC=E4=B8=89=E7=B1=BBHibernate=E4=BA=8B=E4=BB=B6=E7=9A=84 LuceneEventListener=EF=BC=8C + =E8=BF=99=E4=BA=9B=E4=BA=8B=E4=BB=B6=E4=BC=9A=E5=9C=A8=E5=8F=98=E6=9B= =B4=E8=A2=AB=E6=8F=90=E4=BA=A4=E8=87=B3=E6=95=B0=E6=8D=AE=E5=BA=93=E5=90=8E= =E4=BA=A7=E7=94=9F=E3=80=82 + + <hibernate-configuration> + ... + <event type=3D"post-commit-update" = + <listener = + class=3D"org.hibernate.lucene.event.LuceneEventListener"/> + </event> + <event type=3D"post-commit-insert" = + <listener = + class=3D"org.hibernate.lucene.event.LuceneEventListener"/> + </event> + <event type=3D"post-commit-delete" = + <listener = + class=3D"org.hibernate.lucene.event.LuceneEventListener"/> + </event> +</hibernate-configuration> + + + + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/set= up.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/setup.= xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/setup.= xml 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,129 @@ + + + =E5=88=9B=E5=BB=BA=E4=B8=80=E4=B8=AA= =E6=B3=A8=E8=A7=A3=E9=A1=B9=E7=9B=AE + +
+ =E7=B3=BB=E7=BB=9F=E9=9C=80=E6=B1=82 + + + + =E9=A6=96=E5=85=88=E4=BB=8EHibernate=E5=AE=98=E6=96=B9=E7=BD= =91=E7=AB=99=E4=B8=8B=E8=BD=BD=E5=B9=B6=E8=A7=A3=E5=8E=8BHibernate Annotati= ons=E7=9A=84=E5=8F=91=E5=B8=83=E5=8C=85=E3=80=82 + + + + =E8=BF=99=E4=B8=AA=E7=89=88=E6=9C=AC(=E9=A2=84=E8= =A7=88=E7=89=88)=E8=A6=81=E6=B1=82=E4=BD=BF=E7=94=A8Hibernate 3.2.0.CR2=E6= =88=96=E6=9B=B4=E9=AB=98=E7=89=88=E6=9C=AC=E3=80=82=E8=AF=B7=E4=B8=8D=E8=A6= =81=E5=92=8C=E8=80=81=E7=89=88=E6=9C=AC=E7=9A=84Hibernate 3.x=E6=B7=B7=E5= =90=88=E8=B5=B7=E6=9D=A5=E4=BD=BF=E7=94=A8=E3=80=82 + + + + =E8=BF=99=E4=B8=AA=E7=89=88=E6=9C=AC=E5=9C=A8Hibernate core = 3.2.0.CR2=E7=9A=84=E5=9F=BA=E7=A1=80=E4=B8=8A=E5=B7=A5=E4=BD=9C=E8=89=AF=E5= =A5=BD=E3=80=82 + + + + =E9=A6=96=E5=85=88=E7=A1=AE=E5=AE=9A=E4=BD=A0=E5=B7=B2=E7=BB= =8F=E5=AE=89=E8=A3=85=E4=BA=86JDK 5.0=E3=80=82=E5=BD=93=E7=84=B6=E5=B0=B1= =E7=AE=97=E4=BD=BF=E7=94=A8=E4=BD=8E=E7=89=88=E6=9C=AC=E7=9A=84JDK=EF=BC=8C + Xdoclet=E4=B9=9F=E5=8F=AF=E4=BB=A5=E6=8F=90=E4=BE=9B=EF=BC=88=E5= =9F=BA=E4=BA=8E=E6=B3=A8=E8=A7=A3=E7=9A=84=EF=BC=89=E5=85=83=E6=95=B0=E6=8D= =AE=E6=89=80=E5=B8=A6=E6=9D=A5=E7=9A=84=E9=83=A8=E5=88=86=E5=8A=9F=E8=83=BD= =E3=80=82 + =E4=B8=8D=E8=BF=87=E8=AF=B7=E6=B3=A8=E6=84=8F=E6=9C=AC=E6=96=87=E6= =A1=A3=E5=8F=AA=E6=8F=8F=E8=BF=B0=E8=B7=9FJDK5.0=E6=B3=A8=E8=A7=A3=E6=9C=89= =E5=85=B3=E7=9A=84=E5=86=85=E5=AE=B9=EF=BC=8C=E5=85=B3=E4=BA=8EXdoclet=E8= =AF=B7=E5=8F=82=E8=80=83=E7=9B=B8=E5=85=B3=E6=96=87=E6=A1=A3=E3=80=82 + + +
+ +
+ =E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE + + =E9=A6=96=E5=85=88=E5=B0=B1=E6=98=AF=E8=AE=BE=E7=BD=AEclasspath(= =E5=BD=93=E7=84=B6=E6=98=AF=E5=9C=A8IDE=E4=B8=AD=E5=88=9B=E5=BB=BA=E4=BA=86= =E4=B8=80=E4=B8=AA=E6=96=B0=E9=A1=B9=E7=9B=AE=E4=B9=8B=E5=90=8E)=E3=80=82 <= itemizedlist> + + =E5=B0=86Hibernate3=E6=A0=B8=E5=BF=83=E6=96=87=E4=BB=B6=E4= =BB=A5=E5=8F=8A=E5=85=B6=E4=BE=9D=E8=B5=96=E7=9A=84=E7=AC=AC=E4=B8=89=E6=96= =B9=E5=BA=93=E6=96=87=E4=BB=B6(=E8=AF=B7=E5=8F=82=E8=80=83lib/README.txt=E6= =96=87=E4=BB=B6)=E5=8A=A0=E5=85=A5=E5=88=B0=E4=BD=A0=E7=9A=84classpath=E9= =87=8C=E9=9D=A2=E3=80=82 + + + + =E5=B0=86hibernate-annotations.jar + =E5=92=8Clib/ejb3-persistence.jar=E5=8A=A0= =E5=85=A5=E5=88=B0=E4=BD=A0=E7=9A=84classpath=E9=87=8C=E9=9D=A2=E3=80=82 + + + + =E5=A6=82=E6=9E=9C=E8=A6=81=E4=BD=BF=E7=94=A8 =EF=BC=8C=E8=BF=98=E9=9C=80=E8=A6=81=E5=B0=86lucene=E7=9A=84= jar=E6=96=87=E4=BB=B6=E5=8A=A0=E5=85=A5=E4=BD=A0=E7=9A=84classpath=E3=80=82= + + + + =E6=88=91=E4=BB=AC=E6=8E=A8=E8=8D=90=E5=9C=A8=E4=B8=80=E4=B8=AA= =E5=8C=85=E8=A3=85=E5=99=A8(wrapper)=E7=B1=BBHibernateUtil + =E7=9A=84=E9=9D=99=E6=80=81=E5=88=9D=E5=A7=8B=E5=8C=96=E4=BB=A3=E7=A0= =81=E5=9D=97=E4=B8=AD=E5=90=AF=E5=8A=A8Hibernate=E3=80=82=E6=88=96=E8=AE=B8= =E4=BD=A0=E5=9C=A8Hibernate=E6=96=87=E6=A1=A3=E7=9A=84=E5=85=B6=E4=BB=96=E5= =BE=88=E5=A4=9A=E5=9C=B0=E6=96=B9=E7=9C=8B=E5=88=B0=E8=BF=87=E8=BF=99=E4=B8= =AA=E7=B1=BB=EF=BC=8C + =E4=BD=86=E6=98=AF=E8=A6=81=E5=9C=A8=E4=BD=A0=E7=9A=84=E9=A1=B9=E7=9B= =AE=E4=B8=AD=E4=BD=BF=E7=94=A8=E6=B3=A8=E8=A7=A3=EF=BC=8C=E8=BF=98=E9=9C=80= =E8=A6=81=E5=AF=B9=E8=BF=99=E4=B8=AA=E8=BE=85=E5=8A=A9(helper)=E7=B1=BB=E8= =BF=9B=E8=A1=8C=E6=89=A9=E5=B1=95=E3=80=82=E6=89=A9=E5=B1=95=E5=A6=82=E4=B8= =8B: + package hello; + +import org.hibernate.*; +import org.hibernate.cfg.*; +import test.*; +import test.animals.Dog; + +public class HibernateUtil { + +private static final SessionFactory sessionFactory; + + static { + try { + + sessionFactory =3D new AnnotationConfi= guration().buildSessionFactory(); + } catch (Throwable ex) { + // Log exception! + throw new ExceptionInInitializerError(ex); + } + } + + public static Session getSession() + throws HibernateException { + return sessionFactory.openSession(); + } +} + + + =E8=BF=99=E9=87=8C=E6=AF=94=E8=BE=83=E6=9C=89=E6=84=8F=E6=80=9D= =E7=9A=84=E6=98=AF=E4=BD=BF=E7=94=A8=E5=88=B0=E4=BA=86Annotation= Configuration=E7=B1=BB=E3=80=82 + =E5=9C=A8XML=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6(=E9=80=9A=E5=B8=B8=E6= =98=AFhibernate.cfg.xml)=E4=B8=AD=E5=88=99=E5=AE=9A=E4= =B9=89=E4=BA=86=E5=8C=85=E5=92=8C=E7=BB=8F=E8=BF=87=E6=B3=A8=E8=A7=A3=E7=9A= =84=E7=B1=BB=E3=80=82=E4=B8=8B=E9=9D=A2=E7=9A=84xml=E5=92=8C=E5=89=8D=E9=9D= =A2=E7=9A=84=E5=A3=B0=E6=98=8E=E7=AD=89=E4=BB=B7: + + + <!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> + + <hibernate-configuration> + <session-factory> + <mapping package=3D"test.animals"/&= gt; + <mapping class=3D"test.Flight"/> + <mapping class=3D"test.Sky"/> + <mapping class=3D"test.Person"/> + <mapping class=3D"test.animals.Dog"/> + <mapping resource=3D"test/animals/o= rm.xml"/> + </session-factory> + </hibernate-configuration> + + + =E6=B3=A8=E6=84=8F=E7=8E=B0=E5=9C=A8=E4=BD=A0=E5=8F=AF=E4=BB=A5= =E6=B7=B7=E5=90=88=E4=BD=BF=E7=94=A8hbm.xml=E5=92=8C=E6=B3=A8=E8=A7=A3=E3= =80=82=E8=B5=84=E6=BA=90=E5=85=83=E7=B4=A0(resource element)=E5=8F=AF=E4=BB= =A5=E6=98=AFhbm=E6=96=87=E4=BB=B6=E4=B9=9F=E5=8F=AF=E4=BB=A5=E6=98=AFEJB3 X= ML=E5=8F=91=E5=B8=83=E6=8F=8F=E8=BF=B0=E7=AC=A6=EF=BC=8C=E6=AD=A4=E5=B7=AE= =E5=88=AB=E5=AF=B9=E4=BA=8E=E9=85=8D=E7=BD=AE=E8=BF=87=E7=A8=8B=E6=98=AF=E9= =80=8F=E6=98=8E=E7=9A=84=E3=80=82 + + =E9=99=A4=E4=BA=86=E4=B8=8A=E9=9D=A2=E7=9A=84=E6=96=B9=E5=BC=8F,= =E4=BD=A0=E8=BF=98=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87=E7=BC=96=E7=A8=8B=E7= =9A=84=E6=96=B9=E5=BC=8F=E5=AE=9A=E4=B9=89=E5=8C=85=E6=8B=AC=E6=B3=A8=E8=A7= =A3=E7=9A=84=E7=B1=BB=E5=92=8C=E5=8C=85 + + sessionFactory =3D new AnnotationConfiguration() + .addPackage("test.animals") //the fully qualified pack= age name + .addAnnotatedClass(Flight.class) + .addAnnotatedClass(Sky.class) + .addAnnotatedClass(Person.class) + .addAnnotatedClass(Dog.class) + .buildSessionFactory(); + + =E4=BD=A0=E4=B9=9F=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8Hibernate = Entity Manager=E6=9D=A5=E5=AE=8C=E6=88=90=E4=BB=A5=E4=B8=8A=E5=8A=9F=E8=83= =BD=E3=80=82Hibernate Entity Manager=E6=9C=89=E8=87=AA=E5=B7=B1=E7=9A=84=E4= =B8=80=E5=A5=97=E9=85=8D=E7=BD=AE=E6=9C=BA=E5=88=B6=EF=BC=8C=E8=AF=A6=E6=83= =85=E8=AF=B7=E5=8F=82=E8=80=83=E7=9B=B8=E5=85=B3=E6=96=87=E6=A1=A3=E3=80=82= + + =E9=99=A4=E4=BA=86=E5=90=AF=E5=8A=A8=E6=96=B9=E5=BC=8F=E5=92=8C= =E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=9C=89=E6=89=80=E6=94=B9=E5=8F=98=E4= =B9=8B=E5=A4=96=EF=BC=8C=E7=BB=93=E5=90=88=E6=B3=A8=E8=A7=A3=E6=9D=A5=E4=BD= =BF=E7=94=A8Hibernate API=E5=92=8C=E4=BB=A5=E5=89=8D=E6=B2=A1=E6=9C=89=E4= =BB=80=E4=B9=88=E5=8C=BA=E5=88=AB=EF=BC=8C + =E5=9C=A8=E5=85=B6=E4=BB=96=E6=96=B9=E9=9D=A2=E4=BD=A0=E8=BF=98=E6=98= =AF=E5=8F=AF=E4=BB=A5=E7=BB=A7=E7=BB=AD=E4=BF=9D=E6=8C=81=E4=BB=A5=E5=89=8D= =E7=9A=84=E4=B9=A0=E6=83=AF=E5=92=8C=E5=96=9C=E5=A5=BD(hibernate.= properties=EF=BC=8C + hibernate.cfg.xml=EF=BC=8C programmatic APIs=E7= =AD=89=E7=AD=89)=E3=80=82 + =E7=94=9A=E8=87=B3=E5=AF=B9=E4=BA=8E=E5=90=8C=E4=B8=80=E4=B8=AASessionFactory=EF=BC=8C=E4=BD=A0=E9=83=BD=E5=8F=AF=E4=BB=A5= =E6=B7=B7=E5=90=88=E5=B8=A6=E6=B3=A8=E8=A7=A3=E7=9A=84=E6=8C=81=E4=B9=85=E7= =B1=BB=E4=BB=A5=E5=8F=8A=E4=BC=A0=E7=BB=9F=E7=9A=84bm.cfg.xml=E5=A3=B0=E6= =98=8E=E6=96=B9=E5=BC=8F=E3=80=82 + =E7=84=B6=E8=80=8C=E4=BD=A0=E4=B8=8D=E8=83=BD=E5=A4=9A=E6=AC=A1=E5=A3= =B0=E6=98=8E=E5=90=8C=E4=B8=80=E4=B8=AA=E7=B1=BB(=E8=A6=81=E4=B9=88=E9=80= =9A=E8=BF=87=E6=B3=A8=E8=A7=A3=E8=A6=81=E4=B9=88=E9=80=9A=E8=BF=87hbm.xml= =E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6)=EF=BC=8C + =E8=80=8C=E4=B8=94=E5=9C=A8=E4=B8=80=E4=B8=AA=E6=98=A0=E5=B0=84=E5=AE= =9E=E4=BD=93=E7=9A=84=E7=B1=BB=E7=BB=A7=E6=89=BF=E5=B1=82=E6=AC=A1=E4=B8=AD= =EF=BC=8C=E8=BF=99=E4=B8=A4=E4=B8=AA=E9=85=8D=E7=BD=AE=E7=AD=96=E7=95=A5=E4= =B8=8D=E8=83=BD=E5=90=8C=E6=97=B6=E4=BD=BF=E7=94=A8. + + + =E4=B8=BA=E4=BA=86=E7=AE=80=E5=8C=96=E4=BB=8Ehbm=E6=96=87=E4=BB= =B6=E5=88=B0=E6=B3=A8=E8=A7=A3=E7=9A=84=E8=BF=81=E7=A7=BB=E8=BF=87=E7=A8=8B= =EF=BC=8C + =E9=85=8D=E7=BD=AE=E6=9C=BA=E5=88=B6=E5=B0=86=E8=87=AA=E5=8A=A8=E6=A3= =80=E6=B5=8B=E5=9C=A8=E6=B3=A8=E8=A7=A3=E5=92=8Chbm=E6=96=87=E4=BB=B6=E4=B8= =AD=E9=87=8D=E5=A4=8D=E7=9A=84=E6=98=A0=E5=B0=84=E3=80=82 + =E9=BB=98=E8=AE=A4=E6=83=85=E5=86=B5=E4=B8=8Bhbm=E6=96=87=E4=BB=B6=E4= =B8=AD=E7=9A=84=E5=A3=B0=E6=98=8E=E6=AF=94=E7=B1=BB=E4=B8=AD=E7=9A=84=E6=B3= =A8=E8=A7=A3=E5=85=83=E6=95=B0=E6=8D=AE=E5=85=B7=E6=9C=89=E6=9B=B4=E9=AB=98= =E7=9A=84=E4=BC=98=E5=85=88=E7=BA=A7=E3=80=82 + =E8=BF=99=E7=A7=8D=E4=BC=98=E5=85=88=E7=BA=A7=E7=9A=84=E8=AE=BE=E5=AE= =9A=E6=98=AF=E4=BB=A5=E7=B1=BB=E4=B8=BA=E5=8D=95=E4=BD=8D=E7=9A=84=E3=80=82 + =E4=BD=A0=E4=B9=9F=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87hiberna= te.mapping.precedence=E4=BF=AE=E6=94=B9=E8=BF=99=E7=A7=8D=E4=BC= =98=E5=85=88=E7=BA=A7=E3=80=82 + =E9=BB=98=E8=AE=A4=E7=9A=84=E5=80=BC=E6=98=AFhbm, class=EF=BC=8C + =E5=A6=82=E6=9E=9C=E6=94=B9=E4=B8=BAclass,hbm=EF=BC= =8C=E5=BD=93=E5=8F=91=E7=94=9F=E5=86=B2=E7=AA=81=E7=9A=84=E6=97=B6=E5=80=99= =EF=BC=8C=E7=B1=BB=E4=B8=AD=E7=9A=84=E6=B3=A8=E8=A7=A3=E5=B0=86=E6=AF=94hbm= =E6=96=87=E4=BB=B6=E5=85=B7=E6=9C=89=E6=9B=B4=E9=AB=98=E7=9A=84=E4=BC=98=E5= =85=88=E7=BA=A7=E3=80=82 + +
+
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/val= idator.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/valida= tor.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/valida= tor.xml 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,464 @@ + + + Hibernate=E9=AA=8C=E8=AF=81=E5=99=A8 + + =E6=B3=A8=E8=A7=A3=E6=98=AF=E4=B8=80=E7=A7=8D=E4=B8=BA=E9=A2=86=E5= =9F=9F=E6=A8=A1=E5=9E=8B(domain model)=E6=8C=87=E5=AE=9A=E4=B8=8D=E5=8F=98= =E7=BA=A6=E6=9D=9F=E7=9A=84=E7=AE=80=E6=B4=81=E8=80=8C=E5=B9=BD=E9=9B=85=E7= =9A=84=E6=96=B9=E6=B3=95=E3=80=82=E4=BE=8B=E5=A6=82=EF=BC=8C=E4=BD=A0=E8=83= =BD + =E8=A1=A8=E7=A4=BA=E4=B8=80=E4=B8=AA=E5=B1=9E=E6=80=A7=E6=B0=B8=E8=BF=9C= =E4=B8=8D=E4=B8=BAnull=EF=BC=8C=E4=B8=80=E4=B8=AA=E5=B8=90=E6=88=B7=E4=BD= =99=E9=A2=9D=E4=B8=80=E5=AE=9A=E6=98=AF=E6=AD=A3=E5=80=BC=EF=BC=8C=E7=AD=89= =E7=AD=89=E3=80=82=E8=BF=99=E4=BA=9B=E5=9F=9F=E6=A8=A1=E5=9E=8B=E7=BA=A6=E6= =9D=9F=E9=80=9A=E8=BF=87=E4=B8=BAbean=E4=B8=AD=E7=9A=84=E5=B1=9E=E6=80=A7= =E6=B7=BB=E5=8A=A0 + =E6=B3=A8=E8=A7=A3=E6=9D=A5=E5=8A=A0=E4=BB=A5=E5=A3=B0=E6=98=8E=E3=80=82= =E9=9A=8F=E5=90=8E=E4=B8=80=E4=B8=AA=E9=AA=8C=E8=AF=81=E5=99=A8(validator)= =E4=BC=9A=E8=AF=BB=E5=8F=96=E5=B9=B6=E6=A3=80=E6=9F=A5=E8=BF=99=E4=BA=9B=E7= =BA=A6=E6=9D=9F=E3=80=82=E9=AA=8C=E8=AF=81=E6=9C=BA=E5=88=B6=E5=8F=AF=E4=BB= =A5=E6=89=A7=E8=A1=8C=E4=BA=8E=E5=BA=94=E7=94=A8=E7=A8=8B=E5=BA=8F=E4=B8=AD= =E7=9A=84 + =E4=B8=8D=E5=90=8C=E5=B1=82=EF=BC=88=E8=A1=A8=E7=8E=B0=E5=B1=82=E3=80=81= =E6=95=B0=E6=8D=AE=E8=AE=BF=E9=97=AE=E5=B1=82=EF=BC=89=EF=BC=8C=E8=80=8C=E4= =B8=8D=E5=BF=85=E5=A4=8D=E8=BF=B0=E4=BB=BB=E4=BD=95=EF=BC=88=E5=89=8D=E8=BF= =B0=EF=BC=89=E8=BF=99=E4=BA=9B=E8=A7=84=E5=88=99=E3=80=82Hibernate=E9=AA=8C= =E8=AF=81=E5=99=A8=E6=AD=A3=E4=B8=BA=E8=BF=99=E4=B8=80=E7=9B=AE=E7=9A=84=E8= =80=8C=E8=AE=BE=E8=AE=A1=E7=9A=84=E3=80=82 + + Hibernate=E9=AA=8C=E8=AF=81=E5=99=A8=E5=B7=A5=E4=BD=9C=E5=9C=A8=E4= =B8=A4=E4=B8=AA=E5=B1=82=E6=AC=A1=E4=B8=8A=E3=80=82=E7=AC=AC=E4=B8=80=E5=B1= =82=EF=BC=8C=E5=AE=83=E8=83=BD=E6=A3=80=E6=9F=A5=E5=86=85=E5=AD=98=E4=B8=AD= =E4=B8=80=E4=B8=AA=E7=B1=BB=E7=9A=84=E5=AE=9E=E4=BE=8B=E6=98=AF=E5=90=A6=E8= =BF=9D=E5=8F=8D=E7=BA=A6=E6=9D=9F=E3=80=82 + =E7=AC=AC=E4=BA=8C=E5=B1=82=EF=BC=8C=E5=AE=83=E8=83=BD=E5=B0=86=E7=BA=A6= =E6=9D=9F=E5=BA=94=E7=94=A8=E4=BA=8EHibernate=E5=85=83=E6=A8=A1=E5=9E=8B=E4= =B8=8A=EF=BC=8C=E5=B9=B6=E5=B0=86=E5=AE=83=E4=BB=AC=E8=9E=8D=E5=85=A5=E7=94= =9F=E6=88=90=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93schema=E4=B8=AD=E3=80=82 + = + =E6=AF=8F=E4=B8=AA=E7=BA=A6=E6=9D=9F=E6=B3=A8=E8=A7=A3=EF=BC=88con= straint annotation=EF=BC=89=E5=92=8C=E4=B8=80=E4=B8=AA=E9=AA=8C=E8=AF=81=E5= =99=A8=E5=AE=9E=E7=8E=B0=E5=85=B3=E8=81=94=EF=BC=8C=E8=AF=A5=E9=AA=8C=E8=AF= =81=E5=99=A8=E8=B4=9F=E8=B4=A3=E6=A3=80=E6=9F=A5=E4=BD=8D=E4=BA=8E=E5=AE=9E= =E4=BD=93=E5=AE=9E=E4=BE=8B=E4=B8=8A=E7=9A=84=E7=BA=A6=E6=9D=9F=E3=80=82 + =E4=B8=80=E4=B8=AA=E9=AA=8C=E8=AF=81=E5=99=A8=E4=B9=9F=E8=83=BD(=E5=8F= =AF=E9=80=89=E5=9C=B0)=E5=B0=86=E7=BA=A6=E6=9D=9F=E5=BA=94=E7=94=A8=E4=BA= =8EHibernate=E5=85=83=E6=A8=A1=E5=9E=8B=E4=B8=8A=EF=BC=8C=E8=AE=A9Hibernate= =E7=94=9F=E6=88=90=E8=A1=A8=E7=A4=BA=E8=BF=99=E4=B8=80=E7=BA=A6=E6=9D=9F=E7= =9A=84DDL=E3=80=82=E4=BD=BF=E7=94=A8=E5=90=88=E9=80=82=E7=9A=84=E4=BA=8B=E4= =BB=B6=E7=9B=91=E5=90=AC=E5=99=A8=EF=BC=8C=E4=BD=A0=E8=83=BD + =E8=AE=A9Hibernate=E5=9C=A8=E6=8F=92=E5=85=A5=E5=92=8C=E6=9B=B4=E6=96=B0= =E6=97=B6=E6=89=A7=E8=A1=8C=E6=A3=80=E6=9F=A5=E6=93=8D=E4=BD=9C=E3=80=82Hib= ernate=E9=AA=8C=E8=AF=81=E5=99=A8=E5=B9=B6=E4=B8=8D=E5=B1=80=E9=99=90=E4=BA= =8E=E5=90=8CHibernate=E4=B8=80=E8=B5=B7=E4=BD=BF=E7=94=A8=E3=80=82 + =E4=BD=A0=E8=83=BD=E5=9C=A8=E4=BD=A0=E5=BA=94=E7=94=A8=E7=A8=8B=E5=BA=8F= =E7=9A=84=E4=BB=BB=E4=BD=95=E5=9C=B0=E6=96=B9=E6=96=B9=E4=BE=BF=E5=9C=B0=E4= =BD=BF=E7=94=A8=E5=AE=83=E3=80=82 + + =E5=9C=A8=E8=BF=90=E8=A1=8C=E6=97=B6=E6=A3=80=E6=9F=A5=E5=AE=9E=E4= =BE=8B=E6=97=B6=EF=BC=8CHibernate=E9=AA=8C=E8=AF=81=E5=99=A8=E8=BF=94=E5=9B= =9E=E8=BF=9D=E5=8F=8D=E7=BA=A6=E6=9D=9F=E7=9A=84=E4=BF=A1=E6=81=AF=EF=BC=8C + =E8=BF=99=E4=BA=9B=E4=BF=A1=E6=81=AF=E4=BB=A5=E4=B8=80=E4=B8=AAInvalidValue=E6=95=B0=E7=BB=84=E7=9A=84=E5=BD=A2=E5=BC=8F=E8= =BF=94=E5=9B=9E=E3=80=82 + =E9=99=A4=E4=BA=86=E4=BC=97=E5=A4=9A=E5=85=B6=E4=BB=96=E4=BF=A1=E6=81=AF= =E5=A4=96=EF=BC=8CInvalidValue=E5=8C=85=E5=90=AB=E4= =BA=86=E4=B8=80=E4=B8=AA=E9=94=99=E8=AF=AF=E6=8F=8F=E8=BF=B0=E6=B6=88 + =E6=81=AF=EF=BC=8C=E8=AF=A5=E4=BF=A1=E6=81=AF=E5=8F=AF=E4=BB=A5=E5=86=85= =E5=B5=8C=E4=B8=8E=E6=B3=A8=E8=A7=A3=E7=9B=B8=E6=8D=86=E7=BB=91=E7=9A=84=E5= =8F=82=E6=95=B0=E5=80=BC=EF=BC=88=E4=BE=8B=E5=A6=82=E9=95=BF=E5=BA=A6=E9=99= =90=E5=88=B6=EF=BC=89=EF=BC=8C=E4=BB=A5=E5=8F=8A=E8=83=BD=E8=A2=AB=E6=8F=90= =E5=8F=96=E8=87=B3ResourceBundle=E7=9A=84=E6=B6=88=E6=81=AF=E5=AD=97=E4=B8= =B2=E3=80=82 + + + =E7=BA=A6=E6=9D=9F + + + =E4=BB=80=E4=B9=88=E6=98=AF=E7=BA=A6=E6=9D=9F=EF=BC=9F + + =E7=BA=A6=E6=9D=9F=E9=80=9A=E8=BF=87=E6=B3=A8=E8=A7=A3=E8=A1= =A8=E7=A4=BA=E3=80=82=E4=B8=80=E4=B8=AA=E7=BA=A6=E6=9D=9F=E9=80=9A=E5=B8=B8= =E6=9C=89=E4=B8=80=E4=BA=9B=E7=94=A8=E6=9D=A5=E5=8F=82=E6=95=B0=E5=8C=96=E7= =BA=A6=E6=9D=9F=E9=99=90=E5=88=B6=E7=9A=84=E5=B1=9E=E6=80=A7=E3=80=82=E7=BA= =A6=E6=9D=9F=E5=BA=94=E7=94=A8=E4=BA=8E=E5=B8=A6=E6=B3=A8=E8=A7=A3=E7=9A=84= =E5=85=83=E7=B4=A0=E3=80=82 + + + + =E5=86=85=E5=BB=BA=E7=BA=A6=E6=9D=9F + + Hibernate=E9=AA=8C=E8=AF=81=E5=99=A8=E6=9C=89=E4=BA=9B=E5=86= =85=E5=BB=BA=E7=BA=A6=E6=9D=9F=EF=BC=8C=E8=BF=99=E4=BA=9B=E7=BA=A6=E6=9D=9F= =E8=A6=86=E7=9B=96=E4=BA=86=E5=A4=A7=E5=A4=9A=E6=95=B0=E7=9A=84=E5=9F=BA=E6= =9C=AC=E6=95=B0=E6=8D=AE=E6=A3=80=E6=9F=A5=E3=80=82=E9=9A=8F=E5=90=8E=E6=88= =91=E4=BB=AC=E4=BC=9A=E7=9C=8B=E5=88=B0=EF=BC=8C + =E4=BD=A0=E4=B8=8D=E5=BF=85=E5=8F=97=E5=88=B6=E4=BA=8E=E8=BF=99=E4= =BA=9B=E5=86=85=E7=BD=AE=E7=BA=A6=E6=9D=9F=EF=BC=8C=E5=9B=A0=E4=B8=BA=E4=B8= =80=E5=88=86=E9=92=9F=E5=86=85=E5=B0=B1=E5=8F=AF=E4=BB=A5=E5=86=99=E5=87=BA= =E4=BD=A0=E8=87=AA=E5=B7=B1=E7=9A=84=E7=BA=A6=E6=9D=9F=E3=80=82 + + + =E5=86=85=E5=BB=BA=E7=BA=A6=E6=9D=9F + + + + + + + =E6=B3=A8=E8=A7=A3 + + =E5=BA=94=E7=94=A8=E7=9B=AE=E6=A0=87 + + =E8=BF=90=E8=A1=8C=E6=97=B6=E6=A3=80=E6=9F=A5 + + Hibernate=E5=85=83=E6=95=B0=E6=8D=AE=E5=BD=B1=E5=93= =8D + + + + + = + + @Length(min=3D, max=3D) + + =E5=B1=9E=E6=80=A7(String) + + =E6=A3=80=E6=9F=A5=E5=AD=97=E7=AC=A6=E4=B8=B2=E9=95= =BF=E5=BA=A6=E6=98=AF=E5=90=A6=E7=AC=A6=E5=90=88=E8=8C=83=E5=9B=B4 + + =E5=88=97=E9=95=BF=E5=BA=A6=E4=BC=9A=E8=A2=AB=E8=AE= =BE=E5=88=B0=E6=9C=80=E5=A4=A7=E5=80=BC + + + + @Max(value=3D) + + =E5=B1=9E=E6=80=A7 (=E4=BB=A5numeric=E6=88=96=E8=80= =85string=E7=B1=BB=E5=9E=8B=E6=9D=A5=E8=A1=A8=E7=A4=BA=E4=B8=80=E4=B8=AA=E6= =95=B0=E5=AD=97) + + =E6=A3=80=E6=9F=A5=E5=80=BC=E6=98=AF=E5=90=A6=E5=B0= =8F=E4=BA=8E=E6=88=96=E7=AD=89=E4=BA=8E=E6=9C=80=E5=A4=A7=E5=80=BC + + =E5=AF=B9=E5=88=97=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8= =AA=E6=A3=80=E6=9F=A5=E7=BA=A6=E6=9D=9F + + + + @Min(value=3D) + + =E5=B1=9E=E6=80=A7(=E4=BB=A5numeric=E6=88=96=E8=80=85= string=E7=B1=BB=E5=9E=8B=E6=9D=A5=E8=A1=A8=E7=A4=BA=E4=B8=80=E4=B8=AA=E6=95= =B0=E5=AD=97) + + =E6=A3=80=E6=9F=A5=E5=80=BC=E6=98=AF=E5=90=A6=E5=A4= =A7=E4=BA=8E=E6=88=96=E7=AD=89=E4=BA=8E=E6=9C=80=E5=B0=8F=E5=80=BC + + =E5=AF=B9=E5=88=97=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8= =AA=E6=A3=80=E6=9F=A5=E7=BA=A6=E6=9D=9F + + + + @NotNull + + =E5=B1=9E=E6=80=A7 + + =E6=A3=80=E6=9F=A5=E5=80=BC=E6=98=AF=E5=90=A6=E9=9D= =9E=E7=A9=BA(not null) + + =E5=88=97=E4=B8=8D=E4=B8=BA=E7=A9=BA + + + + @Past + + =E5=B1=9E=E6=80=A7(date=E6=88=96calendar) + + =E6=A3=80=E6=9F=A5=E6=97=A5=E6=9C=9F=E6=98=AF=E5=90= =A6=E6=98=AF=E8=BF=87=E5=8E=BB=E6=97=B6 + + =E5=AF=B9=E5=88=97=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8= =AA=E6=A3=80=E6=9F=A5=E7=BA=A6=E6=9D=9F + + + + @Future + + =E5=B1=9E=E6=80=A7 (date =E6=88=96 calendar) + + =E6=A3=80=E6=9F=A5=E6=97=A5=E6=9C=9F=E6=98=AF=E5=90= =A6=E6=98=AF=E5=B0=86=E6=9D=A5=E6=97=B6 + + =E6=97=A0 + + + + @Pattern(regex=3D"regexp", flag=3D) + + =E5=B1=9E=E6=80=A7 (string) + + =E6=A3=80=E6=9F=A5=E5=B1=9E=E6=80=A7=E6=98=AF=E5=90= =A6=E4=B8=8E=E7=BB=99=E5=AE=9A=E5=8C=B9=E9=85=8D=E6=A0=87=E5=BF=97=E7=9A=84= =E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F=E7=9B=B8=E5=8C=B9=E9=85=8D(= =E8=A7=81 = + java.util.regex.Pattern ) + + =E6=97=A0 + + + + @Range(min=3D, max=3D) + + =E5=B1=9E=E6=80=A7(=E4=BB=A5numeric=E6=88=96=E8=80=85= string=E7=B1=BB=E5=9E=8B=E6=9D=A5=E8=A1=A8=E7=A4=BA=E4=B8=80=E4=B8=AA=E6=95= =B0=E5=AD=97) + + =E6=A3=80=E6=9F=A5=E5=80=BC=E6=98=AF=E5=90=A6=E5=9C= =A8=E6=9C=80=E5=B0=8F=E5=92=8C=E6=9C=80=E5=A4=A7=E5=80=BC=E4=B9=8B=E9=97=B4= (=E5=8C=85=E6=8B=AC=E4=B8=B4=E7=95=8C=E5=80=BC) + + =E5=AF=B9=E5=88=97=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8= =AA=E6=A3=80=E6=9F=A5=E7=BA=A6=E6=9D=9F + + = + + @Size(min=3D, max=3D) + + =E5=B1=9E=E6=80=A7 (array, collection, map) + + =E6=A3=80=E6=9F=A5=E5=85=83=E7=B4=A0=E5=A4=A7=E5=B0= =8F=E6=98=AF=E5=90=A6=E5=9C=A8=E6=9C=80=E5=B0=8F=E5=92=8C=E6=9C=80=E5=A4=A7= =E5=80=BC=E4=B9=8B=E9=97=B4(=E5=8C=85=E6=8B=AC=E4=B8=B4=E7=95=8C=E5=80=BC)<= /entry> + + =E6=97=A0 + + + + @AssertFalse + + =E5=B1=9E=E6=80=A7 + + =E6=A3=80=E6=9F=A5=E6=96=B9=E6=B3=95=E7=9A=84=E6=BC= =94=E7=AE=97=E7=BB=93=E6=9E=9C=E6=98=AF=E5=90=A6=E4=B8=BAfalse(=E5=AF=B9=E4= =BB=A5=E4=BB=A3=E7=A0=81=E6=96=B9=E5=BC=8F=E8=80=8C=E4=B8=8D=E6=98=AF=E6=B3= =A8=E8=A7=A3=E8=A1=A8=E7=A4=BA=E7=9A=84=E7=BA=A6=E6=9D=9F=E5=BE=88=E6=9C=89= =E7=94=A8) + + =E6=97=A0 + + + + @AssertTrue + + =E5=B1=9E=E6=80=A7 + + =E6=A3=80=E6=9F=A5=E6=96=B9=E6=B3=95=E7=9A=84=E6=BC= =94=E7=AE=97=E7=BB=93=E6=9E=9C=E6=98=AF=E5=90=A6=E4=B8=BAtrue(=E5=AF=B9=E4= =BB=A5=E4=BB=A3=E7=A0=81=E6=96=B9=E5=BC=8F=E8=80=8C=E4=B8=8D=E6=98=AF=E6=B3= =A8=E8=A7=A3=E8=A1=A8=E7=A4=BA=E7=9A=84=E7=BA=A6=E6=9D=9F=E5=BE=88=E6=9C=89= =E7=94=A8) + + =E6=97=A0 + + + + @Valid + + =E5=B1=9E=E6=80=A7 (object) + + =E5=AF=B9=E5=85=B3=E8=81=94=E5=AF=B9=E8=B1=A1=E9=80= =92=E5=BD=92=E7=9A=84=E8=BF=9B=E8=A1=8C=E9=AA=8C=E8=AF=81=E3=80=82=E5=A6=82= =E6=9E=9C=E5=AF=B9=E8=B1=A1=E6=98=AF=E9=9B=86=E5=90=88=E6=88=96=E6=95=B0=E7= =BB=84=EF=BC=8C=E5=B0=B1=E9=80=92=E5=BD=92=E5=9C=B0=E9=AA=8C=E8=AF=81=E5=85= =B6=E5=85=83=E7=B4=A0=E3=80=82=E5=A6=82=E6=9E=9C=E5=AF=B9=E8=B1=A1=E6=98=AF= Map=EF=BC=8C=E5=88=99=E9=80=92=E5=BD=92=E9=AA=8C=E8=AF=81=E5=85=B6=E5=80=BC= =E5=85=83=E7=B4=A0=E3=80=82 + + =E6=97=A0 + + + + @Email + + =E5=B1=9E=E6=80=A7=EF=BC=88String=EF=BC=89 + + =E6=A3=80=E6=9F=A5=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=98= =AF=E5=90=A6=E7=AC=A6=E5=90=88=E6=9C=89=E6=95=88=E7=9A=84email=E5=9C=B0=E5= =9D=80=E8=A7=84=E8=8C=83=E3=80=82 + + =E6=97=A0 + + + + +
+
+ + + =E9=94=99=E8=AF=AF=E4=BF= =A1=E6=81=AF + + Hibernate=E9=AA=8C=E8=AF=81=E5=99=A8=E6=8F=90=E4=BE=9B=E4=BA= =86=E4=B8=80=E7=BB=84=E9=BB=98=E8=AE=A4=E7=9A=84=E9=94=99=E8=AF=AF=E6=8F=90= =E7=A4=BA=E4=BF=A1=E6=81=AF=EF=BC=8C=E5=AE=83=E4=BB=AC=E8=A2=AB=E7=BF=BB=E8= =AF=91=E6=88=90=E5=A4=9A=E7=A7=8D=E8=AF=AD=E8=A8=80(=E5=A6=82=E6=9E=9C=E4= =BD=A0=E7=9A=84=E8=AF=AD=E8=A8=80=E4=B8=8D=E5=9C=A8=E5=85=B6=E4=B8=AD=EF=BC= =8C=E8=AF=B7=E7=BB=99 + =E6=88=91=E4=BB=AC=E5=AF=84=E4=B8=80=E4=B8=AA=E8=A1=A5=E4=B8=81)=E3= =80=82=E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=9C=A8org.hibernate.validator= .resources.DefaultValidatorMessages.properties + =E4=B9=8B=E5=A4=96=E5=88=9B=E5=BB=BAValidatorMessages.prop= erties=E6=88=96ValidatorMessages_loc.properties + =E6=96=87=E4=BB=B6=E5=B9=B6=E6=94=B9=E5=8F=98=E7=9B=B8=E5=BA=94=E7= =9A=84=E9=94=AE=E5=80=BC=EF=BC=8C=E7=B1=8D=E6=AD=A4=E8=A6=86=E7=9B=96=E9=82= =A3=E4=BA=9B=EF=BC=88=E9=BB=98=E8=AE=A4=EF=BC=89=E4=BF=A1=E6=81=AF=E3=80=82= =E4=BD=A0=E7=94=9A=E8=87=B3=E5=8F=AF=E4=BB=A5=E5=9C=A8=E5=86=99=E8=87=AA=E5= =B7=B1=E7=9A=84=E9=AA=8C=E8=AF=81=E5=99=A8 + =E6=B3=A8=E8=A7=A3=E6=97=B6=E6=B7=BB=E5=8A=A0=E4=BD=A0=E8=87=AA=E5= =B7=B1=E7=9A=84=E9=99=84=E5=8A=A0=E6=B6=88=E6=81=AF=E9=9B=86=E3=80=82 + + =E6=88=96=E8=80=85=E4=BD=A0=E5=8F=AF=E4=BB=A5=E4=BB=A5=E7=BC= =96=E7=A8=8B=E6=96=B9=E5=BC=8F=E6=A3=80=E6=9F=A5bean=E7=9A=84=E9=AA=8C=E8= =AF=81=E8=A7=84=E5=88=99=E5=B9=B6=E6=8F=90=E4=BE=9B=E7=9B=B8=E5=BA=94=E7=9A= =84ResourceBundle=E3=80=82 + + + + =E7=BC=96=E5=86=99=E4=BD=A0=E8=87=AA=E5=B7=B1=E7=9A=84=E7=BA= =A6=E6=9D=9F + + =E6=89=A9=E5=B1=95=E5=86=85=E5=BB=BA=E7=BA=A6=E6=9D=9F=E9=9B= =86=E6=98=AF=E6=9E=81=E5=85=B6=E6=96=B9=E4=BE=BF=E7=9A=84=E3=80=82=E4=BB=BB= =E4=BD=95=E7=BA=A6=E6=9D=9F=E9=83=BD=E5=8C=85=E6=8B=AC=E4=B8=A4=E9=83=A8=E5= =88=86=EF=BC=9A=E7=BA=A6=E6=9D=9F=E6=8F=8F=E8=BF=B0=E7=AC=A6(=E6=B3=A8=E8=A7=A3) + =E5=92=8C=E7=BA=A6=E6=9D=9F=E9=AA=8C=E8=AF=81=E5=99=A8(=E5=AE=9E=E7=8E=B0=E7=B1=BB)=E3=80=82=E4=B8=8B=E9=9D=A2=E6=98=AF=E4= =B8=80=E4=B8=AA=E7=AE=80=E5=8D=95=E7=9A=84=E7=94=A8=E6=88=B7=E5=AE=9A=E4=B9= =89=E6=8F=8F=E8=BF=B0=E7=AC=A6=EF=BC=9A + + @ValidatorClass(CapitalizedValidator.class) +(a)Target(METHOD) = +(a)Retention(RUNTIME) +(a)Documented +public @interface Capitalized { + CapitalizeType type() default Capitalize.FIRST; + String message() default "has incorrect capitalization"; +} + + type=E5=8F=82=E6=95=B0=E6=8F=8F=E8=BF=B0=E5= =B1=9E=E6=80=A7=E5=BA=94=E8=AF=A5=E5=A6=82=E4=BD=95=E8=A2=AB=E5=A4=A7=E5=86= =99=E3=80=82=E8=BF=99=E6=98=AF=E4=B8=80=E4=B8=AA=E5=AE=8C=E5=85=A8=E4=BE=9D= =E8=B5=96=E4=BA=8E=E6=B3=A8=E8=A7=A3=E4=B8=9A=E5=8A=A1(=E9=80=BB=E8=BE=91)= =E7=9A=84=E7=94=A8=E6=88=B7 + =E5=8F=82=E6=95=B0=E3=80=82 + + message=E6=98=AF=E7=94=A8=E4=BA=8E=E6=8F=8F= =E8=BF=B0=E7=BA=A6=E6=9D=9F=E8=BF=9D=E8=A7=84=E7=9A=84=E9=BB=98=E8=AE=A4=E5= =AD=97=E7=AC=A6=E4=B8=B2=EF=BC=8C=E5=AE=83=E6=98=AF=E5=BC=BA=E5=88=B6=E8=A6= =81=E6=B1=82=E7=9A=84=E3=80=82=E4=BD=A0=E5=8F=AF=E4=BB=A5=E9=87=87=E5=8F=96= =E7=A1=AC=E7=BC=96=E7=A0=81=E7=9A=84=E6=96=B9=E5=BC=8F=EF=BC=8C + =E6=88=96=E8=80=85=E9=80=9A=E8=BF=87Java ResourceBundle=E6=9C=BA=E5= =88=B6=E5=B0=86message=E7=9A=84=E9=83=A8=E5=88=86/=E5=85=A8=E9=83=A8=E5=86= =85=E5=AE=B9=E6=8F=90=E5=8F=96=E8=87=B3=E5=A4=96=E9=83=A8=E6=96=87=E4=BB=B6= =E3=80=82=E4=B8=80=E6=97=A6=E5=8F=91=E7=8E=B0message=E4=B8=AD{parameter}=E5= =AD=97=E7=AC=A6=E4=B8=B2=EF=BC=8C + =E5=B0=B1=E4=BC=9A=E5=9C=A8{parameter}=E8=BF=99=E4=B8=AA=E4=BD=8D=E7= =BD=AE=E6=B3=A8=E5=85=A5=E7=9B=B8=E5=BA=94=E7=9A=84=E5=8F=82=E6=95=B0=E5=80= =BC(=E5=9C=A8=E6=88=91=E4=BB=AC=E7=9A=84=E4=BE=8B=E5=AD=90=E9=87=8CCapitali= zation is not {type}=E4=BC=9A=E7=94=9F=E6=88=90 Capitalization is not FIRST= )=EF=BC=8C + =E5=8F=AF=E4=BB=A5=E5=B0=86message=E5=AF=B9=E5=BA=94=E7=9A=84=E6=95= =B4=E4=B8=AA=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=8F=90=E5=8F=96=E8=87=B3=E5=A4=96= =E9=83=A8=E6=96=87=E4=BB=B6ValidatorMessages.properties=EF=BC=8C=E8=BF=99= =E4=B9=9F=E6=98=AF=E4=B8=80=E7=A7=8D=E8=89=AF=E5=A5=BD=E5=AE=9E=E8=B7=B5=E3= =80=82 + =E8=A7=81=E3=80=82 + + @ValidatorClass(CapitalizedValidator.class) +(a)Target(METHOD) = +(a)Retention(RUNTIME) +(a)Documented +public @interface Capitalized { + CapitalizeType type() default Capitalize.FIRST; + String message() default "{validator.capitalized}"; +} + +... +#in ValidatorMessages.properties +validator.capitalized=3DCapitalization is not {type} + + =E5=A6=82=E4=BD=A0=E6=89=80=E8=A7=81{}=E7=AC=A6=E5=8F=B7=E6=98= =AF=E9=80=92=E5=BD=92=E7=9A=84=E3=80=82 + + =E4=B8=BA=E4=BA=86=E5=B0=86=E4=B8=80=E4=B8=AA=E6=8F=8F=E8=BF= =B0=E7=AC=A6=E8=BF=9E=E6=8E=A5=E5=88=B0=E5=AE=83=E7=9A=84=E9=AA=8C=E8=AF=81= =E5=99=A8=E5=AE=9E=E7=8E=B0=EF=BC=8C=E6=88=91=E4=BB=AC=E4=BD=BF=E7=94=A8@ValidatorClass + =E5=85=83=E6=B3=A8=E8=A7=A3=E3=80=82=E9=AA=8C=E8=AF=81=E5=99=A8=E7= =B1=BB=E5=8F=82=E6=95=B0=E5=BF=85=E9=A1=BB=E6=8C=87=E5=AE=9A=E4=B8=80=E4=B8= =AA=E5=AE=9E=E7=8E=B0=E4=BA=86Validator<ConstraintAnnotation>= ; + =E7=9A=84=E7=B1=BB=E3=80=82 + + =E6=88=91=E4=BB=AC=E7=8E=B0=E5=9C=A8=E8=A6=81=E5=AE=9E=E7=8E= =B0=E9=AA=8C=E8=AF=81=E5=99=A8(=E4=B9=9F=E5=B0=B1=E6=98=AF=E5=AE=9E=E7=8E= =B0=E8=A7=84=E5=88=99=E6=A3=80=E6=9F=A5)=E3=80=82=E4=B8=80=E4=B8=AA=E9=AA= =8C=E8=AF=81=E5=99=A8=E5=AE=9E=E7=8E=B0=E8=83=BD=E6=A3=80=E6=9F=A5=E4=B8=80= =E4=B8=AA=E5=B1=9E=E6=80=A7=E7=9A=84=E5=80=BC + (=E5=AE=9E=E7=8E=B0PropertyConstraint)=EF=BC=8C= =E5=B9=B6=E4=B8=94/=E6=88=96=E8=80=85=E5=8F=AF=E4=BB=A5=E4=BF=AE=E6=94=B9hi= bernate=E6=98=A0=E5=B0=84=E5=85=83=E6=95=B0=E6=8D=AE + (=E5=AE=9E=E7=8E=B0PersistentClassConstraint)=EF= =BC=8C=E7=B1=8D=E6=AD=A4=E8=A1=A8=E7=A4=BA=E6=95=B0=E6=8D=AE=E5=BA=93=E7=BA= =A7=E7=9A=84=E7=BA=A6=E6=9D=9F=E3=80=82 + + public class CapitalizedValidator = + implements Validator<Capitalized>, PropertyConstraint { + private CapitalizeType type; + + //part of the Validator<Annotation> contract, = + //allows to get and use the annotation values + public void initialize(Capitalized parameters) { + type =3D parameters.type(); + } + + //part of the property constraint contract + public boolean isValid(Object value) { + if (value=3D=3Dnull) return true; + if ( !(value instanceof String) ) return false; + String string =3D (String) value; + if (type =3D=3D CapitalizeType.ALL) { + return string.equals( string.toUpperCase() ); + } + else { + String first =3D string.substring(0,1); + return first.equals( first.toUpperCase(); + } + } +} + + =E5=A6=82=E6=9E=9C=E8=BF=9D=E5=8F=8D=E7=BA=A6=E6=9D=9F=EF=BC= =8CisValid()=E6=96=B9=E6=B3=95=E5=B0=86=E8=BF=94=E5=9B= =9Efalse=E3=80=82=E6=9B=B4=E5=A4=9A=E4=BE=8B=E5=AD=90=E8=AF=B7=E5=8F=82=E8= =80=83=E5=86=85=E5=BB=BA=E9=AA=8C=E8=AF=81=E5=99=A8=E5=AE=9E=E7=8E=B0=E3=80= =82 + + =E8=87=B3=E6=AD=A4=E6=88=91=E4=BB=AC=E5=8F=AA=E7=9C=8B=E5=88= =B0=E5=B1=9E=E6=80=A7=E7=BA=A7=E7=9A=84=E9=AA=8C=E8=AF=81=EF=BC=8C=E4=BD=A0= =E8=BF=98=E5=8F=AF=E4=BB=A5=E5=86=99=E4=B8=80=E4=B8=AABean=E7=BA=A7=E5=88= =AB=E7=9A=84=E9=AA=8C=E8=AF=81=E6=B3=A8=E8=A7=A3=E3=80=82Bean=E8=87=AA=E8= =BA=AB=E4=BC=9A=E8=A2=AB=E4=BC=A0=E9=80=92=E7=BB=99=E9=AA=8C=E8=AF=81=E5=99= =A8=EF=BC=8C + =E8=80=8C=E4=B8=8D=E6=98=AFbean=E7=9A=84=E5=B1=9E=E6=80=A7=E5=AE=9E= =E4=BE=8B=E3=80=82=E5=8F=AA=E8=A6=81=E5=AF=B9bean=E8=87=AA=E8=BA=AB=E8=BF= =9B=E8=A1=8C=E6=B3=A8=E8=A7=A3=E5=8D=B3=E5=8F=AF=E6=BF=80=E6=B4=BB=E9=AA=8C= =E8=AF=81=E6=A3=80=E6=9F=A5=E3=80=82=E5=9C=A8=E5=8D=95=E5=85=83=E6=B5=8B=E8= =AF=95=E5=A5=97=E4=BB=B6=E4=B8=AD=E8=BF=98=E5=8F=AF=E4=BB=A5=E6=89=BE=E5=88= =B0=E4=B8=80=E4=B8=AA=E5=B0=8F=E4=BE=8B=E5=AD=90=E3=80=82 + + + + =E6=B3=A8=E8=A7=A3=E4=BD=A0=E7=9A=84=E9=A2=86=E5=9F=9F=E6=A8= =A1=E5=9E=8B + + =E6=97=A2=E7=84=B6=E4=BD=A0=E7=8E=B0=E5=9C=A8=E5=B7=B2=E7=BB= =8F=E7=86=9F=E6=82=89=E6=B3=A8=E8=A7=A3=E4=BA=86=EF=BC=8C=E9=82=A3=E4=B9=88= =E5=AF=B9=E8=AF=AD=E6=B3=95=E4=B9=9F=E5=BA=94=E8=AF=A5=E5=BE=88=E6=B8=85=E6= =A5=9A=E4=BA=86=E3=80=82 + + public class Address { + private String line1; + private String line2; + private String zip; + private String state; + private String country; + private long id; + = + // a not null string of 20 characters maximum + @Length(max=3D20) = + @NotNull + public String getCountry() { + return country; + } + = + // a non null string + @NotNull + public String getLine1() { + return line1; + } + + //no constraint = + public String getLine2() { + return line2; + } + = + // a not null string of 3 characters maximum + @Length(max=3D3) @NotNull + public String getState() { + return state; + } + + // a not null numeric string of 5 characters maximum + // if the string is longer, the message will = + //be searched in the resource bundle at key 'long' + @Length(max=3D5, message=3D"{long}") + @Pattern(regex=3D"[0-9]+") + @NotNull + public String getZip() { + return zip; + } + = + // should always be true + @AssertTrue + public boolean isValid() { + return true; + } + + // a numeric between 1 and 2000 + @Id @Min(1) + @Range(max=3D2000) + public long getId() { + return id; + } +} + + =E4=B8=8A=E9=9D=A2=E7=9A=84=E4=BE=8B=E5=AD=90=E5=8F=AA=E5=B1= =95=E7=A4=BA=E4=BA=86=E5=85=AC=E5=85=B1=E5=B1=9E=E6=80=A7=E9=AA=8C=E8=AF=81= =EF=BC=8C=E4=BD=A0=E8=BF=98=E5=8F=AF=E4=BB=A5=E5=AF=B9=E4=BB=BB=E4=BD=95=E5= =8F=AF=E8=A7=81=E5=BA=A6=E7=9A=84=E5=AD=97=E6=AE=B5(field)=E8=BF=9B=E8=A1= =8C=E6=B3=A8=E8=A7=A3=E3=80=82 + + @MyBeanConstraint(max=3D45) +public class Dog { + @AssertTrue private boolean isMale; + @NotNull protected String getName() { ... }; + ... +} + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=AF=B9=E6=8E=A5=E5=8F=A3=E8=BF= =9B=E8=A1=8C=E6=B3=A8=E8=A7=A3=E3=80=82Hibernate=E9=AA=8C=E8=AF=81=E5=99=A8= =E4=BC=9A=E6=A3=80=E6=9F=A5=E7=BB=99=E5=AE=9Abean=E6=89=80=E6=89=A9=E5=B1= =95=E6=88=96=E5=AE=9E=E7=8E=B0=E7=9A=84=E6=89=80=E6=9C=89=E7=88=B6=E7=B1=BB= =E5=92=8C=E6=8E=A5=E5=8F=A3=EF=BC=8C + =E7=B1=8D=E4=BB=A5=E8=AF=BB=E5=8F=96=E7=9B=B8=E5=BA=94=E7=9A=84=E9= =AA=8C=E8=AF=81=E5=99=A8=E6=B3=A8=E8=A7=A3(=E4=BF=A1=E6=81=AF)=E3=80=82 + + public interface Named { + @NotNull String getName(); + ... +} + +public class Dog implements Named { + + @AssertTrue private boolean isMale; + + public String getName() { ... }; + +} + + =E5=9C=A8=E9=AA=8C=E8=AF=81Dog bean=E6=97=B6=E4=BC=9A=E6=A3=80= =E6=9F=A5name=E5=B1=9E=E6=80=A7=E7=9A=84=E6=9C=89=E6=95=88=E6=80=A7(=E4=B8= =8D=E4=B8=BAnull)=E3=80=82 + +
+ + + =E4=BD=BF=E7=94=A8=E9=AA=8C=E8=AF=81=E5=99=A8=E6=A1=86=E6=9E=B6= + + Hibernate=E9=AA=8C=E8=AF=81=E5=99=A8=E6=97=A8=E5=9C=A8=E5=AE=9E= =E7=8E=B0=E5=A4=9A=E5=B1=82=E6=95=B0=E6=8D=AE=E9=AA=8C=E8=AF=81=EF=BC=8C=E6= =88=91=E4=BB=AC=E5=9C=A8=E4=B8=80=E5=A4=84=E8=A1=A8=E7=A4=BA=E7=BA=A6=E6=9D= =9F(=E5=B8=A6=E6=B3=A8=E8=A7=A3=E7=9A=84=E5=9F=9F=E6=A8=A1=E5=9E=8B)=EF=BC= =8C=E7=84=B6=E5=90=8E=E5=B0=86=E5=85=B6=E8=BF=90=E7=94=A8=E4=BA=8E + =E5=BA=94=E7=94=A8=E7=A8=8B=E5=BA=8F=E7=9A=84=E4=B8=8D=E5=90=8C=E5=B1= =82=E3=80=82 + + + =E6=95=B0=E6=8D=AE=E5=BA=93schema=E5=B1=82=E6=AC=A1=E9=AA=8C= =E8=AF=81 + + =E6=97=A0=E9=A1=BB=E9=A2=9D=E5=A4=96=E6=89=8B=E7=BB=AD=EF=BC= =8CHibernate Annotations=E4=BC=9A=E8=87=AA=E5=8A=A8=E5=B0=86=E4=BD=A0=E4=B8= =BA=E5=AE=9E=E4=BD=93=E5=AE=9A=E4=B9=89=E7=9A=84=E7=BA=A6=E6=9D=9F=E7=BF=BB= =E8=AF=91=E4=B8=BA=E6=98=A0=E5=B0=84=E5=85=83=E6=95=B0=E6=8D=AE=E3=80=82=E4= =BE=8B=E5=A6=82=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E7=9A=84=E5=AE=9E=E4=BD= =93 + =E7=9A=84=E4=B8=80=E4=B8=AA=E5=B1=9E=E6=80=A7=E6=B3=A8=E8=A7=A3=E4= =B8=BA@NotNull=EF=BC=8C=E5=9C=A8Hibernate=E7=94=9F=E6=88= =90=E7=9A=84DDL schema=E4=B8=AD=E8=BF=99=E5=88=97=E4=BC=9A=E8=A2=AB=E5=AE= =9A=E4=B9=89=E4=B8=BA + not null=E3=80=82 + + + + Hibernate=E5=9F=BA=E4=BA=8E=E4=BA=8B=E4=BB=B6=E7=9A=84=E9=AA= =8C=E8=AF=81 + + Hibernate=E9=AA=8C=E8=AF=81=E5=99=A8=E6=9C=89=E4=B8=A4=E4=B8= =AA=E5=86=85=E5=BB=BAHibernate=E4=BA=8B=E4=BB=B6=E7=9B=91=E5=90=AC=E5=99=A8= =E3=80=82=E5=BD=93=E4=B8=80=E4=B8=AAPreInsertEvent + =E6=88=96PreUpdateEvent=E5=8F=91=E7=94=9F=E6=97= =B6=EF=BC=8C=E7=9B=91=E5=90=AC=E5=99=A8=E4=BC=9A=E9=AA=8C=E8=AF=81=E8=AF=A5= =E5=AE=9E=E4=BD=93=E5=AE=9E=E4=BE=8B=E7=9A=84=E6=89=80=E6=9C=89=E7=BA=A6=E6= =9D=9F=EF=BC=8C=E5=A6=82=E6=9C=89=E8=BF=9D=E5=8F=8D=E4=BC=9A=E6=8A=9B=E5=87= =BA=E4=B8=80=E4=B8=AA=E5=BC=82=E5=B8=B8=E3=80=82 + =E5=9F=BA=E6=9C=AC=E4=B8=8A=EF=BC=8C=E5=9C=A8Hibernate=E6=89=A7=E8= =A1=8C=E4=BB=BB=E4=BD=95=E6=8F=92=E5=85=A5=E5=92=8C=E6=9B=B4=E6=96=B0=E5=89= =8D=E5=AF=B9=E8=B1=A1=E4=BC=9A=E8=A2=AB=E6=A3=80=E6=9F=A5=E3=80=82=E8=BF=99= =E6=98=AF=E6=BF=80=E6=B4=BB=E9=AA=8C=E8=AF=81=E8=BF=87=E7=A8=8B=E7=9A=84=E6= =9C=80=E4=BE=BF=E6=8D=B7=E6=9C=80=E7=AE=80=E5=8D=95=E7=9A=84=E6=96=B9=E6=B3= =95=E3=80=82=E5=BD=93=E9=81=87=E5=88=B0=E7=BA=A6=E6=9D=9F + =E8=BF=9D=E8=A7=84=E6=97=B6=EF=BC=8C=E4=BA=8B=E4=BB=B6=E4=BC=9A=E5= =BC=95=E5=8F=91=E4=B8=80=E4=B8=AA=E8=BF=90=E8=A1=8C=E6=97=B6Inva= lidStateException=EF=BC=8C=E8=AF=A5=E5=BC=82=E5=B8=B8=E5=8C=85= =E5=90=AB=E4=B8=80=E4=B8=AA=E6=8F=8F=E8=BF=B0=E6=AF=8F=E4=B8=AA=E9=94=99=E8= =AF=AF=E7=9A=84 + InvalidValue=E6=95=B0=E7=BB=84=E3=80=82 + + <hibernate-configuration> + ... + <event type=3D"pre-update"> + <listener = + class=3D"org.hibernate.validator.event.ValidatePreUpdateEventLis= tener"/> + </event> + <event type=3D"pre-insert"> + <listener = + class=3D"org.hibernate.validator.event.ValidatePreInsertEventLis= tener"/> + </event> +</hibernate-configuration> + + + =E5=9C=A8=E4=BD=BF=E7=94=A8Hibernate Entity Manager=E6=97= =B6=EF=BC=8CValidation=E6=A1=86=E6=9E=B6=E4=BC=9A=E8=A2=AB=E8=87=AA=E5=8A= =A8=E6=BF=80=E6=B4=BB=E3=80=82=E5=A6=82=E6=9E=9Cbean=E4=B8=8D=E5=B8=A6=E9= =AA=8C=E8=AF=81=E6=B3=A8=E8=A7=A3=EF=BC=8C + =E5=B0=B1=E4=B8=8D=E4=BC=9A=E6=9C=89=E6=80=A7=E8=83=BD=E6=8D=9F= =E5=A4=B1=E3=80=82 + + + + + =E7=A8=8B=E5=BA=8F=E7=BA=A7=E9=AA=8C=E8=AF=81 + + Hibernate=E9=AA=8C=E8=AF=81=E5=99=A8=E8=83=BD=E5=BA=94=E7=94= =A8=E4=BA=8E=E4=BD=A0=E5=BA=94=E7=94=A8=E7=A8=8B=E5=BA=8F=E4=BB=A3=E7=A0=81= =E4=B8=AD=E7=9A=84=E4=BB=BB=E4=BD=95=E5=9C=B0=E6=96=B9=E3=80=82 + + ClassValidator personValidator =3D new ClassValidato= r( Person.class ); +ClassValidator addressValidator =3D new ClassValidator( Address.class, Res= ourceBundle.getBundle("messages", Locale.ENGLISH) ); + +InvalidValue[] validationMessages =3D addressValidator.getInvalidValues(ad= dress); + + =E5=A4=B4=E4=B8=A4=E8=A1=8C=E4=B8=BA=E6=89=A7=E8=A1=8C=E7=B1= =BB=E6=A3=80=E6=9F=A5=E8=80=8C=E5=87=86=E5=A4=87Hibernate=E9=AA=8C=E8=AF=81= =E5=99=A8=E3=80=82=E7=AC=AC=E4=B8=80=E8=A1=8C=E4=BE=9D=E8=B5=96=E4=BA=8E=E5= =B5=8C=E5=85=A5=E5=9C=A8Hibernate=E9=AA=8C=E8=AF=81=E5=99=A8=E5=86=85=E7=9A= =84=E9=94=99=E8=AF=AF + =E6=B6=88=E6=81=AF(=E8=A7=81)=EF=BC=8C=E7=AC=AC=E4=BA=8C=E8=A1=8C=E4=B8=BA=E8=BF=99=E4=BA=9B=E6= =B6=88=E6=81=AF=E5=87=86=E5=A4=87=E8=B5=84=E6=BA=90=E5=8C=85=E3=80=82=E8=BF= =99=E4=BA=9B=E4=BB=A3=E7=A0=81=E5=8F=AA=E6=89=A7=E8=A1=8C=E4=B8=80=E6=AC=A1= =EF=BC=8C + =E5=B9=B6=E5=B0=86=E9=AA=8C=E8=AF=81=E5=99=A8=E8=BF=9B=E8=A1=8C=E7= =BC=93=E5=AD=98=E5=A4=84=E7=90=86=EF=BC=8C=E8=BF=99=E7=A7=8D=E6=96=B9=E5=BC= =8F=E6=98=AF=E4=B8=80=E7=A7=8D=E8=89=AF=E5=A5=BD=E5=AE=9E=E8=B7=B5=E3=80=82= + + =E7=AC=AC=E4=B8=89=E8=A1=8C=E7=9C=9F=E6=AD=A3=E9=AA=8C=E8=AF= =81=E4=BA=86Address=E5=AE=9E=E4=BE=8B=E5=B9=B6=E8=BF=94= =E5=9B=9E=E4=B8=80=E4=B8=AAInvalidValue=E6=95=B0=E7=BB= =84=E3=80=82 + =E4=BD=A0=E7=9A=84=E5=BA=94=E7=94=A8=E7=A8=8B=E5=BA=8F=E9=80=BB=E8= =BE=91=E9=9A=8F=E5=90=8E=E5=8F=AF=E4=BB=A5=E5=AF=B9=E9=94=99=E8=AF=AF=E5=81= =9A=E5=87=BA=E5=93=8D=E5=BA=94=E3=80=82 + + =E9=99=A4=E4=BA=86=E9=92=88=E5=AF=B9=E6=95=B4=E4=B8=AAbean=E4= =BD=A0=E8=BF=98=E5=8F=AF=E4=BB=A5=E5=AF=B9=E6=9F=90=E4=B8=AA=E7=89=B9=E5=AE= =9A=E5=B1=9E=E6=80=A7=E8=BF=9B=E8=A1=8C=E6=A3=80=E6=9F=A5=E3=80=82=E8=BF=99= =E5=AF=B9=E4=BA=8E=E4=B8=80=E4=B8=AA=E5=B1=9E=E6=80=A7=E4=B8=80=E4=B8=AA=E5= =B1=9E=E6=80=A7=E7=9A=84=E7=94=A8=E6=88=B7=E4=BA=A4=E4=BA=92=E6=83=85=E5=BD= =A2=E6=88=96=E8=AE=B8=E6=98=AF=E6=9C=89=E7=94=A8=E7=9A=84=E3=80=82 + + ClassValidator addressValidator =3D new ClassValidat= or( Address.class, ResourceBundle.getBundle("messages", Locale.ENGLISH) ); + +//only get city property invalid values +InvalidValue[] validationMessages =3D addressValidator.getInvalidValues(ad= dress, "city"); + +//only get potential city property invalid values +InvalidValue[] validationMessages =3D addressValidator.getPotentialInvalid= Values("city", "Paris") + + + + =E9=AA=8C=E8=AF=81=E4=BF=A1=E6=81=AF + + =E4=BD=9C=E4=B8=BA=E4=B8=80=E4=B8=AA=E9=AA=8C=E8=AF=81=E4=BF= =A1=E6=81=AF=E7=9A=84=E8=BD=BD=E4=BD=93=EF=BC=8Chibernate=E6=8F=90=E4=BE=9B= =E4=BA=86=E4=B8=80=E4=B8=AAInvalidValue=E6=95=B0=E7= =BB=84=E3=80=82 + =E6=AF=8F=E4=B8=AAInvalidValue=E6=9C=89=E4=B8=80= =E7=BB=84=EF=BC=8C=E8=BF=99=E4=BA=9B=E6=96=B9=E6=B3=95=E5=88=86=E5=88=AB=E6= =8F=8F=E8=BF=B0=E7=9B=B8=E5=BA=94=E7=9A=84=E4=B8=AA=E4=BD=93=E9=97=AE=E9=A2= =98=E3=80=82 + + getBeanClass()=E8=8E=B7=E5=8F=96=E5= =A4=B1=E8=B4=A5=E7=9A=84bean=E7=B1=BB=E5=9E=8B=E3=80=82 + + getBean()=E8=8E=B7=E5=8F=96=E9=AA=8C= =E8=AF=81=E5=A4=B1=E8=B4=A5=E7=9A=84=E5=AE=9E=E4=BE=8B(=E5=A6=82=E6=9E=9C= =E6=9C=89=E7=9A=84=E8=AF=9D=EF=BC=8C=E5=BD=93=E4=BD=BF=E7=94=A8 + getPotentianInvalidValues()=E6=97=B6=E5=88= =99=E4=B8=8D=E4=BC=9A=E5=8F=96=E5=88=B0) + + getValue()=E8=8E=B7=E5=8F=96=E9=AA=8C= =E8=AF=81=E5=A4=B1=E8=B4=A5=E7=9A=84=E5=80=BC + + getMessage()=E8=8E=B7=E5=8F=96=E5=90= =88=E9=80=82=E7=9A=84=E5=9B=BD=E9=99=85=E5=8C=96=E9=94=99=E8=AF=AF=E6=B6=88= =E6=81=AF + + getRootBean()=E8=8E=B7=E5=8F=96=E4=BA= =A7=E7=94=9F=E9=97=AE=E9=A2=98=E7=9A=84=E6=A0=B9bean=E5=AE=9E=E4=BE=8B(=E5= =9C=A8=E4=B8=8E@Valid=E8=BF=9E=E7=94=A8 + =E6=97=B6=E5=BE=88=E6=9C=89=E7=94=A8)=EF=BC=8C=E5=A6=82=E7=94=A8getP= otentianInvalidValues()=E5=88=99=E8=BF=94=E5=9B=9Enull=E3=80=82 + + getPropertyPath()=E8=8E=B7=E5=8F=96=E2=80= =9C=E9=97=AE=E9=A2=98=E2=80=9D=E5=B1=9E=E6=80=A7=E4=BB=8E=E6=A0=B9bean=E5= =BC=80=E5=A7=8B=E7=9A=84=E5=B8=A6=E7=82=B9=E7=9A=84=E8=B7=AF=E5=BE=84 + + +
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/xml= -overriding.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/xml-ov= erriding.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/modules/xml-ov= erriding.xml 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,345 @@ + + + =E9=80=9A=E8=BF=87XML=E8=A6=86=E5=86=99=E5=85=83=E6=95=B0=E6=8D= =AE + + =E5=9C=A8EJB3=E4=B8=AD=E5=85=83=E6=95=B0=E6=8D=AE=E7=9A=84=E4=B8= =BB=E8=A6=81=E7=9B=AE=E6=A0=87=E6=98=AF=E4=BD=BF=E7=94=A8=E6=B3=A8=E9=87=8A= ,=E4=BD=86=E6=98=AFEJB3=E8=A7=84=E8=8C=83=E4=B9=9F=E6=8F=90=E4=BE=9B=E9=80= =9A=E8=BF=87XML=E9=83=A8=E7=BD=B2=E6=96=87=E4=BB=B6=E6=9D=A5=E8=A6=86=E5=86= =99=E6=88=96=E8=80=85=E6=9B=BF=E6=8D=A2=E5=85=83=E6=95=B0=E6=8D=AE=E6=B3=A8= =E9=87=8A. + =E5=9C=A8=E5=BD=93=E5=89=8D=E7=9A=84=E5=8F=91=E5=B8=83=E7=89=88=E6=9C=AC= =E4=BB=85=E4=BB=85=E6=94=AF=E6=8C=81EJB3=E6=B3=A8=E9=87=8A=E7=9A=84=E8=A6= =86=E5=86=99,=E5=A6=82=E6=9E=9C=E4=BD=A0=E6=83=B3=E4=BD=BF=E7=94=A8Hibernat= e=E7=89=B9=E6=9C=89=E7=9A=84=E4=B8=80=E4=BA=9B=E5=AE=9E=E4=BD=93=E6=B3=A8= =E9=87=8A, + =E4=BD=A0=E6=9C=89=E4=B8=A4=E7=A7=8D=E9=80=89=E6=8B=A9:=E4=B8=80,=E5=8F= =AA=E4=BD=BF=E7=94=A8=E6=B3=A8=E9=87=8A;=E4=BA=8C,=E4=BD=BF=E7=94=A8=E5=8E= =9F=E6=9D=A5=E7=9A=84hbm =E6=98=A0=E5=B0=84=E6=96=87=E4=BB=B6.=E4=BD=A0=E5= =BD=93=E7=84=B6=E8=BF=98=E6=98=AF=E5=8F=AF=E4=BB=A5=E5=90=8C=E6=97=B6=E4=BD= =BF=E7=94=A8=E6=B3=A8=E9=87=8A=E5=AE=9E=E4=BD=93=E5=92=8Chbm XML=E6=98=A0= =E5=B0=84=E6=96=87=E4=BB=B6=E7=9A=84=E5=AE=9E=E4=BD=93. + + =E5=9C=A8=E6=B5=8B=E8=AF=95=E5=A5=97=E4=BB=B6=E4=B8=AD=E6=9C=89=E4= =B8=80=E4=BA=9B=E9=99=84=E5=8A=A0=E7=9A=84XML=E6=96=87=E4=BB=B6=E7=9A=84=E6= =A0=B7=E4=BE=8B. + +
+ =E5=8E=9F=E5=88=99 + + XML=E9=83=A8=E7=BD=B2=E6=96=87=E4=BB=B6=E7=BB=93=E6=9E=84=E8=A2= =AB=E8=AE=BE=E8=AE=A1=E4=B8=BA=E7=9B=B4=E6=8E=A5=E6=98=A0=E5=B0=84=E6=B3=A8= =E9=87=8A=E7=BB=93=E6=9E=84,=E6=89=80=E4=BB=A5=E5=A6=82=E6=9E=9C=E4=BD=A0= =E7=9F=A5=E9=81=93=E6=B3=A8=E9=87=8A=E7=9A=84=E7=BB=93=E6=9E=84,=E9=82=A3= =E4=B9=88=E4=BD=BF=E7=94=A8XML=E8=AF=AD=E6=B3=95=E6=98=AF=E5=BE=88=E7=AE=80= =E5=8D=95=E7=9A=84. + + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=AE=9A=E4=B9=89=E4=B8=80=E4=B8=AA= =E6=88=96=E8=80=85=E5=A4=9A=E4=B8=AAXML=E6=96=87=E4=BB=B6=E6=9D=A5=E6=8F=8F= =E8=BF=B0=E4=BD=A0=E7=9A=84=E5=85=83=E6=95=B0=E6=8D=AE,=E8=BF=99=E4=BA=9B= =E6=96=87=E4=BB=B6=E4=BC=9A=E8=A2=AB=E8=A6=86=E5=86=99=E5=BC=95=E6=93=8E=E5= =90=88=E5=B9=B6(merged). + +
+ =E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E7=9A=84=E5=85=83=E6=95= =B0=E6=8D=AE + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8XML=E6=96=87=E4= =BB=B6=E6=9D=A5=E5=AE=9A=E4=B9=89=E5=85=A8=E5=B1=80=E5=85=83=E6=95=B0=E6=8D= =AE,=E5=AF=B9=E6=AF=8F=E4=B8=80=E4=B8=AA=E9=83=A8=E7=BD=B2=E6=96=87=E4=BB= =B6=E4=BD=A0=E4=B8=8D=E8=83=BD=E5=AE=9A=E4=B9=89=E5=A4=9A=E4=BA=8E=E4=B8=80= =E4=B8=AA=E7=9A=84=E5=85=83=E6=95=B0=E6=8D=AE. + + <?xml version=3D"1.0" encoding=3D"UTF-8"?> + +<entity-mappings = + xmlns=3D"http://java.sun.com/xml/ns/persistence/orm" + xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm orm_1_0= .xsd" + version=3D"1.0"> + + <persistence-unit-metadata> + <xml-mapping-metadata-complete/> + <persistence-unit-defaults> + <schema>myschema</schema> + <catalog>mycatalog</catalog> + <cascade-persist/> + </persistence-unit-defaults> + </persistence-unit-metadata> + + xml-mapping-metadata-complete =E6=84=8F=E5= =91=B3=E7=9D=80=E6=89=80=E6=9C=89=E7=9A=84=E5=AE=9E=E4=BD=93,mapped-supercl= asses=E5=92=8C=E5=B5=8C=E5=A5=97=E7=9A=84=E5=85=83=E6=95=B0=E6=8D=AE=E5=BA= =94=E8=AF=A5=E4=BB=8EXML=E6=96=87=E4=BB=B6=E4=B8=AD=E5=90=AF=E7=94=A8(=E5= =BF=BD=E7=95=A5=E6=B3=A8=E9=87=8A). + + + schema / catalog =E5=B0=86=E8=A6=86=E5=86= =99=E6=89=80=E6=9C=89=E5=9C=A8=E5=85=83=E6=95=B0=E6=8D=AE=E4=B8=AD=E9=BB=98= =E8=AE=A4=E5=AE=9A=E4=B9=89=E7=9A=84schema =E5=92=8C catalog(=E5=8C=85=E6= =8B=ACXML=E5=92=8C=E6=B3=A8=E9=87=8A). + + cascade-persist =E6=84=8F=E5=91=B3=E7=9D=80= =E6=89=80=E6=9C=89=E6=B3=A8=E9=87=8A=E4=BD=9C=E4=B8=BA=E4=B8=80=E4=B8=AA ca= scade type =E9=83=BD=E6=98=AFPERSIST=E7=9A=84. =E6=88=91=E4=BB=AC=E6=8E=A8= =E8=8D=90=E4=BD=A0=E4=B8=8D=E8=A6=81=E4=BD=BF=E7=94=A8=E8=AF=A5=E7=89=B9=E6= =80=A7. +
+ +
+ =E5=AE=9E=E4=BD=93=E7=BA=A7=E5=88=AB=E7=9A=84=E5=85=83=E6=95= =B0=E6=8D=AE + + =E4=BD=A0=E4=B9=9F=E5=8F=AF=E4=BB=A5=E5=9C=A8=E4=B8=80=E4=B8= =AA=E7=BB=99=E5=AE=9A=E7=9A=84=E5=AE=9E=E4=BD=93=E4=B8=8A=E5=AE=9A=E4=B9=89= =E6=88=96=E8=80=85=E8=A6=86=E5=86=99=E5=85=83=E6=95=B0=E6=8D=AE + + + + + + + + + + + + + + + + + + + + + + + + + <?xml version=3D"1.0" encoding=3D"UTF-8"?> + +<entity-mappings = + xmlns=3D"http://java.sun.com/xml/ns/persistence/orm" + xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm orm_1_0= .xsd" + version=3D"1.0"> + + <package>org.hibernate.test.annotations.reflection</package&g= t; + <entity class=3D"Administration" access=3D"PROPERTY" metadata-compl= ete=3D"true"> + <table name=3D"tbl_admin"> + <unique-constraint> + <column-name>firstname</column-name> + <column-name>lastname</column-name> + </unique-constraint> + </table> + <secondary-table name=3D"admin2"> + <primary-key-join-column name=3D"admin_id" referenced-colum= n-name=3D"id"/> + <unique-constraint> + <column-name>address</column-name> + </unique-constraint> + </secondary-table> + <id-class class=3D"SocialSecurityNumber"/> + <inheritance strategy=3D"JOINED"/> + <sequence-generator name=3D"seqhilo" sequence-name=3D"seqhilo"/= > + <table-generator name=3D"table" table=3D"tablehilo"/> + ... + </entity> + + <entity class=3D"PostalAdministration"> + <primary-key-join-column name=3D"id"/> + ... + </entity> +</entity-mappings> + + + + entity-mappings:entity-mappings =E6= =98=AF=E6=89=80=E6=9C=89XML=E6=96=87=E4=BB=B6=E7=9A=84=E6=A0=B9=E5=85=83=E7= =B4=A0.=E4=BD=A0=E5=BF=85=E9=A1=BB=E5=AE=9A=E4=B9=89XML Schema, =E8=AF=A5= =E6=96=87=E4=BB=B6=E5=8C=85=E5=90=AB=E5=9C=A8hibernate-annotations.jar=E4= =B8=AD,=E4=BD=BF=E7=94=A8Hibernate Annotations =E4=B8=8D=E9=9C=80=E8=A6=81= =E8=AE=BF=E9=97=AE=E7=BD=91=E7=BB=9C. + + + + package (=E5=8F=AF=E9=80=89=E7=9A=84)= : =E4=BD=9C=E4=B8=BA=E9=BB=98=E8=AE=A4=E7=9A=84package=E7=94=A8=E4=BA=8E=E5= =9C=A8=E4=B8=80=E4=B8=AA=E7=BB=99=E5=AE=9A=E7=9A=84=E9=83=A8=E7=BD=B2=E6=8F= =8F=E8=BF=B0=E6=96=87=E4=BB=B6=E4=B8=AD=E6=89=80=E6=9C=89=E6=B2=A1=E6=9C=89= =E9=99=90=E5=AE=9A=E7=9A=84=E7=B1=BB. + + + + entity: =E6=8F=8F=E8=BF=B0=E4=B8=80= =E4=B8=AA=E5=AE=9E=E4=BD=93. + + metadata-complete =E5=AE=9A=E4=B9=89= =E5=AF=B9=E4=BA=8E=E8=AF=A5=E5=85=83=E7=B4=A0=E6=98=AF=E5=90=A6=E5=85=A8=E9= =83=A8=E4=BD=BF=E7=94=A8=E5=85=83=E6=95=B0=E6=8D=AE(=E6=8D=A2=E5=8F=A5=E8= =AF=9D=E6=9D=A5=E8=AF=B4=E5=B0=B1=E6=98=AF,=E5=A6=82=E6=9E=9C=E6=B3=A8=E9= =87=8A=E5=87=BA=E7=8E=B0=E5=9C=A8=E7=B1=BB=E7=BA=A7=E5=88=AB=E5=BA=94=E8=AF= =A5=E8=80=83=E8=99=91=E6=88=96=E8=80=85=E5=BF=BD=E7=95=A5). + + =E4=B8=80=E4=B8=AA=E5=AE=9E=E4=BD=93=E4=B8=8D=E5=BE=97= =E4=B8=8D=E6=9C=89=E4=B8=80=E4=B8=AA class =E5=B1=9E=E6=80=A7=E6=9D=A5=E5= =BC=95=E7=94=A8 =E5=85=83=E6=95=B0=E6=8D=AE=E6=89=80=E5=BA=94=E7=94=A8=E7= =9A=84=E7=B1=BB. + + =E9=80=9A=E8=BF=87name=E5=B1=9E=E6=80= =A7=E4=BD=A0=E5=8F=AF=E4=BB=A5=E8=A6=86=E5=86=99=E5=AE=9E=E4=BD=93=E7=9A=84= =E5=90=8D=E5=AD=97, + =E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E5=AE=9A=E4=B9=89=E5=B9=B6=E4=B8= =94@Entity.name=E5=87=BA=E7=8E=B0=E4=BA=86=E7=9A=84=E8= =AF=9D,=E9=82=A3=E4=B9=88=E5=B0=B1=E4=BD=BF=E7=94=A8=E8=AF=A5=E6=B3=A8=E9= =87=8A(=E5=81=87=E5=A6=82metadata complete =E6=B2=A1=E6=9C=89=E8=A2=AB=E8= =AE=BE=E7=BD=AE). + + + =E5=AF=B9=E4=BA=8Emetadata complete (=E5=8F=82=E8=80=83=E4=B8=8B=E9=9D= =A2)=E5=85=83=E7=B4=A0, =E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=AE=9A=E4=B9=89=E4=B8= =80=E4=B8=AA access(FIELD =E6=88=96= =E8=80=85 PROPERTY(=E9=BB=98=E8=AE=A4=E5=80=BC)), + =E5=AF=B9=E4=BA=8E=E9=9D=9Emetadata complete =E5=85=83=E7=B4=A0,=E4=BD= =BF=E7=94=A8=E6=B3=A8=E9=87=8A=E7=9A=84access type. + + + + table: =E4=BD=A0=E5=8F=AF=E4=BB=A5= =E5=A3=B0=E6=98=8Etable =E5=B1=9E=E6=80=A7(name, schema, catalog), =E5=A6= =82=E6=9E=9C=E6=B2=A1=E6=9C=89=E5=AE=9A=E4=B9=89, =E5=B0=86=E4=BD=BF=E7=94= =A8Java=E6=B3=A8=E9=87=8A. + + =E5=B0=B1=E8=B1=A1=E4=BE=8B=E5=AD=90=E4=B8=AD=E6=89=80= =E7=A4=BA=E7=9A=84=E9=82=A3=E6=A0=B7=E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=AE=9A=E4= =B9=89=E4=B8=80=E4=B8=AA=E6=88=96=E8=80=85=E5=A4=9A=E4=B8=AAunique constrai= nts + + + + secondary-table: =E5=AE=9A=E4=B9=89= =E4=B8=80=E4=B8=AAsecondary-table,=E9=99=A4=E4=BA=86=E4=BD=A0=E5=8F=AF=E4= =BB=A5=E9=80=9A=E8=BF=87primary-key-join-column =E5=85= =83=E7=B4=A0=E5=AE=9A=E4=B9=89 primary key / foreign key =E5=88=97=E4=BB=A5= =E5=A4=96=E6=98=AF=E5=92=8C=E4=B8=80=E8=88=AC=E7=9A=84table=E4=B8=80=E6=A0= =B7=E7=9A=84. =E5=9C=A8=E9=9D=9Emetadata complete=E4=B8=8B, annotation seco= ndary tables =E4=BB=85=E4=BB=85=E5=9C=A8=E6=B2=A1=E6=9C=89secondar= y-table =E5=AE=9A=E4=B9=89=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=E4= =BD=BF=E7=94=A8, =E5=90=A6=E5=88=99 =E6=B3=A8=E9=87=8A=E5=B0=86=E8=A2=AB=E5= =BF=BD=E7=95=A5. + + + + id-class: =E5=92=8C@IdClass<= /literal>=E4=B8=80=E6=A0=B7=E5=AE=9A=E4=B9=89=E4=B8=80=E4=B8=AAid class. + + + + inheritance: = + =E5=AE=9A=E4=B9=89=E7=BB=A7=E6=89=BF=E7=AD=96=E7=95=A5(JOINED<= /literal>, + TABLE_PER_CLASS, + SINGLE_TABLE), =E4=BB=85=E4=BB=85=E5=9C=A8= =E6=A0=B9=E5=AE=9E=E4=BD=93=E7=BA=A7=E5=88=AB=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7= =94=A8. + + + + sequence-generator: =E5=AE=9A=E4=B9= =89=E4=B8=80=E4=B8=AA=E5=BA=8F=E5=88=97=E4=BA=A7=E7=94=9F=E5=99=A8. + + + + table-generator: =E5=AE=9A=E4=B9=89= =E4=B8=80=E4=B8=AAtable generator + + + + primary-key-join-column: + =E5=BD=93 JOINED =E7=BB=A7=E6=89=BF=E7=AD=96=E7=95=A5=E4=BD=BF= =E7=94=A8=E6=97=B6,=E4=B8=BAsub entities=E5=AE=9A=E4=B9=89=E4=B8=80=E4=B8= =AA primary key join column. + + + + + + + + + + + + + + + + + + + + <?xml version=3D"1.0" encoding=3D"UTF-8"?> + +<entity-mappings = + xmlns=3D"http://java.sun.com/xml/ns/persistence/orm" + xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm orm_1_0= .xsd" + version=3D"1.0"> + + <package>org.hibernate.test.annotations.reflection</package&g= t; + <entity class=3D"Music" access=3D"PROPERTY" metadata-complete=3D"tr= ue"> + <discriminator-value>Generic</discriminator-value> + <discriminator-column length=3D"34"/> + ... + </entity> + + <entity class=3D"PostalAdministration"> + <primary-key-join-column name=3D"id"/> + <named-query name=3D"adminById"> + <query>select m from Administration m where m.id =3D :id= </query> + <hint name=3D"org.hibernate.timeout" value=3D"200"/> + </named-query> + <named-native-query name=3D"allAdmin" result-set-mapping=3D"adm= inrs"> + <query>select *, count(taxpayer_id) as taxPayerNumber = + from Administration, TaxPayer + where taxpayer_admin_id =3D admin_id group by ...</query> + <hint name=3D"org.hibernate.timeout" value=3D"200"/> + </named-native-query> + <sql-result-set-mapping name=3D"adminrs"> + <entity-result entity-class=3D"Administration"> + <field-result name=3D"name" column=3D"fld_name"/> + </entity-result> + <column-result name=3D"taxPayerNumber"/> + </sql-result-set-mapping> + <attribute-override name=3D"ground"> + <column name=3D"fld_ground" unique=3D"true" scale=3D"2"/> + </attribute-override> + <association-override name=3D"referer"> + <join-column name=3D"referer_id" referenced-column-name=3D"= id"/> + </association-override> + ... + </entity> +</entity-mappings> + + + + discriminator-value / + discriminator-column: =E5=BD=93SINGLE_TABLE=E7=BB=A7= =E6=89=BF=E7=AD=96=E7=95=A5=E4=BD=BF=E7=94=A8=E6=97=B6,=E5=AE=9A=E4=B9=89= =E9=89=B4=E5=88=AB=E5=99=A8=E5=80=BC =E5=92=8C =E4=BF=9D=E5=AD=98=E8=AF=A5= =E5=80=BC=E7=9A=84=E5=88=97. + + + + named-query: =E5=AE=9A=E4=B9=89=E5=91= =BD=E5=90=8D=E6=9F=A5=E8=AF=A2=E5=92=8C=E4=B8=80=E4=BA=9B=E7=9B=B8=E5=85=B3= =E7=9A=84=E5=8F=AF=E8=83=BD=E7=9A=84=E7=BA=BF=E7=B4=A2. =E8=AF=A5=E5=AE=9A= =E4=B9=89=E9=99=84=E5=8A=A0=E5=9C=A8=E6=B3=A8=E9=87=8A=E7=9A=84=E5=AE=9A=E4= =B9=89=E4=B8=AD,=E5=A6=82=E6=9E=9C=E4=B8=A4=E4=B8=AA=E9=83=BD=E5=AE=9A=E4= =B9=89=E4=BA=86=E7=9B=B8=E5=90=8C=E7=9A=84=E5=90=8D=E5=AD=97,=E9=82=A3=E4= =B9=88XML=E5=B0=86=E4=BC=98=E5=85=88=E8=80=83=E8=99=91. + + + + named-native-query: =E5=AE=9A=E4=B9= =89=E4=B8=80=E4=B8=AA=E5=91=BD=E5=90=8D=E6=9C=AC=E5=9C=B0=E6=9F=A5=E8=AF=A2= =E5=92=8C=E4=BB=96=E7=9A=84 sql result set =E6=98=A0=E5=B0=84. =E4=BD=9C= =E4=B8=BA=E5=8F=A6=E5=A4=96=E4=B8=80=E7=A7=8D=E9=80=89=E6=8B=A9,=E4=BD=A0= =E5=8F=AF=E4=BB=A5=E5=AE=9A=E4=B9=89result-class. =E8=BF= =99=E4=BA=9B=E5=AE=9A=E4=B9=89=E9=99=84=E5=8A=A0=E5=9C=A8=E6=B3=A8=E9=87=8A= =E7=9A=84=E5=AE=9A=E4=B9=89=E4=B8=AD.=E5=A6=82=E6=9E=9C=E4=B8=A4=E4=B8=AA= =E5=AE=9A=E4=B9=89=E4=BA=86=E5=90=8C=E6=A0=B7=E7=9A=84=E5=90=8D=E5=AD=97,XM= L=E6=96=87=E4=BB=B6=E4=BC=98=E5=85=88=E8=80=83=E8=99=91. + + + + sql-result-set-mapping: =E6=8F=8F=E8= =BF=B0=E4=BA=86 result set mapping =E7=9A=84=E7=BB=93=E6=9E=84. =E4=BD=A0= =E5=8F=AF=E4=BB=A5=E5=AE=9A=E4=B9=89 =E5=AE=9E=E4=BD=93=E5=92=8C=E5=88=97= =E6=98=A0=E5=B0=84. =E8=BF=99=E4=BA=9B=E5=AE=9A=E4=B9=89=E9=99=84=E5=8A=A0= =E5=9C=A8=E6=B3=A8=E9=87=8A=E7=9A=84=E5=AE=9A=E4=B9=89=E4=B8=AD,=E5=A6=82= =E6=9E=9C=E5=AE=9A=E4=B9=89=E4=BA=86=E5=90=8C=E6=A0=B7=E7=9A=84=E5=90=8D=E5= =AD=97,XML=E6=96=87=E4=BB=B6=E4=BC=98=E5=85=88=E8=80=83=E8=99=91. + + + + attribute-override / + association-override: =E5=AE=9A=E4=B9=89=E4=B8=80=E5= =88=97=E6=88=96=E8=80=85join column overriding. =E8=AF=A5overriding =E9=99= =84=E5=8A=A0=E5=9C=A8=E6=B3=A8=E9=87=8A=E7=9A=84=E5=AE=9A=E4=B9=89=E4=B8=AD= . + + + + + =E4=B8=80=E4=BA=9B=E5=BA=94=E7=94=A8=E4=BA=8E <emb= eddable> =E5=92=8C + <mapped-superclass>. +
+ +
+ =E5=B1=9E=E6=80=A7=E7=BA=A7=E5=88=AB=E7=9A=84=E5=85=83=E6=95= =B0=E6=8D=AE + + + =E4=BD=A0=E5=BD=93=E7=84=B6=E5=8F=AF=E4=BB=A5=E5=AE=9A=E4=B9=89XML=E6= =9D=A5=E8=A6=86=E5=86=99=E5=B1=9E=E6=80=A7. =E5=A6=82=E6=9E=9Cmetadata comp= lete =E7=BB=99=E5=AE=9A=E4=B9=89=E4=BA=86,=E9=82=A3=E4=B9=88=E9=99=84=E5=8A= =A0=E7=9A=84=E5=B1=9E=E6=80=A7(=E5=A6=82: =E5=9C=A8Java =E7=BA=A7=E5=88=AB= =E7=9A=84)=E5=B0=86=E8=A2=AB=E5=BF=BD=E7=95=A5. +=E5=8F=A6=E5=A4=96,=E4=B8=80=E6=97=A6=E4=BD=A0=E5=BC=80=E5=A7=8B=E8=A6=86= =E5=86=99=E4=B8=80=E4=B8=AA=E5=B1=9E=E6=80=A7,=E5=9C=A8=E8=AF=A5=E5=B1=9E= =E6=80=A7=E4=B8=8A=E7=9A=84=E6=89=80=E6=9C=89=E6=B3=A8=E9=87=8A=E9=83=BD=E4= =BC=9A=E8=A2=AB=E5=BF=BD=E7=95=A5.=E6=89=80=E6=9C=89=E5=B1=9E=E6=80=A7=E7= =BA=A7=E5=88=AB=E7=9A=84=E5=85=83=E6=95=B0=E6=8D=AE=E5=BA=94=E7=94=A8=E4=BA= =8Eentity/attributes, + mapped-superclass/attributes =E6=88=96 + embeddable/attributes. + + <attributes> + <id name=3D"id"> + <column name=3D"fld_id"/> + <generated-value generator=3D"generator" strategy=3D"SEQUEN= CE"/> + <temporal>DATE</temporal> + <sequence-generator name=3D"generator" sequence-name=3D"seq= "/> + </id> + <version name=3D"version"/> + <embedded name=3D"embeddedObject"> + <attribute-override name"subproperty"> + <column name=3D"my_column"/> + </attribute-override> + </embedded> + <basic name=3D"status" optional=3D"false"> + <enumerated>STRING</enumerated> + </basic> + <basic name=3D"serial" optional=3D"true"> + <column name=3D"serialbytes"/> + <lob/> + </basic> + <basic name=3D"terminusTime" fetch=3D"LAZY"> + <temporal>TIMESTAMP</temporal> + </basic> + </attributes> + + + =E9=80=9A=E8=BF=87 id, + embedded-id, version, + embedded =E5=92=8C basic=E4=BD= =A0=E5=8F=AF=E4=BB=A5=E8=A6=86=E5=86=99=E4=B8=80=E4=B8=AA=E5=B1=9E=E6=80=A7, + =E8=BF=99=E4=BA=9B=E5=85=83=E7=B4=A0=E4=B8=AD=E7=9A=84=E6=AF=8F=E4=B8= =80=E4=B8=AA=E5=85=83=E7=B4=A0=E9=83=BD=E6=9C=89=E7=9B=B8=E5=BA=94=E7=9A=84= subelements=EF=BC=9Alob, + temporal, enumerated, + column. + +
+ +
+ =E5=85=B3=E8=81=94=E7=BA=A7=E5=88=AB=E7=9A=84=E5=85=83=E6=95= =B0=E6=8D=AE + + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E5=AE=9A=E4=B9=89XML=E8=A6=86=E5= =86=99=E5=85=B3=E8=81=94=E6=B3=A8=E9=87=8A. =E6=89=80=E6=9C=89=E7=9A=84=E5= =85=B3=E8=81=94=E7=BA=A7=E5=88=AB=E7=9A=84=E5=85=83=E6=95=B0=E6=8D=AE=E4=BD= =9C=E7=94=A8=E4=BA=8E + entity/attributes, + mapped-superclass/attributes =E6=88=96 + embeddable/attributes. + + <attributes> + <one-to-many name=3D"players" fetch=3D"EAGER"> + <map-key name=3D"name"/> + <join-column name=3D"driver"/> + <join-column name=3D"number"/> + </one-to-many> + <many-to-many name=3D"roads" target-entity=3D"Administration"&g= t; + <order-by>maxSpeed</order-by> + <join-table name=3D"bus_road"> + <join-column name=3D"driver"/> + <join-column name=3D"number"/> + <inverse-join-column name=3D"road_id"/> + <unique-constraint> + <column-name>driver</column-name> + <column-name>number</column-name> + </unique-constraint> + </join-table> + </many-to-many> + <many-to-many name=3D"allTimeDrivers" mapped-by=3D"drivenBuses"= > + </attributes> + + =E9=80=9A=E8=BF=87one-to-many, one= -to-one, + many-to-one, =E5=92=8C many-to-many. + =E4=BD=A0=E5=8F=AF=E4=BB=A5=E9=87=8D=E5=86=99=E4=B8=80=E4=B8=AA=E5=85= =B3=E8=81=94=E5=85=B3=E7=B3=BB.=E8=BF=99=E4=BA=9B=E5=85=83=E7=B4=A0=E4=B8= =AD=E7=9A=84=E6=AF=8F=E4=B8=80=E4=B8=AA=E9=83=BD=E6=9C=89=E7=9B=B8=E5=BA=94= =E7=9A=84subelements. join-table (=E5=8F=AF=E4=BB=A5=E6= =9C=89 + join-column=E5=92=8C + inverse-join-column), + join-column, + map-key, =E5=92=8C order-by. + mapped-by =E5=92=8C target-entity + =E5=BD=93=E4=BB=96=E4=BB=AC=E6=9C=89=E6=84=8F=E4=B9=89=E7=9A=84=E6=97= =B6=E5=80=99=E5=8F=AF=E4=BB=A5=E5=AE=9A=E4=B9=89=E5=B1=9E=E6=80=A7. =E5=86= =8D=E4=B8=80=E6=AC=A1=E5=BC=BA=E8=B0=83 =E8=AF=A5=E7=BB=93=E6=9E=84=E6=98= =A0=E5=B0=84=E4=BA=8E=E6=B3=A8=E9=87=8A=E7=9A=84=E7=BB=93=E6=9E=84.=E5=9C= =A8=E6=8F=8F=E8=BF=B0=E6=B3=A8=E9=87=8A=E7=9A=84=E4=B8=80=E7=AB=A0=E4=B8=AD= =E4=BD=A0=E5=8F=AF=E4=BB=A5=E6=89=BE=E5=88=B0=E6=89=80=E6=9C=89=E7=9A=84= =E8=AF=AD=E4=B9=89=E4=BF=A1=E6=81=AF. + + +
+
+
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/fopd= f.xsl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/fopdf.x= sl (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/fopdf.x= sl 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,509 @@ + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + Version: + + + + + + + + + + + + + + + + + + + + + + + + + -5em + -5em + + + + + + + + + + + + + + + Hibernate + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + = + + + + + + + + + + + + + + + + + + bold + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 0 + + 1 + + + + + + book toc + + = + + 3 + = + + + + + + = + + 5mm + 10mm + 10mm + + 15mm + 10mm + 0mm + + 18mm + 18mm + + + 0pc + + + + + 11 + + + 1.4 + + + + + + + 0.8em + + + + + + + 17.4cm + + + + 4pt + 4pt + 4pt + 4pt + + = + + 0.1pt + 0.1pt + + + + + 1 + + + + + = + + + left + bold + + + pt + + + + + + + + + + + + = + + + bold + + + pt + + false + 0.4em + 0.6em + 0.8em + + + + = + + + 1em + 1em + 1em + 0.1em + 0.1em + 0.1em + #444444 + solid + 0.1pt + 0.5em + 0.5em + 0.5em + 0.5em + 0.5em + 0.5em + + + + 1 + + #F0F0F0 + + + + + + 1 + + + 90 + + + 0 + + + + + + + + + ( + + ) + + + + + + + + + figure after + example before + equation before + table before + procedure before + + = + + + 0.8em + 0.8em + 0.8em + 0.1em + 0.1em + 0.1em + + + + + + + false + simsun + simsun + simhei + + + + + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html= .css =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html.cs= s (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html.cs= s 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,97 @@ +A { + color: #003399; +} + +A:active { + color: #003399; +} + +A:visited { + color: #888888; +} + +P, OL, UL, LI, DL, DT, DD, BLOCKQUOTE { + color: #000000; +} + +TD, TH, SPAN { + color: #000000; +} + +BLOCKQUOTE { + margin-right: 0px; +} + + +H1, H2, H3, H4, H5, H6 { + color: #000000; + font-weight:500; + margin-top:10px; + padding-top:15px; +} + +TABLE { + border-collapse: collapse; + border-spacing:0; + border: 1px thin black; + empty-cells: hide; +} + +TD { + padding: 4pt; +} + +H1 { font-size: 150%; } +H2 { font-size: 140%; } +H3 { font-size: 110%; font-weight: bold; } +H4 { font-size: 110%; font-weight: bold;} +H5 { font-size: 100%; font-style: italic; } +H6 { font-size: 100%; font-style: italic; } + +TT { +font-size: 90%; + font-family: "Courier New", Courier, monospace; + color: #000000; +} + +PRE { +font-size: 100%; + padding: 5px; + border-style: solid; + border-width: 1px; + border-color: #CCCCCC; + background-color: #F4F4F4; +} + +UL, OL, LI { + list-style: disc; +} + +HR { + width: 100%; + height: 1px; + background-color: #CCCCCC; + border-width: 0px; + padding: 0px; + color: #CCCCCC; +} + +.variablelist { = + padding-top: 10; = + padding-bottom:10; = + margin:0; +} + +.itemizedlist, UL { = + padding-top: 0; = + padding-bottom:0; = + margin:0; = +} + +.term { = + font-weight:bold; +} + + + + = Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html= .xsl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html.xs= l (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html.xs= l 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,84 @@ + + + + + +]> + + + = + + + = + + ../shared/css/html.css + + + 1 + 0 + 1 + 0 + + = + + + + book toc + + = + + 3 + = + = + + + 1 + + + + + + + 0 + + + 90 + + = + + + + figure after + example before + equation before + table before + procedure before + = + = + Added: annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html= _chunk.xsl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html_ch= unk.xsl (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/docbook/zh_cn/styles/html_ch= unk.xsl 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,86 @@ + + + + + +]> + + + = + + + = + + '5' + '1' + ../shared/css/html.css + + + 1 + 0 + 1 + 0 + = + = + + + + book toc + + = + + 3 + + = + + + 1 + + + = + = + + + 0 + + + 90 + + = + + + + figure after + example before + equation before + table before + procedure before + = + = + Added: annotations/branches/v3_4_0_GA_CP/src/main/javadoc/jdstyle.css =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/javadoc/jdstyle.css = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/javadoc/jdstyle.css 2009-11-= 24 20:21:05 UTC (rev 18045) @@ -0,0 +1,117 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the de= faults */ + +/* Page background color */ +body { font-family: Arial; + background-color: white; + font-size: 10pt; + } +td { font-family: Arial; + font-size: 10pt; + } +/* Table colors */ +.TableHeadingColor { background: #F4F4F4 } +.TableSubHeadingColor { background: #F4F4F4 } +.TableRowColor { background: #FFFFFF } + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: normal; font-family: Arial } +.FrameHeadingFont { font-size: normal; font-family: Arial } +.FrameItemFont { font-size: normal; font-family: Arial } + +/* Example of smaller, sans-serif font in frames */ +/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-= serif } */ + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#F4F4F4;} +.NavBarCell1Rev { background-color:silver;} + +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000= ;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF= ;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-co= lor:#FFFFFF;} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-co= lor:#FFFFFF;} + +A { + color: #003399; +} + +A:active { + color: #003399; +} + +A:visited { + color: #888888; +} + +P, OL, UL, LI, DL, DT, DD, BLOCKQUOTE { + color: #000000; +} + +TD, TH, SPAN { + color: #000000; +} + +BLOCKQUOTE { + margin-right: 0px; +} + + +/*H1, H2, H3, H4, H5, H6 { + color: #000000; + font-weight:500; + margin-top:10px; + padding-top:15px; +} + +H1 { font-size: 150%; } +H2 { font-size: 140%; } +H3 { font-size: 110%; font-weight: bold; } +H4 { font-size: 110%; font-weight: bold;} +H5 { font-size: 100%; font-style: italic; } +H6 { font-size: 100%; font-style: italic; }*/ + +TT { +font-size: 90%; + font-family: "Courier New", Courier, monospace; + color: #000000; +} + +PRE { +font-size: 90%; + padding: 5px; + border-style: solid; + border-width: 1px; + border-color: #CCCCCC; + background-color: #F4F4F4; +} + +UL, OL, LI { + list-style: disc; +} + +HR { + width: 100%; + height: 1px; + background-color: #CCCCCC; + border-width: 0px; + padding: 0px; + color: #CCCCCC; +} + +.variablelist { = + padding-top: 10; = + padding-bottom:10; = + margin:0; +} + +.itemizedlist, UL { = + padding-top: 0; = + padding-bottom:0; = + margin:0; = +} + +.term { = + font-weight:bold; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/javadoc/package.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/javadoc/package.html = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/javadoc/package.html 2009-11= -24 20:21:05 UTC (rev 18045) @@ -0,0 +1 @@ + Added: annotations/branches/v3_4_0_GA_CP/src/main/resources/org/hibernate/e= jb/orm_1_0.xsd =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/resources/org/hibernate/ejb/= orm_1_0.xsd (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/resources/org/hibernate/ejb/= orm_1_0.xsd 2009-11-24 20:21:05 UTC (rev 18045) @@ -0,0 +1,1516 @@ + + + + + + + @(#)orm_1_0.xsd 1.0 Feb 14 2006 + + + + + + + + + + + + + + + + + + + + + + The entity-mappings element is the root element of an = mapping + file. It contains the following four types of elements: + + 1. The persistence-unit-metadata element contains meta= data + for the entire persistence unit. It is undefined if th= is element + occurs in multiple mapping files within the same persi= stence unit. + + 2. The package, schema, catalog and access elements ap= ply to all of + the entity, mapped-superclass and embeddable elements = defined in + the same file in which they occur. + + 3. The sequence-generator, table-generator, named-quer= y, + named-native-query and sql-result-set-mapping elements= are global + to the persistence unit. It is undefined to have more = than one + sequence-generator or table-generator of the same name= in the same + or different mapping files in a persistence unit. It i= s also + undefined to have more than one named-query or named-n= ative-query + of the same name in the same or different mapping file= s in a + persistence unit. + + 4. The entity, mapped-superclass and embeddable elemen= ts each define + the mapping information for a managed persistent class= . The mapping + information contained in these elements may be complet= e or it may + be partial. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Metadata that applies to the persistence unit and not just= to + the mapping file in which it is contained. + + If the xml-mapping-metadata-complete element is specified = then + the complete set of mapping metadata for the persistence u= nit + is contained in the XML mapping files for the persistence = unit. + + + + + + + + + + + + + + + + These defaults are applied to the persistence unit as a wh= ole + unless they are overridden by local annotation or XML + element settings. + + schema - Used as the schema for all tables or secondary ta= bles + that apply to the persistence unit + catalog - Used as the catalog for all tables or secondary = tables + that apply to the persistence unit + access - Used as the access type for all managed classes in + the persistence unit + cascade-persist - Adds cascade-persist to the set of casca= de options + in entity relationships of the persistence unit + entity-listeners - List of default entity listeners to be = invoked + on each entity in the persistence unit. + + + + + + + + + + + + + + + + + + + Defines the settings and mappings for an entity. Is allowe= d to be + sparsely populated and used in conjunction with the annota= tions. + Alternatively, the metadata-complete attribute can be used= to + indicate that no annotations on the entity class (and its = fields + or properties) are to be processed. If this is the case th= en + the defaulting rules for the entity and its subelements wi= ll + be recursively applied. + + @Target(TYPE) @Retention(RUNTIME) + public @interface Entity { + String name() default ""; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This element contains the entity field or property mapping= s. + It may be sparsely populated to include only a subset of t= he + fields or properties. If metadata-complete for the entity = is true + then the remainder of the attributes will be defaulted acc= ording + to the default rules. + + + + + + + + + + + + + + + + + + + + + + + + + + This element determines how the persistence provider acces= ses the + state of an entity or embedded object. + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface EntityListeners { + Class[] value(); + } + + + + + + + + + + + + + + + Defines an entity listener to be invoked at lifecycle even= ts + for the entities that list this listener. + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PrePersist {} + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PostPersist {} + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PreRemove {} + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PostRemove {} + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PreUpdate {} + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PostUpdate {} + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PostLoad {} + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface QueryHint { + String name(); + String value(); + } + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface NamedQuery { + String name(); + String query(); + QueryHint[] hints() default {}; + } + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface NamedNativeQuery { + String name(); + String query(); + QueryHint[] hints() default {}; + Class resultClass() default void.class; + String resultSetMapping() default ""; //named SqlResultSet= Mapping + } + + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface SqlResultSetMapping { + String name(); + EntityResult[] entities() default {}; + ColumnResult[] columns() default {}; + } + + + + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface EntityResult { + Class entityClass(); + FieldResult[] fields() default {}; + String discriminatorColumn() default ""; + } + + + + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface FieldResult { + String name(); + String column(); + } + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface ColumnResult { + String name(); + } + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface Table { + String name() default ""; + String catalog() default ""; + String schema() default ""; + UniqueConstraint[] uniqueConstraints() default {}; + } + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface SecondaryTable { + String name(); + String catalog() default ""; + String schema() default ""; + PrimaryKeyJoinColumn[] pkJoinColumns() default {}; + UniqueConstraint[] uniqueConstraints() default {}; + } + + + + + + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface UniqueConstraint { + String[] columnNames(); + } + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Column { + String name() default ""; + boolean unique() default false; + boolean nullable() default true; + boolean insertable() default true; + boolean updatable() default true; + String columnDefinition() default ""; + String table() default ""; + int length() default 255; + int precision() default 0; // decimal precision + int scale() default 0; // decimal scale + } + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface JoinColumn { + String name() default ""; + String referencedColumnName() default ""; + boolean unique() default false; + boolean nullable() default true; + boolean insertable() default true; + boolean updatable() default true; + String columnDefinition() default ""; + String table() default ""; + } + + + + + + + + + + + + + + + + + + + + public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AU= TO }; + + + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface AttributeOverride { + String name(); + Column column(); + } + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface AssociationOverride { + String name(); + JoinColumn[] joinColumns(); + } + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface IdClass { + Class value(); + } + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Id {} + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface EmbeddedId {} + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Transient {} + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Version {} + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Basic { + FetchType fetch() default EAGER; + boolean optional() default true; + } + + + + + + + + + + + + + + + + + + + + + + + public enum FetchType { LAZY, EAGER }; + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Lob {} + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Temporal { + TemporalType value(); + } + + + + + + + + + + + + + public enum TemporalType { + DATE, // java.sql.Date + TIME, // java.sql.Time + TIMESTAMP // java.sql.Timestamp + } + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Enumerated { + EnumType value() default ORDINAL; + } + + + + + + + + + + + + + public enum EnumType { + ORDINAL, + STRING + } + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface ManyToOne { + Class targetEntity() default void.class; + CascadeType[] cascade() default {}; + FetchType fetch() default EAGER; + boolean optional() default true; + } + + + + + + + + + + + + + + + + + + + + + + + public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REF= RESH}; + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface OneToOne { + Class targetEntity() default void.class; + CascadeType[] cascade() default {}; + FetchType fetch() default EAGER; + boolean optional() default true; + String mappedBy() default ""; + } + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface OneToMany { + Class targetEntity() default void.class; + CascadeType[] cascade() default {}; + FetchType fetch() default LAZY; + String mappedBy() default ""; + } + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface JoinTable { + String name() default ""; + String catalog() default ""; + String schema() default ""; + JoinColumn[] joinColumns() default {}; + JoinColumn[] inverseJoinColumns() default {}; + UniqueConstraint[] uniqueConstraints() default {}; + } + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface ManyToMany { + Class targetEntity() default void.class; + CascadeType[] cascade() default {}; + FetchType fetch() default LAZY; + String mappedBy() default ""; + } + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface GeneratedValue { + GenerationType strategy() default AUTO; + String generator() default ""; + } + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface MapKey { + String name() default ""; + } + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface OrderBy { + String value() default ""; + } + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface Inheritance { + InheritanceType strategy() default SINGLE_TABLE; + } + + + + + + + + + + + + + public enum InheritanceType + { SINGLE_TABLE, JOINED, TABLE_PER_CLASS}; + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface DiscriminatorValue { + String value(); + } + + + + + + + + + + + + + public enum DiscriminatorType { STRING, CHAR, INTEGER }; + + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface PrimaryKeyJoinColumn { + String name() default ""; + String referencedColumnName() default ""; + String columnDefinition() default ""; + } + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface DiscriminatorColumn { + String name() default "DTYPE"; + DiscriminatorType discriminatorType() default STRING; + String columnDefinition() default ""; + int length() default 31; + } + + + + + + + + + + + + + + + + Defines the settings and mappings for embeddable objects. = Is + allowed to be sparsely populated and used in conjunction w= ith + the annotations. Alternatively, the metadata-complete attr= ibute + can be used to indicate that no annotations are to be proc= essed + in the class. If this is the case then the defaulting rule= s will + be recursively applied. + + @Target({TYPE}) @Retention(RUNTIME) + public @interface Embeddable {} + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Embedded {} + + + + + + + + + + + + + + + + Defines the settings and mappings for a mapped superclass.= Is + allowed to be sparsely populated and used in conjunction w= ith + the annotations. Alternatively, the metadata-complete attr= ibute + can be used to indicate that no annotations are to be proc= essed + If this is the case then the defaulting rules will be recu= rsively + applied. + + @Target(TYPE) @Retention(RUNTIME) + public @interface MappedSuperclass{} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface SequenceGenerator { + String name(); + String sequenceName() default ""; + int initialValue() default 1; + int allocationSize() default 50; + } + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface TableGenerator { + String name(); + String table() default ""; + String catalog() default ""; + String schema() default ""; + String pkColumnName() default ""; + String valueColumnName() default ""; + String pkColumnValue() default ""; + int initialValue() default 0; + int allocationSize() default 50; + UniqueConstraint[] uniqueConstraints() default {}; + } + + + + + + + + + + + + + + + + + + + + --===============1182405276502404732==-- From hibernate-commits at lists.jboss.org Tue Nov 24 15:27:09 2009 Content-Type: multipart/mixed; boundary="===============3054816273972535029==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18046 - in annotations/branches/v3_4_0_GA_CP/src: test and 1 other directories. Date: Tue, 24 Nov 2009 15:27:09 -0500 Message-ID: <200911242027.nAOKR97j026173@svn01.web.mwc.hst.phx2.redhat.com> --===============3054816273972535029== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-24 15:27:09 -0500 (Tue, 24 Nov 2009) New Revision: 18046 Added: annotations/branches/v3_4_0_GA_CP/src/test/java/ annotations/branches/v3_4_0_GA_CP/src/test/resources/ annotations/branches/v3_4_0_GA_CP/src/test/resources/ehcache.xml annotations/branches/v3_4_0_GA_CP/src/test/resources/hibernate.properties annotations/branches/v3_4_0_GA_CP/src/test/resources/log4j.properties Removed: annotations/branches/v3_4_0_GA_CP/src/test-resources/ Log: JBPAPP-3150 change the build tool of Hibernate Annotations(eap 5 cp branch) Added: annotations/branches/v3_4_0_GA_CP/src/test/resources/ehcache.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/resources/ehcache.xml = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/resources/ehcache.xml 2009-1= 1-24 20:27:09 UTC (rev 18046) @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/resources/hibernate.prope= rties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/resources/hibernate.properti= es (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/resources/hibernate.properti= es 2009-11-24 20:27:09 UTC (rev 18046) @@ -0,0 +1,303 @@ +###################### +### Query Language ### +###################### + +## define query language constants / function names + +hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N' + + +## select the classic query parser + +#hibernate.query.factory_class org.hibernate.hql.classic.ClassicQueryTrans= latorFactory + +hibernate.format_sql true + + + +################# +### Platforms ### +################# + +hibernate.dialect ${db.dialect} +hibernate.connection.driver_class ${jdbc.driver} +hibernate.connection.url ${jdbc.url} +hibernate.connection.username ${jdbc.user} +hibernate.connection.password ${jdbc.pass} +hibernate.connection.isolation ${jdbc.isolation} + + +################################# +### Hibernate Connection Pool ### +################################# + +hibernate.connection.pool_size 1 + +########################### +### C3P0 Connection Pool### +########################### + +#hibernate.c3p0.max_size 2 +#hibernate.c3p0.min_size 2 +#hibernate.c3p0.timeout 5000 +#hibernate.c3p0.max_statements 100 +#hibernate.c3p0.idle_test_period 3000 +#hibernate.c3p0.acquire_increment 2 +#hibernate.c3p0.validate false + +############################## +### Proxool Connection Pool### +############################## + +## Properties for external configuration of Proxool + +hibernate.proxool.pool_alias pool1 + +## Only need one of the following + +#hibernate.proxool.existing_pool true +#hibernate.proxool.xml proxool.xml +#hibernate.proxool.properties proxool.properties + + + +################################# +### Plugin ConnectionProvider ### +################################# + +## use a custom ConnectionProvider (if not set, Hibernate will choose a bu= ilt-in ConnectionProvider using hueristics) + +#hibernate.connection.provider_class org.hibernate.connection.DriverManage= rConnectionProvider +#hibernate.connection.provider_class org.hibernate.connection.DatasourceCo= nnectionProvider +#hibernate.connection.provider_class org.hibernate.connection.C3P0Connecti= onProvider +#hibernate.connection.provider_class org.hibernate.connection.DBCPConnecti= onProvider +#hibernate.connection.provider_class org.hibernate.connection.ProxoolConne= ctionProvider + + + +####################### +### Transaction API ### +####################### + +## Enable automatic flush during the JTA beforeCompletion() callback +## (This setting is relevant with or without the Transaction API) + +#hibernate.transaction.flush_before_completion + + +## Enable automatic session close at the end of transaction +## (This setting is relevant with or without the Transaction API) + +#hibernate.transaction.auto_close_session + + +## the Transaction API abstracts application code from the underlying JTA = or JDBC transactions + +#hibernate.transaction.factory_class org.hibernate.transaction.JTATransact= ionFactory +#hibernate.transaction.factory_class org.hibernate.transaction.JDBCTransac= tionFactory + + +## to use JTATransactionFactory, Hibernate must be able to locate the User= Transaction in JNDI +## default is java:comp/UserTransaction +## you do NOT need this setting if you specify hibernate.transaction.manag= er_lookup_class + +#jta.UserTransaction jta/usertransaction +#jta.UserTransaction javax.transaction.UserTransaction +#jta.UserTransaction UserTransaction + + +## to use the second-level cache with JTA, Hibernate must be able to obtai= n the JTA TransactionManager + +#hibernate.transaction.manager_lookup_class org.hibernate.transaction.JBos= sTransactionManagerLookup +#hibernate.transaction.manager_lookup_class org.hibernate.transaction.Webl= ogicTransactionManagerLookup +#hibernate.transaction.manager_lookup_class org.hibernate.transaction.WebS= phereTransactionManagerLookup +#hibernate.transaction.manager_lookup_class org.hibernate.transaction.Orio= nTransactionManagerLookup +#hibernate.transaction.manager_lookup_class org.hibernate.transaction.Resi= nTransactionManagerLookup + + + +############################## +### Miscellaneous Settings ### +############################## + +## print all generated SQL to the console + +#hibernate.show_sql true + + +## add comments to the generated SQL + +#hibernate.use_sql_comments true + + +## generate statistics + +#hibernate.generate_statistics true + + +## auto schema export + +#hibernate.hbm2ddl.auto create-drop +#hibernate.hbm2ddl.auto create +#hibernate.hbm2ddl.auto update + + +## specify a default schema and catalog for unqualified tablenames + +#hibernate.default_schema test +#hibernate.default_catalog test + + +## enable ordering of SQL UPDATEs by primary key + +hibernate.order_updates true + + +## set the maximum depth of the outer join fetch tree + +hibernate.max_fetch_depth 1 + + +## set the default batch size for batch fetching + +hibernate.default_batch_fetch_size 100 + + +## rollback generated identifier values of deleted entities to default val= ues + +#hibernate.use_identifer_rollback true + + +## enable CGLIB reflection optimizer (enabled by default) + +#hibernate.cglib.use_reflection_optimizer false + + + +##################### +### JDBC Settings ### +##################### + +## specify a JDBC isolation level + +#hibernate.connection.isolation 4 + + +## enable JDBC autocommit (not recommended!) + +#hibernate.connection.autocommit true + + +## set the JDBC fetch size + +#hibernate.jdbc.fetch_size 25 + + +## set the maximum JDBC 2 batch size (a nonzero value enables batching) + +#hibernate.jdbc.batch_size 0 + + +## enable batch updates even for versioned data + +hibernate.jdbc.batch_versioned_data true + + +## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will c= ause Hibernate to use a sensible default) + +#hibernate.jdbc.use_scrollable_resultset true + + +## use streams when writing binary types to / from JDBC + +hibernate.jdbc.use_streams_for_binary true + + +## use JDBC 3 PreparedStatement.getGeneratedKeys() to get the identifier o= f an inserted row + +#hibernate.jdbc.use_get_generated_keys false + + +## choose a custom JDBC batcher + +# hibernate.jdbc.factory_class + + +## enable JDBC result set column alias caching = +## (minor performance enhancement for broken JDBC drivers) + +# hibernate.jdbc.wrap_result_sets + + +## choose a custom SQL exception converter + +#hibernate.jdbc.sql_exception_converter + + + +########################## +### Second-level Cache ### +########################## + +## optimize chache for minimal "puts" instead of minimal "gets" (good for = clustered cache) + +#hibernate.cache.use_minimal_puts true + + +## set a prefix for cache region names + +hibernate.cache.region_prefix hibernate.test + + +## disable the second-level cache + +#hibernate.cache.use_second_level_cache false + + +## enable the query cache + +hibernate.cache.use_query_cache true + + +## store the second-level cache entries in a more human-friendly format + +#hibernate.cache.use_structured_entries true + + +## choose a cache implementation + +#hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider +#hibernate.cache.provider_class org.hibernate.cache.EmptyCacheProvider +hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider +#hibernate.cache.provider_class org.hibernate.cache.TreeCacheProvider +#hibernate.cache.provider_class org.hibernate.cache.OSCacheProvider +#hibernate.cache.provider_class org.hibernate.cache.SwarmCacheProvider + + +## choose a custom query cache implementation + +#hibernate.cache.query_cache_factory + + + +############ +### JNDI ### +############ + +## specify a JNDI name for the SessionFactory + +#hibernate.session_factory_name hibernate/session_factory + + +## Hibernate uses JNDI to bind a name to a SessionFactory and to look up t= he JTA UserTransaction; +## if hibernate.jndi.* are not specified, Hibernate will use the default I= nitialContext() which +## is the best approach in an application server + +#file system +#hibernate.jndi.class com.sun.jndi.fscontext.RefFSContextFactory +#hibernate.jndi.url file:/ + +#WebSphere +#hibernate.jndi.class com.ibm.websphere.naming.WsnInitialContextFactory +#hibernate.jndi.url iiop://localhost:900/ + Added: annotations/branches/v3_4_0_GA_CP/src/test/resources/log4j.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/resources/log4j.properties = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/resources/log4j.properties 2= 009-11-24 20:27:09 UTC (rev 18046) @@ -0,0 +1,51 @@ +### direct log messages to stdout ### +log4j.appender.stdout=3Dorg.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=3DSystem.out +log4j.appender.stdout.layout=3Dorg.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=3D%d{ABSOLUTE} %5p %c{1}:%L= - %m%n + +### direct messages to file hibernate.log ### +log4j.appender.file=3Dorg.apache.log4j.FileAppender +log4j.appender.file.File=3Dhibernate.log +log4j.appender.file.layout=3Dorg.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=3D%d{ABSOLUTE} %5p %c{1}:%L -= %m%n + +### direct messages to socket - chainsaw ### +log4j.appender.socket=3Dorg.apache.log4j.net.SocketAppender +log4j.appender.socket.remoteHost=3Dlocalhost +log4j.appender.socket.port=3D4560 +log4j.appender.socket.locationInfo=3Dtrue + + +### set log levels - for more verbose logging change 'info' to 'debug' ### + +log4j.rootLogger=3Dwarn, stdout + +log4j.logger.org.hibernate=3Ddebug + + +### log just the SQL +log4j.logger.org.hibernate.SQL=3Ddebug + +#log4j.logger.org.hibernate.engine.CascadingAction=3Ddebug + +### log JDBC bind parameters ### +log4j.logger.org.hibernate.type=3Ddebug + +### log schema export/update ### +log4j.logger.org.hibernate.tool.hbm2ddl=3Ddebug + +### log cache activity ### +log4j.logger.org.hibernate.cache=3Ddebug + +### enable the following line if you want to track down connection ### +### leakages when using DriverManagerConnectionProvider ### +#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=3Dt= race + +### annotation logs +#log4j.logger.org.hibernate.annotation=3Dinfo +#log4j.logger.org.hibernate.cfg=3Dinfo +#log4j.logger.org.hibernate.cfg.SettingsFactory=3Dinfo +#log4j.logger.org.hibernate.cfg.AnnotationBinder=3Dinfo +#log4j.logger.org.hibernate.cfg.AnnotationConfiguration=3Dinfo +#log4j.logger.org.hibernate.cfg.Ejb3Column=3Dinfo \ No newline at end of file --===============3054816273972535029==-- From hibernate-commits at lists.jboss.org Tue Nov 24 15:28:30 2009 Content-Type: multipart/mixed; boundary="===============7209757913406946539==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18047 - annotations/branches/v3_4_0_GA_CP/src/java/org/hibernate. Date: Tue, 24 Nov 2009 15:28:29 -0500 Message-ID: <200911242028.nAOKSTvx026305@svn01.web.mwc.hst.phx2.redhat.com> --===============7209757913406946539== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-24 15:28:29 -0500 (Tue, 24 Nov 2009) New Revision: 18047 Removed: annotations/branches/v3_4_0_GA_CP/src/java/org/hibernate/ejb/ Log: JBPAPP-3150 change the build tool of Hibernate Annotations(eap 5 cp branch) --===============7209757913406946539==-- From hibernate-commits at lists.jboss.org Tue Nov 24 15:29:09 2009 Content-Type: multipart/mixed; boundary="===============6795430103158158087==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18048 - annotations/branches/v3_4_0_GA_CP. Date: Tue, 24 Nov 2009 15:29:09 -0500 Message-ID: <200911242029.nAOKT9S3026387@svn01.web.mwc.hst.phx2.redhat.com> --===============6795430103158158087== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-24 15:29:09 -0500 (Tue, 24 Nov 2009) New Revision: 18048 Removed: annotations/branches/v3_4_0_GA_CP/doc/ Log: JBPAPP-3150 change the build tool of Hibernate Annotations(eap 5 cp branch) --===============6795430103158158087==-- From hibernate-commits at lists.jboss.org Tue Nov 24 16:03:23 2009 Content-Type: multipart/mixed; boundary="===============8933672252304354649==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18049 - in annotations/branches/v3_4_0_GA_CP/src/test: java and 66 other directories. Date: Tue, 24 Nov 2009 16:03:23 -0500 Message-ID: <200911242103.nAOL3NJi000790@svn01.web.mwc.hst.phx2.redhat.com> --===============8933672252304354649== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-24 16:03:15 -0500 (Tue, 24 Nov 2009) New Revision: 18049 Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/A320.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/A320b.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/AlternativeNamingStrategy.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/AmericaCupClass.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Boat.hbm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Boat.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Company.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/ConfigurationTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Country.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Customer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Discount.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/EntityTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Ferry.hbm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Ferry.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Flight.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/FlyingObject.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/IncorrectEntity.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/JoinedSubclassTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Passport.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Plane.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Port.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/RequiresDialect.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/SafeMappingTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/SecuredBindingTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Sky.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/TestCase.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Thing.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/Ticket.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/TicketComparator.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/access/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/access/AccessTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/access/Bed.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/access/BigBed.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/access/Chair.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/access/Furniture.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/access/Gardenshed.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/access/Thingy.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/access/Woody.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/AnyTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/CharProperty.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/IntegerProperty.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/LongProperty.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/Property.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/PropertyList.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/PropertyMap.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/PropertySet.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/StringProperty.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/any/package-info.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/array/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/array/ArrayTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/array/Competitor.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/array/Contest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/backquotes/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/backquotes/BackquoteTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/backquotes/Bug.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/backquotes/Category.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/bytecode/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/bytecode/Hammer.hbm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/bytecode/Hammer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/bytecode/ProxyBreakingTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/bytecode/Tool.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cascade/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cascade/CascadeTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cascade/Mouth.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cascade/Tooth.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/A.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/AId.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/B.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/C.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/Channel.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/Child.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/ChildPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/CompositeIdTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/LittleGenius.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/Order.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/OrderLine.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/OrderLinePk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/Parent.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/ParentPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/Presenter.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/Product.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/TvMagazin.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/TvMagazinPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/TvProgram.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/cid/TvProgramIdClass.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/Boy.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/Brand.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/Character.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/CollectionElementTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/CountryAttitude.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/LocalizedString.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/Matrix.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/TestCourse.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/Toy.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/deepcollectionelements/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/deepcollectionelements/A.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/deepcollectionelements/B.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/deepcollectionelements/C.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/deepcollectionelements/DeepCollectionElementTest.j= ava annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/indexedCollection/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/indexedCollection/Contact.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/indexedCollection/IndexedCollectionOfElementsTest.= java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/collectionelement/indexedCollection/Sale.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/configuration/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/configuration/ConfigurationTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/configuration/orm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/configuration/package-info.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/duplicatedgenerator/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/duplicatedgenerator/DuplicateTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/duplicatedgenerator/Flight.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/duplicatedgenerator/orm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/Address.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/AddressType.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/Book.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/CorpType.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/Country.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/Deal.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/EmbeddedTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/FixedLeg.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/FloatLeg.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/InternetProvider.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/Leg.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/LegalStructure.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/Manager.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/Nationality.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/NotonialDeal.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/Person.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/RegionalArticle.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/RegionalArticlePk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/SpreadDeal.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/Summary.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/Swap.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/embedded/VanillaSwap.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Address.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/BasicHibernateAnnotationsTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Bid.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/CasterStringType.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/CommunityBid.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Country.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Flight.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Forest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Java5FeaturesTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Length.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/MonetaryAmount.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/MonetaryAmountUserType.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/PropertyDefaultMappingsTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Race.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Ransom.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Starred.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/Tree.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/WashingMachine.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/ZipCode.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entity/package-info.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entitynonentity/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entitynonentity/Cellular.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entitynonentity/Communication.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entitynonentity/EntityNonEntityTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entitynonentity/GSM.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entitynonentity/Interaction.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entitynonentity/Phone.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/entitynonentity/Voice.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fetch/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fetch/Branch.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fetch/FetchingTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fetch/Leaf.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fetch/Person.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fetch/Stay.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/A.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/A_PK.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/B.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/C.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/ClassA.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/ClassB.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/ClassC.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/ClassD.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/D.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/D_PK.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/fkcircularity/FkCircularityTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/Classes.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/DNA.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/Dummy.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/EmbeddedGenericsTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/Gene.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/GenericsTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/Item.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/Paper.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/PaperType.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/Price.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/PricedStuff.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/SomeGuy.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/State.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/StateType.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/Stuff.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/UnresolvedTypeTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/generics/WildEntity.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/genericsinheritance/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/genericsinheritance/Child.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/genericsinheritance/ChildHierarchy1.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/genericsinheritance/ChildHierarchy2.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/genericsinheritance/ChildHierarchy22.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/genericsinheritance/GenericsInheritanceTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/genericsinheritance/Parent.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/genericsinheritance/ParentHierarchy1.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/genericsinheritance/ParentHierarchy2.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/genericsinheritance/ParentHierarchy22.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/hibernate.cfg.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/EnumIdTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/IdClassTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/IdTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/JoinColumnOverrideTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/UUIDGenerator.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Ball.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/BreakDance.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Bunny.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Computer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Department.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Dog.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/FirTree.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Footballer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/FootballerPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Furniture.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/GoalKeeper.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Home.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Location.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/MilitaryBuilding.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Monkey.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Phone.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Planet.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/PlanetCheatSheet.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/PointyTooth.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Shoe.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/SoundSystem.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Store.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Tower.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/Tree.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/entities/TwinkleToes.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/package-info.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/EnumIdTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/IdClassTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/IdTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/JoinColumnOverrideTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/UUIDGenerator.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Ball.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/BreakDance.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Bunny.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Computer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Department.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Dog.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/FirTree.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Footballer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/FootballerPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Furniture.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/GoalKeeper.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Home.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Location.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/MilitaryBuilding.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Monkey.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Phone.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Planet.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/PlanetCheatSheet.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/PointyTooth.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Shoe.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/SoundSystem.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Store.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Tower.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/Tree.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/entities/TwinkleToes.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/id/sequences/package-info.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/identifiercollection/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/identifiercollection/IdentifierCollectionTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/identifiercollection/Passport.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/identifiercollection/Stamp.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/BasketItems.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/BasketItemsPK.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/Card.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/CardField.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/CardKey.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/Customer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/Customers.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/IdManyToOneTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/Project.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/ShoppingBaskets.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/ShoppingBasketsPK.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/Store.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/StoreCustomer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/StoreCustomerPK.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/A.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/Acces.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/AlphabeticalManyToOneTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/B.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/BId.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/Benefserv.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/C.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/CId.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/Droitacces.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/idmanytoone/alphabetical/Service.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/immutable/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/immutable/Country.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/immutable/Foobar.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/immutable/ImmutableTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/immutable/State.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/AddressBook.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/AddressEntry.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/AddressEntryPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/AlphabeticalDirectory.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Atmosphere.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Drawer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Dress.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Gas.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/GasKey.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Generation.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/GenerationGroup.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/GenerationUser.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/IndexedCollectionTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/MapKeyTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/News.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Newspaper.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Painter.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Painting.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/PaintingPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/PressReleaseAgency.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Software.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Trainee.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Training.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Version.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/indexcoll/Wardrobe.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/Apple.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/Carrot.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/Fruit.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/SubclassTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/Tomato.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/Vegetable.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/VegetablePk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/Alarm.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/Asset.hbm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/Asset.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/Clothing.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/Document.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/EventInformation.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/File.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/FinancialAsset.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/Folder.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/JoinedSubclassAndSecondaryTable.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/JoinedSubclassTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/Parent.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/Pool.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/ProgramExecution.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/PropertyAsset.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/Sweater.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/SwimmingPool.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/joined/SymbolicLink.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/mixed/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/mixed/Document.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/mixed/File.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/mixed/Folder.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/mixed/SubclassTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/mixed/SymbolicLink.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/singletable/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/singletable/Building.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/singletable/Funk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/singletable/House.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/singletable/Music.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/singletable/Noise.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/singletable/PaperTrash.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/singletable/Rock.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/singletable/Trash.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/union/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/union/Document.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/union/File.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/union/Folder.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/union/SubclassTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/inheritance/union/SymbolicLink.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/interfaces/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/interfaces/Contact.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/interfaces/ContactImpl.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/interfaces/InterfacesTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/interfaces/User.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/interfaces/UserImpl.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/join/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/join/A.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/join/B.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/join/C.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/join/Cat.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/join/Death.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/join/Dog.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/join/DogPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/join/JoinTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/join/Life.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/loader/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/loader/Loader.hbm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/loader/LoaderTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/loader/Player.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/loader/Team.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/lob/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/lob/Book.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/lob/CompiledCode.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/lob/Editor.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/lob/LobTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Building.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/BuildingCompany.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Cat.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/CatPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/City.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Company.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Contractor.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Employee.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Employer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Friend.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Group.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/GroupWithSet.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Inspector.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/InspectorPrefixes.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/KnownClient.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Man.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/ManPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/ManyToManyTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Permission.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Store.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Supplier.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Woman.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/WomanPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytomany/Zone.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/BiggestForest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Car.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Carz.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Child.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Color.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Customer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Deal.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/DistrictUser.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/ForestType.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Frame.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Lens.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Lotz.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/LotzPK.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/ManyToOneJoinTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/ManyToOneOnNonPkTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/ManyToOneTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Node.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/NodePk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Order.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/OrderLine.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/Parent.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/ParentPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/TreeType.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/User.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/UserPK.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/referencedcolumnname/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/referencedcolumnname/GenericObject.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/referencedcolumnname/Item.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/referencedcolumnname/Vendor.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/referencedcolumnname/WarehouseItem.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/manytoone/referencedcolumnname/ZItemCost.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/namingstrategy/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/namingstrategy/Address.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/namingstrategy/DummyNamingStrategy.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/namingstrategy/NamingStrategyTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/namingstrategy/Person.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/naturalid/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/naturalid/Citizen.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/naturalid/NaturalIdOnManyToOne.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/naturalid/NaturalIdOnSingleManyToOneTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/naturalid/NaturalIdTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/naturalid/State.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/notfound/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/notfound/Coin.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/notfound/Currency.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/notfound/NotFoundTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Child.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/City.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Monkey.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/OneToManyTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Order.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/OrderByTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/OrderID.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/OrderItem.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/OrderItemID.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Organisation.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/OrganisationUser.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Parent.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/ParentPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Person.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/PoliticalParty.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Politician.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Soldier.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Street.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Tiger.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Trainer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetomany/Troop.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/Address.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/Body.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/Client.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/Computer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/ComputerPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/Heart.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/OneToOneErrorTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/OneToOneTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/Owner.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/OwnerAddress.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/Party.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/PartyAffiliate.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/SerialNumber.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/SerialNumberPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/Show.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/ShowDescription.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/Trousers.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/TrousersZip.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/primarykey/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/primarykey/Address.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/primarykey/NullablePrimaryKeyTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/onetoone/primarykey/Person.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/orm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/override/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/override/AssociationOverrideTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/override/Location.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/override/Move.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/override/Trip.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/persister/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/persister/Card.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/persister/CollectionPersister.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/persister/Deck.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/persister/EntityPersister.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/persister/PersisterTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/polymorphism/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/polymorphism/Car.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/polymorphism/MovingThing.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/polymorphism/PolymorphismTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/polymorphism/SportCar.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/Area.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/Captain.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/CasimirParticle.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/Chaos.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/Dictionary.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/Dimensions.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/Identity.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/Mark.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/Night.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/QueryAndSQLTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/SpaceShip.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/SynonymousDictionary.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/query/orm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/quote/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/quote/QuoteTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/quote/Role.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/quote/User.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/Bag.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/Clothes.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/House.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/Inhabitant.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/Item.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/ItemCost.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/Luggage.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/Postman.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/Rambler.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/ReferencedColumnNameTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/Vendor.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/referencedcolumnname/WarehouseItem.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/Administration.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/Availability.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/BusTrip.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/BusTripPk.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/Competition.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/EJB3OverridenAnnotationReaderTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/LogListener.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/Match.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/Organization.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/OtherLogListener.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/SocialSecurityMoralAccount.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/SocialSecurityNumber.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/SocialSecurityPhysicalAccount.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/TennisMatch.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/XMLContextTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/metadata-complete.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/reflection/orm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/strategy/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/strategy/Location.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/strategy/Storm.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/strategy/StrategyTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tableperclass/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tableperclass/Component.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tableperclass/Machine.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tableperclass/Product.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tableperclass/Robot.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tableperclass/T800.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tableperclass/TablePerClassTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/target/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/target/Brand.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/target/Luggage.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/target/LuggageImpl.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/target/Owner.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/target/OwnerImpl.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/target/Size.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/target/SizeImpl.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/target/TargetTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tuplizer/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tuplizer/Country.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tuplizer/Cuisine.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tuplizer/DataProxyHandler.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tuplizer/DynamicComponentTuplizer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tuplizer/DynamicEntityTuplizer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tuplizer/DynamicInstantiator.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tuplizer/EntityNameInterceptor.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tuplizer/ProxyHelper.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/tuplizer/TuplizerTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/type/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/type/Dvd.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/type/MyOid.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/type/MyOidGenerator.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/type/MyOidType.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/type/TypeTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/various/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/various/Antenna.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/various/Conductor.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/various/GeneratedTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/various/IndexTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/various/ProfessionalAgreement.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/various/Truck.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/various/Vehicule.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/various/VersionTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ejb3/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ejb3/CarModel.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ejb3/Ejb3XmlTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ejb3/Light.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ejb3/Lighter.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ejb3/Manufacturer.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ejb3/Model.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ejb3/orm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ejb3/orm2.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/ejb3/orm3.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/A.hbm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/A.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/AImpl.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/B.hbm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/B.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/BImpl.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/CloudType.hbm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/CloudType.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/Government.hbm.xml annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/Government.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/HbmTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/HbmWithIdentityTest.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/PrimeMinister.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/Sky.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/Z.java annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annot= ations/xml/hbm/ZImpl.java Removed: annotations/branches/v3_4_0_GA_CP/src/test/org/ Log: JBPAPP-3150 change the build tool of Hibernate Annotations(eap 5 cp branch) Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/A320.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/A320.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/A320.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,23 @@ +//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)DiscriminatorValue("A320") +(a)Entity() +public class A320 extends Plane { + private String javaEmbeddedVersion; + + public String getJavaEmbeddedVersion() { + return javaEmbeddedVersion; + } + + public void setJavaEmbeddedVersion(String string) { + javaEmbeddedVersion =3D string; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/A320b.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/A320b.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/A320b.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,12 @@ +//$Id: A320b.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity() +public class A320b extends A320 { + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/AlternativeNamingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/AlternativeNamingStrategy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/AlternativeNamingStrategy.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,73 @@ +//$Id: AlternativeNamingStrategy.java 14736 2008-06-04 14:23:42Z hardy.fer= entschik $ +package org.hibernate.test.annotations; + +import org.hibernate.cfg.EJB3NamingStrategy; +import org.hibernate.cfg.NamingStrategy; +import org.hibernate.util.StringHelper; + +/** + * @author Emmanuel Bernard + */ +public class AlternativeNamingStrategy extends EJB3NamingStrategy { + public static NamingStrategy INSTANCE =3D new AlternativeNamingStrategy(); + + public String classToTableName(String className) { + return tableName( StringHelper.unqualify( className ) ); + } + + public String propertyToColumnName(String propertyName) { + return columnName( StringHelper.unqualify( propertyName ) ); + } + + public String tableName(String tableName) { + return "table_" + tableName; + } + + public String columnName(String columnName) { + return "f_" + columnName; + } + + public String propertyToTableName(String className, String propertyName) { + return tableName( StringHelper.unqualify( className ) + "_" + StringHelp= er.unqualify( propertyName ) ); + } + + public String logicalColumnName(String columnName, String propertyName) { + return StringHelper.isNotEmpty( columnName ) ? columnName : propertyName; + } + + public String collectionTableName( + String ownerEntity, String ownerEntityTable, String associatedEntity, S= tring associatedEntityTable, + String propertyName + ) { + return tableName( + new StringBuilder( ownerEntityTable ).append( "_" ) + .append( + associatedEntityTable !=3D null ? + associatedEntityTable : + StringHelper.unqualify( propertyName ) + ).toString() + ); + } + + public String logicalCollectionTablelName( + String tableName, + String ownerEntityTable, String associatedEntityTable, String propertyN= ame + ) { + if ( tableName !=3D null ) { + return tableName; + } + else { + //use of a stringbuffer to workaround a JDK bug + return new StringBuffer( ownerEntityTable ).append( "_" ) + .append( + associatedEntityTable !=3D null ? + associatedEntityTable : + StringHelper.unqualify( propertyName ) + ).toString(); + } + } + + public String logicalCollectionColumnName(String columnName, String prope= rtyName, String referencedColumn) { + return StringHelper.isNotEmpty( columnName ) ? columnName : propertyName= + "_" + referencedColumn; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/AmericaCupClass.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/AmericaCupClass.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/AmericaCupClass.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +//$Id: AmericaCupClass.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.PrimaryKeyJoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)PrimaryKeyJoinColumn(name =3D "BOAT_ID") +public class AmericaCupClass extends Boat { + private Country country; + + @ManyToOne() + @JoinColumn(name =3D "COUNTRY_ID") + public Country getCountry() { + return country; + } + + public void setCountry(Country country) { + this.country =3D country; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Boat.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Boat.hbm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Boat.hbm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Boat.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Boat.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Boat.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,57 @@ +//$Id: Boat.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + + +/** + * Boat class. Mapped in a Joined manner + * + * @author Emmanuel Bernard + */ +(a)Entity() +(a)Inheritance( + strategy =3D InheritanceType.JOINED +) +public class Boat implements Serializable { + private Integer id; + private int size; + private int weight; + + public Boat() { + super(); + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + @Column(name =3D "boat_size") + public int getSize() { + return size; + } + + public void setId(Integer integer) { + id =3D integer; + } + + public void setSize(int i) { + size =3D i; + } + + public int getWeight() { + return weight; + } + + public void setWeight(int weight) { + this.weight =3D weight; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Company.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Company.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Company.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,46 @@ +//$Id: Company.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.io.Serializable; +import java.util.Date; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + + +/** + * Corporate like Air France + * + * @author Emmanuel Bernard + */ +(a)Entity(name =3D "Corporation") +public class Company implements Serializable { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public String getName() { + return name; + } + + + public void setId(Integer integer) { + id =3D integer; + } + + + public void setName(String string) { + name =3D string; + } + + //should be treated as getter + private int[] getWorkingHoursPerWeek(Set holidayDays) { + return null; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/ConfigurationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/ConfigurationTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/ConfigurationTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,155 @@ +//$Id: ConfigurationTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.test.annotations; + +import org.hibernate.HibernateException; +import org.hibernate.MappingException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; + +/** + * @author Emmanuel Bernard + */ +public class ConfigurationTest extends junit.framework.TestCase { + public void testDeclarativeMix() throws Exception { + AnnotationConfiguration cfg =3D new AnnotationConfiguration(); + cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" ); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + SessionFactory sf =3D cfg.buildSessionFactory(); + assertNotNull( sf ); + Session s =3D sf.openSession(); + Transaction tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "from Boat" ); + assertEquals( 0, q.list().size() ); + q =3D s.createQuery( "from Plane" ); + assertEquals( 0, q.list().size() ); + tx.commit(); + s.close(); + sf.close(); + } + + public void testIgnoringHbm() throws Exception { + AnnotationConfiguration cfg =3D new AnnotationConfiguration(); + cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" ); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + cfg.setProperty( AnnotationConfiguration.ARTEFACT, "class, whatever" ); + SessionFactory sf =3D cfg.buildSessionFactory(); + assertNotNull( sf ); + Session s =3D sf.openSession(); + Transaction tx =3D s.beginTransaction(); + Query q; + try { + s.createQuery( "from Boat" ).list(); + fail( "Boat should not be mapped" ); + } + catch (HibernateException e) { + //all good + } + q =3D s.createQuery( "from Plane" ); + assertEquals( 0, q.list().size() ); + tx.commit(); + s.close(); + sf.close(); + } + + public void testPrecedenceHbm() throws Exception { + AnnotationConfiguration cfg =3D new AnnotationConfiguration(); + cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" ); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + cfg.addAnnotatedClass( Boat.class ); + SessionFactory sf =3D cfg.buildSessionFactory(); + assertNotNull( sf ); + Session s =3D sf.openSession(); + s.getTransaction().begin(); + Boat boat =3D new Boat(); + boat.setSize( 12 ); + boat.setWeight( 34 ); + s.persist( boat ); + s.getTransaction().commit(); + s.clear(); + Transaction tx =3D s.beginTransaction(); + boat =3D (Boat) s.get( Boat.class, boat.getId() ); + assertTrue( "Annotation has precedence", 34 !=3D boat.getWeight() ); + s.delete( boat ); + //s.getTransaction().commit(); + tx.commit(); + s.close(); + sf.close(); + } + + public void testPrecedenceAnnotation() throws Exception { + AnnotationConfiguration cfg =3D new AnnotationConfiguration(); + cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" ); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + cfg.setProperty( AnnotationConfiguration.ARTEFACT, "class, hbm" ); + cfg.addAnnotatedClass( Boat.class ); + SessionFactory sf =3D cfg.buildSessionFactory(); + assertNotNull( sf ); + Session s =3D sf.openSession(); + s.getTransaction().begin(); + Boat boat =3D new Boat(); + boat.setSize( 12 ); + boat.setWeight( 34 ); + s.persist( boat ); + s.getTransaction().commit(); + s.clear(); + Transaction tx =3D s.beginTransaction(); + boat =3D (Boat) s.get( Boat.class, boat.getId() ); + assertTrue( "Annotation has precedence", 34 =3D=3D boat.getWeight() ); + s.delete( boat ); + tx.commit(); + s.close(); + sf.close(); + } + + public void testDeclarativeAnnWoAnnConfig() throws Exception { + Configuration cfg =3D new Configuration(); + try { + cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" ); + fail( "Configuration object should fail when finding annotated elements= declarations" ); + } + catch (MappingException e) { + //success + } + } + + public void testHbmWithSubclassExtends() throws Exception { + AnnotationConfiguration cfg =3D new AnnotationConfiguration(); + cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" ); + cfg.addClass( Ferry.class ); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + SessionFactory sf =3D cfg.buildSessionFactory(); + assertNotNull( sf ); + Session s =3D sf.openSession(); + Transaction tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "from Ferry" ); + assertEquals( 0, q.list().size() ); + q =3D s.createQuery( "from Plane" ); + assertEquals( 0, q.list().size() ); + tx.commit(); + s.close(); + sf.close(); + } + + public void testAnnReferencesHbm() throws Exception { + AnnotationConfiguration cfg =3D new AnnotationConfiguration(); + cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" ); + cfg.addAnnotatedClass( Port.class ); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + SessionFactory sf =3D cfg.buildSessionFactory(); + assertNotNull( sf ); + Session s =3D sf.openSession(); + Transaction tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "from Boat" ); + assertEquals( 0, q.list().size() ); + q =3D s.createQuery( "from Port" ); + assertEquals( 0, q.list().size() ); + tx.commit(); + s.close(); + sf.close(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Country.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Country.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Country.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,47 @@ +//$Id: Country.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +/** + * @author Emmanuel Bernard + */ + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +(a)Entity() +public class Country implements Serializable { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public String getName() { + return name; + } + + public void setId(Integer integer) { + id =3D integer; + } + + public void setName(String string) { + name =3D string; + } + + public int hashCode() { + return name =3D=3D null ? 0 : name.hashCode(); + } + + public boolean equals(Object obj) { + if ( obj =3D=3D this ) return true; + if ( ! ( obj instanceof Country ) ) return false; + Country that =3D (Country) obj; + if ( this.name =3D=3D null ) return false; + return this.name.equals( that.name ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Customer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Customer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Customer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,88 @@ +//$Id: Customer.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.io.Serializable; +import java.util.Collection; +import java.util.SortedSet; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; + +import org.hibernate.annotations.Cascade; +import static org.hibernate.annotations.CascadeType.ALL; +import org.hibernate.annotations.Sort; +import org.hibernate.annotations.SortType; + + +/** + * Company customer + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Customer implements Serializable { + Long id; + String name; + SortedSet tickets; + Collection discountTickets; + Passport passport; + + public Customer() { + } + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public String getName() { + return name; + } + + public void setId(Long long1) { + id =3D long1; + } + + public void setName(String string) { + name =3D string; + } + + @OneToMany(cascade =3D CascadeType.ALL, fetch =3D FetchType.EAGER) + @JoinColumn(name =3D "CUST_ID") + @Sort(type =3D SortType.COMPARATOR, comparator =3D TicketComparator.class) + public SortedSet getTickets() { + return tickets; + } + + public void setTickets(SortedSet tickets) { + this.tickets =3D tickets; + } + + @OneToMany(targetEntity =3D org.hibernate.test.annotations.Discount.class, + cascade =3D CascadeType.ALL, mappedBy =3D "owner") + @Cascade({ALL}) + public Collection getDiscountTickets() { + return discountTickets; + } + + public void setDiscountTickets(Collection collection) { + discountTickets =3D collection; + } + + @OneToOne(cascade =3D CascadeType.ALL) + public Passport getPassport() { + return passport; + } + + public void setPassport(Passport passport) { + this.passport =3D passport; + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Discount.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Discount.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Discount.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,58 @@ +//$Id: Discount.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.io.Serializable; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + + +/** + * Discount ticket a client can use when buying tickets + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Discount implements Serializable { + + private Long id; + private double discount; + private Customer owner; + + + @Column(precision =3D 5, scale =3D 2) + public double getDiscount() { + return discount; + } + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setDiscount(double i) { + discount =3D i; + } + + public void setId(Long long1) { + id =3D long1; + } + + @ManyToOne(cascade =3D {CascadeType.ALL}, fetch =3D FetchType.LAZY) + @JoinColumn(name =3D "CUSTOMER_ID") + public Customer getOwner() { + return owner; + } + + public void setOwner(Customer customer) { + owner =3D customer; + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/EntityTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/EntityTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/EntityTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,385 @@ +//$Id: EntityTest.java 16418 2009-04-23 09:55:33Z jcosta(a)redhat.com $ +package org.hibernate.test.annotations; + +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.TimeZone; + +import org.hibernate.Hibernate; +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.StaleStateException; +import org.hibernate.Transaction; + +/** + * @author Emmanuel Bernard + */ +public class EntityTest extends TestCase { + + public EntityTest(String x) { + super( x ); + } + + public void testLoad() throws Exception { + //put an object in DB + assertEquals( "Flight", getCfg().getClassMapping( Flight.class.getName()= ).getTable().getName() ); + + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Flight firstOne =3D new Flight(); + firstOne.setId( new Long( 1 ) ); + firstOne.setName( "AF3202" ); + firstOne.setDuration( new Long( 1000000 ) ); + firstOne.setDurationInSec( 2000 ); + s.save( firstOne ); + s.flush(); + tx.commit(); + s.close(); + + //read it + s =3D openSession(); + tx =3D s.beginTransaction(); + firstOne =3D (Flight) s.get( Flight.class, new Long( 1 ) ); + assertNotNull( firstOne ); + assertEquals( new Long( 1 ), firstOne.getId() ); + assertEquals( "AF3202", firstOne.getName() ); + assertEquals( new Long( 1000000 ), firstOne.getDuration() ); + assertFalse( "Transient is not working", 2000l =3D=3D firstOne.getDurati= onInSec() ); + tx.commit(); + s.close(); + } + + public void testColumn() throws Exception { + //put an object in DB + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Flight firstOne =3D new Flight(); + firstOne.setId( new Long( 1 ) ); + firstOne.setName( "AF3202" ); + firstOne.setDuration( new Long( 1000000 ) ); + firstOne.setDurationInSec( 2000 ); + s.save( firstOne ); + s.flush(); + tx.commit(); + s.close(); + = + + s =3D openSession(); + tx =3D s.beginTransaction(); + firstOne =3D new Flight(); + firstOne.setId( new Long( 1 ) ); + firstOne.setName( null ); + + try { + s.save( firstOne ); + tx.commit(); + fail( "Name column should be not null" ); + } + catch (HibernateException e) { + //fine + } + finally { + s.close(); + } + + //insert an object and check that name is not updatable + s =3D openSession(); + tx =3D s.beginTransaction(); + firstOne =3D new Flight(); + firstOne.setId( new Long( 1 ) ); + firstOne.setName( "AF3202" ); + firstOne.setTriggeredData( "should not be insertable" ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + firstOne =3D (Flight) s.get( Flight.class, new Long( 1 ) ); + assertNotNull( firstOne ); + assertEquals( new Long( 1 ), firstOne.getId() ); + assertEquals( "AF3202", firstOne.getName() ); + assertFalse( "should not be insertable".equals( firstOne.getTriggeredDat= a() ) ); + firstOne.setName( "BA1234" ); + firstOne.setTriggeredData( "should not be updatable" ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + firstOne =3D (Flight) s.get( Flight.class, new Long( 1 ) ); + assertNotNull( firstOne ); + assertEquals( new Long( 1 ), firstOne.getId() ); + assertEquals( "AF3202", firstOne.getName() ); + assertFalse( "should not be updatable".equals( firstOne.getTriggeredData= () ) ); + tx.commit(); + s.close(); + } + + public void testColumnUnique() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Sky sky =3D new Sky(); + sky.id =3D new Long( 2 ); + sky.color =3D "blue"; + sky.day =3D "monday"; + sky.month =3D "January"; + + Sky sameSky =3D new Sky(); + sameSky.id =3D new Long( 3 ); + sameSky.color =3D "blue"; + sky.day =3D "tuesday"; + sky.month =3D "January"; + + try { + s.save( sky ); + s.flush(); + s.save( sameSky ); + tx.commit(); + fail( "unique constraints not respected" ); + } + catch (HibernateException e) { + //success + } + finally { + if ( tx !=3D null ) tx.rollback(); + s.close(); + } + } + + public void testUniqueConstraint() throws Exception { + int id =3D 5; + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Sky sky =3D new Sky(); + sky.id =3D new Long( id++ ); + sky.color =3D "green"; + sky.day =3D "monday"; + sky.month =3D "March"; + + Sky otherSky =3D new Sky(); + otherSky.id =3D new Long( id++ ); + otherSky.color =3D "red"; + otherSky.day =3D "friday"; + otherSky.month =3D "March"; + + Sky sameSky =3D new Sky(); + sameSky.id =3D new Long( id++ ); + sameSky.color =3D "green"; + sameSky.day =3D "monday"; + sameSky.month =3D "March"; + + s.save( sky ); + s.flush(); + + s.save( otherSky ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + try { + s.save( sameSky ); + tx.commit(); + fail( "unique constraints not respected" ); + } + catch (HibernateException e) { + //success + } + finally { + if ( tx !=3D null ) tx.rollback(); + s.close(); + } + } + + public void testVersion() throws Exception { +// put an object in DB + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Flight firstOne =3D new Flight(); + firstOne.setId( new Long( 2 ) ); + firstOne.setName( "AF3202" ); + firstOne.setDuration( new Long( 500 ) ); + s.save( firstOne ); + s.flush(); + tx.commit(); + s.close(); + + //read it + s =3D openSession(); + tx =3D s.beginTransaction(); + firstOne =3D (Flight) s.get( Flight.class, new Long( 2 ) ); + tx.commit(); + s.close(); + + //read it again + s =3D openSession(); + tx =3D s.beginTransaction(); + Flight concurrentOne =3D (Flight) s.get( Flight.class, new Long( 2 ) ); + concurrentOne.setDuration( new Long( 1000 ) ); + s.update( concurrentOne ); + tx.commit(); + s.close(); + assertFalse( firstOne =3D=3D concurrentOne ); + assertFalse( firstOne.getVersion().equals( concurrentOne.getVersion() ) = ); + + //reattach the first one + s =3D openSession(); + tx =3D s.beginTransaction(); + firstOne.setName( "Second access" ); + s.update( firstOne ); + try { + tx.commit(); + fail( "Optimistic locking should work" ); + } + catch (StaleStateException e) { + //fine + } + finally { + if ( tx !=3D null ) tx.rollback(); + s.close(); + } + + } + + public void testFieldAccess() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Sky sky =3D new Sky(); + sky.id =3D new Long( 1 ); + sky.color =3D "black"; + Sky.area =3D "Paris"; + sky.day =3D "23"; + sky.month =3D "1"; + s.save( sky ); + tx.commit(); + s.close(); + Sky.area =3D "London"; + + s =3D openSession(); + tx =3D s.beginTransaction(); + sky =3D (Sky) s.get( Sky.class, sky.id ); + assertNotNull( sky ); + assertEquals( "black", sky.color ); + assertFalse( "Paris".equals( Sky.area ) ); + tx.commit(); + s.close(); + } + + public void testEntityName() throws Exception { + assertEquals( "Corporation", getCfg().getClassMapping( Company.class.get= Name() ).getTable().getName() ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Company comp =3D new Company(); + s.persist( comp ); + comp.setName( "JBoss Inc" ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + List result =3D s.createQuery( "from Corporation" ).list(); + assertNotNull( result ); + assertEquals( 1, result.size() ); + tx.commit(); + s.close(); + + } + + public void testNonGetter() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Flight airFrance =3D new Flight(); + airFrance.setId( new Long( 747 ) ); + airFrance.setName( "Paris-Amsterdam" ); + airFrance.setDuration( new Long( 10 ) ); + airFrance.setFactor( 25 ); + s.persist( airFrance ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + airFrance =3D (Flight) s.get( Flight.class, airFrance.getId() ); + assertNotNull( airFrance ); + assertEquals( new Long( 10 ), airFrance.getDuration() ); + assertFalse( 25 =3D=3D airFrance.getFactor( false ) ); + s.delete( airFrance ); + tx.commit(); + s.close(); + } + + public void testTemporalType() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Flight airFrance =3D new Flight(); + airFrance.setId( new Long( 747 ) ); + airFrance.setName( "Paris-Amsterdam" ); + airFrance.setDuration( new Long( 10 ) ); + airFrance.setDepartureDate( new Date( 05, 06, 21, 10, 0, 0 ) ); + airFrance.setAlternativeDepartureDate( new GregorianCalendar( 2006, 02, = 03, 10, 00 ) ); + airFrance.getAlternativeDepartureDate().setTimeZone( TimeZone.getTimeZon= e( "GMT" ) ); + airFrance.setBuyDate( new java.sql.Timestamp(122367443) ); + airFrance.setFactor( 25 ); + s.persist( airFrance ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "from Flight f where f.departureDate =3D :dep= artureDate" ); + q.setParameter( "departureDate", airFrance.getDepartureDate(), Hibernate= .DATE ); + Flight copyAirFrance =3D (Flight) q.uniqueResult(); + assertNotNull( copyAirFrance ); + assertEquals( + new Date( 05, 06, 21 ), + copyAirFrance.getDepartureDate() + ); + assertEquals( copyAirFrance.getBuyDate().getTime() / 1000 , airFrance.ge= tBuyDate().getTime() / 1000 ); + + s.delete( copyAirFrance ); + tx.commit(); + s.close(); + } + + public void testBasic() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Flight airFrance =3D new Flight(); + airFrance.setId( new Long( 747 ) ); + airFrance.setName( "Paris-Amsterdam" ); + airFrance.setDuration( null ); + try { + s.persist( airFrance ); + tx.commit(); + fail( "Basic(optional=3Dfalse) fails" ); + } + catch (Exception e) { + //success + if ( tx !=3D null ) tx.rollback(); + } + finally { + s.close(); + } + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + Flight.class, + Company.class, + Sky.class + }; + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Ferry.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Ferry.hbm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Ferry.hbm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Ferry.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Ferry.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Ferry.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: Ferry.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import javax.persistence.Entity; + + +/** + * @author Emmanuel Bernard + */ +(a)Entity() +public class Ferry extends Boat { + private String sea; + + public String getSea() { + return sea; + } + + public void setSea(String string) { + sea =3D string; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Flight.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Flight.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Flight.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,149 @@ +//$Id: Flight.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import javax.persistence.Version; + +/** + * Flight + * + * @author Emmanuel Bernard + */ +(a)Entity() +(a)Inheritance(strategy =3D InheritanceType.TABLE_PER_CLASS) +public class Flight implements Serializable { + Long id; + String name; + transient Long duration; + long durationInSec; + Integer version; + Company company; + String triggeredData; + long factor; + Date departureDate; + java.sql.Timestamp buyDate; + Calendar alternativeDepartureDate; + + @Id + public Long getId() { + return id; + } + + public void setId(Long long1) { + id =3D long1; + } + + @Column(name =3D "flight_name", nullable =3D false, updatable =3D false, = length =3D 50) + public String getName() { + return name; + } + + public void setName(String string) { + name =3D string; + } + + @Basic(fetch =3D FetchType.LAZY, optional =3D false) + public Long getDuration() { + return duration; + } + + @Basic + @Temporal(TemporalType.DATE) + public Date getDepartureDate() { + return departureDate; + } + + public void setDepartureDate(Date departureDate) { + this.departureDate =3D departureDate; + } + + + public void setDuration(Long l) { + duration =3D l; + //durationInSec =3D duration / 1000; + } + + @Transient + public long getDurationInSec() { + return durationInSec; + } + + public void setDurationInSec(long l) { + durationInSec =3D l; + } + + @Version + @Column(name =3D "OPTLOCK") + public Integer getVersion() { + return version; + } + + public void setVersion(Integer i) { + version =3D i; + } + + @ManyToOne(cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}) + @JoinColumn(name =3D "COMP_ID") + public Company getCompany() { + return company; + } + + public void setCompany(Company company) { + this.company =3D company; + } + + @Column(insertable =3D false, updatable =3D false) + public String getTriggeredData() { + return triggeredData; + } + + public void setTriggeredData(String string) { + triggeredData =3D string; + } + + public void getIsNotAGetter() { + //do nothing + } + + public long getFactor(boolean x10) { + //this is not a getter should not be persisted + return factor * ( 1 + ( x10 =3D=3D true ? 9 : 0 ) ); + } + + public void setFactor(long factor) { + this.factor =3D factor; + } + + @Temporal(TemporalType.TIMESTAMP) + public Calendar getAlternativeDepartureDate() { + return alternativeDepartureDate; + } + + public void setAlternativeDepartureDate(Calendar alternativeDepartureDate= ) { + this.alternativeDepartureDate =3D alternativeDepartureDate; + } + + public java.sql.Timestamp getBuyDate() { + return buyDate; + } + + public void setBuyDate(java.sql.Timestamp buyDate) { + this.buyDate =3D buyDate; + } + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/FlyingObject.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/FlyingObject.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/FlyingObject.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,54 @@ +//$Id: FlyingObject.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.MappedSuperclass; +import javax.persistence.Transient; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public abstract class FlyingObject extends Thing implements Serializable { + private String serial; + private int altitude; + private int metricAltitude; + private String color =3D "white"; + + + public int getAltitude() { + return altitude; + } + + public void setAltitude(int i) { + altitude =3D i; + } + + @Transient + public int getMetricAltitude() { + return metricAltitude; + } + + public void setMetricAltitude(int i) { + metricAltitude =3D i; + } + + @Column(name =3D "serialnbr") + public String getSerial() { + return serial; + } + + public void setSerial(String serial) { + this.serial =3D serial; + } + + @Column(nullable =3D false) + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color =3D color; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/IncorrectEntity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/IncorrectEntity.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/IncorrectEntity.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,20 @@ +//$Id: IncorrectEntity.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class IncorrectEntity { + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/JoinedSubclassTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/JoinedSubclassTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/JoinedSubclassTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,110 @@ +//$Id: JoinedSubclassTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschi= k $ +package org.hibernate.test.annotations; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.inheritance.Carrot; +import org.hibernate.test.annotations.inheritance.Tomato; +import org.hibernate.test.annotations.inheritance.Vegetable; +import org.hibernate.test.annotations.inheritance.VegetablePk; + +/** + * @author Emmanuel Bernard + */ +public class JoinedSubclassTest extends TestCase { + + public JoinedSubclassTest(String x) { + super( x ); + } + + public void testDefaultValues() { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Ferry f =3D new Ferry(); + f.setSize( 2 ); + f.setSea( "Channel" ); + s.persist( f ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + f =3D (Ferry) s.get( Ferry.class, f.getId() ); + assertNotNull( f ); + assertEquals( "Channel", f.getSea() ); + assertEquals( 2, f.getSize() ); + s.delete( f ); + tx.commit(); + s.close(); + } + + public void testDeclaredValues() { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Country c =3D new Country(); + c.setName( "France" ); + AmericaCupClass f =3D new AmericaCupClass(); + f.setSize( 2 ); + f.setCountry( c ); + s.persist( c ); + s.persist( f ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + f =3D (AmericaCupClass) s.get( AmericaCupClass.class, f.getId() ); + assertNotNull( f ); + assertEquals( c, f.getCountry() ); + assertEquals( 2, f.getSize() ); + s.delete( f ); + s.delete( f.getCountry() ); + tx.commit(); + s.close(); + } + + public void testCompositePk() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Carrot c =3D new Carrot(); + VegetablePk pk =3D new VegetablePk(); + pk.setFarmer( "Bill" ); + pk.setHarvestDate( "2004-08-15" ); + c.setId( pk ); + c.setLength( 23 ); + s.persist( c ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Vegetable v =3D (Vegetable) s.createCriteria( Vegetable.class ).uniqueRe= sult(); + assertTrue( v instanceof Carrot ); + Carrot result =3D (Carrot) v; + assertEquals( 23, result.getLength() ); + tx.commit(); + s.close(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + Boat.class, + Ferry.class, + AmericaCupClass.class, + Country.class, + Vegetable.class, + Carrot.class, + Tomato.class + }; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Passport.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Passport.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Passport.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,49 @@ +//$Id: Passport.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; + +/** + * International passport + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Passport implements Serializable { + + private Long id; + private String number; + private Customer owner; + + @Id + public Long getId() { + return id; + } + + @Column(name =3D "passport_number") + public String getNumber() { + return number; + } + + @OneToOne(mappedBy =3D "passport") + public Customer getOwner() { + return owner; + } + + public void setId(Long long1) { + id =3D long1; + } + + public void setNumber(String string) { + number =3D string; + } + + public void setOwner(Customer customer) { + owner =3D customer; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Plane.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Plane.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Plane.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,58 @@ +//$Id: Plane.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorType; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.NamedQuery; +import javax.persistence.QueryHint; + +/** + * Plane class + * + * @author Emmanuel Bernard + */ +(a)Entity() +(a)Inheritance(strategy =3D InheritanceType.SINGLE_TABLE) +(a)DiscriminatorColumn(name =3D "planetype", length =3D 100, discriminator= Type =3D DiscriminatorType.STRING) +(a)DiscriminatorValue("Plane") +(a)AttributeOverride(name =3D "altitude", column =3D @Column(name =3D "fld= _altitude")) +(a)NamedQuery(name =3D "plane.byId", query =3D "from Plane where id =3D :i= d", + hints =3D {@QueryHint(name =3D "org.hibernate.cacheable", value =3D "tru= e"), + @QueryHint(name =3D "org.hibernate.cacheRegion", value =3D "testedCacheR= egion"), + @QueryHint(name =3D "org.hibernate.timeout", value =3D "100"), + @QueryHint(name =3D "org.hibernate.fetchSize", value =3D "1"), + @QueryHint(name =3D "org.hibernate.flushMode", value =3D "Commit"), + @QueryHint(name =3D "org.hibernate.cacheMode", value =3D "NORMAL"), + @QueryHint(name =3D "org.hibernate.comment", value =3D "Plane by id")}) +public class Plane extends FlyingObject { + + private Long id; + private int nbrofSeats; + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public int getNbrOfSeats() { + return nbrofSeats; + } + + public void setId(Long long1) { + id =3D long1; + } + + public void setNbrOfSeats(int i) { + nbrofSeats =3D i; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Port.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Port.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Port.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,37 @@ +//$Id: Port.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +/** + * Used to test that annotated classes can have one-to-many + * relationships with hbm loaded classes. + */ +(a)Entity() +public class Port { + private Long id; + private Set boats; + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long long1) { + id =3D long1; + } + + @OneToMany + public Set getBoats() { + return boats; + } + + public void setBoats(Set boats) { + this.boats =3D boats; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/RequiresDialect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/RequiresDialect.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/RequiresDialect.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,20 @@ +// $Id: RequiresDialect.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.hibernate.dialect.Dialect; + +/** + * Annotations used to mark a test to be specific to a given dialect. + * = + * @author Hardy Ferentschik + */ +(a)Target({ElementType.METHOD, ElementType.TYPE}) +(a)Retention(RetentionPolicy.RUNTIME) +public @interface RequiresDialect { + Class[] value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/SafeMappingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/SafeMappingTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/SafeMappingTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +//$Id: SafeMappingTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import org.hibernate.AnnotationException; +import org.hibernate.SessionFactory; +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.cfg.Environment; + +/** + * @author Emmanuel Bernard + */ +public class SafeMappingTest extends junit.framework.TestCase { + public void testDeclarativeMix() throws Exception { + AnnotationConfiguration cfg =3D new AnnotationConfiguration(); + cfg.addAnnotatedClass( IncorrectEntity.class ); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + try { + SessionFactory sf =3D cfg.buildSessionFactory(); + fail( "Entity wo id should fail" ); + } + catch (AnnotationException e) { + //success + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/SecuredBindingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/SecuredBindingTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/SecuredBindingTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,44 @@ +//$Id: SecuredBindingTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschi= k $ +package org.hibernate.test.annotations; + +import java.util.Properties; + +import junit.framework.TestCase; +import org.hibernate.HibernateException; +import org.hibernate.SessionFactory; +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.cfg.Environment; + +/** + * @author Emmanuel Bernard + */ +public class SecuredBindingTest extends TestCase { + + public SecuredBindingTest(String x) { + super( x ); + } + + public void testConfigurationMethods() throws Exception { + AnnotationConfiguration ac =3D new AnnotationConfiguration(); + Properties p =3D new Properties(); + p.put( Environment.DIALECT, "org.hibernate.dialect.HSQLDialect" ); + p.put( "hibernate.connection.driver_class", "org.hsqldb.jdbcDrive" ); + p.put( "hibernate.connection.url", "jdbc:hsqldb:." ); + p.put( "hibernate.connection.username", "sa" ); + p.put( "hibernate.connection.password", "" ); + p.put( "hibernate.show_sql", "true" ); + ac.setProperties( p ); + ac.addAnnotatedClass( Plane.class ); + SessionFactory sf; + try { + sf =3D ac.buildSessionFactory(); + fail( "Driver property overriding should work" ); + sf.close(); + } + catch (HibernateException he) { + //success + } + + } +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Sky.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Sky.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Sky.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,28 @@ +//$Id: Sky.java 16418 2009-04-23 09:55:33Z jcosta(a)redhat.com $ +package org.hibernate.test.annotations; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_sky", + uniqueConstraints =3D {@UniqueConstraint(columnNames =3D {"month", "day"= })} +) +public class Sky implements Serializable { + @Id + protected Long id; + @Column(unique =3D true, columnDefinition =3D "varchar(250)", nullable = =3D false) + protected String color; + @Column(nullable =3D false) + protected String day; + @Column(name =3D "MONTH", nullable =3D false) + protected String month; + static protected String area; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/TestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/TestCase.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/TestCase.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,292 @@ +//$Id: TestCase.java 17724 2009-10-13 15:47:59Z stliu $ +package org.hibernate.test.annotations; + +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.hibernate.HibernateException; +import org.hibernate.Interceptor; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import org.hibernate.dialect.Dialect; +import org.hibernate.jdbc.Work; +import org.hibernate.tool.hbm2ddl.SchemaExport; + +/** + * A base class for all tests. + * + * @author Emmnauel Bernand + * @author Hardy Ferentschik + */ +public abstract class TestCase extends junit.framework.TestCase { + + public static final Logger log =3D LoggerFactory.getLogger( TestCase.clas= s ); + + private static SessionFactory sessions; + private static AnnotationConfiguration cfg; + private static Class lastTestClass; + private Session session; + + /** + * The test method. + */ + private Method runMethod =3D null; + + /** + * Flag indicating whether the test should be run or skipped. + */ + private boolean runTest =3D true; + + /** + * List of required dialect for the current {@code runMethod}. If the lis= t is empty any dialect is allowed. + * Otherwise the current dialect or a superclass of the current dialect m= ust be in the list. + */ + private final Set> requiredDialectList =3D new H= ashSet>(); + + public TestCase() { + super(); + } + + public TestCase(String x) { + super( x ); + } + + protected void buildSessionFactory(Class[] classes, String[] packages,= String[] xmlFiles) throws Exception { + + if ( getSessions() !=3D null ) { + getSessions().close(); + } + try { + setCfg( new AnnotationConfiguration() ); + configure( cfg ); + if ( recreateSchema() ) { + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + } + for ( String aPackage : packages ) { + getCfg().addPackage( aPackage ); + } + for ( Class aClass : classes ) { + getCfg().addAnnotatedClass( aClass ); + } + for ( String xmlFile : xmlFiles ) { + InputStream is =3D Thread.currentThread().getContextClassLoader().getR= esourceAsStream( xmlFile ); + getCfg().addInputStream( is ); + } + setSessions( getCfg().buildSessionFactory( /* new TestInterceptor() */ = ) ); + } + catch ( Exception e ) { + e.printStackTrace(); + throw e; + } + } + + protected void setUp() throws Exception { + runMethod =3D findTestMethod(); + setRunTestFlag( runMethod ); + if ( runTest ) { + if ( getSessions() =3D=3D null || lastTestClass !=3D getClass() ) { + buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFile= s() ); + lastTestClass =3D getClass(); + } + else { + runSchemaGeneration(); + } + } + } + + protected void runTest() throws Throwable { + try { + if ( runTest ) { + runTestMethod( runMethod ); + handleUnclosedSession(); + } + } + catch ( Throwable e ) { + closeSession( e ); + } + } + + private void setRunTestFlag(Method runMethod) { + updateRequiredDialectList( runMethod ); + + if ( runForCurrentDialect() ) { + runTest =3D true; + } + else { + log.warn( + "Skipping test {}, because test does not apply for dialect {}", runMe= thod.getName(), Dialect + .getDialect().getClass() + ); + runTest =3D false; + } + } + + private void updateRequiredDialectList(Method runMethod) { + requiredDialectList.clear(); + + RequiresDialect requiresDialectMethodAnn =3D runMethod.getAnnotation( Re= quiresDialect.class ); + if ( requiresDialectMethodAnn !=3D null ) { + Class[] requiredDialects =3D requiresDialectMethodAn= n.value(); + requiredDialectList.addAll( Arrays.asList( requiredDialects ) ); + } + + RequiresDialect requiresDialectClassAnn =3D getClass().getAnnotation( Re= quiresDialect.class ); + if ( requiresDialectClassAnn !=3D null ) { + Class[] requiredDialects =3D requiresDialectClassAnn= .value(); + requiredDialectList.addAll( Arrays.asList( requiredDialects ) ); + } + } + + protected boolean runForCurrentDialect() { + if ( requiredDialectList.isEmpty() ) { + return true; + } + else { + // check whether the current dialect is assignableFrom from any of the = specified required dialects. + for ( Class dialect : requiredDialectList ) { + if ( dialect.isAssignableFrom( Dialect.getDialect().getClass() ) ) { + return true; + } + } + return false; + } + } + + private void runTestMethod(Method runMethod) throws Throwable { + try { + runMethod.invoke( this, new Class[0] ); + } + catch ( InvocationTargetException e ) { + e.fillInStackTrace(); + throw e.getTargetException(); + } + catch ( IllegalAccessException e ) { + e.fillInStackTrace(); + throw e; + } + } + + private Method findTestMethod() { + String fName =3D getName(); + assertNotNull( fName ); + Method runMethod =3D null; + try { + runMethod =3D getClass().getMethod( fName, null ); + } + catch ( NoSuchMethodException e ) { + fail( "Method \"" + fName + "\" not found" ); + } + if ( !Modifier.isPublic( runMethod.getModifiers() ) ) { + fail( "Method \"" + fName + "\" should be public" ); + } + return runMethod; + } + + private void handleUnclosedSession() { + if ( session !=3D null && session.isOpen() ) { + if ( session.isConnected() ) { + session.doWork( new RollbackWork() ); + } + session.close(); + session =3D null; + fail( "unclosed session" ); + } + else { + session =3D null; + } + } + + private void closeSession(Throwable e) throws Throwable { + try { + if ( session !=3D null && session.isOpen() ) { + if ( session.isConnected() ) { + session.doWork( new RollbackWork() ); + } + session.close(); + } + } + catch ( Exception ignore ) { + } + try { + if ( sessions !=3D null ) { + sessions.close(); + sessions =3D null; + } + } + catch ( Exception ignore ) { + } + throw e; + } + + public Session openSession() throws HibernateException { + session =3D getSessions().openSession(); + return session; + } + + public Session openSession(Interceptor interceptor) throws HibernateExcep= tion { + session =3D getSessions().openSession( interceptor ); + return session; + } + + protected abstract Class[] getMappings(); + + protected String[] getAnnotatedPackages() { + return new String[] { }; + } + + protected String[] getXmlFiles() { + return new String[] { }; + } + + private void setSessions(SessionFactory sessions) { + TestCase.sessions =3D sessions; + } + + protected SessionFactory getSessions() { + return sessions; + } + + protected Dialect getDialect() { + return Dialect.getDialect(); + } + + protected static void setCfg(AnnotationConfiguration cfg) { + TestCase.cfg =3D cfg; + } + + protected static AnnotationConfiguration getCfg() { + return cfg; + } + + protected void configure(Configuration cfg) { + } + + protected boolean recreateSchema() { + return true; + } + + protected void runSchemaGeneration() { + SchemaExport export =3D new SchemaExport( cfg ); + export.create( true, true ); + } + + public class RollbackWork implements Work { + + public void execute(Connection connection) throws SQLException { + connection.rollback(); + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Thing.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Thing.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Thing.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,21 @@ +//$Id: Thing.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Thing { + private boolean isAlive; + + public boolean isAlive() { + return isAlive; + } + + public void setAlive(boolean alive) { + isAlive =3D alive; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/Ticket.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Ticket.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/Ticket.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,58 @@ +//$Id: Ticket.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * Flight ticket + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Ticket implements Serializable { + Long id; + String number; + + public Ticket() { + } + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + @Column(name =3D "ticket_number") + public String getNumber() { + return number; + } + + public void setId(Long long1) { + id =3D long1; + } + + public void setNumber(String string) { + number =3D string; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Ticket ) ) return false; + + final Ticket ticket =3D (Ticket) o; + + if ( !number.equals( ticket.number ) ) return false; + + return true; + } + + public int hashCode() { + return number.hashCode(); + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/TicketComparator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/TicketComparator.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/TicketComparator.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,20 @@ +//$Id: TicketComparator.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations; + +import java.util.Comparator; + +/** + * Ticket comparator ordering longest first + * + * @author Emmanuel Bernard + */ +public class TicketComparator implements Comparator { + + public int compare(Ticket ticket, Ticket ticket1) { + if ( ticket =3D=3D null || ticket1 =3D=3D null ) { + throw new IllegalStateException( "Ticket comparison only available thro= ugh non null tickets" ); + } + return ticket1.getNumber().length() - ticket.getNumber().length(); + + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/access/AccessTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/AccessTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/AccessTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,128 @@ +//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $ +package org.hibernate.test.annotations.access; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class AccessTest extends TestCase { + = + public void testSuperclassOverriding() throws Exception { + Furniture fur =3D new Furniture(); + fur.setColor( "Black" ); + fur.setName( "Beech" ); + fur.isAlive =3D true; + Session s =3D openSession(); + s.persist( fur ); + Transaction tx =3D s.beginTransaction(); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + fur =3D (Furniture) s.get( Furniture.class, fur.getId() ); + assertFalse( fur.isAlive ); + assertNotNull( fur.getColor() ); + s.delete( fur ); + tx.commit(); + s.close(); + } + + public void testSuperclassNonOverriding() throws Exception { + Furniture fur =3D new Furniture(); + fur.setGod( "Buddha" ); + Session s =3D openSession(); + s.persist( fur ); + Transaction tx =3D s.beginTransaction(); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + fur =3D (Furniture) s.get( Furniture.class, fur.getId() ); + assertNotNull( fur.getGod() ); + s.delete( fur ); + tx.commit(); + s.close(); + } + + public void testPropertyOverriding() throws Exception { + Furniture fur =3D new Furniture(); + fur.weight =3D 3; + Session s =3D openSession(); + s.persist( fur ); + Transaction tx =3D s.beginTransaction(); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + fur =3D (Furniture) s.get( Furniture.class, fur.getId() ); + assertEquals( 5, fur.weight ); + s.delete( fur ); + tx.commit(); + s.close(); + + } + + public void testNonOverridenSubclass() throws Exception { + Chair chair =3D new Chair(); + chair.setPillow( "Blue" ); + Session s =3D openSession(); + s.persist( chair ); + Transaction tx =3D s.beginTransaction(); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + chair =3D (Chair) s.get( Chair.class, chair.getId() ); + assertNull( chair.getPillow() ); + s.delete( chair ); + tx.commit(); + s.close(); + + } + + public void testOverridenSubclass() throws Exception { + BigBed bed =3D new BigBed(); + bed.size =3D 5; + bed.setQuality( "good" ); + Session s =3D openSession(); + s.persist( bed ); + Transaction tx =3D s.beginTransaction(); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + bed =3D (BigBed) s.get( BigBed.class, bed.getId() ); + assertEquals( 5, bed.size ); + assertNull( bed.getQuality() ); + s.delete( bed ); + tx.commit(); + s.close(); + + } + + public void testFieldsOverriding() throws Exception { + Gardenshed gs =3D new Gardenshed(); + gs.floors =3D 4; + Session s =3D openSession(); + s.persist( gs ); + Transaction tx =3D s.beginTransaction(); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + gs =3D (Gardenshed) s.get( Gardenshed.class, gs.getId() ); + assertEquals( 4, gs.floors ); + assertEquals( 6, gs.getFloors() ); + s.delete( gs ); + tx.commit(); + s.close(); + + } + + protected Class[] getMappings() { + return new Class[]{ + Bed.class, + Chair.class, + Furniture.class, + BigBed.class, + Gardenshed.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/access/Bed.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Bed.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Bed.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +//$Id: Bed.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.access; + +import javax.persistence.Entity; +import javax.persistence.Transient; + +import org.hibernate.annotations.AccessType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)AccessType("property") +public class Bed extends Furniture { + String quality; + + @Transient + public String getQuality() { + return quality; + } + + public void setQuality(String quality) { + this.quality =3D quality; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/access/BigBed.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/BigBed.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/BigBed.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,14 @@ +//$Id: BigBed.java 15073 2008-08-14 17:32:44Z epbernard $ +package org.hibernate.test.annotations.access; + +import javax.persistence.Entity; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class BigBed extends Bed { + @Column(name=3D"bed_size") + public int size; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/access/Chair.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Chair.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Chair.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,23 @@ +//$Id: Chair.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.access; + +import javax.persistence.Entity; +import javax.persistence.Transient; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Chair extends Furniture { + + @Transient + private String pillow; + + public String getPillow() { + return pillow; + } + + public void setPillow(String pillow) { + this.pillow =3D pillow; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/access/Furniture.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Furniture.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Furniture.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,51 @@ +//$Id: Furniture.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.access; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Transient; + +import org.hibernate.annotations.AccessType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)AccessType("field") +public class Furniture extends Woody { + @Id + @GeneratedValue + private Integer id; + + private String brand; + + @Transient + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand =3D brand; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + + @AccessType("property") + public long weight; + + public long getWeight() { + return weight + 1; + } + + public void setWeight(long weight) { + this.weight =3D weight + 1; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/access/Gardenshed.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Gardenshed.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Gardenshed.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,55 @@ +//$Id: Gardenshed.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.access; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Transient; + +import org.hibernate.annotations.AccessType; + +/** + * This is the opposite of the Furniture test, as this tries to override t= he class AccessType("property") with + * the property AccessType("field"). + * + * @author Dennis Fleurbaaij + * @since 2007-05-31 + */ +(a)Entity +(a)AccessType( "property" ) +public class Gardenshed + extends + Woody { + private Integer id; + private String brand; + public long floors; + + @Transient + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand =3D brand; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + // These 2 functions should not return in Hibernate, but the value should= come from the field "floors" + @AccessType( "field" ) + public long getFloors() { + return this.floors + 2; + } + + public void setFloors(long floors) { + this.floors =3D floors + 2; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/access/Thingy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Thingy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Thingy.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: Thingy.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.access; + +import javax.persistence.MappedSuperclass; +import javax.persistence.Transient; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Thingy { + private String god; + + @Transient + public String getGod() { + return god; + } + + public void setGod(String god) { + this.god =3D god; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/access/Woody.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Woody.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/access/Woody.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Woody.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.access; + +import javax.persistence.MappedSuperclass; + +import org.hibernate.annotations.AccessType; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +(a)AccessType("property") +public class Woody extends Thingy { + private String color; + private String name; + public boolean isAlive; //shouldn't be persistent + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color =3D color; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/any/AnyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/AnyTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/AnyTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,158 @@ +package org.hibernate.test.annotations.any; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +public class AnyTest extends TestCase { + + public void testDefaultAnyAssociation() { + Session s =3D openSession(); + Transaction t =3D s.beginTransaction(); + + PropertySet set1 =3D new PropertySet( "string" ); + Property property =3D new StringProperty( "name", "Alex" ); + set1.setSomeProperty( property ); + set1.addGeneratedProperty( property ); + s.save( set1 ); + + PropertySet set2 =3D new PropertySet( "integer" ); + property =3D new IntegerProperty( "age", 33 ); + set2.setSomeProperty( property ); + set2.addGeneratedProperty( property ); + s.save( set2 ); + + s.flush(); + s.clear(); + + Query q =3D s + .createQuery( "select s from PropertySet s where name =3D :name" ); + q.setString( "name", "string" ); + PropertySet result =3D (PropertySet) q.uniqueResult(); + + assertNotNull( result ); + assertNotNull( result.getSomeProperty() ); + assertTrue( result.getSomeProperty() instanceof StringProperty ); + assertEquals( "Alex", result.getSomeProperty().asString() ); + assertNotNull( result.getGeneralProperties() ); + assertEquals( 1, result.getGeneralProperties().size() ); + assertEquals( "Alex", result.getGeneralProperties().get( 0 ).asString() = ); + + q.setString( "name", "integer" ); + result =3D (PropertySet) q.uniqueResult(); + assertNotNull( result ); + assertNotNull( result.getSomeProperty() ); + assertTrue( result.getSomeProperty() instanceof IntegerProperty ); + assertEquals( "33", result.getSomeProperty().asString() ); + assertNotNull( result.getGeneralProperties() ); + assertEquals( 1, result.getGeneralProperties().size() ); + assertEquals( "33", result.getGeneralProperties().get( 0 ).asString() ); + + t.rollback(); + s.close(); + } + + public void testManyToAnyWithMap() throws Exception { + + Session s =3D openSession(); + Transaction t =3D s.beginTransaction(); + + PropertyMap map =3D new PropertyMap( "sample" ); + map.getProperties().put( "name", new StringProperty( "name", "Alex" ) ); + map.getProperties().put( "age", new IntegerProperty( "age", 33 ) ); + + s.save( map ); + + s.flush(); + s.clear(); + + Query q =3D s + .createQuery( "SELECT map FROM PropertyMap map WHERE map.name =3D :nam= e" ); + q.setString( "name", "sample" ); + PropertyMap actualMap =3D (PropertyMap) q.uniqueResult(); + + assertNotNull( actualMap ); + assertNotNull( actualMap.getProperties() ); + + Property property =3D actualMap.getProperties().get( "name" ); + assertNotNull( property ); + assertTrue( property instanceof StringProperty ); + assertEquals( "Alex", property.asString() ); + + property =3D actualMap.getProperties().get( "age" ); + assertNotNull( property ); + assertTrue( property instanceof IntegerProperty ); + assertEquals( "33", property.asString() ); + + t.rollback(); + s.close(); + + } + + public void testMetaDataUseWithManyToAny() throws Exception { + Session s =3D openSession(); + Transaction t =3D s.beginTransaction(); + + PropertyList list =3D new PropertyList( "sample" ); + StringProperty stringProperty =3D new StringProperty( "name", "Alex" ); + IntegerProperty integerProperty =3D new IntegerProperty( "age", 33 ); + LongProperty longProperty =3D new LongProperty( "distance", 121L ); + CharProperty charProp =3D new CharProperty( "Est", 'E' ); + + list.setSomeProperty( longProperty ); + + list.addGeneratedProperty( stringProperty ); + list.addGeneratedProperty( integerProperty ); + list.addGeneratedProperty( longProperty ); + list.addGeneratedProperty( charProp ); + + s.save( list ); + + s.flush(); + s.clear(); + + Query q =3D s + .createQuery( "SELECT list FROM PropertyList list WHERE list.name =3D = :name" ); + q.setString( "name", "sample" ); + PropertyList actualList =3D (PropertyList) q + .uniqueResult(); + + assertNotNull( actualList ); + assertNotNull( actualList.getGeneralProperties() ); + assertEquals( 4, actualList.getGeneralProperties().size() ); + + Property property =3D actualList.getSomeProperty(); + assertNotNull( property ); + assertTrue( property instanceof LongProperty ); + assertEquals( "121", property.asString() ); + + assertEquals( "Alex", actualList.getGeneralProperties().get( 0 ) + .asString() ); + assertEquals( "33", actualList.getGeneralProperties().get( 1 ).asString(= ) ); + assertEquals( "121", actualList.getGeneralProperties().get( 2 ).asString= () ); + assertEquals( "E", actualList.getGeneralProperties().get( 3 ).asString()= ); + + t.rollback(); + s.close(); + } + + @Override + protected Class[] getMappings() { + return new Class[] { + StringProperty.class, + IntegerProperty.class, + LongProperty.class, + PropertySet.class, + PropertyMap.class, + PropertyList.class, + CharProperty.class + }; + } + + protected String[] getAnnotatedPackages() { + return new String[] { + "org.hibernate.test.annotations.any" + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/any/CharProperty.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/CharProperty.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/CharProperty.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,57 @@ +package org.hibernate.test.annotations.any; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +(a)Entity +(a)Table( name =3D "char_property" ) +public class CharProperty implements Property { + private Integer id; + + private String name; + + private Character value; + + public CharProperty() { + super(); + } + + public CharProperty(String name, Character value) { + super(); + this.name =3D name; + this.value =3D value; + } + + public String asString() { + return Character.toString( value ); + } + + public String getName() { + return name; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Character getValue() { + return value; + } + + public void setValue(Character value) { + this.value =3D value; + } + + public void setName(String name) { + this.name =3D name; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/any/IntegerProperty.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/IntegerProperty.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/IntegerProperty.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,56 @@ +package org.hibernate.test.annotations.any; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +(a)Entity +(a)Table(name=3D"int_property") +public class IntegerProperty implements Property { + private Integer id; + private String name; + private Integer value; + = + public IntegerProperty() { + super(); + } + + public IntegerProperty(String name, Integer value) { + super(); + this.name =3D name; + this.value =3D value; + } + + public String asString() { + return Integer.toString(value); + } + + public String getName() { + return name; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Integer getValue() { + return value; + } + + public void setValue(Integer value) { + this.value =3D value; + } + + public void setName(String name) { + this.name =3D name; + } + + = +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/any/LongProperty.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/LongProperty.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/LongProperty.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,57 @@ +package org.hibernate.test.annotations.any; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +(a)Entity +(a)Table(name =3D "long_property") +public class LongProperty implements Property { + private Integer id; + + private String name; + + private Long value; + + public LongProperty() { + super(); + } + + public LongProperty(String name, Long value) { + super(); + this.name =3D name; + this.value =3D value; + } + + public String asString() { + return Long.toString(value); + } + + public String getName() { + return name; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Long getValue() { + return value; + } + + public void setValue(Long value) { + this.value =3D value; + } + + public void setName(String name) { + this.name =3D name; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/any/Property.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/Property.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/Property.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,7 @@ +package org.hibernate.test.annotations.any; + +public interface Property { + + public String getName(); + public String asString(); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/any/PropertyList.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/PropertyList.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/PropertyList.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,85 @@ +package org.hibernate.test.annotations.any; + +import java.util.ArrayList; +import java.util.List; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.JoinTable; +import javax.persistence.Column; +import javax.persistence.JoinColumn; + +import org.hibernate.annotations.ManyToAny; +import org.hibernate.annotations.Cascade; +import org.hibernate.annotations.IndexColumn; +import org.hibernate.annotations.Any; +import org.hibernate.annotations.CascadeType; + +(a)Entity +(a)Table( name =3D "property_list" ) +public class PropertyList { + private Integer id; + + private String name; + + private T someProperty; + + private List generalProperties =3D new ArrayList(); + + public PropertyList() { + super(); + } + + public PropertyList(String name) { + this.name =3D name; + } + + @ManyToAny( metaDef =3D "Property", metaColumn =3D @Column(name =3D "p= roperty_type") ) + @Cascade( { org.hibernate.annotations.CascadeType.ALL }) + @JoinTable(name =3D "list_properties", + joinColumns =3D @JoinColumn(name =3D "obj_id"), + inverseJoinColumns =3D @JoinColumn(name =3D "property_id") + ) + @IndexColumn(name =3D "prop_index") + public List getGeneralProperties() { + return generalProperties; + } + + public void setGeneralProperties(List generalProperties) { + this.generalProperties =3D generalProperties; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Any( metaDef =3D "Property", metaColumn =3D @Column(name =3D "propert= y_type") ) + @Cascade( CascadeType.ALL ) + @JoinColumn(name =3D "property_id") + public T getSomeProperty() { + return someProperty; + } + + public void setSomeProperty(T someProperty) { + this.someProperty =3D someProperty; + } + + public void addGeneratedProperty(T property) { + this.generalProperties.add( property ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/any/PropertyMap.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/PropertyMap.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/PropertyMap.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,74 @@ +package org.hibernate.test.annotations.any; + +import java.util.HashMap; +import java.util.Map; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Table; + +import org.hibernate.annotations.AnyMetaDef; +import org.hibernate.annotations.Cascade; +import org.hibernate.annotations.ManyToAny; +import org.hibernate.annotations.MapKey; +import org.hibernate.annotations.MetaValue; + +(a)Entity +(a)Table( name =3D "property_map" ) +public class PropertyMap { + private Integer id; + private String name; + + private Map properties =3D new HashMap(); + + public PropertyMap(String name) { + this.name =3D name; + } + + public PropertyMap() { + super(); + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToAny( metaColumn =3D @Column( name =3D "property_type" ) ) + @AnyMetaDef( + idType =3D "integer", metaType =3D "string", + metaValues =3D { + @MetaValue( value =3D "S", targetEntity =3D StringProperty.class ), + @MetaValue( value =3D "I", targetEntity =3D IntegerProperty.class ) } ) + @Cascade( org.hibernate.annotations.CascadeType.ALL ) + @JoinTable( + name =3D "map_properties", + joinColumns =3D @JoinColumn( name =3D "map_id" ), + inverseJoinColumns =3D @JoinColumn( name =3D "property_id" ) ) + @MapKey( columns =3D { @Column( name =3D "map_key" ) } ) + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties =3D properties; + } + + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/any/PropertySet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/PropertySet.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/PropertySet.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,90 @@ +package org.hibernate.test.annotations.any; + +import java.util.ArrayList; +import java.util.List; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Table; + +import org.hibernate.annotations.Any; +import org.hibernate.annotations.AnyMetaDef; +import org.hibernate.annotations.Cascade; +import org.hibernate.annotations.CascadeType; +import org.hibernate.annotations.ManyToAny; +import org.hibernate.annotations.MetaValue; + +(a)Entity +(a)Table( name =3D "property_set" ) +public class PropertySet { + private Integer id; + private String name; + private Property someProperty; + + private List generalProperties =3D new ArrayList(); + + public PropertySet() { + super(); + } + + public PropertySet(String name) { + this.name =3D name; + } + + @ManyToAny( + metaColumn =3D @Column( name =3D "property_type" ) ) + @AnyMetaDef( idType =3D "integer", metaType =3D "string", + metaValues =3D { + @MetaValue( value =3D "S", targetEntity =3D StringProperty.class ), + @MetaValue( value =3D "I", targetEntity =3D IntegerProperty.class ) } ) + @Cascade( { org.hibernate.annotations.CascadeType.ALL } ) + @JoinTable( name =3D "obj_properties", joinColumns =3D @JoinColumn( name = =3D "obj_id" ), + inverseJoinColumns =3D @JoinColumn( name =3D "property_id" ) ) + public List getGeneralProperties() { + return generalProperties; + } + + public void setGeneralProperties(List generalProperties) { + this.generalProperties =3D generalProperties; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Any( metaColumn =3D @Column( name =3D "property_type" ) ) + @Cascade( value =3D { CascadeType.ALL } ) + @AnyMetaDef( idType =3D "integer", metaType =3D "string", metaValues =3D { + @MetaValue( value =3D "S", targetEntity =3D StringProperty.class ), + @MetaValue( value =3D "I", targetEntity =3D IntegerProperty.class ) + } ) + @JoinColumn( name =3D "property_id" ) + public Property getSomeProperty() { + return someProperty; + } + + public void setSomeProperty(Property someProperty) { + this.someProperty =3D someProperty; + } + + public void addGeneratedProperty(Property property) { + this.generalProperties.add( property ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/any/StringProperty.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/StringProperty.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/StringProperty.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,54 @@ +package org.hibernate.test.annotations.any; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +(a)Entity +(a)Table(name=3D"string_property") +public class StringProperty implements Property { + private Integer id; + private String name; + private String value; + + public StringProperty() { + super(); + } + + public StringProperty(String name, String value) { + super(); + this.name =3D name; + this.value =3D value; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public String asString() { + return value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value =3D value; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/any/package-info.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/package-info.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/any/package-info.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,16 @@ +//$Id: +(a)AnyMetaDefs( + @AnyMetaDef( name=3D "Property", metaType =3D "string", idType =3D "inte= ger", + metaValues =3D { + @MetaValue(value =3D "C", targetEntity =3D CharProperty.class), + @MetaValue(value =3D "I", targetEntity =3D IntegerProperty.class), + @MetaValue(value =3D "S", targetEntity =3D StringProperty.class), + @MetaValue(value =3D "L", targetEntity =3D LongProperty.class) + }) +) + +package org.hibernate.test.annotations.any; + +import org.hibernate.annotations.AnyMetaDefs; +import org.hibernate.annotations.AnyMetaDef; +import org.hibernate.annotations.MetaValue; \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/array/ArrayTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/array/ArrayTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/array/ArrayTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,54 @@ +//$Id: ArrayTest.java 14956 2008-07-18 12:08:43Z hardy.ferentschik $ +package org.hibernate.test.annotations.array; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.array.Contest.Month; + +/** + * @author Emmanuel Bernard + */ +public class ArrayTest extends TestCase { + + public void testOneToMany() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Competitor c1 =3D new Competitor(); + c1.setName( "Renault" ); + Competitor c2 =3D new Competitor(); + c2.setName( "Ferrari" ); + Contest contest =3D new Contest(); + contest.setResults( new Competitor[]{c1, c2} ); + contest.setHeldIn(new Month[]{Month.January, Month.December}); + s.persist( contest ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + contest =3D (Contest) s.get( Contest.class, contest.getId() ); + assertNotNull( contest ); + assertNotNull( contest.getResults() ); + assertEquals( 2, contest.getResults().length ); + assertEquals( c2.getName(), contest.getResults()[1].getName() ); + assertEquals( 2, contest.getHeldIn().length ); + assertEquals( Month.January, contest.getHeldIn()[0] ); + tx.commit(); + s.close(); + } + + public ArrayTest(String x) { + super( x ); + } + + @SuppressWarnings("unchecked") + protected Class[] getMappings() { + return new Class[]{ + Competitor.class, + Contest.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/array/Competitor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/array/Competitor.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/array/Competitor.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Competitor.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.array; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Competitor { + private int id; + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Id + @GeneratedValue + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/array/Contest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/array/Contest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/array/Contest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,56 @@ +//$Id: Contest.java 14956 2008-07-18 12:08:43Z hardy.ferentschik $ +package org.hibernate.test.annotations.array; + + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.IndexColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Contest { + private int id; + private Competitor[] results; + private Month[] heldIn; + + @Id + @GeneratedValue + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + @OneToMany(cascade =3D CascadeType.ALL) + @IndexColumn(name =3D "pos") + public Competitor[] getResults() { + return results; + } + + public void setResults(Competitor[] results) { + this.results =3D results; + } + = + @CollectionOfElements + @IndexColumn(name =3D "pos", base=3D1) + public Month[] getHeldIn() { + return heldIn; + } + + public void setHeldIn(Month[] heldIn) { + this.heldIn =3D heldIn; + } + = + public enum Month { + January, February, March, April, May, June, July, August, September, Oct= ober, November, December; + }; = +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/backquotes/BackquoteTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/backquotes/BackquoteTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/backquotes/BackquoteTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,37 @@ +//$Id: BackquoteTest.java 14747 2008-06-06 08:16:25Z hardy.ferentschik $ +package org.hibernate.test.annotations.backquotes; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import junit.framework.TestCase; + +import org.hibernate.cfg.AnnotationConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Testcase for ANN-718 - @JoinTable / @JoinColumn fail when using backquo= tes in PK field name. + * = + * @author Hardy Ferentschik + * + */ +public class BackquoteTest extends TestCase { + = + private Logger log =3D LoggerFactory.getLogger(BackquoteTest.class); = + = + public void testBackquotes() { + try { + AnnotationConfiguration config =3D new AnnotationConfiguration(); + config.addAnnotatedClass(Bug.class); + config.addAnnotatedClass(Category.class); + config.buildSessionFactory(); + } + catch( Exception e ) { + StringWriter writer =3D new StringWriter(); + e.printStackTrace(new PrintWriter(writer)); + log.debug(writer.toString()); + fail(e.getMessage()); + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/backquotes/Bug.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/backquotes/Bug.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/backquotes/Bug.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,52 @@ +//$Id: Bug.java 14747 2008-06-06 08:16:25Z hardy.ferentschik $ +package org.hibernate.test.annotations.backquotes; + +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; + +import org.hibernate.annotations.Index; + +(a)Entity +public class Bug = +{ + @Id + @Column(name=3D"`bug_id`") + private int id; + = + @Column(name=3D"`title`") + @Index(name=3D"`titleindex`") + private String title; + = + @ManyToMany + @JoinTable(name=3D"`bug_category`") + private List categories; + + public List getCategories() { + return categories; + } + + public void setCategories(List categories) { + this.categories =3D categories; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title =3D title; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/backquotes/Category.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/backquotes/Category.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/backquotes/Category.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Category.java 14735 2008-06-04 14:05:50Z hardy.ferentschik $ +package org.hibernate.test.annotations.backquotes; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +(a)Entity +public class Category = +{ + @Id + @Column(name=3D"`cat_id`") + private int id; + = + @Column(name=3D"`title`") + private String title; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title =3D title; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/bytecode/Hammer.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/bytecode/Hammer.hbm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/bytecode/Hammer.hbm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/bytecode/Hammer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/bytecode/Hammer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/bytecode/Hammer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,21 @@ +//$Id: Hammer.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.bytecode; + +/** + * @author Emmanuel Bernard + */ +public class Hammer implements Tool { + private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public Integer usage() { + return 0; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/bytecode/ProxyBreakingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/bytecode/ProxyBreakingTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/bytecode/ProxyBreakingTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,52 @@ +//$Id: ProxyBreakingTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.test.annotations.bytecode; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.Hibernate; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.cfg.Configuration; + +/** + * @author Emmanuel Bernard + */ +public class ProxyBreakingTest extends TestCase { + + static { + System.setProperty( "hibernate.bytecode.provider", "javassist" ); + } + + public void testProxiedBridgeMethod() throws Exception { + //bridge methods should not be proxied + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Hammer h =3D new Hammer(); + s.save(h); + s.flush(); + s.clear(); + assertNotNull( "The proxy creation failure is breaking things", h.getId(= ) ); + h =3D (Hammer) s.load( Hammer.class, h.getId() ); + assertFalse( Hibernate.isInitialized( h ) ); + tx.rollback(); + s.close(); + } + + public ProxyBreakingTest(String name) { + super( name ); + } + + protected Class[] getMappings() { + return new Class[0]; + } + + protected String[] getXmlFiles() { + return new String[] { + "org/hibernate/test/annotations/bytecode/Hammer.hbm.xml" + }; + } + + @Override + protected void configure(Configuration cfg) { + super.configure( cfg.setProperty( "hibernate.bytecode.provider", "javass= ist" ) ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/bytecode/Tool.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/bytecode/Tool.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/bytecode/Tool.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,13 @@ +//$Id: Tool.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.bytecode; + +/** + * @author Emmanuel Bernard + */ +public interface Tool { + public Long getId(); + + public void setId(Long id); + + public Number usage(); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cascade/CascadeTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cascade/CascadeTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cascade/CascadeTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,115 @@ +//$Id: CascadeTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cascade; + +import java.util.ArrayList; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * Check some of the individual cascade styles + * + * @author Emmanuel Bernard + */ +//FIXME do somthing for refresh +public class CascadeTest extends TestCase { + public void testPersist() { + Session s; + Transaction tx; + s =3D openSession(); + Tooth tooth =3D new Tooth(); + Tooth leftTooth =3D new Tooth(); + tooth.leftNeighbour =3D leftTooth; + s.persist( tooth ); + tx =3D s.beginTransaction(); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + leftTooth =3D (Tooth) s.get( Tooth.class, leftTooth.id ); + assertNotNull( leftTooth ); + tx.commit(); + s.close(); + } + + public void testMerge() { + Session s; + Transaction tx; + s =3D openSession(); + Tooth tooth =3D new Tooth(); + Tooth rightTooth =3D new Tooth(); + tooth.type =3D "canine"; + tooth.rightNeighbour =3D rightTooth; + rightTooth.type =3D "incisive"; + s.persist( rightTooth ); + s.persist( tooth ); + tx =3D s.beginTransaction(); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + tooth =3D (Tooth) s.get( Tooth.class, tooth.id ); + assertEquals( "incisive", tooth.rightNeighbour.type ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + tooth.rightNeighbour.type =3D "premolars"; + s.merge( tooth ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + rightTooth =3D (Tooth) s.get( Tooth.class, rightTooth.id ); + assertEquals( "premolars", rightTooth.type ); + tx.commit(); + s.close(); + } + + public void testRemove() { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Tooth tooth =3D new Tooth(); + Mouth mouth =3D new Mouth(); + s.persist( mouth ); + s.persist( tooth ); + tooth.mouth =3D mouth; + mouth.teeth =3D new ArrayList(); + mouth.teeth.add( tooth ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + tooth =3D (Tooth) s.get( Tooth.class, tooth.id ); + assertNotNull( tooth ); + s.delete( tooth.mouth ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + tooth =3D (Tooth) s.get( Tooth.class, tooth.id ); + assertNull( tooth ); + tx.commit(); + s.close(); + } + + public CascadeTest(String x) { + super( x ); + } + + protected Class[] getMappings() { + return new Class[]{ + Mouth.class, + Tooth.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cascade/Mouth.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cascade/Mouth.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cascade/Mouth.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$Id: Mouth.java 15056 2008-08-13 18:15:05Z epbernard $ +package org.hibernate.test.annotations.cascade; + +import java.util.Collection; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Mouth { + @Id + @GeneratedValue + public Integer id; + @Column(name=3D"mouth_size") + public int size; + @OneToMany(mappedBy =3D "mouth", cascade =3D CascadeType.REMOVE) + public Collection teeth; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cascade/Tooth.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cascade/Tooth.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cascade/Tooth.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +//$Id: Tooth.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cascade; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Tooth { + @Id + @GeneratedValue + public Integer id; + public String type; + @ManyToOne(cascade =3D CascadeType.PERSIST) + public Tooth leftNeighbour; + @ManyToOne(cascade =3D CascadeType.MERGE) + public Tooth rightNeighbour; + @ManyToOne + public Mouth mouth; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/A.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/A.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/A.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: A.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import java.io.Serializable; + +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; + + +/** + * @author Artur Legan + * + */ +(a)Entity +public class A implements Serializable{ + + @EmbeddedId + private AId aId; + + public AId getAId() { + return aId; + } + + public void setAId(AId aId) { + this.aId =3D aId; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/AId.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/AId.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/AId.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,40 @@ +//$Id: AId.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import java.io.Serializable; +import javax.persistence.Embeddable; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; + + +/** + * @author Artur Legan + */ +(a)Embeddable +public class AId implements Serializable { + + @OneToOne + @JoinColumn( name =3D "bid" ) + private B b; + + @OneToOne + @JoinColumn( name =3D "cid" ) + private C c; + + + public B getB() { + return b; + } + + public void setB(B b) { + this.b =3D b; + } + + public C getC() { + return c; + } + + public void setC(C c) { + this.c =3D c; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/B.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/B.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/B.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: B.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + + +/** + * @author Artur Legan + */ +(a)Entity +public class B { + + @Id + @GeneratedValue + private Long id; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/C.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/C.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/C.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: C.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + + +/** + * @author Artur Legan + */ +(a)Entity +public class C { + + @Id + @GeneratedValue + private Long id; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/Channel.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Channel.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Channel.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,16 @@ +//$Id: Channel.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Channel { + @Id + @GeneratedValue + public Integer id; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/Child.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Child.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Child.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: Child.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +/** + * Entity having a many to one in its pk + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +public class Child { + @EmbeddedId + @AttributeOverride(name =3D "nthChild", column =3D @Column(name =3D "nth"= )) + public ChildPk id; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/ChildPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/ChildPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/ChildPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,43 @@ +//$Id: ChildPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import java.io.Serializable; +import javax.persistence.Embeddable; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; + +/** + * Child Pk with many to one inside + * + * @author Emmanuel Bernard + */ +(a)Embeddable +public class ChildPk implements Serializable { + public int nthChild; + @ManyToOne() + @JoinColumns({ + @JoinColumn(name =3D "parentLastName", referencedColumnName =3D "p_lname"= ), + @JoinColumn(name =3D "parentFirstName", referencedColumnName =3D "firstNa= me") + }) + public Parent parent; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof ChildPk ) ) return false; + + final ChildPk childPk =3D (ChildPk) o; + + if ( nthChild !=3D childPk.nthChild ) return false; + if ( !parent.equals( childPk.parent ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D nthChild; + result =3D 29 * result + parent.hashCode(); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/CompositeIdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/CompositeIdTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/CompositeIdTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,280 @@ +//$Id: CompositeIdTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import java.util.Date; +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * test some composite id functionalities + * + * @author Emmanuel Bernard + */ +public class CompositeIdTest extends TestCase { + public CompositeIdTest(String x) { + super( x ); + } + + public void testOneToOneInCompositePk() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + B b =3D new B(); + C c =3D new C(); + s.persist( b ); + s.persist( c ); + A a =3D new A(); + a.setAId( new AId() ); + a.getAId().setB( b ); + a.getAId().setC( c ); + s.persist( a ); + s.flush(); + s.clear(); + + a =3D (A) s.get(A.class, a.getAId() ); + assertEquals( b.getId(), a.getAId().getB().getId() ); + + tx.rollback(); + s.close(); + } + + + /** + * This feature is not supported by the EJB3 + * this is an hibernate extension + */ + public void testManyToOneInCompositePk() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + ParentPk ppk =3D new ParentPk(); + ppk.setFirstName( "Emmanuel" ); + ppk.setLastName( "Bernard" ); + Parent p =3D new Parent(); + p.id =3D ppk; + s.persist( p ); + ChildPk cpk =3D new ChildPk(); + cpk.parent =3D p; + cpk.nthChild =3D 1; + Child c =3D new Child(); + c.id =3D cpk; + s.persist( c ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "select c from Child c where c.id.nthChild = =3D :nth" ); + q.setInteger( "nth", 1 ); + List results =3D q.list(); + assertEquals( 1, results.size() ); + c =3D (Child) results.get( 0 ); + assertNotNull( c ); + assertNotNull( c.id.parent ); + //FIXME mke it work in unambigious cases + // assertNotNull(c.id.parent.id); + // assertEquals(p.id.getFirstName(), c.id.parent.id.getFirstName()); + s.delete( c ); + s.delete( c.id.parent ); + tx.commit(); + s.close(); + } + + /** + * This feature is not supported by the EJB3 + * this is an hibernate extension + */ + public void testManyToOneInCompositePkAndSubclass() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + ParentPk ppk =3D new ParentPk(); + ppk.setFirstName( "Emmanuel" ); + ppk.setLastName( "Bernard" ); + Parent p =3D new Parent(); + p.id =3D ppk; + s.persist( p ); + ChildPk cpk =3D new ChildPk(); + cpk.parent =3D p; + cpk.nthChild =3D 1; + LittleGenius c =3D new LittleGenius(); + c.particularSkill =3D "Human Annotation parser"; + c.id =3D cpk; + s.persist( c ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "select c from Child c where c.id.nthChild = =3D :nth" ); + q.setInteger( "nth", 1 ); + List results =3D q.list(); + assertEquals( 1, results.size() ); + c =3D (LittleGenius) results.get( 0 ); + assertNotNull( c ); + assertNotNull( c.id.parent ); + //FIXME mke it work in unambigious cases +// assertNotNull(c.id.parent.id); +// assertEquals(p.id.getFirstName(), c.id.parent.id.getFirstName()); + s.delete( c ); + s.delete( c.id.parent ); + tx.commit(); + s.close(); + } + + public void testManyToOneInCompositeId() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Channel channel =3D new Channel(); + s.persist( channel ); + Presenter pres =3D new Presenter(); + pres.name =3D "Casimir"; + s.persist( pres ); + TvMagazinPk pk =3D new TvMagazinPk(); + TvMagazin mag =3D new TvMagazin(); + mag.time =3D new Date(); + mag.id =3D pk; + //pk.name =3D "Trax"; + pk.channel =3D channel; + pk.presenter =3D pres; + s.persist( mag ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + mag =3D (TvMagazin) s.createQuery( "from TvMagazin mag" ) // where mag.i= d.name =3D :name") + //.setParameter( "name", "Trax" ) + .uniqueResult(); + assertNotNull( mag.id ); + assertNotNull( mag.id.channel ); + assertEquals( channel.id, mag.id.channel.id ); + assertNotNull( mag.id.presenter ); + assertEquals( pres.name, mag.id.presenter.name ); + s.delete( mag ); + s.delete( mag.id.channel ); + s.delete( mag.id.presenter ); + tx.commit(); + s.close(); + } + + public void testManyToOneInCompositeIdClass() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Order order =3D new Order(); + s.persist( order ); + Product product =3D new Product(); + product.name =3D "small car"; + s.persist( product ); + OrderLinePk pk =3D new OrderLinePk(); + OrderLine orderLine =3D new OrderLine(); + orderLine.order =3D order; + orderLine.product =3D product; + s.persist( orderLine ); + s.flush(); + s.clear(); + + orderLine =3D (OrderLine) s.createQuery( "select ol from OrderLine ol" )= .uniqueResult(); + assertNotNull( orderLine.order ); + assertEquals( order.id, orderLine.order.id ); + assertNotNull( orderLine.product ); + assertEquals( product.name, orderLine.product.name ); + + tx.rollback(); + s.close(); + } + + public void testSecondaryTableWithCompositeId() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Channel channel =3D new Channel(); + s.persist( channel ); + Presenter pres =3D new Presenter(); + pres.name =3D "Tim Russet"; + s.persist( pres ); + TvMagazinPk pk =3D new TvMagazinPk(); + TvProgram program =3D new TvProgram(); + program.time =3D new Date(); + program.id =3D pk; + program.text =3D "Award Winning Programming"; + //pk.name =3D "Trax"; + pk.channel =3D channel; + pk.presenter =3D pres; + s.persist( program ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + program =3D (TvProgram) s.createQuery( "from TvProgram pr" ) // where ma= g.id.name =3D :name") + //.setParameter( "name", "Trax" ) + .uniqueResult(); + assertNotNull( program.id ); + assertNotNull( program.id.channel ); + assertEquals( channel.id, program.id.channel.id ); + assertNotNull( program.id.presenter ); + assertNotNull( program.text ); + assertEquals( pres.name, program.id.presenter.name ); + s.delete( program ); + s.delete( program.id.channel ); + s.delete( program.id.presenter ); + tx.commit(); + s.close(); + } + + public void testSecondaryTableWithIdClass() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Channel channel =3D new Channel(); + s.persist( channel ); + Presenter pres =3D new Presenter(); + pres.name =3D "Bob"; + s.persist( pres ); + TvProgramIdClass program =3D new TvProgramIdClass(); + program.time =3D new Date(); + program.channel =3D channel; + program.presenter =3D pres; + program.text =3D "Jump the shark programming"; + //pk.name =3D "Trax"; + s.persist( program ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + program =3D (TvProgramIdClass) s.createQuery( "from TvProgramIdClass pr"= ) // where mag.id.name =3D :name") + //.setParameter( "name", "Trax" ) + .uniqueResult(); + assertNotNull( program.channel ); + assertEquals( channel.id, program.channel.id ); + assertNotNull( program.presenter ); + assertNotNull( program.text ); + assertEquals( pres.name, program.presenter.name ); + s.delete( program ); + s.delete( program.channel ); + s.delete( program.presenter ); + tx.commit(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { + Parent.class, + Child.class, + Channel.class, + TvMagazin.class, + TvProgramIdClass.class, + TvProgram.class, + Presenter.class, + Order.class, + Product.class, + OrderLine.class, + OrderLinePk.class, + LittleGenius.class, + A.class, + B.class, + C.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/LittleGenius.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/LittleGenius.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/LittleGenius.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,19 @@ +package org.hibernate.test.annotations.cid; + +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.PrimaryKeyJoinColumns; + +/** + * Hierarchy with cid + many to one + * @author Anthony + * + */ +(a)Entity +(a)PrimaryKeyJoinColumns({ +(a)PrimaryKeyJoinColumn(name =3D "nthChild"), +(a)PrimaryKeyJoinColumn(name =3D "parentLastName"), +(a)PrimaryKeyJoinColumn(name =3D "parentFirstName")}) +public class LittleGenius extends Child { + public String particularSkill; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/Order.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Order.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Order.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,17 @@ +package org.hibernate.test.annotations.cid; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "OrderTableFoobar") +public class Order { + @Id + @GeneratedValue + public Integer id; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/OrderLine.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/OrderLine.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/OrderLine.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,17 @@ +package org.hibernate.test.annotations.cid; + +import javax.persistence.Entity; +import javax.persistence.IdClass; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)IdClass(OrderLinePk.class) +public class OrderLine { + @Id + public Order order; + @Id + public Product product; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/OrderLinePk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/OrderLinePk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/OrderLinePk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,18 @@ +package org.hibernate.test.annotations.cid; + + +import javax.persistence.ManyToOne; +import javax.persistence.JoinColumn; +import java.io.Serializable; + +/** + * @author Emmanuel Bernard + */ +public class OrderLinePk implements Serializable { + @ManyToOne + @JoinColumn(name =3D "foo", nullable =3D false) + public Order order; + @ManyToOne + @JoinColumn(name =3D "bar", nullable =3D false) + public Product product; = +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/Parent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Parent.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Parent.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +//$Id: Parent.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; + +/** + * Entity with composite id + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Parent { + @EmbeddedId + public ParentPk id; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Parent ) ) return false; + + final Parent parent =3D (Parent) o; + + if ( !id.equals( parent.id ) ) return false; + + return true; + } + + public int hashCode() { + return id.hashCode(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/ParentPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/ParentPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/ParentPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,52 @@ +//$Id: ParentPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import java.io.Serializable; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ + +public class ParentPk implements Serializable { + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName =3D firstName; + } + + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName =3D lastName; + } + + + private String firstName; + @Column(name =3D "p_lname") + private String lastName; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof ParentPk ) ) return false; + + final ParentPk parentPk =3D (ParentPk) o; + + if ( !firstName.equals( parentPk.firstName ) ) return false; + if ( !lastName.equals( parentPk.lastName ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D firstName.hashCode(); + result =3D 29 * result + lastName.hashCode(); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/Presenter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Presenter.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Presenter.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,14 @@ +//$Id: Presenter.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Presenter { + @Id + public String name; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/Product.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Product.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/Product.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,13 @@ +package org.hibernate.test.annotations.cid; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Product { + @Id + public String name; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/TvMagazin.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/TvMagazin.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/TvMagazin.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: TvMagazin.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import java.util.Date; +import javax.persistence.AssociationOverride; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)AssociationOverride(name =3D "id.channel", joinColumns =3D @JoinColumn(= name =3D "chan_id")) +public class TvMagazin { + @EmbeddedId + public TvMagazinPk id; + @Temporal(TemporalType.TIME) + Date time; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/TvMagazinPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/TvMagazinPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/TvMagazinPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,18 @@ +//$Id: TvMagazinPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import java.io.Serializable; +import javax.persistence.Embeddable; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class TvMagazinPk implements Serializable { + @ManyToOne + public Channel channel; + //public String name; + @ManyToOne + public Presenter presenter; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/TvProgram.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/TvProgram.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/TvProgram.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +//$Id: TvProgram.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import java.util.Date; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.SecondaryTable; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +/** + * @author Chandra Patni + */ +(a)Entity +(a)SecondaryTable( name =3D "TV_PROGRAM_EXT", pkJoinColumns =3D { +(a)PrimaryKeyJoinColumn( name =3D "CHANNEL_ID" ), +(a)PrimaryKeyJoinColumn( name =3D "PRESENTER_NAME" ) + } ) +public class TvProgram { + @EmbeddedId + public TvMagazinPk id; + + @Temporal( TemporalType.TIME ) + Date time; + + @Column( name =3D "TXT", table =3D "TV_PROGRAM_EXT" ) + public String text; + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/cid/TvProgramIdClass.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/TvProgramIdClass.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/cid/TvProgramIdClass.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: TvProgramIdClass.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.cid; + +import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.SecondaryTable; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +(a)Entity +(a)SecondaryTable( name =3D "TV_PROGRAM_IDCLASS", pkJoinColumns =3D + { + @PrimaryKeyJoinColumn( name =3D "CHANNEL_ID" ), + @PrimaryKeyJoinColumn( name =3D "PRESENTER_NAME" ) + } ) +(a)IdClass( TvMagazinPk.class ) +public class TvProgramIdClass { + @Id + public Channel channel; + @Id + public Presenter presenter; + + @Temporal( TemporalType.TIME ) + Date time; + + @Column( name =3D "TXT", table =3D "TV_PROGRAM_IDCLASS" ) + public String text; +} + + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/Boy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/Boy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/Boy.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,134 @@ +//$Id: Boy.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.collectionelement; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; + +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.IndexColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)AttributeOverrides({ + @AttributeOverride( name=3D"characters.element", column =3D @Column(name= =3D"fld_character") ), + @AttributeOverride( name=3D"scorePerNickName.element", column =3D @Colum= n(name=3D"fld_score") ), + @AttributeOverride( name=3D"favoriteToys.element.brand.surname", column = =3D @Column(name =3D "fld_surname"))} +) +public class Boy { + private Integer id; + private String firstName; + private String lastName; + private Set nickNames =3D new HashSet(); + private Map scorePerNickName =3D new HashMap(); + private int[] favoriteNumbers; + private Set favoriteToys =3D new HashSet(); + private Set characters =3D new HashSet(); + private Set countryAttitudes =3D new HashSet(); + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName =3D firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName =3D lastName; + } + + @CollectionOfElements + public Set getNickNames() { + return nickNames; + } + + public void setNickNames(Set nickName) { + this.nickNames =3D nickName; + } + + @CollectionOfElements + @JoinTable(name =3D "ScorePerNickName", joinColumns =3D @JoinColumn(name = =3D "BoyId")) + @Column(name =3D "score", nullable =3D false) + public Map getScorePerNickName() { + return scorePerNickName; + } + + public void setScorePerNickName(Map scorePerNickName) { + this.scorePerNickName =3D scorePerNickName; + } + + @CollectionOfElements + @JoinTable( + name =3D "BoyFavoriteNumbers", + joinColumns =3D @JoinColumn(name =3D "BoyId") + ) + @Column(name =3D "favoriteNumber", nullable =3D false) + @IndexColumn(name =3D "nbr_index") + public int[] getFavoriteNumbers() { + return favoriteNumbers; + } + + public void setFavoriteNumbers(int[] favoriteNumbers) { + this.favoriteNumbers =3D favoriteNumbers; + } + + @CollectionOfElements + @AttributeOverride(name =3D "element.serial", column =3D @Column(name =3D= "serial_nbr")) + public Set getFavoriteToys() { + return favoriteToys; + } + + public void setFavoriteToys(Set favoriteToys) { + this.favoriteToys =3D favoriteToys; + } + + @CollectionOfElements + @Enumerated(EnumType.STRING) + public Set getCharacters() { + return characters; + } + + public void setCharacters(Set characters) { + this.characters =3D characters; + } + + @CollectionOfElements(fetch =3D FetchType.EAGER) + //@Where(clause =3D "b_likes=3Dfalse") + public Set getCountryAttitudes() { + return countryAttitudes; + } + + public void setCountryAttitudes(Set countryAttitudes) { + this.countryAttitudes =3D countryAttitudes; + } +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/Brand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/Brand.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/Brand.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,44 @@ +//$Id: Brand.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.collectionelement; + +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class Brand { + private String name; + private String surname; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getSurname() { + return surname; + } + + public void setSurname(String surname) { + this.surname =3D surname; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final Brand brand =3D (Brand) o; + + if ( !name.equals( brand.name ) ) return false; + + return true; + } + + public int hashCode() { + return name.hashCode(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/Character.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/Character.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/Character.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,13 @@ +package org.hibernate.test.annotations.collectionelement; + +/** + * @author Emmanuel Bernard + */ +public enum Character { + GENTLE, + NORMAL, + AGGRESSIVE, + ATTENTIVE, + VIOLENT, + CRAFTY +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/CollectionElementTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/CollectionElementTest.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/CollectionElementTest.java 2009-11-24 21:03:15 UT= C (rev 18049) @@ -0,0 +1,213 @@ +//$Id: CollectionElementTest.java 14754 2008-06-09 15:57:07Z hardy.ferents= chik $ +package org.hibernate.test.annotations.collectionelement; + +import java.util.List; +import java.util.Locale; + +import org.hibernate.Filter; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.Country; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + * @author Hardy Ferentschik + */ +(a)SuppressWarnings("unchecked") +public class CollectionElementTest extends TestCase { + = + public void testSimpleElement() throws Exception { + assertEquals( + "BoyFavoriteNumbers", + getCfg().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNu= mbers" ) + .getCollectionTable().getName() + ); + Session s =3D openSession(); + s.getTransaction().begin(); + Boy boy =3D new Boy(); + boy.setFirstName( "John" ); + boy.setLastName( "Doe" ); + boy.getNickNames().add( "Johnny" ); + boy.getNickNames().add( "Thing" ); + boy.getScorePerNickName().put( "Johnny", new Integer( 3 ) ); + boy.getScorePerNickName().put( "Thing", new Integer( 5 ) ); + int[] favNbrs =3D new int[4]; + for (int index =3D 0; index < favNbrs.length - 1; index++) { + favNbrs[index] =3D index * 3; + } + boy.setFavoriteNumbers( favNbrs ); + boy.getCharacters().add( Character.GENTLE ); + boy.getCharacters().add( Character.CRAFTY ); + s.persist( boy ); + s.getTransaction().commit(); + s.clear(); + Transaction tx =3D s.beginTransaction(); + boy =3D (Boy) s.get( Boy.class, boy.getId() ); + assertNotNull( boy.getNickNames() ); + assertTrue( boy.getNickNames().contains( "Thing" ) ); + assertNotNull( boy.getScorePerNickName() ); + assertTrue( boy.getScorePerNickName().containsKey( "Thing" ) ); + assertEquals( new Integer( 5 ), boy.getScorePerNickName().get( "Thing" )= ); + assertNotNull( boy.getFavoriteNumbers() ); + assertEquals( 3, boy.getFavoriteNumbers()[1] ); + assertTrue( boy.getCharacters().contains( Character.CRAFTY ) ); + List result =3D s.createQuery( "select boy from Boy boy join boy.nickNam= es names where names =3D :name" ) + .setParameter( "name", "Thing" ).list(); + assertEquals( 1, result.size() ); + s.delete( boy ); + tx.commit(); + s.close(); + } + + public void testCompositeElement() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Boy boy =3D new Boy(); + boy.setFirstName( "John" ); + boy.setLastName( "Doe" ); + Toy toy =3D new Toy(); + toy.setName( "Balloon" ); + toy.setSerial( "serial001" ); + toy.setBrand( new Brand() ); + toy.getBrand().setName( "Bandai" ); + boy.getFavoriteToys().add( toy ); + s.persist( boy ); + s.getTransaction().commit(); + s.clear(); + Transaction tx =3D s.beginTransaction(); + boy =3D (Boy) s.get( Boy.class, boy.getId() ); + assertNotNull( boy.getFavoriteToys() ); + assertTrue( boy.getFavoriteToys().contains( toy ) ); + assertEquals( "@Parent is failing", boy, boy.getFavoriteToys().iterator(= ).next().getOwner() ); + s.delete( boy ); + tx.commit(); + s.close(); + } + + public void testAttributedJoin() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Country country =3D new Country(); + country.setName( "Australia" ); + s.persist( country ); + + Boy boy =3D new Boy(); + boy.setFirstName( "John" ); + boy.setLastName( "Doe" ); + CountryAttitude attitude =3D new CountryAttitude(); + // TODO: doesn't work + attitude.setBoy( boy ); + attitude.setCountry( country ); + attitude.setLikes( true ); + boy.getCountryAttitudes().add( attitude ); + s.persist( boy ); + s.getTransaction().commit(); + s.clear(); + + Transaction tx =3D s.beginTransaction(); + boy =3D (Boy) s.get( Boy.class, boy.getId() ); + assertTrue( boy.getCountryAttitudes().contains( attitude ) ); + s.delete( boy ); + s.delete( s.get( Country.class, country.getId() ) ); + tx.commit(); + s.close(); + + } + + public void testLazyCollectionofElements() throws Exception { + assertEquals( + "BoyFavoriteNumbers", + getCfg().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNu= mbers" ) + .getCollectionTable().getName() + ); + Session s =3D openSession(); + s.getTransaction().begin(); + Boy boy =3D new Boy(); + boy.setFirstName( "John" ); + boy.setLastName( "Doe" ); + boy.getNickNames().add( "Johnny" ); + boy.getNickNames().add( "Thing" ); + boy.getScorePerNickName().put( "Johnny", new Integer( 3 ) ); + boy.getScorePerNickName().put( "Thing", new Integer( 5 ) ); + int[] favNbrs =3D new int[4]; + for (int index =3D 0; index < favNbrs.length - 1; index++) { + favNbrs[index] =3D index * 3; + } + boy.setFavoriteNumbers( favNbrs ); + boy.getCharacters().add( Character.GENTLE ); + boy.getCharacters().add( Character.CRAFTY ); + s.persist( boy ); + s.getTransaction().commit(); + s.clear(); + Transaction tx =3D s.beginTransaction(); + boy =3D (Boy) s.get( Boy.class, boy.getId() ); + assertNotNull( boy.getNickNames() ); + assertTrue( boy.getNickNames().contains( "Thing" ) ); + assertNotNull( boy.getScorePerNickName() ); + assertTrue( boy.getScorePerNickName().containsKey( "Thing" ) ); + assertEquals( new Integer( 5 ), boy.getScorePerNickName().get( "Thing" )= ); + assertNotNull( boy.getFavoriteNumbers() ); + assertEquals( 3, boy.getFavoriteNumbers()[1] ); + assertTrue( boy.getCharacters().contains( Character.CRAFTY ) ); + List result =3D s.createQuery( "select boy from Boy boy join boy.nickNam= es names where names =3D :name" ) + .setParameter( "name", "Thing" ).list(); + assertEquals( 1, result.size() ); + s.delete( boy ); + tx.commit(); + s.close(); + } + + public void testFetchEagerAndFilter() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + + TestCourse test =3D new TestCourse(); + + LocalizedString title =3D new LocalizedString( "title in english" ); + title.getVariations().put( Locale.FRENCH.getLanguage(), "title en franca= is" ); + test.setTitle( title ); + s.save( test ); + + s.flush(); + s.clear(); + + Filter filter =3D s.enableFilter( "selectedLocale" ); + filter.setParameter( "param", "fr" ); + + Query q =3D s.createQuery( "from TestCourse t" ); + List l =3D q.list(); + assertEquals( 1, l.size() ); + + TestCourse t =3D (TestCourse) s.get( TestCourse.class, test.getTestCours= eId() ); + assertEquals( 1, t.getTitle().getVariations().size() ); + + tx.rollback(); + + s.close(); + } + + public void testMapKeyType() throws Exception { + Matrix m =3D new Matrix(); + m.getValues().put( 1, 1.1f ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist( m ); + s.flush(); + s.clear(); + m =3D (Matrix) s.get( Matrix.class, m.getId() ); + assertEquals( 1.1f, m.getValues().get( 1 ) ); + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { + Boy.class, + Country.class, + TestCourse.class, + Matrix.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/CountryAttitude.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/CountryAttitude.java (rev= 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/CountryAttitude.java 2009-11-24 21:03:15 UTC (rev= 18049) @@ -0,0 +1,59 @@ +//$Id: CountryAttitude.java 14754 2008-06-09 15:57:07Z hardy.ferentschik $ +package org.hibernate.test.annotations.collectionelement; + +import javax.persistence.Column; +import javax.persistence.Embeddable; +import javax.persistence.ManyToOne; + +import org.hibernate.test.annotations.Country; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class CountryAttitude { + private Boy boy; + private Country country; + private boolean likes; + + // TODO: This currently does not work +// @ManyToOne(optional =3D false) +// public Boy getBoy() { +// return boy; +// } + + public void setBoy(Boy boy) { + this.boy =3D boy; + } + + @ManyToOne(optional =3D false) + public Country getCountry() { + return country; + } + + public void setCountry(Country country) { + this.country =3D country; + } + + @Column(name =3D "b_likes") + public boolean isLikes() { + return likes; + } + + public void setLikes(boolean likes) { + this.likes =3D likes; + } + + @Override + public int hashCode() { + return country.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if ( !( obj instanceof CountryAttitude ) ) { + return false; + } + return country.equals( ( (CountryAttitude) obj ).country ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/LocalizedString.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/LocalizedString.java (rev= 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/LocalizedString.java 2009-11-24 21:03:15 UTC (rev= 18049) @@ -0,0 +1,47 @@ +//$Id: LocalizedString.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.collectionelement; + +import java.util.HashMap; +import java.util.Map; +import java.util.Locale; +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Embeddable; + +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.MapKey; +import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.Filter; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class LocalizedString implements Serializable { + + private static final Locale DEFAULT_LOCALE =3D Locale.ENGLISH; + + public LocalizedString() { + } + + public LocalizedString(String string) { + this.getVariations().put( DEFAULT_LOCALE.getLanguage(), string ); + } + + private Map variations =3D + new HashMap( 1 ); + + @CollectionOfElements + @MapKey( columns =3D @Column( name =3D "language_code" ) ) + @Fetch( FetchMode.JOIN ) + @Filter( name =3D "selectedLocale", + condition =3D " language_code =3D :param " ) + public Map getVariations() { + return variations; + } + + public void setVariations(Map variations) { + this.variations =3D variations; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/Matrix.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/Matrix.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/Matrix.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,48 @@ +//$ +package org.hibernate.test.annotations.collectionelement; + +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.MapKey; +import org.hibernate.annotations.Sort; +import org.hibernate.annotations.SortType; +import org.hibernate.annotations.Type; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Matrix { + @Id + @GeneratedValue + private Integer id; + = + @MapKey(type =3D @Type(type=3D"integer") ) + @CollectionOfElements + @Sort(type =3D SortType.NATURAL) = + @Type(type =3D "float") + private SortedMap values =3D new TreeMap(= ); + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Map getValues() { + return values; + } + + public void setValues(SortedMap values) { + this.values =3D values; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/TestCourse.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/TestCourse.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/TestCourse.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,42 @@ +//$Id: TestCourse.java 14754 2008-06-09 15:57:07Z hardy.ferentschik $ +package org.hibernate.test.annotations.collectionelement; + +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.ParamDef; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)FilterDef(name=3D"selectedLocale", parameters=3D{ @ParamDef( name=3D"pa= ram", type=3D"string" ) } ) +public class TestCourse { + + private Long testCourseId; + + private LocalizedString title; + + @Id + @GeneratedValue(strategy =3D GenerationType.AUTO) + public Long getTestCourseId() { + return testCourseId; + } + + public void setTestCourseId(Long testCourseId) { + this.testCourseId =3D testCourseId; + } + + @Embedded + public LocalizedString getTitle() { + return title; + } + + public void setTitle(LocalizedString title) { + this.title =3D title; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/Toy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/Toy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/Toy.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,73 @@ +//$Id: Toy.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.collectionelement; + +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.Embeddable; + +import org.hibernate.annotations.Parent; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class Toy { + private String name; + private Brand brand; + private String serial; + private Boy owner; + + @AttributeOverride(name =3D "name", column =3D @Column(name =3D "brand_na= me")) + public Brand getBrand() { + return brand; + } + + public void setBrand(Brand brand) { + this.brand =3D brand; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getSerial() { + return serial; + } + + public void setSerial(String serial) { + this.serial =3D serial; + } + + @Parent + public Boy getOwner() { + return owner; + } + + public void setOwner(Boy owner) { + this.owner =3D owner; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final Toy toy =3D (Toy) o; + + if ( !brand.equals( toy.brand ) ) return false; + if ( !name.equals( toy.name ) ) return false; + if ( !serial.equals( toy.serial ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D name.hashCode(); + result =3D 29 * result + brand.hashCode(); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/deepcollectionelements/A.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/deepcollectionelements/A.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/deepcollectionelements/A.java 2009-11-24 21:03:15= UTC (rev 18049) @@ -0,0 +1,45 @@ +//$ +package org.hibernate.test.annotations.collectionelement.deepcollectionele= ments; + +/** + * @author Emmanuel Bernard + */ + +import java.util.List; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; + +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.IndexColumn; + +(a)Entity +(a)Table( name =3D "A" ) +public class A { + @Id + @GeneratedValue( strategy =3D GenerationType.SEQUENCE, generator =3D "aSe= quence" ) + @SequenceGenerator( name =3D "aSequence", sequenceName =3D "seq_A" ) + private int id; + @CollectionOfElements + @IndexColumn( name =3D "ndx" ) + private List listOfB; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + public List getListOfB() { + return listOfB; + } + + public void setListOfB(List listOfB) { + this.listOfB =3D listOfB; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/deepcollectionelements/B.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/deepcollectionelements/B.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/deepcollectionelements/B.java 2009-11-24 21:03:15= UTC (rev 18049) @@ -0,0 +1,36 @@ +//$ +package org.hibernate.test.annotations.collectionelement.deepcollectionele= ments; + +import java.util.List; +import javax.persistence.Embeddable; +import javax.persistence.Transient; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.IndexColumn; + +(a)Embeddable +public class B { + private String name; + + //@CollectionOfElements + @OneToMany + @IndexColumn( name =3D "ndx" ) + private List listOfC; + + public List getListOfC() { + return listOfC; + } + + public void setListOfC(List listOfC) { + this.listOfC =3D listOfC; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/deepcollectionelements/C.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/deepcollectionelements/C.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/deepcollectionelements/C.java 2009-11-24 21:03:15= UTC (rev 18049) @@ -0,0 +1,27 @@ +//$ +package org.hibernate.test.annotations.collectionelement.deepcollectionele= ments; + +import javax.persistence.Column; +import javax.persistence.Embeddable; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.Entity; + + +(a)Entity +public class C { + @Id + @GeneratedValue + private int id; + + @Column( length =3D 500 ) + private String comment; + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment =3D comment; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/deepcollectionelements/DeepCollectionElementTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/deepcollectionelements/DeepCollectionElementTest.= java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/deepcollectionelements/DeepCollectionElementTest.= java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +//$ +package org.hibernate.test.annotations.collectionelement.deepcollectionele= ments; + +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ + +//TEST not used: wait for ANN-591 and HHH-3157 = +public class DeepCollectionElementTest extends TestCase { + + public void testInitialization() throws Exception { + //test only the SF creation + + } + + protected Class[] getMappings() { + return new Class[] { + //A.class, + //B.class, + //C.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/indexedCollection/Contact.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/indexedCollection/Contact.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/indexedCollection/Contact.java 2009-11-24 21:03:1= 5 UTC (rev 18049) @@ -0,0 +1,20 @@ +//$ +package org.hibernate.test.annotations.collectionelement.indexedCollection; + +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class Contact { + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/indexedCollection/IndexedCollectionOfElementsT= est.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/indexedCollection/IndexedCollectionOfElementsTest= .java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/indexedCollection/IndexedCollectionOfElementsTest= .java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,32 @@ +//$ +package org.hibernate.test.annotations.collectionelement.indexedCollection; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; + +/** + * @author Emmanuel Bernard + */ +public class IndexedCollectionOfElementsTest extends TestCase { + + public void testIndexedCollectionOfElements() throws Exception { + Sale sale =3D new Sale(); + Contact contact =3D new Contact(); + contact.setName( "Emmanuel" ); + sale.getContacts().add(contact); + Session s =3D openSession( ); + s.getTransaction().begin(); + s.save( sale ); + s.flush(); + s.get( Sale.class, sale.getId() ); + assertEquals( 1, sale.getContacts().size() ); + s.getTransaction().rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { + Sale.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/collectionelement/indexedCollection/Sale.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/indexedCollection/Sale.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/collectionelement/indexedCollection/Sale.java 2009-11-24 21:03:15 U= TC (rev 18049) @@ -0,0 +1,51 @@ +//$ +package org.hibernate.test.annotations.collectionelement.indexedCollection; + +import java.util.List; +import java.util.ArrayList; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Column; + +import org.hibernate.annotations.Type; +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.CollectionId; +import org.hibernate.annotations.GenericGenerator; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)GenericGenerator(name=3D"increment", strategy =3D "increment") +public class Sale { + @Id @GeneratedValue private Integer id; + + @CollectionOfElements + @JoinTable( + name =3D "contact", + joinColumns =3D @JoinColumn(name =3D "n_key_person")) + @CollectionId( + columns =3D @Column(name =3D "n_key_contact"), + type =3D @Type(type =3D "long"), + generator =3D "increment" ) = + private List contacts =3D new ArrayList(); + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public List getContacts() { + return contacts; + } + + public void setContacts(List contacts) { + this.contacts =3D contacts; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/configuration/ConfigurationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/configuration/ConfigurationTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/configuration/ConfigurationTest.java 2009-11-24 21:03:15 UTC (rev 1= 8049) @@ -0,0 +1,21 @@ +//$Id: ConfigurationTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.test.annotations.configuration; + +import junit.framework.TestCase; +import org.hibernate.cfg.AnnotationConfiguration; + +/** + * @author Emmanuel Bernard + */ +public class ConfigurationTest extends TestCase { + public void testMixPackageAndResourceOrdering() throws Exception { + try { + AnnotationConfiguration config =3D new AnnotationConfiguration(); + config.addResource( "org/hibernate/test/annotations/configuration/orm.x= ml" ); + config.addPackage( "org.hibernate.test.annotations.configuration" ); + } + catch( Exception e ) { + fail("Processing package first when ORM.xml is used should not fail"); + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/configuration/orm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/configuration/orm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/configuration/orm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,7 @@ + + + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/configuration/package-info.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/configuration/package-info.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/configuration/package-info.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,4 @@ +(a)GenericGenerator(name =3D "myGenerator", strategy =3D "sequence") +package org.hibernate.test.annotations.configuration; + +import org.hibernate.annotations.GenericGenerator; Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/duplicatedgenerator/DuplicateTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/duplicatedgenerator/DuplicateTest.java (rev= 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/duplicatedgenerator/DuplicateTest.java 2009-11-24 21:03:15 UTC (rev= 18049) @@ -0,0 +1,28 @@ +//$Id: DuplicateTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.duplicatedgenerator; + +import junit.framework.TestCase; +import org.hibernate.AnnotationException; +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.cfg.Environment; + +/** + * @author Emmanuel Bernard + */ +public class DuplicateTest extends TestCase { + public void testDuplicateEntityName() throws Exception { + AnnotationConfiguration cfg =3D new AnnotationConfiguration(); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + try { + cfg.addAnnotatedClass( Flight.class ); + cfg.addAnnotatedClass( org.hibernate.test.annotations.Flight.class ); + cfg.addResource( "org/hibernate/test/annotations/orm.xml"); + cfg.addResource( "org/hibernate/test/annotations/duplicatedgenerator/or= m.xml"); + cfg.buildSessionFactory(); + fail( "Should not be able to map the same entity name twice" ); + } + catch (AnnotationException ae) { + //success + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/duplicatedgenerator/Flight.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/duplicatedgenerator/Flight.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/duplicatedgenerator/Flight.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,18 @@ +//$Id: Flight.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.duplicatedgenerator; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * Here to test duplicate import + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_flight") +public class Flight { + @Id + public String id; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/duplicatedgenerator/orm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/duplicatedgenerator/orm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/duplicatedgenerator/orm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Address.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Address.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,20 @@ +//$Id: Address.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Embeddable; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class Address implements Serializable { + String address1; + @Column(name =3D "fld_city") + String city; + Country country; + @ManyToOne + AddressType type; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/AddressType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/AddressType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/AddressType.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: AddressType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * Kind of address (home, professional etc) + * + * @author Emmanuel Bernard + */ +(a)Entity() +public class AddressType { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/Book.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Book.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Book.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,49 @@ +//$Id: Book.java 15073 2008-08-14 17:32:44Z epbernard $ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.SecondaryTable; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)SecondaryTable(name =3D "BookSummary") +public class Book { + private String isbn; + private String name; + private Summary summary; + + @Id + public String getIsbn() { + return isbn; + } + + public void setIsbn(String isbn) { + this.isbn =3D isbn; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @AttributeOverrides({ + @AttributeOverride(name =3D "size", column =3D @Column(name=3D"summ_size"= , table =3D "BookSummary")), + @AttributeOverride(name =3D "text", column =3D @Column(table =3D "BookSum= mary")) + }) + public Summary getSummary() { + return summary; + } + + public void setSummary(Summary summary) { + this.summary =3D summary; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/CorpType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/CorpType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/CorpType.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: CorpType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class CorpType { + private Integer id; + private String type; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type =3D type; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/Country.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Country.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Country.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +//$Id: Country.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Embeddable; + +import org.hibernate.annotations.AccessType; + +/** + * Non realistic embedded dependent object + * + * @author Emmanuel Bernard + */ +(a)Embeddable +//access =3D AccessType.PROPERTY) +(a)AccessType("property") +public class Country implements Serializable { + private String iso2; + private String name; + + public String getIso2() { + return iso2; + } + + public void setIso2(String iso2) { + this.iso2 =3D iso2; + } + + @Column(name =3D "countryName") + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/Deal.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Deal.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Deal.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,40 @@ +//$Id: Deal.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.Embedded; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Deal { + /** + * Deal ID. + */ + private String id; + + @Id + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } + + /** + * Swap with the tenor. + */ + private Swap swap; + + @Embedded + public Swap getSwap() { + return swap; + } + + public void setSwap(Swap swap) { + this.swap =3D swap; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/EmbeddedTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/EmbeddedTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/EmbeddedTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,386 @@ +//$Id: EmbeddedTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import java.io.Serializable; +import java.util.List; +import java.util.Set; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.embedded.FloatLeg.RateIndex; +import org.hibernate.test.annotations.embedded.Leg.Frequency; + +/** + * @author Emmanuel Bernard + */ +public class EmbeddedTest extends TestCase { + + public void testSimple() throws Exception { + Session s; + Transaction tx; + Person p =3D new Person(); + Address a =3D new Address(); + Country c =3D new Country(); + Country bornCountry =3D new Country(); + c.setIso2( "DM" ); + c.setName( "Matt Damon Land" ); + bornCountry.setIso2( "US" ); + bornCountry.setName( "United States of America" ); + + a.address1 =3D "colorado street"; + a.city =3D "Springfield"; + a.country =3D c; + p.address =3D a; + p.bornIn =3D bornCountry; + p.name =3D "Homer"; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( p ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + p =3D (Person) s.get( Person.class, p.id ); + assertNotNull( p ); + assertNotNull( p.address ); + assertEquals( "Springfield", p.address.city ); + assertNotNull( p.address.country ); + assertEquals( "DM", p.address.country.getIso2() ); + assertNotNull( p.bornIn ); + assertEquals( "US", p.bornIn.getIso2() ); + tx.commit(); + s.close(); + } + + public void testCompositeId() throws Exception { + Session s; + Transaction tx; + RegionalArticlePk pk =3D new RegionalArticlePk(); + pk.iso2 =3D "FR"; + pk.localUniqueKey =3D "1234567890123"; + RegionalArticle reg =3D new RegionalArticle(); + reg.setName( "Je ne veux pes rester sage - Dolly" ); + reg.setPk( pk ); + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( reg ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + reg =3D (RegionalArticle) s.get( RegionalArticle.class, (Serializable) r= eg.getPk() ); + assertNotNull( reg ); + assertNotNull( reg.getPk() ); + assertEquals( "Je ne veux pes rester sage - Dolly", reg.getName() ); + assertEquals( "FR", reg.getPk().iso2 ); + tx.commit(); + s.close(); + } + + public void testManyToOneInsideComponent() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Person p =3D new Person(); + Country bornIn =3D new Country(); + bornIn.setIso2( "FR" ); + bornIn.setName( "France" ); + p.bornIn =3D bornIn; + p.name =3D "Emmanuel"; + AddressType type =3D new AddressType(); + type.setName( "Primary Home" ); + s.persist( type ); + Country currentCountry =3D new Country(); + currentCountry.setIso2( "US" ); + currentCountry.setName( "USA" ); + Address add =3D new Address(); + add.address1 =3D "4 square street"; + add.city =3D "San diego"; + add.country =3D currentCountry; + add.type =3D type; + p.address =3D add; + s.persist( p ); + tx.commit(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "select p from Person p where p.address.city = =3D :city" ); + q.setString( "city", add.city ); + List result =3D q.list(); + Person samePerson =3D (Person) result.get( 0 ); + assertNotNull( samePerson.address.type ); + assertEquals( type.getName(), samePerson.address.type.getName() ); + tx.commit(); + s.close(); + } + + public void testEmbeddedSuperclass() { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + VanillaSwap swap =3D new VanillaSwap(); + swap.setInstrumentId( "US345421" ); + swap.setCurrency( VanillaSwap.Currency.EUR ); + FixedLeg fixed =3D new FixedLeg(); + fixed.setPaymentFrequency( Leg.Frequency.SEMIANNUALLY ); + fixed.setRate( 5.6 ); + FloatLeg floating =3D new FloatLeg(); + floating.setPaymentFrequency( Leg.Frequency.QUARTERLY ); + floating.setRateIndex( FloatLeg.RateIndex.LIBOR ); + floating.setRateSpread( 1.1 ); + swap.setFixedLeg( fixed ); + swap.setFloatLeg( floating ); + s.persist( swap ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + swap =3D (VanillaSwap) s.get( VanillaSwap.class, swap.getInstrumentId() = ); + // All fields must be filled with non-default values + fixed =3D swap.getFixedLeg(); + assertNotNull( "Fixed leg retrieved as null", fixed ); + floating =3D swap.getFloatLeg(); + assertNotNull( "Floating leg retrieved as null", floating ); + assertEquals( Leg.Frequency.SEMIANNUALLY, fixed.getPaymentFrequency() ); + assertEquals( Leg.Frequency.QUARTERLY, floating.getPaymentFrequency() ); + s.delete( swap ); + tx.commit(); + s.close(); + } + + public void testDottedProperty() { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + // Create short swap + Swap shortSwap =3D new Swap(); + shortSwap.setTenor( 2 ); + FixedLeg shortFixed =3D new FixedLeg(); + shortFixed.setPaymentFrequency( Frequency.SEMIANNUALLY ); + shortFixed.setRate( 5.6 ); + FloatLeg shortFloating =3D new FloatLeg(); + shortFloating.setPaymentFrequency( Frequency.QUARTERLY ); + shortFloating.setRateIndex( RateIndex.LIBOR ); + shortFloating.setRateSpread( 1.1 ); + shortSwap.setFixedLeg( shortFixed ); + shortSwap.setFloatLeg( shortFloating ); + // Create medium swap + Swap swap =3D new Swap(); + swap.setTenor( 7 ); + FixedLeg fixed =3D new FixedLeg(); + fixed.setPaymentFrequency( Frequency.MONTHLY ); + fixed.setRate( 7.6 ); + FloatLeg floating =3D new FloatLeg(); + floating.setPaymentFrequency( Frequency.MONTHLY ); + floating.setRateIndex( RateIndex.TIBOR ); + floating.setRateSpread( 0.8 ); + swap.setFixedLeg( fixed ); + swap.setFloatLeg( floating ); + // Create long swap + Swap longSwap =3D new Swap(); + longSwap.setTenor( 7 ); + FixedLeg longFixed =3D new FixedLeg(); + longFixed.setPaymentFrequency( Frequency.MONTHLY ); + longFixed.setRate( 7.6 ); + FloatLeg longFloating =3D new FloatLeg(); + longFloating.setPaymentFrequency( Frequency.MONTHLY ); + longFloating.setRateIndex( RateIndex.TIBOR ); + longFloating.setRateSpread( 0.8 ); + longSwap.setFixedLeg( longFixed ); + longSwap.setFloatLeg( longFloating ); + // Compose a curve spread deal + SpreadDeal deal =3D new SpreadDeal(); + deal.setId( "FX45632" ); + deal.setNotional( 450000.0 ); + deal.setShortSwap( shortSwap ); + deal.setSwap( swap ); + deal.setLongSwap( longSwap ); + s.persist( deal ); + + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + deal =3D (SpreadDeal) s.get( SpreadDeal.class, deal.getId() ); + // All fields must be filled with non-default values + assertNotNull( "Short swap is null.", deal.getShortSwap() ); + assertNotNull( "Swap is null.", deal.getSwap() ); + assertNotNull( "Long swap is null.", deal.getLongSwap() ); + assertEquals( 2, deal.getShortSwap().getTenor() ); + assertEquals( 7, deal.getSwap().getTenor() ); + assertEquals( 7, deal.getLongSwap().getTenor() ); + assertNotNull( "Short fixed leg is null.", deal.getShortSwap().getFixedL= eg() ); + assertNotNull( "Short floating leg is null.", deal.getShortSwap().getFlo= atLeg() ); + assertNotNull( "Fixed leg is null.", deal.getSwap().getFixedLeg() ); + assertNotNull( "Floating leg is null.", deal.getSwap().getFloatLeg() ); + assertNotNull( "Long fixed leg is null.", deal.getLongSwap().getFixedLeg= () ); + assertNotNull( "Long floating leg is null.", deal.getLongSwap().getFloat= Leg() ); + assertEquals( Frequency.SEMIANNUALLY, deal.getShortSwap().getFixedLeg().= getPaymentFrequency() ); + assertEquals( Frequency.QUARTERLY, deal.getShortSwap().getFloatLeg().get= PaymentFrequency() ); + assertEquals( Frequency.MONTHLY, deal.getSwap().getFixedLeg().getPayment= Frequency() ); + assertEquals( Frequency.MONTHLY, deal.getSwap().getFloatLeg().getPayment= Frequency() ); + assertEquals( Frequency.MONTHLY, deal.getLongSwap().getFixedLeg().getPay= mentFrequency() ); + assertEquals( Frequency.MONTHLY, deal.getLongSwap().getFloatLeg().getPay= mentFrequency() ); + assertEquals( 5.6, deal.getShortSwap().getFixedLeg().getRate() ); + assertEquals( 7.6, deal.getSwap().getFixedLeg().getRate() ); + assertEquals( 7.6, deal.getLongSwap().getFixedLeg().getRate() ); + assertEquals( RateIndex.LIBOR, deal.getShortSwap().getFloatLeg().getRate= Index() ); + assertEquals( RateIndex.TIBOR, deal.getSwap().getFloatLeg().getRateIndex= () ); + assertEquals( RateIndex.TIBOR, deal.getLongSwap().getFloatLeg().getRateI= ndex() ); + assertEquals( 1.1, deal.getShortSwap().getFloatLeg().getRateSpread() ); + assertEquals( 0.8, deal.getSwap().getFloatLeg().getRateSpread() ); + assertEquals( 0.8, deal.getLongSwap().getFloatLeg().getRateSpread() ); + s.delete( deal ); + tx.commit(); + s.close(); + } + + public void testEmbeddedInSecdondaryTable() throws Exception { + Session s; + s =3D openSession(); + s.getTransaction().begin(); + Book book =3D new Book(); + book.setIsbn( "1234" ); + book.setName( "HiA Second Edition" ); + Summary summary =3D new Summary(); + summary.setText( "This is a HiA SE summary" ); + summary.setSize( summary.getText().length() ); + book.setSummary( summary ); + s.persist( book ); + s.getTransaction().commit(); + + s.clear(); + + Transaction tx =3D s.beginTransaction(); + Book loadedBook =3D (Book) s.get( Book.class, book.getIsbn() ); + assertNotNull( loadedBook.getSummary() ); + assertEquals( book.getSummary().getText(), loadedBook.getSummary().getTe= xt() ); + s.delete( loadedBook ); + tx.commit(); + s.close(); + } + + public void testParent() throws Exception { + Session s; + s =3D openSession(); + s.getTransaction().begin(); + Book book =3D new Book(); + book.setIsbn( "1234" ); + book.setName( "HiA Second Edition" ); + Summary summary =3D new Summary(); + summary.setText( "This is a HiA SE summary" ); + summary.setSize( summary.getText().length() ); + book.setSummary( summary ); + s.persist( book ); + s.getTransaction().commit(); + + s.clear(); + + Transaction tx =3D s.beginTransaction(); + Book loadedBook =3D (Book) s.get( Book.class, book.getIsbn() ); + assertNotNull( loadedBook.getSummary() ); + assertEquals( loadedBook, loadedBook.getSummary().getSummarizedBook() ); + s.delete( loadedBook ); + tx.commit(); + s.close(); + } + + public void testEmbeddedAndMultipleManyToOne() throws Exception { + Session s; + s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + CorpType type =3D new CorpType(); + type.setType( "National" ); + s.persist( type ); + Nationality nat =3D new Nationality(); + nat.setName( "Canadian" ); + s.persist( nat ); + InternetProvider provider =3D new InternetProvider(); + provider.setBrandName( "Fido" ); + LegalStructure structure =3D new LegalStructure(); + structure.setCorporationType( type ); + structure.setCountry( "Canada" ); + structure.setName( "Rogers" ); + provider.setOwner( structure ); + structure.setOrigin( nat ); + s.persist( provider ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + provider =3D (InternetProvider) s.get( InternetProvider.class, provider.= getId() ); + assertNotNull( provider.getOwner() ); + assertNotNull( "Many to one not set", provider.getOwner().getCorporation= Type() ); + assertEquals( "Wrong link", type.getType(), provider.getOwner().getCorpo= rationType().getType() ); + assertNotNull( "2nd Many to one not set", provider.getOwner().getOrigin(= ) ); + assertEquals( "Wrong 2nd link", nat.getName(), provider.getOwner().getOr= igin().getName() ); + s.delete( provider ); + s.delete( provider.getOwner().getCorporationType() ); + s.delete( provider.getOwner().getOrigin() ); + tx.commit(); + s.close(); + } + + public void testEmbeddedAndOneToMany() throws Exception { + Session s; + s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + InternetProvider provider =3D new InternetProvider(); + provider.setBrandName( "Fido" ); + LegalStructure structure =3D new LegalStructure(); + structure.setCountry( "Canada" ); + structure.setName( "Rogers" ); + provider.setOwner( structure ); + s.persist( provider ); + Manager manager =3D new Manager(); + manager.setName( "Bill" ); + manager.setEmployer( provider ); + structure.getTopManagement().add( manager ); + s.persist( manager ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + provider =3D (InternetProvider) s.get( InternetProvider.class, provider.= getId() ); + assertNotNull( provider.getOwner() ); + Set topManagement =3D provider.getOwner().getTopManagement(); + assertNotNull( "OneToMany not set", topManagement ); + assertEquals( "Wrong number of elements", 1, topManagement.size() ); + manager =3D (Manager) topManagement.iterator().next(); + assertEquals( "Wrong element", "Bill", manager.getName() ); + s.delete( manager ); + s.delete( provider ); + tx.commit(); + s.close(); + } + + public EmbeddedTest(String x) { + super( x ); + } + + protected Class[] getMappings() { + return new Class[]{ + Person.class, + RegionalArticle.class, + AddressType.class, + VanillaSwap.class, + SpreadDeal.class, + Book.class, + InternetProvider.class, + CorpType.class, + Nationality.class, + Manager.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/FixedLeg.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/FixedLeg.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/FixedLeg.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +package org.hibernate.test.annotations.embedded; + +import java.text.NumberFormat; +import javax.persistence.Embeddable; + +/** + * Represents fixed part of Interest Rate Swap cash flows. + */ +(a)Embeddable +public class FixedLeg extends Leg { + + /** + * Fixed rate. + */ + private double rate; + + public double getRate() { + return rate; + } + + public void setRate(double rate) { + this.rate =3D rate; + } + + public String toString() { + NumberFormat format =3D NumberFormat.getNumberInstance(); + format.setMinimumFractionDigits( 4 ); + format.setMaximumFractionDigits( 4 ); + return format.format( getRate() ) + "%"; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/FloatLeg.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/FloatLeg.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/FloatLeg.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,49 @@ +package org.hibernate.test.annotations.embedded; + +import java.text.NumberFormat; +import javax.persistence.Embeddable; + +/** + * Represents floating part of Interest Rate Swap cash flows. + */ +(a)Embeddable +public class FloatLeg extends Leg { + + /** + * Possible values for the rate index. + */ + public enum RateIndex { + LIBOR, EURIBOR, TIBOR} + + ; + + private RateIndex rateIndex; + + /** + * Spread over the selected rate index (in basis points). + */ + private double rateSpread; + + public RateIndex getRateIndex() { + return rateIndex; + } + + public void setRateIndex(RateIndex rateIndex) { + this.rateIndex =3D rateIndex; + } + + public double getRateSpread() { + return rateSpread; + } + + public void setRateSpread(double rateSpread) { + this.rateSpread =3D rateSpread; + } + + public String toString() { + NumberFormat format =3D NumberFormat.getNumberInstance(); + format.setMinimumFractionDigits( 1 ); + format.setMaximumFractionDigits( 1 ); + return "[" + getRateIndex().toString() + "+" + format.format( getRateSpr= ead() ) + "]"; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/InternetProvider.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/InternetProvider.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/InternetProvider.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,42 @@ +//$Id: InternetProvider.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class InternetProvider { + private Integer id; + private String brandName; + private LegalStructure owner; + + public String getBrandName() { + return brandName; + } + + public void setBrandName(String brandName) { + this.brandName =3D brandName; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public LegalStructure getOwner() { + return owner; + } + + public void setOwner(LegalStructure owner) { + this.owner =3D owner; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/Leg.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Leg.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Leg.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.MappedSuperclass; + +/** + * Represents a leg of a vanilla interest rate swap. + */ +(a)MappedSuperclass +public class Leg { + /** + * Possible values of the payment frequency field. + */ + public enum Frequency { + ANNUALY, SEMIANNUALLY, QUARTERLY, MONTHLY } + + ; + + /** + * Shows how frequent payments according to this leg should be made. + */ + private Frequency paymentFrequency; + + public Frequency getPaymentFrequency() { + return paymentFrequency; + } + + public void setPaymentFrequency(Frequency paymentFrequency) { + this.paymentFrequency =3D paymentFrequency; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/LegalStructure.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/LegalStructure.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/LegalStructure.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,66 @@ +//$Id: LegalStructure.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Embeddable; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class LegalStructure { + private String name; + private String country; + private CorpType corporationType; + private Nationality origin; + private Set topManagement =3D new HashSet(); + + @ManyToOne + @JoinColumn(name =3D "CORP_ID") + public CorpType getCorporationType() { + return corporationType; + } + + public void setCorporationType(CorpType corporationType) { + this.corporationType =3D corporationType; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country =3D country; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToOne + @JoinColumn(name =3D "origin_fk") + public Nationality getOrigin() { + return origin; + } + + public void setOrigin(Nationality origin) { + this.origin =3D origin; + } + + @OneToMany(mappedBy =3D "employer") + public Set getTopManagement() { + return topManagement; + } + + public void setTopManagement(Set topManagement) { + this.topManagement =3D topManagement; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/Manager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Manager.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Manager.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,44 @@ +//$Id: Manager.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Manager { + private Integer id; + private String name; + private InternetProvider employer; + + @ManyToOne + public InternetProvider getEmployer() { + return employer; + } + + public void setEmployer(InternetProvider employer) { + this.employer =3D employer; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/Nationality.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Nationality.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Nationality.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Nationality.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Nationality { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/NotonialDeal.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/NotonialDeal.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/NotonialDeal.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,30 @@ +//$Id: NotonialDeal.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)AttributeOverrides(value =3D { +(a)AttributeOverride(name =3D "swap.tenor", column =3D @Column(name =3D "T= ENOR")), //should be ovvriden by deal +(a)AttributeOverride(name =3D "id", column =3D @Column(name =3D "NOTONIALD= EAL_ID")) + }) +(a)MappedSuperclass +public class NotonialDeal extends Deal { + /** + * Notional amount of both IRSs. + */ + private double notional; + + public double getNotional() { + return notional; + } + + public void setNotional(double notional) { + this.notional =3D notional; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/Person.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Person.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Person.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: Person.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import java.io.Serializable; +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "PersonEmbed") +public class Person implements Serializable { + @Id + @GeneratedValue + Integer id; + + String name; + + @Embedded + Address address; + + @Embedded + @AttributeOverrides({ + @AttributeOverride(name =3D "iso2", column =3D @Column(name =3D "bornIso2= ")), + @AttributeOverride(name =3D "name", column =3D @Column(name =3D "bornCoun= tryName")) + }) + Country bornIn; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/RegionalArticle.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/RegionalArticle.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/RegionalArticle.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,50 @@ +//$Id: RegionalArticle.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.embedded; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * A regional article is typically a bad design, it keep the country iso2 = and a business key as + * (composite) primary key + * + * @author Emmanuel Bernard + */ +(a)Entity +public class RegionalArticle implements Serializable { + private RegionalArticlePk pk; + private String name; + + @Id + public RegionalArticlePk getPk() { + return pk; + } + + public void setPk(RegionalArticlePk pk) { + this.pk =3D pk; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public int hashCode() { + //a NPE can occurs, but I don't expect hashcode to be used before pk is = set + return getPk().hashCode(); + } + + public boolean equals(Object obj) { + //a NPE can occurs, but I don't expect equals to be used before pk is set + if ( obj !=3D null && obj instanceof RegionalArticle ) { + return getPk().equals( ( (RegionalArticle) obj ).getPk() ); + } + else { + return false; + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/RegionalArticlePk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/RegionalArticlePk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/RegionalArticlePk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,38 @@ +//$Id: RegionalArticlePk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.test.annotations.embedded; + +import java.io.Serializable; +import javax.persistence.Embeddable; + +import org.hibernate.annotations.AccessType; + +/** + * Regional article pk + * + * @author Emmanuel Bernard + */ +(a)Embeddable +(a)AccessType("field") +public class RegionalArticlePk implements Serializable { + /** + * country iso2 code + */ + public String iso2; + public String localUniqueKey; + + public int hashCode() { + //this implem sucks + return ( iso2 + localUniqueKey ).hashCode(); + } + + public boolean equals(Object obj) { + //iso2 and localUniqueKey are expected to be set in this implem + if ( obj !=3D null && obj instanceof RegionalArticlePk ) { + RegionalArticlePk other =3D (RegionalArticlePk) obj; + return iso2.equals( other.iso2 ) && localUniqueKey.equals( other.localU= niqueKey ); + } + else { + return false; + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/SpreadDeal.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/SpreadDeal.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/SpreadDeal.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,62 @@ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; + +/** + * Represents a "curve spread" deal that consists of + * two Interest Rate Swaps with different tenors (short and long). + * For simplicity, tenors are not considered here. + */ +(a)Entity +(a)AttributeOverrides(value =3D { +(a)AttributeOverride(name =3D "swap.tenor", column =3D @Column(name =3D "M= EDIUM_TENOR")), +(a)AttributeOverride(name =3D "swap.fixedLeg.paymentFrequency", column =3D= @Column(name =3D "MEDIUM_FIXED_FREQUENCY")), +(a)AttributeOverride(name =3D "swap.fixedLeg.rate", column =3D @Column(nam= e =3D "MEDIUM_FIXED_RATE")), +(a)AttributeOverride(name =3D "swap.floatLeg.paymentFrequency", column =3D= @Column(name =3D "MEDIUM_FLOAT_FREQUENCY")), +(a)AttributeOverride(name =3D "swap.floatLeg.rateIndex", column =3D @Colum= n(name =3D "MEDIUM_FLOAT_RATEINDEX")), +(a)AttributeOverride(name =3D "swap.floatLeg.rateSpread", column =3D @Colu= mn(name =3D "MEDIUM_FLOAT_RATESPREAD")) + }) +public class SpreadDeal extends NotonialDeal { + + /** + * Swap with the tenor. + */ + private Swap longSwap; + + @Embedded + public Swap getLongSwap() { + return longSwap; + } + + public void setLongSwap(Swap swap) { + this.longSwap =3D swap; + } + + + /** + * Swap with the longer tenor. + */ + private Swap shortSwap; + + + @Embedded + @AttributeOverrides(value =3D { + @AttributeOverride(name =3D "tenor", column =3D @Column(name =3D "SHORT_T= ENOR")), + @AttributeOverride(name =3D "fixedLeg.paymentFrequency", column =3D @Colu= mn(name =3D "SHORT_FIXED_FREQUENCY")), + @AttributeOverride(name =3D "fixedLeg.rate", column =3D @Column(name =3D = "SHORT_FIXED_RATE")), + @AttributeOverride(name =3D "floatLeg.paymentFrequency", column =3D @Colu= mn(name =3D "SHORT_FLOAT_FREQUENCY")), + @AttributeOverride(name =3D "floatLeg.rateIndex", column =3D @Column(name= =3D "SHORT_FLOAT_RATEINDEX")), + @AttributeOverride(name =3D "floatLeg.rateSpread", column =3D @Column(nam= e =3D "SHORT_FLOAT_RATESPREAD")) + }) + public Swap getShortSwap() { + return shortSwap; + } + + public void setShortSwap(Swap shortSwap) { + this.shortSwap =3D shortSwap; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/Summary.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Summary.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Summary.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,43 @@ +//$Id: Summary.java 15056 2008-08-13 18:15:05Z epbernard $ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.Embeddable; +import javax.persistence.Column; + +import org.hibernate.annotations.Parent; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class Summary { + private int size; + private String text; + private Book summarizedBook; + + @Column(name=3D"summary_size") + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size =3D size; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text =3D text; + } + + @Parent + public Book getSummarizedBook() { + return summarizedBook; + } + + public void setSummarizedBook(Book summarizedBook) { + this.summarizedBook =3D summarizedBook; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/Swap.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Swap.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/Swap.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,58 @@ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.Embeddable; +import javax.persistence.Embedded; + +/** + * Interest Rate Swap with Tenor. Used here to compose + * a swap spread deal. + */ +(a)Embeddable +public class Swap { + + /** + * Tenor (duration) of the swap (in years). + */ + private int tenor; + + public int getTenor() { + return tenor; + } + + public void setTenor(int tenor) { + this.tenor =3D tenor; + } + + /** + * Fixed leg (cash flows with the fixed rate). + */ + private FixedLeg fixedLeg; + + /** + * Floating leg (cash flows bound to a financial index). + */ + private FloatLeg floatLeg; + + @Embedded + // We retain this annotation to test the precedence of @AttributeOverride + // Outermost override annotation should win + @AttributeOverride(name =3D "paymentFrequency", column =3D @Column(name = =3D "FIXED_FREQENCY")) + public FixedLeg getFixedLeg() { + return fixedLeg; + } + + public void setFixedLeg(FixedLeg fixedLeg) { + this.fixedLeg =3D fixedLeg; + } + + @Embedded + public FloatLeg getFloatLeg() { + return floatLeg; + } + + public void setFloatLeg(FloatLeg floatLeg) { + this.floatLeg =3D floatLeg; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/embedded/VanillaSwap.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/VanillaSwap.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/embedded/VanillaSwap.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,77 @@ +package org.hibernate.test.annotations.embedded; + +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * Represents an Interest Rate Swap. + */ +(a)Entity +public class VanillaSwap { + + /** + * Possible values for the currency field. + */ + public enum Currency { + USD, GBP, EUR, JPY } + + /** + * Identifier of the Interest Rate Swap + */ + private String instrumentId; + + /** + * Currency of the swap (and of both legs). + */ + private Currency currency; + + /** + * Fixed leg (cash flows with the fixed rate). + */ + private FixedLeg fixedLeg; + + /** + * Floating leg (cash flows bound to a financial index). + */ + private FloatLeg floatLeg; + + @Embedded + @AttributeOverride(name =3D "paymentFrequency", column =3D @Column(name = =3D "FIXED_FREQENCY")) + public FixedLeg getFixedLeg() { + return fixedLeg; + } + + public void setFixedLeg(FixedLeg fixedLeg) { + this.fixedLeg =3D fixedLeg; + } + + @Embedded + @AttributeOverride(name =3D "paymentFrequency", column =3D @Column(name = =3D "FLOAT_FREQUENCY")) + public FloatLeg getFloatLeg() { + return floatLeg; + } + + public void setFloatLeg(FloatLeg floatLeg) { + this.floatLeg =3D floatLeg; + } + + public Currency getCurrency() { + return currency; + } + + public void setCurrency(Currency currency) { + this.currency =3D currency; + } + + @Id + public String getInstrumentId() { + return instrumentId; + } + + public void setInstrumentId(String instrumentId) { + this.instrumentId =3D instrumentId; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Address.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Address.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,47 @@ +//$Id: Address.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * Has a serializable class as a property + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "serial_address") +public class Address { + private Integer id; + private String city; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city =3D city; + } + + public Country getCountry() { + return country; + } + + public void setCountry(Country country) { + this.country =3D country; + } + + private Country country; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/BasicHibernateAnnotationsTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/BasicHibernateAnnotationsTest.java (= rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/BasicHibernateAnnotationsTest.java 2009-11-24 21:03:15 UTC (= rev 18049) @@ -0,0 +1,357 @@ +//$Id: BasicHibernateAnnotationsTest.java 17798 2009-10-19 15:48:57Z stliu= $ +package org.hibernate.test.annotations.entity; + +import java.math.BigDecimal; +import java.util.Currency; +import java.util.Date; + +import org.hibernate.Hibernate; +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class BasicHibernateAnnotationsTest extends TestCase { + + public void testEntity() throws Exception { + if( !getDialect().supportsExpectedLobUsagePattern() ){ + return; + } + Forest forest =3D new Forest(); + forest.setName( "Fontainebleau" ); + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( forest ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + forest =3D (Forest) s.get( Forest.class, forest.getId() ); + assertNotNull( forest ); + forest.setName( "Fontainebleau" ); + //should not execute SQL update + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + forest =3D (Forest) s.get( Forest.class, forest.getId() ); + assertNotNull( forest ); + forest.setLength( 23 ); + //should execute dynamic SQL update + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete( s.get( Forest.class, forest.getId() ) ); + tx.commit(); + s.close(); + } + + public void testVersioning() throws Exception { + if( !getDialect().supportsExpectedLobUsagePattern() ){ + return; + } + Forest forest =3D new Forest(); + forest.setName( "Fontainebleau" ); + forest.setLength( 33 ); + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( forest ); + tx.commit(); + s.close(); + + Session parallelSession =3D openSession(); + Transaction parallelTx =3D parallelSession.beginTransaction(); + s =3D openSession(); + tx =3D s.beginTransaction(); + + forest =3D (Forest) parallelSession.get( Forest.class, forest.getId() ); + Forest reloadedForest =3D (Forest) s.get( Forest.class, forest.getId() ); + reloadedForest.setLength( 11 ); + assertNotSame( forest, reloadedForest ); + tx.commit(); + s.close(); + + forest.setLength( 22 ); + try { + parallelTx.commit(); + fail( "All optimistic locking should have make it fail" ); + } + catch (HibernateException e) { + if ( parallelTx !=3D null ) parallelTx.rollback(); + } + finally { + parallelSession.close(); + } + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete( s.get( Forest.class, forest.getId() ) ); + tx.commit(); + s.close(); + + } + + public void testPolymorphism() throws Exception { + if( !getDialect().supportsExpectedLobUsagePattern() ){ + return; + } + Forest forest =3D new Forest(); + forest.setName( "Fontainebleau" ); + forest.setLength( 33 ); + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( forest ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query query =3D s.createQuery( "from java.lang.Object" ); + assertEquals( 0, query.list().size() ); + query =3D s.createQuery( "from Forest" ); + assertTrue( 0 < query.list().size() ); + tx.commit(); + s.close(); + } + + public void testType() throws Exception { + if( !getDialect().supportsExpectedLobUsagePattern() ){ + return; + } + Forest f =3D new Forest(); + f.setName( "Broceliande" ); + String description =3D "C'est une enorme foret enchantee ou vivais Merli= n et toute la clique"; + f.setLongDescription( description ); + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( f ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + f =3D (Forest) s.get( Forest.class, f.getId() ); + assertNotNull( f ); + assertEquals( description, f.getLongDescription() ); + s.delete( f ); + tx.commit(); + s.close(); + + } + + public void testNonLazy() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Forest f =3D new Forest(); + Tree t =3D new Tree(); + t.setName( "Basic one" ); + s.persist( f ); + s.persist( t ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + f =3D (Forest) s.load( Forest.class, f.getId() ); + t =3D (Tree) s.load( Tree.class, t.getId() ); + assertFalse( "Default should be lazy", Hibernate.isInitialized( f ) ); + assertTrue( "Tree is not lazy", Hibernate.isInitialized( t ) ); + tx.commit(); + s.close(); + } + + public void testCache() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + ZipCode zc =3D new ZipCode(); + zc.code =3D "92400"; + s.persist( zc ); + tx.commit(); + s.close(); + getSessions().getStatistics().clear(); + getSessions().getStatistics().setStatisticsEnabled( true ); + getSessions().evict( ZipCode.class ); + s =3D openSession(); + tx =3D s.beginTransaction(); + s.get( ZipCode.class, zc.code ); + assertEquals( 1, getSessions().getStatistics().getSecondLevelCachePutCou= nt() ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.get( ZipCode.class, zc.code ); + assertEquals( 1, getSessions().getStatistics().getSecondLevelCacheHitCou= nt() ); + tx.commit(); + s.close(); + } + + public void testFilter() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.createQuery( "delete Forest" ).executeUpdate(); + Forest f1 =3D new Forest(); + f1.setLength( 2 ); + s.persist( f1 ); + Forest f2 =3D new Forest(); + f2.setLength( 20 ); + s.persist( f2 ); + Forest f3 =3D new Forest(); + f3.setLength( 200 ); + s.persist( f3 ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + s.enableFilter( "betweenLength" ).setParameter( "minLength", 5 ).setPara= meter( "maxLength", 50 ); + long count =3D ( (Long) s.createQuery( "select count(*) from Forest" ).i= terate().next() ).intValue(); + assertEquals( 1, count ); + s.disableFilter( "betweenLength" ); + s.enableFilter( "minLength" ).setParameter( "minLength", 5 ); + count =3D ( (Long) s.createQuery( "select count(*) from Forest" ).iterat= e().next() ).longValue(); + assertEquals( 2l, count ); + s.disableFilter( "minLength" ); + tx.rollback(); + s.close(); + } + + public void testParameterizedType() throws Exception { + if( !getDialect().supportsExpectedLobUsagePattern() ){ + return; + } + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Forest f =3D new Forest(); + f.setSmallText( "ThisIsASmallText" ); + f.setBigText( "ThisIsABigText" ); + s.persist( f ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + Forest f2 =3D (Forest) s.get( Forest.class, f.getId() ); + assertEquals( f.getSmallText().toLowerCase(), f2.getSmallText() ); + assertEquals( f.getBigText().toUpperCase(), f2.getBigText() ); + tx.commit(); + s.close(); + } + + public void testSerialized() throws Exception { + if( !getDialect().supportsExpectedLobUsagePattern() ){ + return; + } + Forest forest =3D new Forest(); + forest.setName( "Shire" ); + Country country =3D new Country(); + country.setName( "Middle Earth" ); + forest.setCountry( country ); + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( forest ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + forest =3D (Forest) s.get( Forest.class, forest.getId() ); + assertNotNull( forest ); + assertNotNull( forest.getCountry() ); + assertEquals( country.getName(), forest.getCountry().getName() ); + tx.commit(); + s.close(); + } + + public void testCompositeType() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Ransom r =3D new Ransom(); + r.setKidnapperName( "Se7en" ); + r.setDate( new Date() ); + MonetaryAmount amount =3D new MonetaryAmount( + new BigDecimal( 100000 ), + Currency.getInstance( "EUR" ) + ); + r.setAmount( amount ); + s.persist( r ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + r =3D (Ransom) s.get( Ransom.class, r.getId() ); + assertNotNull( r ); + assertNotNull( r.getAmount() ); + assertTrue( 0 =3D=3D new BigDecimal( 100000 ).compareTo( r.getAmount().g= etAmount() ) ); + assertEquals( Currency.getInstance( "EUR" ), r.getAmount().getCurrency()= ); + tx.commit(); + s.close(); + } + + public void testFormula() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + org.hibernate.test.annotations.entity.Flight airFrance =3D new Flight(); + airFrance.setId( new Long( 747 ) ); + airFrance.setMaxAltitude( 10000 ); + s.persist( airFrance ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + airFrance =3D (Flight) s.get( Flight.class, airFrance.getId() ); + assertNotNull( airFrance ); + assertEquals( 10000000, airFrance.getMaxAltitudeInMilimeter() ); + s.delete( airFrance ); + tx.commit(); + s.close(); + } + + public BasicHibernateAnnotationsTest(String x) { + super( x ); + } + + protected Class[] getMappings() { + return new Class[]{ + Forest.class, + Tree.class, + Ransom.class, + ZipCode.class, + Flight.class + }; + } + + protected String[] getAnnotatedPackages() { + return new String[]{ + "org.hibernate.test.annotations.entity" + }; + } + + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Bid.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Bid.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Bid.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,63 @@ +//$Id: Bid.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Bid { + private Integer id; + private String description; + private Starred note; + private Starred editorsNote; + private Boolean approved; + + @Enumerated(EnumType.STRING) + //@Column(columnDefinition =3D "VARCHAR(10)") + public Starred getEditorsNote() { + return editorsNote; + } + + public void setEditorsNote(Starred editorsNote) { + this.editorsNote =3D editorsNote; + } + + @Id + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description =3D description; + } + + public Starred getNote() { + return note; + } + + public void setNote(Starred note) { + this.note =3D note; + } + + public Boolean getApproved() { + return approved; + } + + public void setApproved(Boolean approved) { + this.approved =3D approved; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/CasterStringType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/CasterStringType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/CasterStringType.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,90 @@ +//$Id: CasterStringType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.Properties; + +import org.hibernate.HibernateException; +import org.hibernate.usertype.ParameterizedType; +import org.hibernate.usertype.UserType; + +/** + * Sample of parameter type + * + * @author Emmanuel Bernard + */ +public class CasterStringType implements UserType, ParameterizedType { + private static final String CAST =3D "cast"; + private Properties parameters; + + public int[] sqlTypes() { + return new int[]{Types.VARCHAR}; + } + + public Class returnedClass() { + return String.class; + } + + public boolean equals(Object x, Object y) throws HibernateException { + return ( x =3D=3D y ) || ( x !=3D null && x.equals( y ) ); + } + + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + + public Object nullSafeGet(ResultSet rs, String[] names, Object owner) thr= ows HibernateException, SQLException { + String result =3D rs.getString( names[0] ); + if ( rs.wasNull() ) return null; + if ( parameters.getProperty( CAST ).equals( "lower" ) ) { + return result.toLowerCase(); + } + else { + return result.toUpperCase(); + } + } + + public void nullSafeSet(PreparedStatement st, Object value, int index) th= rows HibernateException, SQLException { + if ( value =3D=3D null ) { + st.setNull( index, sqlTypes()[0] ); + } + else { + String string =3D (String) value; + if ( parameters.getProperty( CAST ).equals( "lower" ) ) { + string =3D string.toLowerCase(); + } + else { + string =3D string.toUpperCase(); + } + st.setString( index, string ); + } + } + + public Object deepCopy(Object value) throws HibernateException { + return value; + } + + public boolean isMutable() { + return false; + } + + public Serializable disassemble(Object value) throws HibernateException { + return (Serializable) value; + } + + public Object assemble(Serializable cached, Object owner) throws Hibernat= eException { + return cached; + } + + public Object replace(Object original, Object target, Object owner) throw= s HibernateException { + return original; + } + + public void setParameterValues(Properties parameters) { + this.parameters =3D parameters; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/CommunityBid.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/CommunityBid.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/CommunityBid.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,21 @@ +//$Id: CommunityBid.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class CommunityBid extends Bid { + private Starred communityNote; + + public Starred getCommunityNote() { + return communityNote; + } + + public void setCommunityNote(Starred communityNote) { + this.communityNote =3D communityNote; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Country.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Country.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Country.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,21 @@ +//$Id: Country.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import java.io.Serializable; + +/** + * Serializable object to be serialized in DB as is + * + * @author Emmanuel Bernard + */ +public class Country implements Serializable { + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Flight.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Flight.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Flight.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,49 @@ +//$Id: Flight.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; + +import org.hibernate.annotations.Formula; + +/** + * @author Emmanuel Bernard + */ +(a)Entity() +(a)Table(name =3D "Formula_flight") +(a)Inheritance(strategy =3D InheritanceType.TABLE_PER_CLASS) +public class Flight implements Serializable { + Long id; + long maxAltitudeInMilimeter; + long maxAltitude; + + @Id + public Long getId() { + return id; + } + + public void setId(Long long1) { + id =3D long1; + } + + public long getMaxAltitude() { + return maxAltitude; + } + + public void setMaxAltitude(long maxAltitude) { + this.maxAltitude =3D maxAltitude; + } + + @Formula("maxAltitude * 1000") + public long getMaxAltitudeInMilimeter() { + return maxAltitudeInMilimeter; + } + + public void setMaxAltitudeInMilimeter(long maxAltitudeInMilimeter) { + this.maxAltitudeInMilimeter =3D maxAltitudeInMilimeter; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Forest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Forest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Forest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,113 @@ +//$Id: Forest.java 17791 2009-10-19 13:16:08Z stliu $ +package org.hibernate.test.annotations.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Lob; + +import org.hibernate.annotations.BatchSize; +import org.hibernate.annotations.Filter; +import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.Filters; +import org.hibernate.annotations.Index; +import org.hibernate.annotations.OptimisticLock; +import org.hibernate.annotations.OptimisticLockType; +import org.hibernate.annotations.ParamDef; +import org.hibernate.annotations.Parameter; +import org.hibernate.annotations.PolymorphismType; +import org.hibernate.annotations.Type; +import org.hibernate.annotations.Where; + +/** + * Use hibernate specific annotations + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)BatchSize(size =3D 5) +(a)org.hibernate.annotations.Entity( + selectBeforeUpdate =3D true, + dynamicInsert =3D true, dynamicUpdate =3D true, + optimisticLock =3D OptimisticLockType.ALL, + polymorphism =3D PolymorphismType.EXPLICIT) +(a)Where(clause =3D "1=3D1") +(a)FilterDef(name =3D "minLength", parameters =3D {@ParamDef(name =3D "min= Length", type =3D "integer")}) +(a)Filters({ +(a)Filter(name =3D "betweenLength"), +(a)Filter(name =3D "minLength", condition =3D ":minLength <=3D length") + }) +(a)org.hibernate.annotations.Table(appliesTo =3D "Forest", + indexes =3D {@Index(name =3D "idx", columnNames =3D {"name", "length"})}) +public class Forest { + private Integer id; + private String name; + private long length; + private String longDescription; + private String smallText; + private String bigText; + private Country country; + = + @OptimisticLock(excluded=3Dtrue) = + @Type(type =3D "text") + public String getLongDescription() { + return longDescription; + } + + public void setLongDescription(String longDescription) { + this.longDescription =3D longDescription; + } + + public long getLength() { + return length; + } + + public void setLength(long length) { + this.length =3D length; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Type(type =3D "caster") + public String getSmallText() { + return smallText; + } + + @Type(type =3D "caster", parameters =3D {@Parameter(name =3D "cast", valu= e =3D "upper")}) + public String getBigText() { + return bigText; + } + + public void setSmallText(String smallText) { + this.smallText =3D smallText; + } + + public void setBigText(String bigText) { + this.bigText =3D bigText; + } + + @Lob + public Country getCountry() { + return country; + } + + public void setCountry(Country country) { + this.country =3D country; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Java5FeaturesTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Java5FeaturesTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Java5FeaturesTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,125 @@ +//$Id: Java5FeaturesTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.test.annotations.entity; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class Java5FeaturesTest extends TestCase { + public void testInterface() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Race r =3D new Race(); + r.setId( new Integer( 1 ) ); + r.setLength( new Long( 3 ) ); + s.persist( r ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + r =3D (Race) s.get( Race.class, r.getId() ); + assertEquals( new Long( 3 ), r.getLength() ); + tx.commit(); + s.close(); + + } + + public void testEnums() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + CommunityBid communityBid =3D new CommunityBid(); + communityBid.setId( new Integer( 2 ) ); + communityBid.setCommunityNote( Starred.OK ); + Bid bid =3D new Bid(); + bid.setId( new Integer( 1 ) ); + bid.setDescription( "My best one" ); + bid.setNote( Starred.OK ); + bid.setEditorsNote( Starred.GOOD ); + s.persist( bid ); + s.persist( communityBid ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + //bid =3D (Bid) s.get( Bid.class, bid.getId() ); + bid =3D (Bid)s.createQuery( "select b from Bid b where b.note =3D " + + Starred.class.getName() + ".OK and b.editorsNote =3D " + + Starred.class.getName() + ".GOOD and b.id =3D :id") + .setParameter( "id", bid.getId() ).uniqueResult(); + //testing constant value + assertEquals( Starred.OK, bid.getNote() ); + assertEquals( Starred.GOOD, bid.getEditorsNote() ); + bid =3D (Bid)s.createQuery( "select b from Bid b where b.note =3D :note"= + + " and b.editorsNote =3D :editorNote " + + " and b.id =3D :id") + .setParameter( "id", bid.getId() ) + .setParameter( "note", Starred.OK ) + .setParameter( "editorNote", Starred.GOOD ) + .uniqueResult(); + //testing constant value + assertEquals( Starred.OK, bid.getNote() ); + assertEquals( Starred.GOOD, bid.getEditorsNote() ); + bid.setNote( null ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + bid =3D (Bid) s.get( Bid.class, bid.getId() ); + communityBid =3D (CommunityBid) s.get( CommunityBid.class, communityBid.= getId() ); + assertNull( bid.getNote() ); + assertEquals( Starred.OK, communityBid.getCommunityNote() ); + s.delete( bid ); + s.clear(); + communityBid =3D (CommunityBid) s.createSQLQuery( "select {b.*} from Bid= b where b.id =3D ?" ) + .addEntity( "b", CommunityBid.class ) + .setInteger( 0, communityBid.getId() ).uniqueResult(); + assertEquals( Starred.OK, communityBid.getCommunityNote() ); + s.delete( communityBid ); + tx.commit(); + s.close(); + } + + public void testAutoboxing() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Bid bid =3D new Bid(); + bid.setId( new Integer( 2 ) ); + bid.setDescription( "My best one" ); + bid.setNote( Starred.OK ); + bid.setEditorsNote( Starred.GOOD ); + bid.setApproved( null ); + s.persist( bid ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + bid =3D (Bid) s.get( Bid.class, bid.getId() ); + assertEquals( null, bid.getApproved() ); + s.delete( bid ); + tx.commit(); + s.close(); + } + + public Java5FeaturesTest(String x) { + super( x ); + } + + protected Class[] getMappings() { + return new Class[]{ + Race.class, + Bid.class, + CommunityBid.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Length.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Length.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Length.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,9 @@ +//$Id: Length.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +/** + * @author Emmanuel Bernard + */ +public interface Length { + Type getLength(); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/MonetaryAmount.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/MonetaryAmount.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/MonetaryAmount.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,36 @@ +//$Id: MonetaryAmount.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Currency; + +/** + * @author Emmanuel Bernard + */ +public class MonetaryAmount implements Serializable { + + private BigDecimal amount; + private Currency currency; + + public MonetaryAmount(BigDecimal amount, Currency currency) { + this.amount =3D amount; + this.currency =3D currency; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount =3D amount; + } + + public Currency getCurrency() { + return currency; + } + + public void setCurrency(Currency currency) { + this.currency =3D currency; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/MonetaryAmountUserType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/MonetaryAmountUserType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/MonetaryAmountUserType.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,106 @@ +//$Id: MonetaryAmountUserType.java 14736 2008-06-04 14:23:42Z hardy.ferent= schik $ +package org.hibernate.test.annotations.entity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Currency; + +import org.hibernate.Hibernate; +import org.hibernate.HibernateException; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.type.Type; +import org.hibernate.usertype.CompositeUserType; + +/** + * @author Emmanuel Bernard + */ +public class MonetaryAmountUserType implements CompositeUserType { + + public String[] getPropertyNames() { + return new String[]{"amount", "currency"}; + } + + public Type[] getPropertyTypes() { + return new Type[]{Hibernate.BIG_DECIMAL, Hibernate.CURRENCY}; + } + + public Object getPropertyValue(Object component, int property) throws Hib= ernateException { + MonetaryAmount ma =3D (MonetaryAmount) component; + return property =3D=3D 0 ? (Object) ma.getAmount() : (Object) ma.getCurr= ency(); + } + + public void setPropertyValue(Object component, int property, Object value) + throws HibernateException { + MonetaryAmount ma =3D (MonetaryAmount) component; + if ( property =3D=3D 0 ) { + ma.setAmount( (BigDecimal) value ); + } + else { + ma.setCurrency( (Currency) value ); + } + } + + public Class returnedClass() { + return MonetaryAmount.class; + } + + public boolean equals(Object x, Object y) throws HibernateException { + if ( x =3D=3D y ) return true; + if ( x =3D=3D null || y =3D=3D null ) return false; + MonetaryAmount mx =3D (MonetaryAmount) x; + MonetaryAmount my =3D (MonetaryAmount) y; + return mx.getAmount().equals( my.getAmount() ) && + mx.getCurrency().equals( my.getCurrency() ); + } + + public int hashCode(Object x) throws HibernateException { + return ( (MonetaryAmount) x ).getAmount().hashCode(); + } + + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplemento= r session, Object owner) + throws HibernateException, SQLException { + BigDecimal amt =3D (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, n= ames[0] ); + Currency cur =3D (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1]= ); + if ( amt =3D=3D null ) return null; + return new MonetaryAmount( amt, cur ); + } + + public void nullSafeSet( + PreparedStatement st, Object value, int index, + SessionImplementor session + ) throws HibernateException, SQLException { + MonetaryAmount ma =3D (MonetaryAmount) value; + BigDecimal amt =3D ma =3D=3D null ? null : ma.getAmount(); + Currency cur =3D ma =3D=3D null ? null : ma.getCurrency(); + Hibernate.BIG_DECIMAL.nullSafeSet( st, amt, index ); + Hibernate.CURRENCY.nullSafeSet( st, cur, index + 1 ); + } + + public Object deepCopy(Object value) throws HibernateException { + MonetaryAmount ma =3D (MonetaryAmount) value; + return new MonetaryAmount( ma.getAmount(), ma.getCurrency() ); + } + + public boolean isMutable() { + return true; + } + + public Serializable disassemble(Object value, SessionImplementor session) + throws HibernateException { + return (Serializable) deepCopy( value ); + } + + public Object assemble(Serializable cached, SessionImplementor session, O= bject owner) + throws HibernateException { + return deepCopy( cached ); + } + + public Object replace(Object original, Object target, SessionImplementor = session, Object owner) + throws HibernateException { + return deepCopy( original ); //TODO: improve + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/PropertyDefaultMappingsTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/PropertyDefaultMappingsTest.java (re= v 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/PropertyDefaultMappingsTest.java 2009-11-24 21:03:15 UTC (re= v 18049) @@ -0,0 +1,62 @@ +//$Id: PropertyDefaultMappingsTest.java 14736 2008-06-04 14:23:42Z hardy.f= erentschik $ +package org.hibernate.test.annotations.entity; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class PropertyDefaultMappingsTest extends TestCase { + public PropertyDefaultMappingsTest(String x) { + super( x ); + } + + public void testSerializableObject() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Country c =3D new Country(); + c.setName( "France" ); + Address a =3D new Address(); + a.setCity( "Paris" ); + a.setCountry( c ); + s.persist( a ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Address reloadedAddress =3D (Address) s.get( Address.class, a.getId() ); + assertNotNull( reloadedAddress ); + assertNotNull( reloadedAddress.getCountry() ); + assertEquals( a.getCountry().getName(), reloadedAddress.getCountry().get= Name() ); + tx.rollback(); + s.close(); + } + + public void testTransientField() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + WashingMachine wm =3D new WashingMachine(); + wm.setActive( true ); + s.persist( wm ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + wm =3D (WashingMachine) s.get( WashingMachine.class, wm.getId() ); + assertFalse( "transient should not be persistent", wm.isActive() ); + s.delete( wm ); + tx.commit(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[]{ + Address.class, + WashingMachine.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Race.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Race.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Race.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +//$Id: Race.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Race implements Length { + private Long length; + private Integer id; + + @Id + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Long getLength() { + return length; + } + + public void setLength(Long length) { + this.length =3D length; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Ransom.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Ransom.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Ransom.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,61 @@ +//$Id: Ransom.java 15049 2008-08-13 15:32:32Z epbernard $ +package org.hibernate.test.annotations.entity; + +import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.annotations.Columns; +import org.hibernate.annotations.Type; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Ransom { + private Integer id; + private String kidnapperName; + private MonetaryAmount amount; + private Date date; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getKidnapperName() { + return kidnapperName; + } + + public void setKidnapperName(String kidnapperName) { + this.kidnapperName =3D kidnapperName; + } + + @Type(type =3D "org.hibernate.test.annotations.entity.MonetaryAmountUserT= ype") + @Columns(columns =3D { + @Column(name =3D "r_amount"), + @Column(name =3D "r_currency") + }) + public MonetaryAmount getAmount() { + return amount; + } + + public void setAmount(MonetaryAmount amount) { + this.amount =3D amount; + } + @Column(name=3D"ransom_date") + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date =3D date; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Starred.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Starred.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Starred.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,10 @@ +package org.hibernate.test.annotations.entity; + +/** + * @author Emmanuel Bernard + */ +public enum Starred { + BAD, + OK, + GOOD +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/Tree.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Tree.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/Tree.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,38 @@ +//$Id: Tree.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.annotations.Proxy; + +/** + * Non lazy entity + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)Proxy(lazy =3D false) +public class Tree { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/WashingMachine.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/WashingMachine.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/WashingMachine.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: WashingMachine.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class WashingMachine { + @Id + @GeneratedValue + private Integer id; + private transient boolean isActive; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public boolean isActive() { + return isActive; + } + + public void setActive(boolean active) { + isActive =3D active; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/ZipCode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/ZipCode.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/ZipCode.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,19 @@ +//$Id: ZipCode.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entity; + +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * @author Emmanuel Bernard + */ +(a)Cache(usage =3D CacheConcurrencyStrategy.READ_ONLY) +(a)Entity +(a)org.hibernate.annotations.Entity(mutable =3D false) +public class ZipCode { + @Id + public String code; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entity/package-info.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/package-info.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entity/package-info.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +/** + * Test package for metatata facilities + * It contains an example of filter metadata + */ +(a)FilterDefs( + { + @FilterDef( + name =3D "betweenLength", + defaultCondition =3D ":minLength <=3D length and :maxLength >=3D lengt= h", + parameters =3D { + @ParamDef(name =3D "minLength", type =3D "integer"), + @ParamDef(name =3D "maxLength", type =3D "integer") + } + ) + } +) +(a)TypeDefs( + { + @TypeDef( + name =3D "caster", + typeClass =3D CasterStringType.class, + parameters =3D { + @Parameter(name =3D "cast", value =3D "lower") + } + ) + } +) package org.hibernate.test.annotations.entity; + +import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.FilterDefs; +import org.hibernate.annotations.ParamDef; +import org.hibernate.annotations.Parameter; +import org.hibernate.annotations.TypeDef; +import org.hibernate.annotations.TypeDefs; Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entitynonentity/Cellular.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/Cellular.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/Cellular.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,9 @@ +//$Id: Cellular.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entitynonentity; + +/** + * @author Emmanuel Bernard + */ +public class Cellular extends Phone { + String brand; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entitynonentity/Communication.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/Communication.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/Communication.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,9 @@ +//$Id: Communication.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entitynonentity; + +/** + * @author Emmanuel Bernard + */ +public class Communication extends Interaction { + String species; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entitynonentity/EntityNonEntityTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/EntityNonEntityTest.java (r= ev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/EntityNonEntityTest.java 2009-11-24 21:03:15 UTC (r= ev 18049) @@ -0,0 +1,43 @@ +//$Id: EntityNonEntityTest.java 14736 2008-06-04 14:23:42Z hardy.ferentsch= ik $ +package org.hibernate.test.annotations.entitynonentity; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class EntityNonEntityTest extends TestCase { + public void testMix() throws Exception { + GSM gsm =3D new GSM(); + gsm.brand =3D "Sony"; + gsm.frequency =3D 900; + gsm.isNumeric =3D true; + gsm.number =3D 2; + gsm.species =3D "human"; + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist( gsm ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + gsm =3D (GSM) s.get( GSM.class, gsm.id ); + assertEquals( "top mapped superclass", 2, gsm.number ); + assertNull( "non entity between mapped superclass and entity", gsm.speci= es ); + assertTrue( "mapped superclass under entity", gsm.isNumeric ); + assertNull( "non entity under entity", gsm.brand ); + assertEquals( "leaf entity", 900, gsm.frequency ); + s.delete( gsm ); + tx.commit(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[]{ + Phone.class, + Voice.class, + GSM.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entitynonentity/GSM.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/GSM.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/GSM.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,12 @@ +//$Id: GSM.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entitynonentity; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class GSM extends Cellular { + int frequency; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entitynonentity/Interaction.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/Interaction.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/Interaction.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,14 @@ +//$Id: Interaction.java 15049 2008-08-13 15:32:32Z epbernard $ +package org.hibernate.test.annotations.entitynonentity; + +import javax.persistence.MappedSuperclass; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Interaction { + @Column(name=3D"int_nbr") + public int number; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entitynonentity/Phone.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/Phone.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/Phone.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,12 @@ +//$Id: Phone.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entitynonentity; + +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Phone extends Voice { + boolean isNumeric; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/entitynonentity/Voice.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/Voice.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/entitynonentity/Voice.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,19 @@ +//$Id: Voice.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.entitynonentity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +public class Voice extends Communication { + @Id + @GeneratedValue + public Integer id; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fetch/Branch.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fetch/Branch.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fetch/Branch.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,40 @@ +//$Id: Branch.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.fetch; + +import java.util.Set; +import java.util.HashSet; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.OneToMany; +import javax.persistence.Entity; +import javax.persistence.FetchType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Branch { + @Id + @GeneratedValue + private Integer id; + + @OneToMany(mappedBy =3D "branch", fetch =3D FetchType.EAGER ) + private Set leaves =3D new HashSet(); + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Set getLeaves() { + return leaves; + } + + public void setLeaves(Set leaves) { + this.leaves =3D leaves; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fetch/FetchingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fetch/FetchingTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fetch/FetchingTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,125 @@ +//$Id: FetchingTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.fetch; + +import java.util.Date; + +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class FetchingTest extends TestCase { + public void testLazy() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Person p =3D new Person( "Gavin", "King", "JBoss Inc" ); + Stay stay =3D new Stay( p, new Date(), new Date(), "A380", "Blah", "Blah= " ); + p.addStay( stay ); + s.persist( p ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + p =3D (Person) s.createQuery( "from Person p where p.firstName =3D :name= " ) + .setParameter( "name", "Gavin" ).uniqueResult(); + assertFalse( Hibernate.isInitialized( p.getStays() ) ); + s.delete( p ); + tx.commit(); + s.close(); + } + + public void testExtraLazy() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Person p =3D new Person( "Gavin", "King", "JBoss Inc" ); + Stay stay =3D new Stay( p, new Date(), new Date(), "A380", "Blah", "Blah= " ); + p.getOrderedStay().add( stay ); + s.persist( p ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + p =3D (Person) s.createQuery( "from Person p where p.firstName =3D :name= " ) + .setParameter( "name", "Gavin" ).uniqueResult(); + assertFalse( Hibernate.isInitialized( p.getOrderedStay() ) ); + assertEquals( 1, p.getOrderedStay().size() ); + assertFalse( Hibernate.isInitialized( p.getOrderedStay() ) ); + assertEquals( "A380", p.getOrderedStay().get(0).getVessel() ); + assertFalse( Hibernate.isInitialized( p.getOrderedStay() ) ); + s.delete( p ); + tx.commit(); + s.close(); + } + + public void testHibernateFetchingLazy() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Person p =3D new Person( "Gavin", "King", "JBoss Inc" ); + Stay stay =3D new Stay( null, new Date(), new Date(), "A380", "Blah", "B= lah" ); + Stay stay2 =3D new Stay( null, new Date(), new Date(), "A320", "Blah", "= Blah" ); + Stay stay3 =3D new Stay( null, new Date(), new Date(), "A340", "Blah", "= Blah" ); + stay.setOldPerson( p ); + stay2.setVeryOldPerson( p ); + stay3.setVeryOldPerson( p ); + p.addOldStay( stay ); + p.addVeryOldStay( stay2 ); + p.addVeryOldStay( stay3 ); + s.persist( p ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + p =3D (Person) s.createQuery( "from Person p where p.firstName =3D :name= " ) + .setParameter( "name", "Gavin" ).uniqueResult(); + assertFalse( Hibernate.isInitialized( p.getOldStays() ) ); + assertEquals( 1, p.getOldStays().size() ); + assertFalse( "lazy extra is failing", Hibernate.isInitialized( p.getOldS= tays() ) ); + s.clear(); + stay =3D (Stay) s.get( Stay.class, stay.getId() ); + assertTrue( ! Hibernate.isInitialized( stay.getOldPerson() ) ); + s.clear(); + stay3 =3D (Stay) s.get( Stay.class, stay3.getId() ); + assertTrue( "FetchMode.JOIN should overrides lazy options", Hibernate.is= Initialized( stay3.getVeryOldPerson() ) ); + s.delete( stay3.getVeryOldPerson() ); + tx.commit(); + s.close(); + } + + public void testOneToManyFetchEager() throws Exception { + Branch b =3D new Branch(); + Session s =3D openSession( ); + s.getTransaction().begin(); + s.persist( b ); + s.flush(); + Leaf l =3D new Leaf(); + l.setBranch( b ); + s.persist( l ); + s.flush(); + + s.clear(); + + s.createCriteria( Branch.class ).list(); + + s.getTransaction().rollback(); + s.close(); + } + + public FetchingTest(String x) { + super( x ); + } + + protected Class[] getMappings() { + return new Class[]{ + Person.class, + Stay.class, + Branch.class, + Leaf.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fetch/Leaf.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fetch/Leaf.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fetch/Leaf.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,37 @@ +//$Id: Leaf.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.fetch; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Leaf { + @Id + @GeneratedValue + private Integer id; + + @ManyToOne + private Branch branch; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Branch getBranch() { + return branch; + } + + public void setBranch(Branch branch) { + this.branch =3D branch; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fetch/Person.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fetch/Person.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fetch/Person.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,176 @@ +//$Id: Person.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.fetch; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; +import org.hibernate.annotations.IndexColumn; + + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "Person") +public class Person implements Serializable { + + // member declaration + private int id; + private String firstName; + private String lastName; + private String companyName; + private Collection stays; + private Collection oldStays; + private Collection veryOldStays; + private List orderedStay =3D new ArrayList(); + + // constructors + public Person() { + } + + public Person(String firstName, String lastName, String companyName) { + this.firstName =3D firstName; + this.lastName =3D lastName; + this.companyName =3D companyName; + } + + // properties + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String companyName) { + this.companyName =3D companyName; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName =3D firstName; + } + + @Id + @GeneratedValue + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName =3D lastName; + } + + // relationships + + @OneToMany(cascade =3D CascadeType.ALL, fetch =3D FetchType.LAZY, mappedB= y =3D "person") + public Collection getStays() { + return this.stays; + } + + public void setStays(List stays) { + this.stays =3D stays; + } + + @OneToMany(cascade=3DCascadeType.ALL, mappedBy =3D "oldPerson") + @LazyCollection(LazyCollectionOption.EXTRA) + @Fetch(FetchMode.SUBSELECT) + public Collection getOldStays() { + return oldStays; + } + + public void setOldStays(Collection oldStays) { + this.oldStays =3D oldStays; + } + + @OneToMany(cascade=3DCascadeType.ALL, mappedBy =3D "veryOldPerson") + @Fetch(FetchMode.SELECT) + public Collection getVeryOldStays() { + return veryOldStays; + } + + public void setVeryOldStays(Collection veryOldStays) { + this.veryOldStays =3D veryOldStays; + } + + @OneToMany(cascade=3DCascadeType.ALL) + @LazyCollection(LazyCollectionOption.EXTRA) + @Fetch(FetchMode.SUBSELECT) + @IndexColumn(name=3D"orderedStayIndex") + public List getOrderedStay() { + return orderedStay; + } + + public void setOrderedStay(List orderedStay) { + this.orderedStay =3D orderedStay; + } + + + // business logic + public void addStay(Date startDate, Date endDate, String vessel, String a= uthoriser, String comments) { + Stay stay =3D new Stay( this, startDate, endDate, vessel, authoriser, co= mments ); + addStay( stay ); + } + + public void addStay(Stay stay) { + Collection stays =3D getStays(); + if ( stays =3D=3D null ) { + stays =3D new ArrayList(); + } + stays.add( stay ); + + this.stays =3D stays; + } + + public void addOldStay(Date startDate, Date endDate, String vessel, Strin= g authoriser, String comments) { + Stay stay =3D new Stay( this, startDate, endDate, vessel, authoriser, co= mments ); + addOldStay( stay ); + } + + public void addOldStay(Stay stay) { + Collection stays =3D getOldStays(); + if ( stays =3D=3D null ) { + stays =3D new ArrayList(); + } + stays.add( stay ); + + this.oldStays =3D stays; + } + + public void addVeryOldStay(Date startDate, Date endDate, String vessel, S= tring authoriser, String comments) { + Stay stay =3D new Stay( this, startDate, endDate, vessel, authoriser, co= mments ); + addVeryOldStay( stay ); + } + + public void addVeryOldStay(Stay stay) { + Collection stays =3D getVeryOldStays(); + if ( stays =3D=3D null ) { + stays =3D new ArrayList(); + } + stays.add( stay ); + + this.veryOldStays =3D stays; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fetch/Stay.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fetch/Stay.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fetch/Stay.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,143 @@ +//$Id: Stay.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.fetch; + +import java.io.Serializable; +import java.util.Date; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import org.hibernate.annotations.LazyToOne; +import org.hibernate.annotations.LazyToOneOption; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "Stay") +public class Stay implements Serializable { + + // member declaration + private int id; + private Person person; + private Person oldPerson; + private Person veryOldPerson; + private Date startDate; + private Date endDate; + private String vessel; + private String authoriser; + private String comments; + + + // constructors + public Stay() { + } + + public Stay(int id) { + this.id =3D id; + } + + public Stay(Person person, Date startDate, Date endDate, String vessel, S= tring authoriser, String comments) { + this.authoriser =3D authoriser; + this.endDate =3D endDate; + this.person =3D person; + this.startDate =3D startDate; + this.vessel =3D vessel; + this.comments =3D comments; + } + + + // properties + public String getAuthoriser() { + return authoriser; + } + + public void setAuthoriser(String authoriser) { + this.authoriser =3D authoriser; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments =3D comments; + } + + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate =3D endDate; + } + + @Id + @GeneratedValue + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + @ManyToOne(cascade =3D CascadeType.ALL, fetch =3D FetchType.LAZY) + @JoinColumn(name =3D "person") + public Person getPerson() { + return person; + } + + public void setPerson(Person person) { + this.person =3D person; + } + + @ManyToOne(cascade =3D CascadeType.ALL) + @LazyToOne(LazyToOneOption.PROXY) + @Fetch(FetchMode.SELECT) + @JoinColumn(name =3D "oldperson") + public Person getOldPerson() { + return oldPerson; + } + + public void setOldPerson(Person oldPerson) { + this.oldPerson =3D oldPerson; + } + + @ManyToOne(cascade =3D CascadeType.ALL, fetch =3D FetchType.LAZY) + @LazyToOne(LazyToOneOption.PROXY) + @Fetch(FetchMode.JOIN) + @JoinColumn(name =3D "veryoldperson") + public Person getVeryOldPerson() { + return veryOldPerson; + } + + public void setVeryOldPerson(Person veryOldPerson) { + this.veryOldPerson =3D veryOldPerson; + } + + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate) { + this.startDate =3D startDate; + } + + public String getVessel() { + return vessel; + } + + public void setVessel(String vessel) { + this.vessel =3D vessel; + } + + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/A.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/A.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/A.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +// $Id: A.java 14777 2008-06-18 17:47:30Z hardy.ferentschik $ +package org.hibernate.test.annotations.fkcircularity; + +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; + +/** + * Test entities ANN-722. + * = + * @author Hardy Ferentschik + * + */ +(a)Entity +public class A { + private A_PK id; + + @EmbeddedId + public A_PK getId() { + return id; + } + + public void setId(A_PK id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/A_PK.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/A_PK.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/A_PK.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +// $Id: A_PK.java 14777 2008-06-18 17:47:30Z hardy.ferentschik $ +package org.hibernate.test.annotations.fkcircularity; + +import java.io.Serializable; + +import javax.persistence.ManyToOne; + +/** + * Test entities ANN-722. + * = + * @author Hardy Ferentschik + * + */ +(a)SuppressWarnings("serial") +public class A_PK implements Serializable { + public D d; + + @ManyToOne + public D getD() { + return d; + } + + public void setD(D d) { + this.d =3D d; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/B.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/B.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/B.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,28 @@ +// $Id: B.java 14777 2008-06-18 17:47:30Z hardy.ferentschik $ +package org.hibernate.test.annotations.fkcircularity; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +/** + * Test entities ANN-722. + * = + * @author Hardy Ferentschik + * + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +public class B { + @Id + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/C.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/C.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/C.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,14 @@ +// $Id: C.java 14777 2008-06-18 17:47:30Z hardy.ferentschik $ +package org.hibernate.test.annotations.fkcircularity; + +import javax.persistence.Entity; + +/** + * Test entities ANN-722. + * = + * @author Hardy Ferentschik + * + */ +(a)Entity +public class C extends B { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/ClassA.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/ClassA.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/ClassA.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +// $Id: ClassA.java 14777 2008-06-18 17:47:30Z hardy.ferentschik $ +package org.hibernate.test.annotations.fkcircularity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; + +/** + * Test entities ANN-730. + * = + * @author Hardy Ferentschik + * = + */ +(a)Entity +(a)Table(name =3D "class_a") +(a)Inheritance(strategy =3D InheritanceType.JOINED) +public class ClassA { + + private int id; + + @Id + @Column(name =3D "id") + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/ClassB.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/ClassB.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/ClassB.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,18 @@ +// $Id: ClassB.java 14777 2008-06-18 17:47:30Z hardy.ferentschik $ +package org.hibernate.test.annotations.fkcircularity; + +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.Table; + +/** + * Test entities ANN-730. + * = + * @author Hardy Ferentschik + * = + */ +(a)Entity +(a)Table(name =3D "class_b") +(a)PrimaryKeyJoinColumn(name =3D "id", referencedColumnName =3D "id") +public class ClassB extends ClassA { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/ClassC.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/ClassC.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/ClassC.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,18 @@ +// $Id: ClassC.java 14777 2008-06-18 17:47:30Z hardy.ferentschik $ +package org.hibernate.test.annotations.fkcircularity; + +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.Table; + +/** + * Test entities ANN-730. + * = + * @author Hardy Ferentschik + * = + */ +(a)Entity +(a)Table(name =3D "class_c") +(a)PrimaryKeyJoinColumn(name =3D "id", referencedColumnName =3D "id") +public class ClassC extends ClassB { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/ClassD.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/ClassD.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/ClassD.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,18 @@ +// $Id: ClassD.java 14777 2008-06-18 17:47:30Z hardy.ferentschik $ +package org.hibernate.test.annotations.fkcircularity; + +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.Table; + +/** + * Test entities ANN-730. + * = + * @author Hardy Ferentschik + * + */ +(a)Entity +(a)Table(name =3D "class_1d") +(a)PrimaryKeyJoinColumn(name =3D "id", referencedColumnName =3D "id") +public class ClassD extends ClassC { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/D.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/D.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/D.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +// $Id: D.java 14777 2008-06-18 17:47:30Z hardy.ferentschik $ +package org.hibernate.test.annotations.fkcircularity; + +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; + +/** + * Test entities ANN-722. + * = + * @author Hardy Ferentschik + * + */ +(a)Entity +public class D { + private D_PK id; + + @EmbeddedId + public D_PK getId() { + return id; + } + + public void setId(D_PK id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/D_PK.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/D_PK.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/D_PK.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +// $Id: D_PK.java 14777 2008-06-18 17:47:30Z hardy.ferentschik $ +package org.hibernate.test.annotations.fkcircularity; + +import java.io.Serializable; + +import javax.persistence.ManyToOne; + +/** + * Test entities ANN-722. + * = + * @author Hardy Ferentschik + * + */ +(a)SuppressWarnings("serial") +public class D_PK implements Serializable{ + private C c; + = + @ManyToOne + public C getC() { + return c; + } + + public void setC(C c) { + this.c =3D c; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/fkcircularity/FkCircularityTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/FkCircularityTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/fkcircularity/FkCircularityTest.java 2009-11-24 21:03:15 UTC (rev 1= 8049) @@ -0,0 +1,67 @@ +// $Id: FkCircularityTest.java 14777 2008-06-18 17:47:30Z hardy.ferentschi= k $ +package org.hibernate.test.annotations.fkcircularity; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import junit.framework.TestCase; + +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.dialect.HSQLDialect; +import org.hibernate.dialect.SQLServerDialect; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Test case for ANN-722 and ANN-730. + * = + * @author Hardy Ferentschik + */ +public class FkCircularityTest extends TestCase { + + private Logger log =3D LoggerFactory.getLogger(FkCircularityTest.class); + + public void testJoinedSublcassesInPK() { + try { + AnnotationConfiguration config =3D new AnnotationConfiguration(); + config.addAnnotatedClass(A.class); + config.addAnnotatedClass(B.class); + config.addAnnotatedClass(C.class); + config.addAnnotatedClass(D.class); + config.buildSessionFactory(); + String[] schema =3D config + .generateSchemaCreationScript(new SQLServerDialect()); + for (String s : schema) { + log.debug(s); + } + log.debug("success"); + } catch (Exception e) { + StringWriter writer =3D new StringWriter(); + e.printStackTrace(new PrintWriter(writer)); + log.debug(writer.toString()); + fail(e.getMessage()); + } + } + + public void testDeepJoinedSuclassesHierachy() { + try { + AnnotationConfiguration config =3D new AnnotationConfiguration(); + config.addAnnotatedClass(ClassA.class); + config.addAnnotatedClass(ClassB.class); + config.addAnnotatedClass(ClassC.class); + config.addAnnotatedClass(ClassD.class); + config.buildSessionFactory(); + String[] schema =3D config + .generateSchemaCreationScript(new HSQLDialect()); + for (String s : schema) { + log.debug(s); + } + log.debug("success"); + } catch (Exception e) { + StringWriter writer =3D new StringWriter(); + e.printStackTrace(new PrintWriter(writer)); + log.debug(writer.toString()); + fail(e.getMessage()); + } + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/Classes.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Classes.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Classes.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,47 @@ +package org.hibernate.test.annotations.generics; + +/** + * A test case for ANN-494. + * + * @author Edward Costello + * @author Paolo Perrotta + */ +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Embeddable; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +import org.hibernate.annotations.CollectionOfElements; + +public class Classes { + + @Embeddable + public static class Edition { + T name; + } + = + @Entity + public static class Book { + @Id + @GeneratedValue(strategy=3DGenerationType.AUTO) + Long id; + = + @Embedded + Edition edition; + } + = + @Entity + public static class PopularBook { + @Id + @GeneratedValue(strategy=3DGenerationType.AUTO) + Long id; + = + @CollectionOfElements + Set> editions =3D new HashSet>(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/DNA.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/DNA.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/DNA.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +//$Id: DNA.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Paolo Perrotta + */ +(a)Entity +public class DNA { + + private Integer id; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/Dummy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Dummy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Dummy.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,36 @@ +//$ +package org.hibernate.test.annotations.generics; + +import javax.persistence.Transient; +import javax.persistence.Id; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Dummy { + + @Id + private Long id; + + @Transient + transient private K dummyField; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public K getDummyField() { + return dummyField; + } + + public void setDummyField(K dummyField) { + this.dummyField =3D dummyField; + } + +} = \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/EmbeddedGenericsTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/EmbeddedGenericsTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/EmbeddedGenericsTest.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,73 @@ +package org.hibernate.test.annotations.generics; + +/** + * A test case for ANN-494. + * + * @author Edward Costello + * @author Paolo Perrotta + */ +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +public class EmbeddedGenericsTest extends TestCase { + + Session session; + Classes.Edition edition; + + public void setUp() throws Exception { + super.setUp(); + session =3D openSession(); + session.getTransaction().begin(); + edition =3D new Classes.Edition(); + edition.name =3D "Second"; + } + + public void testWorksWithGenericEmbedded() { + Classes.Book b =3D new Classes.Book(); + b.edition =3D edition; + persist( b ); + = + Classes.Book retrieved =3D (Classes.Book)find( Classes.Book.class, b.id = ); + assertEquals( "Second", retrieved.edition.name ); + = + clean( Classes.Book.class, b.id ); + session.close(); + } + + public void testWorksWithGenericCollectionOfElements() { + Classes.PopularBook b =3D new Classes.PopularBook(); + b.editions.add( edition ); + persist( b ); + + Classes.PopularBook retrieved =3D (Classes.PopularBook)find( Classes.Pop= ularBook.class, b.id ); + assertEquals( "Second", retrieved.editions.iterator().next().name ); + + clean( Classes.PopularBook.class, b.id ); + session.close(); + } + + protected Class[] getMappings() { + return new Class[]{ + Classes.Book.class, + Classes.PopularBook.class + }; + } + + private void persist(Object data) { + session.persist( data ); + session.getTransaction().commit(); + session.clear(); + } + = + private Object find(Class clazz, Long id) { + return session.get( clazz, id ); + } + + private void clean(Class clazz, Long id) { + Transaction tx =3D session.beginTransaction(); + session.delete( find( clazz, id ) ); + tx.commit(); + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/Gene.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Gene.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Gene.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,45 @@ +package org.hibernate.test.annotations.generics; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.Type; + +/** + * @author Paolo Perrotta + */ +(a)Entity +public class Gene { + + private Integer id; + private STE state; + + @Type(type=3D"org.hibernate.test.annotations.generics.StateType") + public STE getState() { + return state; + } + + public void setState(STE state) { + this.state =3D state; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @ManyToOne(targetEntity =3D DNA.class) + public T getGeneticCode() { + return null; + } + + public void setGeneticCode(T gene) { + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/GenericsTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/GenericsTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/GenericsTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,63 @@ +//$Id: GenericsTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class GenericsTest extends TestCase { + public void testManyToOneGenerics() throws Exception { + Paper white =3D new Paper(); + white.setName( "WhiteA4" ); + PaperType type =3D new PaperType(); + type.setName( "A4" ); + SomeGuy me =3D new SomeGuy(); + white.setType( type ); + white.setOwner( me ); + Price price =3D new Price(); + price.setAmount( new Double( 1 ) ); + price.setCurrency( "Euro" ); + white.setValue( price ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist( type ); + s.persist( price ); + s.persist( me ); + s.persist( white ); + tx.commit(); + //s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + white =3D (Paper) s.get( Paper.class, white.getId() ); + s.delete( white.getType() ); + s.delete( white.getOwner() ); + s.delete( white.getValue() ); + s.delete( white ); + tx.commit(); + //s.close(); + } + + @Override + protected void configure(Configuration cfg) { + cfg.setProperty( Environment.AUTO_CLOSE_SESSION, "true" ); + super.configure( cfg ); + } + + protected Class[] getMappings() { + return new Class[]{ + Paper.class, + PaperType.class, + SomeGuy.class, + Price.class, + WildEntity.class, + + //test at deployment only test unbound property when default field acc= ess is used + Dummy.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/Item.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Item.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Item.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,54 @@ +//$Id: Item.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Item extends PricedStuff { + private Integer id; + private String name; + private Type type; + private Owner owner; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToOne + public Type getType() { + return type; + } + + public void setType(Type type) { + this.type =3D type; + } + + @ManyToOne + public Owner getOwner() { + return owner; + } + + public void setOwner(Owner owner) { + this.owner =3D owner; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/Paper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Paper.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Paper.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ +//$Id: Paper.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Paper extends Item { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/PaperType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/PaperType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/PaperType.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: PaperType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class PaperType { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/Price.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Price.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Price.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,42 @@ +//$Id: Price.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Price { + private Integer id; + private Double amount; + private String currency; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Double getAmount() { + return amount; + } + + public void setAmount(Double amount) { + this.amount =3D amount; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency =3D currency; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/PricedStuff.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/PricedStuff.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/PricedStuff.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ +//$Id: PricedStuff.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class PricedStuff extends Stuff { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/SomeGuy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/SomeGuy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/SomeGuy.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$Id: SomeGuy.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class SomeGuy { + private Integer id; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/State.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/State.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/State.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,10 @@ +//$Id: State.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +/** + * @author Emmanuel Bernard + */ +public enum State { + ACTIVE, + DORMANT +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/StateType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/StateType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/StateType.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,69 @@ +//$Id: StateType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import java.io.Serializable; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.PreparedStatement; +import java.sql.Types; + +import org.hibernate.usertype.UserType; +import org.hibernate.HibernateException; + +/** + * @author Emmanuel Bernard + */ +public class StateType implements UserType { + public int[] sqlTypes() { + return new int[] { + Types.INTEGER + }; + } + + public Class returnedClass() { + return State.class; + } + + public boolean equals(Object x, Object y) throws HibernateException { + return x =3D=3D y; + } + + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + + public Object nullSafeGet(ResultSet rs, String[] names, Object owner) thr= ows HibernateException, SQLException { + int result =3D rs.getInt( names[0] ); + if ( rs.wasNull() ) return null; + return State.values()[result]; + } + + public void nullSafeSet(PreparedStatement st, Object value, int index) th= rows HibernateException, SQLException { + if (value =3D=3D null) { + st.setNull( index, Types.INTEGER ); + } + else { + st.setInt( index, ( (State) value ).ordinal() ); + } + } + + public Object deepCopy(Object value) throws HibernateException { + return value; + } + + public boolean isMutable() { + return false; + } + + public Serializable disassemble(Object value) throws HibernateException { + return (Serializable) value; + } + + public Object assemble(Serializable cached, Object owner) throws Hibernat= eException { + return cached; + } + + public Object replace(Object original, Object target, Object owner) throw= s HibernateException { + return original; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/Stuff.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Stuff.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/Stuff.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: Stuff.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import javax.persistence.ManyToOne; +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Stuff { + private Value value; + + @ManyToOne + public Value getValue() { + return value; + } + + public void setValue(Value value) { + this.value =3D value; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/UnresolvedTypeTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/UnresolvedTypeTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/UnresolvedTypeTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,43 @@ +package org.hibernate.test.annotations.generics; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Paolo Perrotta + */ +public class UnresolvedTypeTest extends TestCase { + + public void testAcceptsUnresolvedPropertyTypesIfATargetEntityIsExplicitly= Set() { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Gene item =3D new Gene(); + s.persist( item ); + s.flush(); + tx.rollback(); + s.close(); + } + + public void testAcceptsUnresolvedPropertyTypesIfATypeExplicitlySet() { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Gene item =3D new Gene(); + item.setState( State.DORMANT ); + s.persist( item ); + s.flush(); + s.clear(); + item =3D (Gene) s.get( Gene.class, item.getId() ); + assertEquals( State.DORMANT, item.getState() ); + tx.rollback(); + s.close(); + } + + @Override + protected Class[] getMappings() { + return new Class[]{ + Gene.class, + DNA.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/generics/WildEntity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/WildEntity.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/generics/WildEntity.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,44 @@ +//$Id: WildEntity.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.generics; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Transient; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class WildEntity implements Serializable { + + private static final long serialVersionUID =3D -1171578628576139205L; + + private int id; + + private String property; + + @Id + @GeneratedValue + public int getId() { + return id; + } + + @Transient + public T someMethod() { + return null; + } + + public void setId(int id) { + this.id =3D id; + } + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property =3D property; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/genericsinheritance/Child.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/Child.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/Child.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +package org.hibernate.test.annotations.genericsinheritance; + +import javax.persistence.MappedSuperclass; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +(a)MappedSuperclass +public abstract class Child

{ + + @Id Long id; + @ManyToOne P parent; + = + public Long getId() { + return id; + } + public void setId(Long id) { + this.id =3D id; + } + public P getParent() { + return parent; + } + public void setParent(P parent) { + this.parent =3D parent; + } + = + = +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/genericsinheritance/ChildHierarchy1.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ChildHierarchy1.java (r= ev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ChildHierarchy1.java 2009-11-24 21:03:15 UTC (r= ev 18049) @@ -0,0 +1,8 @@ +package org.hibernate.test.annotations.genericsinheritance; + +import javax.persistence.Entity; + +(a)Entity +public class ChildHierarchy1 extends Child { + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/genericsinheritance/ChildHierarchy2.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ChildHierarchy2.java (r= ev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ChildHierarchy2.java 2009-11-24 21:03:15 UTC (r= ev 18049) @@ -0,0 +1,8 @@ +package org.hibernate.test.annotations.genericsinheritance; + +import javax.persistence.MappedSuperclass; + +(a)MappedSuperclass +public class ChildHierarchy2

extends Child

{ + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/genericsinheritance/ChildHierarchy22.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ChildHierarchy22.java (= rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ChildHierarchy22.java 2009-11-24 21:03:15 UTC (= rev 18049) @@ -0,0 +1,8 @@ +package org.hibernate.test.annotations.genericsinheritance; + +import javax.persistence.Entity; + +(a)Entity +public class ChildHierarchy22 extends ChildHierarchy2 { + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/genericsinheritance/GenericsInheritanceTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/GenericsInheritanceTest.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/GenericsInheritanceTest.java 2009-11-24 21:03:1= 5 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$Id: GenericsInheritanceTest.java 14736 2008-06-04 14:23:42Z hardy.feren= tschik $ +package org.hibernate.test.annotations.genericsinheritance; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; + +/** + * @author Emmanuel Bernard + */ +public class GenericsInheritanceTest extends TestCase { + public void testMapping() throws Exception { + Session s =3D openSession(); + s.close(); + //mapping is tested + } + protected Class[] getMappings() { + return new Class[] { + ChildHierarchy1.class, + ParentHierarchy1.class, + ChildHierarchy22.class, + ParentHierarchy22.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/genericsinheritance/Parent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/Parent.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/Parent.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +package org.hibernate.test.annotations.genericsinheritance; + +import java.util.HashMap; +import java.util.Map; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.MapKey; +import javax.persistence.MappedSuperclass; +import javax.persistence.OneToMany; + +(a)MappedSuperclass +public abstract class Parent { + + @Id @GeneratedValue Long id; + @MapKey @OneToMany(mappedBy=3D"parent") Map children =3D new Hash= Map(); + + = + public Long getId() { + return id; + } + public void setId(Long id) { + this.id =3D id; + } + = + = + public Map getChildren() { + return children; + } + public void setChildren(Map children) { + this.children =3D children; + } + = + = +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/genericsinheritance/ParentHierarchy1.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ParentHierarchy1.java (= rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ParentHierarchy1.java 2009-11-24 21:03:15 UTC (= rev 18049) @@ -0,0 +1,8 @@ +package org.hibernate.test.annotations.genericsinheritance; + +import javax.persistence.Entity; + +(a)Entity +public class ParentHierarchy1 extends Parent { + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/genericsinheritance/ParentHierarchy2.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ParentHierarchy2.java (= rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ParentHierarchy2.java 2009-11-24 21:03:15 UTC (= rev 18049) @@ -0,0 +1,8 @@ +package org.hibernate.test.annotations.genericsinheritance; + +import javax.persistence.MappedSuperclass; + +(a)MappedSuperclass +public class ParentHierarchy2 extends Parent= { + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/genericsinheritance/ParentHierarchy22.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ParentHierarchy22.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/genericsinheritance/ParentHierarchy22.java 2009-11-24 21:03:15 UTC = (rev 18049) @@ -0,0 +1,8 @@ +package org.hibernate.test.annotations.genericsinheritance; + +import javax.persistence.Entity; + +(a)Entity +public class ParentHierarchy22 extends ParentHierarchy2 { + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/hibernate.cfg.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/hibernate.cfg.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/hibernate.cfg.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/EnumIdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/EnumIdTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/EnumIdTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,62 @@ +//$Id: EnumIdTest.java 14785 2008-06-19 10:44:33Z hardy.ferentschik $ +package org.hibernate.test.annotations.id; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.id.entities.Planet; +import org.hibernate.test.annotations.id.entities.PlanetCheatSheet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Tests for enum type as id. + * = + * @author Hardy Ferentschik + * @see ANN-744 + */ +(a)SuppressWarnings("unchecked") +public class EnumIdTest extends TestCase { + + private Logger log =3D LoggerFactory.getLogger(EnumIdTest.class); = + = + public EnumIdTest(String x) { + super(x); + } + + public void testEnumAsId() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + PlanetCheatSheet mercury =3D new PlanetCheatSheet(); + mercury.setPlanet(Planet.MERCURY); + mercury.setMass(3.303e+23); + mercury.setRadius(2.4397e6); + mercury.setNumberOfInhabitants(0); + s.persist(mercury); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + PlanetCheatSheet mercuryFromDb =3D (PlanetCheatSheet) s.get(PlanetCheatS= heet.class, mercury.getPlanet()); + assertNotNull(mercuryFromDb); + log.debug(mercuryFromDb.toString()); + s.delete(mercuryFromDb); + tx.commit(); + s.close(); + = + s =3D openSession(); + tx =3D s.beginTransaction(); + mercury =3D (PlanetCheatSheet) s.get(PlanetCheatSheet.class, Planet.MERC= URY); + assertNull(mercury); + tx.commit(); + s.close(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[] { PlanetCheatSheet.class }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/IdClassTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/IdClassTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/IdClassTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,38 @@ +//$Id: IdClassTest.java 14784 2008-06-19 10:42:20Z hardy.ferentschik $ +package org.hibernate.test.annotations.id; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.id.entities.Location; +import org.hibernate.test.annotations.id.entities.Tower; + +/** + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("unchecked") +public class IdClassTest extends TestCase { + = + public void testIdClassInSuperclass() throws Exception { + Tower tower =3D new Tower(); + tower.latitude =3D 10.3; + tower.longitude =3D 45.4; + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist( tower ); + s.flush(); + s.clear(); + Location loc =3D new Location(); + loc.latitude =3D tower.latitude; + loc.longitude =3D tower.longitude; + assertNotNull( s.get( Tower.class, loc ) ); + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[]{ + Tower.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/IdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/IdTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/IdTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,301 @@ +//$Id: IdTest.java 17735 2009-10-14 05:15:33Z stliu $ +package org.hibernate.test.annotations.id; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.mapping.Column; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.id.entities.Ball; +import org.hibernate.test.annotations.id.entities.BreakDance; +import org.hibernate.test.annotations.id.entities.Computer; +import org.hibernate.test.annotations.id.entities.Department; +import org.hibernate.test.annotations.id.entities.Dog; +import org.hibernate.test.annotations.id.entities.FirTree; +import org.hibernate.test.annotations.id.entities.Footballer; +import org.hibernate.test.annotations.id.entities.FootballerPk; +import org.hibernate.test.annotations.id.entities.Furniture; +import org.hibernate.test.annotations.id.entities.GoalKeeper; +import org.hibernate.test.annotations.id.entities.Home; +import org.hibernate.test.annotations.id.entities.Monkey; +import org.hibernate.test.annotations.id.entities.Phone; +import org.hibernate.test.annotations.id.entities.Shoe; +import org.hibernate.test.annotations.id.entities.SoundSystem; +import org.hibernate.test.annotations.id.entities.Store; +import org.hibernate.test.annotations.id.entities.Tree; + +/** + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("unchecked") +public class IdTest extends TestCase { + public void testGenericGenerator() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + SoundSystem system =3D new SoundSystem(); + system.setBrand("Genelec"); + system.setModel("T234"); + Furniture fur =3D new Furniture(); + s.persist(system); + s.persist(fur); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + system =3D (SoundSystem) s.get(SoundSystem.class, system.getId()); + fur =3D (Furniture) s.get(Furniture.class, fur.getId()); + assertNotNull(system); + assertNotNull(fur); + s.delete(system); + s.delete(fur); + tx.commit(); + s.close(); + + } + + /* + * Ensures that GenericGenerator annotations wrapped inside a + * GenericGenerators holder are bound correctly + */ + public void testGenericGenerators() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Monkey monkey =3D new Monkey(); + s.persist(monkey); + s.flush(); + assertNotNull(monkey.getId()); + tx.rollback(); + s.close(); + } + + public void testTableGenerator() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + + Ball b =3D new Ball(); + Dog d =3D new Dog(); + Computer c =3D new Computer(); + s.persist(b); + s.persist(d); + s.persist(c); + tx.commit(); + s.close(); + assertEquals("table id not generated", new Integer(1), b.getId()); + assertEquals("generator should not be shared", new Integer(1), d + .getId()); + assertEquals("default value should work", new Long(1), c.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete(s.get(Ball.class, new Integer(1))); + s.delete(s.get(Dog.class, new Integer(1))); + s.delete(s.get(Computer.class, new Long(1))); + tx.commit(); + s.close(); + } + + public void testSequenceGenerator() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Shoe b =3D new Shoe(); + s.persist(b); + tx.commit(); + s.close(); + assertNotNull(b.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete(s.get(Shoe.class, b.getId())); + tx.commit(); + s.close(); + } + + public void testClassLevelGenerator() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Store b =3D new Store(); + s.persist(b); + tx.commit(); + s.close(); + assertNotNull(b.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete(s.get(Store.class, b.getId())); + tx.commit(); + s.close(); + } + + public void testMethodLevelGenerator() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Department b =3D new Department(); + s.persist(b); + tx.commit(); + s.close(); + assertNotNull(b.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete(s.get(Department.class, b.getId())); + tx.commit(); + s.close(); + } + + public void testDefaultSequence() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Home h =3D new Home(); + s.persist(h); + tx.commit(); + s.close(); + assertNotNull(h.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Home reloadedHome =3D (Home) s.get(Home.class, h.getId()); + assertEquals(h.getId(), reloadedHome.getId()); + s.delete(reloadedHome); + tx.commit(); + s.close(); + } + + public void testParameterizedAuto() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Home h =3D new Home(); + s.persist(h); + tx.commit(); + s.close(); + assertNotNull(h.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Home reloadedHome =3D (Home) s.get(Home.class, h.getId()); + assertEquals(h.getId(), reloadedHome.getId()); + s.delete(reloadedHome); + tx.commit(); + s.close(); + } + + public void testIdInEmbeddableSuperclass() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + FirTree chrismasTree =3D new FirTree(); + s.persist(chrismasTree); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + chrismasTree =3D (FirTree) s.get(FirTree.class, chrismasTree.getId()); + assertNotNull(chrismasTree); + s.delete(chrismasTree); + tx.commit(); + s.close(); + } + + public void testIdClass() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Footballer fb =3D new Footballer("David", "Beckam", "Arsenal"); + GoalKeeper keeper =3D new GoalKeeper("Fabien", "Bartez", "OM"); + s.persist(fb); + s.persist(keeper); + tx.commit(); + s.clear(); + + // lookup by id + tx =3D s.beginTransaction(); + FootballerPk fpk =3D new FootballerPk("David", "Beckam"); + fb =3D (Footballer) s.get(Footballer.class, fpk); + FootballerPk fpk2 =3D new FootballerPk("Fabien", "Bartez"); + keeper =3D (GoalKeeper) s.get(GoalKeeper.class, fpk2); + assertNotNull(fb); + assertNotNull(keeper); + assertEquals("Beckam", fb.getLastname()); + assertEquals("Arsenal", fb.getClub()); + assertEquals(1, s.createQuery( + "from Footballer f where f.firstname =3D 'David'").list().size()); + tx.commit(); + + // reattach by merge + tx =3D s.beginTransaction(); + fb.setClub("Bimbo FC"); + s.merge(fb); + tx.commit(); + + // reattach by saveOrUpdate + tx =3D s.beginTransaction(); + fb.setClub("Bimbo FC SA"); + s.saveOrUpdate(fb); + tx.commit(); + + // clean up + s.clear(); + tx =3D s.beginTransaction(); + fpk =3D new FootballerPk("David", "Beckam"); + fb =3D (Footballer) s.get(Footballer.class, fpk); + assertEquals("Bimbo FC SA", fb.getClub()); + s.delete(fb); + s.delete(keeper); + tx.commit(); + s.close(); + } + + public void testColumnDefinition() { + Column idCol =3D (Column) getCfg().getClassMapping(Ball.class.getName()) + .getIdentifierProperty().getValue().getColumnIterator().next(); + assertEquals("ball_id", idCol.getName()); + } + + public void testLowAllocationSize() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + int size =3D 4; + BreakDance[] bds =3D new BreakDance[size]; + for (int i =3D 0; i < size; i++) { + bds[i] =3D new BreakDance(); + s.persist(bds[i]); + } + s.flush(); + for (int i =3D 0; i < size; i++) { + assertEquals(i + 1, bds[i].id.intValue()); + } + tx.rollback(); + s.close(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[] { Ball.class, Shoe.class, Store.class, + Department.class, Dog.class, Computer.class, Home.class, + Phone.class, Tree.class, FirTree.class, Footballer.class, + SoundSystem.class, Furniture.class, GoalKeeper.class, + BreakDance.class, Monkey.class}; + } + + /** + * @see org.hibernate.test.annotations.TestCase#getAnnotatedPackages() + */ + protected String[] getAnnotatedPackages() { + return new String[] { "org.hibernate.test.annotations", + "org.hibernate.test.annotations.id" }; + } + + @Override + protected String[] getXmlFiles() { + return new String[] { "org/hibernate/test/annotations/orm.xml" }; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/JoinColumnOverrideTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/JoinColumnOverrideTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/JoinColumnOverrideTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,64 @@ +//$Id: JoinColumnOverrideTest.java 14761 2008-06-11 13:51:06Z hardy.ferent= schik $ +package org.hibernate.test.annotations.id; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.dialect.SQLServerDialect; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.id.entities.Bunny; +import org.hibernate.test.annotations.id.entities.PointyTooth; +import org.hibernate.test.annotations.id.entities.TwinkleToes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Tests for JIRA issue ANN-748. + * = + * @author Hardy Ferentschik + */ +(a)SuppressWarnings("unchecked") +public class JoinColumnOverrideTest extends TestCase { + + private Logger log =3D LoggerFactory.getLogger(JoinColumnOverrideTest.cla= ss); + = + public JoinColumnOverrideTest(String x) { + super(x); + } + + public void testBlownPrecision() throws Exception { + = + try { + AnnotationConfiguration config =3D new AnnotationConfiguration(); + config.addAnnotatedClass(Bunny.class); + config.addAnnotatedClass(PointyTooth.class); + config.addAnnotatedClass(TwinkleToes.class); + config.buildSessionFactory(); + String[] schema =3D config + .generateSchemaCreationScript(new SQLServerDialect()); + for (String s : schema) { + log.debug(s); + } + String expectedSqlPointyTooth =3D "create table PointyTooth (id numeric= (128,0) not null, " + + "bunny_id numeric(128,0) null, primary key (id))"; + assertEquals("Wrong SQL", expectedSqlPointyTooth, schema[1]); + = + String expectedSqlTwinkleToes =3D "create table TwinkleToes (id numeric= (128,0) not null, " + + "bunny_id numeric(128,0) null, primary key (id))"; + assertEquals("Wrong SQL", expectedSqlTwinkleToes, schema[2]); + } catch (Exception e) { + StringWriter writer =3D new StringWriter(); + e.printStackTrace(new PrintWriter(writer)); + log.debug(writer.toString()); + fail(e.getMessage()); + } = + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[] {}; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/UUIDGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/UUIDGenerator.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/UUIDGenerator.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +package org.hibernate.test.annotations.id; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.UUID; + +import org.hibernate.HibernateException; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.id.IdentifierGenerator; + +/** + * Unlike Hibernate's UUID generator. This avoids = + * meaningless synchronization and has less + * than a chance of an asteroid hitting you on the head + * even after trillions of rows are inserted. I know + * this to be true because it says so in Wikipedia(haha). + * http://en.wikipedia.org/wiki/UUID#Random_UUID_probability_of_duplicates + * + */ +public class UUIDGenerator implements IdentifierGenerator { + + public Serializable generate(SessionImplementor arg0, Object arg1) thr= ows HibernateException { + UUID uuid =3D UUID.randomUUID(); + String sud =3D uuid.toString(); + System.out.println("uuid=3D"+uuid); + sud =3D sud.replaceAll("-", ""); + = + BigInteger integer =3D new BigInteger(sud,16); + + System.out.println("bi =3D"+integer.toString() ); + return integer; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Ball.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Ball.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Ball.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: Ball.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.TableGenerator; + +/** + * Sample of table generator + * + * @author Emmanuel Bernard + */ +(a)TableGenerator(name =3D "EMP_GEN", table =3D "GENERATOR_TABLE", pkColum= nName =3D "pkey", + valueColumnName =3D "hi", pkColumnValue =3D "Ball", allocationSize =3D 1= 0) +(a)Entity +(a)SuppressWarnings("serial") +public class Ball implements Serializable { + private Integer id; + + @Id + @GeneratedValue(strategy =3D GenerationType.TABLE, generator =3D "EMP_GEN= ") + @Column(name =3D "ball_id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/BreakDance.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/BreakDance.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/BreakDance.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: BreakDance.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.TableGenerator; +import javax.persistence.GenerationType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class BreakDance { + @Id + @GeneratedValue(generator =3D "memencoIdGen", strategy =3D GenerationType= .TABLE) + @TableGenerator( + name =3D "memencoIdGen", + table =3D "hi_id_key", + pkColumnName =3D "id_key", + valueColumnName =3D "next_hi", + pkColumnValue =3D "issue", + allocationSize =3D 1 + ) + public Integer id; + public String name; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Bunny.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Bunny.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Bunny.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,46 @@ +//$Id: Bunny.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.GenericGenerator; + +/** + * Blown precision on related entity when @JoinColumn is used. + * = + * @see ANN-748 + * @author Andrew C. Oliver andyspam(a)osintegrators.com + */ +(a)Entity +(a)SuppressWarnings("serial") +public class Bunny implements Serializable { + @Id + @GeneratedValue(strategy =3D GenerationType.IDENTITY, generator =3D "java= 5_uuid") + @GenericGenerator(name =3D "java5_uuid", strategy =3D "org.hibernate.test= .annotations.id.UUIDGenerator") + @Column(name =3D "id", precision =3D 128, scale =3D 0) + private BigInteger id; + + @OneToMany(mappedBy =3D "bunny", cascade =3D { CascadeType.PERSIST }) + Set teeth; + = + @OneToMany(mappedBy =3D "bunny", cascade =3D { CascadeType.PERSIST }) + Set toes; + + public void setTeeth(Set teeth) { + this.teeth =3D teeth; + } + + public BigInteger getId() { + return id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Computer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Computer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Computer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: Computer.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity() +public class Computer { + private Long id; + private String serialNumber; + + @Id + @GeneratedValue(strategy =3D GenerationType.TABLE) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public String getSerialNumber() { + return serialNumber; + } + + public void setSerialNumber(String serialNumber) { + this.serialNumber =3D serialNumber; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Department.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Department.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Department.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,29 @@ +//$Id: Department.java 17735 2009-10-14 05:15:33Z stliu $ +package org.hibernate.test.annotations.id.entities; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * Sample of method generator + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)SuppressWarnings("serial") +public class Department implements Serializable { + private Long id; + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long long1) { + id =3D long1; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Dog.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Dog.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Dog.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,42 @@ +//$Id: Dog.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.TableGenerator; + +/** + * Share the generator table decribed by the GEN_TABLE GeneratedIdTable + * using the Dog key as discriminator + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_dog") +(a)TableGenerator(name =3D "DogGen", table =3D "GENERATOR_TABLE", pkColumn= Name =3D "pkey", + valueColumnName =3D "hi", pkColumnValue =3D "Dog", allocationSize =3D 10) +public class Dog { + private Integer id; + private String name; + + @Id + @GeneratedValue(strategy =3D GenerationType.TABLE, generator =3D "DogGen") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/FirTree.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/FirTree.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/FirTree.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ +//$Id: FirTree.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class FirTree extends Tree { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Footballer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Footballer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Footballer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,73 @@ +//$Id: Footballer.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.DiscriminatorColumn; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)IdClass(FootballerPk.class) +(a)DiscriminatorColumn(name =3D "bibi") +public class Footballer { + private String firstname; + private String lastname; + private String club; + + public Footballer() { + } + + public Footballer(String firstname, String lastname, String club) { + this.firstname =3D firstname; + this.lastname =3D lastname; + this.club =3D club; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Footballer ) ) return false; + + final Footballer footballer =3D (Footballer) o; + + if ( !firstname.equals( footballer.firstname ) ) return false; + if ( !lastname.equals( footballer.lastname ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D firstname.hashCode(); + result =3D 29 * result + lastname.hashCode(); + return result; + } + + @Id + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + @Id + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + public String getClub() { + return club; + } + + public void setClub(String club) { + this.club =3D club; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/FootballerPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/FootballerPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/FootballerPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,62 @@ +//$Id: FootballerPk.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +(a)SuppressWarnings("serial") +public class FootballerPk implements Serializable { + private String firstname; + private String lastname; + + @Column(name =3D "fb_fname") + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + public FootballerPk() { + } + + public FootballerPk(String firstname, String lastname) { + this.firstname =3D firstname; + this.lastname =3D lastname; + + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof FootballerPk ) ) return false; + + final FootballerPk footballerPk =3D (FootballerPk) o; + + if ( !firstname.equals( footballerPk.firstname ) ) return false; + if ( !lastname.equals( footballerPk.lastname ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D firstname.hashCode(); + result =3D 29 * result + lastname.hashCode(); + return result; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Furniture.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Furniture.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Furniture.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Furniture.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Parameter; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Furniture { + private Integer id; + + @Id + @GeneratedValue(generator =3D "hibseq") + @GenericGenerator(name =3D "hibseq", strategy =3D "seqhilo", + parameters =3D { + @Parameter(name =3D "max_lo", value =3D "5"), + @Parameter(name =3D "sequence", value =3D "heybabyhey") + } + ) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/GoalKeeper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/GoalKeeper.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/GoalKeeper.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,17 @@ +//$Id: GoalKeeper.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class GoalKeeper extends Footballer { + public GoalKeeper() { + } + + public GoalKeeper(String firstname, String lastname, String club) { + super( firstname, lastname, club ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Home.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Home.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Home.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +//$Id: Home.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * Default sequence generation usage + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Home { + private Long id; + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Location.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Location.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Location.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: Location.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import java.io.Serializable; + +/** + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("serial") +public class Location implements Serializable { + public double longitude; + public double latitude; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final Location location =3D (Location) o; + + if ( Double.compare( location.latitude, latitude ) !=3D 0 ) return false; + if ( Double.compare( location.longitude, longitude ) !=3D 0 ) return fal= se; + + return true; + } + + public int hashCode() { + int result; + long temp; + temp =3D longitude !=3D +0.0d ? Double.doubleToLongBits( longitude ) : 0= L; + result =3D (int) ( temp ^ ( temp >>> 32 ) ); + temp =3D latitude !=3D +0.0d ? Double.doubleToLongBits( latitude ) : 0L; + result =3D 29 * result + (int) ( temp ^ ( temp >>> 32 ) ); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/MilitaryBuilding.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/MilitaryBuilding.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/MilitaryBuilding.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,18 @@ +//$Id: MilitaryBuilding.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +(a)IdClass(Location.class) +public class MilitaryBuilding { + @Id + public double longitude; + @Id + public double latitude; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Monkey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Monkey.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Monkey.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Paul Cowan + */ +(a)Entity +public class Monkey { + private String id; + + @Id + @GeneratedValue(generator =3D "system-uuid-2") + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Phone.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Phone.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Phone.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$Id: Phone.java 17735 2009-10-14 05:15:33Z stliu $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity() +public class Phone { + private Integer id; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Planet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Planet.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Planet.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,6 @@ +// $Id: Planet.java 14785 2008-06-19 10:44:33Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +public enum Planet { + MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/PlanetCheatSheet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/PlanetCheatSheet.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/PlanetCheatSheet.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,85 @@ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.Id; + + +/** + * Test entity for enum type as id. + * = + * @author Hardy Ferentschik + * @see ANN-744 + */ +(a)Entity +public class PlanetCheatSheet { + + @Id + @Enumerated(EnumType.STRING) + @Column(name =3D "planet") + private Planet planet; + + private double mass; + + private double radius; + + private long numberOfInhabitants; + + public Planet getPlanet() { + return planet; + } + + public void setPlanet(Planet planet) { + this.planet =3D planet; + } + + public double getMass() { + return mass; + } + + public void setMass(double mass) { + this.mass =3D mass; + } + + public double getRadius() { + return radius; + } + + public void setRadius(double radius) { + this.radius =3D radius; + } + + public long getNumberOfInhabitants() { + return numberOfInhabitants; + } + + public void setNumberOfInhabitants(long numberOfInhabitants) { + this.numberOfInhabitants =3D numberOfInhabitants; + } + + /** + * Constructs a String with all attributes + * in name =3D value format. + * + * @return a String representation = + * of this object. + */ + public String toString() + { + final String TAB =3D " "; + = + String retValue =3D ""; + = + retValue =3D "PlanetCheatSheet ( " + + super.toString() + TAB + + "planet =3D " + this.planet + TAB + + "mass =3D " + this.mass + TAB + + "radius =3D " + this.radius + TAB + + "numberOfInhabitants =3D " + this.numberOfInhabitants + TAB + + " )"; + = + return retValue; + } = +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/PointyTooth.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/PointyTooth.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/PointyTooth.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,44 @@ +//$Id: PointyTooth.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import java.io.Serializable; +import java.math.BigInteger; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.GenericGenerator; + +/** + * Blown precision on related entity when @JoinColumn is used. = + * Does not cause an issue on HyperSonic, but replicates nicely on PGSQL. + * = + * @see ANN-748 + * @author Andrew C. Oliver andyspam(a)osintegrators.com + */ +(a)Entity +(a)SuppressWarnings("serial") +public class PointyTooth implements Serializable { + @Id + @GeneratedValue(strategy =3D GenerationType.IDENTITY, generator =3D "java= 5_uuid") + @GenericGenerator(name =3D "java5_uuid", strategy =3D "org.hibernate.test= .annotations.id.UUIDGenerator") + @Column(name =3D "id", precision =3D 128, scale =3D 0) + private BigInteger id; + + @ManyToOne + @JoinColumn(name =3D "bunny_id") + Bunny bunny; + + public void setBunny(Bunny bunny) { + this.bunny =3D bunny; + } + + public BigInteger getId() { + return id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Shoe.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Shoe.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Shoe.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,29 @@ +//$Id: Shoe.java 17735 2009-10-14 05:15:33Z stliu $ +package org.hibernate.test.annotations.id.entities; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * sample of Sequance generator + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)SuppressWarnings("serial") +public class Shoe implements Serializable { + private Long id; + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long long1) { + id =3D long1; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/SoundSystem.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/SoundSystem.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/SoundSystem.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,42 @@ +//$Id: SoundSystem.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class SoundSystem { + private String id; + private String brand; + private String model; + + @Id + @GeneratedValue(generator =3D "system-uuid") + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } + + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand =3D brand; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Store.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Store.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Store.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,29 @@ +//$Id: Store.java 17735 2009-10-14 05:15:33Z stliu $ +package org.hibernate.test.annotations.id.entities; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * Sample of class generator + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)SuppressWarnings("serial") +public class Store implements Serializable { + private Long id; + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long long1) { + id =3D long1; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Tower.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Tower.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Tower.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,14 @@ +//$Id: Tower.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)AttributeOverride(name =3D "longitude", column =3D @Column(name =3D "fl= d_longitude")) +public class Tower extends MilitaryBuilding { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/Tree.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Tree.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/Tree.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$Id: Tree.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Tree { + private Integer id; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/entities/TwinkleToes.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/TwinkleToes.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/entities/TwinkleToes.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,42 @@ +//$Id: TwinkleToes.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.entities; + +import java.io.Serializable; +import java.math.BigInteger; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.GenericGenerator; + +/** + * Blown precision on related entity when @JoinColumn is used. = + * Does not cause an issue on HyperSonic, but replicates nicely on PGSQL. + * = + * @see ANN-748 + * @author Andrew C. Oliver andyspam(a)osintegrators.com + */ +(a)Entity +(a)SuppressWarnings("serial") +public class TwinkleToes implements Serializable { + @Id + @GeneratedValue(strategy =3D GenerationType.IDENTITY, generator =3D "java= 5_uuid") + @GenericGenerator(name =3D "java5_uuid", strategy =3D "org.hibernate.test= .annotations.id.UUIDGenerator") + @Column(name =3D "id", precision =3D 128, scale =3D 0) + private BigInteger id; + + @ManyToOne + Bunny bunny; + + public void setBunny(Bunny bunny) { + this.bunny =3D bunny; + } + + public BigInteger getId() { + return id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/package-info.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/package-info.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/package-info.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ +//$Id: package-info.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +/** + * Test package for metatata facilities + * It contains an example of package level metadata + */ +(a)org.hibernate.annotations.GenericGenerator(name =3D "system-uuid", stra= tegy =3D "uuid") +(a)org.hibernate.annotations.GenericGenerators( + @org.hibernate.annotations.GenericGenerator(name =3D "system-uuid-2", st= rategy =3D "uuid") +) +package org.hibernate.test.annotations.id; + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/EnumIdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/EnumIdTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/EnumIdTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,62 @@ +//$Id: EnumIdTest.java 14785 2008-06-19 10:44:33Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.id.sequences.entities.Planet; +import org.hibernate.test.annotations.id.sequences.entities.PlanetCheatShe= et; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Tests for enum type as id. + * = + * @author Hardy Ferentschik + * @see ANN-744 + */ +(a)SuppressWarnings("unchecked") +public class EnumIdTest extends TestCase { + + private Logger log =3D LoggerFactory.getLogger(EnumIdTest.class); = + = + public EnumIdTest(String x) { + super(x); + } + + public void testEnumAsId() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + PlanetCheatSheet mercury =3D new PlanetCheatSheet(); + mercury.setPlanet(Planet.MERCURY); + mercury.setMass(3.303e+23); + mercury.setRadius(2.4397e6); + mercury.setNumberOfInhabitants(0); + s.persist(mercury); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + PlanetCheatSheet mercuryFromDb =3D (PlanetCheatSheet) s.get(PlanetCheatS= heet.class, mercury.getPlanet()); + assertNotNull(mercuryFromDb); + log.debug(mercuryFromDb.toString()); + s.delete(mercuryFromDb); + tx.commit(); + s.close(); + = + s =3D openSession(); + tx =3D s.beginTransaction(); + mercury =3D (PlanetCheatSheet) s.get(PlanetCheatSheet.class, Planet.MERC= URY); + assertNull(mercury); + tx.commit(); + s.close(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[] { PlanetCheatSheet.class }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/IdClassTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/IdClassTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/IdClassTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +//$Id: IdClassTest.java 14784 2008-06-19 10:42:20Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.id.sequences.entities.Location; +import org.hibernate.test.annotations.id.sequences.entities.Tower; + + +/** + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("unchecked") +public class IdClassTest extends TestCase { + = + public void testIdClassInSuperclass() throws Exception { + Tower tower =3D new Tower(); + tower.latitude =3D 10.3; + tower.longitude =3D 45.4; + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist( tower ); + s.flush(); + s.clear(); + Location loc =3D new Location(); + loc.latitude =3D tower.latitude; + loc.longitude =3D tower.longitude; + assertNotNull( s.get( Tower.class, loc ) ); + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[]{ + Tower.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/IdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/IdTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/IdTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,308 @@ +//$Id: IdTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.mapping.Column; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.id.sequences.entities.Ball; +import org.hibernate.test.annotations.id.sequences.entities.BreakDance; +import org.hibernate.test.annotations.id.sequences.entities.Computer; +import org.hibernate.test.annotations.id.sequences.entities.Department; +import org.hibernate.test.annotations.id.sequences.entities.Dog; +import org.hibernate.test.annotations.id.sequences.entities.FirTree; +import org.hibernate.test.annotations.id.sequences.entities.Footballer; +import org.hibernate.test.annotations.id.sequences.entities.FootballerPk; +import org.hibernate.test.annotations.id.sequences.entities.Furniture; +import org.hibernate.test.annotations.id.sequences.entities.GoalKeeper; +import org.hibernate.test.annotations.id.sequences.entities.Home; +import org.hibernate.test.annotations.id.sequences.entities.Monkey; +import org.hibernate.test.annotations.id.sequences.entities.Phone; +import org.hibernate.test.annotations.id.sequences.entities.Shoe; +import org.hibernate.test.annotations.id.sequences.entities.SoundSystem; +import org.hibernate.test.annotations.id.sequences.entities.Store; +import org.hibernate.test.annotations.id.sequences.entities.Tree; + +/** + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("unchecked") +public class IdTest extends TestCase { + public void testGenericGenerator() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + SoundSystem system =3D new SoundSystem(); + system.setBrand("Genelec"); + system.setModel("T234"); + Furniture fur =3D new Furniture(); + s.persist(system); + s.persist(fur); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + system =3D (SoundSystem) s.get(SoundSystem.class, system.getId()); + fur =3D (Furniture) s.get(Furniture.class, fur.getId()); + assertNotNull(system); + assertNotNull(fur); + s.delete(system); + s.delete(fur); + tx.commit(); + s.close(); + + } + + /* + * Ensures that GenericGenerator annotations wrapped inside a + * GenericGenerators holder are bound correctly + */ + public void testGenericGenerators() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Monkey monkey =3D new Monkey(); + s.persist(monkey); + s.flush(); + assertNotNull(monkey.getId()); + tx.rollback(); + s.close(); + } + + public void testTableGenerator() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + + Ball b =3D new Ball(); + Dog d =3D new Dog(); + Computer c =3D new Computer(); + s.persist(b); + s.persist(d); + s.persist(c); + tx.commit(); + s.close(); + assertEquals("table id not generated", new Integer(1), b.getId()); + assertEquals("generator should not be shared", new Integer(1), d + .getId()); + assertEquals("default value should work", new Long(1), c.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete(s.get(Ball.class, new Integer(1))); + s.delete(s.get(Dog.class, new Integer(1))); + s.delete(s.get(Computer.class, new Long(1))); + tx.commit(); + s.close(); + } + + public void testSequenceGenerator() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Shoe b =3D new Shoe(); + s.persist(b); + tx.commit(); + s.close(); + assertNotNull(b.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete(s.get(Shoe.class, b.getId())); + tx.commit(); + s.close(); + } + + public void testClassLevelGenerator() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Store b =3D new Store(); + s.persist(b); + tx.commit(); + s.close(); + assertNotNull(b.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete(s.get(Store.class, b.getId())); + tx.commit(); + s.close(); + } + + public void testMethodLevelGenerator() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Department b =3D new Department(); + s.persist(b); + tx.commit(); + s.close(); + assertNotNull(b.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete(s.get(Department.class, b.getId())); + tx.commit(); + s.close(); + } + + public void testDefaultSequence() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Home h =3D new Home(); + s.persist(h); + tx.commit(); + s.close(); + assertNotNull(h.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Home reloadedHome =3D (Home) s.get(Home.class, h.getId()); + assertEquals(h.getId(), reloadedHome.getId()); + s.delete(reloadedHome); + tx.commit(); + s.close(); + } + + public void testParameterizedAuto() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Home h =3D new Home(); + s.persist(h); + tx.commit(); + s.close(); + assertNotNull(h.getId()); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Home reloadedHome =3D (Home) s.get(Home.class, h.getId()); + assertEquals(h.getId(), reloadedHome.getId()); + s.delete(reloadedHome); + tx.commit(); + s.close(); + } + + public void testIdInEmbeddableSuperclass() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + FirTree chrismasTree =3D new FirTree(); + s.persist(chrismasTree); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + chrismasTree =3D (FirTree) s.get(FirTree.class, chrismasTree.getId()); + assertNotNull(chrismasTree); + s.delete(chrismasTree); + tx.commit(); + s.close(); + } + + public void testIdClass() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Footballer fb =3D new Footballer("David", "Beckam", "Arsenal"); + GoalKeeper keeper =3D new GoalKeeper("Fabien", "Bartez", "OM"); + s.persist(fb); + s.persist(keeper); + tx.commit(); + s.clear(); + + // lookup by id + tx =3D s.beginTransaction(); + FootballerPk fpk =3D new FootballerPk("David", "Beckam"); + fb =3D (Footballer) s.get(Footballer.class, fpk); + FootballerPk fpk2 =3D new FootballerPk("Fabien", "Bartez"); + keeper =3D (GoalKeeper) s.get(GoalKeeper.class, fpk2); + assertNotNull(fb); + assertNotNull(keeper); + assertEquals("Beckam", fb.getLastname()); + assertEquals("Arsenal", fb.getClub()); + assertEquals(1, s.createQuery( + "from Footballer f where f.firstname =3D 'David'").list().size()); + tx.commit(); + + // reattach by merge + tx =3D s.beginTransaction(); + fb.setClub("Bimbo FC"); + s.merge(fb); + tx.commit(); + + // reattach by saveOrUpdate + tx =3D s.beginTransaction(); + fb.setClub("Bimbo FC SA"); + s.saveOrUpdate(fb); + tx.commit(); + + // clean up + s.clear(); + tx =3D s.beginTransaction(); + fpk =3D new FootballerPk("David", "Beckam"); + fb =3D (Footballer) s.get(Footballer.class, fpk); + assertEquals("Bimbo FC SA", fb.getClub()); + s.delete(fb); + s.delete(keeper); + tx.commit(); + s.close(); + } + + public void testColumnDefinition() { + Column idCol =3D (Column) getCfg().getClassMapping(Ball.class.getName()) + .getIdentifierProperty().getValue().getColumnIterator().next(); + assertEquals("ball_id", idCol.getName()); + } + + public void testLowAllocationSize() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + int size =3D 4; + BreakDance[] bds =3D new BreakDance[size]; + for (int i =3D 0; i < size; i++) { + bds[i] =3D new BreakDance(); + s.persist(bds[i]); + } + s.flush(); + for (int i =3D 0; i < size; i++) { + assertEquals(i + 1, bds[i].id.intValue()); + } + tx.rollback(); + s.close(); + } + = + = + = + @Override + protected boolean runForCurrentDialect() { + return super.runForCurrentDialect() && getDialect().supportsSequences(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[] { Ball.class, Shoe.class, Store.class, + Department.class, Dog.class, Computer.class, Home.class, + Phone.class, Tree.class, FirTree.class, Footballer.class, + SoundSystem.class, Furniture.class, GoalKeeper.class, + BreakDance.class, Monkey.class}; + } + = + /** + * @see org.hibernate.test.annotations.TestCase#getAnnotatedPackages() + */ + protected String[] getAnnotatedPackages() { + return new String[] { "org.hibernate.test.annotations", + "org.hibernate.test.annotations.id" }; + } + + @Override + protected String[] getXmlFiles() { + return new String[] { "org/hibernate/test/annotations/orm.xml" }; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/JoinColumnOverrideTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/JoinColumnOverrideTest.java (r= ev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/JoinColumnOverrideTest.java 2009-11-24 21:03:15 UTC (r= ev 18049) @@ -0,0 +1,64 @@ +//$Id: JoinColumnOverrideTest.java 14761 2008-06-11 13:51:06Z hardy.ferent= schik $ +package org.hibernate.test.annotations.id.sequences; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.dialect.SQLServerDialect; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.id.sequences.entities.Bunny; +import org.hibernate.test.annotations.id.sequences.entities.PointyTooth; +import org.hibernate.test.annotations.id.sequences.entities.TwinkleToes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Tests for JIRA issue ANN-748. + * = + * @author Hardy Ferentschik + */ +(a)SuppressWarnings("unchecked") +public class JoinColumnOverrideTest extends TestCase { + + private Logger log =3D LoggerFactory.getLogger(JoinColumnOverrideTest.cla= ss); + = + public JoinColumnOverrideTest(String x) { + super(x); + } + + public void testBlownPrecision() throws Exception { + = + try { + AnnotationConfiguration config =3D new AnnotationConfiguration(); + config.addAnnotatedClass(Bunny.class); + config.addAnnotatedClass(PointyTooth.class); + config.addAnnotatedClass(TwinkleToes.class); + config.buildSessionFactory(); + String[] schema =3D config + .generateSchemaCreationScript(new SQLServerDialect()); + for (String s : schema) { + log.debug(s); + } + String expectedSqlPointyTooth =3D "create table PointyTooth (id numeric= (128,0) not null, " + + "bunny_id numeric(128,0) null, primary key (id))"; + assertEquals("Wrong SQL", expectedSqlPointyTooth, schema[1]); + = + String expectedSqlTwinkleToes =3D "create table TwinkleToes (id numeric= (128,0) not null, " + + "bunny_id numeric(128,0) null, primary key (id))"; + assertEquals("Wrong SQL", expectedSqlTwinkleToes, schema[2]); + } catch (Exception e) { + StringWriter writer =3D new StringWriter(); + e.printStackTrace(new PrintWriter(writer)); + log.debug(writer.toString()); + fail(e.getMessage()); + } = + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[] {}; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/UUIDGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/UUIDGenerator.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/UUIDGenerator.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +package org.hibernate.test.annotations.id.sequences; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.UUID; + +import org.hibernate.HibernateException; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.id.IdentifierGenerator; + +/** + * Unlike Hibernate's UUID generator. This avoids = + * meaningless synchronization and has less + * than a chance of an asteroid hitting you on the head + * even after trillions of rows are inserted. I know + * this to be true because it says so in Wikipedia(haha). + * http://en.wikipedia.org/wiki/UUID#Random_UUID_probability_of_duplicates + * + */ +public class UUIDGenerator implements IdentifierGenerator { + + public Serializable generate(SessionImplementor arg0, Object arg1) thr= ows HibernateException { + UUID uuid =3D UUID.randomUUID(); + String sud =3D uuid.toString(); + System.out.println("uuid=3D"+uuid); + sud =3D sud.replaceAll("-", ""); + = + BigInteger integer =3D new BigInteger(sud,16); + + System.out.println("bi =3D"+integer.toString() ); + return integer; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Ball.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Ball.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Ball.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: Ball.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.TableGenerator; + +/** + * Sample of table generator + * + * @author Emmanuel Bernard + */ +(a)TableGenerator(name =3D "EMP_GEN", table =3D "GENERATOR_TABLE", pkColum= nName =3D "pkey", + valueColumnName =3D "hi", pkColumnValue =3D "Ball", allocationSize =3D 1= 0) +(a)Entity +(a)SuppressWarnings("serial") +public class Ball implements Serializable { + private Integer id; + + @Id + @GeneratedValue(strategy =3D GenerationType.TABLE, generator =3D "EMP_GEN= ") + @Column(name =3D "ball_id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/BreakDance.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/BreakDance.java (rev = 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/BreakDance.java 2009-11-24 21:03:15 UTC (rev = 18049) @@ -0,0 +1,27 @@ +//$Id: BreakDance.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.TableGenerator; +import javax.persistence.GenerationType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class BreakDance { + @Id + @GeneratedValue(generator =3D "memencoIdGen", strategy =3D GenerationType= .TABLE) + @TableGenerator( + name =3D "memencoIdGen", + table =3D "hi_id_key", + pkColumnName =3D "id_key", + valueColumnName =3D "next_hi", + pkColumnValue =3D "issue", + allocationSize =3D 1 + ) + public Integer id; + public String name; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Bunny.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Bunny.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Bunny.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,46 @@ +//$Id: Bunny.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.GenericGenerator; + +/** + * Blown precision on related entity when @JoinColumn is used. + * = + * @see ANN-748 + * @author Andrew C. Oliver andyspam(a)osintegrators.com + */ +(a)Entity +(a)SuppressWarnings("serial") +public class Bunny implements Serializable { + @Id + @GeneratedValue(strategy =3D GenerationType.IDENTITY, generator =3D "java= 5_uuid") + @GenericGenerator(name =3D "java5_uuid", strategy =3D "org.hibernate.test= .annotations.id.UUIDGenerator") + @Column(name =3D "id", precision =3D 128, scale =3D 0) + private BigInteger id; + + @OneToMany(mappedBy =3D "bunny", cascade =3D { CascadeType.PERSIST }) + Set teeth; + = + @OneToMany(mappedBy =3D "bunny", cascade =3D { CascadeType.PERSIST }) + Set toes; + + public void setTeeth(Set teeth) { + this.teeth =3D teeth; + } + + public BigInteger getId() { + return id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Computer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Computer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Computer.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,34 @@ +//$Id: Computer.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity() +public class Computer { + private Long id; + private String serialNumber; + + @Id + @GeneratedValue(strategy =3D GenerationType.TABLE) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public String getSerialNumber() { + return serialNumber; + } + + public void setSerialNumber(String serialNumber) { + this.serialNumber =3D serialNumber; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Department.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Department.java (rev = 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Department.java 2009-11-24 21:03:15 UTC (rev = 18049) @@ -0,0 +1,33 @@ +//$Id: Department.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * Sample of method generator + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)SuppressWarnings("serial") +public class Department implements Serializable { + private Long id; + + @Id + @GeneratedValue(strategy =3D GenerationType.SEQUENCE, generator =3D "SEQ_= DEPT") + @javax.persistence.SequenceGenerator( + name =3D "SEQ_DEPT", + sequenceName =3D "my_sequence" + ) + public Long getId() { + return id; + } + + public void setId(Long long1) { + id =3D long1; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Dog.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Dog.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Dog.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,42 @@ +//$Id: Dog.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.TableGenerator; + +/** + * Share the generator table decribed by the GEN_TABLE GeneratedIdTable + * using the Dog key as discriminator + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_dog") +(a)TableGenerator(name =3D "DogGen", table =3D "GENERATOR_TABLE", pkColumn= Name =3D "pkey", + valueColumnName =3D "hi", pkColumnValue =3D "Dog", allocationSize =3D 10) +public class Dog { + private Integer id; + private String name; + + @Id + @GeneratedValue(strategy =3D GenerationType.TABLE, generator =3D "DogGen") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/FirTree.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/FirTree.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/FirTree.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,11 @@ +//$Id: FirTree.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class FirTree extends Tree { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Footballer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Footballer.java (rev = 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Footballer.java 2009-11-24 21:03:15 UTC (rev = 18049) @@ -0,0 +1,73 @@ +//$Id: Footballer.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.DiscriminatorColumn; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)IdClass(FootballerPk.class) +(a)DiscriminatorColumn(name =3D "bibi") +public class Footballer { + private String firstname; + private String lastname; + private String club; + + public Footballer() { + } + + public Footballer(String firstname, String lastname, String club) { + this.firstname =3D firstname; + this.lastname =3D lastname; + this.club =3D club; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Footballer ) ) return false; + + final Footballer footballer =3D (Footballer) o; + + if ( !firstname.equals( footballer.firstname ) ) return false; + if ( !lastname.equals( footballer.lastname ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D firstname.hashCode(); + result =3D 29 * result + lastname.hashCode(); + return result; + } + + @Id + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + @Id + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + public String getClub() { + return club; + } + + public void setClub(String club) { + this.club =3D club; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/FootballerPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/FootballerPk.java (re= v 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/FootballerPk.java 2009-11-24 21:03:15 UTC (re= v 18049) @@ -0,0 +1,62 @@ +//$Id: FootballerPk.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +(a)SuppressWarnings("serial") +public class FootballerPk implements Serializable { + private String firstname; + private String lastname; + + @Column(name =3D "fb_fname") + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + public FootballerPk() { + } + + public FootballerPk(String firstname, String lastname) { + this.firstname =3D firstname; + this.lastname =3D lastname; + + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof FootballerPk ) ) return false; + + final FootballerPk footballerPk =3D (FootballerPk) o; + + if ( !firstname.equals( footballerPk.firstname ) ) return false; + if ( !lastname.equals( footballerPk.lastname ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D firstname.hashCode(); + result =3D 29 * result + lastname.hashCode(); + return result; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Furniture.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Furniture.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Furniture.java 2009-11-24 21:03:15 UTC (rev 1= 8049) @@ -0,0 +1,33 @@ +//$Id: Furniture.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Parameter; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Furniture { + private Integer id; + + @Id + @GeneratedValue(generator =3D "hibseq") + @GenericGenerator(name =3D "hibseq", strategy =3D "seqhilo", + parameters =3D { + @Parameter(name =3D "max_lo", value =3D "5"), + @Parameter(name =3D "sequence", value =3D "heybabyhey") + } + ) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/GoalKeeper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/GoalKeeper.java (rev = 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/GoalKeeper.java 2009-11-24 21:03:15 UTC (rev = 18049) @@ -0,0 +1,17 @@ +//$Id: GoalKeeper.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class GoalKeeper extends Footballer { + public GoalKeeper() { + } + + public GoalKeeper(String firstname, String lastname, String club) { + super( firstname, lastname, club ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Home.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Home.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Home.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +//$Id: Home.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * Default sequence generation usage + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Home { + private Long id; + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Location.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Location.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Location.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,35 @@ +//$Id: Location.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import java.io.Serializable; + +/** + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("serial") +public class Location implements Serializable { + public double longitude; + public double latitude; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final Location location =3D (Location) o; + + if ( Double.compare( location.latitude, latitude ) !=3D 0 ) return false; + if ( Double.compare( location.longitude, longitude ) !=3D 0 ) return fal= se; + + return true; + } + + public int hashCode() { + int result; + long temp; + temp =3D longitude !=3D +0.0d ? Double.doubleToLongBits( longitude ) : 0= L; + result =3D (int) ( temp ^ ( temp >>> 32 ) ); + temp =3D latitude !=3D +0.0d ? Double.doubleToLongBits( latitude ) : 0L; + result =3D 29 * result + (int) ( temp ^ ( temp >>> 32 ) ); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/MilitaryBuilding.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/MilitaryBuilding.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/MilitaryBuilding.java 2009-11-24 21:03:15 UTC= (rev 18049) @@ -0,0 +1,18 @@ +//$Id: MilitaryBuilding.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +(a)IdClass(Location.class) +public class MilitaryBuilding { + @Id + public double longitude; + @Id + public double latitude; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Monkey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Monkey.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Monkey.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,24 @@ +//$ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Paul Cowan + */ +(a)Entity +public class Monkey { + private String id; + + @Id + @GeneratedValue(generator =3D "system-uuid-2") + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Phone.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Phone.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Phone.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,29 @@ +//$Id: Phone.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity() +public class Phone { + private Integer id; + + @Id + @GeneratedValue(strategy =3D GenerationType.SEQUENCE, generator =3D "Phon= e_Gen") + @javax.persistence.SequenceGenerator( + name =3D "Phone_Gen", + sequenceName =3D "phone_seq" + ) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Planet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Planet.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Planet.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,6 @@ +// $Id: Planet.java 14785 2008-06-19 10:44:33Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +public enum Planet { + MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/PlanetCheatSheet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/PlanetCheatSheet.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/PlanetCheatSheet.java 2009-11-24 21:03:15 UTC= (rev 18049) @@ -0,0 +1,85 @@ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.Id; + + +/** + * Test entity for enum type as id. + * = + * @author Hardy Ferentschik + * @see ANN-744 + */ +(a)Entity +public class PlanetCheatSheet { + + @Id + @Enumerated(EnumType.STRING) + @Column(name =3D "planet") + private Planet planet; + + private double mass; + + private double radius; + + private long numberOfInhabitants; + + public Planet getPlanet() { + return planet; + } + + public void setPlanet(Planet planet) { + this.planet =3D planet; + } + + public double getMass() { + return mass; + } + + public void setMass(double mass) { + this.mass =3D mass; + } + + public double getRadius() { + return radius; + } + + public void setRadius(double radius) { + this.radius =3D radius; + } + + public long getNumberOfInhabitants() { + return numberOfInhabitants; + } + + public void setNumberOfInhabitants(long numberOfInhabitants) { + this.numberOfInhabitants =3D numberOfInhabitants; + } + + /** + * Constructs a String with all attributes + * in name =3D value format. + * + * @return a String representation = + * of this object. + */ + public String toString() + { + final String TAB =3D " "; + = + String retValue =3D ""; + = + retValue =3D "PlanetCheatSheet ( " + + super.toString() + TAB + + "planet =3D " + this.planet + TAB + + "mass =3D " + this.mass + TAB + + "radius =3D " + this.radius + TAB + + "numberOfInhabitants =3D " + this.numberOfInhabitants + TAB + + " )"; + = + return retValue; + } = +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/PointyTooth.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/PointyTooth.java (rev= 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/PointyTooth.java 2009-11-24 21:03:15 UTC (rev= 18049) @@ -0,0 +1,44 @@ +//$Id: PointyTooth.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import java.io.Serializable; +import java.math.BigInteger; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.GenericGenerator; + +/** + * Blown precision on related entity when @JoinColumn is used. = + * Does not cause an issue on HyperSonic, but replicates nicely on PGSQL. + * = + * @see ANN-748 + * @author Andrew C. Oliver andyspam(a)osintegrators.com + */ +(a)Entity +(a)SuppressWarnings("serial") +public class PointyTooth implements Serializable { + @Id + @GeneratedValue(strategy =3D GenerationType.IDENTITY, generator =3D "java= 5_uuid") + @GenericGenerator(name =3D "java5_uuid", strategy =3D "org.hibernate.test= .annotations.id.UUIDGenerator") + @Column(name =3D "id", precision =3D 128, scale =3D 0) + private BigInteger id; + + @ManyToOne + @JoinColumn(name =3D "bunny_id") + Bunny bunny; + + public void setBunny(Bunny bunny) { + this.bunny =3D bunny; + } + + public BigInteger getId() { + return id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Shoe.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Shoe.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Shoe.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,29 @@ +//$Id: Shoe.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * sample of Sequance generator + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)SuppressWarnings("serial") +public class Shoe implements Serializable { + private Long id; + + @Id + @GeneratedValue(strategy =3D GenerationType.SEQUENCE, generator =3D "SEQ_= GEN") + public Long getId() { + return id; + } + + public void setId(Long long1) { + id =3D long1; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/SoundSystem.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/SoundSystem.java (rev= 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/SoundSystem.java 2009-11-24 21:03:15 UTC (rev= 18049) @@ -0,0 +1,42 @@ +//$Id: SoundSystem.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class SoundSystem { + private String id; + private String brand; + private String model; + + @Id + @GeneratedValue(generator =3D "system-uuid") + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } + + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand =3D brand; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Store.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Store.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Store.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Store.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * Sample of class generator + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)javax.persistence.SequenceGenerator( + name =3D "SEQ_STORE", + sequenceName =3D "my_sequence" +) +(a)SuppressWarnings("serial") +public class Store implements Serializable { + private Long id; + + @Id + @GeneratedValue(strategy =3D GenerationType.SEQUENCE, generator =3D "SEQ_= STORE") + public Long getId() { + return id; + } + + public void setId(Long long1) { + id =3D long1; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Tower.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Tower.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Tower.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,14 @@ +//$Id: Tower.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)AttributeOverride(name =3D "longitude", column =3D @Column(name =3D "fl= d_longitude")) +public class Tower extends MilitaryBuilding { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/Tree.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Tree.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/Tree.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$Id: Tree.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Tree { + private Integer id; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/entities/TwinkleToes.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/TwinkleToes.java (rev= 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/entities/TwinkleToes.java 2009-11-24 21:03:15 UTC (rev= 18049) @@ -0,0 +1,42 @@ +//$Id: TwinkleToes.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $ +package org.hibernate.test.annotations.id.sequences.entities; + +import java.io.Serializable; +import java.math.BigInteger; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.GenericGenerator; + +/** + * Blown precision on related entity when @JoinColumn is used. = + * Does not cause an issue on HyperSonic, but replicates nicely on PGSQL. + * = + * @see ANN-748 + * @author Andrew C. Oliver andyspam(a)osintegrators.com + */ +(a)Entity +(a)SuppressWarnings("serial") +public class TwinkleToes implements Serializable { + @Id + @GeneratedValue(strategy =3D GenerationType.IDENTITY, generator =3D "java= 5_uuid") + @GenericGenerator(name =3D "java5_uuid", strategy =3D "org.hibernate.test= .annotations.id.UUIDGenerator") + @Column(name =3D "id", precision =3D 128, scale =3D 0) + private BigInteger id; + + @ManyToOne + Bunny bunny; + + public void setBunny(Bunny bunny) { + this.bunny =3D bunny; + } + + public BigInteger getId() { + return id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/id/sequences/package-info.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/package-info.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/id/sequences/package-info.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ +//$Id: package-info.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +/** + * Test package for metatata facilities + * It contains an example of package level metadata + */ +(a)org.hibernate.annotations.GenericGenerator(name =3D "system-uuid", stra= tegy =3D "uuid") +(a)org.hibernate.annotations.GenericGenerators( + @org.hibernate.annotations.GenericGenerator(name =3D "system-uuid-2", st= rategy =3D "uuid") +) +package org.hibernate.test.annotations.id.sequences; + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/identifiercollection/IdentifierCollectionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/identifiercollection/IdentifierCollectionTest.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/identifiercollection/IdentifierCollectionTest.java 2009-11-24 21:03= :15 UTC (rev 18049) @@ -0,0 +1,45 @@ +//$Id: IdentifierCollectionTest.java 14736 2008-06-04 14:23:42Z hardy.fere= ntschik $ +package org.hibernate.test.annotations.identifiercollection; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; +import org.hibernate.Transaction; + + +/** + * @author Emmanuel Bernard + */ +public class IdentifierCollectionTest extends TestCase { + public void testIdBag() throws Exception { + Passport passport =3D new Passport(); + passport.setName( "Emmanuel Bernard" ); + Stamp canada =3D new Stamp(); + canada.setCountry( "Canada" ); + passport.getStamps().add( canada ); + passport.getVisaStamp().add( canada ); + Stamp norway =3D new Stamp(); + norway.setCountry( "Norway" ); + passport.getStamps().add( norway ); + passport.getStamps().add(canada); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist( passport ); + s.flush(); + //s.clear(); + passport =3D (Passport) s.get( Passport.class, passport.getId() ); + int canadaCount =3D 0; + for ( Stamp stamp : passport.getStamps() ) { + if ( "Canada".equals( stamp.getCountry() ) ) canadaCount++; + } + assertEquals( 2, canadaCount ); + assertEquals( 1, passport.getVisaStamp().size() ); + tx.rollback(); + s.close(); + } + protected Class[] getMappings() { + return new Class[] { + Passport.class, + Stamp.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/identifiercollection/Passport.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/identifiercollection/Passport.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/identifiercollection/Passport.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,70 @@ +//$Id: Passport.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.identifiercollection; + +import java.util.ArrayList; +import java.util.Collection; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.TableGenerator; + +import org.hibernate.annotations.CollectionId; +import org.hibernate.annotations.Type; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)TableGenerator(name=3D"ids_generator", table=3D"IDS") +public class Passport { + @Id @GeneratedValue @Column(name=3D"passport_id") private Long id; + private String name; + + @ManyToMany(cascade =3D CascadeType.ALL) + @JoinTable(name=3D"PASSPORT_STAMP") + @CollectionId(columns =3D @Column(name=3D"COLLECTION_ID"), type=3D@Type(t= ype=3D"long"), generator =3D "generator") + @TableGenerator(name=3D"generator", table=3D"IDSTAMP") + private Collection stamps =3D new ArrayList(); + + @ManyToMany(cascade =3D CascadeType.ALL) + @JoinTable(name=3D"PASSPORT_VISASTAMP") + @CollectionId(columns =3D @Column(name=3D"COLLECTION_ID"), type=3D@Type(t= ype=3D"long"), generator =3D "ids_generator") + //TODO test identity generator + private Collection visaStamp =3D new ArrayList(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public Collection getStamps() { + return stamps; + } + + public void setStamps(Collection stamps) { + this.stamps =3D stamps; + } + + public Collection getVisaStamp() { + return visaStamp; + } + + public void setVisaStamp(Collection visaStamp) { + this.visaStamp =3D visaStamp; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/identifiercollection/Stamp.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/identifiercollection/Stamp.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/identifiercollection/Stamp.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +//$Id: Stamp.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.identifiercollection; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Stamp { + @Id @GeneratedValue private Long id; + private String country; + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country =3D country; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/BasketItems.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/BasketItems.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/BasketItems.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,56 @@ +//$ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; +import javax.persistence.IdClass; +import javax.persistence.Id; +import javax.persistence.Column; +import javax.persistence.CascadeType; +import javax.persistence.FetchType; +import javax.persistence.JoinColumn; +import javax.persistence.Table; +import javax.persistence.ManyToOne; +import javax.persistence.Basic; +import javax.persistence.JoinColumns; +import javax.persistence.Entity; + +(a)Entity +(a)Table(name=3D"BasketItems") +(a)org.hibernate.annotations.Proxy(lazy=3Dfalse) +(a)IdClass(BasketItemsPK.class) +public class BasketItems implements Serializable { + + private static final long serialVersionUID =3D -4580497316918713849L; + + @Id + @ManyToOne(cascade=3D{ CascadeType.MERGE, CascadeType.PERSIST, CascadeTyp= e.REFRESH }) + @JoinColumns({ @JoinColumn(name=3D"basketDatetime", referencedColumnName= =3D"basketDatetime"), @JoinColumn(name=3D"customerID", referencedColumnName= =3D"customerID") }) + @Basic(fetch=3D FetchType.LAZY) + private ShoppingBaskets shoppingBaskets; + + @Column(name=3D"cost", nullable=3Dfalse) + @Id + private Double cost; + + public void setCost(double value) { + setCost(new Double(value)); + } + + public void setCost(Double value) { + this.cost =3D value; + } + + public Double getCost() { + return cost; + } + + public void setShoppingBaskets(ShoppingBaskets value) { + this.shoppingBaskets =3D value; + } + + public ShoppingBaskets getShoppingBaskets() { + return shoppingBaskets; + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/BasketItemsPK.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/BasketItemsPK.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/BasketItemsPK.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,72 @@ +//$ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; +import javax.persistence.CascadeType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.Column; +import javax.persistence.ManyToOne; +import javax.persistence.Basic; +import javax.persistence.Embeddable; +import javax.persistence.FetchType; + +(a)Embeddable +public class BasketItemsPK implements Serializable { + + private static final long serialVersionUID =3D 3585214409096105241L; + + public boolean equals(Object aObj) { + if (aObj =3D=3D this) + return true; + if (!(aObj instanceof BasketItemsPK)) + return false; + BasketItemsPK basketitemspk =3D (BasketItemsPK)aObj; + if (getShoppingBaskets() =3D=3D null && basketitemspk.getShoppingBaskets= () !=3D null) + return false; + if (!getShoppingBaskets().equals(basketitemspk.getShoppingBaskets())) + return false; + if ((getCost() !=3D null && !getCost().equals(basketitemspk.getCost())) = || (getCost() =3D=3D null && basketitemspk.getCost() !=3D null)) + return false; + return true; + } + + public int hashCode() { + int hashcode =3D 0; + if (getShoppingBaskets() !=3D null) { + hashcode =3D hashcode + (getShoppingBaskets().getOwner() =3D=3D null ? = 0 : getShoppingBaskets().getOwner().hashCode()); + hashcode =3D hashcode + (getShoppingBaskets().getBasketDatetime() =3D= =3D null ? 0 : getShoppingBaskets().getBasketDatetime().hashCode()); + } + hashcode =3D hashcode + (getCost() =3D=3D null ? 0 : getCost().hashCode(= )); + return hashcode; + } + + @Id + @ManyToOne(cascade=3D{ CascadeType.MERGE, CascadeType.PERSIST, CascadeTyp= e.REFRESH }) + @JoinColumns({ @JoinColumn(name=3D"basketDatetime", referencedColumnName= =3D"basketDatetime"), @JoinColumn(name=3D"customerID", referencedColumnName= =3D"customerID") }) + @Basic(fetch=3D FetchType.LAZY) + private ShoppingBaskets shoppingBaskets; + + public void setShoppingBaskets(ShoppingBaskets value) { + this.shoppingBaskets =3D value; + } + + public ShoppingBaskets getShoppingBaskets() { + return this.shoppingBaskets; + } + + @Column(name=3D"cost", nullable=3Dfalse) + @Id + private Double cost; + + public void setCost(Double value) { + this.cost =3D value; + } + + public Double getCost() { + return this.cost; + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/Card.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/Card.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/Card.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,70 @@ +//$Id: Card.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.Embeddable; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.CascadeType; +import javax.persistence.FetchType; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Card { + + @Id + private CardPrimaryKey primaryKey =3D new CardPrimaryKey(); + + @OneToMany(cascade =3D CascadeType.ALL, fetch =3D FetchType.EAGER, mapped= By =3D "primaryKey.card") + private Set fields; + + @ManyToOne + private CardField mainCardField; + + @Embeddable + public static class CardPrimaryKey implements Serializable { + + public CardPrimaryKey() {} + + @ManyToOne(optional =3D false) + private Project project; + + public Project getProject() { + return project; + } + + public void setProject(Project project) { + this.project =3D project; + } + + } + + public Set getFields() { + return fields; + } + + public void setFields(Set fields) { + this.fields =3D fields; + } + + public CardPrimaryKey getPrimaryKey() { + return primaryKey; + } + + public void setPrimaryKey(CardPrimaryKey primaryKey) { + this.primaryKey =3D primaryKey; + } + + public CardField getMainCardField() { + return mainCardField; + } + + public void setMainCardField(CardField mainCardField) { + this.mainCardField =3D mainCardField; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/CardField.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/CardField.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/CardField.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,64 @@ +//$Id: CardField.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class CardField { + + @Id + private PrimaryKey primaryKey =3D new PrimaryKey(); + + @ManyToOne + private Card cardtmp; + + @Embeddable + public static class PrimaryKey implements Serializable { + + @ManyToOne(optional =3D false) + private Card card; + + @ManyToOne(optional =3D false) + private CardKey key; + + public Card getCard() { + return card; + } + + public void setCard(Card card) { + this.card =3D card; + } + + public CardKey getKey() { + return key; + } + + public void setKey(CardKey key) { + this.key =3D key; + } + } + + public Card getCardtmp() { + return cardtmp; + } + + public void setCardtmp(Card cardtmp) { + this.cardtmp =3D cardtmp; + } + + public PrimaryKey getPrimaryKey() { + return primaryKey; + } + + public void setPrimaryKey(PrimaryKey primaryKey) { + this.primaryKey =3D primaryKey; + } +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/CardKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/CardKey.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/CardKey.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$Id: CardKey.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.idmanytoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class CardKey { + @Id + @GeneratedValue + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/Customer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/Customer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/Customer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,28 @@ +//$Id: Customer.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.Table; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ + + + +(a)Entity +(a)Table(name =3D "Bs") +public class Customer implements Serializable { + @Id @GeneratedValue + public Integer id; + + @OneToMany(mappedBy =3D "customer") + public Set stores; + + private static final long serialVersionUID =3D 3818501706063039923L; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/Customers.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/Customers.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/Customers.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,48 @@ +//$ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; +import javax.persistence.Id; +import javax.persistence.Column; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +(a)Entity +(a)Table(name=3D"Customers") +(a)org.hibernate.annotations.Proxy(lazy=3Dfalse) +public class Customers implements Serializable { + + private static final long serialVersionUID =3D -885167444315163039L; + + @Column(name=3D"customerID", nullable=3Dfalse) + @Id + private int customerID; + + @OneToMany(mappedBy=3D"owner", cascade=3D CascadeType.ALL, targetEntity= =3DShoppingBaskets.class) + @org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyC= ollectionOption.TRUE) + private java.util.Set shoppingBasketses =3D new java.util.HashSet(); + + public void setCustomerID(int value) { + this.customerID =3D value; + } + + public int getCustomerID() { + return customerID; + } + + public int getORMID() { + return getCustomerID(); + } + + public void setShoppingBasketses(java.util.Set value) { + this.shoppingBasketses =3D value; + } + + public java.util.Set getShoppingBasketses() { + return shoppingBasketses; + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/IdManyToOneTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/IdManyToOneTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/IdManyToOneTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,82 @@ +//$Id: IdManyToOneTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.idmanytoone; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class IdManyToOneTest extends TestCase { + public void testFkCreationOrdering() throws Exception { + //no real test case, the sessionFactory building is tested + Session s =3D openSession(); + s.close(); + } + + public void getBiDirOneToManyInId() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + CardKey key =3D new CardKey(); + s.persist( key ); + Project project =3D new Project(); + s.persist( project ); + Card card =3D new Card(); + card.getPrimaryKey().setProject( project ); + s.persist( card ); + CardField field =3D new CardField(); + field.getPrimaryKey().setKey( key ); + field.getPrimaryKey().setCard( card ); + s.persist( field ); + card.setMainCardField( field ); + s.flush(); + s.clear(); + card =3D (Card) s.createQuery( "from Card c").list().get(0); + assertEquals( 1, card.getFields().size() ); + assertEquals( card.getMainCardField(), card.getFields().iterator().next(= ) ); + tx.rollback(); + s.close(); + } + + public void testIdClassManyToOne() { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Store store =3D new Store(); + Customer customer =3D new Customer(); + s.persist( store ); + s.persist( customer ); + StoreCustomer sc =3D new StoreCustomer( store, customer ); + s.persist( sc ); + s.flush(); + s.clear(); + + store =3D (Store) s.get(Store.class, store.id ); + assertEquals( 1, store.customers.size() ); + assertEquals( customer.id, store.customers.iterator().next().customer.id= ); + tx.rollback(); + + //TODO test Customers / ShoppingBaskets / BasketItems testIdClassManyToO= neWithReferenceColumn + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { + Store.class, + Customer.class, + StoreCustomer.class, + CardKey.class, + CardField.class, + Card.class, + Project.class, + + //tested only through deployment + //ANN-590 testIdClassManyToOneWithReferenceColumn = + Customers.class, + ShoppingBaskets.class, + ShoppingBasketsPK.class, + BasketItems.class, + BasketItemsPK.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/Project.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/Project.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/Project.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +//$Id: Project.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.idmanytoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Project { + + @Id + @GeneratedValue + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/ShoppingBaskets.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/ShoppingBaskets.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/ShoppingBaskets.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,66 @@ +//$ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; + +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +(a)Entity +(a)Table(name=3D"ShoppingBasket") +(a)org.hibernate.annotations.Proxy(lazy=3Dfalse) +(a)IdClass(ShoppingBasketsPK.class) +public class ShoppingBaskets implements Serializable { + + private static final long serialVersionUID =3D 4739240471638885734L; + + @Id + @ManyToOne(cascade=3D{ CascadeType.MERGE, CascadeType.PERSIST, CascadeTyp= e.REFRESH }) + @JoinColumns({ @JoinColumn(name=3D"customerID", referencedColumnName=3D"c= ustomerID") }) + @Basic(fetch=3DFetchType.LAZY) + private Customers owner; + + @Column(name=3D"basketDatetime", nullable=3Dfalse) + @Id + private java.util.Date basketDatetime; + + @OneToMany(mappedBy=3D"shoppingBaskets", cascade=3DCascadeType.ALL, targe= tEntity=3DBasketItems.class) + @org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyC= ollectionOption.TRUE) + private java.util.Set items =3D new java.util.HashSet(); + = + public void setBasketDatetime(java.util.Date value) { + this.basketDatetime =3D value; + } + + public java.util.Date getBasketDatetime() { + return basketDatetime; + } + + public void setOwner(Customers value) { + this.owner =3D value; + } + + public Customers getOwner() { + return owner; + } + + public void setItems(java.util.Set value) { + this.items =3D value; + } + + public java.util.Set getItems() { + return items; + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/ShoppingBasketsPK.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/ShoppingBasketsPK.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/ShoppingBasketsPK.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,70 @@ +//$ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; +import javax.persistence.CascadeType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.JoinColumns; +import javax.persistence.FetchType; +import javax.persistence.Basic; +import javax.persistence.JoinColumn; +import javax.persistence.Column; +import javax.persistence.Embeddable; + +(a)Embeddable +public class ShoppingBasketsPK implements Serializable { + private static final long serialVersionUID =3D 4121297376338222776L; + + public boolean equals(Object aObj) { + if (aObj =3D=3D this) + return true; + if (!(aObj instanceof ShoppingBasketsPK)) + return false; + ShoppingBasketsPK shoppingbasketspk =3D (ShoppingBasketsPK)aObj; + if (getOwner() =3D=3D null && shoppingbasketspk.getOwner() !=3D null) + return false; + if (!getOwner().equals(shoppingbasketspk.getOwner())) + return false; + if (getBasketDatetime() !=3D shoppingbasketspk.getBasketDatetime()) + return false; + return true; + } + + public int hashCode() { + int hashcode =3D 0; + if (getOwner() !=3D null) { + hashcode =3D hashcode + (int) getOwner().getORMID(); + } + hashcode =3D hashcode + (getBasketDatetime() =3D=3D null ? 0 : getBasket= Datetime().hashCode()); + return hashcode; + } + + @Id + @ManyToOne(cascade=3D{ CascadeType.MERGE, CascadeType.PERSIST, CascadeTyp= e.REFRESH }) + @JoinColumns({ @JoinColumn(name=3D"customerID", referencedColumnName=3D"c= ustomerID") }) + @Basic(fetch=3D FetchType.LAZY) + private Customers owner; + + public void setOwner(Customers value) { + this.owner =3D value; + } + + public Customers getOwner() { + return this.owner; + } + + @Column(name=3D"basketDatetime", nullable=3Dfalse) + @Id + private java.util.Date basketDatetime; + + public void setBasketDatetime(java.util.Date value) { + this.basketDatetime =3D value; + } + + public java.util.Date getBasketDatetime() { + return this.basketDatetime; + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/Store.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/Store.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/Store.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: Store.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.Table; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "`As`") +public class Store implements Serializable { + @Id @GeneratedValue + public Integer id; + + @OneToMany(mappedBy =3D "store") + public Set customers; + + + private static final long serialVersionUID =3D 1748046699322502790L; +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/StoreCustomer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/StoreCustomer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/StoreCustomer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,38 @@ +//$Id: StoreCustomer.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.IdClass; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "ABs") +(a)IdClass( StoreCustomerPK.class) +public class StoreCustomer implements Serializable { + StoreCustomer() {} + @Id + @ManyToOne(optional =3D false) + @JoinColumn(name =3D "idA") + public Store store; + + @Id + @ManyToOne(optional =3D false) + @JoinColumn(name =3D "idB") + public Customer customer; + + + public StoreCustomer(Store store, Customer customer) { + this.store =3D store; + this.customer =3D customer; + } + + + private static final long serialVersionUID =3D -8295955012787627232L; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/StoreCustomerPK.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/StoreCustomerPK.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/StoreCustomerPK.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,32 @@ +//$Id: StoreCustomerPK.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.idmanytoone; + +import java.io.Serializable; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +public class StoreCustomerPK implements Serializable { + StoreCustomerPK() {} + @Id + @ManyToOne(optional =3D false) + @JoinColumn(name =3D "idA") + public Store store; + + @Id + @ManyToOne(optional =3D false) + @JoinColumn(name =3D "idB") + public Customer customer; + + + public StoreCustomerPK(Store store, Customer customer) { + this.store =3D store; + this.customer =3D customer; + } + + + private static final long serialVersionUID =3D -1102111921432271459L; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/A.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/A.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/A.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import java.util.List; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +(a)Entity +public class A { + + @Id + private int id; + + @OneToMany( mappedBy =3D "parent" ) + List children; + + public A() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children =3D children; + } + + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/Acces.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/Acces.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/Acces.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,17 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import java.io.Serializable; +import java.math.BigInteger; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +(a)Entity +public class Acces implements Serializable { + @Id + private BigInteger idpk; + + @ManyToOne + private Droitacces idpkdracc; +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java 2009-11-2= 4 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class AlphabeticalIdManyToOneTest extends TestCase { + public void testAlphabeticalTest() throws Exception { + //test through deployment + } + + + protected Class[] getMappings() { + return new Class[] { + B.class, + C.class, + A.class + + + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/AlphabeticalManyToOneTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/AlphabeticalManyToOneTest.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/AlphabeticalManyToOneTest.java 2009-11-24 = 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class AlphabeticalManyToOneTest extends TestCase { + public void testAlphabeticalTest() throws Exception { + //test through deployment + } + + protected Class[] getMappings() { + return new Class[] { + Acces.class, + Droitacces.class, + Benefserv.class, + Service.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/B.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/B.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/B.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; + +(a)Entity +(a)IdClass( BId.class ) +public class B { + + @Id + private C parent; + + @Id + private int sequenceNumber; + + public B() { + } + + public C getParent() { + return parent; + } + + public void setParent(C parent) { + this.parent =3D parent; + } + + public int getSequenceNumber() { + return sequenceNumber; + } + + public void setSequenceNumber(int sequenceNumber) { + this.sequenceNumber =3D sequenceNumber; + } + + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/BId.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/BId.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/BId.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,69 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import java.io.Serializable; +import javax.persistence.Embeddable; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; + +(a)Embeddable +public class BId implements Serializable { + + @ManyToOne + @JoinColumns( { + @JoinColumn( name =3D "aId", nullable =3D false ), + @JoinColumn( name =3D "bSequenceNumber", nullable =3D false ) + } ) + private C parent; + + private int sequenceNumber; + + public BId() { + } + + public C getParent() { + return parent; + } + + public void setParent(C parent) { + this.parent =3D parent; + } + + public int getSequenceNumber() { + return sequenceNumber; + } + + public void setSequenceNumber(int sequenceNumber) { + this.sequenceNumber =3D sequenceNumber; + } + + @Override + public int hashCode() { + final int prime =3D 31; + int result =3D 1; + result =3D prime * result + ( ( parent =3D=3D null ) ? 0 : parent.hashCo= de() ); + result =3D prime * result + sequenceNumber; + return result; + } + + @Override + public boolean equals(Object obj) { + if ( this =3D=3D obj ) + return true; + if ( obj =3D=3D null ) + return false; + if ( getClass() !=3D obj.getClass() ) + return false; + final BId other =3D (BId) obj; + if ( parent =3D=3D null ) { + if ( other.parent !=3D null ) + return false; + } + else if ( !parent.equals( other.parent ) ) + return false; + if ( sequenceNumber !=3D other.sequenceNumber ) + return false; + return true; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/Benefserv.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/Benefserv.java (re= v 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/Benefserv.java 2009-11-24 21:03:15 UTC (re= v 18049) @@ -0,0 +1,17 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import java.math.BigInteger; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +(a)Entity +public class Benefserv { + @Id + private BigInteger idpk; + + @ManyToOne + private Service idpkser; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/C.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/C.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/C.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,52 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import java.util.List; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.OneToMany; + +(a)Entity +(a)IdClass( CId.class ) +public class C { + + @Id + private A parent; + + @Id + private int sequenceNumber; + + @OneToMany( mappedBy =3D "parent" ) + List children; + + public C() { + } + + public A getParent() { + return parent; + } + + public void setParent(A parent) { + this.parent =3D parent; + } + + public int getSequenceNumber() { + return sequenceNumber; + } + + public void setSequenceNumber(int sequenceNumber) { + this.sequenceNumber =3D sequenceNumber; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children =3D children; + } + + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/CId.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/CId.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/CId.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,67 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import java.io.Serializable; +import javax.persistence.Embeddable; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +(a)Embeddable +public class CId implements Serializable { + + @ManyToOne + @JoinColumn( name =3D "aId", nullable =3D false ) + private A parent; + + private int sequenceNumber; + + public CId() { + } + + public A getParent() { + return parent; + } + + public void setParent(A parent) { + this.parent =3D parent; + } + + public int getSequenceNumber() { + return sequenceNumber; + } + + public void setSequenceNumber(int sequenceNumber) { + this.sequenceNumber =3D sequenceNumber; + } + + @Override + public int hashCode() { + final int prime =3D 31; + int result =3D 1; + result =3D prime * result + ( ( parent =3D=3D null ) ? 0 : parent.hashCo= de() ); + result =3D prime * result + sequenceNumber; + return result; + } + + @Override + public boolean equals(Object obj) { + if ( this =3D=3D obj ) + return true; + if ( obj =3D=3D null ) + return false; + if ( getClass() !=3D obj.getClass() ) + return false; + final CId other =3D (CId) obj; + if ( parent =3D=3D null ) { + if ( other.parent !=3D null ) + return false; + } + else if ( !parent.equals( other.parent ) ) + return false; + if ( sequenceNumber !=3D other.sequenceNumber ) + return false; + return true; + } + + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/Droitacces.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/Droitacces.java (r= ev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/Droitacces.java 2009-11-24 21:03:15 UTC (r= ev 18049) @@ -0,0 +1,17 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import java.math.BigInteger; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +(a)Entity +public class Droitacces { + @Id + private BigInteger idpk; + + @ManyToOne + private Benefserv idpkbenef; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/idmanytoone/alphabetical/Service.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/Service.java (rev = 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/idmanytoone/alphabetical/Service.java 2009-11-24 21:03:15 UTC (rev = 18049) @@ -0,0 +1,14 @@ +//$ +package org.hibernate.test.annotations.idmanytoone.alphabetical; + +import java.math.BigInteger; + +import javax.persistence.Entity; +import javax.persistence.Id; + + +(a)Entity +public class Service { + @Id + private BigInteger idpk; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/immutable/Country.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/immutable/Country.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/immutable/Country.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,57 @@ +//$Id: Country.java 14801 2008-06-24 19:03:32Z hardy.ferentschik $ +package org.hibernate.test.annotations.immutable; + +/** + * @author Hardy Ferentschik + */ +import java.io.Serializable; +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.Cascade; +import org.hibernate.annotations.Immutable; + +(a)Entity +(a)Immutable +(a)SuppressWarnings("serial") +public class Country implements Serializable { + private Integer id; + = + private String name; + = + private List states; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public String getName() { + return name; + } + + public void setId(Integer integer) { + id =3D integer; + } + + public void setName(String string) { + name =3D string; + } + + @OneToMany(fetch =3D FetchType.LAZY) + @Cascade(org.hibernate.annotations.CascadeType.ALL) + @Immutable + public List getStates() { + return states; + } + = + public void setStates(List states) { + this.states =3D states; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/immutable/Foobar.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/immutable/Foobar.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/immutable/Foobar.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,37 @@ +// $Id: Foobar.java 14801 2008-06-24 19:03:32Z hardy.ferentschik $ +package org.hibernate.test.annotations.immutable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.annotations.Immutable; + +/** + * @author Hardy Ferentschik + */ +(a)Entity +public class Foobar { + @Id + @GeneratedValue + private Integer id; + = + @Immutable + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/immutable/ImmutableTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/immutable/ImmutableTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/immutable/ImmutableTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,165 @@ +//$Id: ImmutableTest.java 16426 2009-04-23 16:01:18Z jcosta(a)redhat.com $ +package org.hibernate.test.annotations.immutable; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; + +import org.hibernate.AnnotationException; +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.dialect.SQLServerDialect; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.fkcircularity.A; +import org.hibernate.test.annotations.fkcircularity.B; +import org.hibernate.test.annotations.fkcircularity.C; +import org.hibernate.test.annotations.fkcircularity.D; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Tests for Immutable annotation. + * = + * @author Hardy Ferentschik + */ +(a)SuppressWarnings("unchecked") +public class ImmutableTest extends TestCase { + + private Logger log =3D LoggerFactory.getLogger(ImmutableTest.class); + + public ImmutableTest(String x) { + super(x); + } + + public void testImmutableEntity() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Country country =3D new Country(); + country.setName("Germany"); + s.persist(country); + tx.commit(); + s.close(); + + // try changing the entity + s =3D openSession(); + tx =3D s.beginTransaction(); + Country germany =3D (Country) s.get(Country.class, country.getId()); + assertNotNull(germany); + germany.setName("France"); + assertEquals("Local name can be changed", "France", germany.getName()); + s.save(germany); + tx.commit(); + s.close(); + = + // retrieving the country again - it should be unmodified + s =3D openSession(); + tx =3D s.beginTransaction(); + germany =3D (Country) s.get(Country.class, country.getId()); + assertNotNull(germany); + assertEquals("Name should not have changed", "Germany", germany.getName(= )); + tx.commit(); + s.close(); + = +// // try deletion +// s =3D openSession(); +// tx =3D s.beginTransaction(); +// s.delete(germany); +// tx.commit(); +// s.close(); +// = +// s =3D openSession(); +// tx =3D s.beginTransaction(); +// germany =3D (Country) s.get(Country.class, country.getId()); +// assertNotNull(germany); +// assertEquals("Name should not have changed", "Germany", germany.getNam= e()); +// s.close(); + } + = + public void testImmutableCollection() { + Country country =3D new Country(); + country.setName("Germany"); + List states =3D new ArrayList(); + State bayern =3D new State(); + bayern.setName("Bayern"); + State hessen =3D new State(); + hessen.setName("Hessen"); + State sachsen =3D new State(); + sachsen.setName("Sachsen"); + states.add(bayern); + states.add(hessen); + states.add(sachsen); + country.setStates(states); + = + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist(country); + tx.commit(); + s.close(); + = + s =3D openSession(); + tx =3D s.beginTransaction(); + Country germany =3D (Country) s.get(Country.class, country.getId()); + assertNotNull(germany); + assertEquals("Wrong number of states", 3, germany.getStates().size()); + = + // try adding a state + State foobar =3D new State(); + foobar.setName("foobar"); + s.save(foobar); + germany.getStates().add(foobar); + try { + tx.commit(); + fail(); + } catch (HibernateException e) { + assertTrue(e.getMessage().contains("changed an immutable collection ins= tance")); + log.debug("success"); + } + s.close(); + = + s =3D openSession(); + tx =3D s.beginTransaction(); + germany =3D (Country) s.get(Country.class, country.getId()); + assertNotNull(germany); + assertEquals("Wrong number of states", 3, germany.getStates().size()); + = + // try deleting a state + germany.getStates().remove(0); + try { + tx.commit(); + fail(); + } catch (HibernateException e) { + assertTrue(e.getMessage().contains("changed an immutable collection ins= tance")); + log.debug("success"); + } = + s.close(); = + = + s =3D openSession(); + tx =3D s.beginTransaction(); + germany =3D (Country) s.get(Country.class, country.getId()); + assertNotNull(germany); + assertEquals("Wrong number of states", 3, germany.getStates().size()); + tx.commit(); + s.close(); + } + = + public void testMiscplacedImmutableAnnotation() { + try { + AnnotationConfiguration config =3D new AnnotationConfiguration(); + config.addAnnotatedClass(Foobar.class); + config.buildSessionFactory(); + fail(); + } catch (AnnotationException ae) { + log.debug("succes"); + } + } + = + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[] { Country.class, State.class}; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/immutable/State.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/immutable/State.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/immutable/State.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +// $Id: State.java 14801 2008-06-24 19:03:32Z hardy.ferentschik $ +package org.hibernate.test.annotations.immutable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Hardy Ferentschik + */ +(a)Entity +public class State { + @Id + @GeneratedValue + private Integer id; + = + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/AddressBook.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/AddressBook.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/AddressBook.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,75 @@ +//$Id: AddressBook.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.HashMap; +import java.util.Map; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.MapKey; +import javax.persistence.OneToMany; +import javax.persistence.JoinTable; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class AddressBook { + private Integer id; + private String owner; + private Map entries =3D new HashMap(); + private Map lastNameEntries =3D new HashMap(); + private Map directoryEntries =3D new= HashMap(); + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner =3D owner; + } + + @MapKey + @OneToMany(mappedBy =3D "book", cascade =3D {CascadeType.MERGE, CascadeTy= pe.PERSIST, CascadeType.REMOVE}) + @JoinTable(name=3D"AddRegEntry") + public Map getEntries() { + return entries; + } + + public void setEntries(Map entries) { + this.entries =3D entries; + } + + @MapKey(name =3D "person.lastname") + @OneToMany(mappedBy =3D "book") + public Map getLastNameEntries() { + return lastNameEntries; + } + + public void setLastNameEntries(Map lastNameEntries)= { + this.lastNameEntries =3D lastNameEntries; + } + + @MapKey(name =3D "directory") + @OneToMany(mappedBy =3D "book") + @JoinTable(name=3D"Dir_Entry") + public Map getDirectoryEntries() { + return directoryEntries; + } + + public void setDirectoryEntries(Map = directoryEntries) { + this.directoryEntries =3D directoryEntries; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/AddressEntry.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/AddressEntry.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/AddressEntry.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,76 @@ +//$Id: AddressEntry.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class AddressEntry { + private AddressEntryPk person; + private String street; + private String city; + private AddressBook book; + private AlphabeticalDirectory directory; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof AddressEntry ) ) return false; + + final AddressEntry addressEntry =3D (AddressEntry) o; + + if ( !person.equals( addressEntry.person ) ) return false; + + return true; + } + + public int hashCode() { + return person.hashCode(); + } + + @EmbeddedId + public AddressEntryPk getPerson() { + return person; + } + + public void setPerson(AddressEntryPk person) { + this.person =3D person; + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street =3D street; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city =3D city; + } + + @ManyToOne + public AddressBook getBook() { + return book; + } + + public void setBook(AddressBook book) { + this.book =3D book; + } + + @ManyToOne + public AlphabeticalDirectory getDirectory() { + return directory; + } + + public void setDirectory(AlphabeticalDirectory directory) { + this.directory =3D directory; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/AddressEntryPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/AddressEntryPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/AddressEntryPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,57 @@ +//$Id: AddressEntryPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.io.Serializable; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class AddressEntryPk implements Serializable { + private String firstname; + private String lastname; + + public AddressEntryPk() { + } + + public AddressEntryPk(String firstname, String lastname) { + this.firstname =3D firstname; + this.lastname =3D lastname; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof AddressEntryPk ) ) return false; + + final AddressEntryPk addressEntryPk =3D (AddressEntryPk) o; + + if ( !firstname.equals( addressEntryPk.firstname ) ) return false; + if ( !lastname.equals( addressEntryPk.lastname ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D firstname.hashCode(); + result =3D 29 * result + lastname.hashCode(); + return result; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/AlphabeticalDirectory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/AlphabeticalDirectory.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/AlphabeticalDirectory.java 2009-11-24 21:03:15 UTC (rev 1= 8049) @@ -0,0 +1,31 @@ +//$Id: AlphabeticalDirectory.java 14736 2008-06-04 14:23:42Z hardy.ferents= chik $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class AlphabeticalDirectory { + @Id @GeneratedValue private Integer id; + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Atmosphere.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Atmosphere.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Atmosphere.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,42 @@ +//$Id: Atmosphere.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.HashMap; +import java.util.Map; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.Column; +import javax.persistence.JoinTable; +import javax.persistence.JoinColumn; + +import org.hibernate.annotations.MapKey; +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.MapKeyManyToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Atmosphere { + @Id + @GeneratedValue + public Integer id; + + @ManyToMany(cascade =3D CascadeType.ALL) + @MapKey(columns =3D {@Column(name=3D"gas_name")}) + public Map gases =3D new HashMap(); + + @ManyToMany(cascade =3D CascadeType.ALL) + @MapKeyManyToMany(joinColumns =3D @JoinColumn(name=3D"gas_id") ) + @JoinTable(name =3D "Gas_per_key") + public Map gasesPerKey =3D new HashMap(); + + @CollectionOfElements + @Column(name=3D"composition_rate") + @MapKeyManyToMany(joinColumns =3D @JoinColumn(name=3D"gas_id")) + @JoinTable(name =3D "Composition", joinColumns =3D @JoinColumn(name =3D "= atmosphere_id")) + public Map composition =3D new HashMap(); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Drawer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Drawer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Drawer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,59 @@ +//$Id: Drawer.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.List; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.IndexColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Drawer { + private Long id; + private List dresses; + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + /** + * Unidirectional one to many list + * + * @return + */ + @OneToMany + @IndexColumn(name =3D "from_bottom_position") + public List getDresses() { + return dresses; + } + + public void setDresses(List dresses) { + this.dresses =3D dresses; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Drawer ) ) return false; + + final Drawer drawer =3D (Drawer) o; + + if ( !getId().equals( drawer.getId() ) ) return false; + + return true; + } + + public int hashCode() { + return getId().hashCode(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Dress.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Dress.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Dress.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,41 @@ +//$Id: Dress.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Dress { + private Integer id; + + @Id + @GeneratedValue + @Column(name =3D "dress_id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Dress ) ) return false; + + final Dress dress =3D (Dress) o; + + if ( !getId().equals( dress.getId() ) ) return false; + + return true; + } + + public int hashCode() { + return getId().hashCode(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Gas.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Gas.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Gas.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,18 @@ +//$Id: Gas.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Gas { + @Id + @GeneratedValue + public Integer id; + public String name; + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/GasKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/GasKey.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/GasKey.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,21 @@ +//$Id: GasKey.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class GasKey { + @Id private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Generation.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Generation.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Generation.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: Generation.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class Generation { + + private String age; + private String culture; + + public String getAge() { + return age; + } + public void setAge(String age) { + this.age =3D age; + } + public String getCulture() { + return culture; + } + public void setCulture(String culture) { + this.culture =3D culture; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/GenerationGroup.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/GenerationGroup.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/GenerationGroup.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,37 @@ +//$Id: GenerationGroup.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class GenerationGroup { + + @Id + @GeneratedValue + private int id; + + private Generation generation; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + public Generation getGeneration() { + return generation; + } + + public void setGeneration(Generation generation) { + this.generation =3D generation; + } + + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/GenerationUser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/GenerationUser.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/GenerationUser.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,43 @@ +//$Id: GenerationUser.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.Map; +import java.util.HashMap; +import javax.persistence.OneToMany; +import javax.persistence.Id; +import javax.persistence.Entity; +import javax.persistence.MapKey; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class GenerationUser { + + @Id + @GeneratedValue + private int id; + + @OneToMany + @MapKey(name=3D"generation") + private Map ref =3D new HashMap(); + + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + public Map getRef() { + return ref; + } + + public void setRef(Map ref) { + this.ref =3D ref; + } + + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/IndexedCollectionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/IndexedCollectionTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/IndexedCollectionTest.java 2009-11-24 21:03:15 UTC (rev 1= 8049) @@ -0,0 +1,549 @@ +//$Id: IndexedCollectionTest.java 15025 2008-08-11 09:14:39Z hardy.ferents= chik $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.Hibernate; +import org.hibernate.dialect.HSQLDialect; +import org.hibernate.test.annotations.RequiresDialect; +import org.hibernate.test.annotations.TestCase; + +/** + * Test index collections + * + * @author Emmanuel Bernard + */ +public class IndexedCollectionTest extends TestCase { + public void testFkList() throws Exception { + Wardrobe w =3D new Wardrobe(); + Drawer d1 =3D new Drawer(); + Drawer d2 =3D new Drawer(); + w.setDrawers( new ArrayList() ); + w.getDrawers().add( d1 ); + w.getDrawers().add( d2 ); + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( w ); + + s.flush(); + s.clear(); + + w =3D (Wardrobe) s.get( Wardrobe.class, w.getId() ); + assertNotNull( w ); + assertNotNull( w.getDrawers() ); + List result =3D w.getDrawers(); + assertEquals( 2, result.size() ); + assertEquals( d2.getId(), result.get( 1 ).getId() ); + result.remove( d1 ); + s.flush(); + d1 =3D (Drawer) s.merge( d1 ); + result.add( d1 ); + + s.flush(); + s.clear(); + + w =3D (Wardrobe) s.get( Wardrobe.class, w.getId() ); + assertNotNull( w ); + assertNotNull( w.getDrawers() ); + result =3D w.getDrawers(); + assertEquals( 2, result.size() ); + assertEquals( d1.getId(), result.get( 1 ).getId() ); + s.delete( result.get( 0 ) ); + s.delete( result.get( 1 ) ); + s.delete( w ); + s.flush(); + tx.rollback(); + s.close(); + } + + public void testJoinedTableList() throws Exception { + Wardrobe w =3D new Wardrobe(); + w.setDrawers( new ArrayList() ); + Drawer d =3D new Drawer(); + w.getDrawers().add( d ); + Dress d1 =3D new Dress(); + Dress d2 =3D new Dress(); + d.setDresses( new ArrayList() ); + d.getDresses().add( d1 ); + d.getDresses().add( d2 ); + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( d1 ); + s.persist( d2 ); + s.persist( w ); + + s.flush(); + s.clear(); + + d =3D (Drawer) s.get( Drawer.class, d.getId() ); + assertNotNull( d ); + assertNotNull( d.getDresses() ); + List result =3D d.getDresses(); + assertEquals( 2, result.size() ); + assertEquals( d2.getId(), result.get( 1 ).getId() ); + result.remove( d1 ); + s.flush(); + d1 =3D (Dress) s.merge( d1 ); + result.add( d1 ); + + s.flush(); + s.clear(); + + d =3D (Drawer) s.get( Drawer.class, d.getId() ); + assertNotNull( d ); + assertNotNull( d.getDresses() ); + result =3D d.getDresses(); + assertEquals( 2, result.size() ); + assertEquals( d1.getId(), result.get( 1 ).getId() ); + s.delete( result.get( 0 ) ); + s.delete( result.get( 1 ) ); + s.delete( d ); + s.flush(); + tx.rollback(); + s.close(); + } + + public void testMapKey() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Software hibernate =3D new Software(); + hibernate.setName( "Hibernate" ); + Version v1 =3D new Version(); + v1.setCodeName( "HumbaHumba" ); + v1.setNumber( "1.0" ); + v1.setSoftware( hibernate ); + Version v2 =3D new Version(); + v2.setCodeName( "Copacabana" ); + v2.setNumber( "2.0" ); + v2.setSoftware( hibernate ); + Version v4 =3D new Version(); + v4.setCodeName( "Dreamland" ); + v4.setNumber( "4.0" ); + v4.setSoftware( hibernate ); + Map link =3D new HashMap(); + link.put( v1.getCodeName(), v1 ); + link.put( v2.getCodeName(), v2 ); + link.put( v4.getCodeName(), v4 ); + hibernate.setVersions( link ); + s.persist( hibernate ); + s.persist( v1 ); + s.persist( v2 ); + s.persist( v4 ); + + s.flush(); + s.clear(); + + hibernate =3D (Software) s.get( Software.class, "Hibernate" ); + assertEquals( 3, hibernate.getVersions().size() ); + assertEquals( "1.0", hibernate.getVersions().get( "HumbaHumba" ).getNumb= er() ); + assertEquals( "2.0", hibernate.getVersions().get( "Copacabana" ).getNumb= er() ); + hibernate.getVersions().remove( v4.getCodeName() ); + + s.flush(); + s.clear(); + + hibernate =3D (Software) s.get( Software.class, "Hibernate" ); + assertEquals( "So effect on collection changes", 3, hibernate.getVersion= s().size() ); + for ( Version v : hibernate.getVersions().values() ) { + s.delete( v ); + } + s.delete( hibernate ); + + s.flush(); + + tx.rollback(); + s.close(); + } + + public void testDefaultMapKey() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + AddressBook book =3D new AddressBook(); + book.setOwner( "Emmanuel" ); + AddressEntryPk helene =3D new AddressEntryPk( "Helene", "Michau" ); + AddressEntry heleneEntry =3D new AddressEntry(); + heleneEntry.setBook( book ); + heleneEntry.setCity( "Levallois" ); + heleneEntry.setStreet( "Louis Blanc" ); + heleneEntry.setPerson( helene ); + AddressEntryPk primeMinister =3D new AddressEntryPk( "Dominique", "Ville= pin" ); + AddressEntry primeMinisterEntry =3D new AddressEntry(); + primeMinisterEntry.setBook( book ); + primeMinisterEntry.setCity( "Paris" ); + primeMinisterEntry.setStreet( "Hotel Matignon" ); + primeMinisterEntry.setPerson( primeMinister ); + book.getEntries().put( helene, heleneEntry ); + book.getEntries().put( primeMinister, primeMinisterEntry ); + s.persist( book ); + + s.flush(); + s.clear(); + + book =3D (AddressBook) s.get( AddressBook.class, book.getId() ); + assertEquals( 2, book.getEntries().size() ); + assertEquals( heleneEntry.getCity(), book.getEntries().get( helene ).get= City() ); + AddressEntryPk fake =3D new AddressEntryPk( "Fake", "Fake" ); + book.getEntries().put( fake, primeMinisterEntry ); + + s.flush(); + s.clear(); + + book =3D (AddressBook) s.get( AddressBook.class, book.getId() ); + assertEquals( 2, book.getEntries().size() ); + assertNull( book.getEntries().get( fake ) ); + s.delete( book ); + + s.flush(); + tx.rollback(); + s.close(); + } + + public void testMapKeyToEntity() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + AlphabeticalDirectory m =3D new AlphabeticalDirectory(); + m.setName( "M" ); + AlphabeticalDirectory v =3D new AlphabeticalDirectory(); + v.setName( "V" ); + s.persist( m ); + s.persist( v ); + + AddressBook book =3D new AddressBook(); + book.setOwner( "Emmanuel" ); + AddressEntryPk helene =3D new AddressEntryPk( "Helene", "Michau" ); + AddressEntry heleneEntry =3D new AddressEntry(); + heleneEntry.setBook( book ); + heleneEntry.setCity( "Levallois" ); + heleneEntry.setStreet( "Louis Blanc" ); + heleneEntry.setPerson( helene ); + heleneEntry.setDirectory( m ); + AddressEntryPk primeMinister =3D new AddressEntryPk( "Dominique", "Ville= pin" ); + AddressEntry primeMinisterEntry =3D new AddressEntry(); + primeMinisterEntry.setBook( book ); + primeMinisterEntry.setCity( "Paris" ); + primeMinisterEntry.setStreet( "Hotel Matignon" ); + primeMinisterEntry.setPerson( primeMinister ); + primeMinisterEntry.setDirectory( v ); + book.getEntries().put( helene, heleneEntry ); + book.getEntries().put( primeMinister, primeMinisterEntry ); + s.persist( book ); + + s.flush(); + s.clear(); + + book =3D (AddressBook) s.get( AddressBook.class, book.getId() ); + assertEquals( 2, book.getEntries().size() ); + assertEquals( heleneEntry.getCity(), book.getEntries().get( helene ).get= City() ); + assertEquals( "M", book.getEntries().get( helene ).getDirectory().getNam= e() ); + + s.delete( book ); + tx.rollback(); + s.close(); + } + + @RequiresDialect(HSQLDialect.class) + public void testComponentSubPropertyMapKey() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + AddressBook book =3D new AddressBook(); + book.setOwner( "Emmanuel" ); + AddressEntryPk helene =3D new AddressEntryPk( "Helene", "Michau" ); + AddressEntry heleneEntry =3D new AddressEntry(); + heleneEntry.setBook( book ); + heleneEntry.setCity( "Levallois" ); + heleneEntry.setStreet( "Louis Blanc" ); + heleneEntry.setPerson( helene ); + AddressEntryPk primeMinister =3D new AddressEntryPk( "Dominique", "Ville= pin" ); + AddressEntry primeMinisterEntry =3D new AddressEntry(); + primeMinisterEntry.setBook( book ); + primeMinisterEntry.setCity( "Paris" ); + primeMinisterEntry.setStreet( "Hotel Matignon" ); + primeMinisterEntry.setPerson( primeMinister ); + book.getEntries().put( helene, heleneEntry ); + book.getEntries().put( primeMinister, primeMinisterEntry ); + s.persist( book ); + + s.flush(); + s.clear(); + + book =3D (AddressBook) s.get( AddressBook.class, book.getId() ); + assertEquals( 2, book.getLastNameEntries().size() ); + assertEquals( heleneEntry.getCity(), book.getLastNameEntries().get( "Mic= hau" ).getCity() ); + AddressEntryPk fake =3D new AddressEntryPk( "Fake", "Fake" ); + book.getEntries().put( fake, primeMinisterEntry ); + + s.flush(); + s.clear(); + + book =3D (AddressBook) s.get( AddressBook.class, book.getId() ); + assertEquals( 2, book.getEntries().size() ); + assertNull( book.getEntries().get( fake ) ); + s.delete( book ); + tx.rollback(); + s.close(); + } + + public void testMapKeyOnManyToMany() throws Exception { + Session s; + s =3D openSession(); + s.getTransaction().begin(); + News airplane =3D new News(); + airplane.setTitle( "Crash!" ); + airplane.setDetail( "An airplaned crashed." ); + s.persist( airplane ); + Newspaper lemonde =3D new Newspaper(); + lemonde.setName( "Lemonde" ); + lemonde.getNews().put( airplane.getTitle(), airplane ); + s.persist( lemonde ); + + s.flush(); + s.clear(); + + lemonde =3D (Newspaper) s.get( Newspaper.class, lemonde.getId() ); + assertEquals( 1, lemonde.getNews().size() ); + News news =3D lemonde.getNews().get( airplane.getTitle() ); + assertNotNull( news ); + assertEquals( airplane.getTitle(), news.getTitle() ); + s.delete( lemonde ); + s.delete( news ); + + s.getTransaction().rollback(); + s.close(); + } + + public void testMapKeyOnManyToManyOnId() throws Exception { + Session s; + s =3D openSession(); + s.getTransaction().begin(); + News hibernate1 =3D new News(); + hibernate1.setTitle( "#1 ORM solution in the Java world" ); + hibernate1.setDetail( "Well, that's no news ;-)" ); + s.persist( hibernate1 ); + PressReleaseAgency schwartz =3D new PressReleaseAgency(); + schwartz.setName( "Schwartz" ); + schwartz.getProvidedNews().put( hibernate1.getId(), hibernate1 ); + s.persist( schwartz ); + + s.flush(); + s.clear(); + + schwartz =3D (PressReleaseAgency) s.get( PressReleaseAgency.class, schwa= rtz.getId() ); + assertEquals( 1, schwartz.getProvidedNews().size() ); + News news =3D schwartz.getProvidedNews().get( hibernate1.getId() ); + assertNotNull( news ); + assertEquals( hibernate1.getTitle(), news.getTitle() ); + s.delete( schwartz ); + s.delete( news ); + + s.getTransaction().rollback(); + s.close(); + } + + public void testMapKeyAndIdClass() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Painter picasso =3D new Painter(); + Painting laVie =3D new Painting( "La Vie", "Picasso", 50, 20 ); + picasso.getPaintings().put( "La Vie", laVie ); + Painting famille =3D new Painting( "La Famille du Saltimbanque", "Picass= o", 50, 20 ); + picasso.getPaintings().put( "La Famille du Saltimbanque", famille ); + s.persist( picasso ); + + s.flush(); + s.clear(); + + picasso =3D (Painter) s.get( Painter.class, picasso.getId() ); + Painting painting =3D picasso.getPaintings().get( famille.getName() ); + assertNotNull( painting ); + assertEquals( painting.getName(), famille.getName() ); + s.delete( picasso ); + tx.rollback(); + s.close(); + } + + public void testRealMap() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Atmosphere atm =3D new Atmosphere(); + Atmosphere atm2 =3D new Atmosphere(); + GasKey key =3D new GasKey(); + key.setName( "O2" ); + Gas o2 =3D new Gas(); + o2.name =3D "oxygen"; + atm.gases.put( "100%", o2 ); + atm.gasesPerKey.put( key, o2 ); + atm2.gases.put( "100%", o2 ); + atm2.gasesPerKey.put( key, o2 ); + s.persist( key ); + s.persist( atm ); + s.persist( atm2 ); + + s.flush(); + s.clear(); + + atm =3D (Atmosphere) s.get( Atmosphere.class, atm.id ); + key =3D (GasKey) s.get( GasKey.class, key.getName() ); + assertEquals( 1, atm.gases.size() ); + assertEquals( o2.name, atm.gases.get( "100%" ).name ); + assertEquals( o2.name, atm.gasesPerKey.get( key ).name ); + tx.rollback(); + s.close(); + } + + public void testMapKeyEntityEntity() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + AddressBook book =3D new AddressBook(); + s.persist( book ); + AddressEntry entry =3D new AddressEntry(); + entry.setCity( "Atlanta"); + AddressEntryPk pk =3D new AddressEntryPk("Coca", "Cola" ); + entry.setPerson( pk ); + entry.setBook( book ); + AlphabeticalDirectory ad =3D new AlphabeticalDirectory(); + ad.setName( "C"); + s.persist( ad ); + entry.setDirectory( ad ); + s.persist( entry ); + book.getDirectoryEntries().put( ad, entry ); + + s.flush(); + s.clear(); + + book =3D (AddressBook) s.get( AddressBook.class, book.getId() ); + assertEquals( 1, book.getDirectoryEntries().size() ); + assertEquals( "C", book.getDirectoryEntries().keySet().iterator().next()= .getName() ); + tx.rollback(); + s.close(); + } + + public void testEntityKeyElementTarget() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Atmosphere atm =3D new Atmosphere(); + Gas o2 =3D new Gas(); + o2.name =3D "oxygen"; + atm.composition.put( o2, 94.3 ); + s.persist( o2 ); + s.persist( atm ); + + s.flush(); + s.clear(); + + atm =3D (Atmosphere) s.get( Atmosphere.class, atm.id ); + assertTrue( ! Hibernate.isInitialized( atm.composition ) ); + assertEquals( 1, atm.composition.size() ); + assertEquals( o2.name, atm.composition.keySet().iterator().next().name ); + tx.rollback(); + s.close(); + } + + public void testSortedMap() { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Training training =3D new Training(); + Trainee trainee =3D new Trainee(); + trainee.setName( "Jim" ); + Trainee trainee2 =3D new Trainee(); + trainee2.setName( "Emmanuel" ); + s.persist( trainee ); + s.persist( trainee2 ); + training.getTrainees().put( "Jim", trainee ); + training.getTrainees().put( "Emmanuel", trainee2 ); + s.persist( training ); + + s.flush(); + s.clear(); + + training =3D (Training) s.get( Training.class, training.getId() ); + assertEquals( "Emmanuel", training.getTrainees().firstKey() ); + assertEquals( "Jim", training.getTrainees().lastKey() ); + tx.rollback(); + s.close(); + } + + public void testMapKeyLoad() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Software hibernate =3D new Software(); + hibernate.setName( "Hibernate" ); + Version v1 =3D new Version(); + v1.setCodeName( "HumbaHumba" ); + v1.setNumber( "1.0" ); + v1.setSoftware( hibernate ); + hibernate.addVersion( v1 ); + s.persist( hibernate ); + s.persist( v1 ); + + s.flush(); + s.clear(); + + hibernate =3D (Software) s.get( Software.class, "Hibernate" ); + assertEquals(1, hibernate.getVersions().size() ); + Version v2 =3D new Version(); + v2.setCodeName( "HumbaHumba2" ); + v2.setNumber( "2.0" ); + v2.setSoftware( hibernate ); + hibernate.addVersion( v2 ); + assertEquals( "One loaded persisted version, and one just added", 2, hib= ernate.getVersions().size() ); + + s.flush(); + s.clear(); + + hibernate =3D (Software) s.get( Software.class, "Hibernate" ); + for ( Version v : hibernate.getVersions().values() ) { + s.delete( v ); + } + s.delete( hibernate ); + tx.rollback(); + s.close(); + } + + + public IndexedCollectionTest(String x) { + super( x ); + } + + protected Class[] getMappings() { + return new Class[]{ + Wardrobe.class, + Drawer.class, + Dress.class, + Software.class, + Version.class, + AddressBook.class, + AddressEntry.class, + AddressEntryPk.class, //should be silently ignored + Newspaper.class, + News.class, + PressReleaseAgency.class, + Painter.class, + Painting.class, + Atmosphere.class, + Gas.class, + AlphabeticalDirectory.class, + GasKey.class, + Trainee.class, + Training.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/MapKeyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/MapKeyTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/MapKeyTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,40 @@ +//$Id: MapKeyTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; +import org.hibernate.Transaction; + +/** + * @author Emmanuel Bernard + */ +public class MapKeyTest extends TestCase { + + public void testMapKeyOnEmbeddedId() { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Generation c =3D new Generation(); + c.setAge( "a" ); + c.setCulture( "b" ); + GenerationGroup r =3D new GenerationGroup(); + r.setGeneration( c ); + s.persist( r ); + GenerationUser m =3D new GenerationUser(); + s.persist( m ); + m.getRef().put( c, r ); + s.flush(); + s.clear(); + + m =3D (GenerationUser) s.get( GenerationUser.class, m.getId() ); + assertEquals( "a", m.getRef().keySet().iterator().next().getAge() ); + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { + GenerationUser.class, + GenerationGroup.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/News.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/News.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/News.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,44 @@ +//$Id: News.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class News { + private Integer id; + private String title; + private String detail; + + @Id + @GeneratedValue + @Column(name =3D "news_id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title =3D title; + } + + public String getDetail() { + return detail; + } + + public void setDetail(String detail) { + this.detail =3D detail; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Newspaper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Newspaper.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Newspaper.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,48 @@ +//$Id: Newspaper.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.HashMap; +import java.util.Map; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.MapKey; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Newspaper { + private Integer id; + private String name; + private Map news =3D new HashMap(); + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToMany + @MapKey(name =3D "title") + public Map getNews() { + return news; + } + + public void setNews(Map news) { + this.news =3D news; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Painter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Painter.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Painter.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,42 @@ +//$Id: Painter.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.HashMap; +import java.util.Map; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.MapKey; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Painter { + private Integer id; + private Map paintings =3D new HashMap= (); + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @OneToMany(cascade =3D {CascadeType.ALL}) + @MapKey(name =3D "name") + @JoinColumn + public Map getPaintings() { + return paintings; + } + + public void setPaintings(Map paintings) { + this.paintings =3D paintings; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Painting.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Painting.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Painting.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,82 @@ +//$Id: Painting.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)IdClass(PaintingPk.class) +public class Painting { + + private int sizeX; + private int sizeY; + private String name; + private String painter; + + public Painting() { + } + + public Painting(String name, String painter, int sizeX, int sizeY) { + this.name =3D name; + this.painter =3D painter; + this.sizeX =3D sizeX; + this.sizeY =3D sizeY; + } + + @Id + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Id + public String getPainter() { + return painter; + } + + public void setPainter(String painter) { + this.painter =3D painter; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final PaintingPk that =3D (PaintingPk) o; + + if ( !name.equals( that.getName() ) ) return false; + if ( !painter.equals( that.getPainter() ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D name.hashCode(); + result =3D 29 * result + painter.hashCode(); + return result; + } + + public int getSizeX() { + return sizeX; + } + + public void setSizeX(int sizeX) { + this.sizeX =3D sizeX; + } + + public int getSizeY() { + return sizeY; + } + + public void setSizeY(int sizeY) { + this.sizeY =3D sizeY; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/PaintingPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/PaintingPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/PaintingPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,49 @@ +//$Id: PaintingPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.io.Serializable; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class PaintingPk implements Serializable { + private String name; + private String painter; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getPainter() { + return painter; + } + + public void setPainter(String painter) { + this.painter =3D painter; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final PaintingPk that =3D (PaintingPk) o; + + if ( !name.equals( that.name ) ) return false; + if ( !painter.equals( that.painter ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D name.hashCode(); + result =3D 29 * result + painter.hashCode(); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/PressReleaseAgency.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/PressReleaseAgency.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/PressReleaseAgency.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,54 @@ +//$Id: PressReleaseAgency.java 14736 2008-06-04 14:23:42Z hardy.ferentschi= k $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.HashMap; +import java.util.Map; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.MapKey; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class PressReleaseAgency { + private Integer id; + private String name; + private Map providedNews =3D new HashMap(); + + @Id + @GeneratedValue + @Column(name =3D "PressReleaseAgency_id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToMany + @JoinTable(joinColumns =3D @JoinColumn(name =3D "PressReleaseAgency_id"), + inverseJoinColumns =3D @JoinColumn(name =3D "News_id")) + @MapKey + public Map getProvidedNews() { + return providedNews; + } + + public void setProvidedNews(Map providedNews) { + this.providedNews =3D providedNews; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Software.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Software.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Software.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,41 @@ +//$Id: Software.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.Map; +import java.util.HashMap; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.MapKey; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Software { + private String name; + private Map versions =3D new HashMap(); + + @Id + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @OneToMany(mappedBy =3D "software") + @MapKey(name =3D "codeName") + public Map getVersions() { + return versions; + } + + public void setVersions(Map versions) { + this.versions =3D versions; + } + + public void addVersion(Version version) { + this.versions.put(version.getCodeName(), version); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Trainee.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Trainee.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Trainee.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +//$Id: Trainee.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Trainee { + @Id @GeneratedValue private Long id; + private String name; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Training.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Training.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Training.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +//$Id: Training.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.SortedMap; +import java.util.TreeMap; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.MapKey; +import javax.persistence.ManyToMany; + +import org.hibernate.annotations.Sort; +import org.hibernate.annotations.SortType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Training { + @Id @GeneratedValue private Long id; + @Sort(type=3D SortType.NATURAL) + @MapKey(name=3D"name") @ManyToMany SortedMap trainees = =3D new TreeMap(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public SortedMap getTrainees() { + return trainees; + } + + public void setTrainees(SortedMap trainees) { + this.trainees =3D trainees; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Version.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Version.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Version.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,58 @@ +//$Id: Version.java 15049 2008-08-13 15:32:32Z epbernard $ +package org.hibernate.test.annotations.indexcoll; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_version") +public class Version { + private Integer id; + private String codeName; + private String number; + private Software software; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @Column(name=3D"`code_name`") + public String getCodeName() { + return codeName; + } + + public void setCodeName(String codeName) { + this.codeName =3D codeName; + } + + @Column(name=3D"version_nbr") + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number =3D number; + } + + @ManyToOne + public Software getSoftware() { + return software; + } + + public void setSoftware(Software software) { + this.software =3D software; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/indexcoll/Wardrobe.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Wardrobe.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/indexcoll/Wardrobe.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,47 @@ +//$Id: Wardrobe.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.indexcoll; + +import java.util.List; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.IndexColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Wardrobe { + + private Long id; + private List drawers; + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + /** + * unidirectional one to many list with non null foreign key (mapping + * not recommended). + */ + @OneToMany(cascade =3D CascadeType.ALL) + @IndexColumn(name =3D "drawer_position", base =3D 1) + @JoinColumn(name =3D "wardrobe_id", nullable =3D false) + public List getDrawers() { + return drawers; + } + + public void setDrawers(List drawers) { + this.drawers =3D drawers; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/Apple.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/Apple.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/Apple.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ +//$Id: Apple.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Apple extends Fruit { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/Carrot.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/Carrot.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/Carrot.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Carrot.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance; + +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.PrimaryKeyJoinColumns; + +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +(a)PrimaryKeyJoinColumns( + {@PrimaryKeyJoinColumn(name =3D "carrot_farmer", referencedColumnName = =3D "farmer"), + @PrimaryKeyJoinColumn(name =3D "harvest", referencedColumnName =3D "harv= estDate") + }) +(a)OnDelete(action =3D OnDeleteAction.CASCADE) +public class Carrot extends Vegetable { + private int length; + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length =3D length; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/Fruit.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/Fruit.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/Fruit.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +//$Id: Fruit.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Fruit { + private Integer id; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/SubclassTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/SubclassTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/SubclassTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,170 @@ +//$Id: SubclassTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance; + +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.A320; +import org.hibernate.test.annotations.A320b; +import org.hibernate.test.annotations.Plane; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.inheritance.singletable.Funk; +import org.hibernate.test.annotations.inheritance.singletable.Music; +import org.hibernate.test.annotations.inheritance.singletable.Noise; +import org.hibernate.test.annotations.inheritance.singletable.Rock; + +/** + * @author Emmanuel Bernard + */ +public class SubclassTest extends TestCase { + + public SubclassTest(String x) { + super( x ); + } + + public void testPolymorphism() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Plane p =3D new Plane(); + p.setNbrOfSeats( 10 ); + A320 a =3D new A320(); + a.setJavaEmbeddedVersion( "5.0" ); + a.setNbrOfSeats( 300 ); + s.persist( a ); + s.persist( p ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "from " + A320.class.getName() ); + List a320s =3D q.list(); + assertNotNull( a320s ); + assertEquals( 1, a320s.size() ); + assertTrue( a320s.get( 0 ) instanceof A320 ); + assertEquals( "5.0", ( (A320) a320s.get( 0 ) ).getJavaEmbeddedVersion() = ); + q =3D s.createQuery( "from " + Plane.class.getName() ); + List planes =3D q.list(); + assertNotNull( planes ); + assertEquals( 2, planes.size() ); + tx.commit(); + s.close(); + } + + public void test2ndLevelSubClass() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + A320b a =3D new A320b(); + a.setJavaEmbeddedVersion( "Elephant" ); + a.setNbrOfSeats( 300 ); + s.persist( a ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "from " + A320.class.getName() + " as a where= a.javaEmbeddedVersion =3D :version" ); + q.setString( "version", "Elephant" ); + List a320s =3D q.list(); + assertNotNull( a320s ); + assertEquals( 1, a320s.size() ); + tx.commit(); + s.close(); + } + + public void testEmbeddedSuperclass() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Plane p =3D new Plane(); + p.setAlive( true ); //sic + p.setAltitude( 10000 ); + p.setMetricAltitude( 3000 ); + p.setNbrOfSeats( 150 ); + p.setSerial( "0123456789" ); + s.persist( p ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + p =3D (Plane) s.get( Plane.class, p.getId() ); + assertNotNull( p ); + assertEquals( true, p.isAlive() ); + assertEquals( 150, p.getNbrOfSeats() ); + assertEquals( 10000, p.getAltitude() ); + assertEquals( "0123456789", p.getSerial() ); + assertFalse( 3000 =3D=3D p.getMetricAltitude() ); + s.delete( p ); + tx.commit(); + s.close(); + } + + public void testFormula() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Rock guns =3D new Rock(); + guns.setAvgBeat( 90 ); + guns.setType( 2 ); + Noise white =3D new Noise(); + white.setAvgBeat( 0 ); + white.setType( null ); + + s.persist( guns ); + s.persist( white ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + List result =3D s.createCriteria( Noise.class ).list(); + assertNotNull( result ); + assertEquals( 1, result.size() ); + white =3D (Noise) result.get( 0 ); + assertNull( white.getType() ); + s.delete( white ); + result =3D s.createCriteria( Rock.class ).list(); + assertEquals( 1, result.size() ); + s.delete( result.get( 0 ) ); + result =3D s.createCriteria( Funk.class ).list(); + assertEquals( 0, result.size() ); + + tx.commit(); + s.close(); + } + + private void checkClassType(Fruit fruitToTest, Fruit f, Apple a) { + if ( fruitToTest.getId().equals( f.getId() ) ) { + assertFalse( fruitToTest instanceof Apple ); + } + else if ( fruitToTest.getId().equals( a.getId() ) ) { + assertTrue( fruitToTest instanceof Apple ); + } + else { + fail( "Result does not contains the previously inserted elements" ); + } + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + A320b.class, //subclasses should be properly reordered + Plane.class, + A320.class, + Fruit.class, + //FlyingObject.class, //had to declare embedded superclasses + //Thing.class, + Apple.class, + Music.class, + Rock.class, + Funk.class, + Noise.class + }; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/Tomato.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/Tomato.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/Tomato.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Tomato.java 15056 2008-08-13 18:15:05Z epbernard $ +package org.hibernate.test.annotations.inheritance; + +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Column; + +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; + +/** + * @author Emmanuel Bernard + */ +//FIXME HBX-55 default for composite PK does not work yet +//FIXME Tomato is a fruit +(a)Entity() +(a)Inheritance( + strategy =3D InheritanceType.JOINED +) +(a)OnDelete(action =3D OnDeleteAction.CASCADE) +public class Tomato extends Vegetable { + private int size; + + @Column(name=3D"tom_size") + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size =3D size; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/Vegetable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/Vegetable.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/Vegetable.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,51 @@ +//$Id: Vegetable.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity() +(a)Inheritance( + strategy =3D InheritanceType.JOINED +) +public class Vegetable { + private VegetablePk id; + private long priceInCent; + + @Id + public VegetablePk getId() { + return id; + } + + public void setId(VegetablePk id) { + this.id =3D id; + } + + public long getPriceInCent() { + return priceInCent; + } + + public void setPriceInCent(long priceInCent) { + this.priceInCent =3D priceInCent; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Vegetable ) ) return false; + + final Vegetable vegetable =3D (Vegetable) o; + + if ( !id.equals( vegetable.id ) ) return false; + + return true; + } + + public int hashCode() { + return id.hashCode(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/VegetablePk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/VegetablePk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/VegetablePk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,50 @@ +//$Id: VegetablePk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance; + +import java.io.Serializable; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class VegetablePk implements Serializable { + private String farmer; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof VegetablePk ) ) return false; + + final VegetablePk vegetablePk =3D (VegetablePk) o; + + if ( !farmer.equals( vegetablePk.farmer ) ) return false; + if ( !harvestDate.equals( vegetablePk.harvestDate ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D farmer.hashCode(); + result =3D 29 * result + harvestDate.hashCode(); + return result; + } + + public String getFarmer() { + return farmer; + } + + public void setFarmer(String farmer) { + this.farmer =3D farmer; + } + + public String getHarvestDate() { + return harvestDate; + } + + public void setHarvestDate(String harvestDate) { + this.harvestDate =3D harvestDate; + } + + private String harvestDate; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/Alarm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Alarm.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Alarm.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,40 @@ +//$Id: Alarm.java 15074 2008-08-14 17:38:00Z epbernard $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.OneToOne; + +(a)Entity +(a)DiscriminatorValue("AlarmT") +public class Alarm extends EventInformation { + + protected EventInformation eventInfo; + + @OneToOne + @JoinColumns({@JoinColumn(name =3D "EVENTINFO_NOTIFICATIONID", + referencedColumnName =3D "NOTIFICATIONID")}) + public EventInformation getEventInfo() { + return eventInfo; + } + + public void setEventInfo(EventInformation value) { + this.eventInfo =3D value; + } + + + @Override + public String toString() { + StringBuilder sb =3D new StringBuilder(); + String eventId =3D ( getEventInfo() !=3D null ? + getEventInfo().getNotificationId() : null ); + sb.append( + "AlarmT: id =3D " + getNotificationId() + "\t" + + "has event id =3D " + eventId + ); + return sb.toString(); + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/Asset.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Asset.hbm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Asset.hbm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/Asset.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Asset.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Asset.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,41 @@ +//$Id: Asset.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +(a)Table(name =3D "TBLASSET") +public class Asset { + private Integer id; + + private Parent parent =3D null; + + @Id @GeneratedValue public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @ManyToOne(targetEntity =3D Parent.class) + @JoinColumn(name =3D "PARENTID") + public Parent getParent() { + return parent; + } + + public void setParent(Parent parent) { + this.parent =3D parent; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/Clothing.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Clothing.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Clothing.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,48 @@ +//$Id: Clothing.java 15075 2008-08-14 17:43:43Z epbernard $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +public abstract class Clothing { + private long id; + private int size; + private String color; + + @Id + @GeneratedValue + public long getId() { + return id; + } + + public void setId(long id) { + this.id =3D id; + } + + @Column(name =3D "cloth_size") + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size =3D size; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color =3D color; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/Document.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Document.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Document.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Document.java 16296 2009-04-10 20:21:48Z gbadner $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Column; +import javax.persistence.Entity; + +import org.hibernate.annotations.ForeignKey; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)ForeignKey(name =3D "FK_DOCU_FILE") +public class Document extends File { + @Column(nullable =3D false, name=3D"xsize") + private int size; + + Document() { + } + + Document(String name, int size) { + super( name ); + this.size =3D size; + } + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size =3D size; + } +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/joined/Document.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/EventInformation.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/EventInformation.java (r= ev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/EventInformation.java 2009-11-24 21:03:15 UTC (r= ev 18049) @@ -0,0 +1,38 @@ +//$Id: EventInformation.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorType; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + + +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +(a)DiscriminatorColumn(name =3D "DTYPE", discriminatorType =3D Discriminat= orType.STRING, length =3D 80) +(a)DiscriminatorValue("EventInformationT") +public class EventInformation implements java.io.Serializable { + + + protected String notificationId; + + @Id + public String getNotificationId() { + return notificationId; + } + + public void setNotificationId(String value) { + this.notificationId =3D value; + } + + @Override + public String toString() { + StringBuilder sb =3D new StringBuilder(); + sb.append( "EventInformationT: id =3D " + getNotificationId() ); + return sb.toString(); + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/File.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/File.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/File.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,48 @@ +//$Id: File.java 15050 2008-08-13 15:34:39Z epbernard $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.ManyToOne; +import javax.persistence.Column; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +(a)Table(name=3D"joined_file") +public abstract class File { + @Id @Column(name=3D"filename") + private String name; + @ManyToOne + private Folder parent; + + File() { + } + + public File(String name) { + this.name =3D name; + } + + + public String getName() { + return name; + } + + public void setName(String id) { + this.name =3D id; + } + + public Folder getParent() { + return parent; + } + + public void setParent(Folder parent) { + this.parent =3D parent; + } + +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/joined/File.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/FinancialAsset.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/FinancialAsset.java (rev= 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/FinancialAsset.java 2009-11-24 21:03:15 UTC (rev= 18049) @@ -0,0 +1,20 @@ +//$Id: FinancialAsset.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class FinancialAsset extends Asset { + private double price; + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price =3D price; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/Folder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Folder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Folder.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +//$Id: Folder.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Folder extends File { + @OneToMany(mappedBy =3D "parent") + private Set children =3D new HashSet(); + + Folder() { + } + + public Folder(String name) { + super( name ); + } + + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children =3D children; + } +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/joined/Folder.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/JoinedSubclassAndSecondaryTable.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/JoinedSubclassAndSecondaryTable.java 2009-11-24 = 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: JoinedSubclassAndSecondaryTable.java 14736 2008-06-04 14:23:42Z har= dy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class JoinedSubclassAndSecondaryTable extends TestCase { + + public void testSecondaryTableAndJoined() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + SwimmingPool sp =3D new SwimmingPool(); + sp.setAddress( "Park Avenue" ); + s.persist( sp ); + tx.rollback(); + s.close(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + Pool.class, + SwimmingPool.class + }; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/JoinedSubclassTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/JoinedSubclassTest.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/JoinedSubclassTest.java 2009-11-24 21:03:15 UTC = (rev 18049) @@ -0,0 +1,178 @@ +//$Id: JoinedSubclassTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschi= k $ +package org.hibernate.test.annotations.inheritance.joined; + +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class JoinedSubclassTest extends TestCase { + + public JoinedSubclassTest(String x) { + super( x ); + } + + public void testDefault() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + File doc =3D new Document( "Enron Stuff To Shred", 1000 ); + Folder folder =3D new Folder( "Enron" ); + s.persist( doc ); + s.persist( folder ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + List result =3D s.createCriteria( File.class ).list(); + assertNotNull( result ); + assertEquals( 2, result.size() ); + File f2 =3D (File) result.get( 0 ); + checkClassType( f2, doc, folder ); + f2 =3D (File) result.get( 1 ); + checkClassType( f2, doc, folder ); + s.delete( result.get( 0 ) ); + s.delete( result.get( 1 ) ); + tx.commit(); + s.close(); + } + + public void testManyToOneOnAbstract() throws Exception { + Folder f =3D new Folder(); + f.setName( "data" ); + ProgramExecution remove =3D new ProgramExecution(); + remove.setAction( "remove" ); + remove.setAppliesOn( f ); + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( f ); + s.persist( remove ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + remove =3D (ProgramExecution) s.get( ProgramExecution.class, remove.getI= d() ); + assertNotNull( remove ); + assertNotNull( remove.getAppliesOn().getName() ); + s.delete( remove ); + s.delete( remove.getAppliesOn() ); + tx.commit(); + s.close(); + + } + + private void checkClassType(File fruitToTest, File f, Folder a) { + if ( fruitToTest.getName().equals( f.getName() ) ) { + assertFalse( fruitToTest instanceof Folder ); + } + else if ( fruitToTest.getName().equals( a.getName() ) ) { + assertTrue( fruitToTest instanceof Folder ); + } + else { + fail( "Result does not contains the previously inserted elements" ); + } + } + + public void testJoinedAbstractClass() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + s.getTransaction().begin(); + Sweater sw =3D new Sweater(); + sw.setColor( "Black" ); + sw.setSize( 2 ); + sw.setSweat( true ); + s.persist( sw ); + s.getTransaction().commit(); + s.clear(); + + s =3D openSession(); + s.getTransaction().begin(); + sw =3D (Sweater) s.get( Sweater.class, sw.getId() ); + s.delete( sw ); + s.getTransaction().commit(); + s.close(); + } + + public void testInheritance() throws Exception { + Session session =3D openSession(); + Transaction transaction =3D session.beginTransaction(); + String eventPK =3D "event1"; + EventInformation event =3D (EventInformation) session.get( EventInformat= ion.class, eventPK ); + if ( event =3D=3D null ) { + event =3D new EventInformation(); + event.setNotificationId( eventPK ); + session.persist( event ); + } + String alarmPK =3D "alarm1"; + Alarm alarm =3D (Alarm) session.get( Alarm.class, alarmPK ); + if ( alarm =3D=3D null ) { + alarm =3D new Alarm(); + alarm.setNotificationId( alarmPK ); + alarm.setEventInfo( event ); + session.persist( alarm ); + } + transaction.commit(); + session.close(); + } + +// public void testManyToOneAndJoin() throws Exception { +// Session session =3D openSession(); +// Transaction transaction =3D session.beginTransaction(); +// Parent parent =3D new Parent(); +// session.persist( parent ); +// PropertyAsset property =3D new PropertyAsset(); +// property.setParent( parent ); +// property.setPrice( 230000d ); +// FinancialAsset financial =3D new FinancialAsset(); +// financial.setParent( parent ); +// financial.setPrice( 230000d ); +// session.persist( financial ); +// session.persist( property ); +// session.flush(); +// session.clear(); +// parent =3D (Parent) session.get( Parent.class, parent.getId() ); +// assertNotNull( parent ); +// assertEquals( 1, parent.getFinancialAssets().size() ); +// assertEquals( 1, parent.getPropertyAssets().size() ); +// assertEquals( property.getId(), parent.getPropertyAssets().iterator().= next() ); +// transaction.rollback(); +// session.close(); +// } + + @Override + protected String[] getXmlFiles() { + return new String[] { + //"org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml" + }; + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + File.class, + Folder.class, + Document.class, + SymbolicLink.class, + ProgramExecution.class, + Clothing.class, + Sweater.class, + EventInformation.class, + Alarm.class, + //Asset.class, + //Parent.class, + //PropertyAsset.class, + //FinancialAsset.class + }; + } + +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/joined/JoinedSubclassTest.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/Parent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Parent.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Parent.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,49 @@ +//$Id: Parent.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "Parent") +public class Parent { + private Integer id; + private Set propertyAssets =3D new HashSet(); + private Set financialAssets =3D new HashSet(); + + @Id @GeneratedValue public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @OneToMany(cascade =3D CascadeType.REFRESH, fetch =3D FetchType.EAGER, ma= ppedBy =3D "parent", targetEntity =3D PropertyAsset.class) + public Set getPropertyAssets() { + return this.propertyAssets; + } + + public void setPropertyAssets(Set propertyAssets) { + this.propertyAssets =3D propertyAssets; + } + + @OneToMany(cascade =3D CascadeType.REFRESH, fetch =3D FetchType.EAGER, ma= ppedBy =3D "parent", targetEntity =3D FinancialAsset.class) + public Set getFinancialAssets() { + return this.financialAssets; + } + + public void setFinancialAssets(Set financialAssets) { + this.financialAssets =3D financialAssets; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/Pool.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Pool.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Pool.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,38 @@ +//$Id: Pool.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.SecondaryTable; +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +(a)SecondaryTable(name=3D"POOL_ADDRESS") +public class Pool { + @Id @GeneratedValue private Integer id; + @Column(table =3D "POOL_ADDRESS") + private String address; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address =3D address; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/ProgramExecution.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/ProgramExecution.java (r= ev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/ProgramExecution.java 2009-11-24 21:03:15 UTC (r= ev 18049) @@ -0,0 +1,47 @@ +//$Id: ProgramExecution.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class ProgramExecution { + @Id + @GeneratedValue + private Integer id; + private String action; + @ManyToOne(fetch =3D FetchType.LAZY) + private File appliesOn; + + + public File getAppliesOn() { + return appliesOn; + } + + public void setAppliesOn(File appliesOn) { + this.appliesOn =3D appliesOn; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action =3D action; + } + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/PropertyAsset.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/PropertyAsset.java (rev = 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/PropertyAsset.java 2009-11-24 21:03:15 UTC (rev = 18049) @@ -0,0 +1,20 @@ +//$Id: PropertyAsset.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class PropertyAsset extends Asset { + private double price; + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price =3D price; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/Sweater.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Sweater.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/Sweater.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: Sweater.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)PrimaryKeyJoinColumn(name =3D "clothing_id") +public class Sweater extends Clothing { + private boolean isSweat; + + public boolean isSweat() { + return isSweat; + } + + public void setSweat(boolean sweat) { + isSweat =3D sweat; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/SwimmingPool.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/SwimmingPool.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/SwimmingPool.java 2009-11-24 21:03:15 UTC (rev 1= 8049) @@ -0,0 +1,11 @@ +//$Id: SwimmingPool.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class SwimmingPool extends Pool { +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/joined/SymbolicLink.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/SymbolicLink.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/joined/SymbolicLink.java 2009-11-24 21:03:15 UTC (rev 1= 8049) @@ -0,0 +1,29 @@ +//$Id: SymbolicLink.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.ManyToOne; + +(a)Entity +public class SymbolicLink extends File { + + @ManyToOne(optional =3D false) + File target; + + SymbolicLink() { + } + + public SymbolicLink(File target) { + this.target =3D target; + } + + public File getTarget() { + return target; + } + + public void setTarget(File target) { + this.target =3D target; + } + + +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/joined/SymbolicLink.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/mixed/Document.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/mixed/Document.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/mixed/Document.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,36 @@ +//$Id: Document.java 15056 2008-08-13 18:15:05Z epbernard $ +package org.hibernate.test.annotations.inheritance.mixed; + +import javax.persistence.Column; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.SecondaryTable; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorValue("D") +(a)SecondaryTable(name =3D "DocumentMixed") +(a)Table(name=3D"Document_Wrong") //illegal use, a warn is raised +public class Document extends File { + private int size; + + Document() { + } + + Document(String name, int size) { + super( name ); + this.size =3D size; + } + + @Column(table =3D "DocumentMixed", name=3D"doc_size", nullable =3D false) + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size =3D size; + } +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/mixed/Document.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/mixed/File.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/mixed/File.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/mixed/File.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,52 @@ +//$Id: File.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.mixed; + +import javax.persistence.DiscriminatorColumn; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.SecondaryTable; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.SINGLE_TABLE) +(a)Table(name =3D "FileMixed") +(a)SecondaryTable(name =3D "FileFolderMixed") +(a)DiscriminatorColumn(length =3D 1) +public abstract class File { + private String name; + private Folder parent; + + File() { + } + + public File(String name) { + this.name =3D name; + } + + @Id + public String getName() { + return name; + } + + public void setName(String id) { + this.name =3D id; + } + + @ManyToOne + @JoinColumn(table =3D "FileFolderMixed") + public Folder getParent() { + return parent; + } + + public void setParent(Folder parent) { + this.parent =3D parent; + } + +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/mixed/File.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/mixed/Folder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/mixed/Folder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/mixed/Folder.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Folder.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.mixed; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorValue("F") +public class Folder extends File { + private Set children =3D new HashSet(); + + Folder() { + } + + public Folder(String name) { + super( name ); + } + + @OneToMany(mappedBy =3D "parent") + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children =3D children; + } +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/mixed/Folder.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/mixed/SubclassTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/mixed/SubclassTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/mixed/SubclassTest.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,76 @@ +//$Id: SubclassTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.mixed; + +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.exception.SQLGrammarException; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class SubclassTest extends TestCase { + + public SubclassTest(String x) { + super( x ); + } + + public void testDefault() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + File doc =3D new Document( "Enron Stuff To Shred", 1000 ); + Folder folder =3D new Folder( "Enron" ); + s.persist( doc ); + s.persist( folder ); + try { + tx.commit(); + } + catch (SQLGrammarException e) { + System.err.println( e.getSQLException().getNextException() ); + } + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + List result =3D s.createCriteria( File.class ).list(); + assertNotNull( result ); + assertEquals( 2, result.size() ); + File f2 =3D (File) result.get( 0 ); + checkClassType( f2, doc, folder ); + f2 =3D (File) result.get( 1 ); + checkClassType( f2, doc, folder ); + s.delete( result.get( 0 ) ); + s.delete( result.get( 1 ) ); + tx.commit(); + s.close(); + } + + private void checkClassType(File fruitToTest, File f, Folder a) { + if ( fruitToTest.getName().equals( f.getName() ) ) { + assertFalse( fruitToTest instanceof Folder ); + } + else if ( fruitToTest.getName().equals( a.getName() ) ) { + assertTrue( fruitToTest instanceof Folder ); + } + else { + fail( "Result does not contains the previously inserted elements" ); + } + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + File.class, + Folder.class, + Document.class, + SymbolicLink.class + }; + } + +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/mixed/SubclassTest.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/mixed/SymbolicLink.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/mixed/SymbolicLink.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/mixed/SymbolicLink.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,35 @@ +//$Id: SymbolicLink.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.mixed; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.SecondaryTable; + +(a)Entity +(a)DiscriminatorValue("L") +(a)SecondaryTable(name =3D "SymbolicLinkMixed") +public class SymbolicLink extends File { + + File target; + + SymbolicLink() { + } + + public SymbolicLink(File target) { + this.target =3D target; + } + + @ManyToOne(optional =3D false) + @JoinColumn(table =3D "SymbolicLinkMixed") + public File getTarget() { + return target; + } + + public void setTarget(File target) { + this.target =3D target; + } + + +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/mixed/SymbolicLink.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/singletable/Building.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Building.java (rev = 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Building.java 2009-11-24 21:03:15 UTC (rev = 18049) @@ -0,0 +1,43 @@ +//$Id: Building.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.singletable; + +import javax.persistence.Column; +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.annotations.ForceDiscriminator; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorColumn(name =3D "discriminator_disc") +(a)ForceDiscriminator +(a)DiscriminatorValue("B") +public class Building { + @Id + @GeneratedValue + @Column(name =3D "discriminator_id") + private Integer id; + @Column(name =3D "discriminator_street") + private String street; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street =3D street; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/singletable/Funk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Funk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Funk.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,22 @@ +//$Id: Funk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.singletable; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorValue("1") +public class Funk extends Music { + private int starred; + + public int getStarred() { + return starred; + } + + public void setStarred(int starred) { + this.starred =3D starred; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/singletable/House.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/House.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/House.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,13 @@ +//$Id: House.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.singletable; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorValue("H") +public class House extends Building { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/singletable/Music.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Music.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Music.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,53 @@ +//$Id: Music.java 16303 2009-04-11 04:42:16Z gbadner $ +package org.hibernate.test.annotations.inheritance.singletable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; + +import org.hibernate.annotations.DiscriminatorFormula; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorColumn(discriminatorType=3DDiscriminatorType.INTEGER) +(a)DiscriminatorFormula("case when zik_type is null then 0 else zik_type e= nd") +(a)Table(uniqueConstraints =3D @UniqueConstraint(columnNames =3D {"avgBeat= ", "starred"} )) +public abstract class Music { + private Integer id; + private int avgBeat; + private Integer type; + + @Column(name =3D "zik_type") + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type =3D type; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public int getAvgBeat() { + return avgBeat; + } + + public void setAvgBeat(int avgBeat) { + this.avgBeat =3D avgBeat; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/singletable/Noise.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Noise.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Noise.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,13 @@ +//$Id: Noise.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.singletable; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorValue("0") +public class Noise extends Music { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/singletable/PaperTrash.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/PaperTrash.java (re= v 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/PaperTrash.java 2009-11-24 21:03:15 UTC (re= v 18049) @@ -0,0 +1,11 @@ +//$Id: PaperTrash.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.singletable; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class PaperTrash extends Trash { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/singletable/Rock.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Rock.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Rock.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,13 @@ +//$Id: Rock.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.singletable; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorValue("2") +public class Rock extends Music { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/singletable/Trash.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Trash.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/singletable/Trash.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,19 @@ +//$Id: Trash.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.singletable; + +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorColumn(discriminatorType =3D DiscriminatorType.INTEGER) +public class Trash { + @Id + @GeneratedValue + private Integer id; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/union/Document.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/union/Document.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/union/Document.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,32 @@ +//$Id: Document.java 16293 2009-04-10 19:17:45Z gbadner $ +package org.hibernate.test.annotations.inheritance.union; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "DocumentUnion") +public class Document extends File { + private int size; + + Document() { + } + + Document(String name, int size) { + super( name ); + this.size =3D size; + } + + @Column(name=3D"xsize") + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size =3D size; + } +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/union/Document.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/union/File.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/union/File.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/union/File.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,44 @@ +//$Id: File.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.union; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.TABLE_PER_CLASS) +public abstract class File { + private String name; + private Folder parent; + + File() { + } + + public File(String name) { + this.name =3D name; + } + + @Id + public String getName() { + return name; + } + + public void setName(String id) { + this.name =3D id; + } + + @ManyToOne + public Folder getParent() { + return parent; + } + + public void setParent(Folder parent) { + this.parent =3D parent; + } + +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/union/File.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/union/Folder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/union/Folder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/union/Folder.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Folder.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.union; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "FolderUnion") +public class Folder extends File { + private Set children =3D new HashSet(); + + Folder() { + } + + public Folder(String name) { + super( name ); + } + + @OneToMany(mappedBy =3D "parent") + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children =3D children; + } +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/union/Folder.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/union/SubclassTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/union/SubclassTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/union/SubclassTest.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,68 @@ +//$Id: SubclassTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.union; + +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class SubclassTest extends TestCase { + + public SubclassTest(String x) { + super( x ); + } + + public void testDefault() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + File doc =3D new Document( "Enron Stuff To Shred", 1000 ); + Folder folder =3D new Folder( "Enron" ); + s.persist( doc ); + s.persist( folder ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + List result =3D s.createCriteria( File.class ).list(); + assertNotNull( result ); + assertEquals( 2, result.size() ); + File f2 =3D (File) result.get( 0 ); + checkClassType( f2, doc, folder ); + f2 =3D (File) result.get( 1 ); + checkClassType( f2, doc, folder ); + tx.commit(); + s.close(); + } + + private void checkClassType(File fruitToTest, File f, Folder a) { + if ( fruitToTest.getName().equals( f.getName() ) ) { + assertFalse( fruitToTest instanceof Folder ); + } + else if ( fruitToTest.getName().equals( a.getName() ) ) { + assertTrue( fruitToTest instanceof Folder ); + } + else { + fail( "Result does not contains the previously inserted elements" ); + } + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + File.class, + Folder.class, + Document.class, + SymbolicLink.class + }; + } + +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/union/SubclassTest.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/inheritance/union/SymbolicLink.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/union/SymbolicLink.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/inheritance/union/SymbolicLink.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,31 @@ +//$Id: SymbolicLink.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.inheritance.union; + +import javax.persistence.Entity; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +(a)Entity +(a)Table(name =3D "SymbolicLinkUnion") +public class SymbolicLink extends File { + + File target; + + SymbolicLink() { + } + + public SymbolicLink(File target) { + this.target =3D target; + } + + @ManyToOne(optional =3D false) + public File getTarget() { + return target; + } + + public void setTarget(File target) { + this.target =3D target; + } + + +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/inheritance/union/SymbolicLink.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/interfaces/Contact.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/interfaces/Contact.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/interfaces/Contact.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ +//$Id: Contact.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.interfaces; + +/** + * @author Emmanuel Bernard + */ +public interface Contact { + Integer getId(); + + String getName(); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/interfaces/ContactImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/interfaces/ContactImpl.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/interfaces/ContactImpl.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: ContactImpl.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.interfaces; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class ContactImpl implements Contact { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/interfaces/InterfacesTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/interfaces/InterfacesTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/interfaces/InterfacesTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,20 @@ +//$Id: InterfacesTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.interfaces; + +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class InterfacesTest extends TestCase { + public void testInterface() { + + } + + protected Class[] getMappings() { + return new Class[]{ + ContactImpl.class, + UserImpl.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/interfaces/User.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/interfaces/User.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/interfaces/User.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,15 @@ +//$Id: User.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.interfaces; + +import java.util.Collection; + +/** + * @author Emmanuel Bernard + */ +public interface User { + Integer getId(); + + Collection getContacts(); + + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/interfaces/UserImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/interfaces/UserImpl.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/interfaces/UserImpl.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,36 @@ +//$Id: UserImpl.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.interfaces; + +import java.util.Collection; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class UserImpl implements User { + private Collection contacts; + private Integer id; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @OneToMany(targetEntity =3D ContactImpl.class) + public Collection getContacts() { + return contacts; + } + + public void setContacts(Collection contacts) { + this.contacts =3D contacts; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/join/A.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/A.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/A.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$Id: A.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.join; + +import java.util.Date; +import javax.persistence.MappedSuperclass; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public abstract class A { + @Column(nullable =3D false) + private Date createDate; + + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate =3D createDate; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/join/B.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/B.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/B.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,38 @@ +//$Id: B.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.join; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance( strategy =3D InheritanceType.SINGLE_TABLE ) +public abstract class B extends A { + @Id + @GeneratedValue + private Integer id; + @Column(nullable =3D false) private String name; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/join/C.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/C.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/C.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +//$Id: C.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.join; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.DiscriminatorValue; +import javax.persistence.SecondaryTable; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorValue("C") +(a)SecondaryTable(name=3D"C") +public class C extends B { + @Column(table =3D "C") private int age; + + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age =3D age; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/join/Cat.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/Cat.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/Cat.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,101 @@ +//$Id: Cat.java 16418 2009-04-23 09:55:33Z jcosta(a)redhat.com $ +package org.hibernate.test.annotations.join; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.SecondaryTable; +import javax.persistence.SecondaryTables; +import javax.persistence.UniqueConstraint; + +import org.hibernate.annotations.Index; +import org.hibernate.annotations.Table; +import org.hibernate.annotations.ForeignKey; +import org.hibernate.annotations.Tables; +import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.SQLInsert; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)SecondaryTables({ +(a)SecondaryTable(name =3D "`Cat nbr1`"), +(a)SecondaryTable(name =3D "Cat2", uniqueConstraints =3D {@UniqueConstrain= t(columnNames =3D {"storyPart2"})}) + }) +(a)Tables( { + @Table(appliesTo =3D "Cat", indexes =3D @Index(name =3D "secondname", + columnNames =3D "secondName"), comment =3D "My cat table" ), + @Table(appliesTo =3D "Cat2", foreignKey =3D @ForeignKey(name=3D"FK_CAT2_C= AT"), fetch =3D FetchMode.SELECT, + sqlInsert=3D@SQLInsert(sql=3D"insert into Cat2(storyPart2, id) values(u= pper(?), ?)") ) + } ) +public class Cat implements Serializable { + + private Integer id; + private String name; + private String secondName; + private String storyPart1; + private String storyPart2; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + @Index(name =3D "nameindex") + public String getName() { + return name; + } + + public void setId(Integer integer) { + id =3D integer; + } + + public void setName(String string) { + name =3D string; + } + + public String getSecondName() { + return secondName; + } + + public void setSecondName(String secondName) { + this.secondName =3D secondName; + } + +// Bug HHH-36 +// @OneToMany(cascade=3DCascadeType.ALL, fetch=3DFetchType.EAGER) +// @JoinColumn(name=3D"CAT_ID", secondaryTable=3D"ExtendedLife") +// public Set getLifes() { +// return lifes; +// } +// +// public void setLifes(Set collection) { +// lifes =3D collection; +// } + + @Column(table =3D "`Cat nbr1`") + @Index(name =3D "story1index") + public String getStoryPart1() { + return storyPart1; + } + + @Column(table =3D "Cat2", nullable =3D false) + public String getStoryPart2() { + return storyPart2; + } + + + public void setStoryPart1(String string) { + storyPart1 =3D string; + } + + + public void setStoryPart2(String string) { + storyPart2 =3D string; + } + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/join/Death.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/Death.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/Death.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,30 @@ +//$Id: Death.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.join; + +import java.io.Serializable; +import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.SecondaryTable; +import javax.persistence.PrimaryKeyJoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)SecondaryTable( + name =3D "ExtendedDeath", + pkJoinColumns =3D @PrimaryKeyJoinColumn(name =3D "DEATH_ID") +) +public class Death implements Serializable { + @Id + @GeneratedValue(strategy =3D GenerationType.AUTO) + public Integer id; + @Column(name =3D "death_date") + public Date date; + @Column(table =3D "ExtendedDeath") + public String howDoesItHappen; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/join/Dog.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/Dog.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/Dog.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,40 @@ +//$Id: Dog.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.join; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.SecondaryTable; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)SecondaryTable( + name =3D "DogThoroughbred", + pkJoinColumns =3D {@PrimaryKeyJoinColumn(name =3D "NAME", referencedColu= mnName =3D "name"), + @PrimaryKeyJoinColumn(name =3D "OWNER_NAME", referencedColumnName =3D "o= wnerName")} +) +public class Dog { + @Id + public DogPk id; + public int weight; + @Column(table =3D "DogThoroughbred") + public String thoroughbredName; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Dog ) ) return false; + + final Dog dog =3D (Dog) o; + + if ( !id.equals( dog.id ) ) return false; + + return true; + } + + public int hashCode() { + return id.hashCode(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/join/DogPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/DogPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/DogPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: DogPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.join; + +import java.io.Serializable; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class DogPk implements Serializable { + public String name; + public String ownerName; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof DogPk ) ) return false; + + final DogPk dogPk =3D (DogPk) o; + + if ( !name.equals( dogPk.name ) ) return false; + if ( !ownerName.equals( dogPk.ownerName ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D name.hashCode(); + result =3D 29 * result + ownerName.hashCode(); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/join/JoinTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/JoinTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/JoinTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,206 @@ +//$Id: JoinTest.java 16418 2009-04-23 09:55:33Z jcosta(a)redhat.com $ +package org.hibernate.test.annotations.join; + +import java.util.Date; + +import org.hibernate.Criteria; +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.criterion.Expression; +import org.hibernate.mapping.Join; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class JoinTest extends TestCase { + + public void testDefaultValue() throws Exception { + Join join =3D (Join) getCfg().getClassMapping( Life.class.getName() ).ge= tJoinClosureIterator().next(); + assertEquals( "ExtendedLife", join.getTable().getName() ); + org.hibernate.mapping.Column owner =3D new org.hibernate.mapping.Column(= ); + owner.setName( "LIFE_ID" ); + assertTrue( join.getTable().getPrimaryKey().containsColumn( owner ) ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Life life =3D new Life(); + life.duration =3D 15; + life.fullDescription =3D "Long long description"; + s.persist( life ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "from " + Life.class.getName() ); + life =3D (Life) q.uniqueResult(); + assertEquals( "Long long description", life.fullDescription ); + tx.commit(); + s.close(); + } + + public void testCompositePK() throws Exception { + Join join =3D (Join) getCfg().getClassMapping( Dog.class.getName() ).get= JoinClosureIterator().next(); + assertEquals( "DogThoroughbred", join.getTable().getName() ); + org.hibernate.mapping.Column owner =3D new org.hibernate.mapping.Column(= ); + owner.setName( "OWNER_NAME" ); + assertTrue( join.getTable().getPrimaryKey().containsColumn( owner ) ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Dog dog =3D new Dog(); + DogPk id =3D new DogPk(); + id.name =3D "Thalie"; + id.ownerName =3D "Martine"; + dog.id =3D id; + dog.weight =3D 30; + dog.thoroughbredName =3D "Colley"; + s.persist( dog ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "from Dog" ); + dog =3D (Dog) q.uniqueResult(); + assertEquals( "Colley", dog.thoroughbredName ); + tx.commit(); + s.close(); + } + + public void testExplicitValue() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Death death =3D new Death(); + death.date =3D new Date(); + death.howDoesItHappen =3D "Well, haven't seen it"; + s.persist( death ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "from " + Death.class.getName() ); + death =3D (Death) q.uniqueResult(); + assertEquals( "Well, haven't seen it", death.howDoesItHappen ); + s.delete( death ); + tx.commit(); + s.close(); + } + + public void testManyToOne() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Life life =3D new Life(); + Cat cat =3D new Cat(); + cat.setName( "kitty" ); + cat.setStoryPart2( "and the story continues" ); + life.duration =3D 15; + life.fullDescription =3D "Long long description"; + life.owner =3D cat; + s.persist( life ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Criteria crit =3D s.createCriteria( Life.class ); + crit.createCriteria( "owner" ).add( Expression.eq( "name", "kitty" ) ); + life =3D (Life) crit.uniqueResult(); + assertEquals( "Long long description", life.fullDescription ); + s.delete( life.owner ); + s.delete( life ); + tx.commit(); + s.close(); + } + + public void testUniqueConstaintOnSecondaryTable() throws Exception { + Cat cat =3D new Cat(); + cat.setStoryPart2( "My long story" ); + Cat cat2 =3D new Cat(); + cat2.setStoryPart2( "My long story" ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + try { + s.persist( cat ); + s.persist( cat2 ); + tx.commit(); + fail( "unique constraints violation on secondary table" ); + } + catch (HibernateException e) { + //success + } + finally { + if ( tx !=3D null ) tx.rollback(); + s.close(); + } + } + + public void testFetchModeOnSecondaryTable() throws Exception { + Cat cat =3D new Cat(); + cat.setStoryPart2( "My long story" ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + + s.persist( cat ); + s.flush(); + s.clear(); + = + s.get( Cat.class, cat.getId() ); + //Find a way to test it, I need to define the secondary table on a subcl= ass + + tx.rollback(); + s.close(); + } + + public void testCustomSQL() throws Exception { + Cat cat =3D new Cat(); + String storyPart2 =3D "My long story"; + cat.setStoryPart2( storyPart2 ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + + s.persist( cat ); + s.flush(); + s.clear(); + + Cat c =3D (Cat) s.get( Cat.class, cat.getId() ); + assertEquals( storyPart2.toUpperCase(), c.getStoryPart2() ); + + tx.rollback(); + s.close(); + } + + public void testMappedSuperclassAndSecondaryTable() throws Exception { + Session s =3D openSession( ); + s.getTransaction().begin(); + C c =3D new C(); + c.setAge( 12 ); + c.setCreateDate( new Date() ); + c.setName( "Bob" ); + s.persist( c ); + s.flush(); + s.clear(); + c=3D (C) s.get( C.class, c.getId() ); + assertNotNull( c.getCreateDate() ); + assertNotNull( c.getName() ); + s.getTransaction().rollback(); + s.close(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + Life.class, + Death.class, + Cat.class, + Dog.class, + A.class, + B.class, + C.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/join/Life.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/Life.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/join/Life.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: Life.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.join; + +import java.io.Serializable; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.SecondaryTable; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)SecondaryTable(name =3D "ExtendedLife") +public class Life implements Serializable { + @Id + @GeneratedValue(strategy =3D GenerationType.AUTO) + @Column(name =3D "LIFE_ID") + public Integer id; + + public int duration; + @Column(table =3D "ExtendedLife") + public String fullDescription; + + @ManyToOne(cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}) + @JoinColumn(name =3D "CAT_ID", table =3D "ExtendedLife") + public Cat owner; + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/loader/Loader.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/loader/Loader.hbm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/loader/Loader.hbm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,21 @@ + + + + + + + + + + select {p.*} from Player p where p.team_id =3D ? + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/loader/LoaderTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/loader/LoaderTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/loader/LoaderTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,69 @@ +//$Id: LoaderTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.loader; + +import java.util.Set; +import java.util.Iterator; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + + +/** + * @author Emmanuel Bernard + */ +public class LoaderTest extends TestCase { + + + protected String[] getXmlFiles() { + return new String[] { + "org/hibernate/test/annotations/loader/Loader.hbm.xml" + }; + } + + public void testBasic() throws Exception { + Session s =3D openSession( ); + Transaction tx =3D s.beginTransaction(); + Team t =3D new Team(); + Player p =3D new Player(); + p.setName("me"); + t.getPlayers().add(p); + p.setTeam(t); + = + + try { + s.persist(p); + s.persist(t); + tx.commit(); + s.close(); + = + s=3D openSession( ); + tx =3D s.beginTransaction(); + Team t2 =3D (Team)s.load(Team.class,new Long(1)); + Set players =3D t2.getPlayers(); + Iterator iterator =3D players.iterator(); + assertEquals("me", iterator.next().getName()); + tx.commit(); + = + } + catch (Exception e) { + e.printStackTrace(); + if ( tx !=3D null ) tx.rollback(); + } + finally { + s.close(); + } + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + Player.class, + Team.class + }; + } + +} + Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/loader/LoaderTest.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/loader/Player.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/loader/Player.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/loader/Player.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,48 @@ +package org.hibernate.test.annotations.loader; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; + +(a)Entity +public class Player { + = + private Long id; + private Team team; + private String name; + = + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + @ManyToOne(targetEntity =3D Team.class) + @Fetch(FetchMode.SELECT) + @JoinColumn(name =3D "team_id") + public Team getTeam() { + return team; + } + + public void setTeam(Team team) { + this.team =3D team; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + = +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/loader/Player.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/loader/Team.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/loader/Team.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/loader/Team.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,45 @@ +package org.hibernate.test.annotations.loader; + +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.Loader; +import org.hibernate.annotations.NamedNativeQueries; +import org.hibernate.annotations.NamedNativeQuery; + +import javax.persistence.NamedQuery; + +(a)Entity +public class Team { + private Long id; + private Set players =3D new HashSet(); + = + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + = + @OneToMany(targetEntity =3D Player.class, mappedBy =3D "team", fetch =3D = FetchType.EAGER) + @Fetch(FetchMode.SELECT) + @Loader(namedQuery =3D "loadByTeam") + public Set getPlayers() { + return players; + } + + public void setPlayers(Set players) { + this.players =3D players; + } +} Property changes on: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hi= bernate/test/annotations/loader/Team.java ___________________________________________________________________ Name: svn:executable + * Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/lob/Book.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/lob/Book.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/lob/Book.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,79 @@ +//$Id: Book.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.lob; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "lob_book") +public class Book { + private Integer id; + private String shortDescription; + private String fullText; + private Character[] code; + private char[] code2; + private Editor editor; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getShortDescription() { + return shortDescription; + } + + public void setShortDescription(String shortDescription) { + this.shortDescription =3D shortDescription; + } + + @Lob + @Column(name =3D "fld_fulltext") + public String getFullText() { + return fullText; + } + + public void setFullText(String fullText) { + this.fullText =3D fullText; + } + + @Lob + @Column(name =3D "fld_code") + public Character[] getCode() { + return code; + } + + public void setCode(Character[] code) { + this.code =3D code; + } + + @Lob + public char[] getCode2() { + return code2; + } + + public void setCode2(char[] code2) { + this.code2 =3D code2; + } + + @Lob + public Editor getEditor() { + return editor; + } + + public void setEditor(Editor editor) { + this.editor =3D editor; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/lob/CompiledCode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/lob/CompiledCode.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/lob/CompiledCode.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,56 @@ +//$Id: CompiledCode.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.lob; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Lob; + +/** + * Compiled code representation + * + * @author Emmanuel Bernard + */ +(a)Entity +public class CompiledCode { + private Integer id; + private Byte[] header; + private byte[] fullCode; + private byte[] metadata; + + public byte[] getMetadata() { + return metadata; + } + + public void setMetadata(byte[] metadata) { + this.metadata =3D metadata; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @Lob + public Byte[] getHeader() { + return header; + } + + public void setHeader(Byte[] header) { + this.header =3D header; + } + + @Lob + public byte[] getFullCode() { + return fullCode; + } + + public void setFullCode(byte[] fullCode) { + this.fullCode =3D fullCode; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/lob/Editor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/lob/Editor.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/lob/Editor.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,19 @@ +//$Id: Editor.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.lob; + +import java.io.Serializable; + +/** + * @author Emmanuel Bernard + */ +public class Editor implements Serializable { + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/lob/LobTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/lob/LobTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/lob/LobTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,131 @@ +//$Id: LobTest.java 17724 2009-10-13 15:47:59Z stliu $ +package org.hibernate.test.annotations.lob; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class LobTest extends TestCase { + public void testSerializableToBlob() throws Exception { + Book book =3D new Book(); + Editor editor =3D new Editor(); + editor.setName( "O'Reilly" ); + book.setEditor( editor ); + book.setCode2( new char[]{'r'} ); + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( book ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + Book loadedBook =3D (Book) s.get( Book.class, book.getId() ); + assertNotNull( loadedBook.getEditor() ); + assertEquals( book.getEditor().getName(), loadedBook.getEditor().getName= () ); + loadedBook.setEditor( null ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + loadedBook =3D (Book) s.get( Book.class, book.getId() ); + assertNull( loadedBook.getEditor() ); + tx.commit(); + s.close(); + + } + + public void testClob() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Book b =3D new Book(); + b.setShortDescription( "Hibernate Bible" ); + b.setFullText( "Hibernate in Action aims to..." ); + b.setCode( new Character[]{'a', 'b', 'c'} ); + b.setCode2( new char[]{'a', 'b', 'c'} ); + s.persist( b ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Book b2 =3D (Book) s.get( Book.class, b.getId() ); + assertNotNull( b2 ); + assertEquals( b2.getFullText(), b.getFullText() ); + assertEquals( b2.getCode()[1].charValue(), b.getCode()[1].charValue() ); + assertEquals( b2.getCode2()[2], b.getCode2()[2] ); + tx.commit(); + s.close(); + } + + public void testBlob() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + CompiledCode cc =3D new CompiledCode(); + Byte[] header =3D new Byte[2]; + header[0] =3D new Byte( (byte) 3 ); + header[1] =3D new Byte( (byte) 0 ); + cc.setHeader( header ); + int codeSize =3D 5; + byte[] full =3D new byte[codeSize]; + for ( int i =3D 0; i < codeSize ; i++ ) { + full[i] =3D (byte) ( 1 + i ); + } + cc.setFullCode( full ); + s.persist( cc ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + CompiledCode recompiled =3D (CompiledCode) s.get( CompiledCode.class, cc= .getId() ); + assertEquals( recompiled.getHeader()[1], cc.getHeader()[1] ); + assertEquals( recompiled.getFullCode()[codeSize - 1], cc.getFullCode()[c= odeSize - 1] ); + tx.commit(); + s.close(); + } + + public void testBinary() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + CompiledCode cc =3D new CompiledCode(); + byte[] metadata =3D new byte[2]; + metadata[0] =3D (byte) 3; + metadata[1] =3D (byte) 0; + cc.setMetadata( metadata ); + s.persist( cc ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + CompiledCode recompiled =3D (CompiledCode) s.get( CompiledCode.class, cc= .getId() ); + assertEquals( recompiled.getMetadata()[1], cc.getMetadata()[1] ); + tx.commit(); + s.close(); + } + + @Override + protected boolean runForCurrentDialect() { + return super.runForCurrentDialect() && getDialect().supportsExpectedLobU= sagePattern(); + } + + public LobTest(String x) { + super( x ); + } + + protected Class[] getMappings() { + return new Class[]{ + Book.class, + CompiledCode.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Building.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Building.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Building.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: Building.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Building { + @Id @GeneratedValue private Long id; + + @ManyToOne @JoinColumn(name=3D"company_id", referencedColumnName =3D "nam= e") + private BuildingCompany company; + + public BuildingCompany getCompany() { + return company; + } + + public void setCompany(BuildingCompany company) { + this.company =3D company; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/BuildingCompany.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/BuildingCompany.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/BuildingCompany.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,29 @@ +//$Id: BuildingCompany.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.util.Date; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class BuildingCompany extends Company { + @Id @GeneratedValue private Long id; + private Date foundedIn; + + public Date getFoundedIn() { + return foundedIn; + } + + public void setFoundedIn(Date foundedIn) { + this.foundedIn =3D foundedIn; + } + + public Long getId() { + return id; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Cat.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Cat.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Cat.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,68 @@ +//$Id: Cat.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.util.Set; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.ManyToMany; +import javax.persistence.Table; +import javax.persistence.JoinTable; +import javax.persistence.JoinColumn; + +import org.hibernate.annotations.Index; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_cat") +//ANN-630 +//@org.hibernate.annotations.Table(appliesTo=3D "TT", indexes =3D @Index(n= ame =3D "testidx", columnNames =3D "cat_id")) +public class Cat { + private CatPk id; + private int age; + private Set humanContacts; + + @ManyToMany + //@Index(name =3D "CAT_HUMAN_IDX") + @JoinTable(name=3D"TT") + public Set getHumanContacts() { + return humanContacts; + } + + public void setHumanContacts(Set humanContacts) { + this.humanContacts =3D humanContacts; + } + + @EmbeddedId() + public CatPk getId() { + return id; + } + + public void setId(CatPk id) { + this.id =3D id; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age =3D age; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Cat ) ) return false; + + final Cat cat =3D (Cat) o; + + if ( !id.equals( cat.id ) ) return false; + + return true; + } + + public int hashCode() { + return id.hashCode(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/CatPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/CatPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/CatPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,50 @@ +//$Id: CatPk.java 16343 2009-04-15 18:33:43Z gbadner $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +public class CatPk implements Serializable { + private String name; + private String thoroughbred; + + @Column(length=3D128) + public String getThoroughbred() { + return thoroughbred; + } + + public void setThoroughbred(String thoroughbred) { + this.thoroughbred =3D thoroughbred; + } + + @Column(length=3D128) + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof CatPk ) ) return false; + + final CatPk catPk =3D (CatPk) o; + + if ( !name.equals( catPk.name ) ) return false; + if ( !thoroughbred.equals( catPk.thoroughbred ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D name.hashCode(); + result =3D 29 * result + thoroughbred.hashCode(); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/City.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/City.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/City.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: City.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_city") +public class City { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Company.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Company.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Company.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: Company.java 17529 2009-09-19 19:59:46Z stliu $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; +import javax.persistence.MappedSuperclass; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Company implements Serializable { + @Column private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Contractor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Contractor.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Contractor.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +//$Id: Employee.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; + +import javax.persistence.Entity; + +/** + * Employee in an Employer-Employee relationship + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)SuppressWarnings("serial") +public class Contractor extends Employee implements Serializable { + + private float hourlyRate; + + public float getHourlyRate() { + return hourlyRate; + } + + public void setHourlyRate(float hourlyRate) { + this.hourlyRate =3D hourlyRate; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Employee.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Employee.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Employee.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,62 @@ +//$Id: Employee.java 14781 2008-06-18 18:04:17Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; +import java.util.Collection; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.ManyToMany; +import javax.persistence.Column; + +import org.hibernate.annotations.Cascade; + +/** + * Employee in an Employer-Employee relationship + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +(a)SuppressWarnings("serial") +public class Employee implements Serializable { + private Integer id; + private Collection employers; + private String name; + + @Column(name=3D"fld_name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer integer) { + id =3D integer; + } + + @ManyToMany( + cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}, + mappedBy =3D "employees" + ) + @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, + org.hibernate.annotations.CascadeType.PERSIST}) + public Collection getEmployers() { + return employers; + } + + public void setEmployers(Collection employers) { + this.employers =3D employers; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Employer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Employer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Employer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,80 @@ +//$Id: Employer.java 14764 2008-06-12 13:41:16Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.OrderBy; +import javax.persistence.Table; + +import org.hibernate.annotations.Cascade; + +/** + * Employer in a employer-Employee relationship + * + * @author Emmanuel Bernard + */ +(a)Entity() +(a)Table(name=3D"`Employer`") +(a)SuppressWarnings({"serial", "unchecked"}) +public class Employer implements Serializable { + private Integer id; + private Collection employees; + private List contractors; + + @ManyToMany( + targetEntity =3D org.hibernate.test.annotations.manytomany.Contractor.c= lass, + cascade =3D {CascadeType.PERSIST, CascadeType.MERGE} + ) + @JoinTable( + name =3D "EMPLOYER_CONTRACTOR", + joinColumns =3D {@JoinColumn(name =3D "EMPLOYER_ID")}, + inverseJoinColumns =3D {@JoinColumn(name =3D "CONTRACTOR_ID")} + ) + @Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE) + @OrderBy("name desc") = + public List getContractors() { + return contractors; + } + + public void setContractors(List contractors) { + this.contractors =3D contractors; + } + + @ManyToMany( + targetEntity =3D org.hibernate.test.annotations.manytomany.Employee.cla= ss, + cascade =3D {CascadeType.PERSIST, CascadeType.MERGE} + ) + @JoinTable( + name =3D "EMPLOYER_EMPLOYEE", + joinColumns =3D {@JoinColumn(name =3D "EMPER_ID")}, + inverseJoinColumns =3D {@JoinColumn(name =3D "EMPEE_ID")} + ) + @Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE) + @OrderBy("name asc") + public Collection getEmployees() { + return employees; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setEmployees(Collection set) { + employees =3D set; + } + + public void setId(Integer integer) { + id =3D integer; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Friend.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Friend.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Friend.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,59 @@ +//$Id: Friend.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; + + +/** + * Friend has other friends in a many to many way + * + * @author Emmanuel Bernard + */ +(a)Entity() +public class Friend implements Serializable { + private Integer id; + private String name; + private Set friends; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public String getName() { + return name; + } + + public void setId(Integer integer) { + id =3D integer; + } + + public void setName(String string) { + name =3D string; + } + + @ManyToMany( + cascade =3D {CascadeType.PERSIST, CascadeType.MERGE} + ) + @JoinTable( + name =3D "FRIEND2FRIEND", + joinColumns =3D {@JoinColumn(name =3D "FROM_FR", nullable =3D false)}, + inverseJoinColumns =3D {@JoinColumn(name =3D "TO_FR", nullable =3D fals= e)} + ) + public Set getFriends() { + return friends; + } + + public void setFriends(Set friend) { + this.friends =3D friend; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Group.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Group.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Group.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,50 @@ +//$Id: Group.java 17529 2009-09-19 19:59:46Z stliu $ +package org.hibernate.test.annotations.manytomany; + +import java.util.Collection; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.OrderBy; +import javax.persistence.Table; + +import org.hibernate.annotations.Where; +import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.Filter; +import org.hibernate.annotations.FilterJoinTable; +import org.hibernate.annotations.WhereJoinTable; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_group") +(a)FilterDef(name=3D"Groupfilter") +public class Group { + private Integer id; + private Collection permissions; + + @Id + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @ManyToMany(cascade =3D CascadeType.PERSIST) + @OrderBy("expirationDate") + @Where(clause =3D "1=3D1") + @WhereJoinTable(clause =3D "2=3D2") + @Filter(name=3D"Groupfilter", condition =3D "3=3D3") + @FilterJoinTable(name=3D"Groupfilter", condition =3D "4=3D4") + public Collection getPermissions() { + return permissions; + } + + public void setPermissions(Collection permissions) { + this.permissions =3D permissions; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/GroupWithSet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/GroupWithSet.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/GroupWithSet.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,55 @@ +//$Id: GroupWithSet.java 17529 2009-09-19 19:59:46Z stliu $ +package org.hibernate.test.annotations.manytomany; + +import java.util.Collection; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.OrderBy; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; + +import org.hibernate.annotations.Where; +import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.Filter; +import org.hibernate.annotations.FilterJoinTable; +import org.hibernate.annotations.WhereJoinTable; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_group") +(a)FilterDef(name=3D"Groupfilter") +public class GroupWithSet { + private Integer id; + private Set permissions; + + @Id + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @ManyToMany(cascade =3D CascadeType.PERSIST) + @OrderBy("expirationDate") + @Where(clause =3D "1=3D1") + @WhereJoinTable(clause =3D "2=3D2") + @Filter(name=3D"Groupfilter", condition =3D "3=3D3") + @FilterJoinTable(name=3D"Groupfilter", condition =3D "4=3D4") + public Set getPermissions() { + return permissions; + } + + public void setPermissions(Set permissions) { + this.permissions =3D permissions; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Inspector.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Inspector.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Inspector.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,37 @@ +//$Id: Inspector.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +class Inspector implements Serializable { + @Id + @GeneratedValue + @Column(name =3D "id") + private Long _id; + + private String name; + + public Long getId() { + return _id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/InspectorPrefixes.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/InspectorPrefixes.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/InspectorPrefixes.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,51 @@ +//$Id: InspectorPrefixes.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.test.annotations.manytomany; + +import java.util.ArrayList; +import java.util.List; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.PrimaryKeyJoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)PrimaryKeyJoinColumn(name =3D "inspector_id") +class InspectorPrefixes extends Inspector { + @Column(name =3D "prefixes", nullable =3D false) + private String prefixes; + @ManyToMany() + @JoinTable(name =3D "deserted_area", + joinColumns =3D @JoinColumn(name =3D "inspector_name", referencedColumn= Name =3D "name"), + inverseJoinColumns =3D @JoinColumn(name =3D "area_id", referencedColumn= Name =3D "id")) + private List desertedAreas =3D new ArrayList(); + + @ManyToMany() + @JoinTable(name =3D "inspector_prefixes_areas", + joinColumns =3D @JoinColumn(name =3D "inspector_id", referencedColumnNa= me =3D "inspector_id"), + inverseJoinColumns =3D @JoinColumn(name =3D "area_id", referencedColumn= Name =3D "id")) + private List areas =3D new ArrayList(); + + InspectorPrefixes() { + } + + InspectorPrefixes(String prefixes) { + this.prefixes =3D prefixes; + } + + public String getPrefixes() { + return this.prefixes; + } + + public List getAreas() { + return areas; + } + + public List getDesertedAreas() { + return desertedAreas; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/KnownClient.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/KnownClient.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/KnownClient.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,45 @@ +//$Id: KnownClient.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class KnownClient { + private Integer id; + private String name; + private Set stores; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToMany(mappedBy =3D "customers") + public Set getStores() { + return stores; + } + + public void setStores(Set stores) { + this.stores =3D stores; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Man.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Man.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Man.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,63 @@ +//$Id: Man.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToMany; + +/** + * Man knowing sevezral womens + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Man implements Serializable { + private ManPk id; + private String carName; + private Set womens; + + @ManyToMany(cascade =3D {CascadeType.ALL}, mappedBy =3D "mens") + public Set getWomens() { + return womens; + } + + public void setWomens(Set womens) { + this.womens =3D womens; + } + + @Id + public ManPk getId() { + return id; + } + + public void setId(ManPk id) { + this.id =3D id; + } + + public String getCarName() { + return carName; + } + + public void setCarName(String carName) { + this.carName =3D carName; + } + + public int hashCode() { + //a NPE can occurs, but I don't expect hashcode to be used before pk is = set + return getId().hashCode(); + } + + public boolean equals(Object obj) { + //a NPE can occurs, but I don't expect equals to be used before pk is set + if ( obj !=3D null && obj instanceof Man ) { + return getId().equals( ( (Man) obj ).getId() ); + } + else { + return false; + } + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/ManPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/ManPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/ManPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,60 @@ +//$Id: ManPk.java 16343 2009-04-15 18:33:43Z gbadner $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; +import javax.persistence.Embeddable; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class ManPk implements Serializable { + private String firstName; + private String lastName; + private boolean isElder; + + public boolean isElder() { + return isElder; + } + + public void setElder(boolean elder) { + isElder =3D elder; + } + + public int hashCode() { + //this implem sucks + return getFirstName().hashCode() + getLastName().hashCode() + ( isElder(= ) ? 0 : 1 ); + } + + public boolean equals(Object obj) { + //firstName and lastName are expected to be set in this implem + if ( obj !=3D null && obj instanceof ManPk ) { + ManPk other =3D (ManPk) obj; + return getFirstName().equals( other.getFirstName() ) + && getLastName().equals( other.getLastName() ) + && isElder() =3D=3D other.isElder(); + } + else { + return false; + } + } + + public void setFirstName(String firstName) { + this.firstName =3D firstName; + } + + public void setLastName(String lastName) { + this.lastName =3D lastName; + } + + @Column(length=3D128) + public String getFirstName() { + return firstName; + } + + @Column(length=3D128) + public String getLastName() { + return lastName; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/ManyToManyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/ManyToManyTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/ManyToManyTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,671 @@ +//$Id: ManyToManyTest.java 17529 2009-09-19 19:59:46Z stliu $ +package org.hibernate.test.annotations.manytomany; + + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.hibernate.Hibernate; +import org.hibernate.JDBCException; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * Many to many tests + * + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("unchecked") +public class ManyToManyTest extends TestCase { + + public ManyToManyTest(String x) { + super( x ); + } + + public void testDefault() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Store fnac =3D new Store(); + fnac.setName( "Fnac" ); + KnownClient emmanuel =3D new KnownClient(); + emmanuel.setName( "Emmanuel" ); + emmanuel.setStores( new HashSet() ); + fnac.setCustomers( new HashSet() ); + fnac.getCustomers().add( emmanuel ); + emmanuel.getStores().add( fnac ); + fnac.setImplantedIn( new HashSet() ); + City paris =3D new City(); + fnac.getImplantedIn().add( paris ); + paris.setName( "Paris" ); + s.persist( fnac ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Store store; + KnownClient knownClient; + City city; + store =3D (Store) s.get( Store.class, fnac.getId() ); + assertNotNull( store ); + assertNotNull( store.getCustomers() ); + assertEquals( 1, store.getCustomers().size() ); + knownClient =3D (KnownClient) store.getCustomers().iterator().next(); + assertEquals( emmanuel.getName(), knownClient.getName() ); + assertNotNull( store.getImplantedIn() ); + assertEquals( 1, store.getImplantedIn().size() ); + city =3D (City) store.getImplantedIn().iterator().next(); + assertEquals( paris.getName(), city.getName() ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + knownClient =3D (KnownClient) s.get( KnownClient.class, emmanuel.getId()= ); + assertNotNull( knownClient ); + assertNotNull( knownClient.getStores() ); + assertEquals( 1, knownClient.getStores().size() ); + store =3D (Store) knownClient.getStores().iterator().next(); + assertEquals( fnac.getName(), store.getName() ); + tx.commit(); + s.close(); + } + + public void testDefaultCompositePk() throws Exception { + Session s; + Transaction tx; + + s =3D openSession(); + tx =3D s.beginTransaction(); + CatPk catPk =3D new CatPk(); + catPk.setName( "Minou" ); + catPk.setThoroughbred( "Persan" ); + Cat cat =3D new Cat(); + cat.setId( catPk ); + cat.setAge( 32 ); + Woman woman =3D new Woman(); + WomanPk womanPk =3D new WomanPk(); + womanPk.setFirstName( "Emma" ); + womanPk.setLastName( "Peel" ); + woman.setId( womanPk ); + woman.setCats( new HashSet() ); + woman.getCats().add( cat ); + cat.setHumanContacts( new HashSet() ); + cat.getHumanContacts().add( woman ); + s.persist( woman ); + s.persist( cat ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Cat sameCat =3D (Cat) s.get( Cat.class, cat.getId() ); + assertNotNull( sameCat ); + assertNotNull( sameCat.getHumanContacts() ); + assertEquals( 1, sameCat.getHumanContacts().size() ); + Woman sameWoman =3D sameCat.getHumanContacts().iterator().next(); + assertEquals( sameWoman.getId().getLastName(), woman.getId().getLastName= () ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + sameWoman =3D (Woman) s.get( Woman.class, woman.getId() ); + assertNotNull( sameWoman ); + assertNotNull( sameWoman.getCats() ); + assertEquals( 1, sameWoman.getCats().size() ); + sameCat =3D sameWoman.getCats().iterator().next(); + assertEquals( cat.getAge(), sameCat.getAge() ); + tx.commit(); + s.close(); + } + + public void testMappedBy() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Store fnac =3D new Store(); + fnac.setName( "Fnac" ); + Supplier emi =3D new Supplier(); + emi.setName( "Emmanuel" ); + emi.setSuppStores( new HashSet() ); + fnac.setSuppliers( new HashSet() ); + fnac.getSuppliers().add( emi ); + emi.getSuppStores().add( fnac ); + s.persist( fnac ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Store store; + Supplier supplier; + store =3D (Store) s.get( Store.class, fnac.getId() ); + assertNotNull( store ); + assertNotNull( store.getSuppliers() ); + assertEquals( 1, store.getSuppliers().size() ); + supplier =3D (Supplier) store.getSuppliers().iterator().next(); + assertEquals( emi.getName(), supplier.getName() ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + supplier =3D (Supplier) s.get( Supplier.class, emi.getId() ); + assertNotNull( supplier ); + assertNotNull( supplier.getSuppStores() ); + assertEquals( 1, supplier.getSuppStores().size() ); + store =3D (Store) supplier.getSuppStores().iterator().next(); + assertEquals( fnac.getName(), store.getName() ); + tx.commit(); + s.close(); + } + + public void testBasic() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Employer er =3D new Employer(); + Employee ee =3D new Employee(); + s.persist( ee ); + Set erColl =3D new HashSet(); + Collection eeColl =3D new ArrayList(); + erColl.add( ee ); + eeColl.add( er ); + er.setEmployees( erColl ); + ee.setEmployers( eeColl ); + //s.persist(ee); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + er =3D (Employer) s.load( Employer.class, er.getId() ); + assertNotNull( er ); + assertNotNull( er.getEmployees() ); + assertEquals( 1, er.getEmployees().size() ); + Employee eeFromDb =3D (Employee) er.getEmployees().iterator().next(); + assertEquals( ee.getId(), eeFromDb.getId() ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + ee =3D (Employee) s.get( Employee.class, ee.getId() ); + assertNotNull( ee ); + assertFalse( "ManyToMany mappedBy lazyness", Hibernate.isInitialized( ee= .getEmployers() ) ); + tx.commit(); + assertFalse( "ManyToMany mappedBy lazyness", Hibernate.isInitialized( ee= .getEmployers() ) ); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + ee =3D (Employee) s.get( Employee.class, ee.getId() ); + assertNotNull( ee ); + er =3D ee.getEmployers().iterator().next(); + assertTrue( "second join non lazy", Hibernate.isInitialized( er ) ); + s.delete( er ); + s.delete( ee ); + tx.commit(); + s.close(); + } + + public void testOrderByEmployee() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Employer employer =3D new Employer(); + Employee employee1 =3D new Employee(); + employee1.setName( "Emmanuel" ); + Employee employee2 =3D new Employee(); + employee2.setName( "Alice" ); + s.persist( employee1 ); + s.persist( employee2 ); + Set erColl =3D new HashSet(); + Collection eeColl =3D new ArrayList(); + Collection eeColl2 =3D new ArrayList(); + erColl.add( employee1 ); + erColl.add( employee2 ); + eeColl.add( employer ); + eeColl2.add( employer ); + employer.setEmployees( erColl ); + employee1.setEmployers( eeColl ); + employee2.setEmployers( eeColl2 ); + + s.flush(); + s.clear(); + + employer =3D (Employer) s.get( Employer.class, employer.getId() ); + assertNotNull( employer ); + assertNotNull( employer.getEmployees() ); + assertEquals( 2, employer.getEmployees().size() ); + Employee eeFromDb =3D (Employee) employer.getEmployees().iterator().next= (); + assertEquals( employee2.getName(), eeFromDb.getName() ); + tx.rollback(); + s.close(); + + } + = + /** + * ANN-625 + * = + * @throws Exception in case the test fails. + * = + * This test only works against databases which allow a mixed usage of + * table names and table aliases. The generated SQL for this test is: + * = + * select + * contractor0_.EMPLOYER_ID as EMPLOYER1_1_, + * contractor0_.CONTRACTOR_ID as CONTRACTOR2_1_, + * contractor1_.id as id2_0_, + * contractor1_.fld_name as fld3_2_0_, + * contractor1_.hourlyRate as hourlyRate2_0_ = + * from + * EMPLOYER_CONTRACTOR contractor0_ = + * left outer join + * Employee contractor1_ = + * on contractor0_.CONTRACTOR_ID=3Dcontractor1_.id = + * where + * contractor0_.EMPLOYER_ID=3D? = + * order by + * Employee.fld_name desc + * = + * = + */ +// HHH-3577 +// public void testOrderByContractor() throws Exception { +// +// Session s; +// Transaction tx; +// s =3D openSession(); +// tx =3D s.beginTransaction(); +// +// // create some test entities +// Employer employer =3D new Employer(); +// Contractor contractor1 =3D new Contractor(); +// contractor1.setName( "Emmanuel" ); +// contractor1.setHourlyRate(100.0f); +// Contractor contractor2 =3D new Contractor(); +// contractor2.setName( "Hardy" ); +// contractor2.setHourlyRate(99.99f); +// s.persist( contractor1 ); +// s.persist( contractor2 ); +// +// // add contractors to employer +// List setOfContractors =3D new ArrayList(); +// setOfContractors.add( contractor1 ); +// setOfContractors.add( contractor2 ); +// employer.setContractors( setOfContractors ); +// +// // add employer to contractors +// Collection employerListContractor1 =3D new ArrayList(); +// employerListContractor1.add( employer ); +// contractor1.setEmployers( employerListContractor1 ); +// +// Collection employerListContractor2 =3D new ArrayList(); +// employerListContractor2.add( employer ); +// contractor2.setEmployers( employerListContractor2 ); +// +// s.flush(); +// s.clear(); +// +// // assertions +// employer =3D (Employer) s.get( Employer.class, employer.getId() ); +// assertNotNull( employer ); +// assertNotNull( employer.getContractors() ); +// assertEquals( 2, employer.getContractors().size() ); +// Contractor firstContractorFromDb =3D (Contractor) employer.getContract= ors().iterator().next(); +// assertEquals( contractor2.getName(), firstContractorFromDb.getName() ); +// tx.rollback(); +// s.close(); +// } + + public void testRemoveInBetween() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Employer er =3D new Employer(); + Employee ee =3D new Employee(); + Employee ee2 =3D new Employee(); + s.persist( ee ); + s.persist( ee2 ); + Set erColl =3D new HashSet(); + Collection eeColl =3D new ArrayList(); + erColl.add( ee ); + erColl.add( ee2 ); + eeColl.add( er ); + er.setEmployees( erColl ); + ee.setEmployers( eeColl ); + //s.persist(ee); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + er =3D (Employer) s.load( Employer.class, er.getId() ); + assertNotNull( er ); + assertNotNull( er.getEmployees() ); + assertEquals( 2, er.getEmployees().size() ); + Iterator iterator =3D er.getEmployees().iterator(); + Employee eeFromDb =3D (Employee) iterator.next(); + if ( eeFromDb.getId().equals( ee.getId() ) ) { + eeFromDb =3D (Employee) iterator.next(); + } + assertEquals( ee2.getId(), eeFromDb.getId() ); + er.getEmployees().remove( eeFromDb ); + eeFromDb.getEmployers().remove( er ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + ee =3D (Employee) s.get( Employee.class, ee.getId() ); + assertNotNull( ee ); + assertFalse( "ManyToMany mappedBy lazyness", Hibernate.isInitialized( ee= .getEmployers() ) ); + tx.commit(); + assertFalse( "ManyToMany mappedBy lazyness", Hibernate.isInitialized( ee= .getEmployers() ) ); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + ee =3D (Employee) s.get( Employee.class, ee.getId() ); + assertNotNull( ee ); + er =3D ee.getEmployers().iterator().next(); + assertTrue( "second join non lazy", Hibernate.isInitialized( er ) ); + assertEquals( 1, er.getEmployees().size() ); + s.delete( er ); + s.delete( ee ); + tx.commit(); + s.close(); + } + + public void testSelf() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Friend f =3D new Friend(); + Friend sndF =3D new Friend(); + f.setName( "Starsky" ); + sndF.setName( "Hutch" ); + Set frnds =3D new HashSet(); + frnds.add( sndF ); + f.setFriends( frnds ); + //Starsky is a friend of Hutch but hutch is not + s.persist( f ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + f =3D (Friend) s.load( Friend.class, f.getId() ); + assertNotNull( f ); + assertNotNull( f.getFriends() ); + assertEquals( 1, f.getFriends().size() ); + Friend fromDb2ndFrnd =3D (Friend) f.getFriends().iterator().next(); + assertEquals( fromDb2ndFrnd.getId(), sndF.getId() ); + assertEquals( 0, fromDb2ndFrnd.getFriends().size() ); + tx.commit(); + s.close(); + } + + public void testCompositePk() throws Exception { + Session s; + Transaction tx; + + ManPk m1pk =3D new ManPk(); + m1pk.setElder( true ); + m1pk.setFirstName( "Lucky" ); + m1pk.setLastName( "Luke" ); + ManPk m2pk =3D new ManPk(); + m2pk.setElder( false ); + m2pk.setFirstName( "Joe" ); + m2pk.setLastName( "Dalton" ); + + Man m1 =3D new Man(); + m1.setId( m1pk ); + m1.setCarName( "Jolly Jumper" ); + Man m2 =3D new Man(); + m2.setId( m2pk ); + + WomanPk w1pk =3D new WomanPk(); + w1pk.setFirstName( "Ma" ); + w1pk.setLastName( "Dalton" ); + WomanPk w2pk =3D new WomanPk(); + w2pk.setFirstName( "Carla" ); + w2pk.setLastName( "Bruni" ); + + Woman w1 =3D new Woman(); + w1.setId( w1pk ); + Woman w2 =3D new Woman(); + w2.setId( w2pk ); + + Set womens =3D new HashSet(); + womens.add( w1 ); + m1.setWomens( womens ); + Set womens2 =3D new HashSet(); + womens2.add( w1 ); + womens2.add( w2 ); + m2.setWomens( womens2 ); + + Set mens =3D new HashSet(); + mens.add( m1 ); + mens.add( m2 ); + w1.setMens( mens ); + Set mens2 =3D new HashSet(); + mens2.add( m2 ); + w2.setMens( mens2 ); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( m1 ); + s.persist( m2 ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + m1 =3D (Man) s.load( Man.class, m1pk ); + assertFalse( m1.getWomens().isEmpty() ); + assertEquals( 1, m1.getWomens().size() ); + w1 =3D (Woman) s.load( Woman.class, w1pk ); + assertFalse( w1.getMens().isEmpty() ); + assertEquals( 2, w1.getMens().size() ); + + tx.commit(); + s.close(); + } + + public void testAssociationTableUniqueConstraints() throws Exception { + Session s =3D openSession(); + Permission readAccess =3D new Permission(); + readAccess.setPermission( "read" ); + readAccess.setExpirationDate( new Date() ); + Collection coll =3D new ArrayList( 2 ); + coll.add( readAccess ); + coll.add( readAccess ); + Group group =3D new Group(); + group.setId( new Integer( 1 ) ); + group.setPermissions( coll ); + s.getTransaction().begin(); + try { + s.persist( group ); + s.getTransaction().commit(); + fail( "Unique constraints not applied on association table" ); + } + catch (JDBCException e) { + //success + s.getTransaction().rollback(); + } + finally { + s.close(); + } + } + + public void testAssociationTableAndOrderBy() throws Exception { + Session s =3D openSession(); + s.enableFilter( "Groupfilter" ); + Permission readAccess =3D new Permission(); + readAccess.setPermission( "read" ); + readAccess.setExpirationDate( new Date() ); + Permission writeAccess =3D new Permission(); + writeAccess.setPermission( "write" ); + writeAccess.setExpirationDate( new Date( new Date().getTime() - 10*60*10= 00 ) ); + Collection coll =3D new ArrayList( 2 ); + coll.add( readAccess ); + coll.add( writeAccess ); + Group group =3D new Group(); + group.setId( new Integer( 1 ) ); + group.setPermissions( coll ); + s.getTransaction().begin(); + s.persist( group ); + s.flush(); + s.clear(); + group =3D (Group) s.get( Group.class, group.getId() ); + s.createQuery( "select g from Group g join fetch g.permissions").list(); + assertEquals( "write", group.getPermissions().iterator().next().getPermi= ssion() ); + s.getTransaction().rollback(); + s.close(); + } + + public void testAssociationTableAndOrderByWithSet() throws Exception { + Session s =3D openSession(); + s.enableFilter( "Groupfilter" ); + + Permission readAccess =3D new Permission(); + readAccess.setPermission( "read" ); + readAccess.setExpirationDate( new Date() ); + = + Permission writeAccess =3D new Permission(); + writeAccess.setPermission( "write" ); + writeAccess.setExpirationDate( new Date( new Date().getTime() - 10*60*10= 00 ) ); + = + Permission executeAccess =3D new Permission(); + executeAccess.setPermission( "execute" ); + executeAccess.setExpirationDate( new Date( new Date().getTime() - 5*60*1= 000 ) ); + = + Set coll =3D new HashSet( 3 ); + coll.add( readAccess ); + coll.add( writeAccess ); + coll.add( executeAccess ); + + GroupWithSet group =3D new GroupWithSet(); + group.setId( new Integer( 1 ) ); + group.setPermissions( coll ); + s.getTransaction().begin(); + s.persist( group ); + s.flush(); + s.clear(); + + group =3D (GroupWithSet) s.get( GroupWithSet.class, group.getId() ); + s.createQuery( "select g from Group g join fetch g.permissions").list(); + Iterator permIter =3D group.getPermissions().iterator(); + assertEquals( "write", permIter.next().getPermission() ); + assertEquals( "execute", permIter.next().getPermission() ); + assertEquals( "read", permIter.next().getPermission() ); + s.getTransaction().rollback(); + s.close(); + } + = + public void testJoinedSubclassManyToMany() throws Exception { + Session s =3D openSession(); + Zone a =3D new Zone(); + InspectorPrefixes ip =3D new InspectorPrefixes( "dgi" ); + Transaction tx =3D s.beginTransaction(); + s.save( a ); + s.save( ip ); + ip.getAreas().add( a ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + ip =3D (InspectorPrefixes) s.get( InspectorPrefixes.class, ip.getId() ); + assertNotNull( ip ); + assertEquals( 1, ip.getAreas().size() ); + assertEquals( a.getId(), ip.getAreas().get( 0 ).getId() ); + s.delete( ip ); + s.delete( ip.getAreas().get( 0 ) ); + tx.commit(); + s.close(); + } + + public void testJoinedSubclassManyToManyWithNonPkReference() throws Excep= tion { + Session s =3D openSession(); + Zone a =3D new Zone(); + InspectorPrefixes ip =3D new InspectorPrefixes( "dgi" ); + ip.setName( "Inspector" ); + Transaction tx =3D s.beginTransaction(); + s.save( a ); + s.save( ip ); + ip.getDesertedAreas().add( a ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + ip =3D (InspectorPrefixes) s.get( InspectorPrefixes.class, ip.getId() ); + assertNotNull( ip ); + assertEquals( 1, ip.getDesertedAreas().size() ); + assertEquals( a.getId(), ip.getDesertedAreas().get( 0 ).getId() ); + s.delete( ip ); + s.delete( ip.getDesertedAreas().get( 0 ) ); + tx.commit(); + s.close(); + } + + public void testReferencedColumnNameToSuperclass() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + BuildingCompany comp =3D new BuildingCompany(); + comp.setFoundedIn( new Date() ); + comp.setName( "Builder century corp."); + s.persist( comp ); + Building building =3D new Building(); + building.setCompany( comp ); + s.persist( building ); + s.flush(); + s.clear(); + building =3D (Building) s.get( Building.class, building.getId() ); + assertEquals( comp.getName(), building.getCompany().getName() ); + tx.rollback(); + s.close(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + Friend.class, + Employer.class, + Employee.class, + Contractor.class, + Man.class, + Woman.class, + Store.class, + KnownClient.class, + Supplier.class, + City.class, + Cat.class, + Group.class, + GroupWithSet.class, + Permission.class, + Zone.class, + Inspector.class, + InspectorPrefixes.class, + BuildingCompany.class, + Building.class + }; + } + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Permission.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Permission.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Permission.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,32 @@ +//$Id: Permission.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.util.Date; +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Permission { + private String permission; + private Date expirationDate; + + @Id + public String getPermission() { + return permission; + } + + public void setPermission(String permission) { + this.permission =3D permission; + } + + public Date getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(Date expirationDate) { + this.expirationDate =3D expirationDate; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Store.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Store.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Store.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,74 @@ +//$Id: Store.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Store { + private Integer id; + private String name; + private Set customers; + private Set suppliers; + + @ManyToMany(cascade =3D CascadeType.PERSIST) + public Set getImplantedIn() { + return implantedIn; + } + + public void setImplantedIn(Set implantedIn) { + this.implantedIn =3D implantedIn; + } + + private Set implantedIn; + + @ManyToMany(cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}) + @JoinTable( + name =3D "StoreSupplier", + joinColumns =3D @JoinColumn(name =3D "store"), + inverseJoinColumns =3D @JoinColumn(name =3D "supplier") + ) + public Set getSuppliers() { + return suppliers; + } + + public void setSuppliers(Set suppliers) { + this.suppliers =3D suppliers; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToMany(cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}) + public Set getCustomers() { + return customers; + } + + public void setCustomers(Set customers) { + this.customers =3D customers; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Supplier.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Supplier.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Supplier.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,46 @@ +//$Id: Supplier.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Supplier { + private Integer id; + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + private Set suppStores; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @ManyToMany(mappedBy =3D "suppliers") + public Set getSuppStores() { + return suppStores; + } + + public void setSuppStores(Set suppStores) { + this.suppStores =3D suppStores; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Woman.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Woman.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Woman.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,91 @@ +//$Id: Woman.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; + +import org.hibernate.annotations.ForeignKey; + +/** + * Woman knowing several mens + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Woman implements Serializable { + private WomanPk id; + private String carName; + private Set mens; + private Set cats; + + @ManyToMany(mappedBy =3D "humanContacts") + public Set getCats() { + return cats; + } + + public void setCats(Set cats) { + this.cats =3D cats; + } + + @ManyToMany(cascade =3D {CascadeType.ALL}) + @JoinTable( + name =3D "Man_Woman", + joinColumns =3D { + @JoinColumn(name =3D "womanLastName", referencedColumnName =3D "lastNam= e"), + @JoinColumn(name =3D "womanFirstName", referencedColumnName =3D "firstN= ame") + }, + inverseJoinColumns =3D { + @JoinColumn(name =3D "manIsElder", referencedColumnName =3D "elder"), + @JoinColumn(name =3D "manLastName", referencedColumnName =3D "lastName"= ), + @JoinColumn(name =3D "manFirstName", referencedColumnName =3D "firstNam= e") + } + ) + @ForeignKey(name =3D "WM_W_FK", inverseName =3D "WM_M_FK") + public Set getMens() { + return mens; + } + + public void setMens(Set mens) { + this.mens =3D mens; + } + + @Id + public WomanPk getId() { + return id; + } + + public void setId(WomanPk id) { + this.id =3D id; + } + + public String getCarName() { + return carName; + } + + public void setCarName(String carName) { + this.carName =3D carName; + } + + + public int hashCode() { + //a NPE can occurs, but I don't expect hashcode to be used before pk is = set + return getId().hashCode(); + } + + public boolean equals(Object obj) { + //a NPE can occurs, but I don't expect equals to be used before pk is set + if ( obj !=3D null && obj instanceof Woman ) { + return getId().equals( ( (Woman) obj ).getId() ); + } + else { + return false; + } + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/WomanPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/WomanPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/WomanPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,52 @@ +//$Id: WomanPk.java 16343 2009-04-15 18:33:43Z gbadner $ +package org.hibernate.test.annotations.manytomany; + +import java.io.Serializable; +import javax.persistence.Embeddable; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class WomanPk implements Serializable { + + + private String firstName; + private String lastName; + + public int hashCode() { + //this implem sucks + return getFirstName().hashCode() + getLastName().hashCode(); + } + + public boolean equals(Object obj) { + //firstName and lastName are expected to be set in this implem + if ( obj !=3D null && obj instanceof WomanPk ) { + WomanPk other =3D (WomanPk) obj; + return getFirstName().equals( other.getFirstName() ) + && getLastName().equals( other.getLastName() ); + } + else { + return false; + } + } + + public void setFirstName(String firstName) { + this.firstName =3D firstName; + } + + public void setLastName(String lastName) { + this.lastName =3D lastName; + } + + @Column(length=3D128) + public String getFirstName() { + return firstName; + } + + @Column(length=3D128) + public String getLastName() { + return lastName; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytomany/Zone.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Zone.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytomany/Zone.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: Zone.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytomany; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Zone { + private Integer id; + + @Id + @GeneratedValue + @Column(name =3D "id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/BiggestForest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/BiggestForest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/BiggestForest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: BiggestForest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import javax.persistence.Entity; +import javax.persistence.OneToOne; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class BiggestForest { + private Integer id; + private ForestType type; + + @Id @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @OneToOne(mappedBy =3D "biggestRepresentative") + public ForestType getType() { + return type; + } + + public void setType(ForestType type) { + this.type =3D type; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Car.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Car.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Car.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,51 @@ +//$Id: Car.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.ForeignKey; + +/** + * Many to one sample using default mapping values + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Car { + private Integer id; + private Color bodyColor; + private Parent owner; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @ManyToOne(fetch =3D FetchType.EAGER) + @ForeignKey(name=3D"BODY_COLOR_FK") + public Color getBodyColor() { + return bodyColor; + } + + public void setBodyColor(Color bodyColor) { + this.bodyColor =3D bodyColor; + } + + @ManyToOne + public Parent getOwner() { + return owner; + } + + public void setOwner(Parent owner) { + this.owner =3D owner; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Carz.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Carz.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Carz.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,124 @@ +//$Id: Carz.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import java.io.Serializable; +import java.util.Date; +import javax.persistence.Entity; +import javax.persistence.ManyToOne; +import javax.persistence.Column; +import javax.persistence.JoinColumns; +import javax.persistence.FetchType; +import javax.persistence.JoinColumn; +import javax.persistence.TemporalType; +import javax.persistence.Id; +import javax.persistence.Temporal; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Carz implements Serializable { + @Id + private Integer id; + + @Column( name =3D "make", nullable =3D false ) + private String make; + + @Column( name =3D "model", nullable =3D false ) + private String model; + + @Column( name =3D "manufactured", nullable =3D false ) + @Temporal( TemporalType.TIMESTAMP ) + private Date manufactured; + + @ManyToOne( fetch =3D FetchType.LAZY ) + @JoinColumn( name =3D "loc_code", referencedColumnName =3D "loc_code" ) + private Lotz lot; + + public Carz() { + } + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Lotz getLot() { + return this.lot; + } + + public void setLot(Lotz lot) { + this.lot =3D lot; + } + + public String getMake() { + return this.make; + } + + public void setMake(String make) { + this.make =3D make; + } + + public Date getManufactured() { + return this.manufactured; + } + + public void setManufactured(Date manufactured) { + this.manufactured =3D manufactured; + } + + public String getModel() { + return this.model; + } + + public void setModel(String model) { + this.model =3D model; + } + + @Override + public int hashCode() { + final int PRIME =3D 31; + int result =3D 1; + result =3D PRIME * result + ( ( this.id =3D=3D null ) ? + 0 : + this.id.hashCode() ); + result =3D PRIME * result + ( ( this.make =3D=3D null ) ? + 0 : + this.make.hashCode() ); + result =3D PRIME * result + ( ( this.manufactured =3D=3D null ) ? + 0 : + this.manufactured.hashCode() ); + result =3D PRIME * result + ( ( this.model =3D=3D null ) ? + 0 : + this.model.hashCode() ); + return result; + } + + @Override + public boolean equals(Object obj) { + if ( this =3D=3D obj ) return true; + if ( obj =3D=3D null ) return false; + if ( getClass() !=3D obj.getClass() ) return false; + final Carz other =3D (Carz) obj; + if ( this.id =3D=3D null ) { + if ( other.id !=3D null ) return false; + } + else if ( !this.id.equals( other.id ) ) return false; + if ( this.make =3D=3D null ) { + if ( other.make !=3D null ) return false; + } + else if ( !this.make.equals( other.make ) ) return false; + if ( this.manufactured =3D=3D null ) { + if ( other.manufactured !=3D null ) return false; + } + else if ( !this.manufactured.equals( other.manufactured ) ) return false; + if ( this.model =3D=3D null ) { + if ( other.model !=3D null ) return false; + } + else if ( !this.model.equals( other.model ) ) return false; + return true; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Child.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Child.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Child.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,32 @@ +//$Id: Child.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +/** + * TODO: change this sample with an Address -> Country relation. This is m= ore accurate + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_child") +public class Child implements Serializable { + @Id + @GeneratedValue + public Integer id; + + @ManyToOne() + @JoinColumns({ + @JoinColumn(name =3D "parentCivility", referencedColumnName =3D "isMale"), + @JoinColumn(name =3D "parentLastName", referencedColumnName =3D "lastName= "), + @JoinColumn(name =3D "parentFirstName", referencedColumnName =3D "firstNa= me") + }) + public Parent parent; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Color.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Color.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Color.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,37 @@ +//$Id: Color.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * Color showing a surrogate key and a unique constraint to ensure busines= s rule + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Color { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @Column(unique =3D true) + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Customer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Customer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Customer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,16 @@ +//$Id: Customer.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity(name=3D"DealedCustomer") +public class Customer implements Serializable { + @Id @GeneratedValue public Integer id; + public String userId; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Deal.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Deal.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Deal.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,19 @@ +//$Id: Deal.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.ManyToOne; +import javax.persistence.JoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Deal { + @Id @GeneratedValue public Integer id; + @ManyToOne @JoinColumn(referencedColumnName =3D "userId") public Customer= from; + @ManyToOne @JoinColumn(referencedColumnName =3D "userId") public Customer= to; + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/DistrictUser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/DistrictUser.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/DistrictUser.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,43 @@ +package org.hibernate.test.annotations.manytoone; + +import java.util.Date; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +(a)Entity +(a)Table(name =3D "CLRUS2DI") +public class DistrictUser { + @Id + @GeneratedValue + @Column(name =3D "CLRUS2DI_KEY") + private Long id; + + @Column(name =3D "CLRUS2DI_CREATE_USERS_KEY") + private Long createdBy; + + @Column(name =3D "CLRUS2DI_CREATE_DATE") + private Date createdOn; + + //@ManyToOne(cascade =3D CascadeType.ALL) + //@JoinColumn(name =3D "CLRUS2DI_DISTR_KEY") + //private District district; + + @ManyToOne(cascade =3D CascadeType.ALL) + @JoinColumns({@JoinColumn(name =3D "CLRUS2DI_USERS_KEY", referencedColumn= Name =3D "CTVUSERS_KEY"), + @JoinColumn(name =3D "CLRUS2DI_BEGIN_DATE", referencedColumnName =3D "CTV= USERS_START_DATE"), + @JoinColumn(name =3D "CLRUS2DI_END_DATE", referencedColumnName =3D "CTVUS= ERS_END_DATE")}) + private User user; + + @Column(name =3D "CLRUS2DI_LDTMD_KEY") + private Long ldtmd; + + @Column(name =3D "CLRUS2DI_PMTMP_KEY") + private Long pmtmp; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/ForestType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/ForestType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/ForestType.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,66 @@ +//$Id: ForestType.java 15074 2008-08-14 17:38:00Z epbernard $ +package org.hibernate.test.annotations.manytoone; + +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.JoinTable; +import javax.persistence.JoinColumn; + +import org.hibernate.annotations.ForeignKey; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class ForestType { + private Integer id; + private String name; + private Set trees; + private BiggestForest biggestRepresentative; + + @OneToOne + @JoinTable(name=3D"BiggestRepPerForestType", + joinColumns =3D @JoinColumn(name=3D"forest_type"), + inverseJoinColumns =3D @JoinColumn(name=3D"forest") + ) + @ForeignKey(name=3D"A_TYP_FK", + inverseName =3D "A_FOR_FK" //inverse fail cause it involves a Join + ) + public BiggestForest getBiggestRepresentative() { + return biggestRepresentative; + } + + public void setBiggestRepresentative(BiggestForest biggestRepresentative)= { + this.biggestRepresentative =3D biggestRepresentative; + } + + @OneToMany(mappedBy=3D"forestType") + public Set getTrees() { + return trees; + } + + public void setTrees(Set trees) { + this.trees =3D trees; + } + + @Id @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Frame.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Frame.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Frame.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,51 @@ +//$Id: Frame.java 17529 2009-09-19 19:59:46Z stliu $ +package org.hibernate.test.annotations.manytoone; + +import java.util.Set; +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.Formula; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Frame implements Serializable { + @Id + @GeneratedValue + private Long id; + @OneToMany( mappedBy =3D "frame" ) + private Set lenses; + private String name; + @Formula("lower(name)") + private String lowerName; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public Set getLenses() { + return lenses; + } + + public void setLenses(Set lenses) { + this.lenses =3D lenses; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Lens.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Lens.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Lens.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,58 @@ +//$Id: Lens.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import javax.persistence.Entity; +import javax.persistence.ManyToOne; +import javax.persistence.JoinColumn; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; + +import org.hibernate.annotations.Formula; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Lens { + @Id + @GeneratedValue + private Long id; + private float focal; + @Formula("(1/focal)") + private float length; + @ManyToOne() + @JoinColumn(name=3D"`frame_fk`", referencedColumnName =3D "name") + private Frame frame; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public float getFocal() { + return focal; + } + + public void setFocal(float focal) { + this.focal =3D focal; + } + + public float getLength() { + return length; + } + + public void setLength(float length) { + this.length =3D length; + } + + public Frame getFrame() { + return frame; + } + + public void setFrame(Frame frame) { + this.frame =3D frame; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Lotz.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Lotz.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Lotz.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,101 @@ +//$Id: Lotz.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import java.util.List; +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.EmbeddedId; +import javax.persistence.Column; +import javax.persistence.FetchType; +import javax.persistence.OneToMany; +import javax.persistence.CascadeType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Lotz implements Serializable { + @EmbeddedId + protected LotzPK lotPK; + + @Column( name =3D "name", nullable =3D false ) + private String name; + + @Column( name =3D "location", nullable =3D false ) + private String location; + + @OneToMany( mappedBy =3D "lot", fetch =3D FetchType.LAZY, cascade =3D Cas= cadeType.ALL ) + private List cars; + + public Lotz() { + } + + public List getCars() { + return this.cars; + } + + public void setCars(List cars) { + this.cars =3D cars; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location =3D location; + } + + public LotzPK getLotPK() { + return this.lotPK; + } + + public void setLotPK(LotzPK lotPK) { + this.lotPK =3D lotPK; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Override + public int hashCode() { + final int PRIME =3D 31; + int result =3D 1; + result =3D PRIME * result + ( ( this.location =3D=3D null ) ? + 0 : + this.location.hashCode() ); + result =3D PRIME * result + ( ( this.lotPK =3D=3D null ) ? + 0 : + this.lotPK.hashCode() ); + result =3D PRIME * result + ( ( this.name =3D=3D null ) ? + 0 : + this.name.hashCode() ); + return result; + } + + @Override + public boolean equals(Object obj) { + if ( this =3D=3D obj ) return true; + if ( obj =3D=3D null ) return false; + if ( getClass() !=3D obj.getClass() ) return false; + final Lotz other =3D (Lotz) obj; + if ( this.location =3D=3D null ) { + if ( other.location !=3D null ) return false; + } + else if ( !this.location.equals( other.location ) ) return false; + if ( this.lotPK =3D=3D null ) { + if ( other.lotPK !=3D null ) return false; + } + else if ( !this.lotPK.equals( other.lotPK ) ) return false; + if ( this.name =3D=3D null ) { + if ( other.name !=3D null ) return false; + } + else if ( !this.name.equals( other.name ) ) return false; + return true; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/LotzPK.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/LotzPK.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/LotzPK.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: LotzPK.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class LotzPK implements Serializable { + @Column( name =3D "id", nullable =3D false ) + private Integer id; + + @Column( name =3D "loc_code", nullable =3D false, unique =3D true ) + private String locCode; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getLocCode() { + return locCode; + } + + public void setLocCode(String locCode) { + this.locCode =3D locCode; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/ManyToOneJoinTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/ManyToOneJoinTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/ManyToOneJoinTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,62 @@ +//$Id: ManyToOneJoinTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.test.annotations.manytoone; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; +import org.hibernate.Transaction; + +/** + * @author Emmanuel Bernard + */ +public class ManyToOneJoinTest extends TestCase { + public void testManyToOneJoinTable() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + ForestType forest =3D new ForestType(); + forest.setName( "Original forest" ); + s.persist( forest ); + TreeType tree =3D new TreeType(); + tree.setForestType( forest ); + tree.setAlternativeForestType( forest ); + tree.setName( "just a tree"); + s.persist( tree ); + s.flush(); + s.clear(); + tree =3D (TreeType) s.get(TreeType.class, tree.getId() ); + assertNotNull( tree.getForestType() ); + assertNotNull( tree.getAlternativeForestType() ); + s.clear(); + forest =3D (ForestType) s.get( ForestType.class, forest.getId() ); + assertEquals( 1, forest.getTrees().size() ); + assertEquals( tree.getId(), forest.getTrees().iterator().next().getId() = ); + tx.rollback(); + s.close(); + } + + public void testOneToOneJoinTable() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + ForestType forest =3D new ForestType(); + forest.setName( "Original forest" ); + s.persist( forest ); + BiggestForest forestRepr =3D new BiggestForest(); + forestRepr.setType( forest ); + forest.setBiggestRepresentative( forestRepr ); + s.persist( forestRepr ); + s.flush(); + s.clear(); + forest =3D (ForestType) s.get( ForestType.class, forest.getId() ); + assertNotNull( forest.getBiggestRepresentative() ); + assertEquals( forest, forest.getBiggestRepresentative().getType() ); + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { + BiggestForest.class, + ForestType.class, + TreeType.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/ManyToOneOnNonPkTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/ManyToOneOnNonPkTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/ManyToOneOnNonPkTest.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,54 @@ +//$Id: ManyToOneOnNonPkTest.java 14736 2008-06-04 14:23:42Z hardy.ferentsc= hik $ +package org.hibernate.test.annotations.manytoone; + +import java.util.Date; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; + + +/** + * FIXME test for ANN-548 + * @author Emmanuel Bernard + */ +public class ManyToOneOnNonPkTest extends TestCase { + + public void testNonPkPartOfPk() throws Exception { +// Session s =3D openSession( ); +// s.getTransaction().begin(); +// +// LotzPK pk =3D new LotzPK(); +// pk.setId( 1 ); +// pk.setLocCode( "fr" ); +// Lotz lot =3D new Lotz(); +// lot.setLocation( "France" ); +// lot.setName( "Chez Dede" ); +// lot.setLotPK( pk ); +// Carz car =3D new Carz(); +// car.setId( 1 ); +// car.setLot( lot ); +// car.setMake( "Citroen" ); +// car.setManufactured( new Date() ); +// car.setModel( "C5" ); +// s.persist( lot ); +// s.persist( car ); +// +// s.flush(); +// s.clear(); +// s.clear(); +// +// car =3D (Carz) s.createQuery( "from Carz car left join fetch car.lot")= .uniqueResult(); +// assertNotNull( car.getLot() ); +// +// s.getTransaction().commit(); +// s.close(); +// + } + + protected Class[] getMappings() { + return new Class[] { + //Carz.class, + //Lotz.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/ManyToOneTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/ManyToOneTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/ManyToOneTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,346 @@ +//$Id: ManyToOneTest.java 17529 2009-09-19 19:59:46Z stliu $ +package org.hibernate.test.annotations.manytoone; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.hibernate.Hibernate; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.Company; +import org.hibernate.test.annotations.Customer; +import org.hibernate.test.annotations.Discount; +import org.hibernate.test.annotations.Flight; +import org.hibernate.test.annotations.Passport; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.Ticket; + +/** + * @author Emmanuel Bernard + */ +public class ManyToOneTest extends TestCase { + + public ManyToOneTest(String x) { + super( x ); + } + + public void testEager() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Color c =3D new Color(); + c.setName( "Yellow" ); + s.persist( c ); + Car car =3D new Car(); + car.setBodyColor( c ); + s.persist( car ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + car =3D (Car) s.get( Car.class, car.getId() ); + tx.commit(); + s.close(); + assertNotNull( car ); + assertNotNull( car.getBodyColor() ); + assertEquals( "Yellow", car.getBodyColor().getName() ); + + } + + public void testDefaultMetadata() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Color c =3D new Color(); + c.setName( "Blue" ); + s.persist( c ); + Car car =3D new Car(); + car.setBodyColor( c ); + s.persist( car ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + car =3D (Car) s.get( Car.class, car.getId() ); + assertNotNull( car ); + assertNotNull( car.getBodyColor() ); + assertEquals( c.getId(), car.getBodyColor().getId() ); + tx.rollback(); + s.close(); + } + + public void testCreate() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Flight firstOne =3D new Flight(); + firstOne.setId( new Long( 1 ) ); + firstOne.setName( "AF0101" ); + firstOne.setDuration( new Long( 1000 ) ); + Company frenchOne =3D new Company(); + frenchOne.setName( "Air France" ); + firstOne.setCompany( frenchOne ); + s.persist( firstOne ); + tx.commit(); + s.close(); + assertNotNull( "identity id should work", frenchOne.getId() ); + + s =3D openSession(); + tx =3D s.beginTransaction(); + firstOne =3D (Flight) s.get( Flight.class, new Long( 1 ) ); + assertNotNull( firstOne.getCompany() ); + assertEquals( frenchOne.getName(), firstOne.getCompany().getName() ); + tx.commit(); + s.close(); + } + + public void testCascade() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Discount discount =3D new Discount(); + discount.setDiscount( 20.12 ); + Customer customer =3D new Customer(); + Collection discounts =3D new ArrayList(); + discounts.add( discount ); + customer.setName( "Quentin Tarantino" ); + discount.setOwner( customer ); + customer.setDiscountTickets( discounts ); + s.persist( discount ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + discount =3D (Discount) s.get( Discount.class, discount.getId() ); + assertNotNull( discount ); + assertEquals( 20.12, discount.getDiscount() ); + assertNotNull( discount.getOwner() ); + customer =3D new Customer(); + customer.setName( "Clooney" ); + discount.setOwner( customer ); + discounts =3D new ArrayList(); + discounts.add( discount ); + customer.setDiscountTickets( discounts ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + discount =3D (Discount) s.get( Discount.class, discount.getId() ); + assertNotNull( discount ); + assertNotNull( discount.getOwner() ); + assertEquals( "Clooney", discount.getOwner().getName() ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + customer =3D (Customer) s.get( Customer.class, customer.getId() ); + s.delete( customer ); + tx.commit(); + s.close(); + } + + public void testFetch() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Discount discount =3D new Discount(); + discount.setDiscount( 20 ); + Customer customer =3D new Customer(); + Collection discounts =3D new ArrayList(); + discounts.add( discount ); + customer.setName( "Quentin Tarantino" ); + discount.setOwner( customer ); + customer.setDiscountTickets( discounts ); + s.persist( discount ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + discount =3D (Discount) s.get( Discount.class, discount.getId() ); + assertNotNull( discount ); + assertFalse( Hibernate.isInitialized( discount.getOwner() ) ); + tx.commit(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + discount =3D (Discount) s.load( Discount.class, discount.getId() ); + assertNotNull( discount ); + assertFalse( Hibernate.isInitialized( discount.getOwner() ) ); + tx.commit(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete( s.get( Discount.class, discount.getId() ) ); + tx.commit(); + s.close(); + } + + public void testCompositeFK() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + ParentPk ppk =3D new ParentPk(); + ppk.firstName =3D "John"; + ppk.lastName =3D "Doe"; + Parent p =3D new Parent(); + p.age =3D 45; + p.id =3D ppk; + s.persist( p ); + Child c =3D new Child(); + c.parent =3D p; + s.persist( c ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + //FIXME: fix this when the small parser bug will be fixed = + Query q =3D s.createQuery( "from " + Child.class.getName() ); //+ " c wh= ere c.parent.id.lastName =3D :lastName"); + //q.setString("lastName", p.id.lastName); + List result =3D q.list(); + assertEquals( 1, result.size() ); + Child c2 =3D (Child) result.get( 0 ); + assertEquals( c2.id, c.id ); + tx.commit(); + s.close(); + } + + public void testImplicitCompositeFk() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Node n1 =3D new Node(); + n1.setDescription( "Parent" ); + NodePk n1pk =3D new NodePk(); + n1pk.setLevel( 1 ); + n1pk.setName( "Root" ); + n1.setId( n1pk ); + Node n2 =3D new Node(); + NodePk n2pk =3D new NodePk(); + n2pk.setLevel( 2 ); + n2pk.setName( "Level 1: A" ); + n2.setParent( n1 ); + n2.setId( n2pk ); + s.persist( n2 ); + tx.commit(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + n2 =3D (Node) s.get( Node.class, n2pk ); + assertNotNull( n2 ); + assertNotNull( n2.getParent() ); + assertEquals( 1, n2.getParent().getId().getLevel() ); + tx.commit(); + s.close(); + } + + public void testManyToOneNonPk() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Order order =3D new Order(); + order.setOrderNbr( "123" ); + s.persist( order ); + OrderLine ol =3D new OrderLine(); + ol.setItem( "Mouse" ); + ol.setOrder( order ); + s.persist( ol ); + s.flush(); + s.clear(); + ol =3D (OrderLine) s.get( OrderLine.class, ol.getId() ); + assertNotNull( ol.getOrder() ); + assertEquals( "123", ol.getOrder().getOrderNbr() ); + assertTrue( ol.getOrder().getOrderLines().contains( ol ) ); + tx.rollback(); + s.close(); + } + + public void testTwoManyToOneNonPk() throws Exception { + //2 many to one non pk pointing to the same referencedColumnName should = not fail + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + org.hibernate.test.annotations.manytoone.Customer customer =3D new org.h= ibernate.test.annotations.manytoone.Customer(); + customer.userId=3D"123"; + org.hibernate.test.annotations.manytoone.Customer customer2 =3D new org.= hibernate.test.annotations.manytoone.Customer(); + customer2.userId=3D"124"; + s.persist( customer2 ); + s.persist( customer ); + Deal deal =3D new Deal(); + deal.from =3D customer; + deal.to =3D customer2; + s.persist( deal ); + s.flush(); + s.clear(); + deal =3D (Deal) s.get( Deal.class, deal.id ); + assertNotNull( deal.from ); + assertNotNull( deal.to ); + tx.rollback(); + s.close(); + } + + public void testFormulaOnOtherSide() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Frame frame =3D new Frame(); + frame.setName( "Prada" ); + s.persist( frame ); + Lens l =3D new Lens(); + l.setFocal( 2.5f ); + l.setFrame( frame ); + s.persist( l ); + Lens r =3D new Lens(); + r.setFocal( 1.2f); + r.setFrame( frame ); + s.persist( r ); + s.flush(); + s.clear(); + frame =3D (Frame) s.get( Frame.class, frame.getId() ); + assertEquals( 2, frame.getLenses().size() ); + assertTrue( frame.getLenses().iterator().next().getLength() <=3D 1/1.2f = ); + assertTrue( frame.getLenses().iterator().next().getLength() >=3D 1/2.5f = ); + tx.rollback(); + s.close(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected java.lang.Class[] getMappings() { + return new java.lang.Class[]{ + Deal.class, + org.hibernate.test.annotations.manytoone.Customer.class, + Car.class, + Color.class, + Flight.class, + Company.class, + Customer.class, + Discount.class, + Ticket.class, + Passport.class, + Parent.class, + Child.class, + Node.class, + User.class, + DistrictUser.class, + Order.class, + OrderLine.class, + Frame.class, + Lens.class + }; + } + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Node.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Node.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Node.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,68 @@ +//$Id: Node.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import java.io.Serializable; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Node implements Serializable { + + private NodePk id; + private String description; + private Node parent; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Node ) ) return false; + + final Node node =3D (Node) o; + + if ( !id.equals( node.id ) ) return false; + + return true; + } + + public int hashCode() { + return id.hashCode(); + } + + @Id + public NodePk getId() { + return id; + } + + public void setId(NodePk id) { + this.id =3D id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description =3D description; + } + + @ManyToOne(cascade =3D CascadeType.ALL, fetch =3D FetchType.LAZY) + @JoinColumns({ + @JoinColumn(name =3D "parentName"), + @JoinColumn(name =3D "parentLevel") + }) + public Node getParent() { + return parent; + } + + public void setParent(Node parent) { + this.parent =3D parent; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/NodePk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/NodePk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/NodePk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,51 @@ +//$Id: NodePk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class NodePk implements Serializable { + private String name; + private int level; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof NodePk ) ) return false; + + final NodePk nodePk =3D (NodePk) o; + + if ( level !=3D nodePk.level ) return false; + if ( !name.equals( nodePk.name ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D name.hashCode(); + result =3D 29 * result + level; + return result; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @Column(name =3D "fld_lvl") + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level =3D level; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Order.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Order.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Order.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,50 @@ +//$Id: Order.java 17529 2009-09-19 19:59:46Z stliu $ +package org.hibernate.test.annotations.manytoone; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Column; +import javax.persistence.Table; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name=3D"ORDERS") +public class Order implements Serializable { + private Integer id; + private String orderNbr; + private Set orderLines; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @Column(name=3D"order_nbr") + public String getOrderNbr() { + return orderNbr; + } + + public void setOrderNbr(String orderNbr) { + this.orderNbr =3D orderNbr; + } + + @OneToMany(mappedBy =3D "order") + public Set getOrderLines() { + return orderLines; + } + + public void setOrderLines(Set orderLines) { + this.orderLines =3D orderLines; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/OrderLine.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/OrderLine.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/OrderLine.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,45 @@ +//$Id: OrderLine.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.ManyToOne; +import javax.persistence.JoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class OrderLine { + private Integer id; + private String item; + private Order order; + + @Id @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getItem() { + return item; + } + + public void setItem(String item) { + this.item =3D item; + } + + @ManyToOne + @JoinColumn(name=3D"order_nbr", referencedColumnName =3D "order_nbr", uni= que =3D true) + public Order getOrder() { + return order; + } + + public void setOrder(Order order) { + this.order =3D order; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/Parent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Parent.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/Parent.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Parent.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "tbl_parent") +public class Parent implements Serializable { + @Id + public ParentPk id; + public int age; + + public int hashCode() { + //a NPE can occurs, but I don't expect hashcode to be used before pk is = set + return id.hashCode(); + } + + public boolean equals(Object obj) { + //a NPE can occurs, but I don't expect equals to be used before pk is set + if ( obj !=3D null && obj instanceof Parent ) { + return id.equals( ( (Parent) obj ).id ); + } + else { + return false; + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/ParentPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/ParentPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/ParentPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,40 @@ +//$Id: ParentPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class ParentPk implements Serializable { + @Column(length =3D 50) + String firstName; + String lastName; + + /** + * is a male or a female + */ + //show hetereogenous PK types + boolean isMale; + + public int hashCode() { + //this implem sucks + return firstName.hashCode() + lastName.hashCode() + ( isMale ? 0 : 1 ); + } + + public boolean equals(Object obj) { + //firstName and lastName are expected to be set in this implem + if ( obj !=3D null && obj instanceof ParentPk ) { + ParentPk other =3D (ParentPk) obj; + return firstName.equals( other.firstName ) + && lastName.equals( other.lastName ) + && isMale =3D=3D other.isMale; + } + else { + return false; + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/TreeType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/TreeType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/TreeType.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,61 @@ +//$Id: TreeType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.manytoone; + +import javax.persistence.Entity; +import javax.persistence.ManyToOne; +import javax.persistence.JoinTable; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.JoinColumn; +import javax.persistence.FetchType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class TreeType { + private Integer id; + private String name; + private ForestType forestType; + private ForestType alternativeForestType; + + @ManyToOne(fetch =3D FetchType.LAZY) + @JoinTable(name=3D"Tree_Forest") + public ForestType getForestType() { + return forestType; + } + + public void setForestType(ForestType forestType) { + this.forestType =3D forestType; + } + + @ManyToOne(fetch =3D FetchType.LAZY) + @JoinTable(name=3D"Atl_Forest_Type", + joinColumns =3D @JoinColumn(name=3D"tree_id"), + inverseJoinColumns =3D @JoinColumn(name=3D"forest_id") ) + public ForestType getAlternativeForestType() { + return alternativeForestType; + } + + public void setAlternativeForestType(ForestType alternativeForestType) { + this.alternativeForestType =3D alternativeForestType; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/User.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/User.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/User.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,113 @@ +package org.hibernate.test.annotations.manytoone; + +import java.util.Date; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; + +(a)Entity +(a)Table(name =3D "CTVUSERS") +(a)IdClass(UserPK.class) +(a)SequenceGenerator(name =3D "UserSeq", sequenceName =3D "SQ_USER") +public class User { + @Id + @Column(name =3D "CTVUSERS_KEY") + private Long userKey; + + @Id + @Column(name =3D "CTVUSERS_START_DATE") + private Date startDate; + + @Id + @Column(name =3D "CTVUSERS_END_DATE") + private Date endDate; + + @Column(name =3D "CTVUSERS_CREATE_USERS_KEY") + private Long createdBy; + + @Column(name =3D "CTVUSERS_CREATE_DATE") + private Date createdOn; + + @Column(name =3D "CTVUSERS_ID") + private String userId; + + @Column(name =3D "CTVUSERS_PREFX_KEY") + private Integer prefix; + + @Column(name =3D "CTVUSERS_FIRST_NAME") + private String firstName; + + @Column(name =3D "CTVUSERS_LAST_NAME1") + private String lastName1; + + @Column(name =3D "CTVUSERS_LAST_NAME2") + private String lastName2; + + @Column(name =3D "CTVUSERS_MIDDLE_NAME1") + private String middleName1; + + @Column(name =3D "CTVUSERS_MIDDLE_NAME2") + private String middleName2; + + @Column(name =3D "CTVUSERS_SUFFX_KEY") + private Integer suffix; + + @Column(name =3D "CTVUSERS_BIRTH_DATE") + private Date birthDate; + + @Column(name =3D "CTVUSERS_BIRTH_STATE_KEY") + private Integer birthState; + + @Column(name =3D "CTVUSERS_BIRTH_CNTRY_KEY") + private Integer birthCountry; + + @Column(name =3D "CTVUSERS_USERNAME") + private String username; + + @Column(name =3D "CTVUSERS_PASSWORD") + private String password; + + @Column(name =3D "CTVUSERS_LOTYP_KEY") + private Integer userType; + + @Column(name =3D "CTVUSERS_PRIVL_KEY") + private Integer privilege; + + @Column(name =3D "CTVUSERS_STATE_KEY") + private Integer state; + + @Column(name =3D "CTVUSERS_CNTRY_KEY") + private Integer country; + + @Column(name =3D "CTVUSERS_PREFERRED_NAME") + private String preferredName; + + @Column(name =3D "CTVUSERS_BIRTH_PLACE") + private String birthPlace; + + @OneToMany(fetch =3D FetchType.EAGER, cascade =3D CascadeType.ALL, mapped= By =3D "user") + private Set districtUsers; + + @Column(name =3D "CTVUSERS_SCHOL_KEY") + private Long school; + + @Column(name =3D "CTVUSERS_CLSTR_KEY") + private Long cluster; + + @Column(name =3D "CTVUSERS_LDTMM_KEY") + private Long ldtmm; + + @Column(name =3D "CTVUSERS_LDTMD_KEY") + private Long ldtmd; + + @Column(name =3D "CTVUSERS_PMTMP_KEY") + private Long pmtmp; + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/UserPK.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/UserPK.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/UserPK.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +package org.hibernate.test.annotations.manytoone; + +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.Date; +import javax.persistence.Column; + +public class UserPK implements Serializable { + private static final long serialVersionUID =3D -7720874756224520523L; + @Column(name =3D "CTVUSERS_KEY") + public Long userKey; + + @Column(name =3D "CTVUSERS_START_DATE") + public Date startDate; + + + @Column(name =3D "CTVUSERS_END_DATE") + public Date endDate; + + public UserPK() { + } + + @Override + public boolean equals(Object obj) { + if ( !( obj instanceof UserPK ) ) { + return false; + } + UserPK userPK =3D (UserPK) obj; + SimpleDateFormat formatter =3D new SimpleDateFormat( "MM/dd/yyyy" ); + return userKey.equals( userPK.userKey ) && formatter.format( startDate ) + .equals( formatter.format( userPK.startDate ) ) + && formatter.format( endDate ).equals( formatter.format( userPK.endDat= e ) ); + } + + @Override + public int hashCode() { + return userKey.hashCode() * startDate.hashCode() * endDate.hashCode(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/referencedcolumnname/GenericObject.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/GenericObject.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/GenericObject.java 2009-11-24 21:03:= 15 UTC (rev 18049) @@ -0,0 +1,68 @@ +//$ +package org.hibernate.test.annotations.manytoone.referencedcolumnname; + +import java.io.Serializable; +import java.rmi.server.UID; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; +import javax.persistence.Transient; +import javax.persistence.Version; + +(a)MappedSuperclass +public class GenericObject implements Serializable { + protected int id; + protected int version; + protected UID uid =3D new UID(); + + @Id + @GeneratedValue( strategy =3D GenerationType.IDENTITY ) + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + @Version + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version =3D version; + } + + public void incrementVersion() { + this.version++; + } + + public boolean equals(Object other) { + if ( this =3D=3D other ) + return true; + if ( ( other =3D=3D null ) || !( other.getClass().equals( this.getClass(= ) ) ) ) + return false; + GenericObject anObject =3D (GenericObject) other; + if ( this.id =3D=3D 0 || anObject.id =3D=3D 0 ) + return false; + + return ( this.id =3D=3D anObject.id ); + } + + public int hashCode() { + if ( this.id =3D=3D 0 ) + return super.hashCode(); + return this.id; + } + + @Transient + public UID getUid() { + return uid; + } + + public void setUid(UID uid) { + this.uid =3D uid; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/referencedcolumnname/Item.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/Item.java (r= ev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/Item.java 2009-11-24 21:03:15 UTC (r= ev 18049) @@ -0,0 +1,13 @@ +//$ +package org.hibernate.test.annotations.manytoone.referencedcolumnname; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.Transient; + + +(a)Entity +public class Item extends GenericObject { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.ja= va (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.ja= va 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,55 @@ +//$ +package org.hibernate.test.annotations.manytoone.referencedcolumnname; + +import java.math.BigDecimal; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; + +/** + * @author Emmanuel Bernard + */ +public class ManyToOneReferencedColumnNameTest extends TestCase { + public void testReoverableExceptionInFkOrdering() throws Exception { + //SF should not blow up + Vendor v =3D new Vendor(); + Item i =3D new Item(); + ZItemCost ic =3D new ZItemCost(); + ic.setCost( new BigDecimal(2) ); + ic.setItem( i ); + ic.setVendor( v ); + WarehouseItem wi =3D new WarehouseItem(); + wi.setDefaultCost( ic ); + wi.setItem( i ); + wi.setVendor( v ); + wi.setQtyInStock( new BigDecimal(2) ); + Session s =3D openSession( ); + s.getTransaction().begin(); + s.save( i ); + s.save( v ); + s.save( ic ); + s.save( wi ); + s.flush(); + s.getTransaction().rollback(); + s.close(); + = + } + = + = + = + @Override + protected boolean runForCurrentDialect() { + return super.runForCurrentDialect() && getDialect().supportsIdentityColu= mns(); + } + + + + protected Class[] getMappings() { + return new Class[] { + Item.class, + Vendor.class, + WarehouseItem.class, + ZItemCost.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/referencedcolumnname/Vendor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/Vendor.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/Vendor.java 2009-11-24 21:03:15 UTC = (rev 18049) @@ -0,0 +1,12 @@ +//$ +package org.hibernate.test.annotations.manytoone.referencedcolumnname; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.Transient; + +(a)Entity +public class Vendor extends GenericObject { +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/referencedcolumnname/WarehouseItem.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/WarehouseItem.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/WarehouseItem.java 2009-11-24 21:03:= 15 UTC (rev 18049) @@ -0,0 +1,62 @@ +//$ +package org.hibernate.test.annotations.manytoone.referencedcolumnname; + +import java.math.BigDecimal; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; + +(a)Entity +public class WarehouseItem extends GenericObject { + + + Item item; + Vendor vendor; + ZItemCost defaultCost; + BigDecimal qtyInStock; + + + public BigDecimal getQtyInStock() { + return qtyInStock; + } + + public void setQtyInStock(BigDecimal qtyInStock) { + this.qtyInStock =3D qtyInStock; + } + + @ManyToOne +//(fetch=3DFetchType.LAZY) + @JoinColumn( name =3D "ITEM_ID", unique =3D false, nullable =3D false, in= sertable =3D true, updatable =3D true ) + public Item getItem() { + return item; + } + + public void setItem(Item item) { + this.item =3D item; + } + + @ManyToOne( fetch =3D FetchType.LAZY ) + @JoinColumn( name =3D "VENDOR_ID", unique =3D false, nullable =3D false, = insertable =3D true, updatable =3D true ) + public Vendor getVendor() { + return vendor; + } + + public void setVendor(Vendor vendor) { + this.vendor =3D vendor; + } + + @ManyToOne + @JoinColumns( { + @JoinColumn( name =3D "vendor_id", referencedColumnName =3D "vendor_id", = insertable =3D false, updatable =3D false ), + @JoinColumn( name =3D "item_id", referencedColumnName =3D "item_id", inse= rtable =3D false, updatable =3D false ) + } ) + public ZItemCost getDefaultCost() { + return defaultCost; + } + + public void setDefaultCost(ZItemCost defaultCost) { + this.defaultCost =3D defaultCost; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/manytoone/referencedcolumnname/ZItemCost.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/ZItemCost.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/manytoone/referencedcolumnname/ZItemCost.java 2009-11-24 21:03:15 U= TC (rev 18049) @@ -0,0 +1,46 @@ +//$ +package org.hibernate.test.annotations.manytoone.referencedcolumnname; + +import java.math.BigDecimal; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.ManyToOne; +import javax.persistence.Transient; +import javax.persistence.JoinColumn; + +(a)Entity +public class ZItemCost extends GenericObject { + + Item item; + Vendor vendor; + BigDecimal cost; + + @ManyToOne( fetch =3D FetchType.LAZY ) + //@JoinColumn(name=3D"ITEM_ID", unique=3Dfalse, nullable=3Dfalse, inserta= ble=3Dtrue, updatable=3Dtrue) + public Item getItem() { + return item; + } + + public void setItem(Item item) { + this.item =3D item; + } + + @ManyToOne( fetch =3D FetchType.LAZY ) + //@JoinColumn(name=3D"VENDOR_ID", unique=3Dfalse, nullable=3Dfalse, inser= table=3Dtrue, updatable=3Dtrue) + public Vendor getVendor() { + return vendor; + } + + public void setVendor(Vendor vendor) { + this.vendor =3D vendor; + } + + public BigDecimal getCost() { + return cost; + } + + public void setCost(BigDecimal cost) { + this.cost =3D cost; + } +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/namingstrategy/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/namingstrategy/Address.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/namingstrategy/Address.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +// $Id: Address.java 14741 2008-06-05 11:25:56Z hardy.ferentschik $ +package org.hibernate.test.annotations.namingstrategy; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinTable; +import javax.persistence.ManyToOne; + +(a)Entity +public class Address { + + @Id + private long id; + + @ManyToOne + @JoinTable(name =3D "person_address") + private Person person; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id =3D id; + } + + public Person getPerson() { + return person; + } + + public void setPerson(Person person) { + this.person =3D person; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/namingstrategy/DummyNamingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/namingstrategy/DummyNamingStrategy.java (re= v 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/namingstrategy/DummyNamingStrategy.java 2009-11-24 21:03:15 UTC (re= v 18049) @@ -0,0 +1,13 @@ +// $Id: DummyNamingStrategy.java 14741 2008-06-05 11:25:56Z hardy.ferentsc= hik $ +package org.hibernate.test.annotations.namingstrategy; + +import org.hibernate.cfg.EJB3NamingStrategy; + +(a)SuppressWarnings("serial") +public class DummyNamingStrategy extends EJB3NamingStrategy { + = + public String tableName(String tableName) { + return "T" + tableName; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/namingstrategy/NamingStrategyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/namingstrategy/NamingStrategyTest.java (rev= 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/namingstrategy/NamingStrategyTest.java 2009-11-24 21:03:15 UTC (rev= 18049) @@ -0,0 +1,52 @@ +// $Id: NamingStrategyTest.java 14741 2008-06-05 11:25:56Z hardy.ferentsch= ik $ +package org.hibernate.test.annotations.namingstrategy; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import junit.framework.TestCase; + +import org.hibernate.cfg.AnnotationConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Test harness for ANN-716. + * = + * @author Hardy Ferentschik + */ +public class NamingStrategyTest extends TestCase { + = + private Logger log =3D LoggerFactory.getLogger(NamingStrategyTest.class); + + public void testWithCustomNamingStrategy() throws Exception { + try { + AnnotationConfiguration config =3D new AnnotationConfiguration(); + config.setNamingStrategy(new DummyNamingStrategy()); + config.addAnnotatedClass(Address.class); + config.addAnnotatedClass(Person.class); + config.buildSessionFactory(); + } + catch( Exception e ) { + StringWriter writer =3D new StringWriter(); + e.printStackTrace(new PrintWriter(writer)); + log.debug(writer.toString()); + fail(e.getMessage()); + } + } + = + public void testWithoutCustomNamingStrategy() throws Exception { + try { + AnnotationConfiguration config =3D new AnnotationConfiguration(); + config.addAnnotatedClass(Address.class); + config.addAnnotatedClass(Person.class); + config.buildSessionFactory(); + } + catch( Exception e ) { + StringWriter writer =3D new StringWriter(); + e.printStackTrace(new PrintWriter(writer)); + log.debug(writer.toString()); + fail(e.getMessage()); + } + } = +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/namingstrategy/Person.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/namingstrategy/Person.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/namingstrategy/Person.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +// $Id: Person.java 14741 2008-06-05 11:25:56Z hardy.ferentschik $ +package org.hibernate.test.annotations.namingstrategy; + +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +(a)Entity +public class Person { + + @Id + private long id; + + @OneToMany(mappedBy =3D "person") + private Set

addresses =3D new HashSet
(); + + public long getId() { + return id; + } + + public void setId(long id) { + this.id =3D id; + } + + public Set
getAddresses() { + return addresses; + } + + public void setAddresses(Set
addresses) { + this.addresses =3D addresses; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/naturalid/Citizen.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/naturalid/Citizen.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/naturalid/Citizen.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,67 @@ +//$Id: Citizen.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.naturalid; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.NaturalId; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Citizen { + @Id + @GeneratedValue + private Integer id; + private String firstname; + private String lastname; + @NaturalId + @ManyToOne + private State state; + @NaturalId + private String ssn; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state =3D state; + } + + public String getSsn() { + return ssn; + } + + public void setSsn(String ssn) { + this.ssn =3D ssn; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/naturalid/NaturalIdOnManyToOne.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/naturalid/NaturalIdOnManyToOne.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/naturalid/NaturalIdOnManyToOne.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,42 @@ +package org.hibernate.test.annotations.naturalid; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.NaturalId; + +(a)Entity +/** + * Test case for NaturalId annotation - ANN-750 + * = + * @author Emmanuel Bernard + * @author Hardy Ferentschik + */ +class NaturalIdOnManyToOne { + + @Id + @GeneratedValue + int id; + + @NaturalId + @ManyToOne + Citizen citizen; + = + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + public Citizen getCitizen() { + return citizen; + } + + public void setCitizen(Citizen citizen) { + this.citizen =3D citizen; + } +} = Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/naturalid/NaturalIdOnSingleManyToOneTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/naturalid/NaturalIdOnSingleManyToOneTest.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/naturalid/NaturalIdOnSingleManyToOneTest.java 2009-11-24 21:03:15 U= TC (rev 18049) @@ -0,0 +1,95 @@ +//$Id: NaturalIdOnSingleManyToOneTest.java 14786 2008-06-19 14:59:11Z hard= y.ferentschik $ +package org.hibernate.test.annotations.naturalid; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.criterion.Restrictions; +import org.hibernate.metadata.ClassMetadata; +import org.hibernate.stat.Statistics; +import org.hibernate.test.annotations.TestCase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Test case for NaturalId annotation. See ANN-750. + * = + * @author Emmanuel Bernard + * @author Hardy Ferentschik + */ +(a)SuppressWarnings("unchecked") +public class NaturalIdOnSingleManyToOneTest extends TestCase { + = + private Logger log =3D LoggerFactory.getLogger(NaturalIdOnManyToOne.class= ); + + public void testMappingProperties() { + log.warn("Commented out test"); + = + ClassMetadata metaData =3D getSessions().getClassMetadata( + NaturalIdOnManyToOne.class); + assertTrue("Class should have a natural key", metaData + .hasNaturalIdentifier()); + int[] propertiesIndex =3D metaData.getNaturalIdentifierProperties(); + assertTrue("Wrong number of elements", propertiesIndex.length =3D=3D 1); + } + + public void testManyToOneNaturalIdCached() { + NaturalIdOnManyToOne singleManyToOne =3D new NaturalIdOnManyToOne(); + Citizen c1 =3D new Citizen(); + c1.setFirstname("Emmanuel"); + c1.setLastname("Bernard"); + c1.setSsn("1234"); + + State france =3D new State(); + france.setName("Ile de France"); + c1.setState(france); + + singleManyToOne.setCitizen(c1); + + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist(france); + s.persist(c1); + s.persist(singleManyToOne); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Criteria criteria =3D s.createCriteria(NaturalIdOnManyToOne.class); + criteria.add(Restrictions.naturalId().set("citizen", c1)); + criteria.setCacheable(true); + + Statistics stats =3D getSessions().getStatistics(); + stats.setStatisticsEnabled(true); + stats.clear(); + assertEquals("Cache hits should be empty", 0, stats + .getQueryCacheHitCount()); + + // first query + List results =3D criteria.list(); + assertEquals(1, results.size()); + assertEquals("Cache hits should be empty", 0, stats + .getQueryCacheHitCount()); + assertEquals("First query should be a miss", 1, stats + .getQueryCacheMissCount()); + assertEquals("Query result should be added to cache", 1, stats + .getQueryCachePutCount()); + + // query a second time - result should be cached + results =3D criteria.list(); + assertEquals("Cache hits should be empty", 1, stats + .getQueryCacheHitCount()); + + // cleanup + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { Citizen.class, State.class, + NaturalIdOnManyToOne.class }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/naturalid/NaturalIdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/naturalid/NaturalIdTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/naturalid/NaturalIdTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,137 @@ +//$Id: NaturalIdTest.java 14786 2008-06-19 14:59:11Z hardy.ferentschik $ +package org.hibernate.test.annotations.naturalid; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.criterion.Restrictions; +import org.hibernate.metadata.ClassMetadata; +import org.hibernate.stat.Statistics; +import org.hibernate.test.annotations.TestCase; + +/** + * Test case for NaturalId annotation + * = + * @author Emmanuel Bernard + * @author Hardy Ferentschik + */ +(a)SuppressWarnings("unchecked") +public class NaturalIdTest extends TestCase { + + public void testMappingProperties() { + ClassMetadata metaData =3D getSessions().getClassMetadata( + Citizen.class); + assertTrue("Class should have a natural key", metaData + .hasNaturalIdentifier()); + int[] propertiesIndex =3D metaData.getNaturalIdentifierProperties(); + assertTrue("Wrong number of elements", propertiesIndex.length =3D=3D 2); + } + + public void testNaturalIdCached() { + saveSomeCitizens(); + + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + State france =3D (State) s.load(State.class, new Integer(2)); + Criteria criteria =3D s.createCriteria(Citizen.class); + criteria.add(Restrictions.naturalId().set("ssn", "1234").set("state", + france)); + criteria.setCacheable(true); + + Statistics stats =3D getSessions().getStatistics(); + stats.setStatisticsEnabled(true); + stats.clear(); + assertEquals("Cache hits should be empty", 0, stats + .getQueryCacheHitCount()); + + // first query + List results =3D criteria.list(); + assertEquals(1, results.size()); + assertEquals("Cache hits should be empty", 0, stats + .getQueryCacheHitCount()); + assertEquals("First query should be a miss", 1, stats + .getQueryCacheMissCount()); + assertEquals("Query result should be added to cache", 1, stats + .getQueryCachePutCount()); + + // query a second time - result should be cached + results =3D criteria.list(); + assertEquals("Cache hits should be empty", 1, stats + .getQueryCacheHitCount()); + + // cleanup + tx.rollback(); + s.close(); + } + + public void testNaturalIdUncached() { + + saveSomeCitizens(); + + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + State france =3D (State) s.load(State.class, new Integer(2)); + Criteria criteria =3D s.createCriteria(Citizen.class); + criteria.add(Restrictions.naturalId().set("ssn", "1234").set("state", + france)); + criteria.setCacheable(false); + + Statistics stats =3D getSessions().getStatistics(); + stats.setStatisticsEnabled(true); + stats.clear(); + assertEquals("Cache hits should be empty", 0, stats + .getQueryCacheHitCount()); + + // first query + List results =3D criteria.list(); + assertEquals(1, results.size()); + assertEquals("Cache hits should be empty", 0, stats + .getQueryCacheHitCount()); + assertEquals("Query result should be added to cache", 0, stats + .getQueryCachePutCount()); + + // query a second time + results =3D criteria.list(); + assertEquals("Cache hits should be empty", 0, stats + .getQueryCacheHitCount()); + + // cleanup + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { Citizen.class, State.class, + NaturalIdOnManyToOne.class }; + } + + private void saveSomeCitizens() { + Citizen c1 =3D new Citizen(); + c1.setFirstname("Emmanuel"); + c1.setLastname("Bernard"); + c1.setSsn("1234"); + + State france =3D new State(); + france.setName("Ile de France"); + c1.setState(france); + + Citizen c2 =3D new Citizen(); + c2.setFirstname("Gavin"); + c2.setLastname("King"); + c2.setSsn("000"); + State australia =3D new State(); + australia.setName("Australia"); + c2.setState(australia); + + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist(australia); + s.persist(france); + s.persist(c1); + s.persist(c2); + tx.commit(); + s.close(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/naturalid/State.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/naturalid/State.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/naturalid/State.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: State.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.naturalid; + +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class State { + @Id + @GeneratedValue + private Integer id; + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/notfound/Coin.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/notfound/Coin.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/notfound/Coin.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,50 @@ +//$Id: Coin.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.notfound; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Coin { + private Integer id; + private String name; + private Currency currency; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToOne + @JoinColumn(name =3D "currency", referencedColumnName =3D "name") + @NotFound(action =3D NotFoundAction.IGNORE) + public Currency getCurrency() { + return currency; + } + + public void setCurrency(Currency currency) { + this.currency =3D currency; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/notfound/Currency.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/notfound/Currency.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/notfound/Currency.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: Currency.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.notfound; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Currency implements Serializable { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/notfound/NotFoundTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/notfound/NotFoundTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/notfound/NotFoundTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,45 @@ +//$Id: NotFoundTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.notfound; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class NotFoundTest extends TestCase { + + public void testManyToOne() throws Exception { + Currency euro =3D new Currency(); + euro.setName( "Euro" ); + Coin fiveC =3D new Coin(); + fiveC.setName( "Five cents" ); + fiveC.setCurrency( euro ); + Session s =3D openSession(); + s.getTransaction().begin(); + s.persist( euro ); + s.persist( fiveC ); + s.getTransaction().commit(); + s.clear(); + Transaction tx =3D s.beginTransaction(); + euro =3D (Currency) s.get( Currency.class, euro.getId() ); + s.delete( euro ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + fiveC =3D (Coin) s.get( Coin.class, fiveC.getId() ); + assertNull( fiveC.getCurrency() ); + s.delete( fiveC ); + tx.commit(); + s.close(); + + } + + protected Class[] getMappings() { + return new Class[]{ + Coin.class, + Currency.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Child.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Child.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Child.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Child.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Child implements Serializable { + @Id + @GeneratedValue + public Integer id; + + @ManyToOne() + @JoinColumns({ + @JoinColumn(name =3D "parentCivility", referencedColumnName =3D "isMale"), + @JoinColumn(name =3D "parentLastName", referencedColumnName =3D "lastName= "), + @JoinColumn(name =3D "parentFirstName", referencedColumnName =3D "firstNa= me") + }) + public Parent parent; + @Column(name =3D "fav_sup_hero") + public String favoriteSuperhero; + @Column(name =3D "fav_singer") + public String favoriteSinger; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/City.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/City.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/City.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,72 @@ +//$Id: City.java 15046 2008-08-13 14:59:47Z epbernard $ +package org.hibernate.test.annotations.onetomany; + +import java.util.ArrayList; +import java.util.List; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; + +import org.hibernate.annotations.ForeignKey; +import org.hibernate.annotations.Immutable; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +class City { + private Integer id; + private String name; + private List streets; + private List mainStreets; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @OneToMany(mappedBy =3D "city") + @OrderBy("streetNameCopy, id") + public synchronized List getStreets() { + return streets; + } + + public void setStreets(List streets) { + this.streets =3D streets; + } + + @OneToMany() + @JoinColumn(name =3D "mainstreetcity_id") + @ForeignKey(name =3D "CITYSTR_FK") + @OrderBy + @Immutable + public List getMainStreets() { + return mainStreets; + } + + public void setMainStreets(List streets) { + this.mainStreets =3D streets; + } + + public void addMainStreet(Street street) { + if ( mainStreets =3D=3D null ) mainStreets =3D new ArrayList(); + mainStreets.add( street ); + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Monkey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Monkey.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Monkey.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Monkey.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Monkey { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/OneToManyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OneToManyTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OneToManyTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,432 @@ +//$Id: OneToManyTest.java 16346 2009-04-15 19:14:22Z gbadner $ +package org.hibernate.test.annotations.onetomany; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.hibernate.Hibernate; +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.dialect.HSQLDialect; +import org.hibernate.test.annotations.Customer; +import org.hibernate.test.annotations.Discount; +import org.hibernate.test.annotations.Passport; +import org.hibernate.test.annotations.RequiresDialect; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.Ticket; +import org.hibernate.test.annotations.TicketComparator; + +/** + * Test various case of a one to many relationship + * + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("unchecked") +public class OneToManyTest extends TestCase { + + public OneToManyTest(String x) { + super( x ); + } + + public void testColumnDefinitionPropagation() throws Exception { + Session s; + s =3D openSession(); + s.getTransaction().begin(); + Politician casimir =3D new Politician(); + casimir.setName( "Casimir" ); + PoliticalParty dream =3D new PoliticalParty(); + dream.setName( "Dream" ); + dream.addPolitician( casimir ); + s.persist( dream ); + s.getTransaction().commit(); + s.clear(); + + Transaction tx =3D s.beginTransaction(); + s.delete( s.get( PoliticalParty.class, dream.getName() ) ); + tx.commit(); + s.close(); + } + + public void testListWithBagSemanticAndOrderBy() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + City paris =3D new City(); + paris.setName( "Paris" ); + s.persist( paris ); + Street rochechoir =3D new Street(); + rochechoir.setStreetName( "Rochechoir" ); + rochechoir.setCity( paris ); + Street chmpsElysees =3D new Street(); + chmpsElysees.setStreetName( "Champs Elysees" ); + chmpsElysees.setCity( paris ); + Street grandeArmee =3D new Street(); + grandeArmee.setStreetName( "Grande Armee" ); + grandeArmee.setCity( paris ); + s.persist( rochechoir ); + s.persist( chmpsElysees ); + s.persist( grandeArmee ); + paris.addMainStreet( chmpsElysees ); + paris.addMainStreet( grandeArmee ); + + s.flush(); + s.clear(); + + //testing @OrderBy with explicit values including Formula + paris =3D (City) s.get( City.class, paris.getId() ); + assertEquals( 3, paris.getStreets().size() ); + assertEquals( chmpsElysees.getStreetName(), paris.getStreets().get( 0 ).= getStreetName() ); + List mainStreets =3D paris.getMainStreets(); + assertEquals( 2, mainStreets.size() ); + Integer previousId =3D new Integer( -1 ); + for ( Street street : mainStreets ) { + assertTrue( previousId < street.getId() ); + previousId =3D street.getId(); + } + tx.rollback(); + s.close(); + + } + + public void testUnidirectionalDefault() throws Exception { + Session s; + Transaction tx; + Trainer trainer =3D new Trainer(); + trainer.setName( "First trainer" ); + Tiger regularTiger =3D new Tiger(); + regularTiger.setName( "Regular Tiger" ); + Tiger whiteTiger =3D new Tiger(); + whiteTiger.setName( "White Tiger" ); + trainer.setTrainedTigers( new HashSet() ); + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( trainer ); + s.persist( regularTiger ); + s.persist( whiteTiger ); + trainer.getTrainedTigers().add( regularTiger ); + trainer.getTrainedTigers().add( whiteTiger ); + + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + trainer =3D (Trainer) s.get( Trainer.class, trainer.getId() ); + assertNotNull( trainer ); + assertNotNull( trainer.getTrainedTigers() ); + assertEquals( 2, trainer.getTrainedTigers().size() ); + tx.rollback(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + trainer =3D new Trainer(); + trainer.setName( "new trainer" ); + trainer.setTrainedTigers( new HashSet() ); + trainer.getTrainedTigers().add( whiteTiger ); + try { + s.persist( trainer ); + tx.commit(); + fail( "A one to many should not allow several trainer per Tiger" ); + } + catch (HibernateException ce) { + tx.rollback(); + //success + } + s.close(); + } + + public void testUnidirectionalExplicit() throws Exception { + Session s; + Transaction tx; + Trainer trainer =3D new Trainer(); + trainer.setName( "First trainer" ); + Monkey regularMonkey =3D new Monkey(); + regularMonkey.setName( "Regular Monkey" ); + Monkey miniMonkey =3D new Monkey(); + miniMonkey.setName( "Mini Monkey" ); + trainer.setTrainedMonkeys( new HashSet() ); + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( trainer ); + s.persist( regularMonkey ); + s.persist( miniMonkey ); + trainer.getTrainedMonkeys().add( regularMonkey ); + trainer.getTrainedMonkeys().add( miniMonkey ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + trainer =3D (Trainer) s.get( Trainer.class, trainer.getId() ); + assertNotNull( trainer ); + assertNotNull( trainer.getTrainedMonkeys() ); + assertEquals( 2, trainer.getTrainedMonkeys().size() ); + tx.rollback(); + s.close(); + } + + public void testFetching() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Troop t =3D new Troop(); + t.setName( "Final cut" ); + Soldier vandamme =3D new Soldier(); + vandamme.setName( "JC Vandamme" ); + t.addSoldier( vandamme ); + Soldier rambo =3D new Soldier(); + rambo.setName( "Rambo" ); + t.addSoldier( rambo ); + s.persist( t ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + t =3D (Troop) s.get( Troop.class, t.getId() ); + assertNotNull( t.getSoldiers() ); + assertFalse( Hibernate.isInitialized( t.getSoldiers() ) ); + assertEquals( 2, t.getSoldiers().size() ); + assertEquals( rambo.getName(), t.getSoldiers().iterator().next().getName= () ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + t =3D (Troop) s.createQuery( "from " + Troop.class.getName() + " as t wh= ere t.id =3D :id" ) + .setParameter( "id", t.getId() ).uniqueResult(); + assertFalse( Hibernate.isInitialized( t.getSoldiers() ) ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + rambo =3D (Soldier) s.get( Soldier.class, rambo.getId() ); + assertTrue( Hibernate.isInitialized( rambo.getTroop() ) ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + rambo =3D (Soldier) s.createQuery( "from " + Soldier.class.getName() + "= as s where s.id =3D :rid" ) + .setParameter( "rid", rambo.getId() ).uniqueResult(); + assertTrue( "fetching strategy used when we do query", Hibernate.isIniti= alized( rambo.getTroop() ) ); + tx.commit(); + s.close(); + } + + public void testCascadeDeleteOrphan() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Troop disney =3D new Troop(); + disney.setName( "Disney" ); + Soldier mickey =3D new Soldier(); + mickey.setName( "Mickey" ); + disney.addSoldier( mickey ); + s.persist( disney ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + Troop troop =3D (Troop) s.get( Troop.class, disney.getId() ); + Soldier soldier =3D (Soldier) troop.getSoldiers().iterator().next(); + tx.commit(); + s.close(); + //troop.getSoldiers().remove(soldier); + troop.getSoldiers().clear(); + s =3D openSession(); + tx =3D s.beginTransaction(); + s.merge( troop ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + soldier =3D (Soldier) s.get( Soldier.class, mickey.getId() ); + assertNull( "delete-orphan should work", soldier ); + troop =3D (Troop) s.get( Troop.class, disney.getId() ); + s.delete( troop ); + tx.commit(); + s.close(); + } + + public void testCascadeDelete() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Troop disney =3D new Troop(); + disney.setName( "Disney" ); + Soldier mickey =3D new Soldier(); + mickey.setName( "Mickey" ); + disney.addSoldier( mickey ); + s.persist( disney ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + Troop troop =3D (Troop) s.get( Troop.class, disney.getId() ); + s.delete( troop ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + Soldier soldier =3D (Soldier) s.get( Soldier.class, mickey.getId() ); + assertNull( "delete-orphan should work", soldier ); + tx.commit(); + s.close(); + } + + public void testSimpleOneToManySet() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Ticket t =3D new Ticket(); + t.setNumber( "33A" ); + Ticket t2 =3D new Ticket(); + t2.setNumber( "234ER" ); + Customer c =3D new Customer(); + s.persist( c ); + //s.persist(t); + SortedSet tickets =3D new TreeSet( new TicketComparator(= ) ); + tickets.add( t ); + tickets.add( t2 ); + c.setTickets( tickets ); + + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + c =3D (Customer) s.load( Customer.class, c.getId() ); + assertNotNull( c ); + assertTrue( Hibernate.isInitialized( c.getTickets() ) ); + assertNotNull( c.getTickets() ); + tickets =3D c.getTickets(); + assertTrue( tickets.size() > 0 ); + assertEquals( t2.getNumber(), c.getTickets().first().getNumber() ); + tx.commit(); + s.close(); + } + + public void testSimpleOneToManyCollection() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Discount d =3D new Discount(); + d.setDiscount( 10 ); + Customer c =3D new Customer(); + List discounts =3D new ArrayList(); + discounts.add( d ); + d.setOwner( c ); + c.setDiscountTickets( discounts ); + s.persist( c ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + c =3D (Customer) s.load( Customer.class, c.getId() ); + assertNotNull( c ); + assertFalse( Hibernate.isInitialized( c.getDiscountTickets() ) ); + assertNotNull( c.getDiscountTickets() ); + Collection collecDiscount =3D c.getDiscountTickets(); + assertTrue( collecDiscount.size() > 0 ); + tx.commit(); + s.close(); + } + + public void testJoinColumns() throws Exception { + Parent parent =3D new Parent(); + ParentPk pk =3D new ParentPk(); + pk.firstName =3D "Bruce"; + pk.lastName =3D "Willis"; + pk.isMale =3D true; + parent.id =3D pk; + parent.age =3D 40; + Child child =3D new Child(); + Child child2 =3D new Child(); + parent.addChild( child ); + parent.addChild( child2 ); + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( parent ); + tx.commit(); + s.close(); + + assertNotNull( child.id ); + assertNotNull( child2.id ); + assertNotSame( child.id, child2.id ); + + s =3D openSession(); + tx =3D s.beginTransaction(); + parent =3D (Parent) s.get( Parent.class, pk ); + assertNotNull( parent.children ); + Hibernate.initialize( parent.children ); + assertEquals( 2, parent.children.size() ); + tx.commit(); + s.close(); + } + + @RequiresDialect(HSQLDialect.class) + public void testOrderByOnSuperclassProperty() { + OrganisationUser user =3D new OrganisationUser(); + user.setFirstName( "Emmanuel" ); + user.setLastName( "Bernard" ); + user.setIdPerson( new Long(1) ); + user.setSomeText( "SomeText" ); + Organisation org =3D new Organisation(); + org.setIdOrganisation( new Long(1) ); + org.setName( "S Diego Zoo" ); + user.setOrganisation( org ); + Session s =3D openSession(); + s.getTransaction().begin(); + s.persist( user ); + s.persist( org ); + s.flush(); + s.clear(); + s.createQuery( "select org from Organisation org left join fetch org.org= anisationUsers" ).list(); + s.getTransaction().rollback(); + s.close(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + Troop.class, + Soldier.class, + Customer.class, + Ticket.class, + Discount.class, + Passport.class, + Parent.class, + Child.class, + Trainer.class, + Tiger.class, + Monkey.class, + City.class, + Street.class, + PoliticalParty.class, + Politician.class, + Person.class, + Organisation.class, + OrganisationUser.class + }; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Order.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Order.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Order.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,70 @@ +//$Id: Order.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.List; +import java.util.ArrayList; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.Table; + +(a)Entity +(a)Table( name =3D "Order_tbl" ) +(a)IdClass( OrderID.class ) +public class Order { + private String schoolId; + private Integer schoolIdSort; + private Integer academicYear; + + private List itemList =3D new ArrayList(); + + public boolean equals(Object obj) { + return super.equals( obj ); + } + + public int hashCode() { + return 10; + } + + @Id + public Integer getAcademicYear() { + return this.academicYear; + } + + protected void setAcademicYear(Integer academicYear) { + this.academicYear =3D academicYear; + } + + @Id + public String getSchoolId() { + return this.schoolId; + } + + protected void setSchoolId(String schoolId) { + this.schoolId =3D schoolId; + } + + @OneToMany( mappedBy =3D "order" ) + @OrderBy( "dayNo desc" ) + public List getItemList() { + return this.itemList; + } + + public void setItemList(List itemList) { + this.itemList =3D itemList; + } + + public Integer getSchoolIdSort() { + return this.schoolIdSort; + } + + public void setSchoolIdSort(Integer schoolIdSort) { + this.schoolIdSort =3D schoolIdSort; + } + + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/OrderByTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OrderByTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OrderByTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,52 @@ +//$Id: OrderByTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; + +/** + * @author Emmanuel Bernard + */ +public class OrderByTest extends TestCase { + public void testOrderByOnIdClassProperties() throws Exception { + Session s =3D openSession( ); + s.getTransaction().begin(); + Order o =3D new Order(); + o.setAcademicYear( 2000 ); + o.setSchoolId( "Supelec" ); + o.setSchoolIdSort( 1 ); + s.persist( o ); + OrderItem oi1 =3D new OrderItem(); + oi1.setAcademicYear( 2000 ); + oi1.setDayName( "Monday" ); + oi1.setSchoolId( "Supelec" ); + oi1.setOrder( o ); + oi1.setDayNo( 23 ); + s.persist( oi1 ); + OrderItem oi2 =3D new OrderItem(); + oi2.setAcademicYear( 2000 ); + oi2.setDayName( "Tuesday" ); + oi2.setSchoolId( "Supelec" ); + oi2.setOrder( o ); + oi2.setDayNo( 30 ); + s.persist( oi2 ); + s.flush(); + s.clear(); + + OrderID oid =3D new OrderID(); + oid.setAcademicYear( 2000 ); + oid.setSchoolId( "Supelec" ); + o =3D (Order) s.get( Order.class, oid ); + assertEquals( 30, o.getItemList().get( 0 ).getDayNo().intValue() ); + + s.getTransaction().rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { + Order.class, + OrderItem.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/OrderID.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OrderID.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OrderID.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +//$Id: OrderID.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.io.Serializable; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +public class OrderID implements Serializable { + private String schoolId; + private Integer academicYear; + + @Column( name =3D "Academic_Yr" ) + public Integer getAcademicYear() { + return this.academicYear; + } + + public void setAcademicYear(Integer academicYear) { + this.academicYear =3D academicYear; + } + + @Column( name =3D "School_Id" ) + public String getSchoolId() { + return this.schoolId; + } + + public void setSchoolId(String schoolId) { + this.schoolId =3D schoolId; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/OrderItem.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OrderItem.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OrderItem.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,73 @@ +//$Id: OrderItem.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +(a)Entity +(a)Table( name =3D "OrderItem_tbl" ) +(a)IdClass( OrderItemID.class ) +public class OrderItem { + String schoolId; + Integer academicYear; + Integer dayNo; + String dayName; + private Order order; + + @Id + public Integer getDayNo() { + return dayNo; + } + + public void setDayNo(Integer dayNo) { + this.dayNo =3D dayNo; + } + + @Id + public String getSchoolId() { + return schoolId; + } + + public void setSchoolId(String schoolId) { + this.schoolId =3D schoolId; + } + + @Id + public Integer getAcademicYear() { + return academicYear; + } + + public void setAcademicYear(Integer academicYear) { + this.academicYear =3D academicYear; + } + + @Column( name =3D "Day_Name" ) + public String getDayName() { + return dayName; + } + + public void setDayName(String dayName) { + this.dayName =3D dayName; + } + + @ManyToOne( fetch =3D FetchType.LAZY ) + @JoinColumns( { + @JoinColumn( name =3D "School_Id", referencedColumnName =3D "School_Id", = insertable =3D false, updatable =3D false ), + @JoinColumn( name =3D "Academic_Yr", referencedColumnName =3D "Academic_Y= r", insertable =3D false, updatable =3D false ) + } ) + public Order getOrder() { + return this.order; + } + + public void setOrder(Order order) { + this.order =3D order; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/OrderItemID.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OrderItemID.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OrderItemID.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,41 @@ +//$Id: OrderItemID.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.io.Serializable; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +public class OrderItemID implements Serializable { + String schoolId; + Integer academicYear; + Integer dayNo; + + @Column( name =3D "Academic_Yr" ) + public Integer getAcademicYear() { + return this.academicYear; + } + + public void setAcademicYear(Integer academicYear) { + this.academicYear =3D academicYear; + } + + @Column( name =3D "Day_No" ) + public Integer getDayNo() { + return this.dayNo; + } + + public void setDayNo(Integer dayNo) { + this.dayNo =3D dayNo; + } + + @Column( name =3D "School_Id" ) + public String getSchoolId() { + return this.schoolId; + } + + public void setSchoolId(String schoolId) { + this.schoolId =3D schoolId; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Organisation.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Organisation.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Organisation.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,60 @@ +//$Id: Organisation.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.Table; +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.CascadeType; +import javax.persistence.FetchType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table( name =3D "ORGANISATION" ) +public class Organisation implements Serializable { + + private Long idOrganisation; + private String name; + private Set organisationUsers; + + public Organisation() { + } + + public void setIdOrganisation(Long idOrganisation) { + this.idOrganisation =3D idOrganisation; + } + + @Id + @Column( name =3D "id_organisation", nullable =3D false ) + public Long getIdOrganisation() { + return idOrganisation; + } + + public void setName(String name) { + this.name =3D name; + } + + @Column( name =3D "name", nullable =3D false, length =3D 40 ) + public String getName() { + return name; + } + + public void setOrganisationUsers(Set organisationUsers)= { + this.organisationUsers =3D organisationUsers; + } + + @OneToMany( mappedBy =3D "organisation", + fetch =3D FetchType.LAZY, + cascade =3D {CascadeType.PERSIST, CascadeType.MERGE} ) + @OrderBy( value =3D "firstName" ) + public Set getOrganisationUsers() { + return organisationUsers; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/OrganisationUser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OrganisationUser.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/OrganisationUser.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,46 @@ +//$Id: OrganisationUser.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.io.Serializable; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)PrimaryKeyJoinColumn( name =3D "id_organisation_user" ) +(a)Table( name =3D "ORGANISATION_USER" ) +public class OrganisationUser extends Person implements Serializable { + + private String someText; + private Organisation organisation; + + public OrganisationUser() { + } + + public void setSomeText(String someText) { + this.someText =3D someText; + } + + @Column( name =3D "some_text", nullable=3Dtrue,length=3D1024) + public String getSomeText() { + return someText; + } + + public void setOrganisation(Organisation organisation) { + this.organisation =3D organisation; + } + + @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE} ) + @JoinColumn( name =3D "fk_id_organisation", nullable =3D false ) + public Organisation getOrganisation() { + return organisation; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Parent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Parent.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Parent.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,50 @@ +//$Id: Parent.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.BatchSize; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Parent implements Serializable { + @Id + public ParentPk id; + public int age; + + @OneToMany(cascade =3D CascadeType.ALL, mappedBy =3D "parent") + @BatchSize(size =3D 5) + @javax.persistence.OrderBy("favoriteSuperhero asc, favoriteSinger desc") + public Set children; + + public int hashCode() { + //a NPE can occurs, but I don't expect hashcode to be used before pk is = set + return id.hashCode(); + } + + public boolean equals(Object obj) { + //a NPE can occurs, but I don't expect equals to be used before pk is set + if ( obj !=3D null && obj instanceof Parent ) { + return id.equals( ( (Parent) obj ).id ); + } + else { + return false; + } + } + + public void addChild(Child child) { + if ( children =3D=3D null ) { + children =3D new HashSet(); + } + child.parent =3D this; + children.add( child ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/ParentPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/ParentPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/ParentPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,38 @@ +//$Id: ParentPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.io.Serializable; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class ParentPk implements Serializable { + String firstName; + String lastName; + + /** + * is a male or a female + */ + //show hetereogenous PK types + boolean isMale; + + public int hashCode() { + //this implem sucks + return firstName.hashCode() + lastName.hashCode() + ( isMale ? 0 : 1 ); + } + + public boolean equals(Object obj) { + //firstName and lastName are expected to be set in this implem + if ( obj !=3D null && obj instanceof ParentPk ) { + ParentPk other =3D (ParentPk) obj; + return firstName.equals( other.firstName ) + && lastName.equals( other.lastName ) + && isMale =3D=3D other.isMale; + } + else { + return false; + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Person.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Person.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Person.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,55 @@ +//$Id: Person.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Entity; +import javax.persistence.Table; +import javax.persistence.InheritanceType; +import javax.persistence.Inheritance; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance( strategy =3D InheritanceType.JOINED ) +(a)Table( name =3D "PERSON_Orderby" ) +public class Person implements Serializable { + + private Long idPerson; + private String firstName, lastName; + + public Person() { + } + + public void setIdPerson(Long idPerson) { + this.idPerson =3D idPerson; + } + + @Id + @Column( name =3D "id_person", nullable =3D false ) + public Long getIdPerson() { + return idPerson; + } + + public void setFirstName(String firstName) { + this.firstName =3D firstName; + } + + @Column( name =3D "first_name", length =3D 40, nullable =3D false ) + public String getFirstName() { + return firstName; + } + + public void setLastName(String lastName) { + this.lastName =3D lastName; + } + + @Column( name =3D "last_name", length =3D 40, nullable =3D false ) + public String getLastName() { + return lastName; + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/PoliticalParty.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/PoliticalParty.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/PoliticalParty.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,43 @@ +//$Id: PoliticalParty.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class PoliticalParty { + private String name; + private Set politicians =3D new HashSet(); + + @Id + @Column(columnDefinition =3D "VARCHAR(60)") + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @OneToMany(mappedBy =3D "party", cascade =3D CascadeType.ALL) + public Set getPoliticians() { + return politicians; + } + + public void setPoliticians(Set politicians) { + this.politicians =3D politicians; + } + + public void addPolitician(Politician politician) { + politicians.add( politician ); + politician.setParty( this ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Politician.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Politician.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Politician.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,37 @@ +//$Id: Politician.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Politician { + private String name; + private PoliticalParty party; + + @Id + @Column(columnDefinition =3D "VARCHAR(30)") + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToOne + @JoinColumn(name =3D "party_fk") + public PoliticalParty getParty() { + return party; + } + + public void setParty(PoliticalParty party) { + this.party =3D party; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Soldier.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Soldier.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Soldier.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,62 @@ +//$Id: Soldier.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Soldier { + private Integer id; + private String name; + private Troop troop; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToOne(fetch =3D FetchType.EAGER) + @JoinColumn(name =3D "troop_fk") + public Troop getTroop() { + return troop; + } + + public void setTroop(Troop troop) { + this.troop =3D troop; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Soldier ) ) return false; + + final Soldier soldier =3D (Soldier) o; + + if ( !name.equals( soldier.name ) ) return false; + + return true; + } + + public int hashCode() { + return name.hashCode(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Street.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Street.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Street.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,58 @@ +//$Id: Street.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Column; + +import org.hibernate.annotations.Formula; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Street { + private Integer id; + private String streetName; + private String streetNameCopy; + private City city; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @Column(name=3D"STREET_NAME") + public String getStreetName() { + return streetName; + } + + public void setStreetName(String streetName) { + this.streetName =3D streetName; + } + + @Formula("STREET_NAME") + public String getStreetNameCopy() { + return streetNameCopy; + } + + public void setStreetNameCopy(String streetNameCopy) { + this.streetNameCopy =3D streetNameCopy; + } + + @ManyToOne + public City getCity() { + return city; + } + + public void setCity(City city) { + this.city =3D city; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Tiger.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Tiger.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Tiger.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Tiger.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Tiger { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Trainer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Trainer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Trainer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,67 @@ +//$Id: Trainer.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.ForeignKey; + +/** + * Unidirectional one to many sample + * + * @author Emmanuel Bernard + */ +(a)Entity() +public class Trainer { + private Integer id; + private String name; + private Set trainedTigers; + private Set trainedMonkeys; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @OneToMany + public Set getTrainedTigers() { + return trainedTigers; + } + + public void setTrainedTigers(Set trainedTigers) { + this.trainedTigers =3D trainedTigers; + } + + @OneToMany + @JoinTable( + name =3D "TrainedMonkeys", + joinColumns =3D {@JoinColumn(name =3D "trainer_id")}, + inverseJoinColumns =3D @JoinColumn(name =3D "monkey_id") + ) + @ForeignKey(name =3D "TM_TRA_FK", inverseName =3D "TM_MON_FK") + public Set getTrainedMonkeys() { + return trainedMonkeys; + } + + public void setTrainedMonkeys(Set trainedMonkeys) { + this.trainedMonkeys =3D trainedMonkeys; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetomany/Troop.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Troop.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetomany/Troop.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,64 @@ +//$Id: Troop.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetomany; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; +import org.hibernate.annotations.OrderBy; + +/** + * Shows a default one to many + * + * @author Emmanuel Bernard + */ +(a)Entity +public class Troop { + private Integer id; + private String name; + private Set soldiers; + + @OneToMany(mappedBy =3D "troop", cascade =3D {CascadeType.ALL}, fetch =3D= FetchType.LAZY) + @OrderBy(clause =3D "name desc") + @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.= DELETE_ORPHAN) + @OnDelete(action =3D OnDeleteAction.CASCADE) + public Set getSoldiers() { + return soldiers; + } + + public void setSoldiers(Set soldiers) { + this.soldiers =3D soldiers; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public void addSoldier(Soldier s) { + if ( soldiers =3D=3D null ) soldiers =3D new HashSet(); + soldiers.add( s ); + s.setTroop( this ); + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Address.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Address.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: Address.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Address { + + private Integer id; + private String city; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city =3D city; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/Body.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Body.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Body.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: Body.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; +import javax.persistence.PrimaryKeyJoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Body { + private Integer id; + private Heart heart; + + @OneToOne + @PrimaryKeyJoinColumn + public Heart getHeart() { + return heart; + } + + public void setHeart(Heart heart) { + this.heart =3D heart; + } + + @Id + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/Client.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Client.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Client.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,49 @@ +//$Id: Client.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Client { + + private Integer id; + private String name; + private Address address; + + @OneToOne(cascade =3D CascadeType.ALL) + @JoinColumn(name =3D "ADDRESS_ID") + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address =3D address; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/Computer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Computer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Computer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,73 @@ +//$Id: Computer.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.OneToOne; + + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Computer { + + private ComputerPk id; + private String cpu; + private SerialNumber serial; + + @OneToOne(cascade =3D {CascadeType.PERSIST}) + @JoinColumns({ + @JoinColumn(name =3D "serialbrand", referencedColumnName =3D "brand"), + @JoinColumn(name =3D "serialmodel", referencedColumnName =3D "model") + }) + public SerialNumber getSerial() { + return serial; + } + + public void setSerial(SerialNumber serial) { + this.serial =3D serial; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Computer ) ) return false; + + final Computer computer =3D (Computer) o; + + if ( !id.equals( computer.id ) ) return false; + + return true; + } + + public int hashCode() { + return id.hashCode(); + } + + @EmbeddedId + @AttributeOverrides({ + @AttributeOverride(name =3D "brand", column =3D @Column(name =3D "compute= r_brand")), + @AttributeOverride(name =3D "model", column =3D @Column(name =3D "compute= r_model")) + }) + public ComputerPk getId() { + return id; + } + + public void setId(ComputerPk id) { + this.id =3D id; + } + + public String getCpu() { + return cpu; + } + + public void setCpu(String cpu) { + this.cpu =3D cpu; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/ComputerPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/ComputerPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/ComputerPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,49 @@ +//$Id: ComputerPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import java.io.Serializable; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class ComputerPk implements Serializable { + private String brand; + private String model; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof ComputerPk ) ) return false; + + final ComputerPk computerPk =3D (ComputerPk) o; + + if ( !brand.equals( computerPk.brand ) ) return false; + if ( !model.equals( computerPk.model ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D brand.hashCode(); + result =3D 29 * result + model.hashCode(); + return result; + } + + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand =3D brand; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/Heart.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Heart.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Heart.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: Heart.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Heart { + private Integer id; + + @Id + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/OneToOneErrorTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/OneToOneErrorTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/OneToOneErrorTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: OneToOneErrorTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.test.annotations.onetoone; + +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.cfg.Environment; +import org.hibernate.test.annotations.IncorrectEntity; +import org.hibernate.SessionFactory; +import org.hibernate.AnnotationException; + +/** + * @author Emmanuel Bernard + */ +public class OneToOneErrorTest extends junit.framework.TestCase { + public void testWrongOneToOne() throws Exception { + AnnotationConfiguration cfg =3D new AnnotationConfiguration(); + cfg.addAnnotatedClass( Show.class ) + .addAnnotatedClass( ShowDescription.class ); + cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); + try { + SessionFactory sf =3D cfg.buildSessionFactory(); + fail( "Wrong mappedBy does not fail property" ); + } + catch (AnnotationException e) { + //success + } + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/OneToOneTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/OneToOneTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/OneToOneTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,268 @@ +//$Id: OneToOneTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.Customer; +import org.hibernate.test.annotations.Discount; +import org.hibernate.test.annotations.Passport; +import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.annotations.Ticket; + +/** + * @author Emmanuel Bernard + */ +public class OneToOneTest extends TestCase { + + public OneToOneTest(String x) { + super( x ); + } + + public void testEagerFetching() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Client c =3D new Client(); + c.setName( "Emmanuel" ); + Address a =3D new Address(); + a.setCity( "Courbevoie" ); + c.setAddress( a ); + s.persist( c ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "select c from Client c where c.name =3D :nam= e" ); + q.setString( "name", c.getName() ); + c =3D (Client) q.uniqueResult(); + //c =3D (Client) s.get(Client.class, c.getId()); + assertNotNull( c ); + tx.commit(); + s.close(); + assertNotNull( c.getAddress() ); + //assertTrue( "Should be eager fetched", Hibernate.isInitialized( c.getA= ddress() ) ); + + } + + public void testDefaultOneToOne() throws Exception { + //test a default one to one and a mappedBy in the other side + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Customer c =3D new Customer(); + c.setName( "Hibernatus" ); + Passport p =3D new Passport(); + p.setNumber( "123456789" ); + s.persist( c ); //we need the id to assigned it to passport + c.setPassport( p ); + p.setOwner( c ); + p.setId( c.getId() ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + c =3D (Customer) s.get( Customer.class, c.getId() ); + assertNotNull( c ); + p =3D c.getPassport(); + assertNotNull( p ); + assertEquals( "123456789", p.getNumber() ); + assertNotNull( p.getOwner() ); + assertEquals( "Hibernatus", p.getOwner().getName() ); + tx.commit(); // commit or rollback is the same, we don't care for read q= ueries + s.close(); + } + + public void testOneToOneWithExplicitFk() throws Exception { + Client c =3D new Client(); + Address a =3D new Address(); + a.setCity( "Paris" ); + c.setName( "Emmanuel" ); + c.setAddress( a ); + + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( c ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + c =3D (Client) s.get( Client.class, c.getId() ); + assertNotNull( c ); + assertNotNull( c.getAddress() ); + assertEquals( "Paris", c.getAddress().getCity() ); + tx.commit(); + s.close(); + } + + public void testUnidirectionalTrueOneToOne() throws Exception { + Body b =3D new Body(); + Heart h =3D new Heart(); + b.setHeart( h ); + b.setId( new Integer( 1 ) ); + h.setId( b.getId() ); //same PK + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + s.persist( h ); + s.persist( b ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + b =3D (Body) s.get( Body.class, b.getId() ); + assertNotNull( b ); + assertNotNull( b.getHeart() ); + assertEquals( h.getId(), b.getHeart().getId() ); + tx.commit(); + s.close(); + + } + + public void testCompositePk() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + ComputerPk cid =3D new ComputerPk(); + cid.setBrand( "IBM" ); + cid.setModel( "ThinkPad" ); + Computer c =3D new Computer(); + c.setId( cid ); + c.setCpu( "2 GHz" ); + SerialNumberPk sid =3D new SerialNumberPk(); + sid.setBrand( cid.getBrand() ); + sid.setModel( cid.getModel() ); + SerialNumber sn =3D new SerialNumber(); + sn.setId( sid ); + sn.setValue( "REZREZ23424" ); + c.setSerial( sn ); + s.persist( c ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + c =3D (Computer) s.get( Computer.class, cid ); + assertNotNull( c ); + assertNotNull( c.getSerial() ); + assertEquals( sn.getValue(), c.getSerial().getValue() ); + tx.commit(); + s.close(); + } + + public void testBidirectionalTrueOneToOne() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Party party =3D new Party(); + PartyAffiliate affiliate =3D new PartyAffiliate(); + affiliate.partyId =3D "id"; + party.partyId =3D "id"; + party.partyAffiliate =3D affiliate; + affiliate.party =3D party; + s.persist( party ); + s.persist( affiliate ); + s.getTransaction().commit(); + + s.clear(); + + Transaction tx =3D s.beginTransaction(); + affiliate =3D (PartyAffiliate) s.get( PartyAffiliate.class, "id" ); + assertNotNull( affiliate.party ); + assertEquals( affiliate.partyId, affiliate.party.partyId ); + + s.clear(); + + party =3D (Party) s.get( Party.class, "id" ); + assertNotNull( party.partyAffiliate ); + assertEquals( party.partyId, party.partyAffiliate.partyId ); + + s.delete( party ); + s.delete( party.partyAffiliate ); + tx.commit(); + s.close(); + } + + public void testBidirectionalFkOneToOne() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Trousers trousers =3D new Trousers(); + TrousersZip zip =3D new TrousersZip(); + trousers.id =3D new Integer( 1 ); + zip.id =3D new Integer( 2 ); + trousers.zip =3D zip; + zip.trousers =3D trousers; + s.persist( trousers ); + s.persist( zip ); + s.getTransaction().commit(); + + s.clear(); + + Transaction tx =3D s.beginTransaction(); + trousers =3D (Trousers) s.get( Trousers.class, trousers.id ); + assertNotNull( trousers.zip ); + assertEquals( zip.id, trousers.zip.id ); + + s.clear(); + + zip =3D (TrousersZip) s.get( TrousersZip.class, zip.id ); + assertNotNull( zip.trousers ); + assertEquals( trousers.id, zip.trousers.id ); + + s.delete( zip ); + s.delete( zip.trousers ); + tx.commit(); + s.close(); + } + + public void testForeignGenerator() { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Owner owner =3D new Owner(); + OwnerAddress address =3D new OwnerAddress(); + owner.setAddress( address ); + address.setOwner( owner ); + s.persist( owner ); + s.flush(); + s.clear(); + owner =3D (Owner) s.get( Owner.class, owner.getId() ); + assertNotNull( owner ); + assertNotNull( owner.getAddress() ); + assertEquals( owner.getId(), owner.getAddress().getId() ); + tx.rollback(); + s.close(); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + PartyAffiliate.class, + Party.class, + Trousers.class, + TrousersZip.class, + Customer.class, + Ticket.class, + Discount.class, + Passport.class, + Client.class, + Address.class, + Computer.class, + SerialNumber.class, + Body.class, + Heart.class, + Owner.class, + OwnerAddress.class + }; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/Owner.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Owner.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Owner.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: Owner.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.OneToOne; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.CascadeType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Owner { + @Id @GeneratedValue private Integer id; + + @OneToOne(cascade =3D CascadeType.ALL) @PrimaryKeyJoinColumn private Owne= rAddress address; + + public OwnerAddress getAddress() { + return address; + } + + public void setAddress(OwnerAddress address) { + this.address =3D address; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/OwnerAddress.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/OwnerAddress.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/OwnerAddress.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +//$Id: OwnerAddress.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.OneToOne; + +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Parameter; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class OwnerAddress { + @Id @GeneratedValue(generator =3D "fk") + @GenericGenerator(strategy =3D "foreign", name =3D "fk", parameters =3D @= Parameter(name=3D"property", value=3D"owner")) + private Integer id; + + @OneToOne(mappedBy=3D"address", optional =3D false) + private Owner owner; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Owner getOwner() { + return owner; + } + + public void setOwner(Owner owner) { + this.owner =3D owner; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/Party.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Party.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Party.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,20 @@ +//$Id: Party.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; +import javax.persistence.PrimaryKeyJoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Party { + @Id + String partyId; + + @OneToOne + @PrimaryKeyJoinColumn + PartyAffiliate partyAffiliate; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/PartyAffiliate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/PartyAffiliate.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/PartyAffiliate.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,21 @@ +//$Id: PartyAffiliate.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; +import javax.persistence.PrimaryKeyJoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class PartyAffiliate { + @Id + String partyId; + + @OneToOne(mappedBy=3D"partyAffiliate") + Party party; + + String affiliateName; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/SerialNumber.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/SerialNumber.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/SerialNumber.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,46 @@ +//$Id: SerialNumber.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class SerialNumber { + private SerialNumberPk id; + private String value; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof SerialNumber ) ) return false; + + final SerialNumber serialNumber =3D (SerialNumber) o; + + if ( !id.equals( serialNumber.id ) ) return false; + + return true; + } + + public int hashCode() { + return id.hashCode(); + } + + @Id + public SerialNumberPk getId() { + return id; + } + + public void setId(SerialNumberPk id) { + this.id =3D id; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value =3D value; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/SerialNumberPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/SerialNumberPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/SerialNumberPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,49 @@ +//$Id: SerialNumberPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import java.io.Serializable; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class SerialNumberPk implements Serializable { + private String brand; + private String model; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof SerialNumberPk ) ) return false; + + final SerialNumberPk serialNumberPk =3D (SerialNumberPk) o; + + if ( !brand.equals( serialNumberPk.brand ) ) return false; + if ( !model.equals( serialNumberPk.model ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D brand.hashCode(); + result =3D 13 * result + model.hashCode(); + return result; + } + + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand =3D brand; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/Show.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Show.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Show.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: Show.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Show { + @Id + private Integer id; + @OneToOne() private ShowDescription description; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public ShowDescription getDescription() { + return description; + } + + public void setDescription(ShowDescription description) { + this.description =3D description; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/ShowDescription.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/ShowDescription.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/ShowDescription.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: ShowDescription.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class ShowDescription { + @Id + private Integer id; + @OneToOne(mappedBy =3D "wrongProperty") + private Show show; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Show getShow() { + return show; + } + + public void setShow(Show show) { + this.show =3D show; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/Trousers.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Trousers.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/Trousers.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,21 @@ +//$Id: Trousers.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Trousers { + @Id + public Integer id; + + @OneToOne + @JoinColumn(name =3D "zip_id") + public TrousersZip zip; + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/TrousersZip.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/TrousersZip.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/TrousersZip.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,17 @@ +//$Id: TrousersZip.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class TrousersZip { + @Id + public Integer id; + @OneToOne(mappedBy =3D "zip") + public Trousers trousers; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/primarykey/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/primarykey/Address.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/primarykey/Address.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,33 @@ +//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone.primarykey; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; + +(a)Entity +public class Address { + + @Id + private long id; + + @OneToOne(mappedBy =3D "address") + private Person person; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id =3D id; + } + + public Person getPerson() { + return person; + } + + public void setPerson(Person person) { + this.person =3D person; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/primarykey/NullablePrimaryKeyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/primarykey/NullablePrimaryKeyTest.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/primarykey/NullablePrimaryKeyTest.java 2009-11-24 21:03:15= UTC (rev 18049) @@ -0,0 +1,39 @@ +//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone.primarykey; + +import junit.framework.TestCase; + +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.dialect.SQLServerDialect; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Test harness for ANN-742. + * = + * @author Hardy Ferentschik + * = + */ +public class NullablePrimaryKeyTest extends TestCase { + + private Logger log =3D LoggerFactory.getLogger(NullablePrimaryKeyTest.cla= ss); + + public void testGeneratedSql() { + try { + AnnotationConfiguration config =3D new AnnotationConfiguration(); + config.addAnnotatedClass(Address.class); + config.addAnnotatedClass(Person.class); + config.buildSessionFactory(); + String[] schema =3D config + .generateSchemaCreationScript(new SQLServerDialect()); + for (String s : schema) { + log.debug(s); + } + String expectedMappingTableSql =3D "create table personAddress (address= _id numeric(19,0) null, " + + "person_id numeric(19,0) not null, primary key (person_id))"; + assertEquals("Wrong SQL", expectedMappingTableSql, schema[2]); + } catch (Exception e) { + fail(e.getMessage()); + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/onetoone/primarykey/Person.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/primarykey/Person.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/onetoone/primarykey/Person.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.onetoone.primarykey; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.OneToOne; + +(a)Entity +public class Person { + + @Id + private long id; + + @OneToOne + @JoinTable( + name =3D "personAddress", + joinColumns =3D @JoinColumn(name =3D "person_id"), + inverseJoinColumns =3D @JoinColumn(name =3D "address_id") + ) + private Address address; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id =3D id; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address =3D address; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/orm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/orm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/orm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/override/AssociationOverrideTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/override/AssociationOverrideTest.java (rev = 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/override/AssociationOverrideTest.java 2009-11-24 21:03:15 UTC (rev = 18049) @@ -0,0 +1,47 @@ +//$Id: AssociationOverrideTest.java 14736 2008-06-04 14:23:42Z hardy.feren= tschik $ +package org.hibernate.test.annotations.override; + +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class AssociationOverrideTest extends TestCase { + + public void testOverriding() throws Exception { + Location paris =3D new Location(); + paris.setName( "Paris" ); + Location atlanta =3D new Location(); + atlanta.setName( "Atlanta" ); + Trip trip =3D new Trip(); + trip.setFrom( paris ); + //trip.setTo( atlanta ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist( paris ); + s.persist( atlanta ); + try { + s.persist( trip ); + s.flush(); + fail( "Should be non nullable" ); + } + catch (HibernateException e) { + //success + } + finally { + tx.rollback(); + s.close(); + } + } + + protected Class[] getMappings() { + return new Class[]{ + Location.class, + Move.class, + Trip.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/override/Location.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/override/Location.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/override/Location.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: Location.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.override; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Location { + private String name; + + @Id + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/override/Move.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/override/Move.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/override/Move.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,47 @@ +//$Id: Move.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.override; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Move { + private int id; + private Location from; + private Location to; + + @ManyToOne + public Location getFrom() { + return from; + } + + public void setFrom(Location from) { + this.from =3D from; + } + + @Id + @GeneratedValue + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + @ManyToOne + @JoinColumn(name =3D "to", nullable =3D true) + public Location getTo() { + return to; + } + + public void setTo(Location to) { + this.to =3D to; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/override/Trip.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/override/Trip.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/override/Trip.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,18 @@ +//$Id: Trip.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.override; + +import javax.persistence.AssociationOverride; +import javax.persistence.AssociationOverrides; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)AssociationOverrides({ +(a)AssociationOverride(name =3D "from", joinColumns =3D @JoinColumn(name = =3D "from2", nullable =3D false)), +(a)AssociationOverride(name =3D "to", joinColumns =3D @JoinColumn(name =3D= "to2", nullable =3D false)) + }) +public class Trip extends Move { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/persister/Card.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/persister/Card.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/persister/Card.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,21 @@ +package org.hibernate.test.annotations.persister; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +/** + * @author Shawn Clowater + */ +(a)Entity +(a)org.hibernate.annotations.Entity( persister =3D "org.hibernate.persiste= r.entity.SingleTableEntityPersister" ) +public class Card implements Serializable { + @Id + public Integer id; + + @ManyToOne() + @JoinColumn() + public Deck deck; +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/persister/CollectionPersister.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/persister/CollectionPersister.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/persister/CollectionPersister.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,19 @@ +package org.hibernate.test.annotations.persister; + +import org.hibernate.MappingException; +import org.hibernate.cache.CacheException; +import org.hibernate.cache.access.CollectionRegionAccessStrategy; +import org.hibernate.cfg.Configuration; +import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.mapping.Collection; +import org.hibernate.persister.collection.OneToManyPersister; + +/** + * @author Shawn Clowater + */ +public class CollectionPersister extends OneToManyPersister { + public CollectionPersister(Collection collection, CollectionRegionAccessS= trategy cache, Configuration cfg, + SessionFactoryImplementor factory) throws MappingException, Cach= eException { + super( collection, cache, cfg, factory ); + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/persister/Deck.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/persister/Deck.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/persister/Deck.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +package org.hibernate.test.annotations.persister; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.annotations.Persister; + + +/** + * @author Shawn Clowater + */ +(a)Entity +(a)org.hibernate.annotations.Entity( persister =3D "org.hibernate.persiste= r.entity.SingleTableEntityPersister" ) +(a)Persister( impl =3D org.hibernate.test.annotations.persister.EntityPers= ister.class ) +public class Deck implements Serializable { + @Id + public Integer id; + + @OneToMany( mappedBy =3D "deck" ) + @Persister( impl =3D org.hibernate.test.annotations.persister.CollectionP= ersister.class ) + public Set cards; +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/persister/EntityPersister.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/persister/EntityPersister.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/persister/EntityPersister.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,19 @@ +package org.hibernate.test.annotations.persister; + +import org.hibernate.HibernateException; +import org.hibernate.cache.CacheConcurrencyStrategy; +import org.hibernate.cache.access.EntityRegionAccessStrategy; +import org.hibernate.engine.Mapping; +import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.persister.entity.SingleTableEntityPersister; + +/** + * @author Shawn Clowater + */ +public class EntityPersister extends SingleTableEntityPersister { + public EntityPersister(PersistentClass persistentClass, EntityRegionAcces= sStrategy cache, + SessionFactoryImplementor factory, Mapping cfg) throws HibernateE= xception { + super( persistentClass, cache, factory, cfg ); + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/persister/PersisterTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/persister/PersisterTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/persister/PersisterTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,47 @@ +package org.hibernate.test.annotations.persister; + +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.persister.entity.SingleTableEntityPersister; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Shawn Clowater + */ +public class PersisterTest extends TestCase { + public PersisterTest(String x) { + super( x ); + } + + public void testEntityEntityPersisterAndPersisterSpecified() throws Excep= tion { + //checks to see that the persister specified with the @Persister annotat= ion takes precedence if a @Entity.persister() is also specified = + PersistentClass persistentClass =3D (PersistentClass) getCfg().getClassM= apping( Deck.class.getName() ); + assertEquals( "Incorrect Persister class for " + persistentClass.getMapp= edClass(), EntityPersister.class, + persistentClass.getEntityPersisterClass() ); + } + + public void testEntityEntityPersisterSpecified() throws Exception { + //tests the persister specified with an @Entity.persister() = + PersistentClass persistentClass =3D (PersistentClass) getCfg().getClassM= apping( Card.class.getName() ); + assertEquals( "Incorrect Persister class for " + persistentClass.getMapp= edClass(), + SingleTableEntityPersister.class, persistentClass.getEntityPersisterCl= ass() ); + } + + public void testCollectionPersisterSpecified() throws Exception { + //tests the persister specified by the @Persister annotation on a collec= tion + Collection collection =3D (Collection) getCfg().getCollectionMapping( De= ck.class.getName() + ".cards" ); + assertEquals( "Incorrect Persister class for collection " + collection.g= etRole(), CollectionPersister.class, + collection.getCollectionPersisterClass() ); + } + + /** + * @see org.hibernate.test.annotations.TestCase#getMappings() + */ + protected Class[] getMappings() { + return new Class[]{ + Card.class, + Deck.class + }; + } + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/polymorphism/Car.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/polymorphism/Car.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/polymorphism/Car.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +//$Id: Car.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.polymorphism; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +import org.hibernate.annotations.PolymorphismType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy=3D InheritanceType.TABLE_PER_CLASS) +(a)org.hibernate.annotations.Entity(polymorphism =3D PolymorphismType.EXPL= ICIT) +public class Car extends MovingThing { + private Integer id; + private String model; + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } + + @Id @GeneratedValue(strategy =3D GenerationType.TABLE ) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/polymorphism/MovingThing.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/polymorphism/MovingThing.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/polymorphism/MovingThing.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,8 @@ +//$Id: MovingThing.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.polymorphism; + +/** + * @author Emmanuel Bernard + */ +public class MovingThing { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/polymorphism/PolymorphismTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/polymorphism/PolymorphismTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/polymorphism/PolymorphismTest.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,37 @@ +//$Id: PolymorphismTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.polymorphism; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; +import org.hibernate.Transaction; + +/** + * @author Emmanuel Bernard + */ +public class PolymorphismTest extends TestCase { + + public void testPolymorphism() throws Exception { + Car car =3D new Car(); + car.setModel( "SUV" ); + SportCar car2 =3D new SportCar(); + car2.setModel( "350Z" ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + tx.begin(); + s.persist( car ); + s.persist( car2 ); + s.flush(); + assertEquals( 2, s.createQuery( "select car from Car car").list().size()= ); + assertEquals( 0, s.createQuery( "select count(m) from " + MovingThing.cl= ass.getName() + " m").list().size() ); + tx.rollback(); + s.close(); + + } + + protected Class[] getMappings() { + return new Class[] { + Car.class, + SportCar.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/polymorphism/SportCar.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/polymorphism/SportCar.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/polymorphism/SportCar.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,16 @@ +//$Id: SportCar.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.polymorphism; + +import javax.persistence.Entity; +import javax.persistence.Table; + +import org.hibernate.annotations.PolymorphismType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "sport_car") +(a)org.hibernate.annotations.Entity(polymorphism =3D PolymorphismType.EXPL= ICIT) //raise a warn +public class SportCar extends Car { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/Area.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Area.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Area.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,73 @@ +//$Id: Area.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.query; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EntityResult; +import javax.persistence.FieldResult; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.NamedNativeQueries; +import javax.persistence.NamedNativeQuery; +import javax.persistence.SqlResultSetMapping; +import javax.persistence.SqlResultSetMappings; +import javax.persistence.Table; + +/** + * Example of a entity load incl a join fetching of an associated *ToOne e= ntity + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)NamedNativeQueries({ +(a)NamedNativeQuery( + name =3D "night&area", query =3D "select night.id as nid, night.night_du= ration, night.night_date, area.id as aid, " + + "night.area_id, area.name from Night night, tbl_area area where night.= area_id =3D area.id", + resultSetMapping =3D "joinMapping") + }) +(a)org.hibernate.annotations.NamedNativeQueries({ +(a)org.hibernate.annotations.NamedNativeQuery( + name =3D "night&areaCached", + query =3D "select night.id as nid, night.night_duration, night.night_dat= e, area.id as aid, " + + "night.area_id, area.name from Night night, tbl_area area where nigh= t.area_id =3D area.id", + resultSetMapping =3D "joinMapping") + }) +(a)SqlResultSetMappings( + @SqlResultSetMapping(name =3D "joinMapping", entities =3D { + @EntityResult(entityClass =3D org.hibernate.test.annotations.query.Night= .class, fields =3D { + @FieldResult(name =3D "id", column =3D "nid"), + @FieldResult(name =3D "duration", column =3D "night_duration"), + @FieldResult(name =3D "date", column =3D "night_date"), + @FieldResult(name =3D "area", column =3D "area_id") + }), + @EntityResult(entityClass =3D org.hibernate.test.annotations.query.Area.= class, fields =3D { + @FieldResult(name =3D "id", column =3D "aid"), + @FieldResult(name =3D "name", column =3D "name") + }) + } + ) +) +(a)Table(name =3D "tbl_area") +public class Area { + private Integer id; + private String name; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @Column(unique =3D true) + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/Captain.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Captain.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Captain.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,52 @@ +//$Id: Captain.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.query; + +import java.io.Serializable; +import javax.persistence.ColumnResult; +import javax.persistence.Entity; +import javax.persistence.EntityResult; +import javax.persistence.FieldResult; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.SqlResultSetMapping; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)IdClass(Identity.class) +(a)SqlResultSetMapping(name =3D "compositekey", + entities =3D @EntityResult(entityClass =3D org.hibernate.test.annotation= s.query.SpaceShip.class, + fields =3D { + @FieldResult(name =3D "name", column =3D "name"), + @FieldResult(name =3D "model", column =3D "model"), + @FieldResult(name =3D "speed", column =3D "speed"), + @FieldResult(name =3D "dimensions.width", column =3D "width"), + @FieldResult(name =3D "captain.lastname", column =3D "lastn"), + @FieldResult(name =3D "dimensions.length", column =3D "length"), + @FieldResult(name =3D "captain.firstname", column =3D "firstn") + }), + columns =3D {@ColumnResult(name =3D "surface"), + @ColumnResult(name =3D "volume")}) +public class Captain implements Serializable { + private String firstname; + private String lastname; + + @Id + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + @Id + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/CasimirParticle.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/CasimirParticle.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/CasimirParticle.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +//$Id: CasimirParticle.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.query; + +import javax.persistence.Entity; +import javax.persistence.Table; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name=3D"CASIMIR_PARTICULE") +public class CasimirParticle { + @Id + private Long id; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/Chaos.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Chaos.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Chaos.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,86 @@ +//$Id: Chaos.java 16293 2009-04-10 19:17:45Z gbadner $ +package org.hibernate.test.annotations.query; + +import java.util.Set; +import java.util.HashSet; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.NamedQuery; +import javax.persistence.NamedNativeQuery; +import javax.persistence.OneToMany; +import javax.persistence.JoinColumn; +import javax.persistence.Column; + +import org.hibernate.annotations.SQLInsert; +import org.hibernate.annotations.SQLUpdate; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLDeleteAll; +import org.hibernate.annotations.Loader; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name=3D"CHAOS") +(a)SQLInsert( sql=3D"INSERT INTO CHAOS(name, nick_name, chaos_size, id) VA= LUES(upper(?),?,?,?)") +(a)SQLUpdate( sql=3D"UPDATE CHAOS SET name =3D upper(?), nick_name =3D ?, = chaos_size =3D ? WHERE id =3D ?") +(a)SQLDelete( sql=3D"DELETE CHAOS WHERE id =3D ?") +(a)SQLDeleteAll( sql=3D"DELETE CHAOS") +(a)Loader(namedQuery =3D "chaos") +(a)NamedNativeQuery(name=3D"chaos", query=3D"select id, chaos_size, name, = lower( nick_name ) as nick_name from CHAOS where id=3D ?", resultClass =3D = Chaos.class) +public class Chaos { + @Id + private Long id; + @Column(name=3D"chaos_size") + private Long size; + private String name; + @Column(name=3D"nick_name") + private String nickname; + + @OneToMany + @JoinColumn(name=3D"chaos_fk") + @SQLInsert( sql=3D"UPDATE CASIMIR_PARTICULE SET chaos_fk =3D ? where id = =3D ?") + @SQLDelete( sql=3D"UPDATE CASIMIR_PARTICULE SET chaos_fk =3D null where i= d =3D ?") + private Set particles =3D new HashSet(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public Long getSize() { + return size; + } + + public void setSize(Long size) { + this.size =3D size; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getNickname() { + return nickname; + } + + public void setNickname(String nickname) { + this.nickname =3D nickname; + } + + public Set getParticles() { + return particles; + } + + public void setParticles(Set particles) { + this.particles =3D particles; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/Dictionary.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Dictionary.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Dictionary.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,66 @@ +//$Id: Dictionary.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.query; + +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.EntityResult; +import javax.persistence.FieldResult; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.NamedNativeQuery; +import javax.persistence.SqlResultSetMapping; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorColumn(name =3D "disc") +(a)DiscriminatorValue("Dic") +(a)SqlResultSetMapping( + name =3D "dictionary", entities =3D { +(a)EntityResult( + entityClass =3D org.hibernate.test.annotations.query.Dictionary.class, + fields =3D { + @FieldResult(name =3D "id", column =3D "id"), + @FieldResult(name =3D "name", column =3D "name"), + @FieldResult(name =3D "editor", column =3D "editor") + }, + discriminatorColumn =3D "type" +) + } +) +(a)NamedNativeQuery(name =3D "all.dictionaries", + query =3D "select id, name, editor, disc as type from Dictionary", + resultSetMapping =3D "dictionary") +public class Dictionary { + private Integer id; + private String name; + private String editor; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public String getEditor() { + return editor; + } + + public void setEditor(String editor) { + this.editor =3D editor; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/Dimensions.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Dimensions.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Dimensions.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +//$Id: Dimensions.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.query; + +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class Dimensions { + = + + private int length; + private int width; + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length =3D length; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width =3D width; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/Identity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Identity.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Identity.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,47 @@ +//$Id: Identity.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.query; + +import java.io.Serializable; + +/** + * @author Emmanuel Bernard + */ +public class Identity implements Serializable { + private String firstname; + private String lastname; + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final Identity identity =3D (Identity) o; + + if ( !firstname.equals( identity.firstname ) ) return false; + if ( !lastname.equals( identity.lastname ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D firstname.hashCode(); + result =3D 29 * result + lastname.hashCode(); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/Mark.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Mark.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Mark.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: Mark.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.query; + +import javax.persistence.ColumnResult; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.NamedNativeQuery; +import javax.persistence.SqlResultSetMapping; + +/** + * Example of scalar result (not working right now) + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)NamedNativeQuery(name =3D "average", query =3D "select avg(m.value) fro= m Mark m", resultSetMapping =3D "columnmapping") +(a)SqlResultSetMapping( + name =3D "columnmapping", + columns =3D @ColumnResult(name =3D "aver") +) +public class Mark { + @Id + @GeneratedValue + public int id; + public int value; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/Night.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Night.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/Night.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,66 @@ +//$Id: Night.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.query; + +import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; + +/** + * Entity declaring a named query + * + * @author Emmanuel Bernard + */ +(a)Entity +(a)NamedQuery(name =3D "night.moreRecentThan", query =3D "select n from Ni= ght n where n.date >=3D :date") +(a)org.hibernate.annotations.NamedQuery( + name =3D "night.duration", + query =3D "select n from Night n where n.duration =3D :duration", + cacheable =3D true, cacheRegion =3D "nightQuery" +) +public class Night { + private Integer id; + private long duration; + private Date date; + private Area area; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @Column(name =3D "night_duration") + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration =3D duration; + } + + @Column(name =3D "night_date") + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date =3D date; + } + + @ManyToOne + public Area getArea() { + return area; + } + + public void setArea(Area area) { + this.area =3D area; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/QueryAndSQLTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/QueryAndSQLTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/QueryAndSQLTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,380 @@ +//$Id: QueryAndSQLTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.query; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.stat.Statistics; +import org.hibernate.test.annotations.A320; +import org.hibernate.test.annotations.A320b; +import org.hibernate.test.annotations.Plane; +import org.hibernate.test.annotations.TestCase; + +/** + * Test named queries + * + * @author Emmanuel Bernard + */ +public class QueryAndSQLTest extends TestCase { + public QueryAndSQLTest(String x) { + super( x ); + } + + public void testPackageQueries() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Plane p =3D new Plane(); + s.persist( p ); + Query q =3D s.getNamedQuery( "plane.getAll" ); + assertEquals( 1, q.list().size() ); + tx.commit(); + s.close(); + } + + public void testClassQueries() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Night n =3D new Night(); + Calendar c =3D new GregorianCalendar(); + c.set( 2000, 2, 2 ); + Date now =3D c.getTime(); + c.add( Calendar.MONTH, -1 ); + Date aMonthAgo =3D c.getTime(); + c.add( Calendar.MONTH, 2 ); + Date inAMonth =3D c.getTime(); + n.setDate( now ); + n.setDuration( 14 ); + s.persist( n ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.getNamedQuery( "night.moreRecentThan" ); + q.setDate( "date", aMonthAgo ); + assertEquals( 1, q.list().size() ); + q =3D s.getNamedQuery( "night.moreRecentThan" ); + q.setDate( "date", inAMonth ); + assertEquals( 0, q.list().size() ); + Statistics stats =3D getSessions().getStatistics(); + stats.setStatisticsEnabled( true ); + stats.clear(); + q =3D s.getNamedQuery( "night.duration" ); + q.setParameter( "duration", 14l ); + assertEquals( 1, q.list().size() ); + assertEquals( 1, stats.getQueryCachePutCount() ); + q =3D s.getNamedQuery( "night.duration" ); + q.setParameter( "duration", 14l ); + s.delete( q.list().get( 0 ) ); + assertEquals( 1, stats.getQueryCacheHitCount() ); + tx.commit(); + s.close(); + } + + public void testSQLQuery() { + Night n =3D new Night(); + Calendar c =3D new GregorianCalendar(); + c.set( 2000, 2, 2 ); + Date now =3D c.getTime(); + c.add( Calendar.MONTH, -1 ); + Date aMonthAgo =3D c.getTime(); + c.add( Calendar.MONTH, 2 ); + Date inAMonth =3D c.getTime(); + n.setDate( now ); + n.setDuration( 9999 ); + Area area =3D new Area(); + area.setName( "Monceau" ); + + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist( n ); + s.persist( area ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + Query q =3D s.getNamedQuery( "night.getAll.bySQL" ); + q.setParameter( 0, 9990 ); + List result =3D q.list(); + assertEquals( 1, result.size() ); + Night n2 =3D (Night) result.get( 0 ); + assertEquals( n2.getDuration(), n.getDuration() ); + List areas =3D s.getNamedQuery( "getAreaByNative" ).list(); + assertTrue( 1 =3D=3D areas.size() ); + assertEquals( area.getName(), ( (Area) areas.get( 0 ) ).getName() ); + tx.commit(); + s.close(); + } + + public void testSQLQueryWithManyToOne() { + Night n =3D new Night(); + Calendar c =3D new GregorianCalendar(); + c.set( 2000, 2, 2 ); + Date now =3D c.getTime(); + c.add( Calendar.MONTH, -1 ); + Date aMonthAgo =3D c.getTime(); + c.add( Calendar.MONTH, 2 ); + Date inAMonth =3D c.getTime(); + n.setDate( now ); + n.setDuration( 9999 ); + Area a =3D new Area(); + a.setName( "Paris" ); + n.setArea( a ); + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + s.persist( a ); + s.persist( n ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + Statistics stats =3D getSessions().getStatistics(); + stats.setStatisticsEnabled( true ); + Query q =3D s.getNamedQuery( "night&areaCached" ); + List result =3D q.list(); + assertEquals( 1, result.size() ); + assertEquals( 1, stats.getQueryCachePutCount() ); + q.list(); + assertEquals( 1, stats.getQueryCacheHitCount() ); + Night n2 =3D (Night) ( (Object[]) result.get( 0 ) )[0]; + assertEquals( n2.getDuration(), n.getDuration() ); + tx.commit(); + s.close(); + } + + public void testImplicitNativeQuery() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + SpaceShip ship =3D new SpaceShip(); + ship.setModel( "X-Wing" ); + ship.setName( "YuBlue" ); + ship.setSpeed( 2000 ); + ship.setDimensions( new Dimensions() ); + s.persist( ship ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + Query q =3D s.getNamedQuery( "implicitSample" ); + List result =3D q.list(); + assertEquals( 1, result.size() ); + assertEquals( ship.getModel(), ( (SpaceShip) result.get( 0 ) ).getModel(= ) ); + s.delete( result.get( 0 ) ); + tx.commit(); + s.close(); + } + + public void testNativeQueryAndCompositePKAndComponents() throws Exception= { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + SpaceShip ship =3D new SpaceShip(); + ship.setModel( "X-Wing" ); + ship.setName( "YuBlue" ); + ship.setSpeed( 2000 ); + ship.setDimensions( new Dimensions() ); + ship.getDimensions().setLength( 10 ); + ship.getDimensions().setWidth( 5 ); + Captain captain =3D new Captain(); + captain.setFirstname( "Luke" ); + captain.setLastname( "Skywalker" ); + ship.setCaptain( captain ); + s.persist( captain ); + s.persist( ship ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + Query q =3D s.getNamedQuery( "compositekey" ); + List result =3D q.list(); + assertEquals( 1, result.size() ); + Object[] row =3D (Object[]) result.get( 0 ); + SpaceShip spaceShip =3D (SpaceShip) row[0]; + assertEquals( ship.getModel(), spaceShip.getModel() ); + assertNotNull( spaceShip.getDimensions() ); + assertEquals( ship.getDimensions().getWidth(), spaceShip.getDimensions()= .getWidth() ); + assertEquals( ship.getDimensions().getLength(), spaceShip.getDimensions(= ).getLength() ); + assertEquals( ship.getCaptain().getFirstname(), ship.getCaptain().getFir= stname() ); + assertEquals( ship.getCaptain().getLastname(), ship.getCaptain().getLast= name() ); + //FIXME vary depending on databases + assertTrue( row[1].toString().startsWith( "50" ) ); + assertTrue( row[2].toString().startsWith( "500" ) ); + s.delete( spaceShip.getCaptain() ); + s.delete( spaceShip ); + tx.commit(); + s.close(); + } + + public void testDiscriminator() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Dictionary dic =3D new Dictionary(); + dic.setName( "Anglais-Francais" ); + dic.setEditor( "Harrap's" ); + SynonymousDictionary syn =3D new SynonymousDictionary(); + syn.setName( "Synonymes de tous les temps" ); + syn.setEditor( "Imagination edition" ); + s.persist( dic ); + s.persist( syn ); + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + List results =3D s.getNamedQuery( "all.dictionaries" ).list(); + assertEquals( 2, results.size() ); + assertTrue( + results.get( 0 ) instanceof SynonymousDictionary + || results.get( 1 ) instanceof SynonymousDictionary + ); + tx.commit(); + s.close(); + } + +// public void testScalarQuery() throws Exception { +// Session s =3D openSession(); +// Transaction tx; +// tx =3D s.beginTransaction(); +// Mark bad =3D new Mark(); +// bad.value =3D 5; +// Mark good =3D new Mark(); +// good.value =3D 15; +// s.persist(bad); +// s.persist(good); +// tx.commit(); +// s.clear(); +// tx =3D s.beginTransaction(); +// List result =3D s.getNamedQuery("average").list(); +// assertEquals( 1, result.size() ); +// tx.commit(); +// s.close(); +// +// } + + public void testCache() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Plane plane =3D new Plane(); + plane.setNbrOfSeats( 5 ); + s.persist( plane ); + tx.commit(); + s.close(); + getSessions().getStatistics().clear(); + getSessions().getStatistics().setStatisticsEnabled( true ); + s =3D openSession(); + tx =3D s.beginTransaction(); + Query query =3D s.getNamedQuery( "plane.byId" ).setParameter( "id", plan= e.getId() ); + plane =3D (Plane) query.uniqueResult(); + assertEquals( 1, getSessions().getStatistics().getQueryCachePutCount() ); + plane =3D (Plane) s.getNamedQuery( "plane.byId" ).setParameter( "id", pl= ane.getId() ).uniqueResult(); + assertEquals( 1, getSessions().getStatistics().getQueryCacheHitCount() ); + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + s.delete( s.get( Plane.class, plane.getId() ) ); + tx.commit(); + s.close(); + } + + public void testEntitySQLOverriding() { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Chaos chaos =3D new Chaos(); + chaos.setSize( 123l ); + chaos.setId( 1l ); + + String lowerName =3D "hello"; + String upperName =3D lowerName.toUpperCase(); + assertFalse( lowerName.equals( upperName ) ); + + chaos.setName( "hello" ); + chaos.setNickname( "NickName" ); + s.persist( chaos ); + s.flush(); + s.clear(); + s.getSessionFactory().evict( Chaos.class ); + + Chaos resultChaos =3D (Chaos) s.load( Chaos.class, chaos.getId() ); + assertEquals( upperName, resultChaos.getName() ); + assertEquals( "nickname", resultChaos.getNickname() ); + + tx.rollback(); + s.close(); + } + + public void testCollectionSQLOverriding() { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Chaos chaos =3D new Chaos(); + chaos.setSize( 123l ); + chaos.setId( 1l ); + + chaos.setName( "hello" ); + s.persist( chaos ); + CasimirParticle p =3D new CasimirParticle(); + p.setId( 1l ); + s.persist( p ); + chaos.getParticles().add(p); + p =3D new CasimirParticle(); + p.setId( 2l ); + s.persist( p ); + chaos.getParticles().add(p); + s.flush(); + s.clear(); + s.getSessionFactory().evict( Chaos.class ); + + Chaos resultChaos =3D (Chaos) s.load( Chaos.class, chaos.getId() ); + assertEquals( 2, resultChaos.getParticles().size() ); + resultChaos.getParticles().remove( resultChaos.getParticles().iterator()= .next() ); + resultChaos.getParticles().remove( resultChaos.getParticles().iterator()= .next() ); + s.flush(); + + s.clear(); + resultChaos =3D (Chaos) s.load( Chaos.class, chaos.getId() ); + assertEquals( 0, resultChaos.getParticles().size() ); + + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[]{ + Plane.class, + A320.class, + A320b.class, + Night.class, + Area.class, + SpaceShip.class, + Dictionary.class, + SynonymousDictionary.class, + Captain.class, + Chaos.class, + CasimirParticle.class + }; + } + + protected String[] getAnnotatedPackages() { + return new String[]{ + "org.hibernate.test.annotations.query" + }; + } + + @Override + protected String[] getXmlFiles() { + return new String[]{ + "org/hibernate/test/annotations/query/orm.xml" + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/SpaceShip.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/SpaceShip.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/SpaceShip.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,80 @@ +//$Id: SpaceShip.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.query; + +import javax.persistence.Entity; +import javax.persistence.EntityResult; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; +import javax.persistence.NamedNativeQueries; +import javax.persistence.NamedNativeQuery; +import javax.persistence.SqlResultSetMapping; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)SqlResultSetMapping(name =3D "implicit", + entities =3D @EntityResult(entityClass =3D org.hibernate.test.annotation= s.query.SpaceShip.class)) +(a)NamedNativeQueries({ +(a)NamedNativeQuery(name =3D "implicitSample", query =3D "select * from Sp= aceShip", resultSetMapping =3D "implicit"), +(a)NamedNativeQuery(name =3D "compositekey", + query =3D "select name, model, speed, lname as lastn, fname as firstn, l= ength, width, length * width as surface, length * width *10 as volume from = SpaceShip", + resultSetMapping =3D "compositekey") + }) +//we're missins @SqlREsultSetMappings so look at Captain +public class SpaceShip { + private String name; + private String model; + private double speed; + private Captain captain; + private Dimensions dimensions; + + @Id + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToOne(fetch =3D FetchType.LAZY) + @JoinColumns({ + @JoinColumn(name =3D "fname", referencedColumnName =3D "firstname"), + @JoinColumn(name =3D "lname", referencedColumnName =3D "lastname") + }) + public Captain getCaptain() { + return captain; + } + + public void setCaptain(Captain captain) { + this.captain =3D captain; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model =3D model; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed =3D speed; + } + + public Dimensions getDimensions() { + return dimensions; + } + + public void setDimensions(Dimensions dimensions) { + this.dimensions =3D dimensions; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/SynonymousDictionary.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/SynonymousDictionary.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/SynonymousDictionary.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,13 @@ +//$Id: SynonymousDictionary.java 14736 2008-06-04 14:23:42Z hardy.ferentsc= hik $ +package org.hibernate.test.annotations.query; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)DiscriminatorValue("Syn") +public class SynonymousDictionary extends Dictionary { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/query/orm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/orm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/query/orm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ + + + + + select p from Plane p + + + select id, night_duration, night_date as dte, area_id from = Night where night_duration > ? + + + select * from tbl_area + + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/quote/QuoteTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/quote/QuoteTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/quote/QuoteTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: QuoteTest.java 14735 2008-06-04 14:05:50Z hardy.ferentschik $ +package org.hibernate.test.annotations.quote; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; +import org.hibernate.Transaction; + +/** + * @author Emmanuel Bernard + */ +public class QuoteTest extends TestCase { + public void testQuoteManytoMany() { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + User u =3D new User(); + s.persist( u ); + Role r =3D new Role(); + s.persist( r ); + u.getRoles().add( r ); + s.flush(); + s.clear(); + u =3D (User) s.get( User.class, u.getId() ); + assertEquals( 1, u.getRoles().size() ); + tx.rollback(); + String role =3D User.class.getName() + ".roles"; + assertEquals( "User_Role", getCfg().getCollectionMapping( role ).getColl= ectionTable().getName() ); + s.close(); + } + protected Class[] getMappings() { + return new Class[] { + User.class, + Role.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/quote/Role.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/quote/Role.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/quote/Role.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: Role.java 14735 2008-06-04 14:05:50Z hardy.ferentschik $ +package org.hibernate.test.annotations.quote; + +import java.io.Serializable; +import javax.persistence.Id; +import javax.persistence.Entity; +import javax.persistence.GenerationType; +import javax.persistence.GeneratedValue; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "`Role`") +public class Role implements Serializable { + + @Id + @GeneratedValue(strategy =3D GenerationType.AUTO) + private long id; + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/quote/User.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/quote/User.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/quote/User.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,44 @@ +//$Id: User.java 14735 2008-06-04 14:05:50Z hardy.ferentschik $ +package org.hibernate.test.annotations.quote; + +import java.io.Serializable; +import java.util.Set; +import java.util.HashSet; +import javax.persistence.ManyToMany; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Table; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "`User`") +public class User implements Serializable { + + @Id + @GeneratedValue(strategy =3D GenerationType.AUTO) + private long id; + + @ManyToMany + private Set roles =3D new HashSet(); + + + public long getId() { + return id; + } + + public void setId(long id) { + this.id =3D id; + } + + public Set getRoles() { + return roles; + } + + public void setRoles(Set roles) { + this.roles =3D roles; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/Bag.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Bag.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Bag.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,56 @@ +//$Id: Bag.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Bag { + private Integer id; + private String serial; + private Rambler owner; + + public Bag() { + } + + public Bag(String serial, Rambler owner) { + this.serial =3D serial; + this.owner =3D owner; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @Column(unique =3D true) + public String getSerial() { + return serial; + } + + public void setSerial(String serial) { + this.serial =3D serial; + } + + @ManyToOne + @JoinColumn(referencedColumnName =3D "fld_name") + public Rambler getOwner() { + return owner; + } + + public void setOwner(Rambler owner) { + this.owner =3D owner; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/Clothes.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Clothes.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Clothes.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,69 @@ +//$Id: Clothes.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Clothes { + private Integer id; + private String type; + private String flavor; + + public Clothes() { + } + + public Clothes(String type, String flavor) { + this.type =3D type; + this.flavor =3D flavor; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type =3D type; + } + + public String getFlavor() { + return flavor; + } + + public void setFlavor(String flavor) { + this.flavor =3D flavor; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Clothes ) ) return false; + + final Clothes clothes =3D (Clothes) o; + + if ( !flavor.equals( clothes.flavor ) ) return false; + if ( !type.equals( clothes.type ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D type.hashCode(); + result =3D 29 * result + flavor.hashCode(); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/House.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/House.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/House.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,80 @@ +//$Id: House.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class House implements Serializable { + private Integer id; + private String address; + private Postman postman; + private Set hasInhabitants =3D new HashSet(); + + @ManyToOne + @JoinColumn(referencedColumnName =3D "name") + public Postman getPostman() { + return postman; + } + + public void setPostman(Postman postman) { + this.postman =3D postman; + } + + @Id + @GeneratedValue(strategy =3D GenerationType.AUTO) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address =3D address; + } + + @ManyToMany + @JoinTable(joinColumns =3D @JoinColumn(referencedColumnName =3D "address"= ), + inverseJoinColumns =3D @JoinColumn(referencedColumnName =3D "name") + ) + public Set getHasInhabitants() { + return hasInhabitants; + } + + public void setHasInhabitants(Set hasInhabitants) { + this.hasInhabitants =3D hasInhabitants; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof House ) ) return false; + + final House house =3D (House) o; + + if ( address !=3D null ? !address.equals( house.address ) : house.addres= s !=3D null ) return false; + + return true; + } + + public int hashCode() { + return ( address !=3D null ? address.hashCode() : 0 ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/Inhabitant.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Inhabitant.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Inhabitant.java 2009-11-24 21:03:15 UTC (rev 1= 8049) @@ -0,0 +1,62 @@ +//$Id: Inhabitant.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Inhabitant implements Serializable { + private Integer id; + private String name; + private Set livesIn =3D new HashSet(); + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @ManyToMany(mappedBy =3D "hasInhabitants") + public Set getLivesIn() { + return livesIn; + } + + public void setLivesIn(Set livesIn) { + this.livesIn =3D livesIn; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Inhabitant ) ) return false; + + final Inhabitant inhabitant =3D (Inhabitant) o; + + if ( name !=3D null ? !name.equals( inhabitant.name ) : inhabitant.name = !=3D null ) return false; + + return true; + } + + public int hashCode() { + return ( name !=3D null ? name.hashCode() : 0 ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/Item.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Item.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Item.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,23 @@ +//$Id: Item.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Item { + int id; + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/ItemCost.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/ItemCost.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/ItemCost.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,55 @@ +//$Id: ItemCost.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import java.math.BigDecimal; +import java.io.Serializable; +import javax.persistence.Id; +import javax.persistence.Entity; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class ItemCost implements Serializable { + int id; + Item item; + Vendor vendor; + BigDecimal cost; + + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + @ManyToOne + public Item getItem() { + return item; + } + + public void setItem(Item item) { + this.item =3D item; + } + + @ManyToOne + public Vendor getVendor() { + return vendor; + } + + public void setVendor(Vendor vendor) { + this.vendor =3D vendor; + } + + public BigDecimal getCost() { + return cost; + } + + public void setCost(BigDecimal cost) { + this.cost =3D cost; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/Luggage.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Luggage.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Luggage.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,90 @@ +//$Id: Luggage.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Luggage implements Serializable { + private Integer id; + private String owner; + private String type; + private Set hasInside =3D new HashSet(); + + public Luggage() { + } + + public Luggage(String owner, String type) { + this.owner =3D owner; + this.type =3D type; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner =3D owner; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type =3D type; + } + + @OneToMany(cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}) + @JoinColumns({ + @JoinColumn(name =3D "lug_type", referencedColumnName =3D "type"), + @JoinColumn(name =3D "lug_owner", referencedColumnName =3D "owner") + }) + public Set getHasInside() { + return hasInside; + } + + public void setHasInside(Set hasInside) { + this.hasInside =3D hasInside; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof Luggage ) ) return false; + + final Luggage luggage =3D (Luggage) o; + + if ( !owner.equals( luggage.owner ) ) return false; + if ( !type.equals( luggage.type ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D owner.hashCode(); + result =3D 29 * result + type.hashCode(); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/Postman.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Postman.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Postman.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,40 @@ +//$Id: Postman.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Postman implements Serializable { + private String name; + private String id; + + public Postman() { + } + + @Id + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } + + public Postman(String name, String id) { + this.name =3D name; + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/Rambler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Rambler.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Rambler.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,57 @@ +//$Id: Rambler.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Rambler implements Serializable { + private Integer id; + private String name; + private Set bags =3D new HashSet(); + + public Rambler() { + } + + public Rambler(String name) { + this.name =3D name; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @Column(name =3D "fld_name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @OneToMany(mappedBy =3D "owner", cascade =3D {CascadeType.PERSIST, Cascad= eType.MERGE}) + public Set getBags() { + return bags; + } + + public void setBags(Set bags) { + this.bags =3D bags; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/ReferencedColumnNameTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/ReferencedColumnNameTest.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/ReferencedColumnNameTest.java 2009-11-24 21:03= :15 UTC (rev 18049) @@ -0,0 +1,196 @@ +//$Id: ReferencedColumnNameTest.java 16289 2009-04-09 22:09:50Z gbadner $ +package org.hibernate.test.annotations.referencedcolumnname; + +import java.util.Iterator; +import java.math.BigDecimal; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class ReferencedColumnNameTest extends TestCase { + public void testManyToOne() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Postman pm =3D new Postman( "Bob", "A01" ); + House house =3D new House(); + house.setPostman( pm ); + house.setAddress( "Rue des pres" ); + s.persist( pm ); + s.persist( house ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + house =3D (House) s.get( House.class, house.getId() ); + assertNotNull( house.getPostman() ); + assertEquals( "Bob", house.getPostman().getName() ); + pm =3D house.getPostman(); + s.delete( house ); + s.delete( pm ); + tx.commit(); + s.close(); + } + + public void testOneToMany() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + + Rambler rambler =3D new Rambler( "Emmanuel" ); + Bag bag =3D new Bag( "0001", rambler ); + rambler.getBags().add( bag ); + s.persist( rambler ); + + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + + bag =3D (Bag) s.createQuery( "select b from Bag b left join fetch b.owne= r" ).uniqueResult(); + assertNotNull( bag ); + assertNotNull( bag.getOwner() ); + + rambler =3D (Rambler) s.createQuery( "select r from Rambler r left join = fetch r.bags" ).uniqueResult(); + assertNotNull( rambler ); + assertNotNull( rambler.getBags() ); + assertEquals( 1, rambler.getBags().size() ); + s.delete( rambler.getBags().iterator().next() ); + s.delete( rambler ); + + tx.commit(); + s.close(); + } + + public void testUnidirectionalOneToMany() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + + Clothes clothes =3D new Clothes( "underwear", "interesting" ); + Luggage luggage =3D new Luggage( "Emmanuel", "Cabin Luggage" ); + luggage.getHasInside().add( clothes ); + s.persist( luggage ); + + tx.commit(); + s.close(); + + s =3D openSession(); + tx =3D s.beginTransaction(); + + luggage =3D (Luggage) s.createQuery( "select l from Luggage l left join = fetch l.hasInside" ).uniqueResult(); + assertNotNull( luggage ); + assertNotNull( luggage.getHasInside() ); + assertEquals( 1, luggage.getHasInside().size() ); + + s.delete( luggage.getHasInside().iterator().next() ); + s.delete( luggage ); + + tx.commit(); + s.close(); + } + + public void testManyToMany() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + + House whiteHouse =3D new House(); + whiteHouse.setAddress( "1600 Pennsylvania Avenue, Washington" ); + Inhabitant bill =3D new Inhabitant(); + bill.setName( "Bill Clinton" ); + Inhabitant george =3D new Inhabitant(); + george.setName( "George W Bush" ); + s.persist( george ); + s.persist( bill ); + whiteHouse.getHasInhabitants().add( bill ); + whiteHouse.getHasInhabitants().add( george ); + //bill.getLivesIn().add( whiteHouse ); + //george.getLivesIn().add( whiteHouse ); + + s.persist( whiteHouse ); + tx.commit(); + s =3D openSession(); + tx =3D s.beginTransaction(); + + whiteHouse =3D (House) s.get( House.class, whiteHouse.getId() ); + assertNotNull( whiteHouse ); + assertEquals( 2, whiteHouse.getHasInhabitants().size() ); + + tx.commit(); + s.clear(); + tx =3D s.beginTransaction(); + bill =3D (Inhabitant) s.get( Inhabitant.class, bill.getId() ); + assertNotNull( bill ); + assertEquals( 1, bill.getLivesIn().size() ); + assertEquals( whiteHouse.getAddress(), bill.getLivesIn().iterator().next= ().getAddress() ); + + whiteHouse =3D bill.getLivesIn().iterator().next(); + s.delete( whiteHouse ); + Iterator it =3D whiteHouse.getHasInhabitants().iterator(); + while ( it.hasNext() ) { + s.delete( it.next() ); + } + tx.commit(); + s.close(); + } + + public void testManyToOneReferenceManyToOne() throws Exception { + Item item =3D new Item(); + item.setId( 1 ); + Vendor vendor =3D new Vendor(); + vendor.setId( 1 ); + ItemCost cost =3D new ItemCost(); + cost.setCost( new BigDecimal(1) ); + cost.setId( 1 ); + cost.setItem( item ); + cost.setVendor( vendor ); + WarehouseItem wItem =3D new WarehouseItem(); + wItem.setDefaultCost( cost ); + wItem.setId( 1 ); + wItem.setItem( item ); + wItem.setQtyInStock( new BigDecimal(1) ); + wItem.setVendor( vendor ); + Session s =3D openSession( ); + s.getTransaction().begin(); + s.persist( item ); + s.persist( vendor ); + s.persist( cost ); + s.persist( wItem ); + s.flush(); + s.clear(); + wItem =3D (WarehouseItem) s.get(WarehouseItem.class, wItem.getId() ); + assertNotNull( wItem.getDefaultCost().getItem() ); + s.getTransaction().rollback(); + s.close(); + } + + public ReferencedColumnNameTest(String x) { + super( x ); + } + + protected Class[] getMappings() { + return new Class[]{ + House.class, + Postman.class, + Bag.class, + Rambler.class, + Luggage.class, + Clothes.class, + Inhabitant.class, + Item.class, + ItemCost.class, + Vendor.class, + WarehouseItem.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/Vendor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Vendor.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/Vendor.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$Id: Vendor.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import javax.persistence.Id; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Vendor { + int id; + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/referencedcolumnname/WarehouseItem.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/WarehouseItem.java (re= v 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/referencedcolumnname/WarehouseItem.java 2009-11-24 21:03:15 UTC (re= v 18049) @@ -0,0 +1,71 @@ +//$Id: WarehouseItem.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.referencedcolumnname; + +import java.math.BigDecimal; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; +import javax.persistence.JoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class WarehouseItem { + + int id; + Item item; + Vendor vendor; + ItemCost defaultCost; + BigDecimal qtyInStock; + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id =3D id; + } + + public BigDecimal getQtyInStock() { + return qtyInStock; + } + + public void setQtyInStock(BigDecimal qtyInStock) { + this.qtyInStock =3D qtyInStock; + } + + @ManyToOne + public Item getItem() { + return item; + } + + public void setItem(Item item) { + this.item =3D item; + } + + @ManyToOne + public Vendor getVendor() { + return vendor; + } + + public void setVendor(Vendor vendor) { + this.vendor =3D vendor; + } + + @ManyToOne + @JoinColumns({ + @JoinColumn(name=3D"vendor_id", referencedColumnName=3D"vendor_id", = insertable=3Dfalse, updatable=3Dfalse), + @JoinColumn(name=3D"item_id", referencedColumnName=3D"item_id", inse= rtable=3Dfalse, updatable=3Dfalse) + }) + public ItemCost getDefaultCost() { + return defaultCost; + } + + public void setDefaultCost(ItemCost defaultCost) { + this.defaultCost =3D defaultCost; + } +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/Administration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/Administration.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/Administration.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,77 @@ +//$Id: Administration.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +import javax.persistence.Basic; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.OneToOne; +import javax.persistence.PostLoad; +import javax.persistence.SecondaryTable; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +(a)Entity(name =3D "JavaAdministration") +(a)Table(name =3D "JavaAdministration") +(a)SecondaryTable(name =3D "Extend") +public class Administration extends Organization { + @Id + private Integer id; + private String firstname; + private String lastname; + private String address; + private Integer version; + @Basic + private String transientField; + @OneToOne + @JoinColumns({@JoinColumn(name =3D "busNumber_fk"), @JoinColumn(name =3D = "busDriver_fk")}) + private BusTrip defaultBusTrip; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address =3D address; + } + + public Integer getVersion() { + return version; + } + + public void setVersion(Integer version) { + this.version =3D version; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname =3D firstname; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname =3D lastname; + } + + @PostLoad + public void calculate() { + //... + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/Availability.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/Availability.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/Availability.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,10 @@ +//$Id: Availability.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +/** + * @author Emmanuel Bernard + */ +public enum Availability { + ON_DUTY, + NO_SERVICE +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/BusTrip.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/BusTrip.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/BusTrip.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,54 @@ +//$Id: BusTrip.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class BusTrip { + private BusTripPk id; + private Availability status; + private byte[] serial; + private Date terminusTime; + private Map players; + private List roads; + + @EmbeddedId + public BusTripPk getId() { + return id; + } + + public void setId(BusTripPk id) { + this.id =3D id; + } + + public Availability getStatus() { + return status; + } + + public void setStatus(Availability status) { + this.status =3D status; + } + + public byte[] getSerial() { + return serial; + } + + public void setSerial(byte[] serial) { + this.serial =3D serial; + } + + public Date getTerminusTime() { + return terminusTime; + } + + public void setTerminusTime(Date terminusTime) { + this.terminusTime =3D terminusTime; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/BusTripPk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/BusTripPk.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/BusTripPk.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +//$Id: BusTripPk.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +/** + * @author Emmanuel Bernard + */ +public class BusTripPk { + private String busNumber; + private String busDriver; + + public String getBusDriver() { + return busDriver; + } + + public void setBusDriver(String busDriver) { + this.busDriver =3D busDriver; + } + + public String getBusNumber() { + return busNumber; + } + + public void setBusNumber(String busNumber) { + this.busNumber =3D busNumber; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/Competition.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/Competition.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/Competition.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ +//$Id: Competition.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +import javax.persistence.MappedSuperclass; + +/** + * @author Emmanuel Bernard + */ +(a)MappedSuperclass +public class Competition { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/EJB3OverridenAnnotationReaderTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/EJB3OverridenAnnotationReaderTest.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/EJB3OverridenAnnotationReaderTest.java 2009-11-24 21:03:= 15 UTC (rev 18049) @@ -0,0 +1,434 @@ +//$Id: EJB3OverridenAnnotationReaderTest.java 14736 2008-06-04 14:23:42Z h= ardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import javax.persistence.AssociationOverrides; +import javax.persistence.AttributeOverrides; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Embedded; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.ExcludeDefaultListeners; +import javax.persistence.ExcludeSuperclassListeners; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.JoinColumns; +import javax.persistence.JoinTable; +import javax.persistence.Lob; +import javax.persistence.ManyToMany; +import javax.persistence.MapKey; +import javax.persistence.MappedSuperclass; +import javax.persistence.NamedNativeQueries; +import javax.persistence.NamedQueries; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.OrderBy; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.PrimaryKeyJoinColumns; +import javax.persistence.SecondaryTable; +import javax.persistence.SecondaryTables; +import javax.persistence.SequenceGenerator; +import javax.persistence.SqlResultSetMappings; +import javax.persistence.Table; +import javax.persistence.TableGenerator; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import javax.persistence.Version; +import javax.persistence.PrePersist; +import javax.persistence.EntityListeners; +import javax.persistence.PostLoad; +import javax.persistence.PostPersist; + +import junit.framework.TestCase; +import org.dom4j.DocumentException; +import org.dom4j.io.SAXReader; +import org.hibernate.annotations.Columns; +import org.hibernate.cfg.EJB3DTDEntityResolver; +import org.hibernate.cfg.annotations.reflection.EJB3OverridenAnnotationRea= der; +import org.hibernate.cfg.annotations.reflection.XMLContext; +import org.hibernate.util.XMLHelper; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotSupportedException; + + +/** + * @author Emmanuel Bernard + */ +public class EJB3OverridenAnnotationReaderTest extends TestCase { + public void testMappedSuperclassAnnotations() throws Exception { + XMLContext context =3D buildContext( + "org/hibernate/test/annotations/reflection/metadata-complete.xml" ); + EJB3OverridenAnnotationReader reader =3D new EJB3OverridenAnnotationRead= er( Organization.class, context ); + assertTrue( reader.isAnnotationPresent( MappedSuperclass.class ) ); + } + + public void testEntityRelatedAnnotations() throws Exception { + XMLContext context =3D buildContext( "org/hibernate/test/annotations/ref= lection/orm.xml" ); + EJB3OverridenAnnotationReader reader =3D new EJB3OverridenAnnotationRead= er( Administration.class, context ); + assertNotNull( reader.getAnnotation( Entity.class ) ); + assertEquals( + "Default value in xml entity should not override @Entity.name", "JavaA= dministration", + reader.getAnnotation( Entity.class ).name() + ); + assertNotNull( reader.getAnnotation( Table.class ) ); + assertEquals( "@Table not overriden", "tbl_admin", reader.getAnnotation(= Table.class ).name() ); + assertEquals( "Default schema not overriden", "myschema", reader.getAnno= tation( Table.class ).schema() ); + assertEquals( + "Proper @Table.uniqueConstraints", 2, + reader.getAnnotation( Table.class ).uniqueConstraints()[0].columnNames= ().length + ); + String columnName =3D reader.getAnnotation( Table.class ).uniqueConstrai= nts()[0].columnNames()[0]; + assertTrue( + "Proper @Table.uniqueConstraints", "firstname".equals( columnName ) ||= "lastname".equals( columnName ) + ); + assertNull( "Both Java and XML used", reader.getAnnotation( SecondaryTab= le.class ) ); + assertNotNull( "XML does not work", reader.getAnnotation( SecondaryTable= s.class ) ); + SecondaryTable[] tables =3D reader.getAnnotation( SecondaryTables.class = ).value(); + assertEquals( 1, tables.length ); + assertEquals( "admin2", tables[0].name() ); + assertEquals( "unique constraints ignored", 1, tables[0].uniqueConstrain= ts().length ); + assertEquals( "pk join column ignored", 1, tables[0].pkJoinColumns().len= gth ); + assertEquals( "pk join column ignored", "admin_id", tables[0].pkJoinColu= mns()[0].name() ); + assertNotNull( "Sequence Overriding not working", reader.getAnnotation( = SequenceGenerator.class ) ); + assertEquals( + "wrong sequence name", "seqhilo", reader.getAnnotation( SequenceGenera= tor.class ).sequenceName() + ); + assertEquals( "default fails", 50, reader.getAnnotation( SequenceGenerat= or.class ).allocationSize() ); + assertNotNull( "TableOverriding not working", reader.getAnnotation( Tabl= eGenerator.class ) ); + assertEquals( "wrong tble name", "tablehilo", reader.getAnnotation( Tabl= eGenerator.class ).table() ); + assertEquals( "no schema overriding", "myschema", reader.getAnnotation( = TableGenerator.class ).schema() ); + + reader =3D new EJB3OverridenAnnotationReader( Match.class, context ); + assertNotNull( reader.getAnnotation( Table.class ) ); + assertEquals( + "Java annotation not taken into account", "matchtable", reader.getAnno= tation( Table.class ).name() + ); + assertEquals( + "Java annotation not taken into account", "matchschema", reader.getAnn= otation( Table.class ).schema() + ); + assertEquals( "Overriding not taken into account", "mycatalog", reader.g= etAnnotation( Table.class ).catalog() ); + assertNotNull( "SecondaryTable swallowed", reader.getAnnotation( Seconda= ryTables.class ) ); + assertEquals( + "Default schema not taken into account", "myschema", + reader.getAnnotation( SecondaryTables.class ).value()[0].schema() + ); + assertNotNull( reader.getAnnotation( Inheritance.class ) ); + assertEquals( + "inheritance strategy not overriden", InheritanceType.JOINED, + reader.getAnnotation( Inheritance.class ).strategy() + ); + assertNotNull( "NamedQuery not overriden", reader.getAnnotation( NamedQu= eries.class ) ); + assertEquals( "No deduplication", 3, reader.getAnnotation( NamedQueries.= class ).value().length ); + assertEquals( + "deduplication kept the Java version", 1, + reader.getAnnotation( NamedQueries.class ).value()[1].hints().length + ); + assertEquals( + "org.hibernate.timeout", reader.getAnnotation( NamedQueries.class ).va= lue()[1].hints()[0].name() + ); + assertNotNull( "NamedNativeQuery not overriden", reader.getAnnotation( N= amedNativeQueries.class ) ); + assertEquals( "No deduplication", 3, reader.getAnnotation( NamedNativeQu= eries.class ).value().length ); + assertEquals( + "deduplication kept the Java version", 1, + reader.getAnnotation( NamedNativeQueries.class ).value()[1].hints().le= ngth + ); + assertEquals( + "org.hibernate.timeout", reader.getAnnotation( NamedNativeQueries.clas= s ).value()[1].hints()[0].name() + ); + assertNotNull( reader.getAnnotation( SqlResultSetMappings.class ) ); + assertEquals( + "competitor1Point", reader.getAnnotation( SqlResultSetMappings.class )= .value()[0].columns()[0].name() + ); + assertEquals( + "competitor1Point", + reader.getAnnotation( SqlResultSetMappings.class ).value()[0].entities= ()[0].fields()[0].column() + ); + assertNotNull( reader.getAnnotation( ExcludeSuperclassListeners.class ) = ); + assertNotNull( reader.getAnnotation( ExcludeDefaultListeners.class ) ); + + reader =3D new EJB3OverridenAnnotationReader( Competition.class, context= ); + assertNotNull( reader.getAnnotation( MappedSuperclass.class ) ); + + reader =3D new EJB3OverridenAnnotationReader( TennisMatch.class, context= ); + assertNull( "Mutualize PKJC into PKJCs", reader.getAnnotation( PrimaryKe= yJoinColumn.class ) ); + assertNotNull( reader.getAnnotation( PrimaryKeyJoinColumns.class ) ); + assertEquals( + "PrimaryKeyJoinColumn overrden", "id", + reader.getAnnotation( PrimaryKeyJoinColumns.class ).value()[0].name() + ); + assertNotNull( reader.getAnnotation( AttributeOverrides.class ) ); + assertEquals( "Wrong deduplication", 3, reader.getAnnotation( AttributeO= verrides.class ).value().length ); + assertEquals( + "Wrong priority (XML vs java annotations)", "fld_net", + reader.getAnnotation( AttributeOverrides.class ).value()[0].column().n= ame() + ); + assertEquals( + "Column mapping", 2, reader.getAnnotation( AttributeOverrides.class ).= value()[1].column().scale() + ); + assertEquals( + "Column mapping", true, reader.getAnnotation( AttributeOverrides.class= ).value()[1].column().unique() + ); + assertNotNull( reader.getAnnotation( AssociationOverrides.class ) ); + assertEquals( "no XML processing", 1, reader.getAnnotation( AssociationO= verrides.class ).value().length ); + assertEquals( + "wrong xml processing", "id", + reader.getAnnotation( AssociationOverrides.class ).value()[0].joinColu= mns()[0].referencedColumnName() + ); + + + reader =3D new EJB3OverridenAnnotationReader( SocialSecurityPhysicalAcco= unt.class, context ); + assertNotNull( reader.getAnnotation( IdClass.class ) ); + assertEquals( "id-class not used", SocialSecurityNumber.class, reader.ge= tAnnotation( IdClass.class ).value() ); + assertEquals( + "discriminator-value not used", "Physical", reader.getAnnotation( Disc= riminatorValue.class ).value() + ); + assertNotNull( "discriminator-column not used", reader.getAnnotation( Di= scriminatorColumn.class ) ); + assertEquals( + "discriminator-column.name default value broken", "DTYPE", + reader.getAnnotation( DiscriminatorColumn.class ).name() + ); + assertEquals( + "discriminator-column.length broken", 34, reader.getAnnotation( Discri= minatorColumn.class ).length() + ); + } + + public void testEntityRelatedAnnotationsMetadataComplete() throws Excepti= on { + XMLContext context =3D buildContext( + "org/hibernate/test/annotations/reflection/metadata-complete.xml" ); + EJB3OverridenAnnotationReader reader =3D new EJB3OverridenAnnotationRead= er( Administration.class, context ); + assertNotNull( reader.getAnnotation( Entity.class ) ); + assertEquals( + "Metadata complete should ignore java annotations", "", reader.getAnno= tation( Entity.class ).name() + ); + assertNotNull( reader.getAnnotation( Table.class ) ); + assertEquals( "@Table should not be used", "", reader.getAnnotation( Tab= le.class ).name() ); + assertEquals( "Default schema not overriden", "myschema", reader.getAnno= tation( Table.class ).schema() ); + + reader =3D new EJB3OverridenAnnotationReader( Match.class, context ); + assertNotNull( reader.getAnnotation( Table.class ) ); + assertEquals( "@Table should not be used", "", reader.getAnnotation( Tab= le.class ).name() ); + assertEquals( "Overriding not taken into account", "myschema", reader.ge= tAnnotation( Table.class ).schema() ); + assertEquals( "Overriding not taken into account", "mycatalog", reader.g= etAnnotation( Table.class ).catalog() ); + assertNull( "Ignore Java annotation", reader.getAnnotation( SecondaryTab= le.class ) ); + assertNull( "Ignore Java annotation", reader.getAnnotation( SecondaryTab= les.class ) ); + assertNull( "Ignore Java annotation", reader.getAnnotation( Inheritance.= class ) ); + assertNull( reader.getAnnotation( NamedQueries.class ) ); + assertNull( reader.getAnnotation( NamedNativeQueries.class ) ); + + reader =3D new EJB3OverridenAnnotationReader( TennisMatch.class, context= ); + assertNull( reader.getAnnotation( PrimaryKeyJoinColumn.class ) ); + assertNull( reader.getAnnotation( PrimaryKeyJoinColumns.class ) ); + + reader =3D new EJB3OverridenAnnotationReader( Competition.class, context= ); + assertNull( reader.getAnnotation( MappedSuperclass.class ) ); + + reader =3D new EJB3OverridenAnnotationReader( SocialSecurityMoralAccount= .class, context ); + assertNull( reader.getAnnotation( IdClass.class ) ); + assertNull( reader.getAnnotation( DiscriminatorValue.class ) ); + assertNull( reader.getAnnotation( DiscriminatorColumn.class ) ); + assertNull( reader.getAnnotation( SequenceGenerator.class ) ); + assertNull( reader.getAnnotation( TableGenerator.class ) ); + } + + public void testIdRelatedAnnotations() throws Exception { + XMLContext context =3D buildContext( "org/hibernate/test/annotations/ref= lection/orm.xml" ); + Method method =3D Administration.class.getDeclaredMethod( "getId" ); + EJB3OverridenAnnotationReader reader =3D new EJB3OverridenAnnotationRead= er( method, context ); + assertNull( reader.getAnnotation( Id.class ) ); + assertNull( reader.getAnnotation( Column.class ) ); + Field field =3D Administration.class.getDeclaredField( "id" ); + reader =3D new EJB3OverridenAnnotationReader( field, context ); + assertNotNull( reader.getAnnotation( Id.class ) ); + assertNotNull( reader.getAnnotation( GeneratedValue.class ) ); + assertEquals( GenerationType.SEQUENCE, reader.getAnnotation( GeneratedVa= lue.class ).strategy() ); + assertEquals( "generator", reader.getAnnotation( GeneratedValue.class ).= generator() ); + assertNotNull( reader.getAnnotation( SequenceGenerator.class ) ); + assertEquals( "seq", reader.getAnnotation( SequenceGenerator.class ).seq= uenceName() ); + assertNotNull( reader.getAnnotation( Columns.class ) ); + assertEquals( 1, reader.getAnnotation( Columns.class ).columns().length = ); + assertEquals( "fld_id", reader.getAnnotation( Columns.class ).columns()[= 0].name() ); + assertNotNull( reader.getAnnotation( Temporal.class ) ); + assertEquals( TemporalType.DATE, reader.getAnnotation( Temporal.class ).= value() ); + + context =3D buildContext( + "org/hibernate/test/annotations/reflection/metadata-complete.xml" ); + method =3D Administration.class.getDeclaredMethod( "getId" ); + reader =3D new EJB3OverridenAnnotationReader( method, context ); + assertNotNull( + "Default access type when not defined in metadata complete should be p= roperty", + reader.getAnnotation( Id.class ) + ); + field =3D Administration.class.getDeclaredField( "id" ); + reader =3D new EJB3OverridenAnnotationReader( field, context ); + assertNull( + "Default access type when not defined in metadata complete should be p= roperty", + reader.getAnnotation( Id.class ) + ); + + method =3D BusTrip.class.getDeclaredMethod( "getId" ); + reader =3D new EJB3OverridenAnnotationReader( method, context ); + assertNull( reader.getAnnotation( EmbeddedId.class ) ); + field =3D BusTrip.class.getDeclaredField( "id" ); + reader =3D new EJB3OverridenAnnotationReader( field, context ); + assertNotNull( reader.getAnnotation( EmbeddedId.class ) ); + assertNotNull( reader.getAnnotation( AttributeOverrides.class ) ); + assertEquals( 1, reader.getAnnotation( AttributeOverrides.class ).value(= ).length ); + } + + public void testBasicRelatedAnnotations() throws Exception { + XMLContext context =3D buildContext( + "org/hibernate/test/annotations/reflection/metadata-complete.xml" ); + Field field =3D BusTrip.class.getDeclaredField( "status" ); + EJB3OverridenAnnotationReader reader =3D new EJB3OverridenAnnotationRead= er( field, context ); + assertNotNull( reader.getAnnotation( Enumerated.class ) ); + assertEquals( EnumType.STRING, reader.getAnnotation( Enumerated.class ).= value() ); + assertEquals( false, reader.getAnnotation( Basic.class ).optional() ); + field =3D BusTrip.class.getDeclaredField( "serial" ); + reader =3D new EJB3OverridenAnnotationReader( field, context ); + assertNotNull( reader.getAnnotation( Lob.class ) ); + assertEquals( "serialbytes", reader.getAnnotation( Columns.class ).colum= ns()[0].name() ); + field =3D BusTrip.class.getDeclaredField( "terminusTime" ); + reader =3D new EJB3OverridenAnnotationReader( field, context ); + assertNotNull( reader.getAnnotation( Temporal.class ) ); + assertEquals( TemporalType.TIMESTAMP, reader.getAnnotation( Temporal.cla= ss ).value() ); + assertEquals( FetchType.LAZY, reader.getAnnotation( Basic.class ).fetch(= ) ); + + field =3D BusTripPk.class.getDeclaredField( "busDriver" ); + reader =3D new EJB3OverridenAnnotationReader( field, context ); + assertNotNull( reader.isAnnotationPresent( Basic.class ) ); + } + + public void testVersionRelatedAnnotations() throws Exception { + XMLContext context =3D buildContext( "org/hibernate/test/annotations/ref= lection/orm.xml" ); + Method method =3D Administration.class.getDeclaredMethod( "getVersion" ); + EJB3OverridenAnnotationReader reader =3D new EJB3OverridenAnnotationRead= er( method, context ); + assertNotNull( reader.getAnnotation( Version.class ) ); + + Field field =3D Match.class.getDeclaredField( "version" ); + reader =3D new EJB3OverridenAnnotationReader( field, context ); + assertNotNull( reader.getAnnotation( Version.class ) ); + } + + public void testTransientAndEmbeddedRelatedAnnotations() throws Exception= { + XMLContext context =3D buildContext( "org/hibernate/test/annotations/ref= lection/orm.xml" ); + + Field field =3D Administration.class.getDeclaredField( "transientField" = ); + EJB3OverridenAnnotationReader reader =3D new EJB3OverridenAnnotationRead= er( field, context ); + assertNotNull( reader.getAnnotation( Transient.class ) ); + assertNull( reader.getAnnotation( Basic.class ) ); + + field =3D Match.class.getDeclaredField( "playerASSN" ); + reader =3D new EJB3OverridenAnnotationReader( field, context ); + assertNotNull( reader.getAnnotation( Embedded.class ) ); + } + + public void testAssociationRelatedAnnotations() throws Exception { + XMLContext context =3D buildContext( "org/hibernate/test/annotations/ref= lection/orm.xml" ); + + Field field =3D Administration.class.getDeclaredField( "defaultBusTrip" = ); + EJB3OverridenAnnotationReader reader =3D new EJB3OverridenAnnotationRead= er( field, context ); + assertNotNull( reader.getAnnotation( OneToOne.class ) ); + assertNull( reader.getAnnotation( JoinColumns.class ) ); + assertNotNull( reader.getAnnotation( PrimaryKeyJoinColumns.class ) ); + assertEquals( "pk", reader.getAnnotation( PrimaryKeyJoinColumns.class ).= value()[0].name() ); + assertEquals( 5, reader.getAnnotation( OneToOne.class ).cascade().length= ); + assertEquals( FetchType.LAZY, reader.getAnnotation( OneToOne.class ).fet= ch() ); + assertEquals( "test", reader.getAnnotation( OneToOne.class ).mappedBy() = ); + + context =3D buildContext( + "org/hibernate/test/annotations/reflection/metadata-complete.xml" ); + field =3D BusTrip.class.getDeclaredField( "players" ); + reader =3D new EJB3OverridenAnnotationReader( field, context ); + assertNotNull( reader.getAnnotation( OneToMany.class ) ); + assertNotNull( reader.getAnnotation( JoinColumns.class ) ); + assertEquals( 2, reader.getAnnotation( JoinColumns.class ).value().lengt= h ); + assertEquals( "driver", reader.getAnnotation( JoinColumns.class ).value(= )[0].name() ); + assertNotNull( reader.getAnnotation( MapKey.class ) ); + assertEquals( "name", reader.getAnnotation( MapKey.class ).name() ); + + field =3D BusTrip.class.getDeclaredField( "roads" ); + reader =3D new EJB3OverridenAnnotationReader( field, context ); + assertNotNull( reader.getAnnotation( ManyToMany.class ) ); + assertNotNull( reader.getAnnotation( JoinTable.class ) ); + assertEquals( "bus_road", reader.getAnnotation( JoinTable.class ).name()= ); + assertEquals( 2, reader.getAnnotation( JoinTable.class ).joinColumns().l= ength ); + assertEquals( 1, reader.getAnnotation( JoinTable.class ).inverseJoinColu= mns().length ); + assertEquals( 2, reader.getAnnotation( JoinTable.class ).uniqueConstrain= ts()[0].columnNames().length ); + assertNotNull( reader.getAnnotation( OrderBy.class ) ); + assertEquals( "maxSpeed", reader.getAnnotation( OrderBy.class ).value() = ); + } + + public void testEntityListeners() throws Exception { + XMLContext context =3D buildContext( "org/hibernate/test/annotations/ref= lection/orm.xml" ); + + Method method =3D Administration.class.getDeclaredMethod( "calculate" ); + EJB3OverridenAnnotationReader reader =3D new EJB3OverridenAnnotationRead= er( method, context ); + assertTrue( reader.isAnnotationPresent( PrePersist.class ) ); + + reader =3D new EJB3OverridenAnnotationReader( Administration.class, cont= ext ); + assertTrue( reader.isAnnotationPresent( EntityListeners.class ) ); + assertEquals( 1, reader.getAnnotation( EntityListeners.class ).value().l= ength ); + assertEquals( LogListener.class, reader.getAnnotation( EntityListeners.c= lass ).value()[0] ); + + method =3D LogListener.class.getDeclaredMethod( "noLog", Object.class ); + reader =3D new EJB3OverridenAnnotationReader( method, context ); + assertTrue( reader.isAnnotationPresent( PostLoad.class ) ); + + method =3D LogListener.class.getDeclaredMethod( "log", Object.class ); + reader =3D new EJB3OverridenAnnotationReader( method, context ); + assertTrue( reader.isAnnotationPresent( PrePersist.class ) ); + assertFalse( reader.isAnnotationPresent( PostPersist.class ) ); + + assertEquals( 1, context.getDefaultEntityListeners().size() ); + assertEquals( OtherLogListener.class.getName(), context.getDefaultEntity= Listeners().get(0) ); + } + + private XMLContext buildContext(String ormfile) throws SAXException, Docu= mentException, IOException { + XMLHelper xmlHelper =3D new XMLHelper(); + ClassLoader cl =3D Thread.currentThread().getContextClassLoader(); + InputStream is =3D cl.getResourceAsStream( ormfile ); + assertNotNull( "ORM.xml not found: " + ormfile, is ); + XMLContext context =3D new XMLContext(); + List errors =3D new ArrayList(); + SAXReader saxReader =3D xmlHelper.createSAXReader( "XML InputStream", er= rors, EJB3DTDEntityResolver.INSTANCE ); + //saxReader.setValidation( false ); + try { + saxReader.setFeature( "http://apache.org/xml/features/validation/schema= ", true ); + } + catch (SAXNotSupportedException e) { + saxReader.setValidation( false ); + } + org.dom4j.Document doc; + try { + doc =3D saxReader + .read( new InputSource( new BufferedInputStream( is ) ) ); + } + finally { + is.close(); + } + if (errors.size() > 0) { + System.out.println( errors.get( 0 ) ); + } + assertEquals( 0, errors.size() ); + context.addDocument( doc ); + return context; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/LogListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/LogListener.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/LogListener.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: LogListener.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +import javax.persistence.PrePersist; +import javax.persistence.PostPersist; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author Emmanuel Bernard + */ +public class LogListener { + private final Logger log =3D LoggerFactory.getLogger( LogListener.class ); + + @PrePersist + @PostPersist + public void log(Object entity) { + log.debug( "Logging entity {} with hashCode: {}", entity.getClass().getN= ame(), entity.hashCode() ); + } + + + public void noLog(Object entity) { + log.debug( "NoLogging entity {} with hashCode: {}", entity.getClass().ge= tName(), entity.hashCode() ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/Match.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/Match.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/Match.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: Match.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.NamedNativeQueries; +import javax.persistence.NamedNativeQuery; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.SecondaryTable; +import javax.persistence.Table; +import javax.persistence.Version; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(name =3D "matchtable", schema =3D "matchschema") +(a)SecondaryTable(name =3D "extendedMatch") +(a)Inheritance(strategy =3D InheritanceType.TABLE_PER_CLASS) +(a)NamedQueries({ +(a)NamedQuery(name =3D "matchbyid", query =3D "select m from Match m where= m.id =3D :id"), +(a)NamedQuery(name =3D "getAllMatches2", query =3D "select m from Match m") + }) +(a)NamedNativeQueries({ +(a)NamedNativeQuery(name =3D "matchbyid", query =3D "select m from Match m= where m.id =3D :id", resultSetMapping =3D "matchrs"), +(a)NamedNativeQuery(name =3D "getAllMatches2", query =3D "select m from Ma= tch m", resultSetMapping =3D "matchrs") + }) +public class Match extends Competition { + public String competitor1Point; + @Version + public Integer version; + public SocialSecurityNumber playerASSN; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/Organization.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/Organization.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/Organization.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,17 @@ +//$Id: Organization.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +/** + * @author Emmanuel Bernard + */ +public class Organization { + private String organizationId; + + public String getOrganizationId() { + return organizationId; + } + + public void setOrganizationId(String organizationId) { + this.organizationId =3D organizationId; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/OtherLogListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/OtherLogListener.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/OtherLogListener.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,27 @@ +//$Id: OtherLogListener.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +import javax.persistence.PrePersist; +import javax.persistence.PostPersist; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author Emmanuel Bernard + */ +public class OtherLogListener { + private final Logger log =3D LoggerFactory.getLogger( OtherLogListener.cl= ass ); + + @PrePersist + @PostPersist + public void log(Object entity) { + log.debug( "Logging entity {} with hashCode: {}", entity.getClass().getN= ame(), entity.hashCode() ); + } + + + public void noLog(Object entity) { + log.debug( "NoLogging entity {} with hashCode: {}", entity.getClass().ge= tName(), entity.hashCode() ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/SocialSecurityMoralAccount.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/SocialSecurityMoralAccount.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/SocialSecurityMoralAccount.java 2009-11-24 21:03:15 UTC = (rev 18049) @@ -0,0 +1,21 @@ +//$Id: SocialSecurityMoralAccount.java 14736 2008-06-04 14:23:42Z hardy.fe= rentschik $ +package org.hibernate.test.annotations.reflection; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.IdClass; +import javax.persistence.SequenceGenerator; +import javax.persistence.TableGenerator; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)IdClass(SocialSecurityNumber.class) +(a)DiscriminatorValue("Moral") +(a)SequenceGenerator(name =3D "seq") +(a)TableGenerator(name =3D "table") +public class SocialSecurityMoralAccount { + public String number; + public String countryCode; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/SocialSecurityNumber.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/SocialSecurityNumber.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/SocialSecurityNumber.java 2009-11-24 21:03:15 UTC (rev 1= 8049) @@ -0,0 +1,33 @@ +//$Id: SocialSecurityNumber.java 14736 2008-06-04 14:23:42Z hardy.ferentsc= hik $ +package org.hibernate.test.annotations.reflection; + +import java.io.Serializable; +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class SocialSecurityNumber implements Serializable { + public String number; + public String countryCode; + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final SocialSecurityNumber that =3D (SocialSecurityNumber) o; + + if ( !countryCode.equals( that.countryCode ) ) return false; + if ( !number.equals( that.number ) ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D number.hashCode(); + result =3D 29 * result + countryCode.hashCode(); + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/SocialSecurityPhysicalAccount.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/SocialSecurityPhysicalAccount.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/SocialSecurityPhysicalAccount.java 2009-11-24 21:03:15 U= TC (rev 18049) @@ -0,0 +1,13 @@ +//$Id: SocialSecurityPhysicalAccount.java 14736 2008-06-04 14:23:42Z hardy= .ferentschik $ +package org.hibernate.test.annotations.reflection; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class SocialSecurityPhysicalAccount { + public String number; + public String countryCode; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/TennisMatch.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/TennisMatch.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/TennisMatch.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,21 @@ +//$Id: TennisMatch.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)PrimaryKeyJoinColumn(name =3D "match_id") +(a)AttributeOverrides( + {@AttributeOverride(name =3D "net", column =3D @Column(name =3D "net")), + @AttributeOverride(name =3D "line", column =3D @Column(name =3D "line")) + }) +public class TennisMatch { + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/XMLContextTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/XMLContextTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/XMLContextTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,54 @@ +//$Id: XMLContextTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.reflection; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import junit.framework.TestCase; +import org.dom4j.io.SAXReader; +import org.hibernate.cfg.EJB3DTDEntityResolver; +import org.hibernate.cfg.annotations.reflection.XMLContext; +import org.hibernate.util.XMLHelper; +import org.xml.sax.InputSource; +import org.xml.sax.SAXNotSupportedException; + +/** + * @author Emmanuel Bernard + */ +public class XMLContextTest extends TestCase { + public void testAll() throws Exception { + XMLHelper xmlHelper =3D new XMLHelper(); + ClassLoader cl =3D Thread.currentThread().getContextClassLoader(); + InputStream is =3D cl.getResourceAsStream( + "org/hibernate/test/annotations/reflection/orm.xml" ); + assertNotNull( "ORM.xml not found", is ); + XMLContext context =3D new XMLContext(); + List errors =3D new ArrayList(); + SAXReader saxReader =3D xmlHelper.createSAXReader( "XML InputStream", er= rors, EJB3DTDEntityResolver.INSTANCE ); + //saxReader.setValidation( false ); + try { + saxReader.setFeature( "http://apache.org/xml/features/validation/schema= ", true ); + } + catch (SAXNotSupportedException e) { + saxReader.setValidation( false ); + } + org.dom4j.Document doc; + try { + doc =3D saxReader + .read( new InputSource( new BufferedInputStream( is ) ) ); + } + finally { + try { + is.close(); + } + catch (IOException ioe) { + //log.warn( "Could not close input stream", ioe ); + } + } + assertEquals( 0, errors.size() ); + context.addDocument( doc ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/metadata-complete.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/metadata-complete.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/metadata-complete.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,76 @@ + + + + + + + myschema + mycatalog + + + + org.hibernate.test.annotations.reflection + + + + + + + + + + + + + + + + + + + + + + STRING + + + + + + + TIMESTAMP + + + + + + + + maxSpeed + + + + + + driver + number + + + + + + + + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/reflection/orm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/orm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/reflection/orm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,117 @@ + + + + + + myschema + mycatalog + + + + + + + + + org.hibernate.test.annotations.reflection + + + + firstname + lastname + +
+ + + + address + + + + + + + + + + + + + + + + DATE + + + + + + + + + + + + + + + +
+ + + + select m from Match m + + + + select m from Match m where m.id =3D :id + + + + select m from Match m + + + + select m from Match m where m.id =3D :id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Physical + + +
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/strategy/Location.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/strategy/Location.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/strategy/Location.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +//$Id: Location.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.strategy; + +/** + * @author Emmanuel Bernard + */ +public class Location { + private String city; + private String country; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city =3D city; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country =3D country; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/strategy/Storm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/strategy/Storm.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/strategy/Storm.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,62 @@ +//$Id: Storm.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.strategy; + +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.UniqueConstraint; +import javax.persistence.Table; + +import org.hibernate.annotations.Index; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table(uniqueConstraints =3D {@UniqueConstraint(columnNames =3D {"start.= country", "start.city"})}) +public class Storm { + private Integer id; + private Location start; + private Location end; + private String stormName; + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @Embedded + public Location getStart() { + return start; + } + + public void setStart(Location start) { + this.start =3D start; + } + + @Embedded + public Location getEnd() { + return end; + } + + public void setEnd(Location end) { + this.end =3D end; + } + + @Index(name=3D"storm_name_idx") + @Column(unique =3D true) + public String getStormName() { + return stormName; + } + + public void setStormName(String name) { + this.stormName =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/strategy/StrategyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/strategy/StrategyTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/strategy/StrategyTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,44 @@ +//$Id: StrategyTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.strategy; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.DefaultComponentSafeNamingStrategy; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class StrategyTest extends TestCase { + + public void testComponentSafeStrategy() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Location start =3D new Location(); + start.setCity( "Paris" ); + start.setCountry( "France" ); + Location end =3D new Location(); + end.setCity( "London" ); + end.setCountry( "UK" ); + Storm storm =3D new Storm(); + storm.setEnd( end ); + storm.setStart( start ); + s.persist( storm ); + s.flush(); + tx.rollback(); + s.close(); + } + + protected void configure(Configuration cfg) { + cfg.setNamingStrategy( DefaultComponentSafeNamingStrategy.INSTANCE ); + //cfg.getSessionEventListenerConfig().setFlushEventListener( new EJB3Flu= shEventListener() ); + //cfg.getSessionEventListenerConfig().setAutoFlushEventListener( new EJB= 3AutoFlushEventListener() ); + } + + protected Class[] getMappings() { + return new Class[]{ + Storm.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tableperclass/Component.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/Component.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/Component.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,53 @@ +//$Id: Component.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.tableperclass; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +import org.hibernate.annotations.Index; + +/** + * @author Emmanuel Bernard + */ +(a)Entity(name =3D "xpmComponent") +(a)Inheritance(strategy =3D InheritanceType.TABLE_PER_CLASS) +public abstract class Component { + private String manufacturerPartNumber; + private Long manufacturerId; + private Long id; + + + + public void setId(Long id) { + this.id =3D id; + } + + + @Id + public Long getId() { + return id; + } + + @Column(nullable =3D false) + @Index(name =3D "manufacturerPartNumber") + public String getManufacturerPartNumber() { + return manufacturerPartNumber; + } + + @Column(nullable =3D false) + public Long getManufacturerId() { + return manufacturerId; + } + + public void setManufacturerId(Long manufacturerId) { + this.manufacturerId =3D manufacturerId; + } + + + public void setManufacturerPartNumber(String manufacturerPartNumber) { + this.manufacturerPartNumber =3D manufacturerPartNumber; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tableperclass/Machine.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/Machine.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/Machine.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,37 @@ +//$Id: Machine.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.tableperclass; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.TABLE_PER_CLASS) +public class Machine { + private Integer id; + private Double weight; + + @Id + @GeneratedValue(strategy =3D GenerationType.TABLE) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Double getWeight() { + return weight; + } + + public void setWeight(Double weight) { + this.weight =3D weight; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tableperclass/Product.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/Product.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/Product.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,15 @@ +//$Id: Product.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.tableperclass; + +import javax.persistence.Entity; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Table( name =3D "xPM_Product", uniqueConstraints =3D {@UniqueConstraint= ( columnNames =3D { + "manufacturerPartNumber", "manufacturerId"} )} ) +public class Product extends Component { +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tableperclass/Robot.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/Robot.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/Robot.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,20 @@ +//$Id: Robot.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.tableperclass; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Robot extends Machine { + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tableperclass/T800.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/T800.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/T800.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,20 @@ +//$Id: T800.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.tableperclass; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class T800 extends Robot { + public String getTargetName() { + return targetName; + } + + public void setTargetName(String targetName) { + this.targetName =3D targetName; + } + + private String targetName; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tableperclass/TablePerClassTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/TablePerClassTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tableperclass/TablePerClassTest.java 2009-11-24 21:03:15 UTC (rev 1= 8049) @@ -0,0 +1,90 @@ +//$Id: TablePerClassTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.test.annotations.tableperclass; + +import java.util.List; +import java.sql.SQLException; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.JDBCException; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class TablePerClassTest extends TestCase { + public void testUnionSubClass() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Machine computer =3D new Machine(); + computer.setWeight( new Double( 4 ) ); + Robot asimov =3D new Robot(); + asimov.setWeight( new Double( 120 ) ); + asimov.setName( "Asimov" ); + T800 terminator =3D new T800(); + terminator.setName( "Terminator" ); + terminator.setWeight( new Double( 300 ) ); + terminator.setTargetName( "Sarah Connor" ); + s.persist( computer ); + s.persist( asimov ); + s.persist( terminator ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + Query q =3D s.createQuery( "from Machine m where m.weight >=3D :weight" = ); + q.setDouble( "weight", new Double( 10 ) ); + List result =3D q.list(); + assertEquals( 2, result.size() ); + tx.commit(); + s.close(); + s =3D openSession(); + tx =3D s.beginTransaction(); + tx.commit(); + s.close(); + } + + public void testConstraintsOnSuperclassProperties() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Product product1 =3D new Product(); + product1.setId( 1l ); + product1.setManufacturerId( 1l ); + product1.setManufacturerPartNumber( "AAFR"); + s.persist( product1 ); + s.flush(); + Product product2 =3D new Product(); + product2.setId( 2l ); + product2.setManufacturerId( 1l ); + product2.setManufacturerPartNumber( "AAFR"); + s.persist( product2 ); + try { + s.flush(); + fail("Database Exception not handled"); + } + catch( JDBCException e ) { + //success + } + tx.rollback(); + s.close(); + } + + = + + public TablePerClassTest(String x) { + super( x ); //To change body of overridden methods use File | Settings |= File Templates. + } + + protected Class[] getMappings() { + return new Class[]{ + Robot.class, + T800.class, + Machine.class, + Component.class, + Product.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/target/Brand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/Brand.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/Brand.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,56 @@ +//$Id: Brand.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.target; + +import java.util.Map; +import java.util.HashMap; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.ManyToMany; + +import org.hibernate.annotations.MapKey; +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.MapKeyManyToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Brand { + @Id + @GeneratedValue + private Long id; + + @ManyToMany(targetEntity =3D LuggageImpl.class) + @MapKey(targetElement =3D SizeImpl.class) + private Map luggagesBySize =3D new HashMap(= ); + + @CollectionOfElements(targetElement =3D SizeImpl.class) + @MapKeyManyToMany(targetEntity =3D LuggageImpl.class) + private Map sizePerLuggage =3D new HashMap(= ); + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public Map getLuggagesBySize() { + return luggagesBySize; + } + + public void setLuggagesBySize(Map luggagesBySize) { + this.luggagesBySize =3D luggagesBySize; + } + + public Map getSizePerLuggage() { + return sizePerLuggage; + } + + public void setSizePerLuggage(Map sizePerLuggage) { + this.sizePerLuggage =3D sizePerLuggage; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/target/Luggage.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/Luggage.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/Luggage.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,17 @@ +//$Id: Luggage.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.target; + +/** + * @author Emmanuel Bernard + */ +public interface Luggage { + double getHeight(); + double getWidth(); + + void setHeight(double height); + void setWidth(double width); + + Owner getOwner(); + + void setOwner(Owner owner); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/target/LuggageImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/LuggageImpl.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/LuggageImpl.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,57 @@ +//$Id: LuggageImpl.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.target; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.ManyToOne; +import javax.persistence.Embedded; + +import org.hibernate.annotations.Target; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class LuggageImpl implements Luggage { + private Long id; + private double height; + private double width; + private Owner owner; + + @Embedded + @Target(OwnerImpl.class) + public Owner getOwner() { + return owner; + } + + public void setOwner(Owner owner) { + this.owner =3D owner; + } + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id =3D id; + } + + public double getHeight() { + return height; + } + + public void setHeight(double height) { + this.height =3D height; + } + + public double getWidth() { + return width; + } + + public void setWidth(double width) { + this.width =3D width; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/target/Owner.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/Owner.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/Owner.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,12 @@ +//$Id: Owner.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.target; + +import java.util.Map; + +/** + * @author Emmanuel Bernard + */ +public interface Owner { + String getName(); + void setName(String name); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/target/OwnerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/OwnerImpl.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/OwnerImpl.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,24 @@ +//$Id: OwnerImpl.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.target; + +import java.util.Map; +import java.util.HashMap; +import javax.persistence.Embeddable; +import org.hibernate.annotations.MapKey; +import javax.persistence.ManyToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class OwnerImpl implements Owner { + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/target/Size.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/Size.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/Size.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,10 @@ +//$Id: Size.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.target; + +/** + * @author Emmanuel Bernard + */ +public interface Size { + String getName(); + void setName(String name); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/target/SizeImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/SizeImpl.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/SizeImpl.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,20 @@ +//$Id: SizeImpl.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.target; + +import javax.persistence.Embeddable; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public class SizeImpl implements Size { + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/target/TargetTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/TargetTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/target/TargetTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,82 @@ +//$Id: TargetTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.target; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; + +/** + * @author Emmanuel Bernard + */ +public class TargetTest extends TestCase { + + public void testTargetOnEmbedded() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Luggage l =3D new LuggageImpl(); + l.setHeight( 12 ); + l.setWidth( 12 ); + Owner o =3D new OwnerImpl(); + o.setName( "Emmanuel" ); + l.setOwner( o ); + s.persist( l ); + s.flush(); + s.clear(); + l =3D (Luggage) s.get(LuggageImpl.class, ( (LuggageImpl) l).getId() ); + assertEquals( "Emmanuel", l.getOwner().getName() ); + s.getTransaction().rollback(); + s.close(); + } + + public void testTargetOnMapKey() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Luggage l =3D new LuggageImpl(); + l.setHeight( 12 ); + l.setWidth( 12 ); + Size size =3D new SizeImpl(); + size.setName( "S" ); + Owner o =3D new OwnerImpl(); + o.setName( "Emmanuel" ); + l.setOwner( o ); + s.persist( l ); + Brand b =3D new Brand(); + s.persist( b ); + b.getLuggagesBySize().put( size, l ); + s.flush(); + s.clear(); + b =3D (Brand) s.get(Brand.class, b.getId() ); + assertEquals( "S", b.getLuggagesBySize().keySet().iterator().next().getN= ame() ); + s.getTransaction().rollback(); + s.close(); + } + + public void testTargetOnMapKeyManyToMany() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Luggage l =3D new LuggageImpl(); + l.setHeight( 12 ); + l.setWidth( 12 ); + Size size =3D new SizeImpl(); + size.setName( "S" ); + Owner o =3D new OwnerImpl(); + o.setName( "Emmanuel" ); + l.setOwner( o ); + s.persist( l ); + Brand b =3D new Brand(); + s.persist( b ); + b.getSizePerLuggage().put( l, size ); + s.flush(); + s.clear(); + b =3D (Brand) s.get(Brand.class, b.getId() ); + assertEquals( 12d, b.getSizePerLuggage().keySet().iterator().next().getW= idth() ); + s.getTransaction().rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { + LuggageImpl.class, + Brand.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tuplizer/Country.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/Country.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/Country.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,15 @@ +//$Id: Country.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.tuplizer; + +import javax.persistence.Embeddable; +import javax.persistence.Column; + +/** + * @author Emmanuel Bernard + */ +(a)Embeddable +public interface Country { + @Column(name =3D "CountryName") + public String getName(); + public void setName(String name); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tuplizer/Cuisine.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/Cuisine.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/Cuisine.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,29 @@ +//$Id: Cuisine.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.tuplizer; + +import javax.persistence.Id; +import javax.persistence.GeneratedValue; +import javax.persistence.Entity; + +import org.hibernate.annotations.Tuplizer; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Tuplizer(impl =3D DynamicEntityTuplizer.class) +public interface Cuisine { + @Id + @GeneratedValue + public Long getId(); + public void setId(Long id); + + public String getName(); + public void setName(String name); + + @Tuplizer(impl =3D DynamicComponentTuplizer.class) + public Country getCountry(); + public void setCountry(Country country); + + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tuplizer/DataProxyHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/DataProxyHandler.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/DataProxyHandler.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,53 @@ +//$Id: DataProxyHandler.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.tuplizer; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.io.Serializable; + +/** + * A simple {@link java.lang.reflect.InvocationHandler} to act as the hand= ler for our generated + * {@link java.lang.reflect.Proxy}-based entity instances. + *

+ * This is a trivial impl which simply keeps the property values into + * a Map. + * + * @author Steve Ebersole + */ +public final class DataProxyHandler implements InvocationHandler { + private String entityName; + private HashMap data =3D new HashMap(); + + public DataProxyHandler(String entityName, Serializable id) { + this.entityName =3D entityName; + data.put( "Id", id ); + } + + public Object invoke(Object proxy, Method method, Object[] args) throws T= hrowable { + String methodName =3D method.getName(); + if ( methodName.startsWith( "set" ) ) { + String propertyName =3D methodName.substring( 3 ); + data.put( propertyName, args[0] ); + } + else if ( methodName.startsWith( "get" ) ) { + String propertyName =3D methodName.substring( 3 ); + return data.get( propertyName ); + } + else if ( "toString".equals( methodName ) ) { + return entityName + "#" + data.get( "Id" ); + } + else if ( "hashCode".equals( methodName ) ) { + return new Integer( this.hashCode() ); + } + return null; + } + + public String getEntityName() { + return entityName; + } + + public HashMap getData() { + return data; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tuplizer/DynamicComponentTuplizer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/DynamicComponentTuplizer.java (rev= 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/DynamicComponentTuplizer.java 2009-11-24 21:03:15 UTC (rev= 18049) @@ -0,0 +1,29 @@ +//$Id: DynamicComponentTuplizer.java 14736 2008-06-04 14:23:42Z hardy.fere= ntschik $ +package org.hibernate.test.annotations.tuplizer; + +import org.hibernate.tuple.entity.PojoEntityTuplizer; +import org.hibernate.tuple.entity.EntityMetamodel; +import org.hibernate.tuple.Instantiator; +import org.hibernate.tuple.component.PojoComponentTuplizer; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Component; +import org.hibernate.proxy.ProxyFactory; +import org.hibernate.property.Getter; +import org.hibernate.property.Setter; +import org.hibernate.HibernateException; + +/** + * @author Emmanuel Bernard + */ +public class DynamicComponentTuplizer extends PojoComponentTuplizer { + + public DynamicComponentTuplizer(Component component) { + super( component ); + } + + + protected Instantiator buildInstantiator(Component component) { + return new DynamicInstantiator( component.getComponentClassName() ); //T= o change body of overridden methods use File | Settings | File Templates. + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tuplizer/DynamicEntityTuplizer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/DynamicEntityTuplizer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/DynamicEntityTuplizer.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,32 @@ +//$Id: DynamicEntityTuplizer.java 14736 2008-06-04 14:23:42Z hardy.ferents= chik $ +package org.hibernate.test.annotations.tuplizer; + +import org.hibernate.tuple.entity.PojoEntityTuplizer; +import org.hibernate.tuple.entity.EntityMetamodel; +import org.hibernate.tuple.Instantiator; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.proxy.ProxyFactory; +import org.hibernate.property.Getter; +import org.hibernate.property.Setter; + +/** + * @author Emmanuel Bernard + */ +public class DynamicEntityTuplizer extends PojoEntityTuplizer { + + public DynamicEntityTuplizer(EntityMetamodel entityMetamodel, Persistent= Class mappedEntity) { + super( entityMetamodel, mappedEntity ); + } + + protected Instantiator buildInstantiator(PersistentClass persistentClass= ) { + return new DynamicInstantiator( persistentClass.getEntityName() ); + } + + protected ProxyFactory buildProxyFactory(PersistentClass persistentClass= , Getter idGetter, Setter idSetter) { + // allows defining a custom proxy factory, which is responsible for + // generating lazy proxies for a given entity. + // + // Here we simply use the default... + return super.buildProxyFactory( persistentClass, idGetter, idSetter ); + } + } Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tuplizer/DynamicInstantiator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/DynamicInstantiator.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/DynamicInstantiator.java 2009-11-24 21:03:15 UTC (rev 1804= 9) @@ -0,0 +1,56 @@ +//$Id: DynamicInstantiator.java 14736 2008-06-04 14:23:42Z hardy.ferentsch= ik $ +package org.hibernate.test.annotations.tuplizer; + +import java.io.Serializable; +import java.lang.reflect.Proxy; +import java.lang.reflect.InvocationHandler; + +import org.hibernate.tuple.Instantiator; +import org.hibernate.util.ReflectHelper; +import org.hibernate.HibernateException; + +/** + * @author Emmanuel Bernard + */ +public class DynamicInstantiator implements Instantiator { + private final String entityName; + + public DynamicInstantiator(String entityName) { + this.entityName =3D entityName; + } + + public Object instantiate(Serializable id) { + if ( Cuisine.class.getName().equals( entityName ) ) { + return ProxyHelper.newCuisineProxy( id ); + } + if ( Country.class.getName().equals( entityName ) ) { + return ProxyHelper.newCountryProxy( id ); + } + else { + throw new IllegalArgumentException( "unknown entity for instantiation [= " + entityName + "]" ); + } + } + + public Object instantiate() { + return instantiate( null ); + } + + public boolean isInstance(Object object) { + String resolvedEntityName =3D null; + if ( Proxy.isProxyClass( object.getClass() ) ) { + InvocationHandler handler =3D Proxy.getInvocationHandler( object ); + if ( DataProxyHandler.class.isAssignableFrom( handler.getClass() ) ) { + DataProxyHandler myHandler =3D ( DataProxyHandler ) handler; + resolvedEntityName =3D myHandler.getEntityName(); + } + } + try { + return ReflectHelper.classForName( entityName ).isInstance( object ); + } + catch( Throwable t ) { + throw new HibernateException( "could not get handle to entity-name as i= nterface : " + t ); + } + +// return entityName.equals( resolvedEntityName ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tuplizer/EntityNameInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/EntityNameInterceptor.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/EntityNameInterceptor.java 2009-11-24 21:03:15 UTC (rev 18= 049) @@ -0,0 +1,25 @@ +//$Id: EntityNameInterceptor.java 14736 2008-06-04 14:23:42Z hardy.ferents= chik $ +package org.hibernate.test.annotations.tuplizer; + +import org.hibernate.EmptyInterceptor; + +/** + * @author Emmanuel Bernard + */ +public class EntityNameInterceptor extends EmptyInterceptor { + /** + * The callback from Hibernate to determine the entity name given + * a presumed entity instance. + * + * @param object The presumed entity instance. + * @return The entity name (pointing to the proper entity mapping). + */ + public String getEntityName(Object object) { + String entityName =3D ProxyHelper.extractEntityName( object ); + if ( entityName =3D=3D null ) { + entityName =3D super.getEntityName( object ); + } + return entityName; + } +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tuplizer/ProxyHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/ProxyHelper.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/ProxyHelper.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,50 @@ +//$Id: ProxyHelper.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.tuplizer; + +import java.io.Serializable; +import java.lang.reflect.Proxy; +import java.lang.reflect.InvocationHandler; + +/** + * @author Emmanuel Bernard + */ +public class ProxyHelper { + + public static Country newPersonProxy() { + return newCountryProxy( null ); + } + + public static Country newCountryProxy(Serializable id) { + return ( Country ) Proxy.newProxyInstance( + Country.class.getClassLoader(), + new Class[] {Country.class}, + new DataProxyHandler( Country.class.getName(), id ) + ); + } + + public static Cuisine newCustomerProxy() { + return newCuisineProxy( null ); + } + + public static Cuisine newCuisineProxy(Serializable id) { + return ( Cuisine ) Proxy.newProxyInstance( + Cuisine.class.getClassLoader(), + new Class[] {Cuisine.class}, + new DataProxyHandler( Cuisine.class.getName(), id ) + ); + } + + public static String extractEntityName(Object object) { + // Our custom java.lang.reflect.Proxy instances actually bundle + // their appropriate entity name, so we simply extract it from there + // if this represents one of our proxies; otherwise, we return null + if ( Proxy.isProxyClass( object.getClass() ) ) { + InvocationHandler handler =3D Proxy.getInvocationHandler( object ); + if ( DataProxyHandler.class.isAssignableFrom( handler.getClass() ) ) { + DataProxyHandler myHandler =3D ( DataProxyHandler ) handler; + return myHandler.getEntityName(); + } + } + return null; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/tuplizer/TuplizerTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/TuplizerTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/tuplizer/TuplizerTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: TuplizerTest.java 16289 2009-04-09 22:09:50Z gbadner $ +package org.hibernate.test.annotations.tuplizer; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; + +/** + * @author Emmanuel Bernard + */ +public class TuplizerTest extends TestCase { + public void testEntityTuplizer() throws Exception { + Cuisine cuisine =3D ProxyHelper.newCuisineProxy( null ); + cuisine.setName( "Francaise" ); + Country country =3D ProxyHelper.newCountryProxy( null ); + country.setName( "France" ); + cuisine.setCountry( country ); + Session s =3D openSession( new EntityNameInterceptor() ); + s.getTransaction().begin(); + s.persist( cuisine ); + s.flush(); + s.clear(); + cuisine =3D (Cuisine) s.get(Cuisine.class, cuisine.getId() ); + assertNotNull( cuisine ); + assertEquals( "Francaise", cuisine.getName() ); + assertEquals( "France", country.getName() ); + s.getTransaction().rollback(); + s.close(); + } + protected Class[] getMappings() { + return new Class[] { + Cuisine.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/type/Dvd.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/type/Dvd.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/type/Dvd.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,48 @@ +//$Id: Dvd.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.type; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.annotations.Columns; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Type; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Dvd { + private MyOid id; + private String title; + + @Id + @GeneratedValue(generator =3D "custom-id") + @GenericGenerator(name =3D "custom-id", strategy =3D "org.hibernate.test.= annotations.type.MyOidGenerator") + @Type(type =3D "org.hibernate.test.annotations.type.MyOidType") + @Columns( + columns =3D { + @Column(name =3D "high"), + @Column(name =3D "middle"), + @Column(name =3D "low"), + @Column(name =3D "other") + } + ) + public MyOid getId() { + return id; + } + + public void setId(MyOid id) { + this.id =3D id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title =3D title; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/type/MyOid.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/type/MyOid.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/type/MyOid.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,79 @@ +//$Id: MyOid.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.type; + +import java.io.Serializable; + +/** + * @author Emmanuel Bernard + */ +public class MyOid implements Serializable { + private int high; + private int middle; + private int low; + private int other; + + protected MyOid() { + } + + public MyOid(int aHigh, int aMiddle, int aLow, int aOther) { + high =3D aHigh; + middle =3D aMiddle; + low =3D aLow; + other =3D aOther; + } + + public int getHigh() { + return high; + } + + public void setHigh(int aHigh) { + high =3D aHigh; + } + + public int getMiddle() { + return middle; + } + + public void setMiddle(int aMiddle) { + middle =3D aMiddle; + } + + public int getLow() { + return low; + } + + public void setLow(int aLow) { + low =3D aLow; + } + + public int getOther() { + return other; + } + + public void setOther(int aOther) { + other =3D aOther; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( o =3D=3D null || getClass() !=3D o.getClass() ) return false; + + final MyOid myOid =3D (MyOid) o; + + if ( high !=3D myOid.high ) return false; + if ( low !=3D myOid.low ) return false; + if ( middle !=3D myOid.middle ) return false; + if ( other !=3D myOid.other ) return false; + + return true; + } + + public int hashCode() { + int result; + result =3D low; + result =3D 29 * result + middle; + result =3D 29 * result + high; + result =3D 29 * result + other; + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/type/MyOidGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/type/MyOidGenerator.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/type/MyOidGenerator.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,22 @@ +//$Id: MyOidGenerator.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.type; + +import java.io.Serializable; + +import org.hibernate.HibernateException; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.id.IdentifierGenerator; + +/** + * @author Emmanuel Bernard + */ +public class MyOidGenerator implements IdentifierGenerator { + + private int counter; + + public Serializable generate(SessionImplementor aSessionImplementor, Obje= ct aObject) throws HibernateException { + counter++; + return new MyOid( 0, 0, 0, counter ); + } +} + Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/type/MyOidType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/type/MyOidType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/type/MyOidType.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,147 @@ +//$Id: MyOidType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.type; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.hibernate.Hibernate; +import org.hibernate.HibernateException; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.type.Type; +import org.hibernate.usertype.CompositeUserType; + +/** + * @author Emmanuel Bernard + */ +public class MyOidType implements CompositeUserType { + + public static final String[] PROPERTY_NAMES =3D new String[]{"high", "mid= dle", "low", "other"}; + public static final Type[] TYPES =3D new Type[]{Hibernate.INTEGER, Hibern= ate.INTEGER, Hibernate.INTEGER, Hibernate.INTEGER}; + + + public String[] getPropertyNames() { + return PROPERTY_NAMES; + } + + public Type[] getPropertyTypes() { + return TYPES; + } + + public Object getPropertyValue(Object aObject, int i) throws HibernateExc= eption { + MyOid dbOid =3D (MyOid) aObject; + switch ( i ) { + case 0: + return dbOid.getHigh(); + case 1: + return dbOid.getMiddle(); + case 2: + return dbOid.getLow(); + case 3: + return dbOid.getOther(); + default: + throw new HibernateException( "Unsupported property index " + i ); + } + + } + + public void setPropertyValue(Object aObject, int i, Object aObject1) thro= ws HibernateException { + MyOid dbOid =3D (MyOid) aObject; + switch ( i ) { + case 0: + dbOid.setHigh( (Integer) aObject1 ); + case 1: + dbOid.setMiddle( (Integer) aObject1 ); + case 2: + dbOid.setLow( (Integer) aObject1 ); + case 3: + dbOid.setOther( (Integer) aObject1 ); + default: + throw new HibernateException( "Unsupported property index " + i ); + } + } + + public Class returnedClass() { + return MyOid.class; + } + + public boolean equals(Object x, Object y) throws HibernateException { + if ( x =3D=3D y ) return true; + if ( x =3D=3D null || y =3D=3D null ) return false; + + MyOid oid1 =3D (MyOid) x; + MyOid oid2 =3D (MyOid) y; + + if ( oid1.getHigh() !=3D oid2.getHigh() ) { + return false; + } + if ( oid1.getMiddle() !=3D oid2.getMiddle() ) { + return false; + } + if ( oid1.getLow() !=3D oid2.getLow() ) { + return false; + } + return oid1.getOther() =3D=3D oid2.getOther(); + + } + + public int hashCode(Object aObject) throws HibernateException { + return aObject.hashCode(); + } + + public Object nullSafeGet( + ResultSet aResultSet, String[] names, SessionImplementor aSessionImplem= entor, Object aObject + ) throws HibernateException, SQLException { + Integer highval =3D (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet,= names[0] ); + Integer midval =3D (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, = names[1] ); + Integer lowval =3D (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, = names[2] ); + Integer other =3D (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, n= ames[3] ); + + return new MyOid( highval, midval, lowval, other ); + } + + public void nullSafeSet( + PreparedStatement aPreparedStatement, Object value, int index, SessionI= mplementor aSessionImplementor + ) throws HibernateException, SQLException { + MyOid c; + if ( value =3D=3D null ) { + // todo is this correct? + throw new HibernateException( "Oid object may not be null" ); + } + else { + c =3D (MyOid) value; + } + + Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getHigh(), index ); + Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getMiddle(), index = + 1 ); + Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getLow(), index + 2= ); + Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getOther(), index += 3 ); + } + + public Object deepCopy(Object aObject) throws HibernateException { + MyOid oldOid =3D (MyOid) aObject; + + return new MyOid( oldOid.getHigh(), oldOid.getMiddle(), oldOid.getLow(),= oldOid.getOther() ); + } + + public boolean isMutable() { + return false; + } + + public Serializable disassemble(Object value, SessionImplementor aSession= Implementor) throws HibernateException { + return (Serializable) deepCopy( value ); + } + + public Object assemble(Serializable cached, SessionImplementor aSessionIm= plementor, Object aObject) + throws HibernateException { + return deepCopy( cached ); + } + + public Object replace(Object original, Object target, SessionImplementor = aSessionImplementor, Object aObject2) + throws HibernateException { + // we are immutable. return original + return original; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/type/TypeTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/type/TypeTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/type/TypeTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,31 @@ +//$Id: TypeTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.type; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class TypeTest extends TestCase { + public void testIdWithMulticolumns() throws Exception { + Session s; + Transaction tx; + s =3D openSession(); + tx =3D s.beginTransaction(); + Dvd lesOiseaux =3D new Dvd(); + lesOiseaux.setTitle( "Les oiseaux" ); + s.persist( lesOiseaux ); + s.flush(); + assertNotNull( lesOiseaux.getId() ); + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[]{ + Dvd.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/various/Antenna.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/Antenna.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/Antenna.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,25 @@ +//$Id: Antenna.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.various; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Column; + +import org.hibernate.annotations.Generated; +import org.hibernate.annotations.GenerationTime; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Antenna { + @Id public Integer id; + @Generated(GenerationTime.ALWAYS) @Column() + public String longitude; + + @Generated(GenerationTime.INSERT) @Column(insertable =3D false) + public String latitude; + + @Generated(GenerationTime.NEVER) + public Double power; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/various/Conductor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/Conductor.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/Conductor.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,54 @@ +//$Id: Conductor.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.various; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Version; + +import org.hibernate.annotations.Index; +import org.hibernate.annotations.OptimisticLock; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Conductor { + @Id + @GeneratedValue + private Integer id; + + @Column(name =3D "cond_name") + @Index(name =3D "cond_name") + @OptimisticLock(excluded =3D true) + private String name; + + @Version + private Long version; + + + public Long getVersion() { + return version; + } + + public void setVersion(Long version) { + this.version =3D version; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/various/GeneratedTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/GeneratedTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/GeneratedTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,30 @@ +//$Id: GeneratedTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.various; + +import org.hibernate.test.annotations.TestCase; +import org.hibernate.Session; +import org.hibernate.Transaction; + +/** + * @author Emmanuel Bernard + */ +public class GeneratedTest extends TestCase { + + public void testGenerated() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Antenna antenna =3D new Antenna(); + antenna.id =3D new Integer(1); + s.persist( antenna ); + assertNull( antenna.latitude ); + assertNull( antenna.longitude ); + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { + Antenna.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/various/IndexTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/IndexTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/IndexTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,63 @@ +//$Id: IndexTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.various; + +import java.util.Date; + +import org.hibernate.Session; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class IndexTest extends TestCase { + public void testIndexManyToOne() throws Exception { + //TODO find a way to test indexes??? + Session s =3D openSession(); + s.getTransaction().begin(); + Conductor emmanuel =3D new Conductor(); + emmanuel.setName( "Emmanuel" ); + s.persist( emmanuel ); + Vehicule tank =3D new Vehicule(); + tank.setCurrentConductor( emmanuel ); + tank.setRegistrationNumber( "324VX43" ); + s.persist( tank ); + s.flush(); + s.delete( tank ); + s.delete( emmanuel ); + s.getTransaction().rollback(); + s.close(); + } + + public void testIndexAndJoined() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Conductor cond =3D new Conductor(); + cond.setName( "Bob" ); + s.persist( cond ); + ProfessionalAgreement agreement =3D new ProfessionalAgreement(); + agreement.setExpirationDate( new Date() ); + s.persist( agreement ); + Truck truck =3D new Truck(); + truck.setAgreement( agreement ); + truck.setWeight( 20 ); + truck.setRegistrationNumber( "2003424" ); + truck.setYear( 2005 ); + truck.setCurrentConductor( cond ); + s.persist( truck ); + s.flush(); + s.delete( truck ); + s.delete( agreement ); + s.delete( cond ); + s.getTransaction().rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[]{ + Conductor.class, + Vehicule.class, + ProfessionalAgreement.class, + Truck.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/various/ProfessionalAgreement.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/ProfessionalAgreement.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/ProfessionalAgreement.java 2009-11-24 21:03:15 UTC (rev 180= 49) @@ -0,0 +1,34 @@ +//$Id: ProfessionalAgreement.java 14736 2008-06-04 14:23:42Z hardy.ferents= chik $ +package org.hibernate.test.annotations.various; + +import java.util.Date; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class ProfessionalAgreement { + @Id + @GeneratedValue + private Integer id; + private Date expirationDate; + + public Date getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(Date expirationDate) { + this.expirationDate =3D expirationDate; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/various/Truck.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/Truck.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/Truck.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +//$Id: Truck.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.various; + +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.Index; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class Truck extends Vehicule { + @Index(name =3D "weigth_idx") + private int weight; + + @ManyToOne + @JoinColumn(name =3D "agreement_id") + @Index(name =3D "agreement_idx") + private ProfessionalAgreement agreement; + + public int getWeight() { + return weight; + } + + public void setWeight(int weight) { + this.weight =3D weight; + } + + public ProfessionalAgreement getAgreement() { + return agreement; + } + + public void setAgreement(ProfessionalAgreement agreement) { + this.agreement =3D agreement; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/various/Vehicule.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/Vehicule.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/Vehicule.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,83 @@ +//$Id: Vehicule.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.various; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Index; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)Inheritance(strategy =3D InheritanceType.JOINED) +(a)org.hibernate.annotations.Table(appliesTo =3D "Vehicule", + indexes =3D { + @Index(name =3D "improbableindex", columnNames =3D {"registration", "Con= ductor_fk"}), + @Index(name =3D "secondone", columnNames =3D {"Conductor_fk"}) + } +) +public class Vehicule { + @Id + @GeneratedValue(generator =3D "gen") + @GenericGenerator(name =3D "gen", strategy =3D "uuid") + private String id; + @Column(name =3D "registration") + private String registrationNumber; + @ManyToOne(optional =3D false) + @JoinColumn(name =3D "Conductor_fk") + @Index(name =3D "thirdone") + private Conductor currentConductor; + @Index(name =3D "year_idx") + private Integer year; + @ManyToOne(optional =3D true) + @Index(name =3D "forthone") + private Conductor previousConductor; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id =3D id; + } + + public String getRegistrationNumber() { + return registrationNumber; + } + + public void setRegistrationNumber(String registrationNumber) { + this.registrationNumber =3D registrationNumber; + } + + public Conductor getCurrentConductor() { + return currentConductor; + } + + public void setCurrentConductor(Conductor currentConductor) { + this.currentConductor =3D currentConductor; + } + + public Integer getYear() { + return year; + } + + public void setYear(Integer year) { + this.year =3D year; + } + + public Conductor getPreviousConductor() { + return previousConductor; + } + + public void setPreviousConductor(Conductor previousConductor) { + this.previousConductor =3D previousConductor; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/various/VersionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/VersionTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/various/VersionTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,41 @@ +//$Id: VersionTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.various; + +import org.hibernate.Session; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class VersionTest extends TestCase { + + public void testOptimisticLockDisabled() throws Exception { + Conductor c =3D new Conductor(); + c.setName( "Bob" ); + Session s =3D openSession( ); + s.getTransaction().begin(); + s.persist( c ); + s.flush(); + + s.clear(); + + c =3D (Conductor) s.get( Conductor.class, c.getId() ); + Long version =3D c.getVersion(); + c.setName( "Don" ); + s.flush(); + + s.clear(); + + c =3D (Conductor) s.get( Conductor.class, c.getId() ); + assertEquals( version, c.getVersion() ); + + s.getTransaction().rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[] { + Conductor.class + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/ejb3/CarModel.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/CarModel.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/CarModel.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,19 @@ +//$Id: CarModel.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.ejb3; + +import java.util.Date; + +/** + * @author Emmanuel Bernard + */ +public class CarModel extends Model { + private Date year; + + public Date getYear() { + return year; + } + + public void setYear(Date year) { + this.year =3D year; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/ejb3/Ejb3XmlTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/Ejb3XmlTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/Ejb3XmlTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,86 @@ +//$Id: Ejb3XmlTest.java 16301 2009-04-10 23:26:04Z gbadner $ +package org.hibernate.test.annotations.xml.ejb3; + +import java.util.Date; +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class Ejb3XmlTest extends TestCase { + public void testEjb3Xml() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + CarModel model =3D new CarModel(); + model.setYear( new Date() ); + Manufacturer manufacturer =3D new Manufacturer(); + //s.persist( manufacturer ); + model.setManufacturer( manufacturer ); + manufacturer.getModels().add( model ); + s.persist( model ); + s.flush(); + s.clear(); + + model.setYear( new Date() ); + manufacturer =3D (Manufacturer) s.get( Manufacturer.class, manufacturer.= getId() ); + List cars =3D s.getNamedQuery( "allModelsPerManufacturer" ) + .setParameter( "manufacturer", manufacturer ) + .list(); + assertEquals( 1, cars.size() ); + for ( Model car : cars ) { + assertNotNull( car.getManufacturer() ); + s.delete( manufacturer ); + s.delete( car ); + } + tx.rollback(); + s.close(); + } + + public void testXMLEntityHandled() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Lighter l =3D new Lighter(); + l.name =3D "Blue"; + l.power =3D "400F"; + s.persist( l ); + s.flush(); + s.getTransaction().rollback(); + s.close(); + } + + public void testXmlDefaultOverriding() throws Exception { + Session s =3D openSession(); + Transaction tx =3D s.beginTransaction(); + Manufacturer manufacturer =3D new Manufacturer(); + s.persist( manufacturer ); + s.flush(); + s.clear(); + + assertEquals( 1, s.getNamedQuery( "manufacturer.findAll" ).list().size()= ); + tx.rollback(); + s.close(); + } + + protected Class[] getMappings() { + return new Class[]{ + CarModel.class, + Manufacturer.class, + Model.class, + Light.class + //Lighter.class xml only entuty + }; + } + + @Override + protected String[] getXmlFiles() { + return new String[]{ + "org/hibernate/test/annotations/xml/ejb3/orm.xml", + "org/hibernate/test/annotations/xml/ejb3/orm2.xml", + "org/hibernate/test/annotations/xml/ejb3/orm3.xml" + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/ejb3/Light.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/Light.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/Light.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,10 @@ +//$Id: Light.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.ejb3; + +/** + * @author Emmanuel Bernard + */ +public class Light { + public String name; + public String power; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/ejb3/Lighter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/Lighter.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/Lighter.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,10 @@ +//$Id: Lighter.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.ejb3; + +/** + * @author Emmanuel Bernard + */ +public class Lighter { + public String name; + public String power; +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/ejb3/Manufacturer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/Manufacturer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/Manufacturer.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,39 @@ +//$Id: Manufacturer.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.ejb3; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.NamedQuery; +import javax.persistence.TableGenerator; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +(a)NamedQuery(name=3D"manufacturer.findAll", query =3D "from Manufacturer = where 1 =3D 2") +(a)TableGenerator(name=3D"generator", table =3D "this is a broken name wit= h select from and other SQL keywords") +public class Manufacturer { + private Integer id; + private Set models =3D new HashSet(); + + @Id + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @OneToMany + public Set getModels() { + return models; + } + + public void setModels(Set models) { + this.models =3D models; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/ejb3/Model.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/Model.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/Model.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +//$Id: Model.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.ejb3; + +/** + * @author Emmanuel Bernard + */ +public class Model { + private Integer id; + private Manufacturer manufacturer; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public Manufacturer getManufacturer() { + return manufacturer; + } + + public void setManufacturer(Manufacturer manufacturer) { + this.manufacturer =3D manufacturer; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/ejb3/orm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/orm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/orm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,56 @@ + + + + + + + + + + org.hibernate.test.annotations.xml.ejb3 + + + select m from Manufacturer m + + + +
+ + + + + + + + + + + +
+ + + + + from ModelZ m where m.manufacturer =3D :manufacturer + + + + + + + DATE + + + + + + + + + + + +
\ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/ejb3/orm2.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/orm2.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/orm2.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,17 @@ + + + + org.hibernate.test.annotations.xml.ejb3 + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/ejb3/orm3.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/orm3.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/ejb3/orm3.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,17 @@ + + + + org.hibernate.test.annotations.xml.ejb3 + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/A.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/A.hbm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/A.hbm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/A.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/A.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/A.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ +//$Id: A.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.hbm; + +/** + * @author Emmanuel Bernard + */ +public interface A extends java.io.Serializable { + public Integer getAId(); + + public void setAId(Integer aId); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/AImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/AImpl.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/AImpl.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,34 @@ +//$Id: AImpl.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.hbm; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; +import javax.persistence.GeneratedValue; + +(a)Entity +(a)Inheritance( strategy =3D InheritanceType.JOINED ) +(a)org.hibernate.annotations.Proxy( proxyClass =3D A.class ) +(a)Table( name =3D "A" ) +public class AImpl implements A { + private static final long serialVersionUID =3D 1L; + + private Integer aId =3D 0; + + public AImpl() { + } + + @Id + @GeneratedValue + @Column( name =3D "aID" ) + public Integer getAId() { + return this.aId; + } + + public void setAId(Integer aId) { + this.aId =3D aId; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/B.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/B.hbm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/B.hbm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/B.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/B.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/B.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,11 @@ +//$Id: B.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.hbm; + +/** + * @author Emmanuel Bernard + */ +public interface B extends A { + public Integer getBId(); + + public void setBId(Integer bId); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/BImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/BImpl.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/BImpl.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +//$Id: BImpl.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.hbm; + +import javax.persistence.Entity; +import javax.persistence.Table; + +(a)Entity +(a)org.hibernate.annotations.Proxy( proxyClass =3D B.class ) +(a)Table( name =3D "B" ) +public class BImpl extends AImpl implements B { + private static final long serialVersionUID =3D 1L; + + private Integer bId =3D 0; + + public BImpl() { + super(); + } + + public Integer getBId() { + return bId; + } + + public void setBId(Integer bId) { + this.bId =3D bId; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/CloudType.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/CloudType.hbm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/CloudType.hbm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/CloudType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/CloudType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/CloudType.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,26 @@ +//$Id: CloudType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.hbm; + +/** + * @author Emmanuel Bernard + */ +public class CloudType { + private Integer id; + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/Government.hbm.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/Government.hbm.xml (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/Government.hbm.xml 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/Government.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/Government.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/Government.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,35 @@ +//$Id: Government.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.hbm; + +/** + * @author Emmanuel Bernard + */ +public class Government { + private Integer id; + private String name; + private PrimeMinister primeMinister; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public PrimeMinister getPrimeMinister() { + return primeMinister; + } + + public void setPrimeMinister(PrimeMinister primeMinister) { + this.primeMinister =3D primeMinister; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/HbmTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/HbmTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/HbmTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,82 @@ +//$Id:HbmTest.java 9793 2006-04-26 02:20:18 -0400 (mer., 26 avr. 2006) epb= ernard $ +package org.hibernate.test.annotations.xml.hbm; + +import java.util.HashSet; + +import org.hibernate.Session; +import org.hibernate.cfg.Configuration; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class HbmTest extends TestCase { + + public void testManyToOne() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Government gov =3D new Government(); + gov.setName( "Liberals" ); + s.save( gov ); + PrimeMinister pm =3D new PrimeMinister(); + pm.setName( "Murray" ); + pm.setCurrentGovernment( gov ); + s.save( pm ); + s.getTransaction().rollback(); + s.close(); + } + + public void testOneToMany() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + Government gov =3D new Government(); + gov.setName( "Liberals" ); + Government gov2 =3D new Government(); + gov2.setName( "Liberals2" ); + s.save( gov ); + s.save( gov2 ); + PrimeMinister pm =3D new PrimeMinister(); + pm.setName( "Murray" ); + pm.setCurrentGovernment( gov ); + pm.setGovernments( new HashSet() ); + pm.getGovernments().add( gov2 ); + pm.getGovernments().add( gov ); + gov.setPrimeMinister( pm ); + gov2.setPrimeMinister( pm ); + s.save( pm ); + s.flush(); + s.getTransaction().rollback(); + s.close(); + } + + public void testManyToMany() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + CloudType type =3D new CloudType(); + type.setName( "Cumulus" ); + Sky sky =3D new Sky(); + s.persist( type ); + sky.getCloudTypes().add(type); + s.persist( sky ); + s.flush(); + s.getTransaction().rollback(); + s.close(); + } + + + protected Class[] getMappings() { + return new Class[]{ + PrimeMinister.class, + Sky.class, + + }; + } + + @Override + protected String[] getXmlFiles() { + return new String[]{ + "org/hibernate/test/annotations/xml/hbm/Government.hbm.xml", + "org/hibernate/test/annotations/xml/hbm/CloudType.hbm.xml", + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/HbmWithIdentityTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/HbmWithIdentityTest.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/HbmWithIdentityTest.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,51 @@ +//$Id:HbmTest.java 9793 2006-04-26 02:20:18 -0400 (mer., 26 avr. 2006) epb= ernard $ +package org.hibernate.test.annotations.xml.hbm; + +import java.util.HashSet; + +import org.hibernate.Session; +import org.hibernate.cfg.Configuration; +import org.hibernate.test.annotations.TestCase; + +/** + * @author Emmanuel Bernard + */ +public class HbmWithIdentityTest extends TestCase { + + public void testManyToOneAndInterface() throws Exception { + Session s =3D openSession(); + s.getTransaction().begin(); + B b =3D new BImpl(); + b.setBId( 1 ); + s.persist( b ); + Z z =3D new ZImpl(); + z.setB( b ); + s.persist( z ); + s.flush(); + s.getTransaction().rollback(); + s.close(); + } + + = + = + @Override + protected boolean runForCurrentDialect() { + return super.runForCurrentDialect() && getDialect().supportsIdentityColu= mns(); + } + + + + protected Class[] getMappings() { + return new Class[]{ + ZImpl.class + }; + } + + @Override + protected String[] getXmlFiles() { + return new String[]{ + "org/hibernate/test/annotations/xml/hbm/A.hbm.xml", + "org/hibernate/test/annotations/xml/hbm/B.hbm.xml" + }; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/PrimeMinister.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/PrimeMinister.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/PrimeMinister.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,57 @@ +//$Id:PrimeMinister.java 9793 2006-04-26 02:20:18 -0400 (mer., 26 avr. 200= 6) epbernard $ +package org.hibernate.test.annotations.xml.hbm; + +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +(a)Entity +public class PrimeMinister { + private Integer id; + private String name; + private Government currentGovernment; + private Set governments; + + @ManyToOne + public Government getCurrentGovernment() { + return currentGovernment; + } + + public void setCurrentGovernment(Government currentGovernment) { + this.currentGovernment =3D currentGovernment; + } + + @Id + @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + @OneToMany(mappedBy =3D "primeMinister") + public Set getGovernments() { + return governments; + } + + public void setGovernments(Set governments) { + this.governments =3D governments; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/Sky.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/Sky.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/Sky.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,47 @@ +//$Id: Sky.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.hbm; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +(a)Entity(name=3D"EarthSky") +public class Sky { + private Integer id; + private Set cloudTypes =3D new HashSet(); + private CloudType mainCloud; + + @ManyToMany + public Set getCloudTypes() { + return cloudTypes; + } + + public void setCloudTypes(Set cloudTypes) { + this.cloudTypes =3D cloudTypes; + } + + @Id @GeneratedValue + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id =3D id; + } + + @ManyToOne + public CloudType getMainCloud() { + return mainCloud; + } + + public void setMainCloud(CloudType mainCloud) { + this.mainCloud =3D mainCloud; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/Z.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/Z.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/Z.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,15 @@ +//$Id: Z.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.hbm; + +/** + * @author Emmanuel Bernard + */ +public interface Z extends java.io.Serializable { + public Integer getZId(); + + public void setZId(Integer zId); + + public B getB(); + + public void setB(B b); +} Added: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/a= nnotations/xml/hbm/ZImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/ZImpl.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/anno= tations/xml/hbm/ZImpl.java 2009-11-24 21:03:15 UTC (rev 18049) @@ -0,0 +1,45 @@ +//$Id: ZImpl.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.test.annotations.xml.hbm; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.GeneratedValue; + +(a)Entity +(a)Inheritance( strategy =3D InheritanceType.JOINED ) +(a)org.hibernate.annotations.Proxy( proxyClass =3D Z.class ) +(a)Table( name =3D "Z" ) +public class ZImpl implements Z { + private static final long serialVersionUID =3D 1L; + + private Integer zId =3D null; + private B b =3D null; + + @Id + @GeneratedValue + @Column( name =3D "zID" ) + public Integer getZId() { + return zId; + } + + public void setZId(Integer zId) { + this.zId =3D zId; + } + + @ManyToOne( optional =3D false, targetEntity =3D BImpl.class, fetch =3D F= etchType.LAZY ) + @JoinColumn( name =3D "bID", referencedColumnName =3D "bID") + public B getB() { + return b; + } + + public void setB(B b) { + this.b =3D b; + } +} --===============8933672252304354649==-- From hibernate-commits at lists.jboss.org Tue Nov 24 16:08:32 2009 Content-Type: multipart/mixed; boundary="===============7939145156186056277==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18050 - in annotations/branches/v3_4_0_GA_CP/src/main/java: org and 8 other directories. Date: Tue, 24 Nov 2009 16:08:31 -0500 Message-ID: <200911242108.nAOL8VQi001869@svn01.web.mwc.hst.phx2.redhat.com> --===============7939145156186056277== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-24 16:08:28 -0500 (Tue, 24 Nov 2009) New Revision: 18050 Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/Annotation= Exception.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/AccessType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Any.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/AnyMetaDef.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/AnyMetaDefs.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/BatchSize.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Cache.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/CacheConcurrencyStrategy.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/CacheModeType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Cascade.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/CascadeType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Check.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/CollectionId.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/CollectionOfElements.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Columns.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/DiscriminatorFormula.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Entity.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Fetch.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/FetchMode.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Filter.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/FilterDef.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/FilterDefs.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/FilterJoinTable.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/FilterJoinTables.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Filters.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/FlushModeType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/ForceDiscriminator.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/ForeignKey.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Formula.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Generated.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/GenerationTime.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/GenericGenerator.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/GenericGenerators.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Immutable.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Index.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/IndexColumn.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/LazyCollection.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/LazyCollectionOption.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/LazyToOne.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/LazyToOneOption.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Loader.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/ManyToAny.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/MapKey.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/MapKeyManyToMany.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/MetaValue.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/NamedNativeQueries.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/NamedNativeQuery.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/NamedQueries.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/NamedQuery.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/NaturalId.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/NotFound.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/NotFoundAction.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/OnDelete.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/OnDeleteAction.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/OptimisticLock.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/OptimisticLockType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/OrderBy.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/ParamDef.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Parameter.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Parent.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Persister.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/PolymorphismType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Proxy.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/ResultCheckStyle.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/SQLDelete.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/SQLDeleteAll.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/SQLInsert.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/SQLUpdate.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Sort.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/SortType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Table.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Tables.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Target.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Tuplizer.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Tuplizers.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Type.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/TypeDef.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/TypeDefs.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/Where.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotation= s/WhereJoinTable.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Abstra= ctPropertyHolder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Annota= tedClassType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Annota= tionBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Annota= tionConfiguration.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Binder= Helper.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/ClassP= ropertyHolder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Collec= tionPropertyHolder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Compon= entPropertyHolder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Create= KeySecondPass.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Defaul= tComponentSafeNamingStrategy.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/EJB3DT= DEntityResolver.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/EJB3Na= mingStrategy.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ejb3Co= lumn.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ejb3Di= scriminatorColumn.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ejb3Jo= inColumn.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Extend= edMappings.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/FkSeco= ndPass.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/IndexC= olumn.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/IndexO= rUniqueKeySecondPass.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Inheri= tanceState.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Joined= SubclassFkSecondPass.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/NotYet= ImplementedException.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/OneToO= neSecondPass.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Proper= tyData.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Proper= tyHolder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Proper= tyHolderBuilder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Proper= tyInferredData.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Proper= tyPreloadedData.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Recove= rableException.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Second= aryTableSecondPass.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/ToOneF= kSecondPass.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Wrappe= dInferredData.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/ArrayBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/BagBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/CollectionBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/EntityBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/IdBagBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/ListBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/MapBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/Nullability.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/PrimitiveArrayBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/PropertyBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/QueryBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/ResultsetMappingSecondPass.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/SetBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/SimpleValueBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/TableBinder.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/Version.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/reflection/ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/reflection/EJB3OverridenAnnotationReader.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/reflection/EJB3ReflectionManager.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annota= tions/reflection/XMLContext.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/search/ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/search= /HibernateSearchEventListenerRegister.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/mapping/ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/mapping/Id= Generator.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Abstr= actLobType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/ByteA= rrayBlobType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Chara= cterArrayClobType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/EnumT= ype.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Primi= tiveByteArrayBlobType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Primi= tiveCharacterArrayClobType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Seria= lizableToBlobType.java annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Strin= gClobType.java Log: JBPAPP-3150 change the build tool of Hibernate Annotations(eap 5 cp branch) Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/Annota= tionException.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/Annotatio= nException.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/Annotatio= nException.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,24 @@ +//$Id: AnnotationException.java 14736 2008-06-04 14:23:42Z hardy.ferentsch= ik $ +package org.hibernate; + +/** + * Annotation related exception. + * The EJB3 EG will probably set a generic exception. + * I'll then use this one. + * + * @author Emmanuel Bernard + */ +public class AnnotationException extends MappingException { + + public AnnotationException(String msg, Throwable root) { + super( msg, root ); + } + + public AnnotationException(Throwable root) { + super( root ); + } + + public AnnotationException(String s) { + super( s ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/AccessType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/AccessType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/AccessType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +//$Id: AccessType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.*; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Property Access type + * + * @author Emmanuel Bernard + */ +(a)Target({TYPE, METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface AccessType { + String value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Any.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Any.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Any.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,45 @@ +//$Id: Any.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import javax.persistence.Column; +import javax.persistence.FetchType; +import static javax.persistence.FetchType.EAGER; + +/** + * Define a ToOne association pointing to several entity types. + * Matching the according entity type is doe through a metadata discrimina= tor column + * This kind of mapping should be only marginal. + * = + * @author Emmanuel Bernard + */ +(a)java.lang.annotation.Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Any { + /** + * Metadata definition used. + * If defined, should point to a @AnyMetaDef name + * If not defined, the local (ie in the same field or property) @AnyMetaD= ef is used + */ + String metaDef() default ""; + + /** + * Metadata discriminator column description, This column will hold the m= eta value corresponding to the + * targeted entity. + */ + Column metaColumn(); + /** + * Defines whether the value of the field or property should be lazily lo= aded or must be + * eagerly fetched. The EAGER strategy is a requirement on the persistenc= e provider runtime + * that the value must be eagerly fetched. The LAZY strategy is applied w= hen bytecode + * enhancement is used. If not specified, defaults to EAGER. + */ + FetchType fetch() default EAGER; + /** + * Whether the association is optional. If set to false then a non-null r= elationship must always exist. + */ + boolean optional() default true; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/AnyMetaDef.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/AnyMetaDef.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/AnyMetaDef.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,40 @@ +//$Id: AnyMetaDef.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * Defines @Any and @manyToAny metadata + * + * @author Emmanuel Bernard + */ +(a)java.lang.annotation.Target( { PACKAGE, TYPE, METHOD, FIELD } ) +(a)Retention( RUNTIME ) +public @interface AnyMetaDef { + /** + * If defined, assign a global meta definition name to be used in an @Any= or @ManyToAny annotation + * If not defined, the metadata applies to the current property or field + */ + String name() default ""; + + /** + * meta discriminator Hibernate type + */ + String metaType(); + + /** + * Hibernate type of the id column + * @return + */ + String idType(); + + /** + * Matching discriminator values with their respective entity + */ + MetaValue[] metaValues(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/AnyMetaDefs.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/AnyMetaDefs.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/AnyMetaDefs.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,21 @@ +//$Id: AnyMetaDefs.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.FIELD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * Defines @Any and @ManyToAny set of metadata. + * Can be defined at the entity level or the package level + * + * @author Emmanuel Bernard + */ +(a)java.lang.annotation.Target( { PACKAGE, TYPE } ) +(a)Retention( RUNTIME ) +public @interface AnyMetaDefs { + AnyMetaDef[] value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/BatchSize.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/BatchSize.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/BatchSize.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +//$Id: BatchSize.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.*; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Batch size for SQL loading + * + * @author Emmanuel Bernard + */ +(a)Target({TYPE, METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface BatchSize { + /** Strictly positive integer */ + int size(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Cache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Cache.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Cache.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,26 @@ +//$Id: Cache.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.*; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Add caching strategy to a root entity or a collection + * + * @author Emmanuel Bernard + */ +(a)Target({TYPE, METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Cache { + /** concurrency strategy chosen */ + CacheConcurrencyStrategy usage(); + /** cache region name */ + String region() default ""; + /** + * whether or not lazy-properties are included in the second level cache + * default all, other value: non-lazy + */ + String include() default "all"; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/CacheConcurrencyStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/CacheConcurrencyStrategy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/CacheConcurrencyStrategy.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,15 @@ +//$Id: CacheConcurrencyStrategy.java 14736 2008-06-04 14:23:42Z hardy.fere= ntschik $ +package org.hibernate.annotations; + +/** + * Cache concurrency strategy + * + * @author Emmanuel Bernard + */ +public enum CacheConcurrencyStrategy { + NONE, + READ_ONLY, + NONSTRICT_READ_WRITE, + READ_WRITE, + TRANSACTIONAL +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/CacheModeType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/CacheModeType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/CacheModeType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,17 @@ +package org.hibernate.annotations; + +/** + * Enumeration for the different interaction modes between the session and + * the Level 2 Cache. + * + * @author Emmanuel Bernard + * @author Carlos Gonz=EF=BF=BDlez-Cadenas + */ + +public enum CacheModeType { + GET, + IGNORE, + NORMAL, + PUT, + REFRESH +} = \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Cascade.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Cascade.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Cascade.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,16 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Apply a cascade strategy on an association + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Cascade { + CascadeType[] value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/CascadeType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/CascadeType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/CascadeType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +package org.hibernate.annotations; + +/** + * Cascade types (can override default EJB3 cascades + */ +public enum CascadeType { + ALL, + PERSIST, + MERGE, + REMOVE, + REFRESH, + DELETE, + SAVE_UPDATE, + REPLICATE, + DELETE_ORPHAN, + LOCK, + EVICT +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Check.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Check.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Check.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +//$Id: Check.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.*; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Arbitrary SQL check constraints which can be defined at the class, + * property or collection level + * + * @author Emmanuel Bernard + */ +(a)Target({TYPE, METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Check { + String constraints(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/CollectionId.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/CollectionId.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/CollectionId.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,26 @@ +//$Id: CollectionId.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.FIELD; +import javax.persistence.Column; + +/** + * Describe an identifier column for a bag (ie an idbag) + * EXPERIMENTAL: the structure of this annotation might slightly change (g= enerator() mix strategy and generator + * = + * @author Emmanuel Bernard + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface CollectionId { + /** Collection id column(s) */ + Column[] columns(); + /** id type, type.type() must be set */ + Type type(); + /** generator name: 'identity' or a defined generator name */ + String generator(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/CollectionOfElements.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/CollectionOfElements.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/CollectionOfElements.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,28 @@ +//$Id: CollectionOfElements.java 14736 2008-06-04 14:23:42Z hardy.ferentsc= hik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; +import javax.persistence.FetchType; +import static javax.persistence.FetchType.LAZY; + +/** + * Annotation used to mark a collection as a collection of elements or + * a collection of embedded objects + * + * @author Emmanuel Bernard + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface CollectionOfElements { + /** + * Represent the element class in the collection + * Only useful if the collection does not use generics + */ + Class targetElement() default void.class; + + FetchType fetch() default LAZY; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Columns.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Columns.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Columns.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,20 @@ +//$Id: Columns.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; +import javax.persistence.Column; + +/** + * Support an array of columns. Useful for component user types mappings + * + * @author Emmanuel Bernard + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Columns { + Column[] columns(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/DiscriminatorFormula.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/DiscriminatorFormula.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/DiscriminatorFormula.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,20 @@ +//$Id: DiscriminatorFormula.java 14736 2008-06-04 14:23:42Z hardy.ferentsc= hik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Discriminator formula + * To be placed at the root entity. + * + * @author Emmanuel Bernard + * @see Formula + */ +(a)Target({TYPE}) +(a)Retention(RUNTIME) +public @interface DiscriminatorFormula { + String value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Entity.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Entity.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Entity.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,31 @@ +//$Id: Entity.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Extends {@link javax.persistence.Entity} with Hibernate features + * + * @author Emmanuel Bernard + */ +(a)Target(TYPE) +(a)Retention(RUNTIME) +public @interface Entity { + /** Is this entity mutable (read only) or not */ + boolean mutable() default true; + /** Needed column only in SQL on insert */ + boolean dynamicInsert() default false; + /** Needed column only in SQL on update */ + boolean dynamicUpdate() default false; + /** Do a select to retrieve the entity before any potential update */ + boolean selectBeforeUpdate() default false; + /** polymorphism strategy for this entity */ + PolymorphismType polymorphism() default PolymorphismType.IMPLICIT; + /** persister of this entity, default is hibernate internal one */ + String persister() default ""; + /** optimistic locking strategy */ + OptimisticLockType optimisticLock() default OptimisticLockType.VERSION; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Fetch.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Fetch.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Fetch.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +//$Id: Fetch.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Define the fetching strategy used for the given association + * + * @author Emmanuel Bernard + */ +(a)Target({ElementType.METHOD, ElementType.FIELD}) +(a)Retention(RetentionPolicy.RUNTIME) +public @interface Fetch { + FetchMode value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/FetchMode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FetchMode.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FetchMode.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,22 @@ +//$Id: FetchMode.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +/** + * Fetch options on associations + * + * @author Emmanuel Bernard + */ +public enum FetchMode { + /** + * use a select for each individual entity, collection, or join load + */ + SELECT, + /** + * use an outer join to load the related entities, collections or joins + */ + JOIN, + /** + * use a subselect query to load the additional collections + */ + SUBSELECT +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Filter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Filter.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Filter.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,22 @@ +//$Id: Filter.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.*; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Add filters to an entity or a target entity of a collection + * + * @author Emmanuel Bernard + * @author Matthew Inger + * @author Magnus Sandberg + */ +(a)Target({TYPE, METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Filter { + String name(); + + String condition() default ""; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/FilterDef.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FilterDef.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FilterDef.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,24 @@ +//$Id: FilterDef.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Filter definition + * + * @author Matthew Inger + * @author Emmanuel Bernard + */ +(a)Target({TYPE, PACKAGE}) +(a)Retention(RUNTIME) +public @interface FilterDef { + String name(); + + String defaultCondition() default ""; + + ParamDef[] parameters() default {}; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/FilterDefs.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FilterDefs.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FilterDefs.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,20 @@ +//$Id: FilterDefs.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Array of filter definitions + * + * @author Matthew Inger + * @author Emmanuel Bernard + */ +(a)Target({PACKAGE, TYPE}) +(a)Retention(RUNTIME) +public @interface FilterDefs { + FilterDef[] value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/FilterJoinTable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FilterJoinTable.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FilterJoinTable.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,20 @@ +//$Id: FilterJoinTable.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; + +/** + * Add filters to a join table collection + * + * @author Emmanuel Bernard + */ +(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) +(a)Retention(RetentionPolicy.RUNTIME) +public @interface FilterJoinTable { + String name(); + + String condition() default ""; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/FilterJoinTables.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FilterJoinTables.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FilterJoinTables.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +//$Id: FilterJoinTables.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; + +/** + * Add multiple @FilterJoinTable to a collection + * + * @author Emmanuel Bernard + */ +(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) +(a)Retention(RetentionPolicy.RUNTIME) +public @interface FilterJoinTables { + FilterJoinTable[] value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Filters.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Filters.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Filters.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,20 @@ +//$Id: Filters.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.*; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Add multiple @Filters + * + * @author Emmanuel Bernard + * @author Matthew Inger + * @author Magnus Sandberg + */ +(a)Target({TYPE, METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Filters { + Filter[] value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/FlushModeType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FlushModeType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/FlushModeType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,36 @@ +package org.hibernate.annotations; + +/** + * Enumeration extending javax.persistence flush modes. + * + * @author Carlos Gonz=EF=BF=BDlez-Cadenas + */ + +public enum FlushModeType { + /** + * see {@link org.hibernate.FlushMode.ALWAYS} + */ + ALWAYS, + /** + * see {@link org.hibernate.FlushMode.AUTO} + */ + AUTO, + /** + * see {@link org.hibernate.FlushMode.COMMIT} + */ + COMMIT, + /** + * see {@link org.hibernate.FlushMode.NEVER} + * @deprecated use MANUAL, will be removed in a subsequent release + */ + NEVER, + /** + * see {@link org.hibernate.FlushMode.MANUAL} + */ + MANUAL, + + /** + * Current flush mode of the persistence context at the time the query is= executed + */ + PERSISTENCE_CONTEXT +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/ForceDiscriminator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/ForceDiscriminator.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/ForceDiscriminator.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,16 @@ +//$Id: ForceDiscriminator.java 14736 2008-06-04 14:23:42Z hardy.ferentschi= k $ +package org.hibernate.annotations; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * ForceDiscriminator flag + * To be placed at the root entity near @DiscriminatorColumn or @Discrimin= atorFormula + * + * @author Serg Prasolov + */ +(a)Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) +public @interface ForceDiscriminator {} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/ForeignKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/ForeignKey.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/ForeignKey.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,29 @@ +//$Id: ForeignKey.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +(a)Target({FIELD, METHOD, TYPE}) +(a)Retention(RUNTIME) + +/** + * Define the foreign key name + */ +public @interface ForeignKey { + /** + * Name of the foreign key. Used in OneToMany, ManyToOne, and OneToOne + * relationships. Used for the owning side in ManyToMany relationships + */ + String name(); + + /** + * Used for the non-owning side of a ManyToMany relationship. Ignored + * in other relationships + */ + String inverseName() default ""; +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Formula.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Formula.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Formula.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Formula. To be used as a replacement for @Column in most places + * The formula has to be a valid SQL fragment + * + * @author Emmanuel Bernard + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Formula { + String value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Generated.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Generated.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Generated.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +//$Id: Generated.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; + +/** + * The annotated property is generated by the database + * + * @author Emmanuel Bernard + */ +(a)Target({ElementType.FIELD, ElementType.METHOD}) +(a)Retention(RetentionPolicy.RUNTIME) +public @interface Generated { + GenerationTime value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/GenerationTime.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/GenerationTime.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/GenerationTime.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,13 @@ +//$Id: GenerationTime.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +/** + * When should the generation occurs + * + * @author Emmanuel Bernard + */ +public enum GenerationTime { + NEVER, + INSERT, + ALWAYS +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/GenericGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/GenericGenerator.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/GenericGenerator.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,31 @@ +//$Id: GenericGenerator.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.*; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Generator annotation describing any kind of Hibernate + * generator in a detyped manner + * + * @author Emmanuel Bernard + */ +(a)Target({PACKAGE, TYPE, METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface GenericGenerator { + /** + * unique generator name + */ + String name(); + /** + * Generator strategy either a predefined Hibernate + * strategy or a fully qualified class name. + */ + String strategy(); + /** + * Optional generator parameters + */ + Parameter[] parameters() default {}; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/GenericGenerators.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/GenericGenerators.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/GenericGenerators.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,21 @@ +//$ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Array of generic generator definitions + * + * @author Paul Cowan + */ +(a)Target({PACKAGE, TYPE}) +(a)Retention(RUNTIME) +public @interface GenericGenerators { + GenericGenerator[] value(); +} + Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Immutable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Immutable.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Immutable.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,22 @@ +//$Id: Immutable.java 14801 2008-06-24 19:03:32Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.*; + +/** + * Mark an Entity or a Collection as immutable. No annotation means the el= ement is mutable. + *

+ * An immutable entity may not be updated by the application. Updates to a= n immutable + * entity will be ignored, but no exception is thrown. @Immutable mu= st be used on root entities only. = + *

+ *

+ * @Immutable placed on a collection makes the collection immutable, = meaning additions and = + * deletions to and from the collection are not allowed. A HibernateExc= eption is thrown in this case. = + *

+ * + * @author Emmanuel Bernard + */ +(a)java.lang.annotation.Target({ElementType.TYPE, ElementType.METHOD, Elem= entType.FIELD}) +(a)Retention( RetentionPolicy.RUNTIME ) +public @interface Immutable { +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Index.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Index.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Index.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,20 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Define a DB index + * + * @author Emmanuel Bernard + */ +(a)Target({FIELD, METHOD}) +(a)Retention(RUNTIME) +public @interface Index { + String name(); + + String[] columnNames() default {}; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/IndexColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/IndexColumn.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/IndexColumn.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,25 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Describe an index column of a List + * + * @author Matthew Inger + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface IndexColumn { + /** column name */ + String name(); + /** index in DB start from base */ + int base() default 0; + /** is the index nullable */ + boolean nullable() default true; + /** column definition, default to an appropriate integer */ + String columnDefinition() default ""; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/LazyCollection.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/LazyCollection.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/LazyCollection.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +//$Id: LazyCollection.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; + +/** + * Define the lazy status of a collection + * + * @author Emmanuel Bernard + */ +(a)Target({ElementType.METHOD, ElementType.FIELD}) +(a)Retention(RetentionPolicy.RUNTIME) +public @interface LazyCollection { + LazyCollectionOption value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/LazyCollectionOption.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/LazyCollectionOption.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/LazyCollectionOption.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,16 @@ +//$Id: LazyCollectionOption.java 14736 2008-06-04 14:23:42Z hardy.ferentsc= hik $ +package org.hibernate.annotations; + +/** + * Lazy options available for a collection + * + * @author Emmanuel Bernard + */ +public enum LazyCollectionOption { + /** eagerly load it */ + FALSE, + /** load it when the state is requested */ + TRUE, + /** prefer extra queries over fill collection loading */ + EXTRA +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/LazyToOne.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/LazyToOne.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/LazyToOne.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +//$Id: LazyToOne.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Define the lazy status of a ToOne association + * (ie OneToOne or ManyToOne) + * + * @author Emmanuel Bernard + */ +(a)Target({ElementType.METHOD, ElementType.FIELD}) +(a)Retention(RetentionPolicy.RUNTIME) +public @interface LazyToOne { + LazyToOneOption value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/LazyToOneOption.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/LazyToOneOption.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/LazyToOneOption.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,23 @@ +//$Id: LazyToOneOption.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +/** + * Lazy options available for a ToOne association + * + * @author Emmanuel Bernard + */ +public enum LazyToOneOption { + /** eagerly load the association */ + FALSE, + /** + * Lazy, give back a proxy which will be loaded when the state is request= ed + * This should be the prefered option + */ + PROXY, + /** Lazy, give back the real object loaded when a reference is requested + * (Bytecode enhancement is mandatory for this option, fall back to PROXY + * if the class is not enhanced) + * This option should be avoided unless you can't afford the use of proxi= es + */ + NO_PROXY +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Loader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Loader.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Loader.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,22 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Loader Annotation for overwriting Hibernate default FIND method + * + * @author L=EF=BF=BDszl=EF=BF=BD Benke + */ +(a)Target( {TYPE, FIELD, METHOD} ) +(a)Retention( RUNTIME ) +public @interface Loader { + /** + * namedQuery to use for loading + */ + String namedQuery() default ""; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/ManyToAny.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/ManyToAny.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/ManyToAny.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,41 @@ +//$Id: ManyToAny.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.FIELD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import javax.persistence.Column; +import javax.persistence.FetchType; +import static javax.persistence.FetchType.EAGER; + +/** + * Defined a ToMany association pointing to different entity types. + * Matching the according entity type is doe through a metadata discrimina= tor column + * This kind of mapping should be only marginal. + * + * @author Emmanuel Bernard + */ +(a)java.lang.annotation.Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface ManyToAny { + /** + * Metadata definition used. + * If defined, should point to a @AnyMetaDef name + * If not defined, the local (ie in the same field or property) @AnyMetaD= ef is used + */ + String metaDef() default ""; + + /** + * Metadata dicriminator column description, This column will hold the me= ta value corresponding to the + * targeted entity. + */ + Column metaColumn(); + /** + * Defines whether the value of the field or property should be lazily lo= aded or must be + * eagerly fetched. The EAGER strategy is a requirement on the persistenc= e provider runtime + * that the value must be eagerly fetched. The LAZY strategy is applied w= hen bytecode + * enhancement is used. If not specified, defaults to EAGER. + */ + FetchType fetch() default EAGER; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/MapKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/MapKey.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/MapKey.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,32 @@ +//$Id: MapKey.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.FIELD; +import javax.persistence.Column; + +/** + * Define the map key columns as an explicit column holding the map key + * This is completly different from {@link javax.persistence.MapKey} which= use an existing column + * This annotation and {@link javax.persistence.MapKey} are mutually exclu= sive + * + * @author Emmanuel Bernard + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface MapKey { + Column[] columns() default {}; + /** + * Represent the key class in a Map + * Only useful if the collection does not use generics + */ + Class targetElement() default void.class; + + /** + * The optional map key type. Guessed if default + */ + Type type() default @Type(type =3D ""); = +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/MapKeyManyToMany.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/MapKeyManyToMany.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/MapKeyManyToMany.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,26 @@ +//$Id: MapKeyManyToMany.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.persistence.JoinColumn; + +/** + * Define the map key columns as an explicit column holding the map key + * This is completly different from {@link javax.persistence.MapKey} which= use an existing column + * This annotation and {@link javax.persistence.MapKey} are mutually exclu= sive + * + * @author Emmanuel Bernard + */ +(a)Target({ElementType.METHOD, ElementType.FIELD}) +(a)Retention(RetentionPolicy.RUNTIME) +public @interface MapKeyManyToMany { + JoinColumn[] joinColumns() default {}; + /** + * Represent the key class in a Map + * Only useful if the collection does not use generics + */ + Class targetEntity() default void.class; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/MetaValue.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/MetaValue.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/MetaValue.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +//$Id: MetaValue.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +/** + * Represent a discriminator value associated to a given entity type + * @author Emmanuel Bernard + */ +public @interface MetaValue { + /** + * entity type + */ + Class targetEntity(); + + /** + * discriminator value stored in database + */ + String value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/NamedNativeQueries.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NamedNativeQueries.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NamedNativeQueries.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Extends {@link javax.persistence.NamedNativeQueries} to hold hibernate = NamedNativeQuery + * objects + * + * @author Emmanuel Bernard + */ +(a)Target({TYPE, PACKAGE}) +(a)Retention(RUNTIME) +public @interface NamedNativeQueries { + NamedNativeQuery[] value(); +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/NamedNativeQuery.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NamedNativeQuery.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NamedNativeQuery.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,42 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Extends {@link javax.persistence.NamedNativeQuery} with Hibernate featu= res + * + * @author Emmanuel Bernard + */ +(a)Target({TYPE, PACKAGE}) +(a)Retention(RUNTIME) +public @interface NamedNativeQuery { + String name(); + + String query(); + + Class resultClass() default void.class; + + String resultSetMapping() default ""; // name of SQLResultSetMapping + /** the flush mode for the query */ + FlushModeType flushMode() default FlushModeType.PERSISTENCE_CONTEXT; + /** mark the query as cacheable or not */ + boolean cacheable() default false; + /** the cache region to use */ + String cacheRegion() default ""; + /** the number of rows fetched by the JDBC Driver per roundtrip */ + int fetchSize() default -1; + /**the query timeout in seconds*/ + int timeout() default -1; + + boolean callable() default false; + /**comment added to the SQL query, useful for the DBA */ + String comment() default ""; + /**the cache mode used for this query*/ + CacheModeType cacheMode() default CacheModeType.NORMAL; + /**marks whether the results are fetched in read-only mode or not*/ + boolean readOnly() default false; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/NamedQueries.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NamedQueries.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NamedQueries.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,20 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Extends {@link javax.persistence.NamedQueries} to hold hibernate NamedQ= uery + * objects + * + * @author Emmanuel Bernard + * @author Carlos Gonz=EF=BF=BDlez-Cadenas + */ +(a)Target({TYPE, PACKAGE}) +(a)Retention(RUNTIME) +public @interface NamedQueries { + NamedQuery[] value(); +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/NamedQuery.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NamedQuery.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NamedQuery.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,40 @@ +//$Id: NamedQuery.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Extends {@link javax.persistence.NamedQuery} with Hibernate features + * + * @author Carlos Gonz=EF=BF=BDlez-Cadenas + */ +(a)Target({TYPE, PACKAGE}) +(a)Retention(RUNTIME) +public @interface NamedQuery { + + /** the name of the NamedQuery */ + String name(); + /** the Query String for the NamedQuery */ + String query(); + /** the flush mode for the query */ + FlushModeType flushMode() default FlushModeType.PERSISTENCE_CONTEXT; + /** mark the query as cacheable or not */ + boolean cacheable() default false; + /** the cache region to use */ + String cacheRegion() default ""; + /** the number of rows fetched by the JDBC Driver per roundtrip */ + int fetchSize() default -1; + /**the query timeout in seconds*/ + int timeout() default -1; + /**comment added to the SQL query, useful for the DBA */ + String comment() default ""; + /**the cache mode used for this query*/ + CacheModeType cacheMode() default CacheModeType.NORMAL; + /**marks whether the results are fetched in read-only mode or not*/ + boolean readOnly() default false; + +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/NaturalId.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NaturalId.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NaturalId.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,22 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + + +/** + * This specifies that a property is part of the natural id of the entity. + * + * @author Nicol=EF=BF=BDs Lichtmaier + */ +(a)Target( { METHOD, FIELD } ) +(a)Retention( RUNTIME ) +public @interface NaturalId { + /** + * If this natural id component is mutable or not. + */ + boolean mutable() default false; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/NotFound.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NotFound.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NotFound.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Action to do when an element is not found on a association whiel beeing= expected + * + * @author Emmanuel Bernard + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface NotFound { + NotFoundAction action() default NotFoundAction.EXCEPTION; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/NotFoundAction.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NotFoundAction.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/NotFoundAction.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,17 @@ +package org.hibernate.annotations; + +/** + * Actoin to use when an element is not found in DB while beeing expected + * + * @author Emmanuel Bernard + */ +public enum NotFoundAction { + /** + * raise an exception when an element is not found (default and recommend= ed) + */ + EXCEPTION, + /** + * ignore the element when not found in DB + */ + IGNORE +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/OnDelete.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/OnDelete.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/OnDelete.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.*; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + + +/** + * Strategy to use on collections, arrays and on joined subclasses delete + * OnDelete of secondary tables currently not supported. + * + * @author Emmanuel Bernard + */ +(a)Target({METHOD, FIELD, TYPE}) +(a)Retention(RUNTIME) +public @interface OnDelete { + OnDeleteAction action(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/OnDeleteAction.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/OnDeleteAction.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/OnDeleteAction.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,17 @@ +package org.hibernate.annotations; + +/** + * Possible actions on deletes + * + * @author Emmanuel Bernard + */ +public enum OnDeleteAction { + /** + * the default + */ + NO_ACTION, + /** + * use cascade delete capabilities of the DD + */ + CASCADE +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/OptimisticLock.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/OptimisticLock.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/OptimisticLock.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,24 @@ +//$Id: OptimisticLock.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Whether or not update entity's version on property's change + * If the annotation is not present, the property is involved in the optim= istic lock srategy (default) + * + * @author Logi Ragnarsson + */ +(a)Target( {ElementType.METHOD, ElementType.FIELD} ) +(a)Retention( RetentionPolicy.RUNTIME ) +public @interface OptimisticLock { + + /** + * If true, the annotated property change will not trigger a version upgr= ade + */ + boolean excluded(); + +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/OptimisticLockType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/OptimisticLockType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/OptimisticLockType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,27 @@ +//$Id: OptimisticLockType.java 14736 2008-06-04 14:23:42Z hardy.ferentschi= k $ +package org.hibernate.annotations; + +/** + * Optimistic locking strategy + * VERSION is the default and recommanded one + * + * @author Emmanuel Bernard + */ +public enum OptimisticLockType { + /** + * no optimistic locking + */ + NONE, + /** + * use a column version + */ + VERSION, + /** + * dirty columns are compared + */ + DIRTY, + /** + * all columns are compared + */ + ALL +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/OrderBy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/OrderBy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/OrderBy.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Order a collection using SQL ordering (not HQL ordering) + * + * @author Emmanuel Bernard + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface OrderBy { + /** SQL orderby clause */ + String clause(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/ParamDef.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/ParamDef.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/ParamDef.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +//$Id: ParamDef.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * A parameter definition + * + * @author Emmanuel Bernard + */ +(a)Target({}) +(a)Retention(RUNTIME) +public @interface ParamDef { + String name(); + + String type(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Parameter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Parameter.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Parameter.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +//$Id: Parameter.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Parameter (basically key/value pattern) + * + * @author Emmanuel Bernard + */ +(a)Target({}) +(a)Retention(RUNTIME) +public @interface Parameter { + String name(); + + String value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Parent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Parent.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Parent.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +//$Id: Parent.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Reference the property as a pointer back to the owner (generally the ow= ning entity) + * = + * @author Emmanuel Bernard + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Parent { +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Persister.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Persister.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Persister.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,16 @@ +//$Id: Persister.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.*; + +/** + * Specify a custom persister. + * + * @author Shawn Clowater + */ +(a)java.lang.annotation.Target({ElementType.TYPE, ElementType.METHOD, Elem= entType.FIELD}) +(a)Retention( RetentionPolicy.RUNTIME ) +public @interface Persister { + /** Custom persister */ + Class impl(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/PolymorphismType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/PolymorphismType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/PolymorphismType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +//$Id: PolymorphismType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +/** + * Type of avaliable polymorphism for a particular entity + * + * @author Emmanuel Bernard + */ +public enum PolymorphismType { + /** + * default, this entity is retrieved if any of its super entity is asked + */ + IMPLICIT, + /** + * this entity is retrived only if explicitly asked + */ + EXPLICIT +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Proxy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Proxy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Proxy.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,26 @@ +//$Id: Proxy.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Lazy and proxy configuration of a particular class + * + * @author Emmanuel Bernard + */ +(a)Target(TYPE) +(a)Retention(RUNTIME) +public @interface Proxy { + /** + * Whether this class is lazy or not (default to true) + */ + boolean lazy() default true; + + /** + * Proxy class or interface used. Default entity class name. + */ + Class proxyClass() default void.class; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/ResultCheckStyle.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/ResultCheckStyle.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/ResultCheckStyle.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,31 @@ +//$Id: +package org.hibernate.annotations; + +/** + * Possible checks on Sql Insert, Delete, Update + * + * @author L=EF=BF=BDszl=EF=BF=BD Benke + */ +public enum ResultCheckStyle { + /** + * Do not perform checking. Either user simply does not want checking, o= r is + * indicating a {@link java.sql.CallableStatement} execution in which the + * checks are being performed explicitly and failures are handled through + * propogation of {@link java.sql.SQLException}s. + */ + NONE, + /** + * Perform row-count checking. Row counts are the int values returned by= both + * {@link java.sql.PreparedStatement#executeUpdate()} and + * {@link java.sql.Statement#executeBatch()}. These values are checked + * against some expected count. + */ + COUNT, + /** + * Essentially the same as {@link #COUNT} except that the row count actua= lly + * comes from an output parameter registered as part of a + * {@link java.sql.CallableStatement}. This style explicitly prohibits + * statement batching from being used... + */ + PARAM +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/SQLDelete.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/SQLDelete.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/SQLDelete.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,33 @@ +//$Id: SQLDelete.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * SqlDelete Annotation for overwriting Hibernate default DELETE method + * + * @author L=EF=BF=BDszl=EF=BF=BD Benke + */ +(a)Target( {TYPE, FIELD, METHOD} ) +(a)Retention( RUNTIME ) +public @interface SQLDelete { + /** + * Procedure name or DELETE STATEMENT + */ + String sql(); + + /** + * Is the statement using stored procedure or not + */ + boolean callable() default false; + + /** + * For persistence operation what style of determining results (success/f= ailure) is to be used. + */ + ResultCheckStyle check() default ResultCheckStyle.NONE; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/SQLDeleteAll.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/SQLDeleteAll.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/SQLDeleteAll.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,34 @@ +//$Id: SQLDeleteAll.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * SqlDelete Annotation for overwriting Hibernate default DELETE ALL method + * + * @author L=EF=BF=BDszl=EF=BF=BD Benke + */ +(a)Target( {TYPE, FIELD, METHOD} ) +(a)Retention( RetentionPolicy.RUNTIME ) +public @interface SQLDeleteAll { + /** + * Procedure name or DELETE STATEMENT + */ + String sql(); + + /** + * Is the statement using stored procedure or not + */ + boolean callable() default false; + + /** + * For persistence operation what style of determining results (success/f= ailure) is to be used. + */ + ResultCheckStyle check() default ResultCheckStyle.NONE; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/SQLInsert.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/SQLInsert.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/SQLInsert.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,33 @@ +//$Id: SQLInsert.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * SqlInsert Annotation for overwriting Hibernate default INSERT INTO meth= od + * + * @author L=EF=BF=BDszl=EF=BF=BD Benke + */ +(a)Target( {TYPE, FIELD, METHOD} ) +(a)Retention( RUNTIME ) +public @interface SQLInsert { + /** + * Procedure name or INSERT STATEMENT + */ + String sql(); + + /** + * Is the statement using stored procedure or not + */ + boolean callable() default false; + + /** + * For persistence operation what style of determining results (success/f= ailure) is to be used. + */ + ResultCheckStyle check() default ResultCheckStyle.NONE; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/SQLUpdate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/SQLUpdate.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/SQLUpdate.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,34 @@ +//$Id: SQLUpdate.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * SqlUpdate Annotation for overwriting Hibernate default UPDATE method + * + * @author L=EF=BF=BDszl=EF=BF=BD Benke + */ +(a)Target( {TYPE, FIELD, METHOD} ) +(a)Retention( RUNTIME ) +public @interface SQLUpdate { + + /** + * Procedure name or UPDATE STATEMENT + */ + String sql(); + + /** + * Is the statement using stored procedure or not + */ + boolean callable() default false; + + /** + * For persistence operation what style of determining results (success/f= ailure) is to be used. + */ + ResultCheckStyle check() default ResultCheckStyle.NONE; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Sort.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Sort.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Sort.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,29 @@ +//$Id: Sort.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Collection sort + * (Java level sorting) + * + * @author Emmanuel Bernard + */ +(a)Target({METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Sort { + /** + * sort type + */ + SortType type() default SortType.UNSORTED; + /** + * Sort comparator implementation + */ + //TODO find a way to use Class + + Class comparator() default void.class; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/SortType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/SortType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/SortType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,13 @@ +//$Id: SortType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +/** + * Sort strategies + * + * @author Emmanuel Bernard + */ +public enum SortType { + UNSORTED, + NATURAL, + COMPARATOR +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Table.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Table.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Table.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,86 @@ +//$Id: Table.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Complementary information to a table either primary or secondary + * + * @author Emmanuel Bernard + */ +(a)Target({TYPE}) +(a)Retention(RUNTIME) +public @interface Table { + /** + * name of the targeted table + */ + String appliesTo(); + + /** + * Indexes + */ + Index[] indexes() default {}; + + /** + * define a table comment + */ + String comment() default ""; + + /** + * Defines the Foreign Key name of a secondary table + * pointing back to the primary table + */ + ForeignKey foreignKey() default @ForeignKey( name=3D"" ); + + /** + * If set to JOIN, the default, Hibernate will use an inner join to retri= eve a + * secondary table defined by a class or its superclasses and an outer jo= in for a + * secondary table defined by a subclass. + * If set to select then Hibernate will use a + * sequential select for a secondary table defined on a subclass, which w= ill be issued only if a row + * turns out to represent an instance of the subclass. Inner joins will s= till be used to retrieve a + * secondary defined by the class and its superclasses. + * + * Only applies to secondary tables + */ + FetchMode fetch() default FetchMode.JOIN; + + /** + * If true, Hibernate will not try to insert or update the properties def= ined by this join. + * + * Only applies to secondary tables + */ + boolean inverse() default false; + + /** + * If enabled, Hibernate will insert a row only if the properties defined= by this join are non-null + * and will always use an outer join to retrieve the properties. + * + * Only applies to secondary tables + */ + boolean optional() default true; + + /** + * Defines a custom SQL insert statement + * + * Only applies to secondary tables + */ + SQLInsert sqlInsert() default @SQLInsert(sql=3D""); + + /** + * Defines a custom SQL update statement + * + * Only applies to secondary tables + */ + SQLUpdate sqlUpdate() default @SQLUpdate(sql=3D""); + + /** + * Defines a custom SQL delete statement + * + * Only applies to secondary tables + */ + SQLDelete sqlDelete() default @SQLDelete(sql=3D""); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Tables.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Tables.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Tables.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Plural of Table + * + * @author Emmanuel Bernard + * @see Table + */ +(a)Target({TYPE}) +(a)Retention(RUNTIME) +public @interface Tables { + Table[] value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Target.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Target.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Target.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,17 @@ +//$Id: Target.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Retention; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; + +/** + * Define an explicit target,a voiding reflection and generics resolving + * + * @author Emmanuel Bernard + */ +(a)java.lang.annotation.Target({ElementType.FIELD, ElementType.METHOD}) +(a)Retention( RetentionPolicy.RUNTIME ) +public @interface Target { + Class value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Tuplizer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Tuplizer.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Tuplizer.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,21 @@ +//$Id: Tuplizer.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; + +/** + * Define a tuplizer for an entity or a component + * @author Emmanuel Bernard + */ +(a)java.lang.annotation.Target( {TYPE, FIELD, METHOD} ) +(a)Retention( RUNTIME ) +public @interface Tuplizer { + /** tuplizer implementation */ + Class impl(); + /** either pojo, dynamic-map or dom4j=EF=BF=BD */ + String entityMode() default "pojo"; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Tuplizers.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Tuplizers.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Tuplizers.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,16 @@ +//$Id: Tuplizers.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Retention; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; + +/** + * Define a set of tuplizer for an entity or a component + * @author Emmanuel Bernard + */ +(a)java.lang.annotation.Target( {ElementType.TYPE, ElementType.FIELD, Elem= entType.METHOD} ) +(a)Retention( RetentionPolicy.RUNTIME ) +public @interface Tuplizers { + Tuplizer[] value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Type.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Type.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Type.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,21 @@ +//$Id: Type.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * hibernate type + * + * @author Emmanuel Bernard + */ +(a)Target({FIELD, METHOD}) +(a)Retention(RUNTIME) +public @interface Type { + String type(); + + Parameter[] parameters() default {}; +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/TypeDef.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/TypeDef.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/TypeDef.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,23 @@ +//$Id: TypeDef.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Type definition + * + * @author Emmanuel Bernard + */ +(a)Target({TYPE, PACKAGE}) +(a)Retention(RUNTIME) +public @interface TypeDef { + String name(); + + Class typeClass(); + + Parameter[] parameters() default {}; +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/TypeDefs.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/TypeDefs.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/TypeDefs.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +//$Id: TypeDefs.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Type definition array + * + * @author Emmanuel Bernard + */ +(a)Target({TYPE, PACKAGE}) +(a)Retention(RUNTIME) +public @interface TypeDefs { + TypeDef[] value(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/Where.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Where.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/Where.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,18 @@ +package org.hibernate.annotations; + +import static java.lang.annotation.ElementType.*; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; + +/** + * Where clause to add to the element Entity or target entity of a collect= ion + * The clause is written in SQL + * + * @author Emmanuel Bernard + */ +(a)Target({TYPE, METHOD, FIELD}) +(a)Retention(RUNTIME) +public @interface Where { + String clause(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annota= tions/WhereJoinTable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/WhereJoinTable.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/annotatio= ns/WhereJoinTable.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +//$Id: WhereJoinTable.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.annotations; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; + +/** + * Where clause to add to the colleciton join table + * The clause is written in SQL + * + * @author Emmanuel Bernard + */ +(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) +(a)Retention(RetentionPolicy.RUNTIME) +public @interface WhereJoinTable { + String clause(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ab= stractPropertyHolder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Abstr= actPropertyHolder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Abstr= actPropertyHolder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,188 @@ +//$Id: AbstractPropertyHolder.java 14736 2008-06-04 14:23:42Z hardy.ferent= schik $ +package org.hibernate.cfg; + +import java.util.HashMap; +import java.util.Map; +import javax.persistence.AssociationOverride; +import javax.persistence.AssociationOverrides; +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; +import javax.persistence.Embeddable; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.MappedSuperclass; + +import org.hibernate.AssertionFailure; +import org.hibernate.annotations.common.reflection.XAnnotatedElement; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.util.StringHelper; + +/** + * @author Emmanuel Bernard + */ +public abstract class AbstractPropertyHolder implements PropertyHolder { + protected PropertyHolder parent; + private Map holderColumnOverride; + private Map currentPropertyColumnOverride; + private Map holderJoinColumnOverride; + private Map currentPropertyJoinColumnOverride; + private String path; + private ExtendedMappings mappings; + + public AbstractPropertyHolder( + String path, PropertyHolder parent, XClass clazzToProcess, ExtendedMapp= ings mappings + ) { + this.path =3D path; + this.parent =3D parent; + this.mappings =3D mappings; + buildHierarchyColumnOverride( clazzToProcess ); + } + + public String getPath() { + return path; + } + + /** + * property can be null + */ + protected void setCurrentProperty(XProperty property) { + if ( property =3D=3D null ) { + this.currentPropertyColumnOverride =3D null; + this.currentPropertyJoinColumnOverride =3D null; + } + else { + this.currentPropertyColumnOverride =3D buildColumnOverride( + property, + getPath() + ); + if ( this.currentPropertyColumnOverride.size() =3D=3D 0 ) { + this.currentPropertyColumnOverride =3D null; + } + this.currentPropertyJoinColumnOverride =3D buildJoinColumnOverride( + property, + getPath() + ); + if ( this.currentPropertyJoinColumnOverride.size() =3D=3D 0 ) { + this.currentPropertyJoinColumnOverride =3D null; + } + } + } + + /** + * Get column overriding, property first, then parent, then holder + */ + public Column[] getOverriddenColumn(String propertyName) { + Column[] override =3D null; + if ( parent !=3D null ) { + override =3D parent.getOverriddenColumn( propertyName ); + } + if ( override =3D=3D null && currentPropertyColumnOverride !=3D null ) { + override =3D currentPropertyColumnOverride.get( propertyName ); + } + if ( override =3D=3D null && holderColumnOverride !=3D null ) { + override =3D holderColumnOverride.get( propertyName ); + } + return override; + } + + /** + * Get column overriding, property first, then parent, then holder + */ + public JoinColumn[] getOverriddenJoinColumn(String propertyName) { + JoinColumn[] override =3D null; + if ( parent !=3D null ) { + override =3D parent.getOverriddenJoinColumn( propertyName ); + } + if ( override =3D=3D null && currentPropertyJoinColumnOverride !=3D null= ) { + override =3D currentPropertyJoinColumnOverride.get( propertyName ); + } + if ( override =3D=3D null && holderJoinColumnOverride !=3D null ) { + override =3D holderJoinColumnOverride.get( propertyName ); + } + return override; + } + + private void buildHierarchyColumnOverride(XClass element) { + XClass current =3D element; + Map columnOverride =3D new HashMap(); + Map joinColumnOverride =3D new HashMap(); + while ( current !=3D null && !mappings.getReflectionManager().toXClass( = Object.class ).equals( current ) ) { + if ( current.isAnnotationPresent( Entity.class ) || current.isAnnotatio= nPresent( MappedSuperclass.class ) + || current.isAnnotationPresent( Embeddable.class ) ) { + //FIXME is embeddable override? + Map currentOverride =3D buildColumnOverride( current= , getPath() ); + Map currentJoinOverride =3D buildJoinColumnOverr= ide( current, getPath() ); + currentOverride.putAll( columnOverride ); //subclasses have precedence= over superclasses + currentJoinOverride.putAll( joinColumnOverride ); //subclasses have pr= ecedence over superclasses + columnOverride =3D currentOverride; + joinColumnOverride =3D currentJoinOverride; + } + current =3D current.getSuperclass(); + } + + holderColumnOverride =3D columnOverride.size() > 0 ? columnOverride : nu= ll; + holderJoinColumnOverride =3D joinColumnOverride.size() > 0 ? joinColumnO= verride : null; + } + + private static Map buildColumnOverride(XAnnotatedElemen= t element, String path) { + Map columnOverride =3D new HashMap(); + if ( element =3D=3D null ) return columnOverride; + AttributeOverride singleOverride =3D element.getAnnotation( AttributeOve= rride.class ); + AttributeOverrides multipleOverrides =3D element.getAnnotation( Attribut= eOverrides.class ); + AttributeOverride[] overrides; + if ( singleOverride !=3D null ) { + overrides =3D new AttributeOverride[] { singleOverride }; + } + else if ( multipleOverrides !=3D null ) { + overrides =3D multipleOverrides.value(); + } + else { + overrides =3D null; + } + + //fill overriden columns + if ( overrides !=3D null ) { + for (AttributeOverride depAttr : overrides) { + columnOverride.put( + StringHelper.qualify( path, depAttr.name() ), + new Column[] { depAttr.column() } + ); + } + } + return columnOverride; + } + + private static Map buildJoinColumnOverride(XAnnotat= edElement element, String path) { + Map columnOverride =3D new HashMap(); + if ( element =3D=3D null ) return columnOverride; + AssociationOverride singleOverride =3D element.getAnnotation( Associatio= nOverride.class ); + AssociationOverrides multipleOverrides =3D element.getAnnotation( Associ= ationOverrides.class ); + AssociationOverride[] overrides; + if ( singleOverride !=3D null ) { + overrides =3D new AssociationOverride[] { singleOverride }; + } + else if ( multipleOverrides !=3D null ) { + overrides =3D multipleOverrides.value(); + } + else { + overrides =3D null; + } + + //fill overriden columns + if ( overrides !=3D null ) { + for (AssociationOverride depAttr : overrides) { + columnOverride.put( + StringHelper.qualify( path, depAttr.name() ), + depAttr.joinColumns() + ); + } + } + return columnOverride; + } + + public void setParentProperty(String parentProperty) { + throw new AssertionFailure( "Setting the parent property to a non compon= ent" ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/An= notatedClassType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Annot= atedClassType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Annot= atedClassType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,25 @@ +package org.hibernate.cfg; + +/** + * Type of annotation of a class will give its type + * + * @author Emmanuel Bernard + */ +public enum AnnotatedClassType { + /** + * has no revelent top level annotation + */ + NONE, + /** + * has @Entity annotation + */ + ENTITY, + /** + * has a @Embeddable annotation + */ + EMBEDDABLE, + /** + * has @EmbeddedSuperclass annotation + */ + EMBEDDABLE_SUPERCLASS +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/An= notationBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Annot= ationBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Annot= ationBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,2321 @@ +//$Id: AnnotationBinder.java 14786 2008-06-19 14:59:11Z hardy.ferentschik $ +package org.hibernate.cfg; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.DiscriminatorType; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Embeddable; +import javax.persistence.Embedded; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.MapKey; +import javax.persistence.MappedSuperclass; +import javax.persistence.NamedNativeQueries; +import javax.persistence.NamedNativeQuery; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.PrimaryKeyJoinColumns; +import javax.persistence.SequenceGenerator; +import javax.persistence.SqlResultSetMapping; +import javax.persistence.SqlResultSetMappings; +import javax.persistence.Table; +import javax.persistence.TableGenerator; +import javax.persistence.Transient; +import javax.persistence.Version; + +import org.hibernate.AnnotationException; +import org.hibernate.AssertionFailure; +import org.hibernate.EntityMode; +import org.hibernate.FetchMode; +import org.hibernate.MappingException; +import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.BatchSize; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.Cascade; +import org.hibernate.annotations.CascadeType; +import org.hibernate.annotations.Check; +import org.hibernate.annotations.CollectionId; +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.Columns; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.Filter; +import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.FilterDefs; +import org.hibernate.annotations.Filters; +import org.hibernate.annotations.ForeignKey; +import org.hibernate.annotations.Formula; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Index; +import org.hibernate.annotations.LazyToOne; +import org.hibernate.annotations.LazyToOneOption; +import org.hibernate.annotations.ManyToAny; +import org.hibernate.annotations.MapKeyManyToMany; +import org.hibernate.annotations.NaturalId; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; +import org.hibernate.annotations.OrderBy; +import org.hibernate.annotations.ParamDef; +import org.hibernate.annotations.Parameter; +import org.hibernate.annotations.Parent; +import org.hibernate.annotations.Proxy; +import org.hibernate.annotations.Sort; +import org.hibernate.annotations.Target; +import org.hibernate.annotations.Tuplizer; +import org.hibernate.annotations.Tuplizers; +import org.hibernate.annotations.Type; +import org.hibernate.annotations.TypeDef; +import org.hibernate.annotations.TypeDefs; +import org.hibernate.annotations.Where; +import org.hibernate.annotations.GenericGenerators; +import org.hibernate.annotations.common.reflection.ReflectionManager; +import org.hibernate.annotations.common.reflection.XAnnotatedElement; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XPackage; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.cfg.annotations.CollectionBinder; +import org.hibernate.cfg.annotations.EntityBinder; +import org.hibernate.cfg.annotations.Nullability; +import org.hibernate.cfg.annotations.PropertyBinder; +import org.hibernate.cfg.annotations.QueryBinder; +import org.hibernate.cfg.annotations.SimpleValueBinder; +import org.hibernate.cfg.annotations.TableBinder; +import org.hibernate.engine.FilterDefinition; +import org.hibernate.engine.Versioning; +import org.hibernate.id.MultipleHiLoPerTableGenerator; +import org.hibernate.id.PersistentIdentifierGenerator; +import org.hibernate.id.SequenceHiLoGenerator; +import org.hibernate.id.TableHiLoGenerator; +import org.hibernate.mapping.Any; +import org.hibernate.mapping.Component; +import org.hibernate.mapping.DependantValue; +import org.hibernate.mapping.IdGenerator; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.JoinedSubclass; +import org.hibernate.mapping.KeyValue; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.RootClass; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.SingleTableSubclass; +import org.hibernate.mapping.Subclass; +import org.hibernate.mapping.ToOne; +import org.hibernate.mapping.UnionSubclass; +import org.hibernate.persister.entity.JoinedSubclassEntityPersister; +import org.hibernate.persister.entity.SingleTableEntityPersister; +import org.hibernate.persister.entity.UnionSubclassEntityPersister; +import org.hibernate.type.TypeFactory; +import org.hibernate.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * JSR 175 annotation binder + * Will read the annotation from classes, apply the + * principles of the EJB3 spec and produces the Hibernate + * configuration-time metamodel (the classes in the mapping + * package) + * + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("unchecked") +public final class AnnotationBinder { + + /* + * Some design description + * I tried to remove any link to annotation except from the 2 first level= of + * method call. + * It'll enable to: + * - facilitate annotation overriding + * - mutualize one day xml and annotation binder (probably a dream thou= gh) + * - split this huge class in smaller mapping oriented classes + * + * bindSomething usually create the mapping container and is accessed by = one of the 2 first level method + * makeSomething usually create the mapping container and is accessed by = bindSomething[else] + * fillSomething take the container into parameter and fill it. + * + * + */ + private AnnotationBinder() { + } + + private static final Logger log =3D LoggerFactory.getLogger( AnnotationBi= nder.class ); + + public static void bindDefaults(ExtendedMappings mappings) { + Map defaults =3D mappings.getReflectionManager().getDefaults(); + { + List anns =3D (List) defaults.get= ( SequenceGenerator.class ); + if ( anns !=3D null ) { + for (SequenceGenerator ann : anns) { + IdGenerator idGen =3D buildIdGenerator( ann, mappings ); + if ( idGen !=3D null ) mappings.addDefaultGenerator( idGen ); + } + } + } + { + List anns =3D (List) defaults.get( Tabl= eGenerator.class ); + if ( anns !=3D null ) { + for (TableGenerator ann : anns) { + IdGenerator idGen =3D buildIdGenerator( ann, mappings ); + if ( idGen !=3D null ) mappings.addDefaultGenerator( idGen ); + } + } + } + { + List anns =3D (List) defaults.get( NamedQuery.c= lass ); + if ( anns !=3D null ) { + for (NamedQuery ann : anns) { + QueryBinder.bindQuery( ann, mappings, true ); + } + } + } + { + List anns =3D (List) defaults.get( = NamedNativeQuery.class ); + if ( anns !=3D null ) { + for (NamedNativeQuery ann : anns) { + QueryBinder.bindNativeQuery( ann, mappings, true ); + } + } + } + { + List anns =3D (List) defaults= .get( SqlResultSetMapping.class ); + if ( anns !=3D null ) { + for (SqlResultSetMapping ann : anns) { + QueryBinder.bindSqlResultsetMapping( ann, mappings, true ); + } + } + } + } + + public static void bindPackage(String packageName, ExtendedMappings mappi= ngs) { + XPackage pckg =3D null; + try { + pckg =3D mappings.getReflectionManager().packageForName( packageName ); + } + catch (ClassNotFoundException cnf) { + log.warn( "Package not found or wo package-info.java: {}", packageName = ); + return; + } + if ( pckg.isAnnotationPresent( SequenceGenerator.class ) ) { + SequenceGenerator ann =3D pckg.getAnnotation( SequenceGenerator.class ); + IdGenerator idGen =3D buildIdGenerator( ann, mappings ); + mappings.addGenerator( idGen ); + log.debug( "Add sequence generator with name: {}", idGen.getName() ); + } + if ( pckg.isAnnotationPresent( TableGenerator.class ) ) { + TableGenerator ann =3D pckg.getAnnotation( TableGenerator.class ); + IdGenerator idGen =3D buildIdGenerator( ann, mappings ); + mappings.addGenerator( idGen ); + + } + bindGenericGenerators(pckg, mappings); + bindQueries( pckg, mappings ); + bindFilterDefs( pckg, mappings ); + bindTypeDefs( pckg, mappings ); + BinderHelper.bindAnyMetaDefs( pckg, mappings ); + } + + private static void bindGenericGenerators(XAnnotatedElement annotatedElem= ent, ExtendedMappings mappings) { + GenericGenerator defAnn =3D annotatedElement.getAnnotation( GenericGener= ator.class ); + GenericGenerators defsAnn =3D annotatedElement.getAnnotation( GenericGen= erators.class ); + if ( defAnn !=3D null ) { + bindGenericGenerator( defAnn, mappings ); + } + if ( defsAnn !=3D null ) { + for (GenericGenerator def : defsAnn.value() ) { + bindGenericGenerator( def, mappings ); + } + } + } + + private static void bindGenericGenerator(GenericGenerator def, ExtendedMa= ppings mappings) { + IdGenerator idGen =3D buildIdGenerator( def, mappings ); + mappings.addGenerator( idGen ); + } + + private static void bindQueries(XAnnotatedElement annotatedElement, Exten= dedMappings mappings) { + { + SqlResultSetMapping ann =3D annotatedElement.getAnnotation( SqlResultSe= tMapping.class ); + QueryBinder.bindSqlResultsetMapping( ann, mappings, false ); + } + { + SqlResultSetMappings ann =3D annotatedElement.getAnnotation( SqlResultS= etMappings.class ); + if ( ann !=3D null ) { + for (SqlResultSetMapping current : ann.value()) { + QueryBinder.bindSqlResultsetMapping( current, mappings, false ); + } + } + } + { + NamedQuery ann =3D annotatedElement.getAnnotation( NamedQuery.class ); + QueryBinder.bindQuery( ann, mappings, false ); + } + { + org.hibernate.annotations.NamedQuery ann =3D annotatedElement.getAnnota= tion( + org.hibernate.annotations.NamedQuery.class + ); + QueryBinder.bindQuery( ann, mappings ); + } + { + NamedQueries ann =3D annotatedElement.getAnnotation( NamedQueries.class= ); + QueryBinder.bindQueries( ann, mappings, false ); + } + { + org.hibernate.annotations.NamedQueries ann =3D annotatedElement.getAnno= tation( + org.hibernate.annotations.NamedQueries.class + ); + QueryBinder.bindQueries( ann, mappings ); + } + { + NamedNativeQuery ann =3D annotatedElement.getAnnotation( NamedNativeQue= ry.class ); + QueryBinder.bindNativeQuery( ann, mappings, false ); + } + { + org.hibernate.annotations.NamedNativeQuery ann =3D annotatedElement.get= Annotation( + org.hibernate.annotations.NamedNativeQuery.class + ); + QueryBinder.bindNativeQuery( ann, mappings ); + } + { + NamedNativeQueries ann =3D annotatedElement.getAnnotation( NamedNativeQ= ueries.class ); + QueryBinder.bindNativeQueries( ann, mappings, false ); + } + { + org.hibernate.annotations.NamedNativeQueries ann =3D annotatedElement.g= etAnnotation( + org.hibernate.annotations.NamedNativeQueries.class + ); + QueryBinder.bindNativeQueries( ann, mappings ); + } + } + + private static IdGenerator buildIdGenerator(java.lang.annotation.Annotati= on ann, Mappings mappings) { + IdGenerator idGen =3D new IdGenerator(); + if ( mappings.getSchemaName() !=3D null ) { + idGen.addParam( PersistentIdentifierGenerator.SCHEMA, mappings.getSchem= aName() ); + } + if ( mappings.getCatalogName() !=3D null ) { + idGen.addParam( PersistentIdentifierGenerator.CATALOG, mappings.getCata= logName() ); + } + if ( ann =3D=3D null ) { + idGen =3D null; + } + else if ( ann instanceof TableGenerator ) { + TableGenerator tabGen =3D (TableGenerator) ann; + idGen.setName( tabGen.name() ); + idGen.setIdentifierGeneratorStrategy( MultipleHiLoPerTableGenerator.cla= ss.getName() ); + + if ( !BinderHelper.isDefault( tabGen.table() ) ) { + idGen.addParam( MultipleHiLoPerTableGenerator.ID_TABLE, tabGen.table()= ); + } + if ( !BinderHelper.isDefault( tabGen.catalog() ) ) { + idGen.addParam( MultipleHiLoPerTableGenerator.CATALOG, tabGen.catalog(= ) ); + } + if ( !BinderHelper.isDefault( tabGen.schema() ) ) { + idGen.addParam( MultipleHiLoPerTableGenerator.SCHEMA, tabGen.schema() = ); + } + //FIXME implements uniqueconstrains + + if ( !BinderHelper.isDefault( tabGen.pkColumnName() ) ) { + idGen.addParam( MultipleHiLoPerTableGenerator.PK_COLUMN_NAME, tabGen.p= kColumnName() ); + } + if ( !BinderHelper.isDefault( tabGen.valueColumnName() ) ) { + idGen.addParam( MultipleHiLoPerTableGenerator.VALUE_COLUMN_NAME, tabGe= n.valueColumnName() ); + } + if ( !BinderHelper.isDefault( tabGen.pkColumnValue() ) ) { + idGen.addParam( MultipleHiLoPerTableGenerator.PK_VALUE_NAME, tabGen.pk= ColumnValue() ); + } + idGen.addParam( TableHiLoGenerator.MAX_LO, String.valueOf( tabGen.alloc= ationSize() - 1 ) ); + log.debug( "Add table generator with name: {}", idGen.getName() ); + } + else if ( ann instanceof SequenceGenerator ) { + SequenceGenerator seqGen =3D (SequenceGenerator) ann; + idGen.setName( seqGen.name() ); + idGen.setIdentifierGeneratorStrategy( "seqhilo" ); + + if ( !BinderHelper.isDefault( seqGen.sequenceName() ) ) { + idGen.addParam( org.hibernate.id.SequenceGenerator.SEQUENCE, seqGen.se= quenceName() ); + } + //FIXME: work on initialValue() through SequenceGenerator.PARAMETERS + if ( seqGen.initialValue() !=3D 1 ) { + log.warn( + "Hibernate does not support SequenceGenerator.initialValue()" + ); + } + idGen.addParam( SequenceHiLoGenerator.MAX_LO, String.valueOf( seqGen.al= locationSize() - 1 ) ); + log.debug( "Add sequence generator with name: {}", idGen.getName() ); + } + else if ( ann instanceof GenericGenerator ) { + GenericGenerator genGen =3D (GenericGenerator) ann; + idGen.setName( genGen.name() ); + idGen.setIdentifierGeneratorStrategy( genGen.strategy() ); + Parameter[] params =3D genGen.parameters(); + for (Parameter parameter : params) { + idGen.addParam( parameter.name(), parameter.value() ); + } + log.debug( "Add generic generator with name: {}", idGen.getName() ); + } + else { + throw new AssertionFailure( "Unknown Generator annotation: " + ann ); + } + return idGen; + } + + /** + * Bind a class having JSR175 annotations + * The subclasses have to be binded after its mother class + */ + public static void bindClass( + XClass clazzToProcess, Map inheritanceStatePe= rClass, ExtendedMappings mappings + ) throws MappingException { + //TODO: be more strict with secondarytable allowance (not for ids, not f= or secondary table join columns etc) + InheritanceState inheritanceState =3D inheritanceStatePerClass.get( claz= zToProcess ); + AnnotatedClassType classType =3D mappings.getClassType( clazzToProcess ); + if ( AnnotatedClassType.EMBEDDABLE_SUPERCLASS.equals( classType ) //will= be processed by their subentities + || AnnotatedClassType.NONE.equals( classType ) //to be ignored + || AnnotatedClassType.EMBEDDABLE.equals( classType ) //allow embeddabl= e element declaration + ) { + if ( AnnotatedClassType.NONE.equals( classType ) + && clazzToProcess.isAnnotationPresent( org.hibernate.annotations.Enti= ty.class ) ) { + log.warn( "Class annotated @org.hibernate.annotations.Entity but not j= avax.persistence.Entity " + + "(most likely a user error): {}", clazzToProcess.getName() ); + } + return; + } + if ( !classType.equals( AnnotatedClassType.ENTITY ) ) { + //TODO make this test accurate by removing the none elements artificall= y added + throw new AnnotationException( + "Annotated class should have a @javax.persistence.Entity, @javax.pers= istence.Embeddable or @javax.persistence.EmbeddedSuperclass annotation: " += clazzToProcess + .getName() + ); + } + XAnnotatedElement annotatedClass =3D clazzToProcess; + log.info( "Binding entity from annotated class: {}", clazzToProcess.getN= ame() ); + InheritanceState superEntityState =3D + InheritanceState.getSuperEntityInheritanceState( + clazzToProcess, inheritanceStatePerClass, mappings.getReflectionMana= ger() + ); + PersistentClass superEntity =3D superEntityState !=3D null ? + mappings.getClass( + superEntityState.clazz.getName() + ) : + null; + if ( superEntity =3D=3D null ) { + //check if superclass is not a potential persistent class + if ( inheritanceState.hasParents ) { + throw new AssertionFailure( + "Subclass has to be binded after it's mother class: " + + superEntityState.clazz.getName() + ); + } + } + bindQueries( annotatedClass, mappings ); + bindFilterDefs( annotatedClass, mappings ); + bindTypeDefs( annotatedClass, mappings ); + BinderHelper.bindAnyMetaDefs( annotatedClass, mappings ); + + String schema =3D ""; + String table =3D ""; //might be no @Table annotation on the annotated cl= ass + String catalog =3D ""; + String discrimValue =3D null; + List uniqueConstraints =3D new ArrayList(); + Ejb3DiscriminatorColumn discriminatorColumn =3D null; + Ejb3JoinColumn[] inheritanceJoinedColumns =3D null; + + if ( annotatedClass.isAnnotationPresent( javax.persistence.Table.class )= ) { + javax.persistence.Table tabAnn =3D annotatedClass.getAnnotation( javax.= persistence.Table.class ); + table =3D tabAnn.name(); + schema =3D tabAnn.schema(); + catalog =3D tabAnn.catalog(); + uniqueConstraints =3D TableBinder.buildUniqueConstraints( tabAnn.unique= Constraints() ); + } + final boolean hasJoinedColumns =3D inheritanceState.hasParents + && InheritanceType.JOINED.equals( inheritanceState.type ); + if ( hasJoinedColumns ) { + //@Inheritance(JOINED) subclass need to link back to the super entity + PrimaryKeyJoinColumns jcsAnn =3D annotatedClass.getAnnotation( PrimaryK= eyJoinColumns.class ); + boolean explicitInheritanceJoinedColumns =3D jcsAnn !=3D null && jcsAnn= .value().length !=3D 0; + if ( explicitInheritanceJoinedColumns ) { + int nbrOfInhJoinedColumns =3D jcsAnn.value().length; + PrimaryKeyJoinColumn jcAnn; + inheritanceJoinedColumns =3D new Ejb3JoinColumn[nbrOfInhJoinedColumns]; + for (int colIndex =3D 0; colIndex < nbrOfInhJoinedColumns; colIndex++)= { + jcAnn =3D jcsAnn.value()[colIndex]; + inheritanceJoinedColumns[colIndex] =3D Ejb3JoinColumn.buildJoinColumn( + jcAnn, null, superEntity.getIdentifier(), + (Map) null, (PropertyHolder) null, mappings + ); + } + } + else { + PrimaryKeyJoinColumn jcAnn =3D annotatedClass.getAnnotation( PrimaryKe= yJoinColumn.class ); + inheritanceJoinedColumns =3D new Ejb3JoinColumn[1]; + inheritanceJoinedColumns[0] =3D Ejb3JoinColumn.buildJoinColumn( + jcAnn, null, superEntity.getIdentifier(), + (Map) null, (PropertyHolder) null, mappings + ); + } + log.debug( "Subclass joined column(s) created" ); + } + else { + if ( annotatedClass.isAnnotationPresent( javax.persistence.PrimaryKeyJo= inColumns.class ) + || annotatedClass.isAnnotationPresent( javax.persistence.PrimaryKeyJo= inColumn.class ) ) { + log.warn( "Root entity should not hold an PrimaryKeyJoinColum(s), will= be ignored" ); + } + } + + if ( InheritanceType.SINGLE_TABLE.equals( inheritanceState.type ) ) { + javax.persistence.DiscriminatorColumn discAnn =3D annotatedClass.getAnn= otation( + javax.persistence.DiscriminatorColumn.class + ); + DiscriminatorType discriminatorType =3D discAnn !=3D null ? + discAnn.discriminatorType() : + DiscriminatorType.STRING; + + org.hibernate.annotations.DiscriminatorFormula discFormulaAnn =3D annot= atedClass.getAnnotation( + org.hibernate.annotations.DiscriminatorFormula.class + ); + if ( !inheritanceState.hasParents ) { + discriminatorColumn =3D Ejb3DiscriminatorColumn.buildDiscriminatorColu= mn( + discriminatorType, discAnn, discFormulaAnn, mappings + ); + } + if ( discAnn !=3D null && inheritanceState.hasParents ) { + log.warn( + "Discriminator column has to be defined in the root entity, it will = be ignored in subclass: {}", + clazzToProcess.getName() + ); + } + discrimValue =3D annotatedClass.isAnnotationPresent( DiscriminatorValue= .class ) ? + annotatedClass.getAnnotation( DiscriminatorValue.class ).value() : + null; + } + + //we now know what kind of persistent entity it is + PersistentClass persistentClass; + //create persistent class + if ( !inheritanceState.hasParents ) { + persistentClass =3D new RootClass(); + } + else if ( InheritanceType.SINGLE_TABLE.equals( inheritanceState.type ) )= { + persistentClass =3D new SingleTableSubclass( superEntity ); + } + else if ( InheritanceType.JOINED.equals( inheritanceState.type ) ) { + persistentClass =3D new JoinedSubclass( superEntity ); + } + else if ( InheritanceType.TABLE_PER_CLASS.equals( inheritanceState.type = ) ) { + persistentClass =3D new UnionSubclass( superEntity ); + } + else { + throw new AssertionFailure( "Unknown inheritance type: " + inheritanceS= tate.type ); + } + Proxy proxyAnn =3D annotatedClass.getAnnotation( Proxy.class ); + BatchSize sizeAnn =3D annotatedClass.getAnnotation( BatchSize.class ); + Where whereAnn =3D annotatedClass.getAnnotation( Where.class ); + Entity entityAnn =3D annotatedClass.getAnnotation( Entity.class ); + org.hibernate.annotations.Entity hibEntityAnn =3D annotatedClass.getAnno= tation( + org.hibernate.annotations.Entity.class + ); + org.hibernate.annotations.Cache cacheAnn =3D annotatedClass.getAnnotatio= n( + org.hibernate.annotations.Cache.class + ); + EntityBinder entityBinder =3D new EntityBinder( + entityAnn, hibEntityAnn, clazzToProcess, persistentClass, mappings + ); + entityBinder.setDiscriminatorValue( discrimValue ); + entityBinder.setBatchSize( sizeAnn ); + entityBinder.setProxy( proxyAnn ); + entityBinder.setWhere( whereAnn ); + entityBinder.setCache( cacheAnn ); + entityBinder.setInheritanceState( inheritanceState ); + Filter filterAnn =3D annotatedClass.getAnnotation( Filter.class ); + if ( filterAnn !=3D null ) { + entityBinder.addFilter( filterAnn.name(), filterAnn.condition() ); + } + Filters filtersAnn =3D annotatedClass.getAnnotation( Filters.class ); + if ( filtersAnn !=3D null ) { + for (Filter filter : filtersAnn.value()) { + entityBinder.addFilter( filter.name(), filter.condition() ); + } + } + entityBinder.bindEntity(); + + if ( inheritanceState.hasTable() ) { + Check checkAnn =3D annotatedClass.getAnnotation( Check.class ); + String constraints =3D checkAnn =3D=3D null ? + null : + checkAnn.constraints(); + entityBinder.bindTable( + schema, catalog, table, uniqueConstraints, + constraints, inheritanceState.hasDenormalizedTable() ? + superEntity.getTable() : + null + ); + } + else { + if ( annotatedClass.isAnnotationPresent( Table.class ) ) { + log.warn( "Illegal use of @Table in a subclass of a SINGLE_TABLE hiera= rchy: " + clazzToProcess + .getName() ); + } + } +// Map columnOverride =3D PropertyHolderBuilder.buildHi= erarchyColumnOverride( +// clazzToProcess, +// persistentClass.getClassName() +// ); + PropertyHolder propertyHolder =3D PropertyHolderBuilder.buildPropertyHol= der( + clazzToProcess, + persistentClass, + entityBinder, mappings + ); + + javax.persistence.SecondaryTable secTabAnn =3D annotatedClass.getAnnotat= ion( + javax.persistence.SecondaryTable.class + ); + javax.persistence.SecondaryTables secTabsAnn =3D annotatedClass.getAnnot= ation( + javax.persistence.SecondaryTables.class + ); + entityBinder.firstLevelSecondaryTablesBinding( secTabAnn, secTabsAnn ); + + OnDelete onDeleteAnn =3D annotatedClass.getAnnotation( OnDelete.class ); + boolean onDeleteAppropriate =3D false; + if ( InheritanceType.JOINED.equals( inheritanceState.type ) && inheritan= ceState.hasParents ) { + onDeleteAppropriate =3D true; + final JoinedSubclass jsc =3D (JoinedSubclass) persistentClass; + if ( persistentClass.getEntityPersisterClass() =3D=3D null ) { + persistentClass.getRootClass().setEntityPersisterClass( JoinedSubclass= EntityPersister.class ); + } + SimpleValue key =3D new DependantValue( jsc.getTable(), jsc.getIdentifi= er() ); + jsc.setKey( key ); + ForeignKey fk =3D annotatedClass.getAnnotation( ForeignKey.class ); + if ( fk !=3D null && !BinderHelper.isDefault( fk.name() ) ) { + key.setForeignKeyName( fk.name() ); + } + if ( onDeleteAnn !=3D null ) { + key.setCascadeDeleteEnabled( OnDeleteAction.CASCADE.equals( onDeleteAn= n.action() ) ); + } + else { + key.setCascadeDeleteEnabled( false ); + } + //we are never in a second pass at that stage, so queue it + SecondPass sp =3D new JoinedSubclassFkSecondPass( jsc, inheritanceJoine= dColumns, key, mappings ); + mappings.addSecondPass( sp ); + mappings.addSecondPass( new CreateKeySecondPass( jsc ) ); + + } + else if ( InheritanceType.SINGLE_TABLE.equals( inheritanceState.type ) )= { + if ( inheritanceState.hasParents ) { + if ( persistentClass.getEntityPersisterClass() =3D=3D null ) { + persistentClass.getRootClass().setEntityPersisterClass( SingleTableEn= tityPersister.class ); + } + } + else { + if ( inheritanceState.hasSons || !discriminatorColumn.isImplicit() ) { + //need a discriminator column + bindDiscriminatorToPersistentClass( + (RootClass) persistentClass, + discriminatorColumn, + entityBinder.getSecondaryTables(), + propertyHolder + ); + entityBinder.bindDiscriminatorValue();//bind it again since the type = might have changed + } + } + } + else if ( InheritanceType.TABLE_PER_CLASS.equals( inheritanceState.type = ) ) { + if ( inheritanceState.hasParents ) { + if ( persistentClass.getEntityPersisterClass() =3D=3D null ) { + persistentClass.getRootClass().setEntityPersisterClass( UnionSubclass= EntityPersister.class ); + } + } + } + if ( onDeleteAnn !=3D null && !onDeleteAppropriate ) { + log.warn( + "Inapropriate use of @OnDelete on entity, annotation ignored: {}", pr= opertyHolder.getEntityName() + ); + } + + //try to find class level generators + HashMap classGenerators =3D buildLocalGenerators( a= nnotatedClass, mappings ); + + // check properties + List elements =3D + getElementsToProcess( + clazzToProcess, inheritanceStatePerClass, propertyHolder, entityBind= er, mappings + ); + if ( elements =3D=3D null ) { + throw new AnnotationException( "No identifier specified for entity: " += propertyHolder.getEntityName() ); + } + final boolean subclassAndSingleTableStrategy =3D inheritanceState.type = =3D=3D InheritanceType.SINGLE_TABLE + && inheritanceState.hasParents; + //process idclass if any + Set idProperties =3D new HashSet(); + IdClass idClass =3D null; + if ( !inheritanceState.hasParents ) { + //look for idClass + XClass current =3D inheritanceState.clazz; + InheritanceState state =3D inheritanceState; + do { + current =3D state.clazz; + if ( current.isAnnotationPresent( IdClass.class ) ) { + idClass =3D current.getAnnotation( IdClass.class ); + break; + } + state =3D InheritanceState.getSuperclassInheritanceState( + current, inheritanceStatePerClass, mappings.getReflectionManager() + ); + } + while ( state !=3D null ); + } + if ( idClass !=3D null ) { + XClass compositeClass =3D mappings.getReflectionManager().toXClass( idC= lass.value() ); + boolean isComponent =3D true; + boolean propertyAnnotated =3D entityBinder.isPropertyAnnotated( composi= teClass ); + String propertyAccessor =3D entityBinder.getPropertyAccessor( composite= Class ); + String generatorType =3D "assigned"; + String generator =3D BinderHelper.ANNOTATION_STRING_DEFAULT; + PropertyData inferredData =3D new PropertyPreloadedData( + entityBinder.getPropertyAccessor(), "id", compositeClass + ); + HashMap localGenerators =3D new HashMap(); + boolean ignoreIdAnnotations =3D entityBinder.isIgnoreIdAnnotations(); + entityBinder.setIgnoreIdAnnotations( true ); + bindId( + generatorType, + generator, + inferredData, + null, + propertyHolder, + localGenerators, + isComponent, + propertyAnnotated, + propertyAccessor, entityBinder, + true, + false, mappings + ); + inferredData =3D new PropertyPreloadedData( + propertyAccessor, "_identifierMapper", compositeClass + ); + Component mapper =3D fillComponent( + propertyHolder, + inferredData, + propertyAnnotated, + propertyAccessor, false, + entityBinder, + true, true, + false, mappings + ); + entityBinder.setIgnoreIdAnnotations( ignoreIdAnnotations ); + persistentClass.setIdentifierMapper( mapper ); + Property property =3D new Property(); + property.setName( "_identifierMapper" ); + property.setNodeName( "id" ); + property.setUpdateable( false ); + property.setInsertable( false ); + property.setValue( mapper ); + property.setPropertyAccessorName( "embedded" ); + persistentClass.addProperty( property ); + entityBinder.setIgnoreIdAnnotations( true ); + + Iterator properties =3D mapper.getPropertyIterator(); + while ( properties.hasNext() ) { + idProperties.add( ( (Property) properties.next() ).getName() ); + } + } + Set missingIdProperties =3D new HashSet( idProperties ); + for (PropertyData propertyAnnotatedElement : elements) { + String propertyName =3D propertyAnnotatedElement.getPropertyName(); + if ( !idProperties.contains( propertyName ) ) { + processElementAnnotations( + propertyHolder, + subclassAndSingleTableStrategy ? + Nullability.FORCED_NULL : + Nullability.NO_CONSTRAINT, + propertyAnnotatedElement.getProperty(), + propertyAnnotatedElement, classGenerators, entityBinder, + false, false, false, mappings + ); + } + else { + missingIdProperties.remove( propertyName ); + } + } + + if ( missingIdProperties.size() !=3D 0 ) { + StringBuilder missings =3D new StringBuilder(); + for (String property : missingIdProperties) { + missings.append( property ).append( ", " ); + } + throw new AnnotationException( + "Unable to find properties (" + + missings.substring( 0, missings.length() - 2 ) + + ") in entity annotated with @IdClass:" + persistentClass.getEntit= yName() + ); + } + + if ( !inheritanceState.hasParents ) { + final RootClass rootClass =3D (RootClass) persistentClass; + mappings.addSecondPass( new CreateKeySecondPass( rootClass ) ); + } + else { + superEntity.addSubclass( (Subclass) persistentClass ); + } + + mappings.addClass( persistentClass ); + + //Process secondary tables and complementary definitions (ie o.h.a.Table) + mappings.addSecondPass( new SecondaryTableSecondPass( entityBinder, prop= ertyHolder, annotatedClass ) ); + + //add process complementary Table definition (index & all) + entityBinder.processComplementaryTableDefinitions( annotatedClass.getAnn= otation( org.hibernate.annotations.Table.class ) ); + entityBinder.processComplementaryTableDefinitions( annotatedClass.getAnn= otation( org.hibernate.annotations.Tables.class ) ); + + } + + /** + * Get the annotated elements + * Guess the annotated element from @Id or @EmbeddedId presence + * Change EntityBinder by side effect + */ + private static List getElementsToProcess( + XClass clazzToProcess, Map inheritanceStatePe= rClass, + PropertyHolder propertyHolder, EntityBinder entityBinder, ExtendedMappi= ngs mappings + ) { + InheritanceState inheritanceState =3D inheritanceStatePerClass.get( claz= zToProcess ); + List classesToProcess =3D orderClassesToBeProcessed( + clazzToProcess, inheritanceStatePerClass, inheritanceState, mappings + ); + List elements =3D new ArrayList(); + int deep =3D classesToProcess.size(); + boolean hasIdentifier =3D false; + + assert !inheritanceState.isEmbeddableSuperclass; + Boolean isExplicitPropertyAnnotated =3D null; + String explicitAccessType =3D null; + if ( inheritanceState.hasParents ) { + InheritanceState superEntityState =3D + InheritanceState.getSuperEntityInheritanceState( + clazzToProcess, inheritanceStatePerClass, mappings.getReflectionMan= ager() + ); + isExplicitPropertyAnnotated =3D superEntityState !=3D null ? + superEntityState.isPropertyAnnotated : + null; + explicitAccessType =3D superEntityState !=3D null ? + superEntityState.accessType : + null; + } + else { + AccessType access =3D clazzToProcess.getAnnotation( AccessType.class ); + explicitAccessType =3D access !=3D null ? + access.value() : + null; + if ( "property".equals( explicitAccessType ) ) { + isExplicitPropertyAnnotated =3D Boolean.TRUE; + } + else if ( "field".equals( explicitAccessType ) ) { + isExplicitPropertyAnnotated =3D Boolean.FALSE; + } + } + Boolean isPropertyAnnotated =3D isExplicitPropertyAnnotated =3D=3D null ? + Boolean.TRUE : + //default to property and fallback if needed + isExplicitPropertyAnnotated; + String accessType =3D explicitAccessType !=3D null ? + explicitAccessType : + "property"; + /* + * delay the exception in case field access is used + */ + AnnotationException exceptionWhileWalkingElements =3D null; + try { + for (int index =3D 0; index < deep; index++) { + XClass clazz =3D classesToProcess.get( index ); + + boolean currentHasIdentifier =3D addElementsOfAClass( + elements, propertyHolder, isPropertyAnnotated, + accessType, clazz, mappings + ); + hasIdentifier =3D hasIdentifier || currentHasIdentifier; + } + } + catch ( AnnotationException e ) { + exceptionWhileWalkingElements =3D e; + } + + //TODO remember why it should be !inheritanceState.hasParents + if ( !hasIdentifier && !inheritanceState.hasParents ) { + if ( isExplicitPropertyAnnotated !=3D null ) { + //the original exception is legitimate + if ( exceptionWhileWalkingElements !=3D null) throw exceptionWhileWalk= ingElements; + return null; //explicit but no @Id: the upper layer will raise an exce= ption + } + isPropertyAnnotated =3D !isPropertyAnnotated; + accessType =3D "field"; + elements.clear(); + for (int index =3D 0; index < deep; index++) { + XClass clazz =3D classesToProcess.get( index ); + boolean currentHasIdentifier =3D addElementsOfAClass( + elements, propertyHolder, isPropertyAnnotated, + accessType, clazz, mappings + ); + hasIdentifier =3D hasIdentifier || currentHasIdentifier; + } + } + + //the field show no id, fallback tot he original exception + if (!hasIdentifier && exceptionWhileWalkingElements !=3D null) throw exc= eptionWhileWalkingElements; + + //TODO set the access type here? + entityBinder.setPropertyAnnotated( isPropertyAnnotated ); + entityBinder.setPropertyAccessor( accessType ); + inheritanceState.isPropertyAnnotated =3D isPropertyAnnotated; + inheritanceState.accessType =3D accessType; + return hasIdentifier || inheritanceState.hasParents ? + elements : + null; + } + + private static List orderClassesToBeProcessed( + XClass annotatedClass, Map inheritanceStatePe= rClass, + InheritanceState inheritanceState, ExtendedMappings mappings + ) { + //ordered to allow proper messages on properties subclassing + List classesToProcess =3D new ArrayList(); + XClass currentClassInHierarchy =3D annotatedClass; + InheritanceState superclassState; + do { + classesToProcess.add( 0, currentClassInHierarchy ); + XClass superClass =3D currentClassInHierarchy; + do { + superClass =3D superClass.getSuperclass(); + superclassState =3D inheritanceStatePerClass.get( superClass ); + } + while ( superClass !=3D null && !mappings.getReflectionManager() + .equals( superClass, Object.class ) && superclassState =3D=3D null ); + + currentClassInHierarchy =3D superClass; + } + while ( superclassState !=3D null && superclassState.isEmbeddableSupercl= ass ); + + return classesToProcess; + } + + private static void bindFilterDefs(XAnnotatedElement annotatedElement, Ex= tendedMappings mappings) { + FilterDef defAnn =3D annotatedElement.getAnnotation( FilterDef.class ); + FilterDefs defsAnn =3D annotatedElement.getAnnotation( FilterDefs.class = ); + if ( defAnn !=3D null ) { + bindFilterDef( defAnn, mappings ); + } + if ( defsAnn !=3D null ) { + for (FilterDef def : defsAnn.value()) { + bindFilterDef( def, mappings ); + } + } + } + + private static void bindFilterDef(FilterDef defAnn, ExtendedMappings mapp= ings) { + Map params =3D new HashMap(); + for (ParamDef param : defAnn.parameters()) { + params.put( param.name(), TypeFactory.heuristicType( param.type() ) ); + } + FilterDefinition def =3D new FilterDefinition( defAnn.name(), defAnn.def= aultCondition(), params ); + log.info( "Binding filter definition: {}", def.getFilterName() ); + mappings.addFilterDefinition( def ); + } + + private static void bindTypeDefs(XAnnotatedElement annotatedElement, Exte= ndedMappings mappings) { + TypeDef defAnn =3D annotatedElement.getAnnotation( TypeDef.class ); + TypeDefs defsAnn =3D annotatedElement.getAnnotation( TypeDefs.class ); + if ( defAnn !=3D null ) { + bindTypeDef( defAnn, mappings ); + } + if ( defsAnn !=3D null ) { + for (TypeDef def : defsAnn.value()) { + bindTypeDef( def, mappings ); + } + } + } + + private static void bindTypeDef(TypeDef defAnn, ExtendedMappings mappings= ) { + Properties params =3D new Properties(); + for (Parameter param : defAnn.parameters()) { + params.setProperty( param.name(), param.value() ); + } + log.info( "Binding type definition: {}", defAnn.name() ); + mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params= ); + } + + private static void bindDiscriminatorToPersistentClass( + RootClass rootClass, + Ejb3DiscriminatorColumn discriminatorColumn, Map secondar= yTables, + PropertyHolder propertyHolder + ) { + if ( rootClass.getDiscriminator() =3D=3D null ) { + if ( discriminatorColumn =3D=3D null ) { + throw new AssertionFailure( "discriminator column should have been bui= lt" ); + } + discriminatorColumn.setJoins( secondaryTables ); + discriminatorColumn.setPropertyHolder( propertyHolder ); + SimpleValue discrim =3D new SimpleValue( rootClass.getTable() ); + rootClass.setDiscriminator( discrim ); + discriminatorColumn.linkWithValue( discrim ); + discrim.setTypeName( discriminatorColumn.getDiscriminatorTypeName() ); + rootClass.setPolymorphic( true ); + log.debug( "Setting discriminator for entity {}", rootClass.getEntityNa= me() ); + } + } + + /** + * Add elements of a class + */ + private static boolean addElementsOfAClass( + List elements, PropertyHolder propertyHolder, boolean isP= ropertyAnnotated, + String propertyAccessor, final XClass annotatedClass, ExtendedMappings = mappings + ) { + boolean hasIdentifier =3D false; + AccessType access =3D annotatedClass.getAnnotation( AccessType.class ); + String localPropertyAccessor =3D access !=3D null ? + access.value() : + null; + String accessType =3D null; + if ( "property".equals( localPropertyAccessor ) || "field".equals( local= PropertyAccessor ) ) { + accessType =3D localPropertyAccessor; + } + else { + if ( localPropertyAccessor =3D=3D null ) { + localPropertyAccessor =3D propertyAccessor; + } + + if ( isPropertyAnnotated ) { + accessType =3D "property"; + } + else { + accessType =3D "field"; + } + } + + log.debug( "Processing {} {} annotation", propertyHolder.getEntityName()= , accessType ); + List properties =3D annotatedClass.getDeclaredProperties( acc= essType ); + //order so that property are used in the same order when binding native = query + Collections.sort( properties, new Comparator() { + public int compare(XProperty property1, XProperty property2) { + return property1.getName().compareTo( property2.getName() ); + } + } ); + for (XProperty p : properties) { + if ( !p.isTypeResolved() && !discoverTypeWithoutReflection( p ) && !mus= tBeSkipped( p, mappings ) ) { + throw new AnnotationException( + "Property " + StringHelper.qualify( propertyHolder.getEntityName(), = p.getName() ) + + " has an unbound type and no explicit target entity. Resolve this = Generic usage issue" + + " or set an explicit target attribute (eg @OneToMany(target=3D) or= use an explicit @Type" + ); + } + final boolean currentHasIdentifier =3D addProperty( p, elements, localP= ropertyAccessor, mappings ); + hasIdentifier =3D hasIdentifier || currentHasIdentifier; + } + return hasIdentifier; + } + + private static boolean discoverTypeWithoutReflection(XProperty p) { + if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToO= ne.class ) + .targetEntity() + .equals( void.class ) ) { + return true; + } + else if ( p.isAnnotationPresent( OneToMany.class ) && !p.getAnnotation( = OneToMany.class ) + .targetEntity() + .equals( void.class ) ) { + return true; + } + else if ( p.isAnnotationPresent( ManyToOne.class ) && !p.getAnnotation( = ManyToOne.class ) + .targetEntity() + .equals( void.class ) ) { + return true; + } + else if ( p.isAnnotationPresent( ManyToMany.class ) && !p.getAnnotation(= ManyToMany.class ) + .targetEntity() + .equals( void.class ) ) { + return true; + } + else if ( p.isAnnotationPresent( org.hibernate.annotations.Any.class ) )= { + return true; + } + else if ( p.isAnnotationPresent( ManyToAny.class ) ) { + if ( !p.isCollection() && !p.isArray() ) { + throw new AnnotationException( "@ManyToAny used on a non collection no= n array property: " + p.getName() ); + } + return true; + } + else if ( p.isAnnotationPresent( Type.class ) ) { + return true; + } + else if ( p.isAnnotationPresent( Target.class ) ) { + return true; + } + return false; + } + + private static boolean addProperty( + XProperty property, List annElts, + String propertyAccessor, ExtendedMappings mappings + ) { + boolean hasIdentifier =3D false; + PropertyData propertyAnnotatedElement =3D new PropertyInferredData( + property, propertyAccessor, + mappings.getReflectionManager() ); + if ( !mustBeSkipped( propertyAnnotatedElement.getProperty(), mappings ) = ) { + /* + * put element annotated by @Id in front + * since it has to be parsed before any assoctation by Hibernate + */ + final XAnnotatedElement element =3D propertyAnnotatedElement.getPropert= y(); + if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPre= sent( EmbeddedId.class ) ) { + annElts.add( 0, propertyAnnotatedElement ); + hasIdentifier =3D true; + } + else { + annElts.add( propertyAnnotatedElement ); + hasIdentifier =3D false; + } + } + return hasIdentifier; + } + + private static boolean mustBeSkipped(XProperty property, ExtendedMappings= mappings) { + //TODO make those hardcoded tests more portable (through the bytecode pr= ovider?) + return property.isAnnotationPresent( Transient.class ) + || "net.sf.cglib.transform.impl.InterceptFieldCallback".equals( proper= ty.getType().getName() ) + || "org.hibernate.bytecode.javassist.FieldHandler".equals( property.ge= tType().getName() ); + } + + /** + * Process annotation of a particular property + */ + private static void processElementAnnotations( + PropertyHolder propertyHolder, Nullability nullability, XProperty prope= rty, + PropertyData inferredData, HashMap classGenerators, + EntityBinder entityBinder, boolean isIdentifierMapper, + boolean isComponentEmbedded, boolean inSecondPass, ExtendedMappings map= pings + ) + throws MappingException { + /** + * inSecondPass can only be used to apply right away the second pass of = a composite-element + * Because it's a value type, there is no bidirectional association, hen= ce second pass + * ordering does not matter + */ + Ejb3Column[] columns =3D null; + Ejb3JoinColumn[] joinColumns =3D null; + log.debug( + "Processing annotations of {}.{}", propertyHolder.getEntityName(), inf= erredData.getPropertyName() + ); + + if ( property.isAnnotationPresent( Parent.class ) ) { + if ( propertyHolder.isComponent() ) { + propertyHolder.setParentProperty( property.getName() ); + } + else { + throw new AnnotationException( + "@Parent cannot be applied outside an embeddable object: " + + StringHelper.qualify( propertyHolder.getPath(), property.getName= () ) + ); + } + return; + } + + //process @JoinColumn(s) before @Column(s) to handle collection of eleme= nts properly + { + JoinColumn[] anns =3D null; + if ( property.isAnnotationPresent( JoinColumn.class ) ) { + anns =3D new JoinColumn[] { property.getAnnotation( JoinColumn.class )= }; + } + else if ( property.isAnnotationPresent( JoinColumns.class ) ) { + JoinColumns ann =3D property.getAnnotation( JoinColumns.class ); + anns =3D ann.value(); + int length =3D anns.length; + if ( length =3D=3D 0 ) { + throw new AnnotationException( "Cannot bind an empty @JoinColumns" ); + } + } + if ( anns !=3D null ) { + joinColumns =3D Ejb3JoinColumn.buildJoinColumns( + anns, null, entityBinder.getSecondaryTables(), + propertyHolder, inferredData.getPropertyName(), mappings + ); + } + } + if ( property.isAnnotationPresent( Column.class ) || property.isAnnotati= onPresent( Formula.class ) ) { + Column ann =3D property.getAnnotation( Column.class ); + Formula formulaAnn =3D property.getAnnotation( Formula.class ); + columns =3D Ejb3Column.buildColumnFromAnnotation( + new Column[] { ann }, formulaAnn, nullability, propertyHolder, inferr= edData, + entityBinder.getSecondaryTables(), mappings + ); + } + else if ( property.isAnnotationPresent( Columns.class ) ) { + Columns anns =3D property.getAnnotation( Columns.class ); + columns =3D Ejb3Column.buildColumnFromAnnotation( + anns.columns(), null, nullability, propertyHolder, inferredData, enti= tyBinder.getSecondaryTables(), + mappings + ); + } + + //set default values if needed + if ( joinColumns =3D=3D null && + ( property.isAnnotationPresent( ManyToOne.class ) + || property.isAnnotationPresent( OneToOne.class ) ) + ) { + if ( property.isAnnotationPresent( JoinTable.class ) ) { + JoinTable joinTableAnn =3D property.getAnnotation( JoinTable.class ); + joinColumns =3D Ejb3JoinColumn.buildJoinColumns( + joinTableAnn.inverseJoinColumns(), null, entityBinder.getSecondaryTa= bles(), + propertyHolder, inferredData.getPropertyName(), mappings + ); + if ( StringHelper.isEmpty( joinTableAnn.name() ) ) { + throw new AnnotationException( + "JoinTable.name() on a @ToOne association has to be explicit: " + + StringHelper.qualify( propertyHolder.getPath(), inferredData.ge= tPropertyName() ) + ); + } + } + else { + OneToOne oneToOneAnn =3D property.getAnnotation( OneToOne.class ); + String mappedBy =3D oneToOneAnn !=3D null ? + oneToOneAnn.mappedBy() : + null; + joinColumns =3D Ejb3JoinColumn.buildJoinColumns( + (JoinColumn[]) null, + mappedBy, entityBinder.getSecondaryTables(), + propertyHolder, inferredData.getPropertyName(), mappings + ); + } + } + else if ( joinColumns =3D=3D null && + ( property.isAnnotationPresent( OneToMany.class ) + || property.isAnnotationPresent( CollectionOfElements.class ) ) ) { + OneToMany oneToMany =3D property.getAnnotation( OneToMany.class ); + String mappedBy =3D oneToMany !=3D null ? + oneToMany.mappedBy() : + ""; + joinColumns =3D Ejb3JoinColumn.buildJoinColumns( + (JoinColumn[]) null, + mappedBy, entityBinder.getSecondaryTables(), + propertyHolder, inferredData.getPropertyName(), mappings + ); + } + else if ( joinColumns =3D=3D null && property.isAnnotationPresent( org.h= ibernate.annotations.Any.class ) ) { + throw new AnnotationException( "@Any requires an explicit @JoinColumn(s= ): " + + StringHelper.qualify( propertyHolder.getPath(), property.getName() = ) ); + } + if ( columns =3D=3D null && !property.isAnnotationPresent( ManyToMany.cl= ass ) ) { + //useful for collection of embedded elements + columns =3D Ejb3Column.buildColumnFromAnnotation( + null, null, nullability, propertyHolder, inferredData, entityBinder.g= etSecondaryTables(), mappings + ); + } + + if ( nullability =3D=3D Nullability.FORCED_NOT_NULL ) { + //force columns to not null + for (Ejb3Column col : columns) { + col.forceNotNull(); + } + } + + final XClass returnedClass =3D inferredData.getClassOrElement(); + if ( !entityBinder.isIgnoreIdAnnotations() && + ( property.isAnnotationPresent( Id.class ) + || property.isAnnotationPresent( EmbeddedId.class ) ) ) { + if ( isIdentifierMapper ) { + throw new AnnotationException( + "@IdClass class should not have @Id nor @EmbeddedId properties" + ); + } + log.debug( "{} is an id", inferredData.getPropertyName() ); + //clone classGenerator and override with local values + HashMap localGenerators =3D (HashMap) classGenerators.clone(); + localGenerators.putAll( buildLocalGenerators( property, mappings ) ); + + //manage composite related metadata + //guess if its a component and find id data access (property, field etc) + final boolean isComponent =3D returnedClass.isAnnotationPresent( Embedd= able.class ) + || property.isAnnotationPresent( EmbeddedId.class ); + boolean propertyAnnotated =3D entityBinder.isPropertyAnnotated( returne= dClass ); + String propertyAccessor =3D entityBinder.getPropertyAccessor( returnedC= lass ); + //if ( isComponent && embeddableAnn !=3D null && embeddableAnn.access()= =3D=3D AccessType.FIELD ) propertyAccess =3D false; + + GeneratedValue generatedValue =3D property.getAnnotation( GeneratedValu= e.class ); + String generatorType =3D generatedValue !=3D null ? + generatorType( generatedValue.strategy() ) : + "assigned"; + String generator =3D generatedValue !=3D null ? + generatedValue.generator() : + BinderHelper.ANNOTATION_STRING_DEFAULT; + if ( isComponent ) generatorType =3D "assigned"; //a component must not= have any generator + = + bindId( + generatorType, + generator, + inferredData, + columns, + propertyHolder, + localGenerators, + isComponent, + propertyAnnotated, + propertyAccessor, entityBinder, + false, + isIdentifierMapper, mappings + ); + = + log.debug( + "Bind {} on {}", ( isComponent ? "@EmbeddedId" : "@Id" ), inferredDat= a.getPropertyName() + ); + } + else if ( property.isAnnotationPresent( Version.class ) ) { + if ( isIdentifierMapper ) { + throw new AnnotationException( + "@IdClass class should not have @Version property" + ); + } + if ( !( propertyHolder.getPersistentClass() instanceof RootClass ) ) { + throw new AnnotationException( + "Unable to define/override @Version on a subclass: " + + propertyHolder.getEntityName() + ); + } + if ( ! propertyHolder.isEntity() ) { + throw new AnnotationException( + "Unable to define @Version on an embedded class: " + + propertyHolder.getEntityName() + ); + } + log.debug( "{} is a version property", inferredData.getPropertyName() ); + RootClass rootClass =3D (RootClass) propertyHolder.getPersistentClass(); + PropertyBinder propBinder =3D new PropertyBinder(); + propBinder.setName( inferredData.getPropertyName() ); + propBinder.setReturnedClassName( inferredData.getTypeName() ); + propBinder.setLazy( false ); + propBinder.setPropertyAccessorName( inferredData.getDefaultAccess() ); + propBinder.setColumns( columns ); + propBinder.setHolder( propertyHolder ); //PropertyHolderBuilder.buildPr= opertyHolder(rootClass) + propBinder.setProperty( property ); + propBinder.setReturnedClass( inferredData.getPropertyClass() ); + + propBinder.setMappings( mappings ); + Property prop =3D propBinder.bind(); + rootClass.setVersion( prop ); + SimpleValue simpleValue =3D (SimpleValue) prop.getValue(); + if ( !simpleValue.isTypeSpecified() ) simpleValue.setTypeName( "integer= " ); + simpleValue.setNullValue( "undefined" ); + rootClass.setOptimisticLockMode( Versioning.OPTIMISTIC_LOCK_VERSION ); + log.debug( + "Version name: {}, unsavedValue: {}", rootClass.getVersion().getName(= ), + ( (SimpleValue) rootClass.getVersion().getValue() ).getNullValue() + ); + } + else if ( property.isAnnotationPresent( ManyToOne.class ) ) { + ManyToOne ann =3D property.getAnnotation( ManyToOne.class ); + + //check validity + if ( property.isAnnotationPresent( Column.class ) + || property.isAnnotationPresent( Columns.class ) ) { + throw new AnnotationException( "@Column(s) not allowed on a @ManyToOne= property: " + + StringHelper.qualify( propertyHolder.getPath(), inferredData.getPr= opertyName() ) ); + } + + Cascade hibernateCascade =3D property.getAnnotation( Cascade.class ); + NotFound notFound =3D property.getAnnotation( NotFound.class ); + boolean ignoreNotFound =3D notFound !=3D null && notFound.action().equa= ls( NotFoundAction.IGNORE ); + OnDelete onDeleteAnn =3D property.getAnnotation( OnDelete.class ); + boolean onDeleteCascade =3D onDeleteAnn !=3D null && OnDeleteAction.CAS= CADE.equals( onDeleteAnn.action() ); + JoinTable assocTable =3D property.getAnnotation( JoinTable.class ); + if ( assocTable !=3D null ) { + Join join =3D propertyHolder.addJoin( assocTable, false ); + for (Ejb3JoinColumn joinColumn : joinColumns) { + joinColumn.setSecondaryTableName( join.getTable().getName() ); + } + } + bindManyToOne( + getCascadeStrategy( ann.cascade(), hibernateCascade ), + joinColumns, + ann.optional(), + ignoreNotFound, onDeleteCascade, + mappings.getReflectionManager().toXClass( ann.targetEntity() ), + propertyHolder, + inferredData, false, isIdentifierMapper, inSecondPass, mappings + ); + } + else if ( property.isAnnotationPresent( OneToOne.class ) ) { + OneToOne ann =3D property.getAnnotation( OneToOne.class ); + + //check validity + if ( property.isAnnotationPresent( Column.class ) + || property.isAnnotationPresent( Columns.class ) ) { + throw new AnnotationException( "@Column(s) not allowed on a @OneToOne = property: " + + StringHelper.qualify( propertyHolder.getPath(), inferredData.getPr= opertyName() ) ); + } + + //FIXME support a proper PKJCs + boolean trueOneToOne =3D property.isAnnotationPresent( PrimaryKeyJoinCo= lumn.class ) + || property.isAnnotationPresent( PrimaryKeyJoinColumns.class ); + Cascade hibernateCascade =3D property.getAnnotation( Cascade.class ); + NotFound notFound =3D property.getAnnotation( NotFound.class ); + boolean ignoreNotFound =3D notFound !=3D null && notFound.action().equa= ls( NotFoundAction.IGNORE ); + OnDelete onDeleteAnn =3D property.getAnnotation( OnDelete.class ); + boolean onDeleteCascade =3D onDeleteAnn !=3D null && OnDeleteAction.CAS= CADE.equals( onDeleteAnn.action() ); + JoinTable assocTable =3D property.getAnnotation( JoinTable.class ); + if ( assocTable !=3D null ) { + Join join =3D propertyHolder.addJoin( assocTable, false ); + for (Ejb3JoinColumn joinColumn : joinColumns) { + joinColumn.setSecondaryTableName( join.getTable().getName() ); + } + } + bindOneToOne( + getCascadeStrategy( ann.cascade(), hibernateCascade ), + joinColumns, + ann.optional(), + getFetchMode( ann.fetch() ), + ignoreNotFound, onDeleteCascade, + mappings.getReflectionManager().toXClass( ann.targetEntity() ), + propertyHolder, + inferredData, ann.mappedBy(), trueOneToOne, isIdentifierMapper, inSec= ondPass, mappings + ); + } + else if ( property.isAnnotationPresent( org.hibernate.annotations.Any.cl= ass ) ) { + + //check validity + if ( property.isAnnotationPresent( Column.class ) + || property.isAnnotationPresent( Columns.class ) ) { + throw new AnnotationException( "@Column(s) not allowed on a @Any prope= rty: " + + StringHelper.qualify( propertyHolder.getPath(), inferredData.getPr= opertyName() ) ); + } + + Cascade hibernateCascade =3D property.getAnnotation( Cascade.class ); + NotFound notFound =3D property.getAnnotation( NotFound.class ); + boolean ignoreNotFound =3D notFound !=3D null && notFound.action().equa= ls( NotFoundAction.IGNORE ); + OnDelete onDeleteAnn =3D property.getAnnotation( OnDelete.class ); + boolean onDeleteCascade =3D onDeleteAnn !=3D null && OnDeleteAction.CAS= CADE.equals( onDeleteAnn.action() ); + JoinTable assocTable =3D property.getAnnotation( JoinTable.class ); + if ( assocTable !=3D null ) { + Join join =3D propertyHolder.addJoin( assocTable, false ); + for (Ejb3JoinColumn joinColumn : joinColumns) { + joinColumn.setSecondaryTableName( join.getTable().getName() ); + } + } + bindAny( getCascadeStrategy( null, hibernateCascade ), //@Any has not c= ascade attribute + joinColumns, onDeleteCascade, nullability, + propertyHolder, inferredData, entityBinder, + isIdentifierMapper, mappings ); + } + else if ( property.isAnnotationPresent( OneToMany.class ) + || property.isAnnotationPresent( ManyToMany.class ) + || property.isAnnotationPresent( CollectionOfElements.class ) + || property.isAnnotationPresent( ManyToAny.class ) ) { + OneToMany oneToManyAnn =3D property.getAnnotation( OneToMany.class ); + ManyToMany manyToManyAnn =3D property.getAnnotation( ManyToMany.class ); + CollectionOfElements collectionOfElementsAnn =3D property.getAnnotation= ( CollectionOfElements.class ); + org.hibernate.annotations.IndexColumn indexAnn =3D property.getAnnotati= on( + org.hibernate.annotations.IndexColumn.class + ); + JoinTable assocTable =3D property.getAnnotation( JoinTable.class ); + + IndexColumn indexColumn =3D IndexColumn.buildColumnFromAnnotation( + indexAnn, propertyHolder, inferredData, mappings + ); + CollectionBinder collectionBinder =3D CollectionBinder.getCollectionBin= der( + propertyHolder.getEntityName(), + property, + !indexColumn.isImplicit() + ); + collectionBinder.setIndexColumn( indexColumn ); + MapKey mapKeyAnn =3D property.getAnnotation( MapKey.class ); + collectionBinder.setMapKey( mapKeyAnn ); + collectionBinder.setPropertyName( inferredData.getPropertyName() ); + BatchSize batchAnn =3D property.getAnnotation( BatchSize.class ); + collectionBinder.setBatchSize( batchAnn ); + javax.persistence.OrderBy ejb3OrderByAnn =3D property.getAnnotation( ja= vax.persistence.OrderBy.class ); + OrderBy orderByAnn =3D property.getAnnotation( OrderBy.class ); + collectionBinder.setEjb3OrderBy( ejb3OrderByAnn ); + collectionBinder.setSqlOrderBy( orderByAnn ); + Sort sortAnn =3D property.getAnnotation( Sort.class ); + collectionBinder.setSort( sortAnn ); + Cache cachAnn =3D property.getAnnotation( Cache.class ); + collectionBinder.setCache( cachAnn ); + collectionBinder.setPropertyHolder( propertyHolder ); + Cascade hibernateCascade =3D property.getAnnotation( Cascade.class ); + NotFound notFound =3D property.getAnnotation( NotFound.class ); + boolean ignoreNotFound =3D notFound !=3D null && notFound.action().equa= ls( NotFoundAction.IGNORE ); + collectionBinder.setIgnoreNotFound( ignoreNotFound ); + collectionBinder.setCollectionType( inferredData.getProperty().getEleme= ntClass() ); + collectionBinder.setMappings( mappings ); + collectionBinder.setPropertyAccessorName( inferredData.getDefaultAccess= () ); + + Ejb3Column[] elementColumns =3D null; + PropertyData virtualProperty =3D new WrappedInferredData( inferredData,= "element" ); + if ( property.isAnnotationPresent( Column.class ) || property.isAnnotat= ionPresent( + Formula.class + ) ) { + Column ann =3D property.getAnnotation( Column.class ); + Formula formulaAnn =3D property.getAnnotation( Formula.class ); + elementColumns =3D Ejb3Column.buildColumnFromAnnotation( + new Column[] { ann }, + formulaAnn, + nullability, + propertyHolder, + virtualProperty, + entityBinder.getSecondaryTables(), + mappings + ); + } + else if ( property.isAnnotationPresent( Columns.class ) ) { + Columns anns =3D property.getAnnotation( Columns.class ); + elementColumns =3D Ejb3Column.buildColumnFromAnnotation( + anns.columns(), null, nullability, propertyHolder, virtualProperty, + entityBinder.getSecondaryTables(), mappings + ); + } + else { + elementColumns =3D Ejb3Column.buildColumnFromAnnotation( + null, + null, + nullability, + propertyHolder, + virtualProperty, + entityBinder.getSecondaryTables(), + mappings + ); + } + + org.hibernate.annotations.MapKey hibMapKeyAnn =3D property.getAnnotatio= n( + org.hibernate.annotations.MapKey.class + ); + PropertyData mapKeyVirtualProperty =3D new WrappedInferredData( inferre= dData, "mapkey" ); + Ejb3Column[] mapColumns =3D Ejb3Column.buildColumnFromAnnotation( + hibMapKeyAnn !=3D null && hibMapKeyAnn.columns().length > 0 ? + hibMapKeyAnn.columns() : + null, + null, + Nullability.FORCED_NOT_NULL, + propertyHolder, + mapKeyVirtualProperty, + entityBinder.getSecondaryTables(), + mappings + ); + collectionBinder.setMapKeyColumns( mapColumns ); + + MapKeyManyToMany mapKeyManyToMany =3D property.getAnnotation( MapKeyMan= yToMany.class ); + Ejb3JoinColumn[] mapJoinColumns =3D Ejb3JoinColumn.buildJoinColumns( + mapKeyManyToMany !=3D null ? + mapKeyManyToMany.joinColumns() : + null, + null, entityBinder.getSecondaryTables(), + propertyHolder, mapKeyVirtualProperty.getPropertyName(), mappings + ); + collectionBinder.setMapKeyManyToManyColumns( mapJoinColumns ); + + //potential element + collectionBinder.setEmbedded( property.isAnnotationPresent( Embedded.cl= ass ) ); + collectionBinder.setElementColumns( elementColumns ); + collectionBinder.setProperty( property ); + + //TODO enhance exception with @ManyToAny and @CollectionOfElements + if ( oneToManyAnn !=3D null && manyToManyAnn !=3D null ) { + throw new AnnotationException( + "@OneToMany and @ManyToMany on the same property is not allowed: " + + propertyHolder.getEntityName() + "." + inferredData.getPropertyN= ame() + ); + } + String mappedBy =3D null; + if ( oneToManyAnn !=3D null ) { + for (Ejb3JoinColumn column : joinColumns) { + if ( column.isSecondary() ) { + throw new NotYetImplementedException( "Collections having FK in seco= ndary table" ); + } + } + collectionBinder.setFkJoinColumns( joinColumns ); + mappedBy =3D oneToManyAnn.mappedBy(); + collectionBinder.setTargetEntity( + mappings.getReflectionManager().toXClass( oneToManyAnn.targetEntity(= ) ) + ); + collectionBinder.setCascadeStrategy( getCascadeStrategy( oneToManyAnn.= cascade(), hibernateCascade ) ); + collectionBinder.setOneToMany( true ); + } + else if ( collectionOfElementsAnn !=3D null ) { + for (Ejb3JoinColumn column : joinColumns) { + if ( column.isSecondary() ) { + throw new NotYetImplementedException( "Collections having FK in seco= ndary table" ); + } + } + collectionBinder.setFkJoinColumns( joinColumns ); + mappedBy =3D ""; + collectionBinder.setTargetEntity( + mappings.getReflectionManager().toXClass( collectionOfElementsAnn.ta= rgetElement() ) + ); + //collectionBinder.setCascadeStrategy( getCascadeStrategy( embeddedCol= lectionAnn.cascade(), hibernateCascade ) ); + collectionBinder.setOneToMany( true ); + } + else if ( manyToManyAnn !=3D null ) { + mappedBy =3D manyToManyAnn.mappedBy(); + collectionBinder.setTargetEntity( + mappings.getReflectionManager().toXClass( manyToManyAnn.targetEntity= () ) + ); + collectionBinder.setCascadeStrategy( getCascadeStrategy( manyToManyAnn= .cascade(), hibernateCascade ) ); + collectionBinder.setOneToMany( false ); + } + else if ( property.isAnnotationPresent( ManyToAny.class ) ) { + mappedBy =3D ""; + collectionBinder.setTargetEntity( + mappings.getReflectionManager().toXClass( void.class ) + ); + collectionBinder.setCascadeStrategy( getCascadeStrategy( null, hiberna= teCascade ) ); + collectionBinder.setOneToMany( false ); + } + collectionBinder.setMappedBy( mappedBy ); + bindJoinedTableAssociation( + assocTable, mappings, entityBinder, collectionBinder, propertyHolder,= inferredData, mappedBy + ); + + OnDelete onDeleteAnn =3D property.getAnnotation( OnDelete.class ); + boolean onDeleteCascade =3D onDeleteAnn !=3D null && OnDeleteAction.CAS= CADE.equals( onDeleteAnn.action() ); + collectionBinder.setCascadeDeleteEnabled( onDeleteCascade ); + if ( isIdentifierMapper ) { + collectionBinder.setInsertable( false ); + collectionBinder.setUpdatable( false ); + } + if ( property.isAnnotationPresent( CollectionId.class ) ) { //do not co= mpute the generators unless necessary + HashMap localGenerators =3D (HashMap) classGenerators.clone(); + localGenerators.putAll( buildLocalGenerators( property, mappings ) ); + collectionBinder.setLocalGenerators( localGenerators ); + + } + collectionBinder.bind(); + + } + else { + //define whether the type is a component or not + boolean isComponent =3D false; + Embeddable embeddableAnn =3D returnedClass.getAnnotation( Embeddable.cl= ass ); + Embedded embeddedAnn =3D property.getAnnotation( Embedded.class ); + isComponent =3D embeddedAnn !=3D null || embeddableAnn !=3D null; + + if ( isComponent ) { + //process component object + //boolean propertyAccess =3D true; + //if ( embeddableAnn !=3D null && embeddableAnn.access() =3D=3D Access= Type.FIELD ) propertyAccess =3D false; + boolean propertyAnnotated =3D entityBinder.isPropertyAnnotated( proper= ty ); + String propertyAccessor =3D entityBinder.getPropertyAccessor( property= ); + bindComponent( + inferredData, propertyHolder, propertyAnnotated, propertyAccessor, e= ntityBinder, + isIdentifierMapper, + mappings, isComponentEmbedded + ); + } + else { + //provide the basic property mapping + boolean optional =3D true; + boolean lazy =3D false; + if ( property.isAnnotationPresent( Basic.class ) ) { + Basic ann =3D property.getAnnotation( Basic.class ); + optional =3D ann.optional(); + lazy =3D ann.fetch() =3D=3D FetchType.LAZY; + } + //implicit type will check basic types and Serializable classes + if ( !optional && nullability !=3D Nullability.FORCED_NULL ) { + //force columns to not null + for (Ejb3Column col : columns) { + col.forceNotNull(); + } + } + + PropertyBinder propBinder =3D new PropertyBinder(); + propBinder.setName( inferredData.getPropertyName() ); + propBinder.setReturnedClassName( inferredData.getTypeName() ); + propBinder.setLazy( lazy ); + propBinder.setPropertyAccessorName( inferredData.getDefaultAccess() ); + propBinder.setColumns( columns ); + propBinder.setHolder( propertyHolder ); + propBinder.setProperty( property ); + propBinder.setReturnedClass( inferredData.getPropertyClass() ); + propBinder.setMappings( mappings ); + if ( isIdentifierMapper ) { + propBinder.setInsertable( false ); + propBinder.setUpdatable( false ); + } + propBinder.bind(); + } + } + //init index + //process indexes after everything: in second pass, many to one has to b= e done before indexes + Index index =3D property.getAnnotation( Index.class ); + if ( index !=3D null ) { + if ( joinColumns !=3D null ) { + = + for (Ejb3Column column : joinColumns) { + column.addIndex( index, inSecondPass ); + } + } + else { + if ( columns !=3D null ) { + for (Ejb3Column column : columns) { + column.addIndex( index, inSecondPass ); + } + } + } + } + + NaturalId naturalIdAnn =3D property.getAnnotation( NaturalId.class ); + if ( naturalIdAnn !=3D null ) { + if ( joinColumns !=3D null ) { + for (Ejb3Column column : joinColumns) { + column.addUniqueKey( "_UniqueKey", inSecondPass ); + } + } + else { + for (Ejb3Column column : columns) { + column.addUniqueKey( "_UniqueKey", inSecondPass ); + } + } + } + } + + //TODO move that to collection binder? + private static void bindJoinedTableAssociation( + JoinTable joinTableAnn, ExtendedMappings mappings, EntityBinder entityB= inder, + CollectionBinder collectionBinder, PropertyHolder propertyHolder, Prope= rtyData inferredData, + String mappedBy + ) { + TableBinder associationTableBinder =3D new TableBinder(); + JoinColumn[] annJoins; + JoinColumn[] annInverseJoins; + if ( joinTableAnn !=3D null ) { + collectionBinder.setExplicitAssociationTable( true ); + if ( !BinderHelper.isDefault( joinTableAnn.schema() ) ) + associationTableBinder.setSchema( joinTableAnn.schema() ); + if ( !BinderHelper.isDefault( joinTableAnn.catalog() ) ) + associationTableBinder.setCatalog( joinTableAnn.catalog() ); + if ( !BinderHelper.isDefault( joinTableAnn.name() ) ) associationTableB= inder.setName( joinTableAnn.name() ); + associationTableBinder.setUniqueConstraints( joinTableAnn.uniqueConstra= ints() ); + + //set check constaint in the second pass + + JoinColumn[] joins =3D joinTableAnn.joinColumns(); + + if ( joins.length =3D=3D 0 ) { + annJoins =3D null; + } + else { + annJoins =3D joins; + } + + JoinColumn[] inverseJoins =3D joinTableAnn.inverseJoinColumns(); + + if ( inverseJoins.length =3D=3D 0 ) { + annInverseJoins =3D null; + } + else { + annInverseJoins =3D inverseJoins; + } + } + else { + annJoins =3D null; + annInverseJoins =3D null; + } + Ejb3JoinColumn[] joinColumns =3D Ejb3JoinColumn.buildJoinTableJoinColumn= s( + annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredD= ata.getPropertyName(), mappedBy, + mappings + ); + Ejb3JoinColumn[] inverseJoinColumns =3D Ejb3JoinColumn.buildJoinTableJoi= nColumns( + annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, in= ferredData.getPropertyName(), + mappedBy, mappings + ); + associationTableBinder.setMappings( mappings ); + collectionBinder.setTableBinder( associationTableBinder ); + collectionBinder.setJoinColumns( joinColumns ); + collectionBinder.setInverseJoinColumns( inverseJoinColumns ); + } + + private static void bindComponent( + PropertyData inferredData, + PropertyHolder propertyHolder, + boolean propertyAnnotated, + String propertyAccessor, EntityBinder entityBinder, + boolean isIdentifierMapper, + ExtendedMappings mappings, boolean isComponentEmbedded + ) { + Component comp =3D fillComponent( + propertyHolder, inferredData, propertyAnnotated, propertyAccessor, tru= e, entityBinder, + isComponentEmbedded, isIdentifierMapper, + false, mappings + ); + XProperty property =3D inferredData.getProperty(); + setupComponentTuplizer( property, comp ); + + PropertyBinder binder =3D new PropertyBinder(); + binder.setName( inferredData.getPropertyName() ); + binder.setValue( comp ); + binder.setProperty( inferredData.getProperty() ); + binder.setPropertyAccessorName( inferredData.getDefaultAccess() ); + Property prop =3D binder.make(); + propertyHolder.addProperty( prop ); + } + + public static Component fillComponent( + PropertyHolder propertyHolder, PropertyData inferredData, + boolean propertyAnnotated, String propertyAccessor, boolean isNullable, + EntityBinder entityBinder, + boolean isComponentEmbedded, boolean isIdentifierMapper, boolean inSeco= ndPass, ExtendedMappings mappings + ) { + /** + * inSecondPass can only be used to apply right away the second pass of = a composite-element + * Because it's a value type, there is no bidirectional association, hen= ce second pass + * ordering does not matter + */ + Component comp =3D new Component( propertyHolder.getPersistentClass() ); + comp.setEmbedded( isComponentEmbedded ); + //yuk + comp.setTable( propertyHolder.getTable() ); + if ( !isIdentifierMapper ) { + comp.setComponentClassName( inferredData.getClassOrElementName() ); + } + else { + comp.setComponentClassName( comp.getOwner().getClassName() ); + } + comp.setNodeName( inferredData.getPropertyName() ); + String subpath =3D StringHelper.qualify( propertyHolder.getPath(), infer= redData.getPropertyName() ); + log.debug( "Binding component with path: {}", subpath ); + PropertyHolder subHolder =3D PropertyHolderBuilder.buildPropertyHolder( + comp, subpath, + inferredData, propertyHolder, mappings + ); + List classElements =3D new ArrayList(); + XClass returnedClassOrElement =3D inferredData.getClassOrElement(); + addElementsOfAClass( + classElements, + subHolder, + propertyAnnotated, + propertyAccessor, returnedClassOrElement, mappings + ); + //add elements of the embeddable superclass + XClass superClass =3D inferredData.getPropertyClass().getSuperclass(); + while ( superClass !=3D null && superClass.isAnnotationPresent( MappedSu= perclass.class ) ) { + //FIXME: proper support of typevariables incl var resolved at upper lev= els + addElementsOfAClass( + classElements, + subHolder, + entityBinder.isPropertyAnnotated( superClass ), + propertyAccessor, superClass, mappings + ); + superClass =3D superClass.getSuperclass(); + } + for (PropertyData propertyAnnotatedElement : classElements) { + processElementAnnotations( + subHolder, isNullable ? + Nullability.NO_CONSTRAINT : + Nullability.FORCED_NOT_NULL, + propertyAnnotatedElement.getProperty(), propertyAnnotatedElement, + new HashMap(), entityBinder, isIdentifierMapper,= isComponentEmbedded, + inSecondPass, mappings + ); + } + return comp; + } + + private static void bindId( + String generatorType, String generatorName, + PropertyData inferredData, Ejb3Column[] columns, PropertyHolder propert= yHolder, + Map localGenerators, + boolean isComposite, + boolean isPropertyAnnotated, + String propertyAccessor, EntityBinder entityBinder, boolean isEmbedded, + boolean isIdentifierMapper, ExtendedMappings mappings + ) { + /* + * Fill simple value and property since and Id is a property + */ + PersistentClass persistentClass =3D propertyHolder.getPersistentClass(); + if ( !( persistentClass instanceof RootClass ) ) { + throw new AnnotationException( + "Unable to define/override @Id(s) on a subclass: " + + propertyHolder.getEntityName() + ); + } + RootClass rootClass =3D (RootClass) persistentClass; + String persistentClassName =3D rootClass =3D=3D null ? + null : + rootClass.getClassName(); + SimpleValue id; + if ( isComposite ) { + id =3D fillComponent( + propertyHolder, inferredData, isPropertyAnnotated, propertyAccessor, + false, entityBinder, isEmbedded, isIdentifierMapper, false, mappings + ); + Component componentId =3D (Component) id; + componentId.setKey( true ); + if ( rootClass.getIdentifier() !=3D null ) { + throw new AnnotationException( componentId.getComponentClassName() + "= must not have @Id properties when used as an @EmbeddedId" ); + } + if ( componentId.getPropertySpan() =3D=3D 0 ) { + throw new AnnotationException( componentId.getComponentClassName() + "= has no persistent id property" ); + } + //tuplizers + XProperty property =3D inferredData.getProperty(); + setupComponentTuplizer( property, componentId ); + } + else { + for (Ejb3Column column : columns) { + column.forceNotNull(); //this is an id + } + SimpleValueBinder value =3D new SimpleValueBinder(); + value.setPropertyName( inferredData.getPropertyName() ); + value.setReturnedClassName( inferredData.getTypeName() ); + value.setColumns( columns ); + value.setPersistentClassName( persistentClassName ); + value.setMappings( mappings ); + value.setType( inferredData.getProperty(), inferredData.getClassOrEleme= nt() ); + id =3D value.make(); + } + rootClass.setIdentifier( id ); + BinderHelper.makeIdGenerator( id, generatorType, generatorName, mappings= , localGenerators ); + if ( isEmbedded ) { + rootClass.setEmbeddedIdentifier( inferredData.getPropertyClass() =3D=3D= null ); + } + else { + PropertyBinder binder =3D new PropertyBinder(); + binder.setName( inferredData.getPropertyName() ); + binder.setValue( id ); + binder.setPropertyAccessorName( inferredData.getDefaultAccess() ); + binder.setProperty( inferredData.getProperty() ); + Property prop =3D binder.make(); + rootClass.setIdentifierProperty( prop ); + } + } + + private static void setupComponentTuplizer(XProperty property, Component = component) { + if ( property =3D=3D null ) return; + if ( property.isAnnotationPresent( Tuplizers.class ) ) { + for (Tuplizer tuplizer : property.getAnnotation( Tuplizers.class ).valu= e()) { + EntityMode mode =3D EntityMode.parse( tuplizer.entityMode() ); + component.addTuplizer( mode, tuplizer.impl().getName() ); + } + } + if ( property.isAnnotationPresent( Tuplizer.class ) ) { + Tuplizer tuplizer =3D property.getAnnotation( Tuplizer.class ); + EntityMode mode =3D EntityMode.parse( tuplizer.entityMode() ); + component.addTuplizer( mode, tuplizer.impl().getName() ); + } + } + + private static void bindManyToOne( + String cascadeStrategy, Ejb3JoinColumn[] columns, boolean optional, + boolean ignoreNotFound, boolean cascadeOnDelete, + XClass targetEntity, PropertyHolder propertyHolder, + PropertyData inferredData, boolean unique, boolean isIdentifierMapper, = boolean inSecondPass, + ExtendedMappings mappings + ) { + //All FK columns should be in the same table + org.hibernate.mapping.ManyToOne value =3D new org.hibernate.mapping.Many= ToOne( columns[0].getTable() ); + if ( isDefault( targetEntity, mappings ) ) { + value.setReferencedEntityName( inferredData.getClassOrElementName() ); + } + else { + value.setReferencedEntityName( targetEntity.getName() ); + } + defineFetchingStrategy( value, inferredData.getProperty() ); + //value.setFetchMode( fetchMode ); + value.setIgnoreNotFound( ignoreNotFound ); + value.setCascadeDeleteEnabled( cascadeOnDelete ); + //value.setLazy( fetchMode !=3D FetchMode.JOIN ); + if ( !optional ) { + for (Ejb3JoinColumn column : columns) { + column.setNullable( false ); + } + } + value.setTypeName( inferredData.getClassOrElementName() ); + final String propertyName =3D inferredData.getPropertyName(); + value.setTypeUsingReflection( propertyHolder.getClassName(), propertyNam= e ); + + ForeignKey fk =3D inferredData.getProperty().getAnnotation( ForeignKey.c= lass ); + String fkName =3D fk !=3D null ? + fk.name() : + ""; + if ( !BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName= ); + + String path =3D propertyHolder.getPath() + "." + propertyName; + FkSecondPass secondPass =3D new ToOneFkSecondPass( + value, columns, + !optional && unique, //cannot have nullabe and unique on certain DBs l= ike Derby + propertyHolder.getEntityOwnerClassName(), + path, mappings + ); + if ( inSecondPass ) { + secondPass.doSecondPass( mappings.getClasses() ); + } + else { + mappings.addSecondPass( + secondPass + ); + } + Ejb3Column.checkPropertyConsistency( columns, propertyHolder.getEntityNa= me() + propertyName ); + PropertyBinder binder =3D new PropertyBinder(); + binder.setName( propertyName ); + binder.setValue( value ); + //binder.setCascade(cascadeStrategy); + if ( isIdentifierMapper ) { + binder.setInsertable( false ); + binder.setUpdatable( false ); + } + else { + binder.setInsertable( columns[0].isInsertable() ); + binder.setUpdatable( columns[0].isUpdatable() ); + } + binder.setPropertyAccessorName( inferredData.getDefaultAccess() ); + binder.setCascade( cascadeStrategy ); + binder.setProperty(inferredData.getProperty()); + Property prop =3D binder.make(); + //composite FK columns are in the same table so its OK + propertyHolder.addProperty( prop, columns ); + } + + protected static void defineFetchingStrategy(ToOne toOne, XProperty prope= rty) { + LazyToOne lazy =3D property.getAnnotation( LazyToOne.class ); + Fetch fetch =3D property.getAnnotation( Fetch.class ); + ManyToOne manyToOne =3D property.getAnnotation( ManyToOne.class ); + OneToOne oneToOne =3D property.getAnnotation( OneToOne.class ); + FetchType fetchType; + if ( manyToOne !=3D null ) { + fetchType =3D manyToOne.fetch(); + } + else if ( oneToOne !=3D null ) { + fetchType =3D oneToOne.fetch(); + } + else { + throw new AssertionFailure( + "Define fetch strategy on a property not annotated with @OneToMany no= r @OneToOne" + ); + } + if ( lazy !=3D null ) { + toOne.setLazy( !( lazy.value() =3D=3D LazyToOneOption.FALSE ) ); + toOne.setUnwrapProxy( ( lazy.value() =3D=3D LazyToOneOption.NO_PROXY ) = ); + } + else { + toOne.setLazy( fetchType =3D=3D FetchType.LAZY ); + toOne.setUnwrapProxy( false ); + } + if ( fetch !=3D null ) { + if ( fetch.value() =3D=3D org.hibernate.annotations.FetchMode.JOIN ) { + toOne.setFetchMode( FetchMode.JOIN ); + toOne.setLazy( false ); + toOne.setUnwrapProxy( false ); + } + else if ( fetch.value() =3D=3D org.hibernate.annotations.FetchMode.SELE= CT ) { + toOne.setFetchMode( FetchMode.SELECT ); + } + else if ( fetch.value() =3D=3D org.hibernate.annotations.FetchMode.SUBS= ELECT ) { + throw new AnnotationException( "Use of FetchMode.SUBSELECT not allowed= on ToOne associations" ); + } + else { + throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() ); + } + } + else { + toOne.setFetchMode( getFetchMode( fetchType ) ); + } + } + + private static void bindOneToOne( + String cascadeStrategy, + Ejb3JoinColumn[] joinColumns, + boolean optional, + FetchMode fetchMode, + boolean ignoreNotFound, + boolean cascadeOnDelete, + XClass targetEntity, + PropertyHolder propertyHolder, + PropertyData inferredData, String mappedBy, + boolean trueOneToOne, + boolean isIdentifierMapper, boolean inSecondPass, ExtendedMappings mapp= ings + ) { + //column.getTable() =3D> persistentClass.getTable() + final String propertyName =3D inferredData.getPropertyName(); + log.debug( "Fetching {} with {}", propertyName, fetchMode ); + boolean mapToPK =3D true; + if ( !trueOneToOne ) { + //try to find a hidden true one to one (FK =3D=3D PK columns) + KeyValue identifier =3D propertyHolder.getIdentifier(); + if ( identifier =3D=3D null ) { + //this is a @OneToOne in a @EmbeddedId (the persistentClass.identifier= is not set yet, it's being built) + //by definition the PK cannot refers to itself so it cannot map to its= elf + mapToPK =3D false; + } + else { + Iterator idColumns =3D identifier.getColumnIterator(); + List idColumnNames =3D new ArrayList(); + org.hibernate.mapping.Column currentColumn; + while ( idColumns.hasNext() ) { + currentColumn =3D (org.hibernate.mapping.Column) idColumns.next(); + idColumnNames.add( currentColumn.getName() ); + } + for (Ejb3JoinColumn col : joinColumns) { + if ( !idColumnNames.contains( col.getMappingColumn().getName() ) ) { + mapToPK =3D false; + break; + } + } + } + } + if ( trueOneToOne || mapToPK || !BinderHelper.isDefault( mappedBy ) ) { + //is a true one-to-one + //FIXME referencedColumnName ignored =3D> ordering may fail. + OneToOneSecondPass secondPass =3D new OneToOneSecondPass( + mappedBy, + propertyHolder.getEntityName(), + propertyName, + propertyHolder, inferredData, targetEntity, ignoreNotFound, cascadeOn= Delete, + optional, cascadeStrategy, joinColumns, mappings + ); + if ( inSecondPass ) { + secondPass.doSecondPass( mappings.getClasses() ); + } + else { + mappings.addSecondPass( + secondPass, BinderHelper.isDefault( mappedBy ) + ); + } + } + else { + //has a FK on the table + bindManyToOne( + cascadeStrategy, joinColumns, optional, ignoreNotFound, cascadeOnDele= te, + targetEntity, + propertyHolder, inferredData, true, isIdentifierMapper, inSecondPass,= mappings + ); + } + } + + private static void bindAny( + String cascadeStrategy, Ejb3JoinColumn[] columns, boolean cascadeOnDele= te, Nullability nullability, + PropertyHolder propertyHolder, PropertyData inferredData, EntityBinder = entityBinder, + boolean isIdentifierMapper, ExtendedMappings mappings + ) { + org.hibernate.annotations.Any anyAnn =3D inferredData.getProperty().getA= nnotation( org.hibernate.annotations.Any.class ); + if ( anyAnn =3D=3D null ) { + throw new AssertionFailure( "Missing @Any annotation: " + + StringHelper.qualify( propertyHolder.getPath(), inferredData.getPro= pertyName() ) ); + } + Any value =3D BinderHelper.buildAnyValue( anyAnn.metaDef(), columns, any= Ann.metaColumn(), inferredData, + cascadeOnDelete, nullability, propertyHolder, entityBinder, anyAnn.opt= ional(), mappings ); + + PropertyBinder binder =3D new PropertyBinder(); + binder.setName( inferredData.getPropertyName() ); + binder.setValue( value ); + + binder.setLazy( anyAnn.fetch() =3D=3D FetchType.LAZY ); + //binder.setCascade(cascadeStrategy); + if ( isIdentifierMapper ) { + binder.setInsertable( false ); + binder.setUpdatable( false ); + } + else { + binder.setInsertable( columns[0].isInsertable() ); + binder.setUpdatable( columns[0].isUpdatable() ); + } + binder.setPropertyAccessorName( inferredData.getDefaultAccess() ); + binder.setCascade( cascadeStrategy ); + Property prop =3D binder.make(); + //composite FK columns are in the same table so its OK + propertyHolder.addProperty( prop, columns ); + } + + private static String generatorType(GenerationType generatorEnum) { + switch ( generatorEnum ) { + case IDENTITY: + return "identity"; + case AUTO: + return "native"; + case TABLE: + return MultipleHiLoPerTableGenerator.class.getName(); + case SEQUENCE: + return "seqhilo"; + } + throw new AssertionFailure( "Unknown GeneratorType: " + generatorEnum ); + } + + private static EnumSet convertToHibernateCascadeType(javax.p= ersistence.CascadeType[] ejbCascades) { + EnumSet hibernateCascadeSet =3D EnumSet.noneOf( CascadeType= .class ); + if ( ejbCascades !=3D null && ejbCascades.length > 0 ) { + for (javax.persistence.CascadeType cascade : ejbCascades) { + switch ( cascade ) { + case ALL: + hibernateCascadeSet.add( CascadeType.ALL ); + break; + case PERSIST: + hibernateCascadeSet.add( CascadeType.PERSIST ); + break; + case MERGE: + hibernateCascadeSet.add( CascadeType.MERGE ); + break; + case REMOVE: + hibernateCascadeSet.add( CascadeType.REMOVE ); + break; + case REFRESH: + hibernateCascadeSet.add( CascadeType.REFRESH ); + break; + } + } + } + + return hibernateCascadeSet; + } + + private static String getCascadeStrategy( + javax.persistence.CascadeType[] ejbCascades, Cascade hibernateCascadeAn= notation + ) { + EnumSet hibernateCascadeSet =3D convertToHibernateCascadeTy= pe( ejbCascades ); + CascadeType[] hibernateCascades =3D hibernateCascadeAnnotation =3D=3D nu= ll ? + null : + hibernateCascadeAnnotation.value(); + + if ( hibernateCascades !=3D null && hibernateCascades.length > 0 ) { + for (CascadeType cascadeType : hibernateCascades) { + hibernateCascadeSet.add( cascadeType ); + } + } + + StringBuilder cascade =3D new StringBuilder(); + Iterator cascadeType =3D hibernateCascadeSet.iterator(); + while ( cascadeType.hasNext() ) { + switch ( cascadeType.next() ) { + case ALL: + cascade.append( "," ).append( "all" ); + break; + case SAVE_UPDATE: + cascade.append( "," ).append( "save-update" ); + break; + case PERSIST: + cascade.append( "," ).append( "persist" ); + break; + case MERGE: + cascade.append( "," ).append( "merge" ); + break; + case LOCK: + cascade.append( "," ).append( "lock" ); + break; + case REFRESH: + cascade.append( "," ).append( "refresh" ); + break; + case REPLICATE: + cascade.append( "," ).append( "replicate" ); + break; + case EVICT: + cascade.append( "," ).append( "evict" ); + break; + case DELETE: + cascade.append( "," ).append( "delete" ); + break; + case DELETE_ORPHAN: + cascade.append( "," ).append( "delete-orphan" ); + break; + case REMOVE: + cascade.append( "," ).append( "delete" ); + break; + } + } + return cascade.length() > 0 ? + cascade.substring( 1 ) : + "none"; + } + + public static FetchMode getFetchMode(FetchType fetch) { + if ( fetch =3D=3D FetchType.EAGER ) { + return FetchMode.JOIN; + } + else { + return FetchMode.SELECT; + } + } + + private static HashMap buildLocalGenerators(XAnnotat= edElement annElt, Mappings mappings) { + HashMap generators =3D new HashMap(); + TableGenerator tabGen =3D annElt.getAnnotation( TableGenerator.class ); + SequenceGenerator seqGen =3D annElt.getAnnotation( SequenceGenerator.cla= ss ); + GenericGenerator genGen =3D annElt.getAnnotation( GenericGenerator.class= ); + if ( tabGen !=3D null ) { + IdGenerator idGen =3D buildIdGenerator( tabGen, mappings ); + generators.put( idGen.getName(), idGen ); + } + if ( seqGen !=3D null ) { + IdGenerator idGen =3D buildIdGenerator( seqGen, mappings ); + generators.put( idGen.getName(), idGen ); + } + if ( genGen !=3D null ) { + IdGenerator idGen =3D buildIdGenerator( genGen, mappings ); + generators.put( idGen.getName(), idGen ); + } + return generators; + } + + public static boolean isDefault(XClass clazz, ExtendedMappings mappings) { + return mappings.getReflectionManager().equals( clazz, void.class ); + } + + public static Map buildInheritanceStates( + List orderedClasses, ReflectionManager reflectionManager + ) { + Map inheritanceStatePerClass =3D new HashMap( + orderedClasses.size() + ); + for (XClass clazz : orderedClasses) { + InheritanceState superclassState =3D InheritanceState.getSuperclassInhe= ritanceState( + clazz, inheritanceStatePerClass, + reflectionManager + ); + InheritanceState state =3D new InheritanceState( clazz ); + if ( superclassState !=3D null ) { + //the classes are ordered thus preventing an NPE + //FIXME if an entity has subclasses annotated @MappedSperclass wo sub = @Entity this is wrong + superclassState.hasSons =3D true; + InheritanceState superEntityState =3D InheritanceState.getSuperEntityI= nheritanceState( + clazz, inheritanceStatePerClass, + reflectionManager + ); + state.hasParents =3D superEntityState !=3D null; + final boolean nonDefault =3D state.type !=3D null && !InheritanceType.= SINGLE_TABLE.equals( state.type ); + if ( superclassState.type !=3D null ) { + final boolean mixingStrategy =3D state.type !=3D null && !state.type.= equals( superclassState.type ); + if ( nonDefault && mixingStrategy ) { + log.warn( + "Mixing inheritance strategy in a entity hierarchy is not allowed,= ignoring sub strategy in: {}", + clazz.getName() + ); + } + state.type =3D superclassState.type; + } + } + inheritanceStatePerClass.put( clazz, state ); + } + return inheritanceStatePerClass; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/An= notationConfiguration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Annot= ationConfiguration.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Annot= ationConfiguration.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,1073 @@ +// $Id: AnnotationConfiguration.java 14990 2008-07-29 18:14:14Z hardy.fere= ntschik $ +package org.hibernate.cfg; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.Set; +import java.util.StringTokenizer; + +import javax.persistence.Entity; +import javax.persistence.MappedSuperclass; + +import org.dom4j.Attribute; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; +import org.hibernate.AnnotationException; +import org.hibernate.HibernateException; +import org.hibernate.Interceptor; +import org.hibernate.MappingException; +import org.hibernate.SessionFactory; +import org.hibernate.annotations.AnyMetaDef; +import org.hibernate.annotations.common.reflection.ReflectionManager; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.cfg.annotations.Version; +import org.hibernate.cfg.annotations.reflection.EJB3ReflectionManager; +import org.hibernate.event.EventListeners; +import org.hibernate.event.PreInsertEventListener; +import org.hibernate.event.PreUpdateEventListener; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Table; +import org.hibernate.mapping.UniqueKey; +import org.hibernate.util.JoinedIterator; +import org.hibernate.util.ReflectHelper; +import org.hibernate.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * Similar to the {@link Configuration} object but handles EJB3 and Hibern= ate + * specific annotations as a metadata facility. + * + * @author Emmanuel Bernard + * @author Hardy Ferentschik + */ +public class AnnotationConfiguration extends Configuration { + private Logger log =3D LoggerFactory.getLogger( AnnotationConfiguration.c= lass ); + = + /** + * Class name of the class needed to enable Search. + */ + private static final String SEARCH_STARTUP_CLASS =3D "org.hibernate.searc= h.event.EventListenerRegister"; + = + /** + * Method to call to enable Search. + */ = + private static final String SEARCH_STARTUP_METHOD =3D "enableHibernateSea= rch"; + + static { + Version.touch(); //touch version + } + + public static final String ARTEFACT =3D "hibernate.mapping.precedence"; + public static final String DEFAULT_PRECEDENCE =3D "hbm, class"; + + private Map namedGenerators; + private Map> joins; + private Map classTypes; + private Set defaultNamedQueryNames; + private Set defaultNamedNativeQueryNames; + private Set defaultSqlResulSetMappingNames; + private Set defaultNamedGenerators; + private Map generatorTables; + private Map> tableUniqueConstraints; + private Map mappedByResolver; + private Map propertyRefResolver; + private Map anyMetaDefs; + private List annotatedClasses; + private Map annotatedClassEntities; + private Map hbmEntities; + private List caches; + private List hbmDocuments; //user ordering matters, hence the l= ist + private String precedence =3D null; + private boolean inSecondPass =3D false; + private transient ReflectionManager reflectionManager; + private boolean isDefaultProcessed =3D false; + private boolean isValidatorNotPresentLogged; + + public AnnotationConfiguration() { + super(); + } + + public AnnotationConfiguration(SettingsFactory sf) { + super( sf ); + } + + protected List orderAndFillHierarchy(List original) { + //TODO remove embeddable + List copy =3D new ArrayList( original ); + //for each class, copy all the relevant hierarchy + for (XClass clazz : original) { + XClass superClass =3D clazz.getSuperclass(); + while ( superClass !=3D null && !reflectionManager.equals( superClass, = Object.class ) && !copy.contains( superClass ) ) { + if ( superClass.isAnnotationPresent( Entity.class ) + || superClass.isAnnotationPresent( MappedSuperclass.class ) ) { + copy.add( superClass ); + } + superClass =3D superClass.getSuperclass(); + } + } + List workingCopy =3D new ArrayList( copy ); + List newList =3D new ArrayList( copy.size() ); + while ( workingCopy.size() > 0 ) { + XClass clazz =3D workingCopy.get( 0 ); + orderHierarchy( workingCopy, newList, copy, clazz ); + } + return newList; + } + + private void orderHierarchy(List copy, List newList, List= original, XClass clazz) { + if ( clazz =3D=3D null || reflectionManager.equals( clazz, Object.class = ) ) return; + //process superclass first + orderHierarchy( copy, newList, original, clazz.getSuperclass() ); + if ( original.contains( clazz ) ) { + if ( !newList.contains( clazz ) ) { + newList.add( clazz ); + } + copy.remove( clazz ); + } + } + + /** + * Read a mapping from the class annotation metadata (JSR 175). + * + * @param persistentClass the mapped class + * @return the configuration object + */ + public AnnotationConfiguration addAnnotatedClass(Class persistentClass) t= hrows MappingException { + XClass persistentXClass =3D reflectionManager.toXClass( persistentClass = ); + try { + annotatedClasses.add( persistentXClass ); + return this; + } + catch (MappingException me) { + log.error( "Could not compile the mapping annotations", me ); + throw me; + } + } + + /** + * Read package level metadata + * + * @param packageName java package name + * @return the configuration object + */ + public AnnotationConfiguration addPackage(String packageName) throws Mapp= ingException { + log.info( "Mapping package {}", packageName ); + try { + AnnotationBinder.bindPackage( packageName, createExtendedMappings() ); + return this; + } + catch (MappingException me) { + log.error( "Could not compile the mapping annotations", me ); + throw me; + } + } + + public ExtendedMappings createExtendedMappings() { + return new ExtendedMappings( + classes, + collections, + tables, + namedQueries, + namedSqlQueries, + sqlResultSetMappings, + defaultNamedQueryNames, + defaultNamedNativeQueryNames, + defaultSqlResulSetMappingNames, + defaultNamedGenerators, + imports, + secondPasses, + propertyReferences, + namingStrategy, + typeDefs, + filterDefinitions, + namedGenerators, + joins, + classTypes, + extendsQueue, + tableNameBinding, columnNameBindingPerTable, auxiliaryDatabaseObjects, + generatorTables, + tableUniqueConstraints, + mappedByResolver, + propertyRefResolver, + anyMetaDefs, + reflectionManager + ); + } + + @Override + public void setCacheConcurrencyStrategy( + String clazz, String concurrencyStrategy, String region, boolean cacheL= azyProperty + ) throws MappingException { + caches.add( new CacheHolder( clazz, concurrencyStrategy, region, true, c= acheLazyProperty ) ); + } + + @Override + public void setCollectionCacheConcurrencyStrategy(String collectionRole, = String concurrencyStrategy, String region) + throws MappingException { + caches.add( new CacheHolder( collectionRole, concurrencyStrategy, region= , false, false ) ); + } + + @Override + protected void reset() { + super.reset(); + namedGenerators =3D new HashMap(); + joins =3D new HashMap>(); + classTypes =3D new HashMap(); + generatorTables =3D new HashMap(); + defaultNamedQueryNames =3D new HashSet(); + defaultNamedNativeQueryNames =3D new HashSet(); + defaultSqlResulSetMappingNames =3D new HashSet(); + defaultNamedGenerators =3D new HashSet(); + tableUniqueConstraints =3D new HashMap>(); + mappedByResolver =3D new HashMap(); + propertyRefResolver =3D new HashMap(); + annotatedClasses =3D new ArrayList(); + caches =3D new ArrayList(); + hbmEntities =3D new HashMap(); + annotatedClassEntities =3D new HashMap(); + hbmDocuments =3D new ArrayList(); + namingStrategy =3D EJB3NamingStrategy.INSTANCE; + setEntityResolver( new EJB3DTDEntityResolver() ); + anyMetaDefs =3D new HashMap(); + reflectionManager =3D new EJB3ReflectionManager(); + } + + @Override + protected void secondPassCompile() throws MappingException { + log.debug( "Execute first pass mapping processing" ); + //build annotatedClassEntities + { + List tempAnnotatedClasses =3D new ArrayList( annotatedC= lasses.size() ); + for (XClass clazz : annotatedClasses) { + if ( clazz.isAnnotationPresent( Entity.class ) ) { + annotatedClassEntities.put( clazz.getName(), clazz ); + tempAnnotatedClasses.add( clazz ); + } + else if ( clazz.isAnnotationPresent( MappedSuperclass.class ) ) { + tempAnnotatedClasses.add( clazz ); + } + //only keep MappedSuperclasses and Entity in this list + } + annotatedClasses =3D tempAnnotatedClasses; + } + + //process default values first + if ( !isDefaultProcessed ) { + AnnotationBinder.bindDefaults( createExtendedMappings() ); + isDefaultProcessed =3D true; + } + + //process entities + if ( precedence =3D=3D null ) precedence =3D getProperties().getProperty= ( ARTEFACT ); + if ( precedence =3D=3D null ) precedence =3D DEFAULT_PRECEDENCE; + StringTokenizer precedences =3D new StringTokenizer( precedence, ",; ", = false ); + if ( !precedences.hasMoreElements() ) { + throw new MappingException( ARTEFACT + " cannot be empty: " + precedenc= e ); + } + while ( precedences.hasMoreElements() ) { + String artifact =3D (String) precedences.nextElement(); + removeConflictedArtifact( artifact ); + processArtifactsOfType( artifact ); + } + + int cacheNbr =3D caches.size(); + for (int index =3D 0; index < cacheNbr; index++) { + CacheHolder cacheHolder =3D caches.get( index ); + if ( cacheHolder.isClass ) { + super.setCacheConcurrencyStrategy( + cacheHolder.role, cacheHolder.usage, cacheHolder.region, cacheHolder= .cacheLazy + ); + } + else { + super.setCollectionCacheConcurrencyStrategy( cacheHolder.role, cacheHo= lder.usage, cacheHolder.region ); + } + } + caches.clear(); + try { + inSecondPass =3D true; + processFkSecondPassInOrder(); + Iterator iter =3D secondPasses.iterator(); + while ( iter.hasNext() ) { + SecondPass sp =3D (SecondPass) iter.next(); + //do the second pass of fk before the others and remove them + if ( sp instanceof CreateKeySecondPass ) { + sp.doSecondPass( classes ); + iter.remove(); + } + } + + iter =3D secondPasses.iterator(); + while ( iter.hasNext() ) { + SecondPass sp =3D (SecondPass) iter.next(); + //do the SecondaryTable second pass before any association becasue ass= ociations can be built on joins + if ( sp instanceof SecondaryTableSecondPass ) { + sp.doSecondPass( classes ); + iter.remove(); + } + } + super.secondPassCompile(); + inSecondPass =3D false; + } + catch (RecoverableException e) { + //the exception was not recoverable after all + throw (RuntimeException) e.getCause(); + } + Iterator tables =3D tableUniqueConstraints.entrySet().iterator(); + Table table; + Map.Entry entry; + String keyName; + int uniqueIndexPerTable; + while ( tables.hasNext() ) { + entry =3D (Map.Entry) tables.next(); + table =3D (Table) entry.getKey(); + List uniqueConstraints =3D (List) entry.getValue(); + uniqueIndexPerTable =3D 0; + for (String[] columnNames : uniqueConstraints) { + keyName =3D "key" + uniqueIndexPerTable++; + buildUniqueKeyFromColumnNames( columnNames, table, keyName ); + } + } + boolean applyOnDdl =3D getProperties().getProperty( + "hibernate.validator.apply_to_ddl", //org.hibernate.validator.Environm= ent.APPLY_TO_DDL + "true" ) + .equalsIgnoreCase( "true" ); + + //TODO search for the method only once and cache it? + Constructor validatorCtr =3D null; + Method applyMethod =3D null; + try { + Class classValidator =3D ReflectHelper.classForName( "org.hibernate.val= idator.ClassValidator", this.getClass() ); + Class messageInterpolator =3D ReflectHelper.classForName( "org.hibernat= e.validator.MessageInterpolator", this.getClass() ); + validatorCtr =3D classValidator.getDeclaredConstructor( + Class.class, ResourceBundle.class, messageInterpolator, Map.class, Re= flectionManager.class + ); + applyMethod =3D classValidator.getMethod( "apply", PersistentClass.clas= s ); + } + catch (ClassNotFoundException e) { + if ( !isValidatorNotPresentLogged ) { + log.info( "Hibernate Validator not found: ignoring" ); + } + isValidatorNotPresentLogged =3D true; + } + catch (NoSuchMethodException e) { + throw new AnnotationException( e ); + } + if ( applyMethod !=3D null && applyOnDdl ) { + for (PersistentClass persistentClazz : (Collection) cl= asses.values()) { + //integrate the validate framework + String className =3D persistentClazz.getClassName(); + if ( StringHelper.isNotEmpty( className ) ) { + try { + Object validator =3D validatorCtr.newInstance( + ReflectHelper.classForName( className ), null, null, null, reflect= ionManager + ); + applyMethod.invoke( validator, persistentClazz ); + } + catch (Exception e) { + log.warn( "Unable to apply constraints on DDL for " + className, e ); + } + } + } + } + } + + /** + * Processes FKSecondPass instances trying to resolve any + * graph circularity (ie PK made of a many to one linking to + * an entity having a PK made of a ManyToOne ...). + */ + private void processFkSecondPassInOrder() { + log.debug( "processing fk mappings (*ToOne and JoinedSubclass)" ); + List fkSecondPasses =3D getFKSecondPassesOnly(); + = + if (fkSecondPasses.size() =3D=3D 0) { + return; // nothing to do here + } + = + // split FkSecondPass instances into primary key and non primary key FKs. + // While doing so build a map of class names to FkSecondPass instances d= epending on this class. + Map> isADependencyOf =3D new HashMap>(); + List endOfQueueFkSecondPasses =3D new ArrayList( fkSecondPasses.size() ); + for (FkSecondPass sp : fkSecondPasses) { + if ( sp.isInPrimaryKey() ) { + String referenceEntityName =3D sp.getReferencedEntityName(); + PersistentClass classMapping =3D getClassMapping( referenceEntityName = ); + String dependentTable =3D classMapping.getTable().getQuotedName(); + if ( !isADependencyOf.containsKey( dependentTable ) ) { + isADependencyOf.put( dependentTable, new HashSet() ); + } + isADependencyOf.get( dependentTable ).add( sp ); + } + else { + endOfQueueFkSecondPasses.add( sp ); + } + } + = + // using the isADependencyOf map we order the FkSecondPass recursively i= nstances into the right order for processing + List orderedFkSecondPasses =3D new ArrayList( fkSecondPass= es.size() ); + for (String tableName : isADependencyOf.keySet()) { + buildRecursiveOrderedFkSecondPasses(orderedFkSecondPasses, isADependenc= yOf, tableName, tableName); + } + = + // process the ordered FkSecondPasses + for ( FkSecondPass sp : orderedFkSecondPasses ) { + sp.doSecondPass( classes ); + } + + processEndOfQueue(endOfQueueFkSecondPasses); + } + + private void processEndOfQueue(List endOfQueueFkSecondPasses) { + /* + * If a second pass raises a recoverableException, queue it for next rou= nd + * stop of no pass has to be processed or if the number of pass to proce= sses + * does not diminish between two rounds. + * If some failing pass remain, raise the original exception + */ + boolean stopProcess =3D false; + RuntimeException originalException =3D null; + while ( ! stopProcess ) { + List failingSecondPasses =3D new ArrayList(); + Iterator it =3D endOfQueueFkSecondPasses.listIterator(); + while ( it.hasNext() ) { + final SecondPass pass =3D (SecondPass) it.next(); + try { + pass.doSecondPass( classes ); + } + catch (RecoverableException e) { + failingSecondPasses.add( pass ); + if (originalException =3D=3D null) originalException =3D (RuntimeExce= ption) e.getCause(); + } + } + stopProcess =3D failingSecondPasses.size() =3D=3D 0 || failingSecondPas= ses.size() =3D=3D endOfQueueFkSecondPasses.size(); + endOfQueueFkSecondPasses =3D failingSecondPasses; + } + if (endOfQueueFkSecondPasses.size() > 0) { + throw originalException; + } + } + + /** + * @return Returns a list of all secondPasses instances whic= h are a instance of + * FkSecondPass. + */ + private List getFKSecondPassesOnly() { + Iterator iter =3D secondPasses.iterator(); + List fkSecondPasses =3D new ArrayList(second= Passes.size()); + while ( iter.hasNext() ) { + SecondPass sp =3D (SecondPass) iter.next(); + //do the second pass of fk before the others and remove them + if ( sp instanceof FkSecondPass ) { + fkSecondPasses.add( (FkSecondPass) sp ); + iter.remove(); + } + } + return fkSecondPasses; + } + + /** + * Recursively builds a list of FkSecondPass instances ready to be proces= sed in this order. + * Checking all dependencies recursively seems quite expensive, but the o= riginal code just relied = + * on some sort of table name sorting which failed in certain circumstanc= es. + * = + * @param orderedFkSecondPasses The list containing the FkSecondPas= s instances ready = + * for processing. + * @param isADependencyOf Our lookup data structure to determine dependen= cies between tables + * @param startTable Table name to start recursive algorithm. + * @param currentTable The current table name used to check for 'new' dep= endencies. + * = + * @see ANN-722 ANN-730 + */ + private void buildRecursiveOrderedFkSecondPasses( + List orderedFkSecondPasses, + Map> isADependencyOf, String startTable, Stri= ng currentTable) { + + Set dependencies =3D isADependencyOf.get(currentTable); + = + // bottom out + if (dependencies =3D=3D null || dependencies.size() =3D=3D 0) { + return; + } + = + for (FkSecondPass sp : dependencies) { + String dependentTable =3D sp.getValue().getTable().getQuotedName(); + if (dependentTable.compareTo(startTable) =3D=3D 0) { + StringBuilder sb =3D new StringBuilder( + "Foreign key circularity dependency involving the following tables: = "); + throw new AnnotationException(sb.toString()); + } + buildRecursiveOrderedFkSecondPasses(orderedFkSecondPasses, isADependenc= yOf, startTable, dependentTable); + if (!orderedFkSecondPasses.contains(sp)) { + orderedFkSecondPasses.add(0, sp); + } + } = + } + + private void processArtifactsOfType(String artifact) { + if ( "hbm".equalsIgnoreCase( artifact ) ) { + log.debug( "Process hbm files" ); + for (Document document : hbmDocuments) { + super.add( document ); + } + hbmDocuments.clear(); + hbmEntities.clear(); + } + else if ( "class".equalsIgnoreCase( artifact ) ) { + log.debug( "Process annotated classes" ); + //bind classes in the correct order calculating some inheritance state + List orderedClasses =3D orderAndFillHierarchy( annotatedClasses= ); + Map inheritanceStatePerClass =3D AnnotationBi= nder.buildInheritanceStates( + orderedClasses, reflectionManager + ); + ExtendedMappings mappings =3D createExtendedMappings(); + for (XClass clazz : orderedClasses) { + //todo use the same extended mapping + AnnotationBinder.bindClass( clazz, inheritanceStatePerClass, mappings = ); + } + annotatedClasses.clear(); + annotatedClassEntities.clear(); + } + else { + log.warn( "Unknown artifact: {}", artifact ); + } + } + + private void removeConflictedArtifact(String artifact) { + if ( "hbm".equalsIgnoreCase( artifact ) ) { + for (String entity : hbmEntities.keySet()) { + if ( annotatedClassEntities.containsKey( entity ) ) { + annotatedClasses.remove( annotatedClassEntities.get( entity ) ); + annotatedClassEntities.remove( entity ); + } + } + } + else if ( "class".equalsIgnoreCase( artifact ) ) { + for (String entity : annotatedClassEntities.keySet()) { + if ( hbmEntities.containsKey( entity ) ) { + hbmDocuments.remove( hbmEntities.get( entity ) ); + hbmEntities.remove( entity ); + } + } + } + } + + private void buildUniqueKeyFromColumnNames(String[] columnNames, Table ta= ble, String keyName) { + UniqueKey uc; + int size =3D columnNames.length; + Column[] columns =3D new Column[size]; + Set unbound =3D new HashSet(); + Set unboundNoLogical =3D new HashSet(); + ExtendedMappings mappings =3D createExtendedMappings(); + for (int index =3D 0; index < size; index++) { + String columnName; + try { + columnName =3D mappings.getPhysicalColumnName( columnNames[index], tab= le ); + columns[index] =3D new Column( columnName ); + unbound.add( columns[index] ); + //column equals and hashcode is based on column name + } + catch (MappingException e) { + unboundNoLogical.add( new Column( columnNames[index] ) ); + } + } + for (Column column : columns) { + if ( table.containsColumn( column ) ) { + uc =3D table.getOrCreateUniqueKey( keyName ); + uc.addColumn( table.getColumn( column ) ); + unbound.remove( column ); + } + } + if ( unbound.size() > 0 || unboundNoLogical.size() > 0 ) { + StringBuilder sb =3D new StringBuilder( "Unable to create unique key co= nstraint (" ); + for (String columnName : columnNames) { + sb.append( columnName ).append( ", " ); + } + sb.setLength( sb.length() - 2 ); + sb.append( ") on table " ).append( table.getName() ).append( ": " ); + for (Column column : unbound) { + sb.append( column.getName() ).append( ", " ); + } + for (Column column : unboundNoLogical) { + sb.append( column.getName() ).append( ", " ); + } + sb.setLength( sb.length() - 2 ); + sb.append( " not found" ); + throw new AnnotationException( sb.toString() ); + } + } + + @Override + protected void parseMappingElement(Element subelement, String name) { + Attribute rsrc =3D subelement.attribute( "resource" ); + Attribute file =3D subelement.attribute( "file" ); + Attribute jar =3D subelement.attribute( "jar" ); + Attribute pckg =3D subelement.attribute( "package" ); + Attribute clazz =3D subelement.attribute( "class" ); + if ( rsrc !=3D null ) { + log.debug( "{} <- {}", name, rsrc ); + addResource( rsrc.getValue() ); + } + else if ( jar !=3D null ) { + log.debug( "{} <- {}", name, jar ); + addJar( new File( jar.getValue() ) ); + } + else if ( file !=3D null ) { + log.debug( "{} <- {}", name, file ); + addFile( file.getValue() ); + } + else if ( pckg !=3D null ) { + log.debug( "{} <- {}", name, pckg ); + addPackage( pckg.getValue() ); + } + else if ( clazz !=3D null ) { + log.debug( "{} <- {}", name, clazz ); + Class loadedClass; + try { + loadedClass =3D ReflectHelper.classForName( clazz.getValue() ); + } + catch (ClassNotFoundException cnf) { + throw new MappingException( + "Unable to load class declared as in the configuration:", + cnf + ); + } + catch (NoClassDefFoundError ncdf) { + throw new MappingException( + "Unable to load class declared as in the configuration:", + ncdf + ); + } + + addAnnotatedClass( loadedClass ); + } + else { + throw new MappingException( " element in configuration specifi= es no attributes" ); + } + } + + @Override + protected void add(org.dom4j.Document doc) throws MappingException { + boolean ejb3Xml =3D "entity-mappings".equals( doc.getRootElement().getNa= me() ); + if ( inSecondPass ) { + //if in second pass bypass the queueing, getExtendedQueue reuse this me= thod + if ( !ejb3Xml ) super.add( doc ); + } + else { + if ( !ejb3Xml ) { + final Element hmNode =3D doc.getRootElement(); + Attribute packNode =3D hmNode.attribute( "package" ); + String defaultPackage =3D packNode !=3D null + ? packNode.getValue() + : ""; + Set entityNames =3D new HashSet(); + findClassNames( defaultPackage, hmNode, entityNames ); + for (String entity : entityNames) { + hbmEntities.put( entity, doc ); + } + hbmDocuments.add( doc ); + } + else { + List classnames =3D ( (EJB3ReflectionManager) reflectionManage= r ).getXMLContext().addDocument( doc ); + for (String classname : classnames) { + try { + annotatedClasses.add( reflectionManager.classForName( classname, thi= s.getClass() ) ); + } + catch (ClassNotFoundException e) { + throw new AnnotationException( "Unable to load class defined in XML:= " + classname, e ); + } + } + } + } + } + + private static void findClassNames( + String defaultPackage, final Element startNode, + final java.util.Set names + ) { + // if we have some extends we need to check if those classes possibly co= uld be inside the + // same hbm.xml file... + Iterator[] classes =3D new Iterator[4]; + classes[0] =3D startNode.elementIterator( "class" ); + classes[1] =3D startNode.elementIterator( "subclass" ); + classes[2] =3D startNode.elementIterator( "joined-subclass" ); + classes[3] =3D startNode.elementIterator( "union-subclass" ); + + Iterator classIterator =3D new JoinedIterator( classes ); + while ( classIterator.hasNext() ) { + Element element =3D (Element) classIterator.next(); + String entityName =3D element.attributeValue( "entity-name" ); + if ( entityName =3D=3D null ) entityName =3D getClassName( element.attr= ibute( "name" ), defaultPackage ); + names.add( entityName ); + findClassNames( defaultPackage, element, names ); + } + } + + private static String getClassName(Attribute name, String defaultPackage)= { + if ( name =3D=3D null ) return null; + String unqualifiedName =3D name.getValue(); + if ( unqualifiedName =3D=3D null ) return null; + if ( unqualifiedName.indexOf( '.' ) < 0 && defaultPackage !=3D null ) { + return defaultPackage + '.' + unqualifiedName; + } + return unqualifiedName; + } + + public void setPrecedence(String precedence) { + this.precedence =3D precedence; + } + + private static class CacheHolder { + public CacheHolder(String role, String usage, String region, boolean isC= lass, boolean cacheLazy) { + this.role =3D role; + this.usage =3D usage; + this.region =3D region; + this.isClass =3D isClass; + this.cacheLazy =3D cacheLazy; + } + + public String role; + public String usage; + public String region; + public boolean isClass; + public boolean cacheLazy; + } + + @Override + public AnnotationConfiguration addInputStream(InputStream xmlInputStream)= throws MappingException { + try { + List errors =3D new ArrayList(); + SAXReader saxReader =3D xmlHelper.createSAXReader( "XML InputStream", e= rrors, getEntityResolver() ); + try { + saxReader.setFeature( "http://apache.org/xml/features/validation/schem= a", true ); + //saxReader.setFeature( "http://apache.org/xml/features/validation/dyn= amic", true ); + //set the default schema locators + saxReader.setProperty( + "http://apache.org/xml/properties/schema/external-schemaLocation", + "http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd" + ); + } + catch (SAXException e) { + saxReader.setValidation( false ); + } + org.dom4j.Document doc =3D saxReader + .read( new InputSource( xmlInputStream ) ); + + if ( errors.size() !=3D 0 ) { + throw new MappingException( "invalid mapping", (Throwable) errors.get(= 0 ) ); + } + add( doc ); + return this; + } + catch (DocumentException e) { + throw new MappingException( "Could not parse mapping document in input = stream", e ); + } + finally { + try { + xmlInputStream.close(); + } + catch (IOException ioe) { + log.warn( "Could not close input stream", ioe ); + } + } + } + + public SessionFactory buildSessionFactory() throws HibernateException { + //add validator events if the jar is available + boolean enableValidatorListeners =3D !"false".equalsIgnoreCase( getPrope= rty( "hibernate.validator.autoregister_listeners" ) ); + Class validateEventListenerClass =3D null; + try { + validateEventListenerClass =3D ReflectHelper.classForName( + "org.hibernate.validator.event.ValidateEventListener", + AnnotationConfiguration.class ); + } + catch (ClassNotFoundException e) { + //validator is not present + log.debug( "Validator not present in classpath, ignoring event listener= registration" ); + } + if ( enableValidatorListeners && validateEventListenerClass !=3D null ) { + //TODO so much duplication + Object validateEventListener; + try { + validateEventListener =3D validateEventListenerClass.newInstance(); + } + catch (Exception e) { + throw new AnnotationException( "Unable to load Validator event listene= r", e ); + } + { + boolean present =3D false; + PreInsertEventListener[] listeners =3D getEventListeners().getPreInser= tEventListeners(); + if ( listeners !=3D null ) { + for (Object eventListener : listeners) { + //not isAssignableFrom since the user could subclass + present =3D present || validateEventListenerClass =3D=3D eventListen= er.getClass(); + } + if ( !present ) { + int length =3D listeners.length + 1; + PreInsertEventListener[] newListeners =3D new PreInsertEventListener= [length]; + System.arraycopy( listeners, 0, newListeners, 0, length - 1 ); + newListeners[length - 1] =3D (PreInsertEventListener) validateEventL= istener; + getEventListeners().setPreInsertEventListeners( newListeners ); + } + } + else { + getEventListeners().setPreInsertEventListeners( + new PreInsertEventListener[] { (PreInsertEventListener) validateEve= ntListener } + ); + } + } + + //update event listener + { + boolean present =3D false; + PreUpdateEventListener[] listeners =3D getEventListeners().getPreUpdat= eEventListeners(); + if ( listeners !=3D null ) { + for (Object eventListener : listeners) { + //not isAssignableFrom since the user could subclass + present =3D present || validateEventListenerClass =3D=3D eventListen= er.getClass(); + } + if ( !present ) { + int length =3D listeners.length + 1; + PreUpdateEventListener[] newListeners =3D new PreUpdateEventListener= [length]; + System.arraycopy( listeners, 0, newListeners, 0, length - 1 ); + newListeners[length - 1] =3D (PreUpdateEventListener) validateEventL= istener; + getEventListeners().setPreUpdateEventListeners( newListeners ); + } + } + else { + getEventListeners().setPreUpdateEventListeners( + new PreUpdateEventListener[] { (PreUpdateEventListener) validateEve= ntListener } + ); + } + } + } + = + enableHibernateSearch(); = + = + return super.buildSessionFactory(); + } + + /** + * Tries to automatically register Hibernate Search event listeners by lo= cating the = + * appropriate bootstrap class and calling the enableHibernateSearc= h method. + */ + private void enableHibernateSearch() { + // load the bootstrap class + Class searchStartupClass; + try { + searchStartupClass =3D ReflectHelper.classForName(SEARCH_STARTUP_CLASS,= AnnotationConfiguration.class); = + } catch ( ClassNotFoundException e ) { + // TODO remove this together with SearchConfiguration after 3.1.0 relea= se of Search + // try loading deprecated HibernateSearchEventListenerRegister + try { + searchStartupClass =3D ReflectHelper.classForName("org.hibernate.cfg.s= earch.HibernateSearchEventListenerRegister", AnnotationConfiguration.class); + } catch ( ClassNotFoundException cnfe ) { + log.debug("Search not present in classpath, ignoring event listener re= gistration."); + return; + } + } + = + // call the method for registering the listeners + try { + Object searchStartupInstance =3D searchStartupClass.newInstance(); + Method enableSearchMethod =3D searchStartupClass.getDeclaredMethod(SEAR= CH_STARTUP_METHOD, + EventListeners.class, Properties.class); + enableSearchMethod.invoke(searchStartupInstance, getEventListeners(), g= etProperties()); + } catch ( InstantiationException e ) { + log.debug("Unable to instantiate {}, ignoring event listener registrati= on.", SEARCH_STARTUP_CLASS); + } catch ( IllegalAccessException e ) { + log.debug("Unable to instantiate {}, ignoring event listener registrati= on.", SEARCH_STARTUP_CLASS); + } catch ( NoSuchMethodException e ) { + log.debug("Method enableHibernateSearch() not found in {}.", SEARCH_STA= RTUP_CLASS); + } catch ( InvocationTargetException e ) { + log.debug("Unable to execute {}, ignoring event listener registration."= , SEARCH_STARTUP_METHOD); + } + } + + @Override + public AnnotationConfiguration addFile(String xmlFile) throws MappingExce= ption { + super.addFile( xmlFile ); + return this; + } + + @Override + public AnnotationConfiguration addFile(File xmlFile) throws MappingExcept= ion { + super.addFile( xmlFile ); + return this; + } + + @Override + public AnnotationConfiguration addCacheableFile(File xmlFile) throws Mapp= ingException { + super.addCacheableFile( xmlFile ); + return this; + } + + @Override + public AnnotationConfiguration addCacheableFile(String xmlFile) throws Ma= ppingException { + super.addCacheableFile( xmlFile ); + return this; + } + + @Override + public AnnotationConfiguration addXML(String xml) throws MappingException= { + super.addXML( xml ); + return this; + } + + @Override + public AnnotationConfiguration addURL(URL url) throws MappingException { + super.addURL( url ); + return this; + } + + @Override + public AnnotationConfiguration addResource(String resourceName, ClassLoad= er classLoader) throws MappingException { + super.addResource( resourceName, classLoader ); + return this; + } + + @Override + public AnnotationConfiguration addDocument(org.w3c.dom.Document doc) thro= ws MappingException { + super.addDocument( doc ); + return this; + } + + @Override + public AnnotationConfiguration addResource(String resourceName) throws Ma= ppingException { + super.addResource( resourceName ); + return this; + } + + @Override + public AnnotationConfiguration addClass(Class persistentClass) throws Map= pingException { + super.addClass( persistentClass ); + return this; + } + + @Override + public AnnotationConfiguration addJar(File jar) throws MappingException { + super.addJar( jar ); + return this; + } + + @Override + public AnnotationConfiguration addDirectory(File dir) throws MappingExcep= tion { + super.addDirectory( dir ); + return this; + } + + @Override + public AnnotationConfiguration setInterceptor(Interceptor interceptor) { + super.setInterceptor( interceptor ); + return this; + } + + @Override + public AnnotationConfiguration setProperties(Properties properties) { + super.setProperties( properties ); + return this; + } + + @Override + public AnnotationConfiguration addProperties(Properties extraProperties) { + super.addProperties( extraProperties ); + return this; + } + + @Override + public AnnotationConfiguration mergeProperties(Properties properties) { + super.mergeProperties( properties ); + return this; + } + + @Override + public AnnotationConfiguration setProperty(String propertyName, String va= lue) { + super.setProperty( propertyName, value ); + return this; + } + + @Override + public AnnotationConfiguration configure() throws HibernateException { + super.configure(); + return this; + } + + @Override + public AnnotationConfiguration configure(String resource) throws Hibernat= eException { + super.configure( resource ); + return this; + } + + @Override + public AnnotationConfiguration configure(URL url) throws HibernateExcepti= on { + super.configure( url ); + return this; + } + + @Override + public AnnotationConfiguration configure(File configFile) throws Hibernat= eException { + super.configure( configFile ); + return this; + } + + @Override + protected AnnotationConfiguration doConfigure(InputStream stream, String = resourceName) throws HibernateException { + super.doConfigure( stream, resourceName ); + return this; + } + + @Override + public AnnotationConfiguration configure(org.w3c.dom.Document document) t= hrows HibernateException { + super.configure( document ); + return this; + } + + @Override + protected AnnotationConfiguration doConfigure(Document doc) throws Hibern= ateException { + super.doConfigure( doc ); + return this; + } + + @Override + public AnnotationConfiguration setCacheConcurrencyStrategy(String clazz, = String concurrencyStrategy) throws MappingException { + super.setCacheConcurrencyStrategy( clazz, concurrencyStrategy ); + return this; + } + + @Override + public AnnotationConfiguration setCollectionCacheConcurrencyStrategy(Stri= ng collectionRole, String concurrencyStrategy) throws MappingException { + super.setCollectionCacheConcurrencyStrategy( collectionRole, concurrency= Strategy ); + return this; + } + + @Override + public AnnotationConfiguration setNamingStrategy(NamingStrategy namingStr= ategy) { + super.setNamingStrategy( namingStrategy ); + return this; + } + + //not a public API + public ReflectionManager getReflectionManager() { + return reflectionManager; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Bi= nderHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Binde= rHelper.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Binde= rHelper.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,556 @@ +//$Id: BinderHelper.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.cfg; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.StringTokenizer; + +import org.hibernate.AnnotationException; +import org.hibernate.AssertionFailure; +import org.hibernate.MappingException; +import org.hibernate.annotations.AnyMetaDef; +import org.hibernate.annotations.AnyMetaDefs; +import org.hibernate.annotations.MetaValue; +import org.hibernate.annotations.common.reflection.XAnnotatedElement; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XPackage; +import org.hibernate.cfg.annotations.EntityBinder; +import org.hibernate.cfg.annotations.Nullability; +import org.hibernate.cfg.annotations.TableBinder; +import org.hibernate.id.MultipleHiLoPerTableGenerator; +import org.hibernate.id.PersistentIdentifierGenerator; +import org.hibernate.mapping.Any; +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.Component; +import org.hibernate.mapping.IdGenerator; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.Table; +import org.hibernate.mapping.ToOne; +import org.hibernate.mapping.Value; +import org.hibernate.type.TypeFactory; +import org.hibernate.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Emmanuel Bernard + */ +public class BinderHelper { + + public static final String ANNOTATION_STRING_DEFAULT =3D ""; + private static Logger log =3D LoggerFactory.getLogger( BinderHelper.class= ); + + private BinderHelper() { + } + + static { + Set primitiveNames =3D new HashSet(); + primitiveNames.add( byte.class.getName() ); + primitiveNames.add( short.class.getName() ); + primitiveNames.add( int.class.getName() ); + primitiveNames.add( long.class.getName() ); + primitiveNames.add( float.class.getName() ); + primitiveNames.add( double.class.getName() ); + primitiveNames.add( char.class.getName() ); + primitiveNames.add( boolean.class.getName() ); + PRIMITIVE_NAMES =3D Collections.unmodifiableSet( primitiveNames ); + } + + public static final Set PRIMITIVE_NAMES; + + /** + * create a property copy reusing the same value + */ + public static Property shallowCopy(Property property) { + Property clone =3D new Property(); + clone.setCascade( property.getCascade() ); + clone.setInsertable( property.isInsertable() ); + clone.setLazy( property.isLazy() ); + clone.setName( property.getName() ); + clone.setNodeName( property.getNodeName() ); + clone.setNaturalIdentifier( property.isNaturalIdentifier() ); + clone.setOptimisticLocked( property.isOptimisticLocked() ); + clone.setOptional( property.isOptional() ); + clone.setPersistentClass( property.getPersistentClass() ); + clone.setPropertyAccessorName( property.getPropertyAccessorName() ); + clone.setSelectable( property.isSelectable() ); + clone.setUpdateable( property.isUpdateable() ); + clone.setValue( property.getValue() ); + return clone; + } + + public static void createSyntheticPropertyReference( + Ejb3JoinColumn[] columns, + PersistentClass ownerEntity, + PersistentClass associatedEntity, + Value value, + boolean inverse, ExtendedMappings mappings + ) { + //associated entity only used for more precise exception, yuk! + if ( columns[0].isImplicit() || StringHelper.isNotEmpty( columns[0].getM= appedBy() ) ) return; + int fkEnum =3D Ejb3JoinColumn.checkReferencedColumnsType( columns, owner= Entity, mappings ); + PersistentClass associatedClass =3D columns[0].getPropertyHolder() !=3D = null ? + columns[0].getPropertyHolder().getPersistentClass() : + null; + if ( Ejb3JoinColumn.NON_PK_REFERENCE =3D=3D fkEnum ) { + /** + * Create a synthetic property to refer to including an + * embedded component value containing all the properties + * mapped to the referenced columns + * We need to shallow copy those properties to mark them + * as non insertable / non updatable + */ + StringBuilder propertyNameBuffer =3D new StringBuilder( "_" ); + propertyNameBuffer.append( associatedClass.getEntityName().replace( '.'= , '_' ) ); + propertyNameBuffer.append( "_" ).append( columns[0].getPropertyName() ); + String syntheticPropertyName =3D propertyNameBuffer.toString(); + //find properties associated to a certain column + Object columnOwner =3D findColumnOwner( ownerEntity, columns[0].getRefe= rencedColumn(), mappings ); + List properties =3D findPropertiesByColumns( columnOwner, col= umns, mappings ); + //create an embeddable component + Property synthProp =3D null; + if ( properties !=3D null ) { + //todo how about properties.size() =3D=3D 1, this should be much simpl= er + Component embeddedComp =3D columnOwner instanceof PersistentClass ? + new Component( (PersistentClass) columnOwner ) : + new Component( (Join) columnOwner ); + embeddedComp.setEmbedded( true ); + embeddedComp.setNodeName( syntheticPropertyName ); + embeddedComp.setComponentClassName( embeddedComp.getOwner().getClassNa= me() ); + for (Property property : properties) { + Property clone =3D BinderHelper.shallowCopy( property ); + clone.setInsertable( false ); + clone.setUpdateable( false ); + clone.setNaturalIdentifier( false ); + embeddedComp.addProperty( clone ); + } + synthProp =3D new Property(); + synthProp.setName( syntheticPropertyName ); + synthProp.setNodeName( syntheticPropertyName ); + synthProp.setPersistentClass( ownerEntity ); + synthProp.setUpdateable( false ); + synthProp.setInsertable( false ); + synthProp.setValue( embeddedComp ); + synthProp.setPropertyAccessorName( "embedded" ); + ownerEntity.addProperty( synthProp ); + //make it unique + TableBinder.createUniqueConstraint( embeddedComp ); + } + else { + //TODO use a ToOne type doing a second select + StringBuilder columnsList =3D new StringBuilder(); + columnsList.append( "referencedColumnNames(" ); + for (Ejb3JoinColumn column : columns) { + columnsList.append( column.getReferencedColumn() ).append( ", " ); + } + columnsList.setLength( columnsList.length() - 2 ); + columnsList.append( ") " ); + + if ( associatedEntity !=3D null ) { + //overidden destination + columnsList.append( "of " ) + .append( associatedEntity.getEntityName() ) + .append( "." ) + .append( columns[0].getPropertyName() ) + .append( " " ); + } + else { + if ( columns[0].getPropertyHolder() !=3D null ) { + columnsList.append( "of " ) + .append( columns[0].getPropertyHolder().getEntityName() ) + .append( "." ) + .append( columns[0].getPropertyName() ) + .append( " " ); + } + } + columnsList.append( "referencing " ) + .append( ownerEntity.getEntityName() ) + .append( " not mapped to a single property" ); + throw new AnnotationException( columnsList.toString() ); + } + + /** + * creating the property ref to the new synthetic property + */ + if ( value instanceof ToOne ) { + ( (ToOne) value ).setReferencedPropertyName( syntheticPropertyName ); + mappings.addUniquePropertyReference( ownerEntity.getEntityName(), synt= heticPropertyName ); + } + else if ( value instanceof Collection ) { + ( (Collection) value ).setReferencedPropertyName( syntheticPropertyNam= e ); + //not unique because we could create a mtm wo association table + mappings.addPropertyReference( ownerEntity.getEntityName(), syntheticP= ropertyName ); + } + else { + throw new AssertionFailure( + "Do a property ref on an unexpected Value type: " + + value.getClass().getName() + ); + } + mappings.addPropertyReferencedAssociation( + ( inverse ? "inverse__" : "" ) + associatedClass.getEntityName(), + columns[0].getPropertyName(), + syntheticPropertyName + ); + } + } + + + private static List findPropertiesByColumns( + Object columnOwner, Ejb3JoinColumn[] columns, + ExtendedMappings mappings + ) { + Map> columnsToProperty =3D new HashMap>(); + List orderedColumns =3D new ArrayList( columns.length ); + Table referencedTable =3D null; + if ( columnOwner instanceof PersistentClass ) { + referencedTable =3D ( (PersistentClass) columnOwner ).getTable(); + } + else if ( columnOwner instanceof Join ) { + referencedTable =3D ( (Join) columnOwner ).getTable(); + } + else { + throw new AssertionFailure( + columnOwner =3D=3D null ? + "columnOwner is null" : + "columnOwner neither PersistentClass nor Join: " + columnOwner.getC= lass() + ); + } + //build the list of column names + for (Ejb3JoinColumn column1 : columns) { + Column column =3D new Column( + mappings.getPhysicalColumnName( column1.getReferencedColumn(), refere= ncedTable ) + ); + orderedColumns.add( column ); + columnsToProperty.put( column, new HashSet() ); + } + boolean isPersistentClass =3D columnOwner instanceof PersistentClass; + Iterator it =3D isPersistentClass ? + ( (PersistentClass) columnOwner ).getPropertyIterator() : + ( (Join) columnOwner ).getPropertyIterator(); + while ( it.hasNext() ) { + matchColumnsByProperty( (Property) it.next(), columnsToProperty ); + } + if ( isPersistentClass ) { + matchColumnsByProperty( ( (PersistentClass) columnOwner ).getIdentifier= Property(), columnsToProperty ); + } + + //first naive implementation + //only check 1 columns properties + //TODO make it smarter by checking correctly ordered multi column proper= ties + List orderedProperties =3D new ArrayList(); + for (Column column : orderedColumns) { + boolean found =3D false; + for (Property property : columnsToProperty.get( column )) { + if ( property.getColumnSpan() =3D=3D 1 ) { + orderedProperties.add( property ); + found =3D true; + break; + } + } + if ( !found ) return null; //have to find it the hard way + } + return orderedProperties; + } + + private static void matchColumnsByProperty(Property property, Map> columnsToProperty) { + if ( property =3D=3D null ) return; + if ( "noop".equals( property.getPropertyAccessorName() ) + || "embedded".equals( property.getPropertyAccessorName() ) ) { + return; + } +// FIXME cannot use subproperties becasue the caller needs top level prope= rties +// if ( property.isComposite() ) { +// Iterator subProperties =3D ( (Component) property.getValue() ).getPro= pertyIterator(); +// while ( subProperties.hasNext() ) { +// matchColumnsByProperty( (Property) subProperties.next(), columnsToPr= operty ); +// } +// } + else { + Iterator columnIt =3D property.getColumnIterator(); + while ( columnIt.hasNext() ) { + Object column =3D columnIt.next(); //can be a Formula so we don't cast + //noinspection SuspiciousMethodCalls + if ( columnsToProperty.containsKey( column ) ) { + columnsToProperty.get( column ).add( property ); + } + } + } + } + + /** + * Retrieve the property by path in a recursive way, including Indetifier= Property in the loop + * If propertyName is null or empty, the IdentifierProperty is returned + */ + public static Property findPropertyByName(PersistentClass associatedClass= , String propertyName) { + Property property =3D null; + Property idProperty =3D associatedClass.getIdentifierProperty(); + String idName =3D idProperty !=3D null ? idProperty.getName() : null; + try { + if ( propertyName =3D=3D null + || propertyName.length() =3D=3D 0 + || propertyName.equals( idName ) ) { + //default to id + property =3D idProperty; + } + else { + if ( propertyName.indexOf( idName + "." ) =3D=3D 0 ) { + property =3D idProperty; + propertyName =3D propertyName.substring( idName.length() + 1 ); + } + StringTokenizer st =3D new StringTokenizer( propertyName, ".", false ); + while ( st.hasMoreElements() ) { + String element =3D (String) st.nextElement(); + if ( property =3D=3D null ) { + property =3D associatedClass.getProperty( element ); + } + else { + if ( !property.isComposite() ) return null; + property =3D ( (Component) property.getValue() ).getProperty( elemen= t ); + } + } + } + } + catch (MappingException e) { + try { + //if we do not find it try to check the identifier mapper + if ( associatedClass.getIdentifierMapper() =3D=3D null ) return null; + StringTokenizer st =3D new StringTokenizer( propertyName, ".", false ); + while ( st.hasMoreElements() ) { + String element =3D (String) st.nextElement(); + if ( property =3D=3D null ) { + property =3D associatedClass.getIdentifierMapper().getProperty( elem= ent ); + } + else { + if ( !property.isComposite() ) return null; + property =3D ( (Component) property.getValue() ).getProperty( elemen= t ); + } + } + } + catch (MappingException ee) { + return null; + } + } + return property; + } + + public static String getRelativePath(PropertyHolder propertyHolder, Strin= g propertyName) { + if ( propertyHolder =3D=3D null ) return propertyName; + String path =3D propertyHolder.getPath(); + String entityName =3D propertyHolder.getPersistentClass().getEntityName(= ); + if ( path.length() =3D=3D entityName.length() ) { + return propertyName; + } + else { + return StringHelper.qualify( path.substring( entityName.length() + 1 ),= propertyName ); + } + } + + /** + * Find the column owner (ie PersistentClass or Join) of columnName. + * If columnName is null or empty, persistentClass is returned + */ + public static Object findColumnOwner( + PersistentClass persistentClass, String columnName, ExtendedMappings ma= ppings + ) { + if ( StringHelper.isEmpty( columnName ) ) { + return persistentClass; //shortcut for implicit referenced column names + } + PersistentClass current =3D persistentClass; + Object result =3D null; + boolean found =3D false; + do { + result =3D current; + Table currentTable =3D current.getTable(); + try { + mappings.getPhysicalColumnName( columnName, currentTable ); + found =3D true; + } + catch (MappingException me) { + //swallow it + } + Iterator joins =3D current.getJoinIterator(); + while ( !found && joins.hasNext() ) { + result =3D joins.next(); + currentTable =3D ( (Join) result ).getTable(); + try { + mappings.getPhysicalColumnName( columnName, currentTable ); + found =3D true; + } + catch (MappingException me) { + //swallow it + } + } + current =3D current.getSuperclass(); + } + while ( !found && current !=3D null ); + return found ? result : null; + } + + /** + * apply an id generator to a SimpleValue + */ + public static void makeIdGenerator( + SimpleValue id, String generatorType, String generatorName, ExtendedMap= pings mappings, + Map localGenerators + ) { + Table table =3D id.getTable(); + table.setIdentifierValue( id ); + //generator settings + id.setIdentifierGeneratorStrategy( generatorType ); + Properties params =3D new Properties(); + //always settable + params.setProperty( + PersistentIdentifierGenerator.TABLE, table.getName() + ); + + if ( id.getColumnSpan() =3D=3D 1 ) { + params.setProperty( + PersistentIdentifierGenerator.PK, + ( (org.hibernate.mapping.Column) id.getColumnIterator().next() ).getN= ame() + ); + } + if ( !isDefault( generatorName ) ) { + //we have a named generator + IdGenerator gen =3D mappings.getGenerator( generatorName, localGenerato= rs ); + if ( gen =3D=3D null ) { + throw new AnnotationException( "Unknown Id.generator: " + generatorNam= e ); + } + //This is quite vague in the spec but a generator could override the ge= nerate choice + String identifierGeneratorStrategy =3D gen.getIdentifierGeneratorStrate= gy(); + //yuk! this is a hack not to override 'AUTO' even if generator is set + final boolean avoidOverriding =3D + identifierGeneratorStrategy.equals( "identity" ) + || identifierGeneratorStrategy.equals( "seqhilo" ) + || identifierGeneratorStrategy.equals( MultipleHiLoPerTableGenerato= r.class.getName() ); + if ( generatorType =3D=3D null || !avoidOverriding ) { + id.setIdentifierGeneratorStrategy( identifierGeneratorStrategy ); + } + //checkIfMatchingGenerator(gen, generatorType, generatorName); + Iterator genParams =3D gen.getParams().entrySet().iterator(); + while ( genParams.hasNext() ) { + Map.Entry elt =3D (Map.Entry) genParams.next(); + params.setProperty( (String) elt.getKey(), (String) elt.getValue() ); + } + } + if ( "assigned".equals( generatorType ) ) id.setNullValue( "undefined" ); + id.setIdentifierGeneratorProperties( params ); + } + + public static boolean isDefault(String annotationString) { + return annotationString !=3D null && annotationString.length() =3D=3D 0; + //equivalent to (but faster) ANNOTATION_STRING_DEFAULT.equals( annotatio= nString ); + } + + public static Any buildAnyValue(String anyMetaDefName, Ejb3JoinColumn[] c= olumns, javax.persistence.Column metaColumn, PropertyData inferredData, + boolean cascadeOnDelete, Nullability nullability, PropertyHolder = propertyHolder, + EntityBinder entityBinder, boolean optional, ExtendedMappings map= pings) { + //All FK columns should be in the same table + Any value =3D new Any( columns[0].getTable() ); + AnyMetaDef metaAnnDef =3D inferredData.getProperty().getAnnotation( AnyM= etaDef.class ); + + if ( metaAnnDef !=3D null ) { + //local has precedence over general and can be mapped for future refere= nce if named + bindAnyMetaDefs( inferredData.getProperty(), mappings ); + } + else { + metaAnnDef =3D mappings.getAnyMetaDef( anyMetaDefName ); + } + if ( metaAnnDef !=3D null ) { + value.setIdentifierType( metaAnnDef.idType() ); + value.setMetaType( metaAnnDef.metaType() ); + + HashMap values =3D new HashMap(); + org.hibernate.type.Type metaType =3D TypeFactory.heuristicType( value.g= etMetaType() ); + for (MetaValue metaValue : metaAnnDef.metaValues()) { + try { + Object discrim =3D ( (org.hibernate.type.DiscriminatorType) metaType = ).stringToObject( metaValue + .value() ); + String entityName =3D metaValue.targetEntity().getName(); + values.put( discrim, entityName ); + } + catch (ClassCastException cce) { + throw new MappingException( "metaType was not a DiscriminatorType: " + + metaType.getName() ); + } + catch (Exception e) { + throw new MappingException( "could not interpret metaValue", e ); + } + } + if ( !values.isEmpty() ) value.setMetaValues( values ); + } + else { + throw new AnnotationException( "Unable to find @AnyMetaDef for an @(Man= yTo)Any mapping: " + + StringHelper.qualify( propertyHolder.getPath(), inferredData.getPro= pertyName() ) ); + } + + value.setCascadeDeleteEnabled( cascadeOnDelete ); + if ( !optional ) { + for (Ejb3JoinColumn column : columns) { + column.setNullable( false ); + } + } + + Ejb3Column[] metaColumns =3D Ejb3Column.buildColumnFromAnnotation( new j= avax.persistence.Column[] { metaColumn }, null, + nullability, propertyHolder, inferredData, entityBinder.getSecondaryTa= bles(), mappings ); + //set metaColumn to the right table + for (Ejb3Column column : metaColumns) { + column.setTable( value.getTable() ); + } + //meta column + for (Ejb3Column column : metaColumns) { + column.linkWithValue( value ); + } + + //id columns + final String propertyName =3D inferredData.getPropertyName(); + Ejb3Column.checkPropertyConsistency( columns, propertyHolder.getEntityNa= me() + propertyName ); + for (Ejb3JoinColumn column : columns) { + column.linkWithValue( value ); + } + return value; + } + + public static void bindAnyMetaDefs(XAnnotatedElement annotatedElement, Ex= tendedMappings mappings) { + AnyMetaDef defAnn =3D annotatedElement.getAnnotation( AnyMetaDef.class ); + AnyMetaDefs defsAnn =3D annotatedElement.getAnnotation( AnyMetaDefs.clas= s ); + boolean mustHaveName =3D XClass.class.isAssignableFrom( annotatedElement= .getClass() ) + || XPackage.class.isAssignableFrom( annotatedElement.getClass() ); + if ( defAnn !=3D null ) { + checkAnyMetaDefValidity( mustHaveName, defAnn, annotatedElement ); + bindAnyMetaDef( defAnn, mappings ); + } + if ( defsAnn !=3D null ) { + for (AnyMetaDef def : defsAnn.value()) { + checkAnyMetaDefValidity( mustHaveName, def, annotatedElement ); + bindAnyMetaDef( def, mappings ); + } + } + } + + private static void checkAnyMetaDefValidity(boolean mustHaveName, AnyMeta= Def defAnn, XAnnotatedElement annotatedElement) { + if ( mustHaveName && isDefault( defAnn.name() ) ) { + String name =3D XClass.class.isAssignableFrom( annotatedElement.getClas= s() ) ? + ( (XClass) annotatedElement ).getName() : + ( (XPackage) annotatedElement ).getName(); + throw new AnnotationException( "@AnyMetaDef.name cannot be null on an e= ntity or a package: " + name ); + } + } + + private static void bindAnyMetaDef(AnyMetaDef defAnn, ExtendedMappings ma= ppings) { + if ( isDefault( defAnn.name() ) ) return; //don't map not named definiti= ons + log.info( "Binding Any Meta definition: {}", defAnn.name() ); + mappings.addAnyMetaDef( defAnn ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Cl= assPropertyHolder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Class= PropertyHolder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Class= PropertyHolder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,120 @@ +//$Id: ClassPropertyHolder.java 14736 2008-06-04 14:23:42Z hardy.ferentsch= ik $ +package org.hibernate.cfg; + +import java.util.HashMap; +import java.util.Map; +import javax.persistence.JoinTable; + +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.cfg.annotations.EntityBinder; +import org.hibernate.mapping.Component; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.KeyValue; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.Table; + +/** + * @author Emmanuel Bernard + */ +public class ClassPropertyHolder extends AbstractPropertyHolder { + private PersistentClass persistentClass; + private Map joins; + private transient Map joinsPerRealTableName; + private EntityBinder entityBinder; + + public ClassPropertyHolder( + PersistentClass persistentClass, XClass clazzToProcess, Map joins, ExtendedMappings mappings + ) { + super( persistentClass.getEntityName(), null, clazzToProcess, mappings ); + this.persistentClass =3D persistentClass; + this.joins =3D joins; + } + + public ClassPropertyHolder( + PersistentClass persistentClass, XClass clazzToProcess, EntityBinder en= tityBinder, + ExtendedMappings mappings + ) { + this( persistentClass, clazzToProcess, entityBinder.getSecondaryTables()= , mappings ); + this.entityBinder =3D entityBinder; + } + + public String getEntityName() { + return persistentClass.getEntityName(); + } + + public void addProperty(Property prop, Ejb3Column[] columns) { + //Ejb3Column.checkPropertyConsistency( ); //already called earlier + if ( columns[0].isSecondary() ) { + //TODO move the getJoin() code here? + columns[0].getJoin().addProperty( prop ); + } + else { + addProperty( prop ); + } + } + + public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCrea= tion) { + Join join =3D entityBinder.addJoin( joinTableAnn, this, noDelayInPkColum= nCreation ); + this.joins =3D entityBinder.getSecondaryTables(); + return join; + } + + public void addProperty(Property prop) { + if ( prop.getValue() instanceof Component ) { + //TODO handle quote and non quote table comparison + String tableName =3D prop.getValue().getTable().getName(); + if ( getJoinsPerRealTableName().containsKey( tableName ) ) { + getJoinsPerRealTableName().get( tableName ).addProperty( prop ); + } + else { + persistentClass.addProperty( prop ); + } + } + else { + persistentClass.addProperty( prop ); + } + } + + /** + * Needed for proper compliance with naming strategy, the property table + * can be overriden if the properties are part of secondary tables + */ + private Map getJoinsPerRealTableName() { + if ( joinsPerRealTableName =3D=3D null ) { + joinsPerRealTableName =3D new HashMap( joins.size() ); + for (Join join : joins.values()) { + joinsPerRealTableName.put( join.getTable().getName(), join ); + } + } + return joinsPerRealTableName; + } + + public String getClassName() { + return persistentClass.getClassName(); + } + + public String getEntityOwnerClassName() { + return getClassName(); + } + + public Table getTable() { + return persistentClass.getTable(); + } + + public boolean isComponent() { + return false; + } + + public boolean isEntity() { + return true; + } + + public PersistentClass getPersistentClass() { + return persistentClass; + } + + public KeyValue getIdentifier() { + return persistentClass.getIdentifier(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Co= llectionPropertyHolder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Colle= ctionPropertyHolder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Colle= ctionPropertyHolder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,75 @@ +//$Id: CollectionPropertyHolder.java 14736 2008-06-04 14:23:42Z hardy.fere= ntschik $ +package org.hibernate.cfg; + +import javax.persistence.JoinTable; + +import org.hibernate.AssertionFailure; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.KeyValue; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.Table; + +/** + * @author Emmanuel Bernard + */ +public class CollectionPropertyHolder extends AbstractPropertyHolder { + Collection collection; + + public CollectionPropertyHolder( + Collection collection, String path, XClass clazzToProcess, XProperty pr= operty, + PropertyHolder parentPropertyHolder, ExtendedMappings mappings + ) { + super( path, parentPropertyHolder, clazzToProcess, mappings ); + this.collection =3D collection; + setCurrentProperty( property ); + } + + public String getClassName() { + throw new AssertionFailure( "Collection property holder does not have a = class name" ); + } + + public String getEntityOwnerClassName() { + return null; + } + + public Table getTable() { + return collection.getCollectionTable(); + } + + public void addProperty(Property prop) { + throw new AssertionFailure( "Cannot add property to a collection" ); + } + + public KeyValue getIdentifier() { + throw new AssertionFailure( "Identifier collection not yet managed" ); + } + + public PersistentClass getPersistentClass() { + return collection.getOwner(); + } + + public boolean isComponent() { + return false; + } + + public boolean isEntity() { + return false; + } + + public String getEntityName() { + return collection.getOwner().getEntityName(); + } + + public void addProperty(Property prop, Ejb3Column[] columns) { + //Ejb3Column.checkPropertyConsistency( ); //already called earlier + throw new AssertionFailure( "addProperty to a join table of a collection= : does it make sense?" ); + } + + public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCrea= tion) { + throw new AssertionFailure( "Add a in a second pass" ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Co= mponentPropertyHolder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Compo= nentPropertyHolder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Compo= nentPropertyHolder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,136 @@ +//$Id: ComponentPropertyHolder.java 14736 2008-06-04 14:23:42Z hardy.feren= tschik $ +package org.hibernate.cfg; + +import javax.persistence.Column; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; + +import org.hibernate.AnnotationException; +import org.hibernate.mapping.Component; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.KeyValue; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.Table; + +/** + * Component implementation of property holder + * + * @author Emmanuel Bernard + */ +public class ComponentPropertyHolder extends AbstractPropertyHolder { + //TODO introduce a overrideTable() method for columns held by sec table r= ather than the hack + // joinsPerRealTableName in ClassPropertyHolder + private Component component; + + public String getEntityName() { + return component.getComponentClassName(); + } + + public void addProperty(Property prop, Ejb3Column[] columns) { + //Ejb3Column.checkPropertyConsistency( ); //already called earlier + /* + * Check table matches between the component and the columns + * if not, change the component table if no properties are set + * if a property is set already the core cannot support that + */ + Table table =3D columns[0].getTable(); + if ( !table.equals( component.getTable() ) ) { + if ( component.getPropertySpan() =3D=3D 0 ) { + component.setTable( table ); + } + else { + throw new AnnotationException( + "A component cannot hold properties split into 2 different tables: " + + this.getPath() + ); + } + } + addProperty( prop ); + } + + public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCrea= tion) { + return parent.addJoin( joinTableAnn, noDelayInPkColumnCreation ); + + } + + public ComponentPropertyHolder( + Component component, String path, PropertyData inferredData, PropertyHo= lder parent, + ExtendedMappings mappings + ) { + super( path, parent, inferredData.getPropertyClass(), mappings ); + setCurrentProperty( inferredData.getProperty() ); + this.component =3D component; + } + + public String getClassName() { + return component.getComponentClassName(); + } + + public String getEntityOwnerClassName() { + return component.getOwner().getClassName(); + } + + public Table getTable() { + return component.getTable(); + } + + public void addProperty(Property prop) { + component.addProperty( prop ); + } + + public KeyValue getIdentifier() { + return component.getOwner().getIdentifier(); + } + + public PersistentClass getPersistentClass() { + return component.getOwner(); + } + + public boolean isComponent() { + return true; + } + + public boolean isEntity() { + return false; + } + + public void setParentProperty(String parentProperty) { + component.setParentProperty( parentProperty ); + } + + @Override + public Column[] getOverriddenColumn(String propertyName) { + //FIXME this is yukky + Column[] result =3D super.getOverriddenColumn( propertyName ); + if ( result =3D=3D null ) { + String userPropertyName =3D extractUserPropertyName( "id", propertyName= ); + if ( userPropertyName !=3D null ) result =3D super.getOverriddenColumn(= userPropertyName ); + } + if ( result =3D=3D null ) { + String userPropertyName =3D extractUserPropertyName( "_identifierMapper= ", propertyName ); + if ( userPropertyName !=3D null ) result =3D super.getOverriddenColumn(= userPropertyName ); + } + return result; + } + + private String extractUserPropertyName(String redundantString, String pro= pertyName) { + String result =3D null; + String className =3D component.getOwner().getClassName(); + if ( propertyName.startsWith( className ) + && propertyName.length() > className.length() + 2 + redundantString.le= ngth() // .id. + && propertyName.substring( + className.length() + 1, className.length() + 1 + redundantString.lengt= h() + ).equals( redundantString ) + ) { + //remove id we might be in a @IdCLass case + result =3D className + propertyName.substring( className.length() + 1 += redundantString.length() ); + } + return result; + } + + @Override + public JoinColumn[] getOverriddenJoinColumn(String propertyName) { + return super.getOverriddenJoinColumn( propertyName ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Cr= eateKeySecondPass.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Creat= eKeySecondPass.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Creat= eKeySecondPass.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,37 @@ +//$Id: CreateKeySecondPass.java 14736 2008-06-04 14:23:42Z hardy.ferentsch= ik $ +package org.hibernate.cfg; + +import java.util.Map; + +import org.hibernate.MappingException; +import org.hibernate.mapping.JoinedSubclass; +import org.hibernate.mapping.RootClass; + +/** + * @author Emmanuel Bernard + */ +public class CreateKeySecondPass implements SecondPass { + private RootClass rootClass; + private JoinedSubclass joinedSubClass; + + public CreateKeySecondPass(RootClass rootClass) { + this.rootClass =3D rootClass; + } + + public CreateKeySecondPass(JoinedSubclass joinedSubClass) { + this.joinedSubClass =3D joinedSubClass; + } + + public void doSecondPass(Map persistentClasses) throws MappingException { + if ( rootClass !=3D null ) { + rootClass.createPrimaryKey(); + } + else if ( joinedSubClass !=3D null ) { + joinedSubClass.createPrimaryKey(); + joinedSubClass.createForeignKey(); + } + else { + throw new AssertionError( "rootClass and joinedSubClass are null" ); + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/De= faultComponentSafeNamingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Defau= ltComponentSafeNamingStrategy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Defau= ltComponentSafeNamingStrategy.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,77 @@ +//$Id: DefaultComponentSafeNamingStrategy.java 14736 2008-06-04 14:23:42Z = hardy.ferentschik $ +package org.hibernate.cfg; + +import org.hibernate.AssertionFailure; +import org.hibernate.util.StringHelper; + +/** + * @author Emmanuel Bernard + */ +public class DefaultComponentSafeNamingStrategy extends EJB3NamingStrategy= { + public static final NamingStrategy INSTANCE =3D new DefaultComponentSafeN= amingStrategy(); + + protected static String addUnderscores(String name) { + return name.replace( '.', '_' ).toLowerCase(); + } + + @Override + public String propertyToColumnName(String propertyName) { + return addUnderscores( propertyName ); + } + + @Override + public String collectionTableName( + String ownerEntity, String ownerEntityTable, String associatedEntity, S= tring associatedEntityTable, + String propertyName + ) { + return tableName( + new StringBuilder( ownerEntityTable ).append( "_" ) + .append( + associatedEntityTable !=3D null ? + associatedEntityTable : + addUnderscores( propertyName ) + ).toString() + ); + } + + + public String foreignKeyColumnName( + String propertyName, String propertyEntityName, String propertyTableNam= e, String referencedColumnName + ) { + String header =3D propertyName !=3D null ? addUnderscores( propertyName = ) : propertyTableName; + if ( header =3D=3D null ) throw new AssertionFailure( "NamingStrategy no= t properly filled" ); + return columnName( header + "_" + referencedColumnName ); + } + + @Override + public String logicalColumnName(String columnName, String propertyName) { + return StringHelper.isNotEmpty( columnName ) ? columnName : propertyName; + } + + @Override + public String logicalCollectionTableName( + String tableName, String ownerEntityTable, String associatedEntityTable= , String propertyName + ) { + if ( tableName !=3D null ) { + return tableName; + } + else { + //use of a stringbuffer to workaround a JDK bug + return new StringBuffer( ownerEntityTable ).append( "_" ) + .append( + associatedEntityTable !=3D null ? + associatedEntityTable : + propertyName + ).toString(); + } + + } + + @Override + public String logicalCollectionColumnName(String columnName, String prope= rtyName, String referencedColumn) { + return StringHelper.isNotEmpty( columnName ) ? + columnName : + propertyName + "_" + referencedColumn; + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/EJ= B3DTDEntityResolver.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/EJB3D= TDEntityResolver.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/EJB3D= TDEntityResolver.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,75 @@ +//$Id: EJB3DTDEntityResolver.java 14736 2008-06-04 14:23:42Z hardy.ferents= chik $ +package org.hibernate.cfg; + +import java.io.InputStream; + +import org.hibernate.util.DTDEntityResolver; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Emmanuel Bernard + */ +public class EJB3DTDEntityResolver extends DTDEntityResolver { + public static final EntityResolver INSTANCE =3D new EJB3DTDEntityResolver= (); + + private final Logger log =3D LoggerFactory.getLogger( EJB3DTDEntityResolv= er.class ); + + boolean resolved =3D false; + + public boolean isResolved() { + return resolved; + } + + public InputSource resolveEntity(String publicId, String systemId) { + InputSource is =3D super.resolveEntity( publicId, systemId ); + if ( is =3D=3D null ) { + if ( systemId !=3D null ) { + if ( systemId.endsWith( "orm_1_0.xsd" ) ) { + log.debug( + "recognized EJB3 ORM namespace; attempting to resolve on classpath = under org/hibernate/ejb" + ); + String path =3D "org/hibernate/ejb/" + "orm_1_0.xsd"; + InputStream dtdStream =3D resolveInHibernateNamespace( path ); + if ( dtdStream =3D=3D null ) { + log.debug( "unable to locate [{}] on classpath", systemId ); + } + else { + log.debug( "located [{}] in classpath", systemId ); + InputSource source =3D new InputSource( dtdStream ); + source.setPublicId( publicId ); + source.setSystemId( systemId ); + resolved =3D false; + return source; + } + } + else if ( systemId.endsWith( "persistence_1_0.xsd" ) ) { + log.debug( + "recognized EJB3 ORM namespace; attempting to resolve on classpath = under org/hibernate/ejb" + ); + String path =3D "org/hibernate/ejb/" + "persistence_1_0.xsd"; + InputStream dtdStream =3D resolveInHibernateNamespace( path ); + if ( dtdStream =3D=3D null ) { + log.debug( "unable to locate [{}] on classpath", systemId ); + } + else { + log.debug( "located [{}] in classpath", systemId ); + InputSource source =3D new InputSource( dtdStream ); + source.setPublicId( publicId ); + source.setSystemId( systemId ); + resolved =3D true; + return source; + } + } + } + } + else { + resolved =3D true; + return is; + } + //use the default behavior + return null; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/EJ= B3NamingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/EJB3N= amingStrategy.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/EJB3N= amingStrategy.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,86 @@ +//$Id: EJB3NamingStrategy.java 14741 2008-06-05 11:25:56Z hardy.ferentschi= k $ +package org.hibernate.cfg; + +import java.io.Serializable; + +import org.hibernate.AssertionFailure; +import org.hibernate.util.StringHelper; + +/** + * Naming strategy implementing the EJB3 standards + * + * @author Emmanuel Bernard + */ +public class EJB3NamingStrategy implements NamingStrategy, Serializable { + public static final NamingStrategy INSTANCE =3D new EJB3NamingStrategy(); + + public String classToTableName(String className) { + return StringHelper.unqualify( className ); + } + + public String propertyToColumnName(String propertyName) { + return StringHelper.unqualify( propertyName ); + } + + public String tableName(String tableName) { + return tableName; + } + + public String columnName(String columnName) { + return columnName; + } + + public String collectionTableName( + String ownerEntity, String ownerEntityTable, String associatedEntity, S= tring associatedEntityTable, + String propertyName + ) { + return tableName( + new StringBuilder( ownerEntityTable ).append( "_" ) + .append( + associatedEntityTable !=3D null ? + associatedEntityTable : + StringHelper.unqualify( propertyName ) + ).toString() + ); + } + + public String joinKeyColumnName(String joinedColumn, String joinedTable) { + return columnName( joinedColumn ); + } + + public String foreignKeyColumnName( + String propertyName, String propertyEntityName, String propertyTableNam= e, String referencedColumnName + ) { + String header =3D propertyName !=3D null ? StringHelper.unqualify( prope= rtyName ) : propertyTableName; + if ( header =3D=3D null ) throw new AssertionFailure( "NamingStrategy no= t properly filled" ); + return columnName( header + "_" + referencedColumnName ); + } + + public String logicalColumnName(String columnName, String propertyName) { + return StringHelper.isNotEmpty( columnName ) ? columnName : StringHelper= .unqualify( propertyName ); + } + + public String logicalCollectionTableName( + String tableName, + String ownerEntityTable, String associatedEntityTable, String propertyN= ame + ) { + if ( tableName !=3D null ) { + return tableName; + } + else { + //use of a stringbuffer to workaround a JDK bug + return new StringBuffer( ownerEntityTable ).append( "_" ) + .append( + associatedEntityTable !=3D null ? + associatedEntityTable : + StringHelper.unqualify( propertyName ) + ).toString(); + } + } + + public String logicalCollectionColumnName(String columnName, String prope= rtyName, String referencedColumn) { + return StringHelper.isNotEmpty( columnName ) ? + columnName : + StringHelper.unqualify( propertyName ) + "_" + referencedColumn; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ej= b3Column.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ejb3C= olumn.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ejb3C= olumn.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,461 @@ +//$Id: Ejb3Column.java 14748 2008-06-06 10:35:35Z hardy.ferentschik $ +package org.hibernate.cfg; + +import java.util.Map; + +import org.hibernate.AnnotationException; +import org.hibernate.AssertionFailure; +import org.hibernate.annotations.Index; +import org.hibernate.cfg.annotations.Nullability; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.Formula; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.Table; +import org.hibernate.util.StringHelper; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; + +/** + * Wrap state of an EJB3 @Column annotation + * and build the Hibernate column mapping element + * + * @author Emmanuel Bernard + */ +public class Ejb3Column { + private static final Logger log =3D LoggerFactory.getLogger( Ejb3Column.c= lass ); + private Column mappingColumn; + private boolean insertable =3D true; + private boolean updatable =3D true; + private String secondaryTableName; + protected Map joins; + protected PropertyHolder propertyHolder; + private ExtendedMappings mappings; + private boolean isImplicit; + public static final int DEFAULT_COLUMN_LENGTH =3D 255; + public String sqlType; + private int length =3D DEFAULT_COLUMN_LENGTH; + private int precision; + private int scale; + private String logicalColumnName; + private String propertyName; + private boolean unique; + private boolean nullable =3D true; + private String formulaString; + private Formula formula; + private Table table; + + public void setTable(Table table) { + this.table =3D table; + } + + public String getLogicalColumnName() { + return logicalColumnName; + } + + public String getSqlType() { + return sqlType; + } + + public int getLength() { + return length; + } + + public int getPrecision() { + return precision; + } + + public int getScale() { + return scale; + } + + public boolean isUnique() { + return unique; + } + + public String getFormulaString() { + return formulaString; + } + + public String getSecondaryTableName() { + return secondaryTableName; + } + + public void setFormula(String formula) { + this.formulaString =3D formula; + } + + public boolean isImplicit() { + return isImplicit; + } + + public void setInsertable(boolean insertable) { + this.insertable =3D insertable; + } + + public void setUpdatable(boolean updatable) { + this.updatable =3D updatable; + } + + protected ExtendedMappings getMappings() { + return mappings; + } + + public void setMappings(ExtendedMappings mappings) { + this.mappings =3D mappings; + } + + public void setImplicit(boolean implicit) { + isImplicit =3D implicit; + } + + public void setSqlType(String sqlType) { + this.sqlType =3D sqlType; + } + + public void setLength(int length) { + this.length =3D length; + } + + public void setPrecision(int precision) { + this.precision =3D precision; + } + + public void setScale(int scale) { + this.scale =3D scale; + } + + public void setLogicalColumnName(String logicalColumnName) { + this.logicalColumnName =3D logicalColumnName; + } + + public void setPropertyName(String propertyName) { + this.propertyName =3D propertyName; + } + + public String getPropertyName() { + return propertyName; + } + + public void setUnique(boolean unique) { + this.unique =3D unique; + } + + public boolean isNullable() { + return mappingColumn.isNullable(); + } + + public Ejb3Column() { + } + + public void bind() { + if ( StringHelper.isNotEmpty( formulaString ) ) { + log.debug( "binding formula {}", formulaString ); + formula =3D new Formula(); + formula.setFormula( formulaString ); + } + else { + initMappingColumn( + logicalColumnName, propertyName, length, precision, scale, nullable, = sqlType, unique, true + ); + log.debug( "Binding column {}. Unique {}. Nullable {}.", new Object[] {= mappingColumn.getName(), unique, nullable}); + } + } + + protected void initMappingColumn( + String columnName, String propertyName, int length, int precision, int = scale, boolean nullable, + String sqlType, boolean unique, boolean applyNamingStrategy + ) { + this.mappingColumn =3D new Column(); + redefineColumnName( columnName, propertyName, applyNamingStrategy ); + this.mappingColumn.setLength( length ); + if ( precision > 0 ) { //revelent precision + this.mappingColumn.setPrecision( precision ); + this.mappingColumn.setScale( scale ); + } + this.mappingColumn.setNullable( nullable ); + this.mappingColumn.setSqlType( sqlType ); + this.mappingColumn.setUnique( unique ); + } + + public boolean isNameDeferred() { + return mappingColumn =3D=3D null || StringHelper.isEmpty( mappingColumn.= getName() ); + } + + public void redefineColumnName(String columnName, String propertyName, bo= olean applyNamingStrategy) { + if ( applyNamingStrategy ) { + if ( StringHelper.isEmpty( columnName ) ) { + if ( propertyName !=3D null ) { + mappingColumn.setName( mappings.getNamingStrategy().propertyToColumnN= ame( propertyName ) ); + } + //Do nothing otherwise + } + else { + mappingColumn.setName( mappings.getNamingStrategy().columnName( column= Name ) ); + } + } + else { + if ( StringHelper.isNotEmpty( columnName ) ) mappingColumn.setName( col= umnName ); + } + } + + public String getName() { + return mappingColumn.getName(); + } + + public Column getMappingColumn() { + return mappingColumn; + } + + public boolean isInsertable() { + return insertable; + } + + public boolean isUpdatable() { + return updatable; + } + + public void setNullable(boolean nullable) { + if ( mappingColumn !=3D null ) { + mappingColumn.setNullable( nullable ); + } + else { + this.nullable =3D nullable; + } + } + + public void setJoins(Map joins) { + this.joins =3D joins; + } + + public PropertyHolder getPropertyHolder() { + return propertyHolder; + } + + public void setPropertyHolder(PropertyHolder propertyHolder) { + this.propertyHolder =3D propertyHolder; + } + + protected void setMappingColumn(Column mappingColumn) { + this.mappingColumn =3D mappingColumn; + } + + public void linkWithValue(SimpleValue value) { + if ( formula !=3D null ) { + value.addFormula( formula ); + } + else { + getMappingColumn().setValue( value ); + value.addColumn( getMappingColumn() ); + value.getTable().addColumn( getMappingColumn() ); + addColumnBinding( value ); + table =3D value.getTable(); + } + } + + protected void addColumnBinding(SimpleValue value) { + String logicalColumnName =3D mappings.getNamingStrategy() + .logicalColumnName( this.logicalColumnName, propertyName ); + mappings.addColumnBinding( logicalColumnName, getMappingColumn(), value.= getTable() ); + } + + /** + * Find appropriate table of the column. + * It can come from a secondary table or from the main table of the persi= stent class + * + * @return appropriate table + * @throws AnnotationException missing secondary table + */ + public Table getTable() { + if ( table !=3D null ) return table; //association table + if ( isSecondary() ) { + return getJoin().getTable(); + } + else { + return propertyHolder.getTable(); + } + } + + public boolean isSecondary() { + if ( propertyHolder =3D=3D null ) { + throw new AssertionFailure( "Should not call getTable() on column wo pe= rsistent class defined" ); + } + if ( StringHelper.isNotEmpty( secondaryTableName ) ) { + return true; + } + // else { + return false; + } + + public Join getJoin() { + Join join =3D joins.get( secondaryTableName ); + if ( join =3D=3D null ) { + throw new AnnotationException( + "Cannot find the expected secondary table: no " + + secondaryTableName + " available for " + propertyHolder.getClassN= ame() + ); + } + else { + return join; + } + } + + public void forceNotNull() { + mappingColumn.setNullable( false ); + } + + public void setSecondaryTableName(String secondaryTableName) { + this.secondaryTableName =3D secondaryTableName; + } + + public static Ejb3Column[] buildColumnFromAnnotation( + javax.persistence.Column[] anns, + org.hibernate.annotations.Formula formulaAnn, Nullability nullability, = PropertyHolder propertyHolder, + PropertyData inferredData, + Map secondaryTables, + ExtendedMappings mappings + ) { + Ejb3Column[] columns; + if ( formulaAnn !=3D null ) { + Ejb3Column formulaColumn =3D new Ejb3Column(); + formulaColumn.setFormula( formulaAnn.value() ); + formulaColumn.setImplicit( false ); + formulaColumn.setMappings( mappings ); + formulaColumn.setPropertyHolder( propertyHolder ); + formulaColumn.bind(); + columns =3D new Ejb3Column[] { formulaColumn }; + } + else { + javax.persistence.Column[] actualCols =3D anns; + javax.persistence.Column[] overriddenCols =3D propertyHolder.getOverrid= denColumn( + StringHelper.qualify( propertyHolder.getPath(), inferredData.getPrope= rtyName() ) + ); + if ( overriddenCols !=3D null ) { + //check for overridden first + if ( anns !=3D null && overriddenCols.length !=3D anns.length ) { + throw new AnnotationException( "AttributeOverride.column() should ove= rride all columns for now" ); + } + actualCols =3D overriddenCols.length =3D=3D 0 ? null : overriddenCols; + log.debug( "Column(s) overridden for property {}", inferredData.getPro= pertyName() ); + } + if ( actualCols =3D=3D null ) { + columns =3D buildImplicitColumn( inferredData, secondaryTables, proper= tyHolder, nullability, mappings ); + } + else { + final int length =3D actualCols.length; + columns =3D new Ejb3Column[length]; + for (int index =3D 0; index < length; index++) { + javax.persistence.Column col =3D actualCols[index]; + String sqlType =3D col.columnDefinition().equals( "" ) ? null : col.c= olumnDefinition(); + Ejb3Column column =3D new Ejb3Column(); + column.setImplicit( false ); + column.setSqlType( sqlType ); + column.setLength( col.length() ); + column.setPrecision( col.precision() ); + column.setScale( col.scale() ); + column.setLogicalColumnName( col.name() ); + column.setPropertyName( + BinderHelper.getRelativePath( propertyHolder, inferredData.getPrope= rtyName() ) + ); + column.setNullable( + col.nullable() + ); //TODO force to not null if available? This is a (bad) user choice. + column.setUnique( col.unique() ); + column.setInsertable( col.insertable() ); + column.setUpdatable( col.updatable() ); + column.setSecondaryTableName( col.table() ); + column.setPropertyHolder( propertyHolder ); + column.setJoins( secondaryTables ); + column.setMappings( mappings ); + column.bind(); + columns[index] =3D column; + } + } + } + return columns; + } + + private static Ejb3Column[] buildImplicitColumn( + PropertyData inferredData, Map secondaryTables, PropertyH= older propertyHolder, + Nullability nullability, ExtendedMappings mappings + ) { + Ejb3Column[] columns; + columns =3D new Ejb3Column[1]; + Ejb3Column column =3D new Ejb3Column(); + column.setImplicit( false ); + //not following the spec but more clean + if ( nullability !=3D Nullability.FORCED_NULL + && inferredData.getClassOrElement().isPrimitive() + && !inferredData.getProperty().isArray() ) { + column.setNullable( false ); + } + column.setLength( DEFAULT_COLUMN_LENGTH ); + column.setPropertyName( + BinderHelper.getRelativePath( propertyHolder, inferredData.getProperty= Name() ) + ); + column.setPropertyHolder( propertyHolder ); + column.setJoins( secondaryTables ); + column.setMappings( mappings ); + column.bind(); + columns[0] =3D column; + return columns; + } + + public static void checkPropertyConsistency(Ejb3Column[] columns, String = propertyName) { + int nbrOfColumns =3D columns.length; + if ( nbrOfColumns > 1 ) { + for (int currentIndex =3D 1; currentIndex < nbrOfColumns; currentIndex+= +) { + if ( columns[currentIndex].isInsertable() !=3D columns[currentIndex - = 1].isInsertable() ) { + throw new AnnotationException( + "Mixing insertable and non insertable columns in a property is not = allowed: " + propertyName + ); + } + if ( columns[currentIndex].isNullable() !=3D columns[currentIndex - 1]= .isNullable() ) { + throw new AnnotationException( + "Mixing nullable and non nullable columns in a property is not allo= wed: " + propertyName + ); + } + if ( columns[currentIndex].isUpdatable() !=3D columns[currentIndex - 1= ].isUpdatable() ) { + throw new AnnotationException( + "Mixing updatable and non updatable columns in a property is not al= lowed: " + propertyName + ); + } + if ( !columns[currentIndex].getTable().equals( columns[currentIndex - = 1].getTable() ) ) { + throw new AnnotationException( + "Mixing different tables in a property is not allowed: " + property= Name + ); + } + } + } + } + + public void addIndex(Index index, boolean inSecondPass) { + if ( index =3D=3D null ) return; + String indexName =3D index.name(); + addIndex( indexName, inSecondPass ); + } + + void addIndex(String indexName, boolean inSecondPass) { + IndexOrUniqueKeySecondPass secondPass =3D new IndexOrUniqueKeySecondPass= ( indexName, this, mappings, false ); + if ( inSecondPass ) { + secondPass.doSecondPass( mappings.getClasses() ); + } + else { + mappings.addSecondPass( + secondPass + ); + } + } + + void addUniqueKey(String uniqueKeyName, boolean inSecondPass) { + IndexOrUniqueKeySecondPass secondPass =3D new IndexOrUniqueKeySecondPass= ( uniqueKeyName, this, mappings, true ); + if ( inSecondPass ) { + secondPass.doSecondPass( mappings.getClasses() ); + } + else { + mappings.addSecondPass( + secondPass + ); + } + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ej= b3DiscriminatorColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ejb3D= iscriminatorColumn.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ejb3D= iscriminatorColumn.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,82 @@ +//$Id: Ejb3DiscriminatorColumn.java 14736 2008-06-04 14:23:42Z hardy.feren= tschik $ +package org.hibernate.cfg; + +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorType; + +import org.hibernate.AssertionFailure; +import org.hibernate.annotations.DiscriminatorFormula; + +/** + * Discriminator column + * + * @author Emmanuel Bernard + */ +public class Ejb3DiscriminatorColumn extends Ejb3Column { + + + private static final String DEFAULT_DISCRIMINATOR_COLUMN_NAME =3D "DTYPE"; + private static final String DEFAULT_DISCRIMINATOR_TYPE =3D "string"; + + private String discriminatorTypeName; + private static final int DEFAULT_DISCRIMINATOR_LENGTH =3D 31; + + public Ejb3DiscriminatorColumn() { + //discriminator default value + super(); + setLogicalColumnName( DEFAULT_DISCRIMINATOR_COLUMN_NAME ); + setNullable( false ); + setDiscriminatorTypeName( DEFAULT_DISCRIMINATOR_TYPE ); + setLength( DEFAULT_DISCRIMINATOR_LENGTH ); + } + + public String getDiscriminatorTypeName() { + return discriminatorTypeName; + } + + public void setDiscriminatorTypeName(String discriminatorTypeName) { + this.discriminatorTypeName =3D discriminatorTypeName; + } + + public static Ejb3DiscriminatorColumn buildDiscriminatorColumn( + DiscriminatorType type, DiscriminatorColumn discAnn, DiscriminatorFormu= la discFormulaAnn, + ExtendedMappings mappings + ) { + Ejb3DiscriminatorColumn discriminatorColumn =3D new Ejb3DiscriminatorCol= umn(); + discriminatorColumn.setMappings( mappings ); + discriminatorColumn.setImplicit( true ); + if ( discFormulaAnn !=3D null ) { + discriminatorColumn.setImplicit( false ); + discriminatorColumn.setFormula( discFormulaAnn.value() ); + } + else if ( discAnn !=3D null ) { + discriminatorColumn.setImplicit( false ); + if ( !BinderHelper.isDefault( discAnn.columnDefinition() ) ) { + discriminatorColumn.setSqlType( + discAnn.columnDefinition() + ); + } + if ( !BinderHelper.isDefault( discAnn.name() ) ) { + discriminatorColumn.setLogicalColumnName( discAnn.name() ); + } + discriminatorColumn.setNullable( false ); + } + if ( DiscriminatorType.CHAR.equals( type ) ) { + discriminatorColumn.setDiscriminatorTypeName( "character" ); + discriminatorColumn.setImplicit( false ); + } + else if ( DiscriminatorType.INTEGER.equals( type ) ) { + discriminatorColumn.setDiscriminatorTypeName( "integer" ); + discriminatorColumn.setImplicit( false ); + } + else if ( DiscriminatorType.STRING.equals( type ) || type =3D=3D null ) { + if ( discAnn !=3D null ) discriminatorColumn.setLength( discAnn.length(= ) ); + discriminatorColumn.setDiscriminatorTypeName( "string" ); + } + else { + throw new AssertionFailure( "Unknown discriminator type: " + type ); + } + discriminatorColumn.bind(); + return discriminatorColumn; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ej= b3JoinColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ejb3J= oinColumn.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ejb3J= oinColumn.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,530 @@ +//$Id: Ejb3JoinColumn.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $ +package org.hibernate.cfg; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import javax.persistence.JoinColumn; +import javax.persistence.PrimaryKeyJoinColumn; + +import org.hibernate.AnnotationException; +import org.hibernate.MappingException; +import org.hibernate.annotations.common.util.StringHelper; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.Table; +import org.hibernate.mapping.Value; + +/** + * Wrap state of an EJB3 @JoinColumn annotation + * and build the Hibernate column mapping element + * + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("unchecked") +public class Ejb3JoinColumn extends Ejb3Column { + /** + * property name repated to this column + */ + private String referencedColumn; + private String mappedBy; + //property name on the mapped by side if any + private String mappedByPropertyName; + //table name on the mapped by side if any + private String mappedByTableName; + private String mappedByEntityName; + + //FIXME hacky solution to get the information at property ref resolution + public String getManyToManyOwnerSideEntityName() { + return manyToManyOwnerSideEntityName; + } + + public void setManyToManyOwnerSideEntityName(String manyToManyOwnerSideEn= tityName) { + this.manyToManyOwnerSideEntityName =3D manyToManyOwnerSideEntityName; + } + + private String manyToManyOwnerSideEntityName; + + public void setReferencedColumn(String referencedColumn) { + this.referencedColumn =3D referencedColumn; + } + + public String getMappedBy() { + return mappedBy; + } + + public void setMappedBy(String mappedBy) { + this.mappedBy =3D mappedBy; + } + + //Due to @AnnotationOverride overriding rules, I don't want the construct= or to be public + private Ejb3JoinColumn() { + setMappedBy( BinderHelper.ANNOTATION_STRING_DEFAULT ); + } + + //Due to @AnnotationOverride overriding rules, I don't want the construct= or to be public + //TODO get rid of it and use setters + private Ejb3JoinColumn( + String sqlType, + String name, + boolean nullable, + boolean unique, + boolean insertable, + boolean updatable, + String referencedColumn, + String secondaryTable, + Map joins, + PropertyHolder propertyHolder, + String propertyName, + String mappedBy, + boolean isImplicit, + ExtendedMappings mappings + ) { + super(); + setImplicit( isImplicit ); + setSqlType( sqlType ); + setLogicalColumnName( name ); + setNullable( nullable ); + setUnique( unique ); + setInsertable( insertable ); + setUpdatable( updatable ); + setSecondaryTableName( secondaryTable ); + setPropertyHolder( propertyHolder ); + setJoins( joins ); + setMappings( mappings ); + setPropertyName( BinderHelper.getRelativePath( propertyHolder, propertyN= ame ) ); + bind(); + this.referencedColumn =3D referencedColumn; + this.mappedBy =3D mappedBy; + } + + public String getReferencedColumn() { + return referencedColumn; + } + + public static Ejb3JoinColumn[] buildJoinColumns( + JoinColumn[] anns, + String mappedBy, Map joins, + PropertyHolder propertyHolder, + String propertyName, + ExtendedMappings mappings + ) { + JoinColumn[] actualColumns =3D propertyHolder.getOverriddenJoinColumn( + StringHelper.qualify( propertyHolder.getPath(), propertyName ) + ); + if ( actualColumns =3D=3D null ) actualColumns =3D anns; + if ( actualColumns =3D=3D null || actualColumns.length =3D=3D 0 ) { + return new Ejb3JoinColumn[] { + buildJoinColumn( (JoinColumn) null, mappedBy, joins, propertyHolder, = propertyName, mappings ) + }; + } + else { + int size =3D actualColumns.length; + Ejb3JoinColumn[] result =3D new Ejb3JoinColumn[size]; + for (int index =3D 0; index < size; index++) { + result[index] =3D buildJoinColumn( + actualColumns[index], + mappedBy, + joins, + propertyHolder, + propertyName, + mappings + ); + } + return result; + } + } + + /** + * build join column for SecondaryTables + */ + private static Ejb3JoinColumn buildJoinColumn( + JoinColumn ann, + String mappedBy, Map joins, + PropertyHolder propertyHolder, + String propertyName, + ExtendedMappings mappings + ) { + if ( ann !=3D null ) { + if ( BinderHelper.isDefault( mappedBy ) ) { + throw new AnnotationException( + "Illegal attempt to define a @JoinColumn with a mappedBy association= : " + + BinderHelper.getRelativePath( propertyHolder, propertyName ) + ); + } + Ejb3JoinColumn joinColumn =3D new Ejb3JoinColumn(); + joinColumn.setJoinAnnotation( ann, null ); + joinColumn.setJoins( joins ); + joinColumn.setPropertyHolder( propertyHolder ); + joinColumn.setPropertyName( BinderHelper.getRelativePath( propertyHolde= r, propertyName ) ); + joinColumn.setImplicit( false ); + joinColumn.setMappings( mappings ); + joinColumn.bind(); + return joinColumn; + } + else { + Ejb3JoinColumn joinColumn =3D new Ejb3JoinColumn(); + joinColumn.setMappedBy( mappedBy ); + joinColumn.setJoins( joins ); + joinColumn.setPropertyHolder( propertyHolder ); + joinColumn.setPropertyName( BinderHelper.getRelativePath( propertyHolde= r, propertyName ) ); + joinColumn.setImplicit( true ); + joinColumn.setMappings( mappings ); + joinColumn.bind(); + return joinColumn; + } + } + + + //FIXME default name still useful in association table + public void setJoinAnnotation(JoinColumn annJoin, String defaultName) { + if ( annJoin =3D=3D null ) { + setImplicit( true ); + } + else { + setImplicit( false ); + if ( !BinderHelper.isDefault( annJoin.columnDefinition() ) ) setSqlType= ( annJoin.columnDefinition() ); + if ( !BinderHelper.isDefault( annJoin.name() ) ) setLogicalColumnName( = annJoin.name() ); + setNullable( annJoin.nullable() ); + setUnique( annJoin.unique() ); + setInsertable( annJoin.insertable() ); + setUpdatable( annJoin.updatable() ); + setReferencedColumn( annJoin.referencedColumnName() ); + setSecondaryTableName( annJoin.table() ); + } + } + + /** + * Build JoinColumn for a JOINED hierarchy + */ + public static Ejb3JoinColumn buildJoinColumn( + PrimaryKeyJoinColumn pkJoinAnn, + JoinColumn joinAnn, + Value identifier, + Map joins, + PropertyHolder propertyHolder, ExtendedMappings mappings + ) { + + Column col =3D (Column) identifier.getColumnIterator().next(); + String defaultName =3D mappings.getLogicalColumnName( col.getQuotedName(= ), identifier.getTable() ); + if ( pkJoinAnn !=3D null || joinAnn !=3D null ) { + String colName; + String columnDefinition; + String referencedColumnName; + if ( pkJoinAnn !=3D null ) { + colName =3D pkJoinAnn.name(); + columnDefinition =3D pkJoinAnn.columnDefinition(); + referencedColumnName =3D pkJoinAnn.referencedColumnName(); + } + else { + colName =3D joinAnn.name(); + columnDefinition =3D joinAnn.columnDefinition(); + referencedColumnName =3D joinAnn.referencedColumnName(); + } + String sqlType =3D "".equals( columnDefinition ) ? null : columnDefinit= ion; + String name =3D "".equals( colName ) ? defaultName : colName; + return new Ejb3JoinColumn( + sqlType, + name, false, false, + true, true, + referencedColumnName, + null, joins, + propertyHolder, null, null, false, mappings + ); + } + else { + return new Ejb3JoinColumn( + (String) null, defaultName, + false, false, true, true, null, (String) null, + joins, propertyHolder, null, null, true, mappings + ); + } + } + + /** + * Override persistent class on oneToMany Cases for late settings + * Must only be used on second level pass binding + */ + public void setPersistentClass(PersistentClass persistentClass, Map joins) { + //FIXME shouldn't we deduce the classname from the persistentclasS? + this.propertyHolder =3D PropertyHolderBuilder.buildPropertyHolder( persi= stentClass, joins, getMappings() ); + } + + public static void checkIfJoinColumn(Object columns, PropertyHolder holde= r, PropertyData property) { + if ( !( columns instanceof Ejb3JoinColumn[] ) ) { + throw new AnnotationException( + "@Column cannot be used on an association property: " + + holder.getEntityName() + + "." + + property.getPropertyName() + ); + } + } + + public void linkValueUsingDefaultColumnNaming( + Column referencedColumn, PersistentClass referencedEntity, SimpleValue = value + ) { + String columnName; + String logicalReferencedColumn =3D getMappings().getLogicalColumnName( + referencedColumn.getQuotedName(), referencedEntity.getTable() + ); + boolean mappedBySide =3D mappedByTableName !=3D null || mappedByProperty= Name !=3D null; + boolean ownerSide =3D getPropertyName() !=3D null; + + Boolean isRefColumnQuoted =3D StringHelper.isQuoted( logicalReferencedCo= lumn ); + String unquotedLogicalReferenceColumn =3D isRefColumnQuoted ? + StringHelper.unquote( logicalReferencedColumn ) : + logicalReferencedColumn; + + if ( mappedBySide ) { + String unquotedMappedbyTable =3D StringHelper.unquote( mappedByTableNam= e ); + columnName =3D getMappings().getNamingStrategy().foreignKeyColumnName( + mappedByPropertyName, + mappedByEntityName, + unquotedMappedbyTable, + unquotedLogicalReferenceColumn + ); + //one element was quoted so we quote + if ( isRefColumnQuoted || StringHelper.isQuoted( mappedByTableName ) ) { + columnName =3D StringHelper.quote( columnName ); + } + } + else if ( ownerSide ) { + String logicalTableName =3D getMappings().getLogicalTableName( referenc= edEntity.getTable() ); + String unquotedLogicalTableName =3D StringHelper.unquote( logicalTableN= ame ); + columnName =3D getMappings().getNamingStrategy().foreignKeyColumnName( + getPropertyName(), + referencedEntity.getEntityName(), + unquotedLogicalTableName, + unquotedLogicalReferenceColumn + ); + //one element was quoted so we quote + if ( isRefColumnQuoted || StringHelper.isQuoted( logicalTableName ) ) { + columnName =3D StringHelper.quote( columnName ); + } + } + else { + //is an intra-entity hierarchy table join so copy the name by default + String logicalTableName =3D getMappings().getLogicalTableName( referenc= edEntity.getTable() ); + String unquotedLogicalTableName =3D StringHelper.unquote( logicalTableN= ame ); + columnName =3D getMappings().getNamingStrategy().joinKeyColumnName( + unquotedLogicalReferenceColumn, + unquotedLogicalTableName + ); + //one element was quoted so we quote + if ( isRefColumnQuoted || StringHelper.isQuoted( logicalTableName ) ) { + columnName =3D StringHelper.quote( columnName ); + } + } + //yuk side effect on an implicit column + setLogicalColumnName( columnName ); + setReferencedColumn( logicalReferencedColumn ); + initMappingColumn( + columnName, + null, referencedColumn.getLength(), + referencedColumn.getPrecision(), + referencedColumn.getScale(), + getMappingColumn().isNullable(), + referencedColumn.getSqlType(), + getMappingColumn().isUnique(), false + ); + linkWithValue( value ); + } + + /** + * used for mappedBy cases + */ + public void linkValueUsingAColumnCopy(Column column, SimpleValue value) { + initMappingColumn( + //column.getName(), + column.getQuotedName(), + null, column.getLength(), + column.getPrecision(), + column.getScale(), + getMappingColumn().isNullable(), + column.getSqlType(), + getMappingColumn().isUnique(), + false //We do copy no strategy here + ); + linkWithValue( value ); + } + + protected void addColumnBinding(SimpleValue value) { + if ( StringHelper.isEmpty( mappedBy ) ) { + String unquotedLogColName =3D StringHelper.unquote( getLogicalColumnNam= e() ); + String unquotedRefColumn =3D StringHelper.unquote( getReferencedColumn(= ) ); + String logicalColumnName =3D getMappings().getNamingStrategy() + .logicalCollectionColumnName( unquotedLogColName, getPropertyName(), = unquotedRefColumn ); + if ( StringHelper.isQuoted( getLogicalColumnName() ) || StringHelper.is= Quoted( getLogicalColumnName() ) ) { + logicalColumnName =3D StringHelper.quote( logicalColumnName ); + } + getMappings().addColumnBinding( logicalColumnName, getMappingColumn(), = value.getTable() ); + } + } + + //keep it JDK 1.4 compliant + //implicit way + public static final int NO_REFERENCE =3D 0; + //reference to the pk in an explicit order + public static final int PK_REFERENCE =3D 1; + //reference to non pk columns + public static final int NON_PK_REFERENCE =3D 2; + + public static int checkReferencedColumnsType( + Ejb3JoinColumn[] columns, PersistentClass referencedEntity, + ExtendedMappings mappings + ) { + //convenient container to find whether a column is an id one or not + Set idColumns =3D new HashSet(); + Iterator idColumnsIt =3D referencedEntity.getKey().getColumnIterator(); + while ( idColumnsIt.hasNext() ) { + idColumns.add( (Column) idColumnsIt.next() ); + } + + boolean isFkReferencedColumnName =3D false; + boolean noReferencedColumn =3D true; + //build the list of potential tables + if ( columns.length =3D=3D 0 ) return NO_REFERENCE; //shortcut + Object columnOwner =3D BinderHelper.findColumnOwner( + referencedEntity, columns[0].getReferencedColumn(), mappings + ); + if ( columnOwner =3D=3D null ) { + try { + throw new MappingException( + "Unable to find column with logical name: " + + columns[0].getReferencedColumn() + " in " + referencedEntity.get= Table() + " and its related " + + "supertables and secondary tables" + ); + } + catch (MappingException e) { + throw new RecoverableException(e); + } + } + Table matchingTable =3D columnOwner instanceof PersistentClass ? + ( (PersistentClass) columnOwner ).getTable() : + ( (Join) columnOwner ).getTable(); + //check each referenced column + for (Ejb3JoinColumn ejb3Column : columns) { + String logicalReferencedColumnName =3D ejb3Column.getReferencedColumn(); + if ( StringHelper.isNotEmpty( logicalReferencedColumnName ) ) { + String referencedColumnName =3D null; + try { + referencedColumnName =3D mappings.getPhysicalColumnName( logicalRefer= encedColumnName, matchingTable ); + } + catch (MappingException me) { + //rewrite the exception + throw new MappingException( + "Unable to find column with logical name: " + + logicalReferencedColumnName + " in " + matchingTable.getName() + ); + } + noReferencedColumn =3D false; + Column refCol =3D new Column( referencedColumnName ); + boolean contains =3D idColumns.contains( refCol ); + if ( !contains ) { + isFkReferencedColumnName =3D true; + break; //we know the state + } + } + } + if ( isFkReferencedColumnName ) { + return NON_PK_REFERENCE; + } + else if ( noReferencedColumn ) { + return NO_REFERENCE; + } + else if ( idColumns.size() !=3D columns.length ) { + //reference use PK but is a subset or a superset + return NON_PK_REFERENCE; + } + else { + return PK_REFERENCE; + } + } + + /** + * Called to apply column definitions from the referenced FK column to th= is column. + * = + * @param column the referenced column. + */ + public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping= .Column column) { + = + // columnDefinition can also be specified using @JoinColumn, hence we ha= ve to check + // whether it is set or not + if ( StringHelper.isEmpty( sqlType ) ) { + sqlType =3D column.getSqlType(); + if ( getMappingColumn() !=3D null ) getMappingColumn().setSqlType( sqlT= ype ); + } + = + // these properties can only be applied on the referenced column - we ca= n just take them over + getMappingColumn().setLength(column.getLength()); + getMappingColumn().setPrecision(column.getPrecision()); + getMappingColumn().setScale(column.getScale()); = + } + + @Override + public void redefineColumnName(String columnName, String propertyName, bo= olean applyNamingStrategy) { + if ( StringHelper.isNotEmpty( columnName ) ) { + getMappingColumn().setName( + applyNamingStrategy ? + getMappings().getNamingStrategy().columnName( columnName ) : + columnName + ); + } + } + + public static Ejb3JoinColumn[] buildJoinTableJoinColumns( + JoinColumn[] annJoins, Map secondaryTables, + PropertyHolder propertyHolder, String propertyName, String mappedBy, Ex= tendedMappings mappings + ) { + Ejb3JoinColumn[] joinColumns; + if ( annJoins =3D=3D null ) { + Ejb3JoinColumn currentJoinColumn =3D new Ejb3JoinColumn(); + currentJoinColumn.setImplicit( true ); + currentJoinColumn.setNullable( false ); //I break the spec, but it's fo= r good + currentJoinColumn.setPropertyHolder( propertyHolder ); + currentJoinColumn.setJoins( secondaryTables ); + currentJoinColumn.setMappings( mappings ); + currentJoinColumn.setPropertyName( + BinderHelper.getRelativePath( propertyHolder, propertyName ) + ); + currentJoinColumn.setMappedBy( mappedBy ); + currentJoinColumn.bind(); + + joinColumns =3D new Ejb3JoinColumn[] { + currentJoinColumn + + }; + } + else { + joinColumns =3D new Ejb3JoinColumn[annJoins.length]; + JoinColumn annJoin; + int length =3D annJoins.length; + for (int index =3D 0; index < length; index++) { + annJoin =3D annJoins[index]; + Ejb3JoinColumn currentJoinColumn =3D new Ejb3JoinColumn(); + currentJoinColumn.setImplicit( true ); + currentJoinColumn.setPropertyHolder( propertyHolder ); + currentJoinColumn.setJoins( secondaryTables ); + currentJoinColumn.setMappings( mappings ); + currentJoinColumn.setPropertyName( BinderHelper.getRelativePath( prope= rtyHolder, propertyName ) ); + currentJoinColumn.setMappedBy( mappedBy ); + currentJoinColumn.setJoinAnnotation( annJoin, propertyName ); + currentJoinColumn.setNullable( false ); //I break the spec, but it's f= or good + //done after the annotation to override it + currentJoinColumn.bind(); + joinColumns[index] =3D currentJoinColumn; + } + } + return joinColumns; + } + + public void setMappedBy(String entityName, String logicalTableName, Strin= g mappedByProperty) { + this.mappedByEntityName =3D entityName; + this.mappedByTableName =3D logicalTableName; + this.mappedByPropertyName =3D mappedByProperty; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Ex= tendedMappings.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Exten= dedMappings.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Exten= dedMappings.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,282 @@ +//$Id: ExtendedMappings.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.cfg; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import javax.persistence.Embeddable; +import javax.persistence.Entity; +import javax.persistence.MappedSuperclass; + +import org.hibernate.AnnotationException; +import org.hibernate.MappingException; +import org.hibernate.annotations.AnyMetaDef; +import org.hibernate.annotations.common.reflection.ReflectionManager; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.engine.NamedQueryDefinition; +import org.hibernate.engine.NamedSQLQueryDefinition; +import org.hibernate.engine.ResultSetMappingDefinition; +import org.hibernate.mapping.IdGenerator; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Table; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; + +/** + * Allow annotation related mappings + *

+ * at least for named generators + * + * @author Emmanuel Bernard + */ +public class ExtendedMappings extends Mappings { + + private final Logger log =3D LoggerFactory.getLogger( ExtendedMappings.cl= ass ); + + private final Map namedGenerators; + private final Map> joins; + private final Map classTypes; + private final Map generatorTables; + private final Map> tableUniqueConstraints; + private final Map mappedByResolver; + private final Map propertyRefResolver; + private final ReflectionManager reflectionManager; + private final Set defaultNamedQueryNames; + private final Set defaultNamedNativeQueryNames; + private final Set defaultSqlResulSetMappingNames; + private final Set defaultNamedGenerators; + private final Map anyMetaDefs; + + ExtendedMappings( + Map classes, Map collections, Map tables, Map queries, Map sqlqueries, = Map sqlResultSetMappings, + Set defaultNamedQueryNames, Set defaultNamedNativeQuery= Names, + Set defaultSqlResulSetMappingNames, Set defaultNamedGen= erators, Map imports, + List secondPasses, List propertyReferences, NamingStrategy namingStrate= gy, Map typeDefs, + Map filterDefinitions, Map namedGenerators, Map> joins, Map classTypes, Map extendsQueue, Map tableNameBinding, + Map columnNameBindingPerTable, + final List auxiliaryDatabaseObjects, + Map generatorTables, + Map> tableUniqueConstraints, + Map mappedByResolver, + Map propertyRefResolver, + Map anyMetaDefs, + ReflectionManager reflectionManager + ) { + super( + classes, + collections, + tables, + queries, + sqlqueries, + sqlResultSetMappings, + imports, + secondPasses, + propertyReferences, + namingStrategy, + typeDefs, + filterDefinitions, + extendsQueue, + auxiliaryDatabaseObjects, + tableNameBinding, + columnNameBindingPerTable + ); + this.namedGenerators =3D namedGenerators; + this.joins =3D joins; + this.classTypes =3D classTypes; + this.generatorTables =3D generatorTables; + this.tableUniqueConstraints =3D tableUniqueConstraints; + this.mappedByResolver =3D mappedByResolver; + this.propertyRefResolver =3D propertyRefResolver; + this.reflectionManager =3D reflectionManager; + this.defaultNamedQueryNames =3D defaultNamedQueryNames; + this.defaultNamedNativeQueryNames =3D defaultNamedNativeQueryNames; + this.defaultSqlResulSetMappingNames =3D defaultSqlResulSetMappingNames; + this.defaultNamedGenerators =3D defaultNamedGenerators; + this.anyMetaDefs =3D anyMetaDefs; + } + + public void addGenerator(IdGenerator generator) throws MappingException { + if ( !defaultNamedGenerators.contains( generator.getName() ) ) { + Object old =3D namedGenerators.put( generator.getName(), generator ); + if ( old !=3D null ) log.warn( "duplicate generator name: {}", generato= r.getName() ); + } + } + + public void addJoins(PersistentClass persistentClass, Map j= oins) throws MappingException { + Object old =3D this.joins.put( persistentClass.getEntityName(), joins ); + if ( old !=3D null ) log.warn( "duplicate joins for class: {}", persiste= ntClass.getEntityName() ); + } + + public AnnotatedClassType addClassType(XClass clazz) { + AnnotatedClassType type; + if ( clazz.isAnnotationPresent( Entity.class ) ) { + type =3D AnnotatedClassType.ENTITY; + } + else if ( clazz.isAnnotationPresent( Embeddable.class ) ) { + type =3D AnnotatedClassType.EMBEDDABLE; + } + else if ( clazz.isAnnotationPresent( MappedSuperclass.class ) ) { + type =3D AnnotatedClassType.EMBEDDABLE_SUPERCLASS; + } + else { + type =3D AnnotatedClassType.NONE; + } + classTypes.put( clazz.getName(), type ); + return type; + } + + /** + * get and maintain a cache of class type. + * A class can be an entity, a embedded objet or nothing. + */ + public AnnotatedClassType getClassType(XClass clazz) { + AnnotatedClassType type =3D classTypes.get( clazz.getName() ); + if ( type =3D=3D null ) { + return addClassType( clazz ); + } + else { + return type; + } + } + + public IdGenerator getGenerator(String name) { + return getGenerator( name, null ); + } + + public Map getJoins(String persistentClass) { + return joins.get( persistentClass ); + } + + /** + * Try to find the generator from the localGenerators + * and then from the global generator list + * + * @param name generator name + * @param localGenerators local generators to find to + * @return the appropriate idgenerator or null if not found + */ + public IdGenerator getGenerator(String name, Map loc= alGenerators) { + if ( localGenerators !=3D null ) { + IdGenerator result =3D localGenerators.get( name ); + if ( result !=3D null ) return result; + } + return namedGenerators.get( name ); + } + + public void addGeneratorTable(String name, Properties params) { + Object old =3D generatorTables.put( name, params ); + if ( old !=3D null ) log.warn( "duplicate generator table: {}", name ); + } + + public Properties getGeneratorTableProperties(String name, Map localGeneratorTables) { + if ( localGeneratorTables !=3D null ) { + Properties result =3D localGeneratorTables.get( name ); + if ( result !=3D null ) return result; + } + return generatorTables.get( name ); + } + + public void addUniqueConstraints(Table table, List uniqueConstraints) { + List oldConstraints =3D tableUniqueConstraints.get( table ); + if ( oldConstraints =3D=3D null ) { + oldConstraints =3D new ArrayList(); + tableUniqueConstraints.put( table, oldConstraints ); + } + oldConstraints.addAll( uniqueConstraints ); + } + + public Map> getTableUniqueConstraints() { + return tableUniqueConstraints; + } + + public void addMappedBy(String entityName, String propertyName, String in= versePropertyName) { + mappedByResolver.put( entityName + "." + propertyName, inversePropertyNa= me ); + } + + public String getFromMappedBy(String entityName, String propertyName) { + return mappedByResolver.get( entityName + "." + propertyName ); + } + + public void addPropertyReferencedAssociation(String entityName, String pr= opertyName, String propertyRef) { + propertyRefResolver.put( entityName + "." + propertyName, propertyRef ); + } + + public String getPropertyReferencedAssociation(String entityName, String = propertyName) { + return propertyRefResolver.get( entityName + "." + propertyName ); + } + + @Override + public void addUniquePropertyReference(String referencedClass, String pro= pertyName) { + super.addUniquePropertyReference( referencedClass, propertyName ); + } + + @Override + public void addPropertyReference(String referencedClass, String propertyN= ame) { + super.addPropertyReference( referencedClass, propertyName ); + } + + public ReflectionManager getReflectionManager() { + return reflectionManager; + } + + public void addDefaultQuery(String name, NamedQueryDefinition query) { + super.addQuery( name, query ); + defaultNamedQueryNames.add( name ); + } + + public void addDefaultSQLQuery(String name, NamedSQLQueryDefinition query= ) { + super.addSQLQuery( name, query ); + defaultNamedNativeQueryNames.add( name ); + } + + public void addDefaultGenerator(IdGenerator idGen) { + this.addGenerator( idGen ); + defaultNamedGenerators.add( idGen.getName() ); + + } + + public void addDefaultResultSetMapping(ResultSetMappingDefinition definit= ion) { + final String name =3D definition.getName(); + if ( !defaultSqlResulSetMappingNames.contains( name ) + && super.getResultSetMapping( name ) !=3D null ) { + resultSetMappings.remove( name ); + } + super.addResultSetMapping( definition ); + defaultSqlResulSetMappingNames.add( name ); + } + + @Override + public void addQuery(String name, NamedQueryDefinition query) throws Mapp= ingException { + if ( !defaultNamedQueryNames.contains( name ) ) super.addQuery( name, qu= ery ); + } + + @Override + public void addResultSetMapping(ResultSetMappingDefinition definition) { + if ( !defaultSqlResulSetMappingNames.contains( definition.getName() ) ) + super.addResultSetMapping( definition ); + } + + @Override + public void addSQLQuery(String name, NamedSQLQueryDefinition query) throw= s MappingException { + if ( !defaultNamedNativeQueryNames.contains( name ) ) super.addSQLQuery(= name, query ); + } + + public Map getClasses() { + return classes; + } + + public void addAnyMetaDef(AnyMetaDef defAnn) { + if ( anyMetaDefs.containsKey( defAnn.name() ) ) { + throw new AnnotationException( "Two @AnyMetaDef with the same name defi= ned: " + defAnn.name() ); + } + anyMetaDefs.put( defAnn.name(), defAnn ); + } + + public AnyMetaDef getAnyMetaDef(String name) { + return anyMetaDefs.get( name ); + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Fk= SecondPass.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/FkSec= ondPass.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/FkSec= ondPass.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,56 @@ +//$Id: FkSecondPass.java 14779 2008-06-18 17:56:27Z hardy.ferentschik $ +package org.hibernate.cfg; + +import java.util.concurrent.atomic.AtomicInteger; + +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.Value; + +/** + * @author Emmanuel Bernard + */ +public abstract class FkSecondPass implements SecondPass { + protected SimpleValue value; + protected Ejb3JoinColumn[] columns; + /** + * unique counter is needed to differentiate 2 instances of FKSecondPass + * as they are compared. + * Fairly hacky but IBM VM sometimes returns the same hashCode for 2 diff= erent objects + * TODO is it doable to rely on the Ejb3JoinColumn names? Not sure at the= y could be inferred + */ + private int uniqueCounter; + private static AtomicInteger globalCounter =3D new AtomicInteger(); + + public FkSecondPass(SimpleValue value, Ejb3JoinColumn[] columns) { + this.value =3D value; + this.columns =3D columns; + this.uniqueCounter =3D globalCounter.getAndIncrement(); + } + + public int getUniqueCounter() { + return uniqueCounter; + } + + public Value getValue() { + return value; + } + + public boolean equals(Object o) { + if ( this =3D=3D o ) return true; + if ( !( o instanceof FkSecondPass ) ) return false; + + FkSecondPass that =3D (FkSecondPass) o; + + if ( uniqueCounter !=3D that.uniqueCounter ) return false; + + return true; + } + + public int hashCode() { + return uniqueCounter; + } + + public abstract String getReferencedEntityName(); + + public abstract boolean isInPrimaryKey(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/In= dexColumn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Index= Column.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Index= Column.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,87 @@ +package org.hibernate.cfg; + +import java.util.Map; + +import org.hibernate.mapping.Join; + +/** + * index column + * + * @author inger + */ +public class IndexColumn + extends Ejb3Column { + + private int base; + + //FIXME move to a getter setter strategy for readeability + public IndexColumn( + boolean isImplicit, + String sqlType, + int length, + int precision, + int scale, + String name, + boolean nullable, + boolean unique, + boolean insertable, + boolean updatable, + String secondaryTableName, + Map joins, + PropertyHolder propertyHolder, + ExtendedMappings mappings + ) { + super(); + setImplicit( isImplicit ); + setSqlType( sqlType ); + setLength( length ); + setPrecision( precision ); + setScale( scale ); + setLogicalColumnName( name ); + setNullable( nullable ); + setUnique( unique ); + setInsertable( insertable ); + setUpdatable( updatable ); + setSecondaryTableName( secondaryTableName ); + setPropertyHolder( propertyHolder ); + setJoins( joins ); + setMappings( mappings ); + bind(); + //super(isImplicit, sqlType, length, precision, scale, name, nullable, u= nique, insertable, updatable, secondaryTableName, joins, propertyHolder, ma= ppings); + + } + + public int getBase() { + return base; + } + + public void setBase(int base) { + this.base =3D base; + } + + public static IndexColumn buildColumnFromAnnotation( + org.hibernate.annotations.IndexColumn ann, + PropertyHolder propertyHolder, + PropertyData inferredData, + ExtendedMappings mappings + ) { + IndexColumn column; + if ( ann !=3D null ) { + String sqlType =3D BinderHelper.isDefault( ann.columnDefinition() ) ? n= ull : ann.columnDefinition(); + String name =3D BinderHelper.isDefault( ann.name() ) ? inferredData.get= PropertyName() : ann.name(); + //TODO move it to a getter based system and remove the constructor + column =3D new IndexColumn( + false, sqlType, 0, 0, 0, name, ann.nullable(), + false, true, true, null, null, propertyHolder, mappings + ); + column.setBase( ann.base() ); + } + else { + column =3D new IndexColumn( + true, null, 0, 0, 0, null, true, + false, true, true, null, null, propertyHolder, mappings + ); + } + return column; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/In= dexOrUniqueKeySecondPass.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Index= OrUniqueKeySecondPass.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Index= OrUniqueKeySecondPass.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,81 @@ +//$Id: IndexOrUniqueKeySecondPass.java 14747 2008-06-06 08:16:25Z hardy.fe= rentschik $ +package org.hibernate.cfg; + +import java.util.Map; + +import org.hibernate.AnnotationException; +import org.hibernate.MappingException; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.Table; + +/** + * @author Emmanuel Bernard + */ +public class IndexOrUniqueKeySecondPass implements SecondPass { + private Table table; + private final String indexName; + private final String[] columns; + private final ExtendedMappings mappings; + private final Ejb3Column column; + private final boolean unique; + + /** + * Build an index + */ + public IndexOrUniqueKeySecondPass(Table table, String indexName, String[]= columns, ExtendedMappings mappings) { + this.table =3D table; + this.indexName =3D indexName; + this.columns =3D columns; + this.mappings =3D mappings; + this.column =3D null; + this.unique =3D false; + } + + /** + * Build an index + */ + public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column, Ex= tendedMappings mappings) { + this( indexName, column, mappings, false ); + } + + /** + * Build an index if unique is false or a Unique Key if unique is true + */ + public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column, + ExtendedMappings mappings, boolean unique) { + this.indexName =3D indexName; + this.column =3D column; + this.columns =3D null; + this.mappings =3D mappings; + this.unique =3D unique; + } + + public void doSecondPass(Map persistentClasses) throws MappingException { + if ( columns !=3D null ) { + for (String columnName : columns) { + addConstraintToColumn( columnName ); + } + } + if ( column !=3D null ) { + this.table =3D column.getTable(); + addConstraintToColumn( mappings.getLogicalColumnName( column.getMapping= Column().getQuotedName(), table ) ); + } + } + + private void addConstraintToColumn(String columnName) { + Column column =3D table.getColumn( + new Column( + mappings.getPhysicalColumnName( columnName, table ) + ) + ); + if ( column =3D=3D null ) { + throw new AnnotationException( + "@Index references a unknown column: " + columnName + ); + } + if ( unique ) + table.getOrCreateUniqueKey( indexName ).addColumn( column ); + else + table.getOrCreateIndex( indexName ).addColumn( column ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/In= heritanceState.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Inher= itanceState.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Inher= itanceState.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,90 @@ +//$Id: InheritanceState.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.cfg; + +import java.util.Map; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.MappedSuperclass; + +import org.hibernate.annotations.common.reflection.ReflectionManager; +import org.hibernate.annotations.common.reflection.XAnnotatedElement; +import org.hibernate.annotations.common.reflection.XClass; + +/** + * Some extra data to the inheritance position of a class + * + * @author Emmanuel Bernard + */ +public class InheritanceState { + public InheritanceState(XClass clazz) { + this.clazz =3D clazz; + extractInheritanceType(); + } + + public XClass clazz; + /** + * has son either mappedsuperclass son or entity son + */ + public boolean hasSons =3D false; + /** + * a mother entity is available + */ + public boolean hasParents =3D false; + public InheritanceType type; + public boolean isEmbeddableSuperclass =3D false; + + /** + * only defined on embedded superclasses + */ + public String accessType =3D null; + public Boolean isPropertyAnnotated; + + private void extractInheritanceType() { + XAnnotatedElement element =3D clazz; + Inheritance inhAnn =3D element.getAnnotation( Inheritance.class ); + MappedSuperclass mappedSuperClass =3D element.getAnnotation( MappedSuper= class.class ); + if ( mappedSuperClass !=3D null ) { + isEmbeddableSuperclass =3D true; + type =3D inhAnn =3D=3D null ? null : inhAnn.strategy(); + } + else { + type =3D inhAnn =3D=3D null ? InheritanceType.SINGLE_TABLE : inhAnn.str= ategy(); + } + } + + boolean hasTable() { + return !hasParents || !InheritanceType.SINGLE_TABLE.equals( type ); + } + + boolean hasDenormalizedTable() { + return hasParents && InheritanceType.TABLE_PER_CLASS.equals( type ); + } + + public static InheritanceState getSuperEntityInheritanceState( + XClass clazz, Map states, + ReflectionManager reflectionManager + ) { + XClass superclass =3D clazz; + do { + superclass =3D superclass.getSuperclass(); + InheritanceState currentState =3D states.get( superclass ); + if ( currentState !=3D null && !currentState.isEmbeddableSuperclass ) r= eturn currentState; + } + while ( superclass !=3D null && !reflectionManager.equals( superclass, O= bject.class ) ); + return null; + } + + public static InheritanceState getSuperclassInheritanceState( + XClass clazz, Map states, + ReflectionManager reflectionManager + ) { + XClass superclass =3D clazz; + do { + superclass =3D superclass.getSuperclass(); + InheritanceState currentState =3D states.get( superclass ); + if ( currentState !=3D null ) return currentState; + } + while ( superclass !=3D null && !reflectionManager.equals( superclass, O= bject.class ) ); + return null; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Jo= inedSubclassFkSecondPass.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Joine= dSubclassFkSecondPass.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Joine= dSubclassFkSecondPass.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,36 @@ +//$Id: JoinedSubclassFkSecondPass.java 14779 2008-06-18 17:56:27Z hardy.fe= rentschik $ +package org.hibernate.cfg; + +import java.util.Map; + +import org.hibernate.MappingException; +import org.hibernate.cfg.annotations.TableBinder; +import org.hibernate.mapping.JoinedSubclass; +import org.hibernate.mapping.SimpleValue; + +/** + * @author Emmanuel Bernard + */ +(a)SuppressWarnings({"serial", "unchecked"}) +public class JoinedSubclassFkSecondPass extends FkSecondPass { + private JoinedSubclass entity; + private ExtendedMappings mappings; + + public JoinedSubclassFkSecondPass(JoinedSubclass entity, Ejb3JoinColumn[]= inheritanceJoinedColumns, SimpleValue key, ExtendedMappings mappings) { + super( key, inheritanceJoinedColumns ); + this.entity =3D entity; + this.mappings =3D mappings; + } + + public String getReferencedEntityName() { + return entity.getSuperclass().getEntityName(); + } + + public boolean isInPrimaryKey() { + return true; + } + + public void doSecondPass(Map persistentClasses) throws MappingException { + TableBinder.bindFk( entity.getSuperclass(), entity, columns, value, fals= e, mappings ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/No= tYetImplementedException.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/NotYe= tImplementedException.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/NotYe= tImplementedException.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,25 @@ +//$Id: NotYetImplementedException.java 14736 2008-06-04 14:23:42Z hardy.fe= rentschik $ +package org.hibernate.cfg; + +import org.hibernate.MappingException; + +/** + * Mapping not yet implemented + * + * @author Emmanuel Bernard + */ +public class NotYetImplementedException extends MappingException { + + public NotYetImplementedException(String msg, Throwable root) { + super( msg, root ); + } + + public NotYetImplementedException(Throwable root) { + super( root ); + } + + public NotYetImplementedException(String s) { + super( s ); + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/On= eToOneSecondPass.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/OneTo= OneSecondPass.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/OneTo= OneSecondPass.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,263 @@ +//$Id: OneToOneSecondPass.java 14759 2008-06-10 14:14:15Z hardy.ferentschi= k $ +package org.hibernate.cfg; + +import java.util.Iterator; +import java.util.Map; + +import org.hibernate.AnnotationException; +import org.hibernate.MappingException; +import org.hibernate.annotations.ForeignKey; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.cfg.annotations.PropertyBinder; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.DependantValue; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.ManyToOne; +import org.hibernate.mapping.OneToOne; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.type.ForeignKeyDirection; +import org.hibernate.util.StringHelper; + +/** + * We have to handle OneToOne in a second pass because: + * - + */ +public class OneToOneSecondPass implements SecondPass { + private String mappedBy; + private ExtendedMappings mappings; + private String ownerEntity; + private String ownerProperty; + private PropertyHolder propertyHolder; + private boolean ignoreNotFound; + private PropertyData inferredData; + private XClass targetEntity; + private boolean cascadeOnDelete; + private boolean optional; + private String cascadeStrategy; + private Ejb3JoinColumn[] joinColumns; + + //that suck, we should read that from the property mainly + public OneToOneSecondPass( + String mappedBy, String ownerEntity, String ownerProperty, + PropertyHolder propertyHolder, PropertyData inferredData, XClass target= Entity, boolean ignoreNotFound, + boolean cascadeOnDelete, boolean optional, String cascadeStrategy, Ejb3= JoinColumn[] columns, + ExtendedMappings mappings + ) { + this.ownerEntity =3D ownerEntity; + this.ownerProperty =3D ownerProperty; + this.mappedBy =3D mappedBy; + this.propertyHolder =3D propertyHolder; + this.mappings =3D mappings; + this.ignoreNotFound =3D ignoreNotFound; + this.inferredData =3D inferredData; + this.targetEntity =3D targetEntity; + this.cascadeOnDelete =3D cascadeOnDelete; + this.optional =3D optional; + this.cascadeStrategy =3D cascadeStrategy; + this.joinColumns =3D columns; + } + + //TODO refactor this code, there is a lot of duplication in this method + public void doSecondPass(Map persistentClasses) throws MappingException { + org.hibernate.mapping.OneToOne value =3D new org.hibernate.mapping.OneTo= One( + propertyHolder.getTable(), propertyHolder.getPersistentClass() + ); + final String propertyName =3D inferredData.getPropertyName(); + value.setPropertyName( propertyName ); + String referencedEntityName; + if ( AnnotationBinder.isDefault( targetEntity, mappings ) ) { + referencedEntityName =3D inferredData.getClassOrElementName(); + } + else { + referencedEntityName =3D targetEntity.getName(); + } + value.setReferencedEntityName( referencedEntityName ); = + AnnotationBinder.defineFetchingStrategy( value, inferredData.getProperty= () ); + //value.setFetchMode( fetchMode ); + value.setCascadeDeleteEnabled( cascadeOnDelete ); + //value.setLazy( fetchMode !=3D FetchMode.JOIN ); + + if ( !optional ) value.setConstrained( true ); + value.setForeignKeyType( + value.isConstrained() ? + ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT : + ForeignKeyDirection.FOREIGN_KEY_TO_PARENT + ); + PropertyBinder binder =3D new PropertyBinder(); + binder.setName( propertyName ); + binder.setValue( value ); + binder.setCascade( cascadeStrategy ); + binder.setPropertyAccessorName( inferredData.getDefaultAccess() ); + Property prop =3D binder.make(); + if ( BinderHelper.isDefault( mappedBy ) ) { + /* + * we need to check if the columns are in the right order + * if not, then we need to create a many to one and formula + * but actually, since entities linked by a one to one need + * to share the same composite id class, this cannot happen in hibernate + */ + boolean rightOrder =3D true; + + if ( rightOrder ) { + String path =3D StringHelper.qualify( propertyHolder.getPath(), proper= tyName ); + ( new ToOneFkSecondPass( + value, joinColumns, + !optional, //cannot have nullabe and unique on certain DBs + propertyHolder.getEntityOwnerClassName(), + path, mappings + ) ).doSecondPass( persistentClasses ); + //no column associated since its a one to one + propertyHolder.addProperty( prop ); + } + else { + //this is a many to one with Formula + + } + } + else { + PersistentClass otherSide =3D (PersistentClass) persistentClasses.get( = value.getReferencedEntityName() ); + Property otherSideProperty; + try { + if ( otherSide =3D=3D null ) { + throw new MappingException( "Unable to find entity: " + value.getRefe= rencedEntityName() ); + } + otherSideProperty =3D BinderHelper.findPropertyByName( otherSide, mapp= edBy ); + } + catch (MappingException e) { + throw new AnnotationException( + "Unknown mappedBy in: " + StringHelper.qualify( ownerEntity, ownerPr= operty ) + + ", referenced property unknown: " + + StringHelper.qualify( value.getReferencedEntityName(), mappedBy ) + ); + } + if ( otherSideProperty =3D=3D null ) { + throw new AnnotationException( + "Unknown mappedBy in: " + StringHelper.qualify( ownerEntity, ownerPr= operty ) + + ", referenced property unknown: " + + StringHelper.qualify( value.getReferencedEntityName(), mappedBy ) + ); + } + if ( otherSideProperty.getValue() instanceof OneToOne ) { + propertyHolder.addProperty( prop ); + } + else if ( otherSideProperty.getValue() instanceof ManyToOne ) { + Iterator it =3D otherSide.getJoinIterator(); + Join otherSideJoin =3D null; + while ( it.hasNext() ) { + otherSideJoin =3D (Join) it.next(); + if ( otherSideJoin.containsProperty( otherSideProperty ) ) { + break; + } + } + if ( otherSideJoin !=3D null ) { + //@OneToOne @JoinTable + Join mappedByJoin =3D buildJoinFromMappedBySide( + (PersistentClass) persistentClasses.get( ownerEntity ), otherSidePr= operty, otherSideJoin + ); + ManyToOne manyToOne =3D new ManyToOne( mappedByJoin.getTable() ); + //FIXME use ignore not found here + manyToOne.setIgnoreNotFound( ignoreNotFound ); + manyToOne.setCascadeDeleteEnabled( value.isCascadeDeleteEnabled() ); + manyToOne.setEmbedded( value.isEmbedded() ); + manyToOne.setFetchMode( value.getFetchMode() ); + manyToOne.setLazy( value.isLazy() ); + manyToOne.setReferencedEntityName( value.getReferencedEntityName() ); + manyToOne.setUnwrapProxy( value.isUnwrapProxy() ); + prop.setValue( manyToOne ); + Iterator otherSideJoinKeyColumns =3D otherSideJoin.getKey().getColumn= Iterator(); + while ( otherSideJoinKeyColumns.hasNext() ) { + Column column =3D (Column) otherSideJoinKeyColumns.next(); + Column copy =3D new Column(); + copy.setLength( column.getLength() ); + copy.setScale( column.getScale() ); + copy.setValue( manyToOne ); + copy.setName( column.getQuotedName() ); + copy.setNullable( column.isNullable() ); + copy.setPrecision( column.getPrecision() ); + copy.setUnique( column.isUnique() ); + copy.setSqlType( column.getSqlType() ); + copy.setCheckConstraint( column.getCheckConstraint() ); + copy.setComment( column.getComment() ); + copy.setDefaultValue( column.getDefaultValue() ); + manyToOne.addColumn( copy ); + } + mappedByJoin.addProperty( prop ); + } + else { + propertyHolder.addProperty( prop ); + } + + value.setReferencedPropertyName( mappedBy ); + + String propertyRef =3D value.getReferencedPropertyName(); + if ( propertyRef !=3D null ) { + mappings.addUniquePropertyReference( + value.getReferencedEntityName(), + propertyRef + ); + } + } + else { + throw new AnnotationException( + "Referenced property not a (One|Many)ToOne: " + + StringHelper.qualify( + otherSide.getEntityName(), mappedBy + ) + + " in mappedBy of " + + StringHelper.qualify( ownerEntity, ownerProperty ) + ); + } + } + ForeignKey fk =3D inferredData.getProperty().getAnnotation( ForeignKey.c= lass ); + String fkName =3D fk !=3D null ? fk.name() : ""; + if ( !BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName= ); + } + + /** + * Builds the Join instance for the mapped by side of a O= neToOne association using = + * a join tables. + *

+ * Note:
+ *

    + *
  • From the mappedBy side we should not create the PK nor the FK, thi= s is handled from the other side.
  • + *
  • This method is a dirty dupe of EntityBinder.bindSecondaryTable. + *

    + */ + private Join buildJoinFromMappedBySide(PersistentClass persistentClass, P= roperty otherSideProperty, Join originalJoin) { + Join join =3D new Join(); + join.setPersistentClass( persistentClass ); + + //no check constraints available on joins + join.setTable( originalJoin.getTable() ); + join.setInverse( true ); + SimpleValue key =3D new DependantValue( join.getTable(), persistentClass= .getIdentifier() ); + //TODO support @ForeignKey + join.setKey( key ); + join.setSequentialSelect( false ); + //TODO support for inverse and optional + join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing= anyway + key.setCascadeDeleteEnabled( false ); + Iterator mappedByColumns =3D otherSideProperty.getValue().getColumnItera= tor(); + while ( mappedByColumns.hasNext() ) { + Column column =3D (Column) mappedByColumns.next(); + Column copy =3D new Column(); + copy.setLength( column.getLength() ); + copy.setScale( column.getScale() ); + copy.setValue( key ); + copy.setName( column.getQuotedName() ); + copy.setNullable( column.isNullable() ); + copy.setPrecision( column.getPrecision() ); + copy.setUnique( column.isUnique() ); + copy.setSqlType( column.getSqlType() ); + copy.setCheckConstraint( column.getCheckConstraint() ); + copy.setComment( column.getComment() ); + copy.setDefaultValue( column.getDefaultValue() ); + key.addColumn( copy ); + } + persistentClass.addJoin( join ); + return join; + } +} + Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Pr= opertyData.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Prope= rtyData.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Prope= rtyData.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,42 @@ +package org.hibernate.cfg; + +import org.hibernate.MappingException; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; + +public interface PropertyData { + + /** + * @return default member access (whether field or property) + * @throws MappingException No getter or field found or wrong JavaBean sp= ec usage + */ + public String getDefaultAccess(); + + /** + * @return property name + * @throws MappingException No getter or field found or wrong JavaBean sp= ec usage + */ + public String getPropertyName() throws MappingException; + + /** + * Returns the returned class itself or the element type if an array + */ + public XClass getClassOrElement() throws MappingException; + + /** + * Return the class itself + */ + public XClass getPropertyClass() throws MappingException; + + /** + * Returns the returned class name itself or the element type if an array + */ + public String getClassOrElementName() throws MappingException; + + /** + * Returns the returned class name itself + */ + public String getTypeName() throws MappingException; + + public XProperty getProperty(); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Pr= opertyHolder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Prope= rtyHolder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Prope= rtyHolder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,54 @@ +package org.hibernate.cfg; + +import javax.persistence.Column; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; + +import org.hibernate.mapping.Join; +import org.hibernate.mapping.KeyValue; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.Table; + +/** + * Property holder abstract property containers from their direct implemen= tation + * + * @author Emmanuel Bernard + */ +public interface PropertyHolder { + String getClassName(); + + String getEntityOwnerClassName(); + + Table getTable(); + + void addProperty(Property prop); + + KeyValue getIdentifier(); + + PersistentClass getPersistentClass(); + + boolean isComponent(); + + boolean isEntity(); + + void setParentProperty(String parentProperty); + + String getPath(); + + /** + * return null if the column is not overridden, or an array of column if = true + */ + Column[] getOverriddenColumn(String propertyName); + + /** + * return null if the column is not overridden, or an array of column if = true + */ + JoinColumn[] getOverriddenJoinColumn(String propertyName); + + String getEntityName(); + + void addProperty(Property prop, Ejb3Column[] columns); + + Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation); +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Pr= opertyHolderBuilder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Prope= rtyHolderBuilder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Prope= rtyHolderBuilder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,67 @@ +//$Id: PropertyHolderBuilder.java 14736 2008-06-04 14:23:42Z hardy.ferents= chik $ +package org.hibernate.cfg; + +import java.util.Map; + +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.cfg.annotations.EntityBinder; +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.Component; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.PersistentClass; + +/** + * This factory is here ot build a PropertyHolder and prevent .mapping int= erface adding + * + * @author Emmanuel Bernard + */ +public final class PropertyHolderBuilder { + private PropertyHolderBuilder() { + } + + public static PropertyHolder buildPropertyHolder( + XClass clazzToProcess, + PersistentClass persistentClass, + EntityBinder entityBinder, + //Map joins, + ExtendedMappings mappings + ) { + return new ClassPropertyHolder( persistentClass, clazzToProcess, entityB= inder, mappings ); + } + + /** + * build a component property holder + * + * @param component component to wrap + * @param path component path + * @param mappings + * @return PropertyHolder + */ + public static PropertyHolder buildPropertyHolder( + Component component, String path, PropertyData inferredData, PropertyHo= lder parent, + ExtendedMappings mappings + ) { + return new ComponentPropertyHolder( component, path, inferredData, paren= t, mappings ); + } + + /** + * buid a property holder on top of a collection + */ + public static PropertyHolder buildPropertyHolder( + Collection collection, String path, XClass clazzToProcess, XProperty pr= operty, + PropertyHolder parentPropertyHolder, ExtendedMappings mappings + ) { + return new CollectionPropertyHolder( collection, path, clazzToProcess, p= roperty, parentPropertyHolder, mappings ); + } + + /** + * must only be used on second level phases ( has to be settled alr= eady) + */ + public static PropertyHolder buildPropertyHolder( + PersistentClass persistentClass, Map joins, + ExtendedMappings mappings + ) { + return new ClassPropertyHolder( persistentClass, null, joins, mappings ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Pr= opertyInferredData.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Prope= rtyInferredData.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Prope= rtyInferredData.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,72 @@ +//$Id: PropertyInferredData.java 14736 2008-06-04 14:23:42Z hardy.ferentsc= hik $ +package org.hibernate.cfg; + +import org.hibernate.MappingException; +import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.Target; +import org.hibernate.annotations.common.reflection.ReflectionManager; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; + +/** + * Retrieve all inferred data from an annnoted element + * + * @author Emmanuel Bernard + * @author Paolo Perrotta + */ +public class PropertyInferredData implements PropertyData { + private final String defaultAccess; + + private final XProperty property; + private final ReflectionManager reflectionManager; + + /** + * Take the annoted element for lazy process + */ + public PropertyInferredData(XProperty property, String propertyAccessor, = ReflectionManager reflectionManager) { + this.property =3D property; + this.defaultAccess =3D propertyAccessor; + this.reflectionManager =3D reflectionManager; + } + + public String getDefaultAccess() throws MappingException { + // if(skip()) + // return defaultAccess; + AccessType access =3D property.getAnnotation( AccessType.class ); + return access !=3D null ? access.value() : defaultAccess; + } + + public String getPropertyName() throws MappingException { + return property.getName(); + } + + public XClass getPropertyClass() throws MappingException { + if ( property.isAnnotationPresent( Target.class ) ) { + return reflectionManager.toXClass( property.getAnnotation( Target.class= ).value() ); + } + else { + return property.getType(); + } + } + + public XClass getClassOrElement() throws MappingException { + if ( property.isAnnotationPresent( Target.class ) ) { + return reflectionManager.toXClass( property.getAnnotation( Target.class= ).value() ); + } + else { + return property.getClassOrElementClass(); + } + } + + public String getClassOrElementName() throws MappingException { + return getClassOrElement().getName(); + } + + public String getTypeName() throws MappingException { + return getPropertyClass().getName(); + } + + public XProperty getProperty() { + return property; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Pr= opertyPreloadedData.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Prope= rtyPreloadedData.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Prope= rtyPreloadedData.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,48 @@ +//$Id: PropertyPreloadedData.java 14736 2008-06-04 14:23:42Z hardy.ferents= chik $ +package org.hibernate.cfg; + +import org.hibernate.MappingException; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; + +public class PropertyPreloadedData implements PropertyData { + private final String defaultAccess; + + private final String propertyName; + + private final XClass returnedClass; + + public PropertyPreloadedData(String defaultAccess, String propertyName, X= Class returnedClass) { + this.defaultAccess =3D defaultAccess; + this.propertyName =3D propertyName; + this.returnedClass =3D returnedClass; + } + + public String getDefaultAccess() throws MappingException { + return defaultAccess; + } + + public String getPropertyName() throws MappingException { + return propertyName; + } + + public XClass getClassOrElement() throws MappingException { + return getPropertyClass(); + } + + public XClass getPropertyClass() throws MappingException { + return returnedClass; + } + + public String getClassOrElementName() throws MappingException { + return getTypeName(); + } + + public String getTypeName() throws MappingException { + return returnedClass =3D=3D null ? null : returnedClass.getName(); + } + + public XProperty getProperty() { + return null; //instead of UnsupportedOperationException + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Re= coverableException.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Recov= erableException.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Recov= erableException.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,25 @@ +//$ +package org.hibernate.cfg; + +import org.hibernate.AnnotationException; + +/** + * Should neven be exposed to the client + * An exception that wrap an underlying exception whith the hope + * subsequent processing will recover from it. + * + * @author Emmanuel Bernard + */ +public class RecoverableException extends AnnotationException { + public RecoverableException(String msg, Throwable root) { + super( msg, root ); + } + + public RecoverableException(Throwable root) { + super( root ); + } + + public RecoverableException(String s) { + super( s ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Se= condaryTableSecondPass.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Secon= daryTableSecondPass.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Secon= daryTableSecondPass.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,28 @@ +//$Id: SecondaryTableSecondPass.java 14736 2008-06-04 14:23:42Z hardy.fere= ntschik $ +package org.hibernate.cfg; + +import java.util.Map; + +import org.hibernate.MappingException; +import org.hibernate.annotations.common.reflection.XAnnotatedElement; +import org.hibernate.cfg.annotations.EntityBinder; + +/** + * @author Emmanuel Bernard + */ +public class SecondaryTableSecondPass implements SecondPass { + private EntityBinder entityBinder; + private PropertyHolder propertyHolder; + private XAnnotatedElement annotatedClass; + + public SecondaryTableSecondPass(EntityBinder entityBinder, PropertyHolder= propertyHolder, XAnnotatedElement annotatedClass) { + this.entityBinder =3D entityBinder; + this.propertyHolder =3D propertyHolder; + this.annotatedClass =3D annotatedClass; + } + + public void doSecondPass(Map persistentClasses) throws MappingException { + entityBinder.finalSecondaryTableBinding( propertyHolder ); + = + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/To= OneFkSecondPass.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/ToOne= FkSecondPass.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/ToOne= FkSecondPass.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,102 @@ +// $Id: ToOneFkSecondPass.java 14736 2008-06-04 14:23:42Z hardy.ferentschi= k $ +package org.hibernate.cfg; + +import java.util.Iterator; + +import org.hibernate.AnnotationException; +import org.hibernate.AssertionFailure; +import org.hibernate.MappingException; +import org.hibernate.cfg.annotations.TableBinder; +import org.hibernate.mapping.ManyToOne; +import org.hibernate.mapping.OneToOne; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.ToOne; +import org.hibernate.mapping.KeyValue; +import org.hibernate.mapping.Component; +import org.hibernate.util.StringHelper; + +/** + * Enable a proper set of the FK columns in respect with the id column ord= er + * Allow the correct implementation of the default EJB3 values which needs= both + * sides of the association to be resolved + * + * @author Emmanuel Bernard + */ +public class ToOneFkSecondPass extends FkSecondPass { + private boolean unique; + private ExtendedMappings mappings; + private String path; + private String entityClassName; + + public ToOneFkSecondPass( + ToOne value, Ejb3JoinColumn[] columns, boolean unique, String entityCla= ssName, String path, ExtendedMappings mappings + ) { + super( value, columns ); + this.mappings =3D mappings; + this.unique =3D unique; + this.entityClassName =3D entityClassName; + this.path =3D entityClassName !=3D null ? path.substring( entityClassNam= e.length() + 1 ) : path; + } + + public String getReferencedEntityName() { + return ( (ToOne) value ).getReferencedEntityName(); + } + + public boolean isInPrimaryKey() { + if ( entityClassName =3D=3D null ) return false; + final PersistentClass persistentClass =3D mappings.getClass( entityClass= Name ); + Property property =3D persistentClass.getIdentifierProperty(); + if ( path =3D=3D null ) { + return false; + } + else if ( property !=3D null) { + //try explicit identifier property + return path.startsWith( property.getName() + "." ); + } + else { + //try the embedded property + //embedded property starts their path with 'id.' See PropertyPreloadedD= ata( ) use when idClass !=3D null in AnnotationBinder + if ( path.startsWith( "id." ) ) { + KeyValue valueIdentifier =3D persistentClass.getIdentifier(); + String localPath =3D path.substring( 3 ); + if ( valueIdentifier instanceof Component ) { + Iterator it =3D ( (Component) valueIdentifier ).getPropertyIterator(); + while ( it.hasNext() ) { + Property idProperty =3D (Property) it.next(); + if ( localPath.startsWith( idProperty.getName() ) ) return true; + } + + } + } + } + return false; + } + + public void doSecondPass(java.util.Map persistentClasses) throws MappingE= xception { + if ( value instanceof ManyToOne ) { + ManyToOne manyToOne =3D (ManyToOne) value; + PersistentClass ref =3D (PersistentClass) persistentClasses.get( manyTo= One.getReferencedEntityName() ); + if ( ref =3D=3D null ) { + throw new AnnotationException( + "@OneToOne or @ManyToOne on " + + StringHelper.qualify( entityClassName, path ) + + " references an unknown entity: " + + manyToOne.getReferencedEntityName() + ); + } + BinderHelper.createSyntheticPropertyReference( columns, ref, null, many= ToOne, false, mappings ); + TableBinder.bindFk( ref, null, columns, manyToOne, unique, mappings ); + /* + * HbmBinder does this only when property-ref !=3D null, but IMO, it ma= kes sense event if it is null + */ + if ( !manyToOne.isIgnoreNotFound() ) manyToOne.createPropertyRefConstra= ints( persistentClasses ); + } + else if ( value instanceof OneToOne ) { + ( (OneToOne) value ).createForeignKey(); + } + else { + throw new AssertionFailure( "FkSecondPass for a wrong value type: " + v= alue.getClass().getName() ); + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Wr= appedInferredData.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Wrapp= edInferredData.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/Wrapp= edInferredData.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,48 @@ +//$Id: WrappedInferredData.java 14736 2008-06-04 14:23:42Z hardy.ferentsch= ik $ +package org.hibernate.cfg; + +import org.hibernate.MappingException; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.util.StringHelper; + +/** + * @author Emmanuel Bernard + */ +public class WrappedInferredData implements PropertyData { + private PropertyData wrappedInferredData; + private String propertyName; + + public XClass getClassOrElement() throws MappingException { + return wrappedInferredData.getClassOrElement(); + } + + public String getClassOrElementName() throws MappingException { + return wrappedInferredData.getClassOrElementName(); + } + + public String getDefaultAccess() { + return wrappedInferredData.getDefaultAccess(); + } + + public XProperty getProperty() { + return wrappedInferredData.getProperty(); + } + + public XClass getPropertyClass() throws MappingException { + return wrappedInferredData.getPropertyClass(); + } + + public String getPropertyName() throws MappingException { + return propertyName; + } + + public String getTypeName() throws MappingException { + return wrappedInferredData.getTypeName(); + } + + public WrappedInferredData(PropertyData inferredData, String suffix) { + this.wrappedInferredData =3D inferredData; + this.propertyName =3D StringHelper.qualify( inferredData.getPropertyName= (), suffix ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/ArrayBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/ArrayBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/ArrayBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,20 @@ +package org.hibernate.cfg.annotations; + +import org.hibernate.mapping.Array; +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.PersistentClass; + +/** + * Bind an Array + * + * @author Anthony Patricio + */ +public class ArrayBinder extends ListBinder { + + public ArrayBinder() { + } + + protected Collection createCollection(PersistentClass persistentClass) { + return new Array( persistentClass ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/BagBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/BagBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/BagBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,19 @@ +package org.hibernate.cfg.annotations; + +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.PersistentClass; + +/** + * Bind a bag. + * + * @author Matthew Inger + */ +public class BagBinder extends CollectionBinder { + + public BagBinder() { + } + + protected Collection createCollection(PersistentClass persistentClass) { + return new org.hibernate.mapping.Bag( persistentClass ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/CollectionBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/CollectionBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/CollectionBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,1429 @@ +package org.hibernate.cfg.annotations; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Embeddable; +import javax.persistence.FetchType; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.MapKey; +import javax.persistence.OneToMany; + +import org.hibernate.AnnotationException; +import org.hibernate.AssertionFailure; +import org.hibernate.FetchMode; +import org.hibernate.MappingException; +import org.hibernate.annotations.BatchSize; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CollectionId; +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.Filter; +import org.hibernate.annotations.FilterJoinTable; +import org.hibernate.annotations.FilterJoinTables; +import org.hibernate.annotations.Filters; +import org.hibernate.annotations.ForeignKey; +import org.hibernate.annotations.Immutable; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; +import org.hibernate.annotations.Loader; +import org.hibernate.annotations.ManyToAny; +import org.hibernate.annotations.OptimisticLock; +import org.hibernate.annotations.OrderBy; +import org.hibernate.annotations.Persister; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLDeleteAll; +import org.hibernate.annotations.SQLInsert; +import org.hibernate.annotations.SQLUpdate; +import org.hibernate.annotations.Sort; +import org.hibernate.annotations.SortType; +import org.hibernate.annotations.Where; +import org.hibernate.annotations.WhereJoinTable; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.cfg.AnnotatedClassType; +import org.hibernate.cfg.AnnotationBinder; +import org.hibernate.cfg.BinderHelper; +import org.hibernate.cfg.CollectionSecondPass; +import org.hibernate.cfg.Ejb3Column; +import org.hibernate.cfg.Ejb3JoinColumn; +import org.hibernate.cfg.ExtendedMappings; +import org.hibernate.cfg.IndexColumn; +import org.hibernate.cfg.PropertyData; +import org.hibernate.cfg.PropertyHolder; +import org.hibernate.cfg.PropertyHolderBuilder; +import org.hibernate.cfg.PropertyInferredData; +import org.hibernate.cfg.PropertyPreloadedData; +import org.hibernate.cfg.SecondPass; +import org.hibernate.engine.ExecuteUpdateResultCheckStyle; +import org.hibernate.mapping.Any; +import org.hibernate.mapping.Backref; +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.Component; +import org.hibernate.mapping.DependantValue; +import org.hibernate.mapping.IdGenerator; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.KeyValue; +import org.hibernate.mapping.ManyToOne; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.Selectable; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.SingleTableSubclass; +import org.hibernate.mapping.Table; +import org.hibernate.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Base class for binding different types of collections to Hibernate conf= iguration objects. + * + * @author inger + * @author Emmanuel Bernard + */ +(a)SuppressWarnings({"unchecked", "serial"}) +public abstract class CollectionBinder { + + private Logger log =3D LoggerFactory.getLogger( CollectionBinder.class ); + + protected Collection collection; + protected String propertyName; + PropertyHolder propertyHolder; + int batchSize; + private String mappedBy; + private XClass collectionType; + private XClass targetEntity; + private ExtendedMappings mappings; + private Ejb3JoinColumn[] inverseJoinColumns; + private String cascadeStrategy; + String cacheConcurrencyStrategy; + String cacheRegionName; + private boolean oneToMany; + protected IndexColumn indexColumn; + private String orderBy; + protected String hqlOrderBy; + private boolean isSorted; + private Class comparator; + private boolean hasToBeSorted; + protected boolean cascadeDeleteEnabled; + protected String mapKeyPropertyName; + private boolean insertable =3D true; + private boolean updatable =3D true; + private Ejb3JoinColumn[] fkJoinColumns; + private boolean isExplicitAssociationTable; + private Ejb3Column[] elementColumns; + private boolean isEmbedded; + private XProperty property; + private boolean ignoreNotFound; + private TableBinder tableBinder; + private Ejb3Column[] mapKeyColumns; + private Ejb3JoinColumn[] mapKeyManyToManyColumns; + protected HashMap localGenerators; + + public void setUpdatable(boolean updatable) { + this.updatable =3D updatable; + } + + public void setInsertable(boolean insertable) { + this.insertable =3D insertable; + } + + + public void setCascadeStrategy(String cascadeStrategy) { + this.cascadeStrategy =3D cascadeStrategy; + } + + public void setPropertyAccessorName(String propertyAccessorName) { + this.propertyAccessorName =3D propertyAccessorName; + } + + private String propertyAccessorName; + + public void setInverseJoinColumns(Ejb3JoinColumn[] inverseJoinColumns) { + this.inverseJoinColumns =3D inverseJoinColumns; + } + + public void setJoinColumns(Ejb3JoinColumn[] joinColumns) { + this.joinColumns =3D joinColumns; + } + + private Ejb3JoinColumn[] joinColumns; + + public void setPropertyHolder(PropertyHolder propertyHolder) { + this.propertyHolder =3D propertyHolder; + } + + public void setBatchSize(BatchSize batchSize) { + this.batchSize =3D batchSize =3D=3D null ? -1 : batchSize.size(); + } + + public void setEjb3OrderBy(javax.persistence.OrderBy orderByAnn) { + if ( orderByAnn !=3D null ) { + hqlOrderBy =3D orderByAnn.value(); + } + } + + public void setSqlOrderBy(OrderBy orderByAnn) { + if ( orderByAnn !=3D null ) { + if ( !BinderHelper.isDefault( orderByAnn.clause() ) ) orderBy =3D order= ByAnn.clause(); + } + } + + public void setSort(Sort sortAnn) { + if ( sortAnn !=3D null ) { + isSorted =3D !SortType.UNSORTED.equals( sortAnn.type() ); + if ( isSorted && SortType.COMPARATOR.equals( sortAnn.type() ) ) { + comparator =3D sortAnn.comparator(); + } + } + } + + /** + * collection binder factory + */ + public static CollectionBinder getCollectionBinder( + String entityName, XProperty property, + boolean isIndexed + ) { + if ( property.isArray() ) { + if ( property.getElementClass().isPrimitive() ) { + return new PrimitiveArrayBinder(); + } + else { + return new ArrayBinder(); + } + } + else if ( property.isCollection() ) { + //TODO consider using an XClass + Class returnedClass =3D property.getCollectionClass(); + if ( java.util.Set.class.equals( returnedClass ) ) { + if ( property.isAnnotationPresent( CollectionId.class ) ) { + throw new AnnotationException( "Set do not support @CollectionId: " + + StringHelper.qualify( entityName, property.getName() ) ); + } + return new SetBinder(); + } + else if ( java.util.SortedSet.class.equals( returnedClass ) ) { + if ( property.isAnnotationPresent( CollectionId.class ) ) { + throw new AnnotationException( "Set do not support @CollectionId: " + + StringHelper.qualify( entityName, property.getName() ) ); + } + return new SetBinder( true ); + } + else if ( java.util.Map.class.equals( returnedClass ) ) { + if ( property.isAnnotationPresent( CollectionId.class ) ) { + throw new AnnotationException( "Map do not support @CollectionId: " + + StringHelper.qualify( entityName, property.getName() ) ); + } + return new MapBinder(); + } + else if ( java.util.SortedMap.class.equals( returnedClass ) ) { + if ( property.isAnnotationPresent( CollectionId.class ) ) { + throw new AnnotationException( "Map do not support @CollectionId: " + + StringHelper.qualify( entityName, property.getName() ) ); + } + return new MapBinder( true ); + } + else if ( java.util.Collection.class.equals( returnedClass ) ) { + if ( property.isAnnotationPresent( CollectionId.class ) ) { + return new IdBagBinder(); + } + else { + return new BagBinder(); + } + } + else if ( java.util.List.class.equals( returnedClass ) ) { + if ( isIndexed ) { + if ( property.isAnnotationPresent( CollectionId.class ) ) { + throw new AnnotationException( "List do not support @CollectionId an= d @IndexColumn at the same time: " + + StringHelper.qualify( entityName, property.getName() ) ); + } + return new ListBinder(); + } + else if ( property.isAnnotationPresent( CollectionId.class ) ) { + return new IdBagBinder(); + } + else { + return new BagBinder(); + } + } + else { + throw new AnnotationException( + returnedClass.getName() + " collection not yet supported: " + + StringHelper.qualify( entityName, property.getName() ) + ); + } + } + else { + throw new AnnotationException( + "Illegal attempt to map a non collection as a @OneToMany, @ManyToMany= or @CollectionOfElements: " + + StringHelper.qualify( entityName, property.getName() ) + ); + } + } + + protected CollectionBinder() { + } + + protected CollectionBinder(boolean sorted) { + this.hasToBeSorted =3D sorted; + } + + public void setMappedBy(String mappedBy) { + this.mappedBy =3D mappedBy; + } + + public void setTableBinder(TableBinder tableBinder) { + this.tableBinder =3D tableBinder; + } + + public void setCollectionType(XClass collectionType) { + this.collectionType =3D collectionType; + } + + public void setTargetEntity(XClass targetEntity) { + this.targetEntity =3D targetEntity; + } + + public void setMappings(ExtendedMappings mappings) { + this.mappings =3D mappings; + } + + protected abstract Collection createCollection(PersistentClass persistent= Class); + + public Collection getCollection() { + return collection; + } + + public void setPropertyName(String propertyName) { + this.propertyName =3D propertyName; + } + + public void bind() { + this.collection =3D createCollection( propertyHolder.getPersistentClass(= ) ); + log.debug( "Collection role: {}", StringHelper.qualify( propertyHolder.g= etPath(), propertyName ) ); + collection.setRole( StringHelper.qualify( propertyHolder.getPath(), prop= ertyName ) ); + collection.setNodeName( propertyName ); + + if ( property.isAnnotationPresent( org.hibernate.annotations.MapKey.clas= s ) && mapKeyPropertyName !=3D null ) { + throw new AnnotationException( + "Cannot mix @javax.persistence.MapKey and @org.hibernate.annotations.= MapKey " + + "on the same collection: " + StringHelper.qualify( + propertyHolder.getPath(), propertyName + ) + ); + } + + //set laziness + defineFetchingStrategy(); + collection.setBatchSize( batchSize ); + if ( orderBy !=3D null && hqlOrderBy !=3D null ) { + throw new AnnotationException( + "Cannot use sql order by clause in conjunction of EJB3 order by claus= e: " + safeCollectionRole() + ); + } + + collection.setMutable( !property.isAnnotationPresent( Immutable.class ) = ); + OptimisticLock lockAnn =3D property.getAnnotation( OptimisticLock.class = ); + if ( lockAnn !=3D null ) collection.setOptimisticLocked( !lockAnn.exclud= ed() ); + Persister persisterAnn =3D property.getAnnotation( Persister.class ); + if ( persisterAnn !=3D null ) collection.setCollectionPersisterClass( pe= rsisterAnn.impl() ); + + // set ordering + if ( orderBy !=3D null ) collection.setOrderBy( orderBy ); + if ( isSorted ) { + collection.setSorted( true ); + if ( comparator !=3D null ) { + try { + collection.setComparator( (Comparator) comparator.newInstance() ); + } + catch (ClassCastException e) { + throw new AnnotationException( + "Comparator not implementing java.util.Comparator class: " + + comparator.getName() + "(" + safeCollectionRole() + ")" + ); + } + catch (Exception e) { + throw new AnnotationException( + "Could not instantiate comparator class: " + + comparator.getName() + "(" + safeCollectionRole() + ")" + ); + } + } + } + else { + if ( hasToBeSorted ) { + throw new AnnotationException( + "A sorted collection has to define @Sort: " + + safeCollectionRole() + ); + } + } + + //set cache + if ( StringHelper.isNotEmpty( cacheConcurrencyStrategy ) ) { + collection.setCacheConcurrencyStrategy( cacheConcurrencyStrategy ); + collection.setCacheRegionName( cacheRegionName ); + } + + //SQL overriding + SQLInsert sqlInsert =3D property.getAnnotation( SQLInsert.class ); + SQLUpdate sqlUpdate =3D property.getAnnotation( SQLUpdate.class ); + SQLDelete sqlDelete =3D property.getAnnotation( SQLDelete.class ); + SQLDeleteAll sqlDeleteAll =3D property.getAnnotation( SQLDeleteAll.class= ); + Loader loader =3D property.getAnnotation( Loader.class ); + if ( sqlInsert !=3D null ) { + collection.setCustomSQLInsert( sqlInsert.sql().trim(), sqlInsert.callab= le(), + ExecuteUpdateResultCheckStyle.parse( sqlInsert.check().toString().toL= owerCase() ) + ); + + } + if ( sqlUpdate !=3D null ) { + collection.setCustomSQLUpdate( sqlUpdate.sql(), sqlUpdate.callable(), + ExecuteUpdateResultCheckStyle.parse( sqlUpdate.check().toString().toL= owerCase() ) + ); + } + if ( sqlDelete !=3D null ) { + collection.setCustomSQLDelete( sqlDelete.sql(), sqlDelete.callable(), + ExecuteUpdateResultCheckStyle.parse( sqlDelete.check().toString().toL= owerCase() ) + ); + } + if ( sqlDeleteAll !=3D null ) { + collection.setCustomSQLDeleteAll( sqlDeleteAll.sql(), sqlDeleteAll.call= able(), + ExecuteUpdateResultCheckStyle.parse( sqlDeleteAll.check().toString().= toLowerCase() ) + ); + } + if ( loader !=3D null ) { + collection.setLoaderName( loader.namedQuery() ); + } + + //work on association + boolean isMappedBy =3D !BinderHelper.isDefault( mappedBy ); + collection.setInverse( isMappedBy ); + + //many to many may need some second pass informations + if ( !oneToMany && isMappedBy ) { + mappings.addMappedBy( getCollectionType().getName(), mappedBy, property= Name ); + } + //TODO reducce tableBinder !=3D null and oneToMany + XClass collectionType =3D getCollectionType(); + SecondPass sp =3D getSecondPass( + fkJoinColumns, + joinColumns, + inverseJoinColumns, + elementColumns, + mapKeyColumns, mapKeyManyToManyColumns, isEmbedded, + property, collectionType, + ignoreNotFound, oneToMany, + tableBinder, mappings + ); + if ( collectionType.isAnnotationPresent( Embeddable.class ) + || property.isAnnotationPresent( CollectionOfElements.class ) ) { + // do it right away, otherwise @ManyToon on composite element call addS= econdPass = + // and raise a ConcurrentModificationException + //sp.doSecondPass( CollectionHelper.EMPTY_MAP ); + mappings.addSecondPass( sp, !isMappedBy ); + } + else { + mappings.addSecondPass( sp, !isMappedBy ); + } + + mappings.addCollection( collection ); + + //property building + PropertyBinder binder =3D new PropertyBinder(); + binder.setName( propertyName ); + binder.setValue( collection ); + binder.setCascade( cascadeStrategy ); + if ( cascadeStrategy !=3D null && cascadeStrategy.indexOf( "delete-orpha= n" ) >=3D 0 ) { + collection.setOrphanDelete( true ); + } + binder.setPropertyAccessorName( propertyAccessorName ); + binder.setProperty( property ); + binder.setInsertable( insertable ); + binder.setUpdatable( updatable ); + Property prop =3D binder.make(); + //we don't care about the join stuffs because the column is on the assoc= iation table. + propertyHolder.addProperty( prop ); + } + + private void defineFetchingStrategy() { + LazyCollection lazy =3D property.getAnnotation( LazyCollection.class ); + Fetch fetch =3D property.getAnnotation( Fetch.class ); + OneToMany oneToMany =3D property.getAnnotation( OneToMany.class ); + ManyToMany manyToMany =3D property.getAnnotation( ManyToMany.class ); + CollectionOfElements elements =3D property.getAnnotation( CollectionOfEl= ements.class ); + ManyToAny manyToAny =3D property.getAnnotation( ManyToAny.class ); + FetchType fetchType; + if ( oneToMany !=3D null ) { + fetchType =3D oneToMany.fetch(); + } + else if ( manyToMany !=3D null ) { + fetchType =3D manyToMany.fetch(); + } + else if ( elements !=3D null ) { + fetchType =3D elements.fetch(); + } + else if ( manyToAny !=3D null ) { + fetchType =3D FetchType.LAZY; + } + else { + throw new AssertionFailure( + "Define fetch strategy on a property not annotated with @ManyToOne no= r @OneToMany nor @CollectionOfElements" + ); + } + if ( lazy !=3D null ) { + collection.setLazy( !( lazy.value() =3D=3D LazyCollectionOption.FALSE )= ); + collection.setExtraLazy( lazy.value() =3D=3D LazyCollectionOption.EXTRA= ); + } + else { + collection.setLazy( fetchType =3D=3D FetchType.LAZY ); + collection.setExtraLazy( false ); + } + if ( fetch !=3D null ) { + if ( fetch.value() =3D=3D org.hibernate.annotations.FetchMode.JOIN ) { + collection.setFetchMode( FetchMode.JOIN ); + collection.setLazy( false ); + } + else if ( fetch.value() =3D=3D org.hibernate.annotations.FetchMode.SELE= CT ) { + collection.setFetchMode( FetchMode.SELECT ); + } + else if ( fetch.value() =3D=3D org.hibernate.annotations.FetchMode.SUBS= ELECT ) { + collection.setFetchMode( FetchMode.SELECT ); + collection.setSubselectLoadable( true ); + collection.getOwner().setSubselectLoadableCollections( true ); + } + else { + throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() ); + } + } + else { + collection.setFetchMode( AnnotationBinder.getFetchMode( fetchType ) ); + } + } + + private XClass getCollectionType() { + if ( AnnotationBinder.isDefault( targetEntity, mappings ) ) { + if ( collectionType !=3D null ) { + return collectionType; + } + else { + String errorMsg =3D "Collection has neither generic type or OneToMany.= targetEntity() defined: " + + safeCollectionRole(); + throw new AnnotationException( errorMsg ); + } + } + else { + return targetEntity; + } + } + + public SecondPass getSecondPass( + final Ejb3JoinColumn[] fkJoinColumns, final Ejb3JoinColumn[] keyColumns, + final Ejb3JoinColumn[] inverseColumns, + final Ejb3Column[] elementColumns, + final Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToMa= nyColumns, final boolean isEmbedded, + final XProperty property, final XClass collType, + final boolean ignoreNotFound, final boolean unique, + final TableBinder assocTableBinder, final ExtendedMappings mappings + ) { + + return new CollectionSecondPass( mappings, collection ) { + + public void secondPass(java.util.Map persistentClasses, java.util.Map i= nheritedMetas) + throws MappingException { + bindStarToManySecondPass( + persistentClasses, collType, fkJoinColumns, keyColumns, inverseColum= ns, elementColumns, + isEmbedded, property, unique, assocTableBinder, ignoreNotFound, mapp= ings + ); + + } + }; + } + + /** + * return true if it's a Fk, false if it's an association table + */ + protected boolean bindStarToManySecondPass( + Map persistentClasses, XClass collType, Ejb3JoinColumn[] fkJoinColumns, + Ejb3JoinColumn[] keyColumns, Ejb3JoinColumn[] inverseColumns, Ejb3Colum= n[] elementColumns, + boolean isEmbedded, + XProperty property, boolean unique, + TableBinder associationTableBinder, boolean ignoreNotFound, ExtendedMap= pings mappings + ) { + PersistentClass persistentClass =3D (PersistentClass) persistentClasses.= get( collType.getName() ); + boolean reversePropertyInJoin =3D false; + if ( persistentClass !=3D null && StringHelper.isNotEmpty( this.mappedBy= ) ) { + try { + reversePropertyInJoin =3D 0 !=3D persistentClass.getJoinNumber( + persistentClass.getRecursiveProperty( this.mappedBy ) + ); + } + catch (MappingException e) { + StringBuilder error =3D new StringBuilder( 80 ); + error.append( "mappedBy reference an unknown target entity property: "= ) + .append( collType ).append( "." ).append( this.mappedBy ) + .append( " in " ) + .append( collection.getOwnerEntityName() ) + .append( "." ) + .append( property.getName() ); + throw new AnnotationException( error.toString() ); + } + } + if ( persistentClass !=3D null + && !reversePropertyInJoin + && oneToMany + && !this.isExplicitAssociationTable + && ( joinColumns[0].isImplicit() && !BinderHelper.isDefault( this.mapp= edBy ) //implicit @JoinColumn + || !fkJoinColumns[0].isImplicit() ) //this is an explicit @JoinColumn + ) { + //this is a Foreign key + bindOneToManySecondPass( + getCollection(), + persistentClasses, + fkJoinColumns, + collType, + cascadeDeleteEnabled, + ignoreNotFound, hqlOrderBy, + mappings + ); + return true; + } + else { + //this is an association table + bindManyToManySecondPass( + this.collection, + persistentClasses, + keyColumns, + inverseColumns, + elementColumns, + isEmbedded, collType, + ignoreNotFound, unique, + cascadeDeleteEnabled, + associationTableBinder, property, propertyHolder, hqlOrderBy, mappings + ); + return false; + } + } + + protected void bindOneToManySecondPass( + Collection collection, Map persistentClasses, Ejb3JoinColumn[] fkJoinCo= lumns, + XClass collectionType, + boolean cascadeDeleteEnabled, boolean ignoreNotFound, String hqlOrderBy= , ExtendedMappings extendedMappings + ) { + + log.debug("Binding a OneToMany: {}.{} through a foreign key", propertyHo= lder.getEntityName(), propertyName); + org.hibernate.mapping.OneToMany oneToMany =3D new org.hibernate.mapping.= OneToMany( collection.getOwner() ); + collection.setElement( oneToMany ); + oneToMany.setReferencedEntityName( collectionType.getName() ); + oneToMany.setIgnoreNotFound( ignoreNotFound ); + + String assocClass =3D oneToMany.getReferencedEntityName(); + PersistentClass associatedClass =3D (PersistentClass) persistentClasses.= get( assocClass ); + String orderBy =3D buildOrderByClauseFromHql( hqlOrderBy, associatedClas= s, collection.getRole() ); + if ( orderBy !=3D null ) collection.setOrderBy( orderBy ); + if ( mappings =3D=3D null ) { + throw new AssertionFailure( + "CollectionSecondPass for oneToMany should not be called with null ma= ppings" + ); + } + Map joins =3D mappings.getJoins( assocClass ); + if ( associatedClass =3D=3D null ) { + throw new MappingException( + "Association references unmapped class: " + assocClass + ); + } + oneToMany.setAssociatedClass( associatedClass ); + for (Ejb3JoinColumn column : fkJoinColumns) { + column.setPersistentClass( associatedClass, joins ); + column.setJoins( joins ); + collection.setCollectionTable( column.getTable() ); + } + log.info( + "Mapping collection: " + collection.getRole() + " -> " + collection.ge= tCollectionTable().getName() + ); + bindFilters( false ); + bindCollectionSecondPass( collection, null, fkJoinColumns, cascadeDelete= Enabled, property, mappings ); + if ( !collection.isInverse() + && !collection.getKey().isNullable() ) { + // for non-inverse one-to-many, with a not-null fk, add a backref! + String entityName =3D oneToMany.getReferencedEntityName(); + PersistentClass referenced =3D mappings.getClass( entityName ); + Backref prop =3D new Backref(); + prop.setName( '_' + fkJoinColumns[0].getPropertyName() + "Backref" ); + prop.setUpdateable( false ); + prop.setSelectable( false ); + prop.setCollectionRole( collection.getRole() ); + prop.setEntityName( collection.getOwner().getEntityName() ); + prop.setValue( collection.getKey() ); + referenced.addProperty( prop ); + } + } + + + private void bindFilters(boolean hasAssociationTable) { + Filter simpleFilter =3D property.getAnnotation( Filter.class ); + //set filtering + //test incompatible choices + //if ( StringHelper.isNotEmpty( where ) ) collection.setWhere( where ); + if ( simpleFilter !=3D null ) { + if ( hasAssociationTable ) { + collection.addManyToManyFilter( simpleFilter.name(), getCondition( sim= pleFilter ) ); + } + else { + collection.addFilter( simpleFilter.name(), getCondition( simpleFilter = ) ); + } + } + Filters filters =3D property.getAnnotation( Filters.class ); + if ( filters !=3D null ) { + for (Filter filter : filters.value()) { + if ( hasAssociationTable ) { + collection.addManyToManyFilter( filter.name(), getCondition( filter )= ); + } + else { + collection.addFilter( filter.name(), getCondition( filter ) ); + } + } + } + FilterJoinTable simpleFilterJoinTable =3D property.getAnnotation( Filter= JoinTable.class ); + if ( simpleFilterJoinTable !=3D null ) { + if ( hasAssociationTable ) { + collection.addFilter( simpleFilterJoinTable.name(), getCondition( simp= leFilterJoinTable ) ); + } + else { + throw new AnnotationException( + "Illegal use of @FilterJoinTable on an association without join tabl= e:" + + StringHelper.qualify( propertyHolder.getPath(), propertyName ) + ); + } + } + FilterJoinTables filterJoinTables =3D property.getAnnotation( FilterJoin= Tables.class ); + if ( filterJoinTables !=3D null ) { + for (FilterJoinTable filter : filterJoinTables.value()) { + if ( hasAssociationTable ) { + collection.addFilter( filter.name(), getCondition( filter ) ); + } + else { + throw new AnnotationException( + "Illegal use of @FilterJoinTable on an association without join tab= le:" + + StringHelper.qualify( propertyHolder.getPath(), propertyName ) + ); + } + } + } + + Where where =3D property.getAnnotation( Where.class ); + String whereClause =3D where =3D=3D null ? null : where.clause(); + if ( StringHelper.isNotEmpty( whereClause ) ) { + if ( hasAssociationTable ) { + collection.setManyToManyWhere( whereClause ); + } + else { + collection.setWhere( whereClause ); + } + } + + WhereJoinTable whereJoinTable =3D property.getAnnotation( WhereJoinTable= .class ); + String whereJoinTableClause =3D whereJoinTable =3D=3D null ? null : wher= eJoinTable.clause(); + if ( StringHelper.isNotEmpty( whereJoinTableClause ) ) { + if ( hasAssociationTable ) { + collection.setWhere( whereJoinTableClause ); + } + else { + throw new AnnotationException( + "Illegal use of @WhereJoinTable on an association without join table= :" + + StringHelper.qualify( propertyHolder.getPath(), propertyName ) + ); + } + } +// This cannot happen in annotations since the second fetch is hardcoded = to join +// if ( ( ! collection.getManyToManyFilterMap().isEmpty() || collection.g= etManyToManyWhere() !=3D null ) && +// collection.getFetchMode() =3D=3D FetchMode.JOIN && +// collection.getElement().getFetchMode() !=3D FetchMode.JOIN ) { +// throw new MappingException( +// "association with join table defining filter or where withou= t join fetching " + +// "not valid within collection using join fetching [" + collect= ion.getRole() + "]" +// ); +// } + } + + private String getCondition(FilterJoinTable filter) { + //set filtering + String name =3D filter.name(); + String cond =3D filter.condition(); + return getCondition( cond, name ); + } + + private String getCondition(Filter filter) { + //set filtering + String name =3D filter.name(); + String cond =3D filter.condition(); + return getCondition( cond, name ); + } + + private String getCondition(String cond, String name) { + if ( BinderHelper.isDefault( cond ) ) { + cond =3D mappings.getFilterDefinition( name ).getDefaultFilterCondition= (); + if ( StringHelper.isEmpty( cond ) ) { + throw new AnnotationException( + "no filter condition found for filter " + name + " in " + + StringHelper.qualify( propertyHolder.getPath(), propertyName ) + ); + } + } + return cond; + } + + public void setCache(Cache cacheAnn) { + if ( cacheAnn !=3D null ) { + cacheRegionName =3D BinderHelper.isDefault( cacheAnn.region() ) ? null = : cacheAnn.region(); + cacheConcurrencyStrategy =3D EntityBinder.getCacheConcurrencyStrategy( = cacheAnn.usage() ); + } + else { + cacheConcurrencyStrategy =3D null; + cacheRegionName =3D null; + } + } + + public void setOneToMany(boolean oneToMany) { + this.oneToMany =3D oneToMany; + } + + public void setIndexColumn(IndexColumn indexColumn) { + this.indexColumn =3D indexColumn; + } + + public void setMapKey(MapKey key) { + if ( key !=3D null ) { + mapKeyPropertyName =3D key.name(); + } + } + + private static String buildOrderByClauseFromHql(String hqlOrderBy, Persis= tentClass associatedClass, String role) { + String orderByString =3D null; + if ( hqlOrderBy !=3D null ) { + List properties =3D new ArrayList(); + List ordering =3D new ArrayList(); + StringBuilder orderByBuffer =3D new StringBuilder(); + if ( hqlOrderBy.length() =3D=3D 0 ) { + //order by id + Iterator it =3D associatedClass.getIdentifier().getColumnIterator(); + while ( it.hasNext() ) { + Selectable col =3D (Selectable) it.next(); + orderByBuffer.append( col.getText() ).append( " asc" ).append( ", " ); + } + } + else { + StringTokenizer st =3D new StringTokenizer( hqlOrderBy, " ,", false ); + String currentOrdering =3D null; + //FIXME make this code decent + while ( st.hasMoreTokens() ) { + String token =3D st.nextToken(); + if ( isNonPropertyToken( token ) ) { + if ( currentOrdering !=3D null ) { + throw new AnnotationException( + "Error while parsing HQL orderBy clause: " + hqlOrderBy + + " (" + role + ")" + ); + } + currentOrdering =3D token; + } + else { + //Add ordering of the previous + if ( currentOrdering =3D=3D null ) { + //default ordering + ordering.add( "asc" ); + } + else { + ordering.add( currentOrdering ); + currentOrdering =3D null; + } + properties.add( token ); + } + } + ordering.remove( 0 ); //first one is the algorithm starter + // add last one ordering + if ( currentOrdering =3D=3D null ) { + //default ordering + ordering.add( "asc" ); + } + else { + ordering.add( currentOrdering ); + currentOrdering =3D null; + } + int index =3D 0; + + for (String property : properties) { + Property p =3D BinderHelper.findPropertyByName( associatedClass, prop= erty ); + if ( p =3D=3D null ) { + throw new AnnotationException( + "property from @OrderBy clause not found: " + + associatedClass.getEntityName() + "." + property + ); + } + PersistentClass pc =3D p.getPersistentClass(); + String table; + if ( pc =3D=3D null ) { + //we are touching a @IdClass property, the pc is not set + //this means pc =3D=3D associatedClass + //TODO check whether @ManyToOne @JoinTable in @IdClass used for @Ord= erBy works: doh! + table =3D ""; + } + = + else if (pc =3D=3D associatedClass + || (associatedClass instanceof SingleTableSubclass && pc + .getMappedClass().isAssignableFrom( + associatedClass.getMappedClass()))) { + table =3D ""; + } else { + table =3D pc.getTable().getQuotedName() + "."; + } + = + Iterator propertyColumns =3D p.getColumnIterator(); + while ( propertyColumns.hasNext() ) { + Selectable column =3D (Selectable) propertyColumns.next(); + orderByBuffer.append( table ) + .append( column.getText() ) + .append( " " ) + .append( ordering.get( index ) ) + .append( ", " ); + } + index++; + } + } + orderByString =3D orderByBuffer.substring( 0, orderByBuffer.length() - = 2 ); + } + return orderByString; + } + + private static String buildOrderByClauseFromHql(String hqlOrderBy, Compon= ent component, String role) { + String orderByString =3D null; + if ( hqlOrderBy !=3D null ) { + List properties =3D new ArrayList(); + List ordering =3D new ArrayList(); + StringBuilder orderByBuffer =3D new StringBuilder(); + if ( hqlOrderBy.length() =3D=3D 0 ) { + //TODO : Check that. Maybe order by key for maps + } + else { + StringTokenizer st =3D new StringTokenizer( hqlOrderBy, " ,", false ); + String currentOrdering =3D null; + //FIXME make this code decent + while ( st.hasMoreTokens() ) { + String token =3D st.nextToken(); + if ( isNonPropertyToken( token ) ) { + if ( currentOrdering !=3D null ) { + throw new AnnotationException( + "Error while parsing HQL orderBy clause: " + hqlOrderBy + + " (" + role + ")" + ); + } + currentOrdering =3D token; + } + else { + //Add ordering of the previous + if ( currentOrdering =3D=3D null ) { + //default ordering + ordering.add( "asc" ); + } + else { + ordering.add( currentOrdering ); + currentOrdering =3D null; + } + properties.add( token ); + } + } + ordering.remove( 0 ); //first one is the algorithm starter + // add last one ordering + if ( currentOrdering =3D=3D null ) { + //default ordering + ordering.add( "asc" ); + } + else { + ordering.add( currentOrdering ); + currentOrdering =3D null; + } + int index =3D 0; + + for (String property : properties) { + Property p =3D component.getProperty( property ); + if ( p =3D=3D null ) { + throw new AnnotationException( + "property from @OrderBy clause not found: " + + role + "." + property + ); + } + + Iterator propertyColumns =3D p.getColumnIterator(); + while ( propertyColumns.hasNext() ) { + Selectable column =3D (Selectable) propertyColumns.next(); + orderByBuffer.append( column.getText() ) + .append( " " ) + .append( ordering.get( index ) ) + .append( ", " ); + } + index++; + } + + if ( orderByBuffer.length() >=3D 2 ) { + orderByString =3D orderByBuffer.substring( 0, orderByBuffer.length() = - 2 ); + } + } + } + return orderByString; + } + + private static boolean isNonPropertyToken(String token) { + if ( " ".equals( token ) ) return true; + if ( ",".equals( token ) ) return true; + if ( token.equalsIgnoreCase( "desc" ) ) return true; + if ( token.equalsIgnoreCase( "asc" ) ) return true; + return false; + } + + private static SimpleValue buildCollectionKey( + Collection collValue, Ejb3JoinColumn[] joinColumns, boolean cascadeDele= teEnabled, + XProperty property, ExtendedMappings mappings + ) { + //binding key reference using column + KeyValue keyVal; + //give a chance to override the referenced property name + //has to do that here because the referencedProperty creation happens in= a FKSecondPass for Many to one yuk! + if ( joinColumns.length > 0 && StringHelper.isNotEmpty( joinColumns[0].g= etMappedBy() ) ) { + String entityName =3D joinColumns[0].getManyToManyOwnerSideEntityName()= !=3D null ? + "inverse__" + joinColumns[0].getManyToManyOwnerSideEntityName() : + joinColumns[0].getPropertyHolder().getEntityName(); + String propRef =3D mappings.getPropertyReferencedAssociation( + entityName, + joinColumns[0].getMappedBy() + ); + if ( propRef !=3D null ) { + collValue.setReferencedPropertyName( propRef ); + mappings.addPropertyReference( collValue.getOwnerEntityName(), propRef= ); + } + } + String propRef =3D collValue.getReferencedPropertyName(); + if ( propRef =3D=3D null ) { + keyVal =3D collValue.getOwner().getIdentifier(); + } + else { + keyVal =3D (KeyValue) collValue.getOwner() + .getRecursiveProperty( propRef ) + .getValue(); + } + DependantValue key =3D new DependantValue( collValue.getCollectionTable(= ), keyVal ); + key.setTypeName( null ); + Ejb3Column.checkPropertyConsistency( joinColumns, collValue.getOwnerEnti= tyName() ); + key.setNullable( joinColumns.length =3D=3D 0 || joinColumns[0].isNullabl= e() ); + key.setUpdateable( joinColumns.length =3D=3D 0 || joinColumns[0].isUpdat= able() ); + key.setCascadeDeleteEnabled( cascadeDeleteEnabled ); + collValue.setKey( key ); + ForeignKey fk =3D property !=3D null ? property.getAnnotation( ForeignKe= y.class ) : null; + String fkName =3D fk !=3D null ? fk.name() : ""; + if ( !BinderHelper.isDefault( fkName ) ) key.setForeignKeyName( fkName ); + return key; + } + + protected void bindManyToManySecondPass( + Collection collValue, + Map persistentClasses, + Ejb3JoinColumn[] joinColumns, + Ejb3JoinColumn[] inverseJoinColumns, + Ejb3Column[] elementColumns, + boolean isEmbedded, + XClass collType, + boolean ignoreNotFound, boolean unique, + boolean cascadeDeleteEnabled, + TableBinder associationTableBinder, XProperty property, PropertyHolder = parentPropertyHolder, + String hqlOrderBy, ExtendedMappings mappings + ) throws MappingException { + + PersistentClass collectionEntity =3D (PersistentClass) persistentClasses= .get( collType.getName() ); + boolean isCollectionOfEntities =3D collectionEntity !=3D null; + ManyToAny anyAnn =3D property.getAnnotation( ManyToAny.class ); + if ( log.isDebugEnabled() ) { + String path =3D collValue.getOwnerEntityName() + "." + joinColumns[0].g= etPropertyName(); + if ( isCollectionOfEntities && unique ) { + log.debug( "Binding a OneToMany: {} through an association table", pat= h ); + } + else if ( isCollectionOfEntities ) { + log.debug( "Binding as ManyToMany: {}", path ); + } + else if ( anyAnn !=3D null ) { + log.debug( "Binding a ManyToAny: {}", path ); + } + else { + log.debug( "Binding a collection of element: {}", path ); + } + } + //check for user error + if ( !isCollectionOfEntities ) { + if ( property.isAnnotationPresent( ManyToMany.class ) || property.isAnn= otationPresent( OneToMany.class ) ) { + String path =3D collValue.getOwnerEntityName() + "." + joinColumns[0].= getPropertyName(); + throw new AnnotationException( + "Use of @OneToMany or @ManyToMany targeting an unmapped class: " + p= ath + "[" + collType + "]" + ); + } + else if ( anyAnn !=3D null ) { + if ( !property.isAnnotationPresent( JoinTable.class ) ) { + String path =3D collValue.getOwnerEntityName() + "." + joinColumns[0]= .getPropertyName(); + throw new AnnotationException( + "@JoinTable is mandatory when @ManyToAny is used: " + path + ); + } + } + else { + JoinTable joinTableAnn =3D property.getAnnotation( JoinTable.class ); + if ( joinTableAnn !=3D null && joinTableAnn.inverseJoinColumns().lengt= h > 0 ) { + String path =3D collValue.getOwnerEntityName() + "." + joinColumns[0]= .getPropertyName(); + throw new AnnotationException( + "Use of @JoinTable.inverseJoinColumns targeting an unmapped class: = " + path + "[" + collType + "]" + ); + } + } + } + + boolean mappedBy =3D !BinderHelper.isDefault( joinColumns[0].getMappedBy= () ); + if ( mappedBy ) { + if ( !isCollectionOfEntities ) { + StringBuilder error =3D new StringBuilder( 80 ) + .append( + "Collection of elements must not have mappedBy or association refe= rence an unmapped entity: " + ) + .append( collValue.getOwnerEntityName() ) + .append( "." ) + .append( joinColumns[0].getPropertyName() ); + throw new AnnotationException( error.toString() ); + } + Property otherSideProperty; + try { + otherSideProperty =3D collectionEntity.getRecursiveProperty( joinColum= ns[0].getMappedBy() ); + } + catch (MappingException e) { + StringBuilder error =3D new StringBuilder( 80 ); + error.append( "mappedBy reference an unknown target entity property: "= ) + .append( collType ).append( "." ).append( joinColumns[0].getMappedBy= () ) + .append( " in " ) + .append( collValue.getOwnerEntityName() ) + .append( "." ) + .append( joinColumns[0].getPropertyName() ); + throw new AnnotationException( error.toString() ); + } + Table table; + if ( otherSideProperty.getValue() instanceof Collection ) { + //this is a collection on the other side + table =3D ( (Collection) otherSideProperty.getValue() ).getCollectionT= able(); + } + else { + //This is a ToOne with a @JoinTable or a regular property + table =3D otherSideProperty.getValue().getTable(); + } + collValue.setCollectionTable( table ); + String entityName =3D collectionEntity.getEntityName(); + for (Ejb3JoinColumn column : joinColumns) { + //column.setDefaultColumnHeader( joinColumns[0].getMappedBy() ); //see= ms not to be used, make sense + column.setManyToManyOwnerSideEntityName( entityName ); + } + } + else { + //TODO: only for implicit columns? + //FIXME NamingStrategy + for (Ejb3JoinColumn column : joinColumns) { + String mappedByProperty =3D mappings.getFromMappedBy( + collValue.getOwnerEntityName(), column.getPropertyName() + ); + Table ownerTable =3D collValue.getOwner().getTable(); + column.setMappedBy( + collValue.getOwner().getEntityName(), mappings.getLogicalTableName( = ownerTable ), + mappedByProperty + ); +// String header =3D ( mappedByProperty =3D=3D null ) ? mappings.getLog= icalTableName( ownerTable ) : mappedByProperty; +// column.setDefaultColumnHeader( header ); + } + if ( StringHelper.isEmpty( associationTableBinder.getName() ) ) { + //default value + associationTableBinder.setDefaultName( + collValue.getOwner().getEntityName(), + mappings.getLogicalTableName( collValue.getOwner().getTable() ), + collectionEntity !=3D null ? collectionEntity.getEntityName() : null, + collectionEntity !=3D null ? mappings.getLogicalTableName( collectio= nEntity.getTable() ) : null, + joinColumns[0].getPropertyName() + ); + } + collValue.setCollectionTable( associationTableBinder.bind() ); + } + bindFilters( isCollectionOfEntities ); + bindCollectionSecondPass( collValue, collectionEntity, joinColumns, casc= adeDeleteEnabled, property, mappings ); + + ManyToOne element =3D null; + if ( isCollectionOfEntities ) { + element =3D + new ManyToOne( collValue.getCollectionTable() ); + collValue.setElement( element ); + element.setReferencedEntityName( collType.getName() ); + //element.setFetchMode( fetchMode ); + //element.setLazy( fetchMode !=3D FetchMode.JOIN ); + //make the second join non lazy + element.setFetchMode( FetchMode.JOIN ); + element.setLazy( false ); + element.setIgnoreNotFound( ignoreNotFound ); + if ( StringHelper.isNotEmpty( hqlOrderBy ) ) { + collValue.setManyToManyOrdering( + buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.g= etRole() ) + ); + } + ForeignKey fk =3D property !=3D null ? property.getAnnotation( ForeignK= ey.class ) : null; + String fkName =3D fk !=3D null ? fk.inverseName() : ""; + if ( !BinderHelper.isDefault( fkName ) ) element.setForeignKeyName( fkN= ame ); + } + else if ( anyAnn !=3D null ) { + //@ManyToAny + //Make sure that collTyp is never used during the @ManyToAny branch: it= will be set to void.class + PropertyData inferredData =3D new PropertyInferredData( property, "unsu= pported", mappings.getReflectionManager() ); + //override the table + for (Ejb3Column column : inverseJoinColumns) { + column.setTable( collValue.getCollectionTable() ); + } + Any any =3D BinderHelper.buildAnyValue( anyAnn.metaDef(), inverseJoinCo= lumns, anyAnn.metaColumn(), + inferredData, cascadeDeleteEnabled, Nullability.NO_CONSTRAINT, + propertyHolder, new EntityBinder(), true, mappings ); + collValue.setElement( any ); + } + else { + XClass elementClass; + AnnotatedClassType classType; +// Map columnOverrides =3D PropertyH= olderBuilder.buildColumnOverride( +// property, StringHelper.qualify( collValue.getRole(), "element" ) +// ); + //FIXME the "element" is lost + PropertyHolder holder =3D null; + if ( BinderHelper.PRIMITIVE_NAMES.contains( collType.getName() ) ) { + classType =3D AnnotatedClassType.NONE; + elementClass =3D null; + } + else { + elementClass =3D collType; + classType =3D mappings.getClassType( elementClass ); + + holder =3D PropertyHolderBuilder.buildPropertyHolder( + collValue, + collValue.getRole(), // + ".element", + elementClass, + property, parentPropertyHolder, mappings + ); + //force in case of attribute override + boolean attributeOverride =3D property.isAnnotationPresent( AttributeO= verride.class ) + || property.isAnnotationPresent( AttributeOverrides.class ); + if ( isEmbedded || attributeOverride ) { + classType =3D AnnotatedClassType.EMBEDDABLE; + } + } + + if ( AnnotatedClassType.EMBEDDABLE.equals( classType ) ) { + EntityBinder entityBinder =3D new EntityBinder(); + PersistentClass owner =3D collValue.getOwner(); + boolean isPropertyAnnotated; + //FIXME support @Access for collection of elements + //String accessType =3D access !=3D null ? access.value() : null; + if ( owner.getIdentifierProperty() !=3D null ) { + isPropertyAnnotated =3D owner.getIdentifierProperty().getPropertyAcce= ssorName().equals( "property" ); + } + else if ( owner.getIdentifierMapper() !=3D null && owner.getIdentifier= Mapper().getPropertySpan() > 0 ) { + Property prop =3D (Property) owner.getIdentifierMapper().getPropertyI= terator().next(); + isPropertyAnnotated =3D prop.getPropertyAccessorName().equals( "prope= rty" ); + } + else { + throw new AssertionFailure( "Unable to guess collection property acce= ssor name" ); + } + + //boolean propertyAccess =3D embeddable =3D=3D null || AccessType.PROP= ERTY.equals( embeddable.access() ); + PropertyData inferredData =3D new PropertyPreloadedData( "property", "= element", elementClass ); + //TODO be smart with isNullable + Component component =3D AnnotationBinder.fillComponent( + holder, inferredData, isPropertyAnnotated, isPropertyAnnotated ? "pr= operty" : "field", true, + entityBinder, false, false, + true, mappings + ); + + collValue.setElement( component ); + + if ( StringHelper.isNotEmpty( hqlOrderBy ) ) { + String path =3D collValue.getOwnerEntityName() + "." + joinColumns[0]= .getPropertyName(); + String orderBy =3D buildOrderByClauseFromHql( hqlOrderBy, component, = path ); + if ( orderBy !=3D null ) { + collValue.setOrderBy( orderBy ); + } + } + } + else { + SimpleValueBinder elementBinder =3D new SimpleValueBinder(); + elementBinder.setMappings( mappings ); + elementBinder.setReturnedClassName( collType.getName() ); + if ( elementColumns =3D=3D null || elementColumns.length =3D=3D 0 ) { + elementColumns =3D new Ejb3Column[1]; + Ejb3Column column =3D new Ejb3Column(); + column.setImplicit( false ); + //not following the spec but more clean + column.setNullable( true ); + column.setLength( Ejb3Column.DEFAULT_COLUMN_LENGTH ); + column.setLogicalColumnName( Collection.DEFAULT_ELEMENT_COLUMN_NAME ); + //TODO create an EMPTY_JOINS collection + column.setJoins( new HashMap() ); + column.setMappings( mappings ); + column.bind(); + elementColumns[0] =3D column; + } + //override the table + for (Ejb3Column column : elementColumns) { + column.setTable( collValue.getCollectionTable() ); + } + elementBinder.setColumns( elementColumns ); + elementBinder.setType( property, elementClass ); + collValue.setElement( elementBinder.make() ); + } + } + + checkFilterConditions( collValue ); + + //FIXME: do optional =3D false + if ( isCollectionOfEntities ) { + bindManytoManyInverseFk( collectionEntity, inverseJoinColumns, element,= unique, mappings ); + } + + } + + private static void checkFilterConditions(Collection collValue) { + //for now it can't happen, but sometime soon... + if ( ( collValue.getFilterMap().size() !=3D 0 || StringHelper.isNotEmpty= ( collValue.getWhere() ) ) && + collValue.getFetchMode() =3D=3D FetchMode.JOIN && + !( collValue.getElement() instanceof SimpleValue ) && //SimpleValue (C= ollectionOfElements) are always SELECT but it does not matter + collValue.getElement().getFetchMode() !=3D FetchMode.JOIN ) { + throw new MappingException( + "@ManyToMany or @CollectionOfElements defining filter or where withou= t join fetching " + + "not valid within collection using join fetching[" + collValue.ge= tRole() + "]" + ); + } + } + + private static void bindCollectionSecondPass( + Collection collValue, PersistentClass collectionEntity, Ejb3JoinColumn[= ] joinColumns, + boolean cascadeDeleteEnabled, XProperty property, + ExtendedMappings mappings + ) { + BinderHelper.createSyntheticPropertyReference( + joinColumns, collValue.getOwner(), collectionEntity, collValue, false,= mappings + ); + SimpleValue key =3D buildCollectionKey( collValue, joinColumns, cascadeD= eleteEnabled, property, mappings ); + TableBinder.bindFk( collValue.getOwner(), collectionEntity, joinColumns,= key, false, mappings ); + } + + public void setCascadeDeleteEnabled(boolean onDeleteCascade) { + this.cascadeDeleteEnabled =3D onDeleteCascade; + } + + private String safeCollectionRole() { + if ( propertyHolder !=3D null ) { + return propertyHolder.getEntityName() + "." + propertyName; + } + else { + return ""; + } + } + + + /** + * bind the inverse FK of a ManyToMany + * If we are in a mappedBy case, read the columns from the associated + * colletion element + * Otherwise delegates to the usual algorithm + */ + public static void bindManytoManyInverseFk( + PersistentClass referencedEntity, Ejb3JoinColumn[] columns, SimpleValue= value, boolean unique, + ExtendedMappings mappings + ) { + final String mappedBy =3D columns[0].getMappedBy(); + if ( StringHelper.isNotEmpty( mappedBy ) ) { + final Property property =3D referencedEntity.getRecursiveProperty( mapp= edBy ); + Iterator mappedByColumns; + if ( property.getValue() instanceof Collection ) { + mappedByColumns =3D ( (Collection) property.getValue() ).getKey().getC= olumnIterator(); + } + else { + //find the appropriate reference key, can be in a join + Iterator joinsIt =3D referencedEntity.getJoinIterator(); + KeyValue key =3D null; + while ( joinsIt.hasNext() ) { + Join join =3D (Join) joinsIt.next(); + if ( join.containsProperty( property ) ) { + key =3D join.getKey(); + break; + } + } + if ( key =3D=3D null ) key =3D property.getPersistentClass().getIdenti= fier(); + mappedByColumns =3D key.getColumnIterator(); + } + while ( mappedByColumns.hasNext() ) { + Column column =3D (Column) mappedByColumns.next(); + columns[0].linkValueUsingAColumnCopy( column, value ); + } + String referencedPropertyName =3D + mappings.getPropertyReferencedAssociation( + "inverse__" + referencedEntity.getEntityName(), mappedBy + ); + if ( referencedPropertyName !=3D null ) { + //TODO always a many to one? + ( (ManyToOne) value ).setReferencedPropertyName( referencedPropertyNam= e ); + mappings.addUniquePropertyReference( referencedEntity.getEntityName(),= referencedPropertyName ); + } + value.createForeignKey(); + } + else { + BinderHelper.createSyntheticPropertyReference( columns, referencedEntit= y, null, value, true, mappings ); + TableBinder.bindFk( referencedEntity, null, columns, value, unique, map= pings ); + } + } + + public void setFkJoinColumns(Ejb3JoinColumn[] ejb3JoinColumns) { + this.fkJoinColumns =3D ejb3JoinColumns; + } + + public void setExplicitAssociationTable(boolean explicitAssocTable) { + this.isExplicitAssociationTable =3D explicitAssocTable; + } + + public void setElementColumns(Ejb3Column[] elementColumns) { + this.elementColumns =3D elementColumns; + } + + public void setEmbedded(boolean annotationPresent) { + this.isEmbedded =3D annotationPresent; + } + + public void setProperty(XProperty property) { + this.property =3D property; + } + + public void setIgnoreNotFound(boolean ignoreNotFound) { + this.ignoreNotFound =3D ignoreNotFound; + } + + public void setMapKeyColumns(Ejb3Column[] mapKeyColumns) { + this.mapKeyColumns =3D mapKeyColumns; + } + + public void setMapKeyManyToManyColumns(Ejb3JoinColumn[] mapJoinColumns) { + this.mapKeyManyToManyColumns =3D mapJoinColumns; + } + + public void setLocalGenerators(HashMap localGenerato= rs) { + this.localGenerators =3D localGenerators; + } +} \ No newline at end of file Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/EntityBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/EntityBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/EntityBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,808 @@ +//$Id: EntityBinder.java 14741 2008-06-05 11:25:56Z hardy.ferentschik $ +package org.hibernate.cfg.annotations; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.SecondaryTable; +import javax.persistence.SecondaryTables; +import javax.persistence.UniqueConstraint; + +import org.hibernate.AnnotationException; +import org.hibernate.AssertionFailure; +import org.hibernate.EntityMode; +import org.hibernate.MappingException; +import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.BatchSize; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; +import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.ForceDiscriminator; +import org.hibernate.annotations.Immutable; +import org.hibernate.annotations.Loader; +import org.hibernate.annotations.OptimisticLockType; +import org.hibernate.annotations.Persister; +import org.hibernate.annotations.PolymorphismType; +import org.hibernate.annotations.Proxy; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLDeleteAll; +import org.hibernate.annotations.SQLInsert; +import org.hibernate.annotations.SQLUpdate; +import org.hibernate.annotations.Tables; +import org.hibernate.annotations.Tuplizer; +import org.hibernate.annotations.Tuplizers; +import org.hibernate.annotations.Where; +import org.hibernate.annotations.common.reflection.XAnnotatedElement; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.cfg.AnnotationBinder; +import org.hibernate.cfg.BinderHelper; +import org.hibernate.cfg.Ejb3JoinColumn; +import org.hibernate.cfg.ExtendedMappings; +import org.hibernate.cfg.InheritanceState; +import org.hibernate.cfg.PropertyHolder; +import org.hibernate.engine.ExecuteUpdateResultCheckStyle; +import org.hibernate.engine.FilterDefinition; +import org.hibernate.engine.Versioning; +import org.hibernate.mapping.DependantValue; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.RootClass; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.Table; +import org.hibernate.mapping.TableOwner; +import org.hibernate.mapping.Value; +import org.hibernate.util.ReflectHelper; +import org.hibernate.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Stateful holder and processor for binding Entity information + * + * @author Emmanuel Bernard + */ +public class EntityBinder { + private String name; + private XClass annotatedClass; + private PersistentClass persistentClass; + private ExtendedMappings mappings; + private Logger log =3D LoggerFactory.getLogger( EntityBinder.class ); + private String discriminatorValue =3D ""; + private boolean isPropertyAnnotated =3D false; + private boolean dynamicInsert; + private boolean dynamicUpdate; + private boolean explicitHibernateEntityAnnotation; + private OptimisticLockType optimisticLockType; + private PolymorphismType polymorphismType; + private boolean selectBeforeUpdate; + private int batchSize; + private boolean lazy; + private XClass proxyClass; + private String where; + private java.util.Map secondaryTables =3D new HashMap(); + private java.util.Map secondaryTableJoins =3D new HashMap= (); + private String cacheConcurrentStrategy; + private String cacheRegion; + private java.util.Map filters =3D new HashMap(); + private InheritanceState inheritanceState; + private boolean ignoreIdAnnotations; + private boolean cacheLazyProperty; + private String propertyAccessor; + + public boolean isPropertyAnnotated() { + return isPropertyAnnotated; + } + + /** + * Use as a fake one for Collection of elements + */ + public EntityBinder() { + } + + public EntityBinder( + Entity ejb3Ann, org.hibernate.annotations.Entity hibAnn, + XClass annotatedClass, PersistentClass persistentClass, + ExtendedMappings mappings + ) { + this.mappings =3D mappings; + this.persistentClass =3D persistentClass; + this.annotatedClass =3D annotatedClass; + bindEjb3Annotation( ejb3Ann ); + bindHibernateAnnotation( hibAnn ); + } + + private void bindHibernateAnnotation(org.hibernate.annotations.Entity hib= Ann) { + if ( hibAnn !=3D null ) { + dynamicInsert =3D hibAnn.dynamicInsert(); + dynamicUpdate =3D hibAnn.dynamicUpdate(); + optimisticLockType =3D hibAnn.optimisticLock(); + selectBeforeUpdate =3D hibAnn.selectBeforeUpdate(); + polymorphismType =3D hibAnn.polymorphism(); + explicitHibernateEntityAnnotation =3D true; + //persister handled in bind + } + else { + //default values when the annotation is not there + dynamicInsert =3D false; + dynamicUpdate =3D false; + optimisticLockType =3D OptimisticLockType.VERSION; + polymorphismType =3D PolymorphismType.IMPLICIT; + selectBeforeUpdate =3D false; + } + } + + private void bindEjb3Annotation(Entity ejb3Ann) { + if ( ejb3Ann =3D=3D null ) throw new AssertionFailure( "@Entity should a= lways be not null" ); + if ( BinderHelper.isDefault( ejb3Ann.name() ) ) { + name =3D StringHelper.unqualify( annotatedClass.getName() ); + } + else { + name =3D ejb3Ann.name(); + } + } + + public void setDiscriminatorValue(String discriminatorValue) { + this.discriminatorValue =3D discriminatorValue; + } + + public void bindEntity() { + persistentClass.setAbstract( annotatedClass.isAbstract() ); + persistentClass.setClassName( annotatedClass.getName() ); + persistentClass.setNodeName( name ); + //persistentClass.setDynamic(false); //no longer needed with the Entity = name refactoring? + persistentClass.setEntityName( annotatedClass.getName() ); + bindDiscriminatorValue(); + + persistentClass.setLazy( lazy ); + if ( proxyClass !=3D null ) { + persistentClass.setProxyInterfaceName( proxyClass.getName() ); + } + persistentClass.setDynamicInsert( dynamicInsert ); + persistentClass.setDynamicUpdate( dynamicUpdate ); + + if ( persistentClass instanceof RootClass ) { + RootClass rootClass =3D (RootClass) persistentClass; + boolean mutable =3D true; + //priority on @Immutable, then @Entity.mutable() + if ( annotatedClass.isAnnotationPresent( Immutable.class ) ) { + mutable =3D false; + } + else { + org.hibernate.annotations.Entity entityAnn =3D + annotatedClass.getAnnotation( org.hibernate.annotations.Entity.class= ); + if ( entityAnn !=3D null ) { + mutable =3D entityAnn.mutable(); + } + } + rootClass.setMutable( mutable ); + rootClass.setExplicitPolymorphism( isExplicitPolymorphism( polymorphism= Type ) ); + if ( StringHelper.isNotEmpty( where ) ) rootClass.setWhere( where ); + if ( cacheConcurrentStrategy !=3D null ) { + rootClass.setCacheConcurrencyStrategy( cacheConcurrentStrategy ); + rootClass.setCacheRegionName( cacheRegion ); + rootClass.setLazyPropertiesCacheable( cacheLazyProperty ); + } + rootClass.setForceDiscriminator( annotatedClass.isAnnotationPresent( Fo= rceDiscriminator.class ) ); + } + else { + if ( explicitHibernateEntityAnnotation ) { + log.warn( "@org.hibernate.annotations.Entity used on a non root entity= : ignored for {}", + annotatedClass.getName() ); + } + if ( annotatedClass.isAnnotationPresent( Immutable.class ) ) { + log.warn( "@Immutable used on a non root entity: ignored for {}", + annotatedClass.getName() ); + } + } + persistentClass.setOptimisticLockMode( getVersioning( optimisticLockType= ) ); + persistentClass.setSelectBeforeUpdate( selectBeforeUpdate ); + + //set persister if needed + //@Persister has precedence over @Entity.persister + Persister persisterAnn =3D annotatedClass.getAnnotation( Persister.class= ); + Class persister =3D null; + if ( persisterAnn !=3D null ) { + persister =3D persisterAnn.impl(); + } + else { + org.hibernate.annotations.Entity entityAnn =3D annotatedClass.getAnnota= tion( org.hibernate.annotations.Entity.class ); + if ( entityAnn !=3D null && !BinderHelper.isDefault( entityAnn.persiste= r() ) ) { + try { + persister =3D ReflectHelper.classForName( entityAnn.persister() ); + } + catch (ClassNotFoundException cnfe) { + throw new AnnotationException( "Could not find persister class: " + p= ersister ); + } + } + } + if ( persister !=3D null ) persistentClass.setEntityPersisterClass( pers= ister ); + + persistentClass.setBatchSize( batchSize ); + + //SQL overriding + SQLInsert sqlInsert =3D annotatedClass.getAnnotation( SQLInsert.class ); + SQLUpdate sqlUpdate =3D annotatedClass.getAnnotation( SQLUpdate.class ); + SQLDelete sqlDelete =3D annotatedClass.getAnnotation( SQLDelete.class ); + SQLDeleteAll sqlDeleteAll =3D annotatedClass.getAnnotation( SQLDeleteAll= .class ); + Loader loader =3D annotatedClass.getAnnotation( Loader.class ); + if ( sqlInsert !=3D null ) { + persistentClass.setCustomSQLInsert( sqlInsert.sql().trim(), sqlInsert.c= allable(), + ExecuteUpdateResultCheckStyle.parse( sqlInsert.check().toString().toL= owerCase() ) + ); + + } + if ( sqlUpdate !=3D null ) { + persistentClass.setCustomSQLUpdate( sqlUpdate.sql(), sqlUpdate.callable= (), + ExecuteUpdateResultCheckStyle.parse( sqlUpdate.check().toString().toL= owerCase() ) + ); + } + if ( sqlDelete !=3D null ) { + persistentClass.setCustomSQLDelete( sqlDelete.sql(), sqlDelete.callable= (), + ExecuteUpdateResultCheckStyle.parse( sqlDelete.check().toString().toL= owerCase() ) + ); + } + if ( sqlDeleteAll !=3D null ) { + persistentClass.setCustomSQLDelete( sqlDeleteAll.sql(), sqlDeleteAll.ca= llable(), + ExecuteUpdateResultCheckStyle.parse( sqlDeleteAll.check().toString().= toLowerCase() ) + ); + } + if ( loader !=3D null ) { + persistentClass.setLoaderName( loader.namedQuery() ); + } + + //tuplizers + if ( annotatedClass.isAnnotationPresent( Tuplizers.class ) ) { + for (Tuplizer tuplizer : annotatedClass.getAnnotation( Tuplizers.class = ).value()) { + EntityMode mode =3D EntityMode.parse( tuplizer.entityMode() ); + persistentClass.addTuplizer( mode, tuplizer.impl().getName() ); + } + } + if ( annotatedClass.isAnnotationPresent( Tuplizer.class ) ) { + Tuplizer tuplizer =3D annotatedClass.getAnnotation( Tuplizer.class ); + EntityMode mode =3D EntityMode.parse( tuplizer.entityMode() ); + persistentClass.addTuplizer( mode, tuplizer.impl().getName() ); + } + + if ( !inheritanceState.hasParents ) { + Iterator> iter =3D filters.entrySet().iterato= r(); + while ( iter.hasNext() ) { + Map.Entry filter =3D iter.next(); + String filterName =3D filter.getKey(); + String cond =3D filter.getValue(); + if ( BinderHelper.isDefault( cond ) ) { + FilterDefinition definition =3D mappings.getFilterDefinition( filterN= ame ); + cond =3D definition =3D=3D null ? null : definition.getDefaultFilterC= ondition(); + if ( StringHelper.isEmpty( cond ) ) { + throw new AnnotationException( + "no filter condition found for filter " + filterName + " in " + th= is.name + ); + } + } + persistentClass.addFilter( filterName, cond ); + } + } + else { + if ( filters.size() > 0 ) { + log.warn( "@Filter not allowed on subclasses (ignored): {}", persisten= tClass.getEntityName() ); + } + } + log.debug( "Import with entity name {}", name ); + try { + mappings.addImport( persistentClass.getEntityName(), name ); + String entityName =3D persistentClass.getEntityName(); + if ( !entityName.equals( name ) ) { + mappings.addImport( entityName, entityName ); + } + } + catch (MappingException me) { + throw new AnnotationException( "Use of the same entity name twice: " + = name, me ); + } + } + + public void bindDiscriminatorValue() { + if ( StringHelper.isEmpty( discriminatorValue ) ) { + Value discriminator =3D persistentClass.getDiscriminator(); + if ( discriminator =3D=3D null ) { + persistentClass.setDiscriminatorValue( name ); + } + else if ( "character".equals( discriminator.getType().getName() ) ) { + throw new AnnotationException( + "Using default @DiscriminatorValue for a discriminator of type CHAR = is not safe" + ); + } + else if ( "integer".equals( discriminator.getType().getName() ) ) { + persistentClass.setDiscriminatorValue( String.valueOf( name.hashCode()= ) ); + } + else { + persistentClass.setDiscriminatorValue( name ); //Spec compliant + } + } + else { + //persistentClass.getDiscriminator() + persistentClass.setDiscriminatorValue( discriminatorValue ); + } + } + + int getVersioning(OptimisticLockType type) { + switch ( type ) { + case VERSION: + return Versioning.OPTIMISTIC_LOCK_VERSION; + case NONE: + return Versioning.OPTIMISTIC_LOCK_NONE; + case DIRTY: + return Versioning.OPTIMISTIC_LOCK_DIRTY; + case ALL: + return Versioning.OPTIMISTIC_LOCK_ALL; + default: + throw new AssertionFailure( "optimistic locking not supported: " + typ= e ); + } + } + + private boolean isExplicitPolymorphism(PolymorphismType type) { + switch ( type ) { + case IMPLICIT: + return false; + case EXPLICIT: + return true; + default: + throw new AssertionFailure( "Unknown polymorphism type: " + type ); + } + } + + public void setBatchSize(BatchSize sizeAnn) { + if ( sizeAnn !=3D null ) { + batchSize =3D sizeAnn.size(); + } + else { + batchSize =3D -1; + } + } + + public void setProxy(Proxy proxy) { + if ( proxy !=3D null ) { + lazy =3D proxy.lazy(); + if ( !lazy ) { + proxyClass =3D null; + } + else { + if ( AnnotationBinder.isDefault( + mappings.getReflectionManager().toXClass( proxy.proxyClass() ), mapp= ings + ) ) { + proxyClass =3D annotatedClass; + } + else { + proxyClass =3D mappings.getReflectionManager().toXClass( proxy.proxyC= lass() ); + } + } + } + else { + lazy =3D true; //needed to allow association lazy loading. + proxyClass =3D annotatedClass; + } + } + + public void setWhere(Where whereAnn) { + if ( whereAnn !=3D null ) { + where =3D whereAnn.clause(); + } + } + + private String getClassTableName(String tableName) { + if ( StringHelper.isEmpty( tableName ) ) { + return mappings.getNamingStrategy().classToTableName( name ); + } + else { + return mappings.getNamingStrategy().tableName( tableName ); + } + } + + public void bindTable( + String schema, String catalog, + String tableName, List uniqueConstraints, + String constraints, Table denormalizedSuperclassTable + ) { + String logicalName =3D StringHelper.isNotEmpty( tableName ) ? + tableName : + StringHelper.unqualify( name ); + Table table =3D TableBinder.fillTable( + schema, catalog, + getClassTableName( tableName ), + logicalName, + persistentClass.isAbstract(), uniqueConstraints, constraints, + denormalizedSuperclassTable, mappings + ); + + if ( persistentClass instanceof TableOwner ) { + log.info( "Bind entity {} on table {}", persistentClass.getEntityName()= , table.getName() ); + ( (TableOwner) persistentClass ).setTable( table ); + } + else { + throw new AssertionFailure( "binding a table for a subclass" ); + } + } + + public void finalSecondaryTableBinding(PropertyHolder propertyHolder) { + /* + * Those operations has to be done after the id definition of the persis= tence class. + * ie after the properties parsing + */ + Iterator joins =3D secondaryTables.values().iterator(); + Iterator joinColumns =3D secondaryTableJoins.values().iterator(); + + while ( joins.hasNext() ) { + Object uncastedColumn =3D joinColumns.next(); + Join join =3D (Join) joins.next(); + createPrimaryColumnsToSecondaryTable( uncastedColumn, propertyHolder, j= oin ); + } + mappings.addJoins( persistentClass, secondaryTables ); + } + + private void createPrimaryColumnsToSecondaryTable(Object uncastedColumn, = PropertyHolder propertyHolder, Join join) { + Ejb3JoinColumn[] ejb3JoinColumns; + PrimaryKeyJoinColumn[] pkColumnsAnn =3D null; + JoinColumn[] joinColumnsAnn =3D null; + if ( uncastedColumn instanceof PrimaryKeyJoinColumn[] ) { + pkColumnsAnn =3D (PrimaryKeyJoinColumn[]) uncastedColumn; + } + if ( uncastedColumn instanceof JoinColumn[] ) { + joinColumnsAnn =3D (JoinColumn[]) uncastedColumn; + } + if ( pkColumnsAnn =3D=3D null && joinColumnsAnn =3D=3D null ) { + ejb3JoinColumns =3D new Ejb3JoinColumn[1]; + ejb3JoinColumns[0] =3D Ejb3JoinColumn.buildJoinColumn( + null, + null, + persistentClass.getIdentifier(), + secondaryTables, + propertyHolder, mappings + ); + } + else { + int nbrOfJoinColumns =3D pkColumnsAnn !=3D null ? + pkColumnsAnn.length : + joinColumnsAnn.length; + if ( nbrOfJoinColumns =3D=3D 0 ) { + ejb3JoinColumns =3D new Ejb3JoinColumn[1]; + ejb3JoinColumns[0] =3D Ejb3JoinColumn.buildJoinColumn( + null, + null, + persistentClass.getIdentifier(), + secondaryTables, + propertyHolder, mappings + ); + } + else { + ejb3JoinColumns =3D new Ejb3JoinColumn[nbrOfJoinColumns]; + if ( pkColumnsAnn !=3D null ) { + for (int colIndex =3D 0; colIndex < nbrOfJoinColumns; colIndex++) { + ejb3JoinColumns[colIndex] =3D Ejb3JoinColumn.buildJoinColumn( + pkColumnsAnn[colIndex], + null, + persistentClass.getIdentifier(), + secondaryTables, + propertyHolder, mappings + ); + } + } + else { + for (int colIndex =3D 0; colIndex < nbrOfJoinColumns; colIndex++) { + ejb3JoinColumns[colIndex] =3D Ejb3JoinColumn.buildJoinColumn( + null, + joinColumnsAnn[colIndex], + persistentClass.getIdentifier(), + secondaryTables, + propertyHolder, mappings + ); + } + } + } + } + + for (Ejb3JoinColumn joinColumn : ejb3JoinColumns) { + joinColumn.forceNotNull(); + } + bindJoinToPersistentClass( join, ejb3JoinColumns ); + } + + private void bindJoinToPersistentClass( + Join join, Ejb3JoinColumn[] ejb3JoinColumns + ) { + SimpleValue key =3D new DependantValue( join.getTable(), persistentClass= .getIdentifier() ); + join.setKey( key ); + setFKNameIfDefined( join ); + key.setCascadeDeleteEnabled( false ); + TableBinder.bindFk( persistentClass, null, ejb3JoinColumns, key, false, = mappings ); + join.createPrimaryKey(); + join.createForeignKey(); + persistentClass.addJoin( join ); + } + + private void setFKNameIfDefined(Join join) { + org.hibernate.annotations.Table matchingTable =3D findMatchingCompliment= TableAnnotation( join ); + if ( matchingTable !=3D null && !BinderHelper.isDefault( matchingTable.f= oreignKey().name() ) ) { + ( (SimpleValue) join.getKey() ).setForeignKeyName( matchingTable.foreig= nKey().name() ); + } + } + + private org.hibernate.annotations.Table findMatchingComplimentTableAnnota= tion(Join join) { + String tableName =3D join.getTable().getQuotedName(); + org.hibernate.annotations.Table table =3D annotatedClass.getAnnotation( = org.hibernate.annotations.Table.class ); + org.hibernate.annotations.Table matchingTable =3D null; + if ( table !=3D null && tableName.equals( table.appliesTo() ) ) { + matchingTable =3D table; + } + else { + Tables tables =3D annotatedClass.getAnnotation( Tables.class ); + if ( tables !=3D null ) { + for (org.hibernate.annotations.Table current : tables.value()) { + if ( tableName.equals( current.appliesTo() ) ) { + matchingTable =3D current; + break; + } + } + } + } + return matchingTable; + } + + public void firstLevelSecondaryTablesBinding( + SecondaryTable secTable, SecondaryTables secTables + ) { + if ( secTables !=3D null ) { + //loop through it + for (SecondaryTable tab : secTables.value()) { + addJoin( tab, null, null, false ); + } + } + else { + if ( secTable !=3D null ) addJoin( secTable, null, null, false ); + } + } + + //Used for @*ToMany @JoinTable + public Join addJoin(JoinTable joinTable, PropertyHolder holder, boolean n= oDelayInPkColumnCreation) { + return addJoin( null, joinTable, holder, noDelayInPkColumnCreation ); + } + + /** + * A non null propertyHolder means than we process the Pk creation withou= t delay + */ + private Join addJoin( + SecondaryTable secondaryTable, JoinTable joinTable, PropertyHolder prop= ertyHolder, + boolean noDelayInPkColumnCreation + ) { + Join join =3D new Join(); + join.setPersistentClass( persistentClass ); + String schema; + String catalog; + String table; + String realTable; + UniqueConstraint[] uniqueConstraintsAnn; + if ( secondaryTable !=3D null ) { + schema =3D secondaryTable.schema(); + catalog =3D secondaryTable.catalog(); + table =3D secondaryTable.name(); + realTable =3D mappings.getNamingStrategy().tableName( table ); //always= an explicit table name + uniqueConstraintsAnn =3D secondaryTable.uniqueConstraints(); + } + else if ( joinTable !=3D null ) { + schema =3D joinTable.schema(); + catalog =3D joinTable.catalog(); + table =3D joinTable.name(); + realTable =3D mappings.getNamingStrategy().tableName( table ); //always= an explicit table name + uniqueConstraintsAnn =3D joinTable.uniqueConstraints(); + } + else { + throw new AssertionFailure( "Both JoinTable and SecondaryTable are null= " ); + } + List uniqueConstraints =3D new ArrayList( uniqueConstraintsAnn =3D=3D nu= ll ? + 0 : + uniqueConstraintsAnn.length ); + if ( uniqueConstraintsAnn !=3D null && uniqueConstraintsAnn.length !=3D = 0 ) { + for (UniqueConstraint uc : uniqueConstraintsAnn) { + uniqueConstraints.add( uc.columnNames() ); + } + } + Table tableMapping =3D TableBinder.fillTable( + schema, + catalog, + realTable, + table, false, uniqueConstraints, null, null, mappings + ); + //no check constraints available on joins + join.setTable( tableMapping ); + + //somehow keep joins() for later. + //Has to do the work later because it needs persistentClass id! + Object joinColumns =3D null; + //get the appropriate pk columns + if ( secondaryTable !=3D null ) { + joinColumns =3D secondaryTable.pkJoinColumns(); + } + else if ( joinTable !=3D null ) { + joinColumns =3D joinTable.joinColumns(); + } + log.info( + "Adding secondary table to entity {} -> {}", persistentClass.getEntity= Name(), join.getTable().getName() + ); + + org.hibernate.annotations.Table matchingTable =3D findMatchingCompliment= TableAnnotation( join ); + if ( matchingTable !=3D null ) { + join.setSequentialSelect( FetchMode.JOIN !=3D matchingTable.fetch() ); + join.setInverse( matchingTable.inverse() ); + join.setOptional( matchingTable.optional() ); + if ( !BinderHelper.isDefault( matchingTable.sqlInsert().sql() ) ) { + join.setCustomSQLInsert( matchingTable.sqlInsert().sql().trim(), + matchingTable.sqlInsert().callable(), + ExecuteUpdateResultCheckStyle.parse( matchingTable.sqlInsert().check= ().toString().toLowerCase() ) + ); + } + if ( !BinderHelper.isDefault( matchingTable.sqlUpdate().sql() ) ) { + join.setCustomSQLUpdate( matchingTable.sqlUpdate().sql().trim(), + matchingTable.sqlUpdate().callable(), + ExecuteUpdateResultCheckStyle.parse( matchingTable.sqlUpdate().check= ().toString().toLowerCase() ) + ); + } + if ( !BinderHelper.isDefault( matchingTable.sqlDelete().sql() ) ) { + join.setCustomSQLDelete( matchingTable.sqlDelete().sql().trim(), + matchingTable.sqlDelete().callable(), + ExecuteUpdateResultCheckStyle.parse( matchingTable.sqlDelete().check= ().toString().toLowerCase() ) + ); + } + } + else { + //default + join.setSequentialSelect( false ); + join.setInverse( false ); + join.setOptional( true ); //perhaps not quite per-spec, but a Good Thin= g anyway + } + + if ( noDelayInPkColumnCreation ) { + createPrimaryColumnsToSecondaryTable( joinColumns, propertyHolder, join= ); + } + else { + secondaryTables.put( realTable, join ); + secondaryTableJoins.put( realTable, joinColumns ); + } + return join; + } + + public java.util.Map getSecondaryTables() { + return secondaryTables; + } + + public void setCache(Cache cacheAnn) { + if ( cacheAnn !=3D null ) { + cacheRegion =3D BinderHelper.isDefault( cacheAnn.region() ) ? + null : + cacheAnn.region(); + cacheConcurrentStrategy =3D getCacheConcurrencyStrategy( cacheAnn.usage= () ); + if ( "all".equalsIgnoreCase( cacheAnn.include() ) ) { + cacheLazyProperty =3D true; + } + else if ( "non-lazy".equalsIgnoreCase( cacheAnn.include() ) ) { + cacheLazyProperty =3D false; + } + else { + throw new AnnotationException( "Unknown lazy property annotations: " += cacheAnn.include() ); + } + } + else { + cacheConcurrentStrategy =3D null; + cacheRegion =3D null; + cacheLazyProperty =3D true; + } + } + + public static String getCacheConcurrencyStrategy(CacheConcurrencyStrategy= strategy) { + switch ( strategy ) { + case NONE: + return null; + case READ_ONLY: + return org.hibernate.cache.access.AccessType.READ_ONLY.getName(); + case READ_WRITE: + return org.hibernate.cache.access.AccessType.READ_WRITE.getName(); + case NONSTRICT_READ_WRITE: + return org.hibernate.cache.access.AccessType.NONSTRICT_READ_WRITE.getN= ame(); + case TRANSACTIONAL: + return org.hibernate.cache.access.AccessType.TRANSACTIONAL.getName(); + default: + throw new AssertionFailure( "CacheConcurrencyStrategy unknown: " + str= ategy ); + } + } + + public void addFilter(String name, String condition) { + filters.put( name, condition ); + } + + public void setInheritanceState(InheritanceState inheritanceState) { + this.inheritanceState =3D inheritanceState; + } + + public boolean isIgnoreIdAnnotations() { + return ignoreIdAnnotations; + } + + public void setIgnoreIdAnnotations(boolean ignoreIdAnnotations) { + this.ignoreIdAnnotations =3D ignoreIdAnnotations; + } + + public void processComplementaryTableDefinitions(org.hibernate.annotation= s.Table table) { + //comment and index are processed here + if ( table =3D=3D null ) return; + String appliedTable =3D table.appliesTo(); + Iterator tables =3D persistentClass.getTableClosureIterator(); + Table hibTable =3D null; + while ( tables.hasNext() ) { + Table pcTable =3D (Table) tables.next(); + if ( pcTable.getQuotedName().equals( appliedTable ) ) { + //we are in the correct table to find columns + hibTable =3D pcTable; + break; + } + hibTable =3D null; + } + if ( hibTable =3D=3D null ) { + //maybe a join/secondary table + for ( Join join : secondaryTables.values() ) { + if ( join.getTable().getQuotedName().equals( appliedTable ) ) { + hibTable =3D join.getTable(); + break; + } + } + } + if ( hibTable =3D=3D null ) { + throw new AnnotationException( + "@org.hibernate.annotations.Table references an unknown table: " + ap= pliedTable + ); + } + if ( !BinderHelper.isDefault( table.comment() ) ) hibTable.setComment( t= able.comment() ); + TableBinder.addIndexes( hibTable, table.indexes(), mappings ); + } + + public void processComplementaryTableDefinitions(Tables tables) { + if ( tables =3D=3D null ) return; + for (org.hibernate.annotations.Table table : tables.value()) { + processComplementaryTableDefinitions( table ); + } + } + + public void setPropertyAnnotated(boolean propertyAnnotated) { + this.isPropertyAnnotated =3D propertyAnnotated; + } + + public String getPropertyAccessor() { + return propertyAccessor; + } + + public void setPropertyAccessor(String propertyAccessor) { + this.propertyAccessor =3D propertyAccessor; + } + + public boolean isPropertyAnnotated(XAnnotatedElement element) { + AccessType access =3D element.getAnnotation( AccessType.class ); + if ( access =3D=3D null ) return isPropertyAnnotated; + String propertyAccessor =3D access.value(); + if ( "property".equals( propertyAccessor ) ) { + return Boolean.TRUE; + } + else if ( "field".equals( propertyAccessor ) ) { + return Boolean.FALSE; + } + else { + return isPropertyAnnotated; + } + } + + public String getPropertyAccessor(XAnnotatedElement element) { + AccessType access =3D element.getAnnotation( AccessType.class ); + if ( access =3D=3D null ) return propertyAccessor; + return access.value(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/IdBagBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/IdBagBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/IdBagBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,89 @@ +//$Id: IdBagBinder.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.cfg.annotations; + +import java.util.Collections; +import java.util.Map; + +import org.hibernate.AnnotationException; +import org.hibernate.annotations.CollectionId; +import org.hibernate.annotations.Type; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.cfg.BinderHelper; +import org.hibernate.cfg.Ejb3Column; +import org.hibernate.cfg.Ejb3JoinColumn; +import org.hibernate.cfg.ExtendedMappings; +import org.hibernate.cfg.PropertyData; +import org.hibernate.cfg.PropertyInferredData; +import org.hibernate.cfg.WrappedInferredData; +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.IdentifierCollection; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.Table; +import org.hibernate.util.StringHelper; + +/** + * @author Emmanuel Bernard + */ +public class IdBagBinder extends BagBinder { + protected Collection createCollection(PersistentClass persistentClass) { + return new org.hibernate.mapping.IdentifierBag( persistentClass ); + } + + @Override + protected boolean bindStarToManySecondPass( + Map persistentClasses, XClass collType, Ejb3JoinColumn[] fkJoinColumns,= Ejb3JoinColumn[] keyColumns, + Ejb3JoinColumn[] inverseColumns, Ejb3Column[] elementColumns, boolean i= sEmbedded, XProperty property, + boolean unique, TableBinder associationTableBinder, boolean ignoreNotFo= und, ExtendedMappings mappings + ) { + boolean result =3D super.bindStarToManySecondPass( + persistentClasses, collType, fkJoinColumns, keyColumns, inverseColumns= , elementColumns, isEmbedded, + property, unique, associationTableBinder, ignoreNotFound, mappings + ); + CollectionId collectionIdAnn =3D property.getAnnotation( CollectionId.cl= ass ); + if ( collectionIdAnn !=3D null ) { + SimpleValueBinder simpleValue =3D new SimpleValueBinder(); + + PropertyData propertyData =3D new WrappedInferredData( + new PropertyInferredData( property, null, //default access should not= be useful + mappings.getReflectionManager() ), + "id" ); + Ejb3Column[] idColumns =3D Ejb3Column.buildColumnFromAnnotation( + collectionIdAnn.columns(), + null, + Nullability.FORCED_NOT_NULL, + propertyHolder, + propertyData, + Collections.EMPTY_MAP, + mappings + ); + Table table =3D collection.getCollectionTable(); + simpleValue.setTable( table ); + simpleValue.setColumns( idColumns ); + Type typeAnn =3D collectionIdAnn.type(); + if ( typeAnn !=3D null && !BinderHelper.isDefault( typeAnn.type() ) ) { + simpleValue.setExplicitType( typeAnn ); + } + else { + throw new AnnotationException( "@CollectionId is missing type: " + + StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); + } + simpleValue.setMappings( mappings ); + SimpleValue id =3D simpleValue.make(); + ( (IdentifierCollection) collection ).setIdentifier( id ); + String generator =3D collectionIdAnn.generator(); + String generatorType; + if ( "identity".equals( generator ) || "assigned".equals( generator ) + || "sequence".equals( generator ) || "native".equals( generator ) ) { + generatorType =3D generator; + generator =3D ""; + } + else { + generatorType =3D null; + } + BinderHelper.makeIdGenerator( id, generatorType, generator, mappings, l= ocalGenerators ); + } + return result; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/ListBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/ListBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/ListBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,115 @@ +package org.hibernate.cfg.annotations; + +import java.util.Map; + +import org.hibernate.AnnotationException; +import org.hibernate.MappingException; +import org.hibernate.annotations.OrderBy; +import org.hibernate.annotations.Sort; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.annotations.common.util.StringHelper; +import org.hibernate.cfg.CollectionSecondPass; +import org.hibernate.cfg.Ejb3Column; +import org.hibernate.cfg.Ejb3JoinColumn; +import org.hibernate.cfg.ExtendedMappings; +import org.hibernate.cfg.PropertyHolder; +import org.hibernate.cfg.PropertyHolderBuilder; +import org.hibernate.cfg.SecondPass; +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.IndexBackref; +import org.hibernate.mapping.List; +import org.hibernate.mapping.OneToMany; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.SimpleValue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Bind a list to the underlying Hibernate configuration + * + * @author Matthew Inger + * @author Emmanuel Bernard + */ +(a)SuppressWarnings({"unchecked", "serial"}) +public class ListBinder extends CollectionBinder { + private Logger log =3D LoggerFactory.getLogger( ListBinder.class ); + + public ListBinder() { + } + + protected Collection createCollection(PersistentClass persistentClass) { + return new org.hibernate.mapping.List( persistentClass ); + } + + public void setSqlOrderBy(OrderBy orderByAnn) { + if ( orderByAnn !=3D null ) log.warn( "@OrderBy not allowed for a indexe= d collection, annotation ignored." ); + } + + public void setSort(Sort sortAnn) { + if ( sortAnn !=3D null ) log.warn( "@Sort not allowed for a indexed coll= ection, annotation ignored." ); + } + + @Override + public SecondPass getSecondPass( + final Ejb3JoinColumn[] fkJoinColumns, final Ejb3JoinColumn[] keyColumns, + final Ejb3JoinColumn[] inverseColumns, + final Ejb3Column[] elementColumns, + Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToManyColu= mns, final boolean isEmbedded, + final XProperty property, final XClass collType, + final boolean ignoreNotFound, final boolean unique, + final TableBinder assocTableBinder, final ExtendedMappings mappings + ) { + return new CollectionSecondPass( mappings, ListBinder.this.collection ) { + public void secondPass(Map persistentClasses, Map inheritedMetas) + throws MappingException { + bindStarToManySecondPass( + persistentClasses, collType, fkJoinColumns, keyColumns, inverseColum= ns, elementColumns, + isEmbedded, property, unique, assocTableBinder, ignoreNotFound, mapp= ings + ); + bindIndex( mappings ); + } + }; + } + + private void bindIndex(final ExtendedMappings mappings) { + if ( indexColumn.isImplicit() =3D=3D false ) { + PropertyHolder valueHolder =3D PropertyHolderBuilder.buildPropertyHolde= r( + this.collection, + StringHelper.qualify( this.collection.getRole(), "key" ), + (XClass) null, + (XProperty) null, propertyHolder, mappings + ); + List list =3D (List) this.collection; + if ( !list.isOneToMany() ) indexColumn.forceNotNull(); + indexColumn.setPropertyHolder( valueHolder ); + SimpleValueBinder value =3D new SimpleValueBinder(); + value.setColumns( new Ejb3Column[] { indexColumn } ); + value.setExplicitType( "integer" ); + value.setMappings( mappings ); + SimpleValue indexValue =3D value.make(); + indexColumn.linkWithValue( indexValue ); + list.setIndex( indexValue ); + list.setBaseIndex( indexColumn.getBase() ); + if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInver= se() ) { + String entityName =3D ( (OneToMany) list.getElement() ).getReferencedE= ntityName(); + PersistentClass referenced =3D mappings.getClass( entityName ); + IndexBackref ib =3D new IndexBackref(); + ib.setName( '_' + propertyName + "IndexBackref" ); + ib.setUpdateable( false ); + ib.setSelectable( false ); + ib.setCollectionRole( list.getRole() ); + ib.setEntityName( list.getOwner().getEntityName() ); + ib.setValue( list.getIndex() ); + referenced.addProperty( ib ); + } + } + else { + Collection coll =3D this.collection; + throw new AnnotationException( + "List/array has to be annotated with an @IndexColumn: " + + coll.getRole() + ); + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/MapBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/MapBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/MapBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,388 @@ +//$Id: MapBinder.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.cfg.annotations; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Random; +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; + +import org.hibernate.AnnotationException; +import org.hibernate.AssertionFailure; +import org.hibernate.FetchMode; +import org.hibernate.MappingException; +import org.hibernate.annotations.MapKeyManyToMany; +import org.hibernate.annotations.MapKey; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.cfg.AnnotatedClassType; +import org.hibernate.cfg.AnnotationBinder; +import org.hibernate.cfg.BinderHelper; +import org.hibernate.cfg.CollectionSecondPass; +import org.hibernate.cfg.Ejb3Column; +import org.hibernate.cfg.Ejb3JoinColumn; +import org.hibernate.cfg.ExtendedMappings; +import org.hibernate.cfg.PropertyData; +import org.hibernate.cfg.PropertyHolder; +import org.hibernate.cfg.PropertyHolderBuilder; +import org.hibernate.cfg.PropertyPreloadedData; +import org.hibernate.cfg.SecondPass; +import org.hibernate.dialect.HSQLDialect; +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.Component; +import org.hibernate.mapping.DependantValue; +import org.hibernate.mapping.Formula; +import org.hibernate.mapping.Join; +import org.hibernate.mapping.ManyToOne; +import org.hibernate.mapping.OneToMany; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.ToOne; +import org.hibernate.mapping.Value; +import org.hibernate.sql.Template; +import org.hibernate.util.StringHelper; + +/** + * Implementation to bind a Map + * + * @author Emmanuel Bernard + */ +public class MapBinder extends CollectionBinder { + public MapBinder(boolean sorted) { + super( sorted ); + } + + public MapBinder() { + super(); + } + + protected Collection createCollection(PersistentClass persistentClass) { + return new org.hibernate.mapping.Map( persistentClass ); + } + + @Override + public SecondPass getSecondPass( + final Ejb3JoinColumn[] fkJoinColumns, final Ejb3JoinColumn[] keyColumns, + final Ejb3JoinColumn[] inverseColumns, + final Ejb3Column[] elementColumns, + final Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToMa= nyColumns, final boolean isEmbedded, + final XProperty property, final XClass collType, + final boolean ignoreNotFound, final boolean unique, + final TableBinder assocTableBinder, final ExtendedMappings mappings + ) { + return new CollectionSecondPass( mappings, MapBinder.this.collection ) { + public void secondPass(Map persistentClasses, Map inheritedMetas) + throws MappingException { + bindStarToManySecondPass( + persistentClasses, collType, fkJoinColumns, keyColumns, inverseColum= ns, elementColumns, + isEmbedded, property, unique, assocTableBinder, ignoreNotFound, mapp= ings + ); + bindKeyFromAssociationTable( + collType, persistentClasses, mapKeyPropertyName, property, isEmbedde= d, mappings, + mapKeyColumns, mapKeyManyToManyColumns, + inverseColumns !=3D null ? inverseColumns[0].getPropertyName() : null + ); + } + }; + } + + private void bindKeyFromAssociationTable( + XClass collType, Map persistentClasses, String mapKeyPropertyName, XPro= perty property, + boolean isEmbedded, ExtendedMappings mappings, Ejb3Column[] mapKeyColum= ns, + Ejb3JoinColumn[] mapKeyManyToManyColumns, String targetPropertyName + ) { + if ( mapKeyPropertyName !=3D null ) { + //this is an EJB3 @MapKey + PersistentClass associatedClass =3D (PersistentClass) persistentClasses= .get( collType.getName() ); + if ( associatedClass =3D=3D null ) throw new AnnotationException( "Asso= ciated class not found: " + collType ); + Property mapProperty =3D BinderHelper.findPropertyByName( associatedCla= ss, mapKeyPropertyName ); + if ( mapProperty =3D=3D null ) { + throw new AnnotationException( + "Map key property not found: " + collType + "." + mapKeyPropertyName + ); + } + org.hibernate.mapping.Map map =3D (org.hibernate.mapping.Map) this.coll= ection; + Value indexValue =3D createFormulatedValue( mapProperty.getValue(), map= , targetPropertyName, associatedClass ); + map.setIndex( indexValue ); + } + else { + //this is a true Map mapping + //TODO ugly copy/pastle from CollectionBinder.bindManyToManySecondPass + String mapKeyType; + Class target =3D void.class; + /* + * target has priority over reflection for the map key type + */ + if ( property.isAnnotationPresent( org.hibernate.annotations.MapKey.cla= ss ) ) { + target =3D property.getAnnotation( org.hibernate.annotations.MapKey.cl= ass ).targetElement(); + } + else if ( property.isAnnotationPresent( MapKeyManyToMany.class ) ) { + target =3D property.getAnnotation( MapKeyManyToMany.class ).targetEnti= ty(); + } + if ( !void.class.equals( target ) ) { + mapKeyType =3D target.getName(); + } + else { + mapKeyType =3D property.getMapKey().getName(); + } + PersistentClass collectionEntity =3D (PersistentClass) persistentClasse= s.get( mapKeyType ); + boolean isIndexOfEntities =3D collectionEntity !=3D null; + ManyToOne element =3D null; + org.hibernate.mapping.Map mapValue =3D (org.hibernate.mapping.Map) this= .collection; + if ( isIndexOfEntities ) { + element =3D new ManyToOne( mapValue.getCollectionTable() ); + mapValue.setIndex( element ); + element.setReferencedEntityName( mapKeyType ); + //element.setFetchMode( fetchMode ); + //element.setLazy( fetchMode !=3D FetchMode.JOIN ); + //make the second join non lazy + element.setFetchMode( FetchMode.JOIN ); + element.setLazy( false ); + //does not make sense for a map key element.setIgnoreNotFound( ignoreN= otFound ); + } + else { + XClass elementClass; + AnnotatedClassType classType; + // Map columnOverrides =3D Prope= rtyHolderBuilder.buildColumnOverride( + // property, StringHelper.qualify( collValue.getRole(), "element" ) + // ); + //FIXME the "element" is lost + PropertyHolder holder =3D null; + if ( BinderHelper.PRIMITIVE_NAMES.contains( mapKeyType ) ) { + classType =3D AnnotatedClassType.NONE; + elementClass =3D null; + } + else { + try { + elementClass =3D mappings.getReflectionManager().classForName( mapKe= yType, MapBinder.class ); + } + catch (ClassNotFoundException e) { + throw new AnnotationException( "Unable to find class: " + mapKeyType= , e ); + } + classType =3D mappings.getClassType( elementClass ); + + holder =3D PropertyHolderBuilder.buildPropertyHolder( + mapValue, + StringHelper.qualify( mapValue.getRole(), "mapkey" ), + elementClass, + property, propertyHolder, mappings + ); + //force in case of attribute override + boolean attributeOverride =3D property.isAnnotationPresent( Attribute= Override.class ) + || property.isAnnotationPresent( AttributeOverrides.class ); + if ( isEmbedded || attributeOverride ) { + classType =3D AnnotatedClassType.EMBEDDABLE; + } + } + + if ( AnnotatedClassType.EMBEDDABLE.equals( classType ) ) { + EntityBinder entityBinder =3D new EntityBinder(); + PersistentClass owner =3D mapValue.getOwner(); + boolean isPropertyAnnotated; + //FIXME support @Access for collection of elements + //String accessType =3D access !=3D null ? access.value() : null; + if ( owner.getIdentifierProperty() !=3D null ) { + isPropertyAnnotated =3D owner.getIdentifierProperty() + .getPropertyAccessorName() + .equals( "property" ); + } + else + if ( owner.getIdentifierMapper() !=3D null && owner.getIdentifierMapp= er().getPropertySpan() > 0 ) { + Property prop =3D (Property) owner.getIdentifierMapper().getProperty= Iterator().next(); + isPropertyAnnotated =3D prop.getPropertyAccessorName().equals( "prop= erty" ); + } + else { + throw new AssertionFailure( "Unable to guess collection property acc= essor name" ); + } + + //boolean propertyAccess =3D embeddable =3D=3D null || AccessType.PRO= PERTY.equals( embeddable.access() ); + //FIXME "index" is it right? + PropertyData inferredData =3D new PropertyPreloadedData( "property", = "index", elementClass ); + //TODO be smart with isNullable + Component component =3D AnnotationBinder.fillComponent( + holder, inferredData, isPropertyAnnotated, isPropertyAnnotated ? "p= roperty" : "field", true, + entityBinder, false, false, + true, mappings + ); + mapValue.setIndex( component ); + } + else { + SimpleValueBinder elementBinder =3D new SimpleValueBinder(); + elementBinder.setMappings( mappings ); + elementBinder.setReturnedClassName( mapKeyType ); + + Ejb3Column[] elementColumns =3D mapKeyColumns; + if ( elementColumns =3D=3D null || elementColumns.length =3D=3D 0 ) { + elementColumns =3D new Ejb3Column[1]; + Ejb3Column column =3D new Ejb3Column(); + column.setImplicit( false ); + column.setNullable( true ); + column.setLength( Ejb3Column.DEFAULT_COLUMN_LENGTH ); + column.setLogicalColumnName( Collection.DEFAULT_KEY_COLUMN_NAME ); + //TODO create an EMPTY_JOINS collection + column.setJoins( new HashMap() ); + column.setMappings( mappings ); + column.bind(); + elementColumns[0] =3D column; + } + //override the table + for (Ejb3Column column : elementColumns) { + column.setTable( mapValue.getCollectionTable() ); + } + elementBinder.setColumns( elementColumns ); + //do not call setType as it extract the type from @Type + //the algorithm generally does not apply for map key anyway + MapKey mapKeyAnn =3D property.getAnnotation( org.hibernate.annotation= s.MapKey.class ); + if (mapKeyAnn !=3D null && ! BinderHelper.isDefault( mapKeyAnn.type()= .type() ) ) { + elementBinder.setExplicitType( mapKeyAnn.type() ); + } + mapValue.setIndex( elementBinder.make() ); + } + } + //FIXME pass the Index Entity JoinColumns + if ( !collection.isOneToMany() ) { + //index column shoud not be null + for (Ejb3JoinColumn col : mapKeyManyToManyColumns) { + col.forceNotNull(); + } + } + if ( isIndexOfEntities ) { + bindManytoManyInverseFk( + collectionEntity, + mapKeyManyToManyColumns, + element, + false, //a map key column has no unique constraint + mappings + ); + } + } + } + + protected Value createFormulatedValue( + Value value, Collection collection, String targetPropertyName, Persiste= ntClass associatedClass + ) { + Value element =3D collection.getElement(); + String fromAndWhere =3D null; + if ( !( element instanceof OneToMany ) ) { + String referencedPropertyName =3D null; + if ( element instanceof ToOne ) { + referencedPropertyName =3D ( (ToOne) element ).getReferencedPropertyNa= me(); + } + else if ( element instanceof DependantValue ) { + //TODO this never happen I think + if ( propertyName !=3D null ) { + referencedPropertyName =3D collection.getReferencedPropertyName(); + } + else { + throw new AnnotationException( "SecondaryTable JoinColumn cannot refe= rence a non primary key" ); + } + } + Iterator referencedEntityColumns; + if ( referencedPropertyName =3D=3D null ) { + referencedEntityColumns =3D associatedClass.getIdentifier().getColumnI= terator(); + } + else { + Property referencedProperty =3D associatedClass.getRecursiveProperty( = referencedPropertyName ); + referencedEntityColumns =3D referencedProperty.getColumnIterator(); + } + String alias =3D "$alias$"; + StringBuilder fromAndWhereSb =3D new StringBuilder( " from " ) + .append( associatedClass.getTable().getName() ) + //.append(" as ") //Oracle doesn't support it in subqueries + .append( " " ) + .append( alias ).append( " where " ); + Iterator collectionTableColumns =3D element.getColumnIterator(); + while ( collectionTableColumns.hasNext() ) { + Column colColumn =3D (Column) collectionTableColumns.next(); + Column refColumn =3D (Column) referencedEntityColumns.next(); + fromAndWhereSb.append( alias ).append( '.' ).append( refColumn.getQuot= edName() ) + .append( '=3D' ).append( colColumn.getQuotedName() ).append( " and "= ); + } + fromAndWhere =3D fromAndWhereSb.substring( 0, fromAndWhereSb.length() -= 5 ); + } + + if ( value instanceof Component ) { + Component component =3D (Component) value; + Iterator properties =3D component.getPropertyIterator(); + Component indexComponent =3D new Component( collection ); + indexComponent.setComponentClassName( component.getComponentClassName()= ); + //TODO I don't know if this is appropriate + indexComponent.setNodeName( "index" ); + while ( properties.hasNext() ) { + Property current =3D (Property) properties.next(); + Property newProperty =3D new Property(); + newProperty.setCascade( current.getCascade() ); + newProperty.setGeneration( current.getGeneration() ); + newProperty.setInsertable( false ); + newProperty.setUpdateable( false ); + newProperty.setMetaAttributes( current.getMetaAttributes() ); + newProperty.setName( current.getName() ); + newProperty.setNodeName( current.getNodeName() ); + newProperty.setNaturalIdentifier( false ); + //newProperty.setOptimisticLocked( false ); + newProperty.setOptional( false ); + newProperty.setPersistentClass( current.getPersistentClass() ); + newProperty.setPropertyAccessorName( current.getPropertyAccessorName()= ); + newProperty.setSelectable( current.isSelectable() ); + newProperty.setValue( createFormulatedValue( current.getValue(), colle= ction, targetPropertyName, + associatedClass + ) ); + indexComponent.addProperty( newProperty ); + } + return indexComponent; + } + else if ( value instanceof SimpleValue ) { + SimpleValue sourceValue =3D (SimpleValue) value; + SimpleValue targetValue; + if ( value instanceof ManyToOne ) { + ManyToOne sourceManyToOne =3D (ManyToOne) sourceValue; + ManyToOne targetManyToOne =3D new ManyToOne( collection.getCollectionT= able() ); + targetManyToOne.setFetchMode( FetchMode.DEFAULT ); + targetManyToOne.setLazy( true ); + //targetValue.setIgnoreNotFound( ); does not make sense for a map key + targetManyToOne.setReferencedEntityName( sourceManyToOne.getReferenced= EntityName() ); + targetValue =3D targetManyToOne; + } + else { + targetValue =3D new SimpleValue( collection.getCollectionTable() ); + targetValue.setTypeName( sourceValue.getTypeName() ); + targetValue.setTypeParameters( sourceValue.getTypeParameters() ); + } + Iterator columns =3D sourceValue.getColumnIterator(); + Random random =3D new Random(); + while ( columns.hasNext() ) { + Object current =3D columns.next(); + Formula formula =3D new Formula(); + String formulaString; + if ( current instanceof Column ) { + formulaString =3D ( (Column) current ).getQuotedName(); + } + else if ( current instanceof Formula ) { + formulaString =3D ( (Formula) current ).getFormula(); + } + else { + throw new AssertionFailure( "Unknown element in column iterator: " + = current.getClass() ); + } + if ( fromAndWhere !=3D null ) { + formulaString =3D Template.renderWhereStringTemplate( formulaString, = "$alias$", new HSQLDialect() ); + formulaString =3D "(select " + formulaString + fromAndWhere + ")"; + formulaString =3D StringHelper.replace( + formulaString, + "$alias$", + "a" + random.nextInt( 16 ) + ); + } + formula.setFormula( formulaString ); + targetValue.addFormula( formula ); + + } + return targetValue; + } + else { + throw new AssertionFailure( "Unknown type encounters for map key: " + v= alue.getClass() ); + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/Nullability.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/Nullability.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/Nullability.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,12 @@ +package org.hibernate.cfg.annotations; + +/** + * Are the columns forced to null, not null or not forced + * + * @author Emmanuel Bernard + */ +public enum Nullability { + FORCED_NULL, + FORCED_NOT_NULL, + NO_CONSTRAINT +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/PrimitiveArrayBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/PrimitiveArrayBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/PrimitiveArrayBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,16 @@ +//$Id: PrimitiveArrayBinder.java 14736 2008-06-04 14:23:42Z hardy.ferentsc= hik $ +package org.hibernate.cfg.annotations; + +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.PrimitiveArray; + +/** + * @author Emmanuel Bernard + */ +public class PrimitiveArrayBinder extends ArrayBinder { + @Override + protected Collection createCollection(PersistentClass persistentClass) { + return new PrimitiveArray( persistentClass ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/PropertyBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/PropertyBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/PropertyBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,195 @@ +//$Id: PropertyBinder.java 14801 2008-06-24 19:03:32Z hardy.ferentschik $ +package org.hibernate.cfg.annotations; + +import javax.persistence.EmbeddedId; +import javax.persistence.Id; + +import org.hibernate.AnnotationException; +import org.hibernate.annotations.Generated; +import org.hibernate.annotations.GenerationTime; +import org.hibernate.annotations.Immutable; +import org.hibernate.annotations.NaturalId; +import org.hibernate.annotations.OptimisticLock; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.cfg.Ejb3Column; +import org.hibernate.cfg.ExtendedMappings; +import org.hibernate.cfg.PropertyHolder; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.PropertyGeneration; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.Value; +import org.hibernate.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Emmanuel Bernard + */ +public class PropertyBinder { + private Logger log =3D LoggerFactory.getLogger( PropertyBinder.class ); + private String name; + private String returnedClassName; + private boolean lazy; + private String propertyAccessorName; + private Ejb3Column[] columns; + private PropertyHolder holder; + private ExtendedMappings mappings; + private Value value; + private boolean insertable =3D true; + private boolean updatable =3D true; + private String cascade; + /* + * property can be null + * prefer propertyName to property.getName() since some are overloaded + */ + private XProperty property; + private XClass returnedClass; + + public void setInsertable(boolean insertable) { + this.insertable =3D insertable; + } + + public void setUpdatable(boolean updatable) { + this.updatable =3D updatable; + } + + + public void setName(String name) { + this.name =3D name; + } + + public void setReturnedClassName(String returnedClassName) { + this.returnedClassName =3D returnedClassName; + } + + public void setLazy(boolean lazy) { + this.lazy =3D lazy; + } + + public void setPropertyAccessorName(String propertyAccessorName) { + this.propertyAccessorName =3D propertyAccessorName; + } + + public void setColumns(Ejb3Column[] columns) { + insertable =3D columns[0].isInsertable(); + updatable =3D columns[0].isUpdatable(); + //consistency is checked later when we know the property name + this.columns =3D columns; + } + + public void setHolder(PropertyHolder holder) { + this.holder =3D holder; + } + + public void setValue(Value value) { + this.value =3D value; + } + + public void setCascade(String cascadeStrategy) { + this.cascade =3D cascadeStrategy; + } + + public void setMappings(ExtendedMappings mappings) { + this.mappings =3D mappings; + } + + private void validateBind() { + if (property.isAnnotationPresent(Immutable.class)) { + throw new AnnotationException("@Immutable on property not allowed. " + + "Only allowed on entity level or on a collection."); + } = + } + + private void validateMake() { + //TODO check necessary params for a make + } + + public Property bind() { + validateBind(); + log.debug( "binding property {} with lazy=3D{}", name, lazy ); + String containerClassName =3D holder =3D=3D null ? + null : + holder.getClassName(); + SimpleValueBinder value =3D new SimpleValueBinder(); + value.setMappings( mappings ); + value.setPropertyName( name ); + value.setReturnedClassName( returnedClassName ); + value.setColumns( columns ); + value.setPersistentClassName( containerClassName ); + value.setType( property, returnedClass ); + value.setMappings( mappings ); + SimpleValue propertyValue =3D value.make(); + setValue( propertyValue ); + Property prop =3D make(); + holder.addProperty( prop, columns ); + return prop; + } + + public Property make() { + validateMake(); + log.debug( "Building property " + name ); + Property prop =3D new Property(); + prop.setName( name ); + prop.setNodeName( name ); + prop.setValue( value ); + prop.setLazy( lazy ); + prop.setCascade( cascade ); + prop.setPropertyAccessorName( propertyAccessorName ); + Generated ann =3D property !=3D null ? + property.getAnnotation( Generated.class ) : + null; + GenerationTime generated =3D ann !=3D null ? + ann.value() : + null; + if ( generated !=3D null ) { + if ( !GenerationTime.NEVER.equals( generated ) ) { + if ( property.isAnnotationPresent( javax.persistence.Version.class ) + && GenerationTime.INSERT.equals( generated ) ) { + throw new AnnotationException( "@Generated(INSERT) on a @Version prop= erty not allowed, use ALWAYS: " + + StringHelper.qualify( holder.getPath(), name ) ); + } + insertable =3D false; + if ( GenerationTime.ALWAYS.equals( generated ) ) { + updatable =3D false; + } + prop.setGeneration( PropertyGeneration.parse( generated.toString().toL= owerCase() ) ); + } + } + NaturalId naturalId =3D property !=3D null ? + property.getAnnotation( NaturalId.class ) : + null; + if ( naturalId !=3D null ) { + if ( !naturalId.mutable() ) { + updatable =3D false; + } + prop.setNaturalIdentifier( true ); + } + prop.setInsertable( insertable ); + prop.setUpdateable( updatable ); + OptimisticLock lockAnn =3D property !=3D null ? + property.getAnnotation( OptimisticLock.class ) : + null; + if ( lockAnn !=3D null ) { + prop.setOptimisticLocked( !lockAnn.excluded() ); + //TODO this should go to the core as a mapping validation checking + if ( lockAnn.excluded() && ( + property.isAnnotationPresent( javax.persistence.Version.class ) + || property.isAnnotationPresent( Id.class ) + || property.isAnnotationPresent( EmbeddedId.class ) ) ) { + throw new AnnotationException( "@OptimisticLock.exclude=3Dtrue incompa= tible with @Id, @EmbeddedId and @Version: " + + StringHelper.qualify( holder.getPath(), name ) ); + } + } + log.trace( "Cascading " + name + " with " + cascade ); + return prop; + } + + public void setProperty(XProperty property) { + this.property =3D property; + } + + public void setReturnedClass(XClass returnedClass) { + this.returnedClass =3D returnedClass; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/QueryBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/QueryBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/QueryBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,388 @@ +//$Id: QueryBinder.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.cfg.annotations; + +import java.util.HashMap; +import javax.persistence.NamedNativeQueries; +import javax.persistence.NamedNativeQuery; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.QueryHint; +import javax.persistence.SqlResultSetMapping; +import javax.persistence.SqlResultSetMappings; + +import org.hibernate.AnnotationException; +import org.hibernate.AssertionFailure; +import org.hibernate.CacheMode; +import org.hibernate.FlushMode; +import org.hibernate.LockMode; +import org.hibernate.annotations.CacheModeType; +import org.hibernate.annotations.FlushModeType; +import org.hibernate.cfg.BinderHelper; +import org.hibernate.cfg.ExtendedMappings; +import org.hibernate.cfg.NotYetImplementedException; +import org.hibernate.engine.NamedQueryDefinition; +import org.hibernate.engine.NamedSQLQueryDefinition; +import org.hibernate.engine.query.sql.NativeSQLQueryReturn; +import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Query binder + * + * @author Emmanuel Bernard + */ +public abstract class QueryBinder { + private static final Logger log =3D LoggerFactory.getLogger( QueryBinder.= class ); + + public static void bindQuery(NamedQuery queryAnn, ExtendedMappings mappin= gs, boolean isDefault) { + if ( queryAnn =3D=3D null ) return; + if ( BinderHelper.isDefault( queryAnn.name() ) ) { + throw new AnnotationException( "A named query must have a name when use= d in class or package level" ); + } + //EJBQL Query + QueryHint[] hints =3D queryAnn.hints(); + String queryName =3D queryAnn.query(); + NamedQueryDefinition query =3D new NamedQueryDefinition( + queryName, + getBoolean( queryName, "org.hibernate.cacheable", hints ), + getString( queryName, "org.hibernate.cacheRegion", hints ), + getInteger( queryName, "org.hibernate.timeout", hints ), + getInteger( queryName, "org.hibernate.fetchSize", hints ), + getFlushMode( queryName, hints ), + getCacheMode( queryName, hints ), + getBoolean( queryName, "org.hibernate.readOnly", hints ), + getString( queryName, "org.hibernate.comment", hints ), + null + ); + if ( isDefault ) { + mappings.addDefaultQuery( queryAnn.name(), query ); + } + else { + mappings.addQuery( queryAnn.name(), query ); + } + log.info( "Binding Named query: {} =3D> {}", queryAnn.name(), queryAnn.q= uery() ); + } + + + public static void bindNativeQuery(NamedNativeQuery queryAnn, ExtendedMap= pings mappings, boolean isDefault) { + if ( queryAnn =3D=3D null ) return; + //ResultSetMappingDefinition mappingDefinition =3D mappings.getResultSet= Mapping( queryAnn.resultSetMapping() ); + if ( BinderHelper.isDefault( queryAnn.name() ) ) { + throw new AnnotationException( "A named query must have a name when use= d in class or package level" ); + } + NamedSQLQueryDefinition query; + String resultSetMapping =3D queryAnn.resultSetMapping(); + QueryHint[] hints =3D queryAnn.hints(); + String queryName =3D queryAnn.query(); + if ( !BinderHelper.isDefault( resultSetMapping ) ) { + //sql result set usage + query =3D new NamedSQLQueryDefinition( + queryName, + resultSetMapping, + null, + getBoolean( queryName, "org.hibernate.cacheable", hints ), + getString( queryName, "org.hibernate.cacheRegion", hints ), + getInteger( queryName, "org.hibernate.timeout", hints ), + getInteger( queryName, "org.hibernate.fetchSize", hints ), + getFlushMode( queryName, hints ), + getCacheMode( queryName, hints ), + getBoolean( queryName, "org.hibernate.readOnly", hints ), + getString( queryName, "org.hibernate.comment", hints ), + null, + getBoolean( queryName, "org.hibernate.callable", hints ) + ); + } + else if ( !void.class.equals( queryAnn.resultClass() ) ) { + //class mapping usage + //FIXME should be done in a second pass due to entity name? + final NativeSQLQueryRootReturn entityQueryReturn =3D + new NativeSQLQueryRootReturn( "alias1", queryAnn.resultClass().getNam= e(), new HashMap(), LockMode.READ ); + query =3D new NamedSQLQueryDefinition( + queryName, + new NativeSQLQueryReturn[] { entityQueryReturn }, + null, + getBoolean( queryName, "org.hibernate.cacheable", hints ), + getString( queryName, "org.hibernate.cacheRegion", hints ), + getInteger( queryName, "org.hibernate.timeout", hints ), + getInteger( queryName, "org.hibernate.fetchSize", hints ), + getFlushMode( queryName, hints ), + getCacheMode( queryName, hints ), + getBoolean( queryName, "org.hibernate.readOnly", hints ), + getString( queryName, "org.hibernate.comment", hints ), + null, + getBoolean( queryName, "org.hibernate.callable", hints ) + ); + } + else { + throw new NotYetImplementedException( "Pure native scalar queries are n= ot yet supported" ); + } + if ( isDefault ) { + mappings.addDefaultSQLQuery( queryAnn.name(), query ); + } + else { + mappings.addSQLQuery( queryAnn.name(), query ); + } + log.info( "Binding named native query: {} =3D> {}", queryAnn.name(), que= ryAnn.query() ); + } + + public static void bindNativeQuery(org.hibernate.annotations.NamedNativeQ= uery queryAnn, ExtendedMappings mappings) { + if ( queryAnn =3D=3D null ) return; + //ResultSetMappingDefinition mappingDefinition =3D mappings.getResultSet= Mapping( queryAnn.resultSetMapping() ); + if ( BinderHelper.isDefault( queryAnn.name() ) ) { + throw new AnnotationException( "A named query must have a name when use= d in class or package level" ); + } + NamedSQLQueryDefinition query; + String resultSetMapping =3D queryAnn.resultSetMapping(); + if ( !BinderHelper.isDefault( resultSetMapping ) ) { + //sql result set usage + query =3D new NamedSQLQueryDefinition( + queryAnn.query(), + resultSetMapping, + null, + queryAnn.cacheable(), + BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.ca= cheRegion(), + queryAnn.timeout() < 0 ? null : queryAnn.timeout(), + queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(), + getFlushMode( queryAnn.flushMode() ), + getCacheMode( queryAnn.cacheMode() ), + queryAnn.readOnly(), + BinderHelper.isDefault( queryAnn.comment() ) ? null : queryAnn.commen= t(), + null, + queryAnn.callable() + ); + } + else if ( !void.class.equals( queryAnn.resultClass() ) ) { + //class mapping usage + //FIXME should be done in a second pass due to entity name? + final NativeSQLQueryRootReturn entityQueryReturn =3D + new NativeSQLQueryRootReturn( "alias1", queryAnn.resultClass().getNam= e(), new HashMap(), LockMode.READ ); + query =3D new NamedSQLQueryDefinition( + queryAnn.query(), + new NativeSQLQueryReturn[] { entityQueryReturn }, + null, + queryAnn.cacheable(), + BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.ca= cheRegion(), + queryAnn.timeout() < 0 ? null : queryAnn.timeout(), + queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(), + getFlushMode( queryAnn.flushMode() ), + getCacheMode( queryAnn.cacheMode() ), + queryAnn.readOnly(), + BinderHelper.isDefault( queryAnn.comment() ) ? null : queryAnn.commen= t(), + null, + queryAnn.callable() + ); + } + else { + throw new NotYetImplementedException( "Pure native scalar queries are n= ot yet supported" ); + } + mappings.addSQLQuery( queryAnn.name(), query ); + log.info( "Binding named native query: {} =3D> {}", queryAnn.name(), que= ryAnn.query() ); + } + + public static void bindQueries(NamedQueries queriesAnn, ExtendedMappings = mappings, boolean isDefault) { + if ( queriesAnn =3D=3D null ) return; + for (NamedQuery q : queriesAnn.value()) { + bindQuery( q, mappings, isDefault ); + } + } + + public static void bindNativeQueries(NamedNativeQueries queriesAnn, Exten= dedMappings mappings, boolean isDefault) { + if ( queriesAnn =3D=3D null ) return; + for (NamedNativeQuery q : queriesAnn.value()) { + bindNativeQuery( q, mappings, isDefault ); + } + } + + public static void bindNativeQueries( + org.hibernate.annotations.NamedNativeQueries queriesAnn, ExtendedMappin= gs mappings + ) { + if ( queriesAnn =3D=3D null ) return; + for (org.hibernate.annotations.NamedNativeQuery q : queriesAnn.value()) { + bindNativeQuery( q, mappings ); + } + } + + public static void bindQuery(org.hibernate.annotations.NamedQuery queryAn= n, ExtendedMappings mappings) { + if ( queryAnn =3D=3D null ) return; + if ( BinderHelper.isDefault( queryAnn.name() ) ) { + throw new AnnotationException( "A named query must have a name when use= d in class or package level" ); + } + + FlushMode flushMode; + flushMode =3D getFlushMode( queryAnn.flushMode() ); + + NamedQueryDefinition query =3D new NamedQueryDefinition( + queryAnn.query(), + queryAnn.cacheable(), + BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cac= heRegion(), + queryAnn.timeout() < 0 ? null : queryAnn.timeout(), + queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(), + flushMode, + getCacheMode( queryAnn.cacheMode() ), + queryAnn.readOnly(), + BinderHelper.isDefault( queryAnn.comment() ) ? null : queryAnn.comment= (), + null + ); + + mappings.addQuery( queryAnn.name(), query ); + if ( log.isInfoEnabled() ) log.info( "Binding named query: " + queryAnn.= name() + " =3D> " + queryAnn.query() ); + } + + private static FlushMode getFlushMode(FlushModeType flushModeType) { + FlushMode flushMode; + switch ( flushModeType ) { + case ALWAYS: + flushMode =3D FlushMode.ALWAYS; + break; + case AUTO: + flushMode =3D FlushMode.AUTO; + break; + case COMMIT: + flushMode =3D FlushMode.COMMIT; + break; + case NEVER: + flushMode =3D FlushMode.MANUAL; + break; + case MANUAL: + flushMode =3D FlushMode.MANUAL; + break; + case PERSISTENCE_CONTEXT: + flushMode =3D null; + break; + default: + throw new AssertionFailure( "Unknown flushModeType: " + flushModeType = ); + } + return flushMode; + } + + private static CacheMode getCacheMode(CacheModeType cacheModeType) { + switch ( cacheModeType ) { + case GET: + return CacheMode.GET; + case IGNORE: + return CacheMode.IGNORE; + case NORMAL: + return CacheMode.NORMAL; + case PUT: + return CacheMode.PUT; + case REFRESH: + return CacheMode.REFRESH; + default: + throw new AssertionFailure( "Unknown cacheModeType: " + cacheModeType = ); + } + } + + + public static void bindQueries(org.hibernate.annotations.NamedQueries que= riesAnn, ExtendedMappings mappings) { + if ( queriesAnn =3D=3D null ) return; + for (org.hibernate.annotations.NamedQuery q : queriesAnn.value()) { + bindQuery( q, mappings ); + } + } + + public static void bindSqlResultsetMappings(SqlResultSetMappings ann, Ext= endedMappings mappings, boolean isDefault) { + if ( ann =3D=3D null ) return; + for (SqlResultSetMapping rs : ann.value()) { + //no need to handle inSecondPass + mappings.addSecondPass( new ResultsetMappingSecondPass( rs, mappings, t= rue ) ); + } + } + + public static void bindSqlResultsetMapping(SqlResultSetMapping ann, Exten= dedMappings mappings, boolean isDefault) { + //no need to handle inSecondPass + mappings.addSecondPass( new ResultsetMappingSecondPass( ann, mappings, i= sDefault ) ); + } + + private static CacheMode getCacheMode(String query, QueryHint[] hints) { + for (QueryHint hint : hints) { + if ( "org.hibernate.cacheMode".equals( hint.name() ) ) { + if ( hint.value().equalsIgnoreCase( CacheMode.GET.toString() ) ) { + return CacheMode.GET; + } + else if ( hint.value().equalsIgnoreCase( CacheMode.IGNORE.toString() )= ) { + return CacheMode.IGNORE; + } + else if ( hint.value().equalsIgnoreCase( CacheMode.NORMAL.toString() )= ) { + return CacheMode.NORMAL; + } + else if ( hint.value().equalsIgnoreCase( CacheMode.PUT.toString() ) ) { + return CacheMode.PUT; + } + else if ( hint.value().equalsIgnoreCase( CacheMode.REFRESH.toString() = ) ) { + return CacheMode.REFRESH; + } + else { + throw new AnnotationException( "Unknown CacheMode in hint: " + query = + ":" + hint.name() ); + } + } + } + return null; + } + + private static FlushMode getFlushMode(String query, QueryHint[] hints) { + for (QueryHint hint : hints) { + if ( "org.hibernate.flushMode".equals( hint.name() ) ) { + if ( hint.value().equalsIgnoreCase( FlushMode.ALWAYS.toString() ) ) { + return FlushMode.ALWAYS; + } + else if ( hint.value().equalsIgnoreCase( FlushMode.AUTO.toString() ) )= { + return FlushMode.AUTO; + } + else if ( hint.value().equalsIgnoreCase( FlushMode.COMMIT.toString() )= ) { + return FlushMode.COMMIT; + } + else if ( hint.value().equalsIgnoreCase( FlushMode.NEVER.toString() ) = ) { + return FlushMode.MANUAL; + } + else if ( hint.value().equalsIgnoreCase( FlushMode.MANUAL.toString() )= ) { + return FlushMode.MANUAL; + } + else { + throw new AnnotationException( "Unknown FlushMode in hint: " + query = + ":" + hint.name() ); + } + } + } + return null; + } + + private static boolean getBoolean(String query, String hintName, QueryHin= t[] hints) { + for (QueryHint hint : hints) { + if ( hintName.equals( hint.name() ) ) { + if ( hint.value().equalsIgnoreCase( "true" ) ) { + return true; + } + else if ( hint.value().equalsIgnoreCase( "false" ) ) { + return false; + } + else { + throw new AnnotationException( "Not a boolean in hint: " + query + ":= " + hint.name() ); + } + } + } + return false; + } + + private static String getString(String query, String hintName, QueryHint[= ] hints) { + for (QueryHint hint : hints) { + if ( hintName.equals( hint.name() ) ) { + return hint.value(); + } + } + return null; + } + + private static Integer getInteger(String query, String hintName, QueryHin= t[] hints) { + for (QueryHint hint : hints) { + if ( hintName.equals( hint.name() ) ) { + try { + return Integer.decode( hint.value() ); + } + catch (NumberFormatException nfe) { + throw new AnnotationException( "Not an integer in hint: " + query + "= :" + hint.name(), nfe ); + } + } + } + return null; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/ResultsetMappingSecondPass.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/ResultsetMappingSecondPass.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/ResultsetMappingSecondPass.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,231 @@ +//$Id: ResultsetMappingSecondPass.java 14736 2008-06-04 14:23:42Z hardy.fe= rentschik $ +package org.hibernate.cfg.annotations; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.persistence.ColumnResult; +import javax.persistence.EntityResult; +import javax.persistence.FieldResult; +import javax.persistence.SqlResultSetMapping; + +import org.hibernate.LockMode; +import org.hibernate.MappingException; +import org.hibernate.cfg.BinderHelper; +import org.hibernate.cfg.ExtendedMappings; +import org.hibernate.cfg.QuerySecondPass; +import org.hibernate.engine.ResultSetMappingDefinition; +import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn; +import org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn; +import org.hibernate.mapping.Component; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.ToOne; +import org.hibernate.mapping.Value; +import org.hibernate.util.CollectionHelper; +import org.hibernate.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Emmanuel Bernard + */ +public class ResultsetMappingSecondPass implements QuerySecondPass { + private Logger log =3D LoggerFactory.getLogger( ResultsetMappingSecondPas= s.class ); + private SqlResultSetMapping ann; + private ExtendedMappings mappings; + private boolean isDefault; + + public ResultsetMappingSecondPass(SqlResultSetMapping ann, ExtendedMappin= gs mappings, boolean isDefault) { + this.ann =3D ann; + this.mappings =3D mappings; + this.isDefault =3D isDefault; + } + + public void doSecondPass(Map persistentClasses) throws MappingException { + //TODO add parameters checkings + if ( ann =3D=3D null ) return; + ResultSetMappingDefinition definition =3D new ResultSetMappingDefinition= ( ann.name() ); + log.info( "Binding resultset mapping: {}", definition.getName() ); + + int entityAliasIndex =3D 0; + + for (EntityResult entity : ann.entities()) { + //TODO parameterize lock mode? + List properties =3D new ArrayList(); + List propertyNames =3D new ArrayList(); + Map propertyresults =3D new HashMap(); + for (FieldResult field : entity.fields()) { + //use an ArrayList cause we might have several columns per root proper= ty + String name =3D field.name(); + if ( name.indexOf( '.' ) =3D=3D -1 ) { + //regular property + properties.add( field ); + propertyNames.add( name ); + } + else { + /** + * Reorder properties + * 1. get the parent property + * 2. list all the properties following the expected one in the paren= t property + * 3. calculate the lowest index and insert the property + */ + PersistentClass pc =3D mappings.getClass( entity.entityClass().getNam= e() ); + if ( pc =3D=3D null ) { + throw new MappingException( + "Entity not found " + entity.entityClass().getName() + + " in SqlResultsetMapping " + ann.name() + ); + } + int dotIndex =3D name.lastIndexOf( '.' ); + String reducedName =3D name.substring( 0, dotIndex ); + Iterator parentPropIter =3D getSubPropertyIterator( pc, reducedName ); + List followers =3D getFollowers( parentPropIter, reducedName, name ); + + int index =3D propertyNames.size(); + int followersSize =3D followers.size(); + for (int loop =3D 0; loop < followersSize; loop++) { + String follower =3D (String) followers.get( loop ); + int currentIndex =3D getIndexOfFirstMatchingProperty( propertyNames,= follower ); + index =3D currentIndex !=3D -1 && currentIndex < index ? currentInde= x : index; + } + propertyNames.add( index, name ); + properties.add( index, field ); + } + } + + Set uniqueReturnProperty =3D new HashSet(); + Iterator iterator =3D properties.iterator(); + while ( iterator.hasNext() ) { + FieldResult propertyresult =3D (FieldResult) iterator.next(); + String name =3D propertyresult.name(); + if ( "class".equals( name ) ) { + throw new MappingException( + "class is not a valid property name to use in a @FieldResult, use @= Entity(discriminatorColumn) instead" + ); + } + ArrayList allResultColumns =3D new ArrayList(); + allResultColumns.add( propertyresult.column() ); + + if ( uniqueReturnProperty.contains( name ) ) { + throw new MappingException( + "duplicate @FieldResult for property " + name + + " on @Entity " + entity.entityClass().getName() + " in " + ann.na= me() + ); + } + uniqueReturnProperty.add( name ); + String key =3D StringHelper.root( name ); + ArrayList intermediateResults =3D (ArrayList) propertyresults.get( key= ); + if ( intermediateResults =3D=3D null ) { + propertyresults.put( key, allResultColumns ); + } + else { + intermediateResults.addAll( allResultColumns ); + } + } + Iterator entries =3D propertyresults.entrySet().iterator(); + while ( entries.hasNext() ) { + Map.Entry entry =3D (Map.Entry) entries.next(); + if ( entry.getValue() instanceof ArrayList ) { + ArrayList list =3D (ArrayList) entry.getValue(); + entry.setValue( list.toArray( new String[list.size()] ) ); + } + } + + if ( !BinderHelper.isDefault( entity.discriminatorColumn() ) ) { + propertyresults.put( "class", new String[] { entity.discriminatorColum= n() } ); + } + + propertyresults =3D propertyresults.isEmpty() ? CollectionHelper.EMPTY_= MAP : propertyresults; + NativeSQLQueryRootReturn result =3D + new NativeSQLQueryRootReturn( + "alias" + entityAliasIndex++, entity.entityClass().getName(), prope= rtyresults, LockMode.READ + ); + definition.addQueryReturn( result ); + } + + for (ColumnResult column : ann.columns()) { + definition.addQueryReturn( new NativeSQLQueryScalarReturn( column.name(= ), null ) ); + } + + if ( isDefault ) { + mappings.addDefaultResultSetMapping( definition ); + } + else { + mappings.addResultSetMapping( definition ); + } + } + + private List getFollowers(Iterator parentPropIter, String reducedName, St= ring name) { + boolean hasFollowers =3D false; + List followers =3D new ArrayList(); + while ( parentPropIter.hasNext() ) { + String currentPropertyName =3D ( (Property) parentPropIter.next() ).get= Name(); + String currentName =3D reducedName + '.' + currentPropertyName; + if ( hasFollowers ) { + followers.add( currentName ); + } + if ( name.equals( currentName ) ) hasFollowers =3D true; + } + return followers; + } + + private Iterator getSubPropertyIterator(PersistentClass pc, String reduce= dName) { + Value value =3D pc.getRecursiveProperty( reducedName ).getValue(); + Iterator parentPropIter; + if ( value instanceof Component ) { + Component comp =3D (Component) value; + parentPropIter =3D comp.getPropertyIterator(); + } + else if ( value instanceof ToOne ) { + ToOne toOne =3D (ToOne) value; + PersistentClass referencedPc =3D mappings.getClass( toOne.getReferenced= EntityName() ); + if ( toOne.getReferencedPropertyName() !=3D null ) { + try { + parentPropIter =3D ( (Component) referencedPc.getRecursiveProperty( + toOne.getReferencedPropertyName() + ).getValue() ).getPropertyIterator(); + } + catch (ClassCastException e) { + throw new MappingException( + "dotted notation reference neither a component nor a many/one to on= e", e + ); + } + } + else { + try { + if ( referencedPc.getIdentifierMapper() =3D=3D null ) { + parentPropIter =3D ( (Component) referencedPc.getIdentifierProperty() + .getValue() ).getPropertyIterator(); + } + else { + parentPropIter =3D referencedPc.getIdentifierMapper().getPropertyIte= rator(); + } + } + catch (ClassCastException e) { + throw new MappingException( + "dotted notation reference neither a component nor a many/one to on= e", e + ); + } + } + } + else { + throw new MappingException( "dotted notation reference neither a compon= ent nor a many/one to one" ); + } + return parentPropIter; + } + + private static int getIndexOfFirstMatchingProperty(List propertyNames, St= ring follower) { + int propertySize =3D propertyNames.size(); + for (int propIndex =3D 0; propIndex < propertySize; propIndex++) { + if ( ( (String) propertyNames.get( propIndex ) ).startsWith( follower )= ) { + return propIndex; + } + } + return -1; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/SetBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/SetBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/SetBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,39 @@ +package org.hibernate.cfg.annotations; + +import org.hibernate.annotations.OrderBy; +import org.hibernate.cfg.Environment; +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.PersistentClass; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Bind a set. + * + * @author Matthew Inger + */ +public class SetBinder extends CollectionBinder { + private final Logger log =3D LoggerFactory.getLogger( SetBinder.class ); + + public SetBinder() { + } + + public SetBinder(boolean sorted) { + super( sorted ); + } + + protected Collection createCollection(PersistentClass persistentClass) { + return new org.hibernate.mapping.Set( persistentClass ); + } + + public void setSqlOrderBy(OrderBy orderByAnn) { + if ( orderByAnn !=3D null ) { + if ( Environment.jvmSupportsLinkedHashCollections() ) { + super.setSqlOrderBy( orderByAnn ); + } + else { + log.warn( "Attribute \"order-by\" ignored in JDK1.3 or less" ); + } + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/SimpleValueBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/SimpleValueBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/SimpleValueBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,248 @@ +//$Id: SimpleValueBinder.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.cfg.annotations; + +import java.io.Serializable; +import java.sql.Types; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; +import javax.persistence.Enumerated; +import javax.persistence.Lob; +import javax.persistence.Temporal; + +import org.hibernate.AnnotationException; +import org.hibernate.AssertionFailure; +import org.hibernate.annotations.Parameter; +import org.hibernate.annotations.Type; +import org.hibernate.annotations.common.reflection.XClass; +import org.hibernate.annotations.common.reflection.XProperty; +import org.hibernate.cfg.BinderHelper; +import org.hibernate.cfg.Ejb3Column; +import org.hibernate.cfg.ExtendedMappings; +import org.hibernate.cfg.NotYetImplementedException; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.Table; +import org.hibernate.type.ByteArrayBlobType; +import org.hibernate.type.CharacterArrayClobType; +import org.hibernate.type.EnumType; +import org.hibernate.type.PrimitiveByteArrayBlobType; +import org.hibernate.type.PrimitiveCharacterArrayClobType; +import org.hibernate.type.SerializableToBlobType; +import org.hibernate.type.StringClobType; +import org.hibernate.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Emmanuel Bernard + */ +public class SimpleValueBinder { + private Logger log =3D LoggerFactory.getLogger( SimpleValueBinder.class ); + private String propertyName; + private String returnedClassName; + private Ejb3Column[] columns; + private String persistentClassName; + private String explicitType =3D ""; + private Properties typeParameters =3D new Properties(); + private ExtendedMappings mappings; + private Table table; + + public void setPropertyName(String propertyName) { + this.propertyName =3D propertyName; + } + + public void setReturnedClassName(String returnedClassName) { + this.returnedClassName =3D returnedClassName; + } + + public void setTable(Table table) { + this.table =3D table; + } + + public void setColumns(Ejb3Column[] columns) { + this.columns =3D columns; + } + + + public void setPersistentClassName(String persistentClassName) { + this.persistentClassName =3D persistentClassName; + } + + //TODO execute it lazily to be order safe + public void setType(XProperty property, XClass returnedClass) { + if ( returnedClass =3D=3D null ) return; //we cannot guess anything + XClass returnedClassOrElement =3D returnedClass; + boolean isArray =3D false; + if ( property.isArray() ) { + returnedClassOrElement =3D property.getElementClass(); + isArray =3D true; + } + Properties typeParameters =3D this.typeParameters; + typeParameters.clear(); + String type =3D BinderHelper.ANNOTATION_STRING_DEFAULT; + if ( property.isAnnotationPresent( Temporal.class ) ) { + Temporal ann =3D property.getAnnotation( Temporal.class ); + boolean isDate; + if ( mappings.getReflectionManager().equals( returnedClassOrElement, Da= te.class ) ) { + isDate =3D true; + } + else if ( mappings.getReflectionManager().equals( returnedClassOrElemen= t, Calendar.class ) ) { + isDate =3D false; + } + else { + throw new AnnotationException( + "@Temporal should only be set on a java.util.Date or java.util.Calen= dar property: " + + StringHelper.qualify( persistentClassName, propertyName ) + ); + } + + switch ( ann.value() ) { + case DATE: + type =3D isDate ? "date" : "calendar_date"; + break; + case TIME: + type =3D "time"; + if ( !isDate ) { + throw new NotYetImplementedException( + "Calendar cannot persist TIME only" + + StringHelper.qualify( persistentClassName, propertyName ) + ); + } + break; + case TIMESTAMP: + type =3D isDate ? "timestamp" : "calendar"; + break; + default: + throw new AssertionFailure( "Unknown temporal type: " + ann.value() ); + } + } + else if ( property.isAnnotationPresent( Lob.class ) ) { + + if ( mappings.getReflectionManager().equals( returnedClassOrElement, ja= va.sql.Clob.class ) ) { + type =3D "clob"; + } + else if ( mappings.getReflectionManager().equals( returnedClassOrElemen= t, java.sql.Blob.class ) ) { + type =3D "blob"; + } + else if ( mappings.getReflectionManager().equals( returnedClassOrElemen= t, String.class ) ) { + type =3D StringClobType.class.getName(); + } + else if ( mappings.getReflectionManager().equals( returnedClassOrElemen= t, Character.class ) && isArray ) { + type =3D CharacterArrayClobType.class.getName(); + } + else if ( mappings.getReflectionManager().equals( returnedClassOrElemen= t, char.class ) && isArray ) { + type =3D PrimitiveCharacterArrayClobType.class.getName(); + } + else if ( mappings.getReflectionManager().equals( returnedClassOrElemen= t, Byte.class ) && isArray ) { + type =3D ByteArrayBlobType.class.getName(); + } + else if ( mappings.getReflectionManager().equals( returnedClassOrElemen= t, byte.class ) && isArray ) { + type =3D PrimitiveByteArrayBlobType.class.getName(); + } + else if ( mappings.getReflectionManager() + .toXClass( Serializable.class ) + .isAssignableFrom( returnedClassOrElement ) ) { + type =3D SerializableToBlobType.class.getName(); + //typeParameters =3D new Properties(); + typeParameters.setProperty( + SerializableToBlobType.CLASS_NAME, + returnedClassOrElement.getName() + ); + } + else { + type =3D "blob"; + } + } + //implicit type will check basic types and Serializable classes + if ( columns =3D=3D null ) { + throw new AssertionFailure( "SimpleValueBinder.setColumns should be set= before SimpleValueBinder.setType" ); + } + if ( BinderHelper.ANNOTATION_STRING_DEFAULT.equals( type ) ) { + if ( returnedClassOrElement.isEnum() ) { + type =3D EnumType.class.getName(); + typeParameters =3D new Properties(); + typeParameters.setProperty( EnumType.ENUM, returnedClassOrElement.getN= ame() ); + String schema =3D columns[0].getTable().getSchema(); + schema =3D schema =3D=3D null ? "" : schema; + String catalog =3D columns[0].getTable().getCatalog(); + catalog =3D catalog =3D=3D null ? "" : catalog; + typeParameters.setProperty( EnumType.SCHEMA, schema ); + typeParameters.setProperty( EnumType.CATALOG, catalog ); + typeParameters.setProperty( EnumType.TABLE, columns[0].getTable().getN= ame() ); + typeParameters.setProperty( EnumType.COLUMN, columns[0].getName() ); + Enumerated enumAnn =3D property.getAnnotation( Enumerated.class ); + if ( enumAnn !=3D null ) { + javax.persistence.EnumType enumType =3D enumAnn.value(); + if ( javax.persistence.EnumType.ORDINAL.equals( enumType ) ) { + typeParameters.setProperty( EnumType.TYPE, String.valueOf( Types.INT= EGER ) ); + } + else if ( javax.persistence.EnumType.STRING.equals( enumType ) ) { + typeParameters.setProperty( EnumType.TYPE, String.valueOf( Types.VAR= CHAR ) ); + } + else { + throw new AssertionFailure( "Unknown EnumType: " + enumType ); + } + } + } + } + explicitType =3D type; + this.typeParameters =3D typeParameters; + Type annType =3D (Type) property.getAnnotation( Type.class ); + setExplicitType( annType ); + } + + public void setExplicitType(String explicitType) { + this.explicitType =3D explicitType; + } + + //FIXME raise an assertion failure if setExplicitType(String) and setExp= licitType(Type) are use at the same time + public void setExplicitType(Type typeAnn) { + if ( typeAnn !=3D null ) { + explicitType =3D typeAnn.type(); + typeParameters.clear(); + for (Parameter param : typeAnn.parameters()) { + typeParameters.setProperty( param.name(), param.value() ); + } + } + } + + public void setMappings(ExtendedMappings mappings) { + this.mappings =3D mappings; + } + + private void validate() { + //TODO check necessary params + Ejb3Column.checkPropertyConsistency( columns, propertyName ); + } + + public SimpleValue make() { + validate(); + log.debug( "building SimpleValue for {}", propertyName ); + if ( table =3D=3D null ) { + table =3D columns[0].getTable(); + } + SimpleValue simpleValue =3D new SimpleValue( table ); + return fillSimpleValue( simpleValue ); + } + + public SimpleValue fillSimpleValue(SimpleValue simpleValue) { + String type =3D BinderHelper.isDefault( explicitType ) ? returnedClassNa= me : explicitType; + org.hibernate.mapping.TypeDef typeDef =3D mappings.getTypeDef( type ); + if ( typeDef !=3D null ) { + type =3D typeDef.getTypeClass(); + simpleValue.setTypeParameters( typeDef.getParameters() ); + } + if ( typeParameters !=3D null && typeParameters.size() !=3D 0 ) { + //explicit type params takes precedence over type def params + simpleValue.setTypeParameters( typeParameters ); + } + simpleValue.setTypeName( type ); + if ( persistentClassName !=3D null ) { + simpleValue.setTypeUsingReflection( persistentClassName, propertyName ); + } + for (Ejb3Column column : columns) { + column.linkWithValue( simpleValue ); + } + return simpleValue; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/TableBinder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/TableBinder.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/TableBinder.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,386 @@ +//$Id: TableBinder.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $ +package org.hibernate.cfg.annotations; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import javax.persistence.UniqueConstraint; + +import org.hibernate.AnnotationException; +import org.hibernate.AssertionFailure; +import org.hibernate.annotations.Index; +import org.hibernate.annotations.common.util.StringHelper; +import org.hibernate.cfg.BinderHelper; +import org.hibernate.cfg.Ejb3JoinColumn; +import org.hibernate.cfg.ExtendedMappings; +import org.hibernate.cfg.IndexOrUniqueKeySecondPass; +import org.hibernate.mapping.Collection; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.DependantValue; +import org.hibernate.mapping.JoinedSubclass; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.mapping.SimpleValue; +import org.hibernate.mapping.Table; +import org.hibernate.mapping.ToOne; +import org.hibernate.mapping.Value; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Table related operations + * + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("unchecked") +public class TableBinder { + //TODO move it to a getter/setter strategy + private static Logger log =3D LoggerFactory.getLogger( TableBinder.class = ); + private String schema; + private String catalog; + private String name; + private boolean isAbstract; + private List uniqueConstraints; + String constraints; + Table denormalizedSuperTable; + ExtendedMappings mappings; + private String ownerEntityTable; + private String associatedEntityTable; + private String propertyName; + private String ownerEntity; + private String associatedEntity; + + public void setSchema(String schema) { + this.schema =3D schema; + } + + public void setCatalog(String catalog) { + this.catalog =3D catalog; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public void setAbstract(boolean anAbstract) { + isAbstract =3D anAbstract; + } + + public void setUniqueConstraints(UniqueConstraint[] uniqueConstraints) { + this.uniqueConstraints =3D TableBinder.buildUniqueConstraints( uniqueCon= straints ); + } + + public void setConstraints(String constraints) { + this.constraints =3D constraints; + } + + public void setDenormalizedSuperTable(Table denormalizedSuperTable) { + this.denormalizedSuperTable =3D denormalizedSuperTable; + } + + public void setMappings(ExtendedMappings mappings) { + this.mappings =3D mappings; + } + + // only bind association table currently + public Table bind() { + //logicalName only accurate for assoc table... + String unquotedOwnerTable =3D StringHelper.unquote( ownerEntityTable ); + String unquotedAssocTable =3D StringHelper.unquote( associatedEntityTabl= e ); + + String logicalName =3D mappings.getNamingStrategy() + .logicalCollectionTableName( + name, + unquotedOwnerTable, + unquotedAssocTable, + propertyName ); + if ( StringHelper.isQuoted( ownerEntityTable ) || StringHelper.isQuoted(= associatedEntityTable ) ) { + logicalName =3D StringHelper.quote( logicalName ); + } + String extendedName; + if ( name !=3D null ) { + extendedName =3D mappings.getNamingStrategy().tableName( name ); + } + else { + extendedName =3D mappings.getNamingStrategy() + .collectionTableName( + ownerEntity, + unquotedOwnerTable, + associatedEntity, + unquotedAssocTable, + propertyName + ); + if ( StringHelper.isQuoted( ownerEntityTable ) || StringHelper.isQuoted= ( associatedEntityTable ) ) { + extendedName =3D StringHelper.quote( extendedName ); + } + } + return fillTable( + schema, catalog, + extendedName, logicalName, isAbstract, uniqueConstraints, constraints, + denormalizedSuperTable, mappings + ); + } + + public static Table fillTable( + String schema, String catalog, String realTableName, String logicalName= , boolean isAbstract, + List uniqueConstraints, String constraints, Table denormalizedSuperTabl= e, ExtendedMappings mappings + ) { + schema =3D BinderHelper.isDefault( schema ) ? mappings.getSchemaName() := schema; + catalog =3D BinderHelper.isDefault( catalog ) ? mappings.getCatalogName(= ) : catalog; + Table table; + if ( denormalizedSuperTable !=3D null ) { + table =3D mappings.addDenormalizedTable( + schema, + catalog, + realTableName, + isAbstract, + null, //subselect + denormalizedSuperTable + ); + } + else { + table =3D mappings.addTable( + schema, + catalog, + realTableName, + null, //subselect + isAbstract + ); + } + if ( uniqueConstraints !=3D null && uniqueConstraints.size() > 0 ) { + mappings.addUniqueConstraints( table, uniqueConstraints ); + } + if ( constraints !=3D null ) table.addCheckConstraint( constraints ); + //logicalName is null if we are in the second pass + if ( logicalName !=3D null ) { + mappings.addTableBinding( schema, catalog, logicalName, realTableName, = denormalizedSuperTable ); + } + return table; + } + + public static void bindFk( + PersistentClass referencedEntity, PersistentClass destinationEntity, Ej= b3JoinColumn[] columns, + SimpleValue value, + boolean unique, ExtendedMappings mappings + ) { + PersistentClass associatedClass; + if ( destinationEntity !=3D null ) { + //overidden destination + associatedClass =3D destinationEntity; + } + else { + associatedClass =3D columns[0].getPropertyHolder() =3D=3D null ? null := columns[0].getPropertyHolder() + .getPersistentClass(); + } + final String mappedByProperty =3D columns[0].getMappedBy(); + if ( StringHelper.isNotEmpty( mappedByProperty ) ) { + /** + * Get the columns of the mapped-by property + * copy them and link the copy to the actual value + */ + log.debug("Retrieving property {}.{}", associatedClass.getEntityName(),= mappedByProperty); + + final Property property =3D associatedClass.getRecursiveProperty( colum= ns[0].getMappedBy() ); + Iterator mappedByColumns; + if ( property.getValue() instanceof Collection ) { + Collection collection =3D ( (Collection) property.getValue() ); + Value element =3D collection.getElement(); + if ( element =3D=3D null ) { + throw new AnnotationException( + "Illegal use of mappedBy on both sides of the relationship: " + + associatedClass.getEntityName() + "." + mappedByProperty + ); + } + mappedByColumns =3D element.getColumnIterator(); + } + else { + mappedByColumns =3D property.getValue().getColumnIterator(); + } + while ( mappedByColumns.hasNext() ) { + Column column =3D (Column) mappedByColumns.next(); + columns[0].overrideFromReferencedColumnIfNecessary( column ); + columns[0].linkValueUsingAColumnCopy( column, value ); + } + } + else if ( columns[0].isImplicit() ) { + /** + * if columns are implicit, then create the columns based on the + * referenced entity id columns + */ + Iterator idColumns; + if ( referencedEntity instanceof JoinedSubclass ) { + idColumns =3D ( (JoinedSubclass) referencedEntity ).getKey().getColumn= Iterator(); + } + else { + idColumns =3D referencedEntity.getIdentifier().getColumnIterator(); + } + while ( idColumns.hasNext() ) { + Column column =3D (Column) idColumns.next(); + columns[0].overrideFromReferencedColumnIfNecessary( column ); + columns[0].linkValueUsingDefaultColumnNaming( column, referencedEntity= , value ); + } + } + else { + int fkEnum =3D Ejb3JoinColumn.checkReferencedColumnsType( columns, refe= rencedEntity, mappings ); + + if ( Ejb3JoinColumn.NON_PK_REFERENCE =3D=3D fkEnum ) { + String referencedPropertyName; + if ( value instanceof ToOne ) { + referencedPropertyName =3D ( (ToOne) value ).getReferencedPropertyNam= e(); + } + else if ( value instanceof DependantValue ) { + String propertyName =3D columns[0].getPropertyName(); + if ( propertyName !=3D null ) { + Collection collection =3D (Collection) referencedEntity.getRecursive= Property( propertyName ) + .getValue(); + referencedPropertyName =3D collection.getReferencedPropertyName(); + } + else { + throw new AnnotationException( "SecondaryTable JoinColumn cannot ref= erence a non primary key" ); + } + + } + else { + throw new AssertionFailure( + "Do a property ref on an unexpected Value type: " + + value.getClass().getName() + ); + } + if ( referencedPropertyName =3D=3D null ) { + throw new AssertionFailure( + "No property ref found while expected" + ); + } + Property synthProp =3D referencedEntity.getRecursiveProperty( referenc= edPropertyName ); + if ( synthProp =3D=3D null ) { + throw new AssertionFailure( + "Cannot find synthProp: " + referencedEntity.getEntityName() + "." = + referencedPropertyName + ); + } + linkJoinColumnWithValueOverridingNameIfImplicit( + referencedEntity, synthProp.getColumnIterator(), columns, value + ); + + } + else { + if ( Ejb3JoinColumn.NO_REFERENCE =3D=3D fkEnum ) { + //implicit case, we hope PK and FK columns are in the same order + if ( columns.length !=3D referencedEntity.getIdentifier().getColumnSp= an() ) { + throw new AnnotationException( + "A Foreign key refering " + referencedEntity.getEntityName() + + " from " + associatedClass.getEntityName() + + " has the wrong number of column. should be " + referencedEnti= ty.getIdentifier() + .getColumnSpan() + ); + } + linkJoinColumnWithValueOverridingNameIfImplicit( + referencedEntity, + referencedEntity.getIdentifier().getColumnIterator(), + columns, + value + ); + } + else { + //explicit referencedColumnName + Iterator idColItr =3D referencedEntity.getKey().getColumnIterator(); + org.hibernate.mapping.Column col; + Table table =3D referencedEntity.getTable(); //works cause the pk has= to be on the primary table + if ( !idColItr.hasNext() ) log.debug( "No column in the identifier!" = ); + while ( idColItr.hasNext() ) { + boolean match =3D false; + //for each PK column, find the associated FK column. + col =3D (org.hibernate.mapping.Column) idColItr.next(); + for (Ejb3JoinColumn joinCol : columns) { + String referencedColumn =3D joinCol.getReferencedColumn(); + referencedColumn =3D mappings.getPhysicalColumnName( referencedColu= mn, table ); + if ( referencedColumn.equals( col.getName() ) ) { + //proper join column + if ( joinCol.isNameDeferred() ) { + joinCol.linkValueUsingDefaultColumnNaming( + col, referencedEntity, value + ); + } + else { + joinCol.linkWithValue( value ); + } + joinCol.overrideFromReferencedColumnIfNecessary( col ); + match =3D true; + break; + } + } + if ( !match ) { + throw new AnnotationException( + "Column name " + col.getName() + " of " + + referencedEntity.getEntityName() + " not found in JoinColumns= .referencedColumnName" + ); + } + } + } + } + } + value.createForeignKey(); + if ( unique =3D=3D true ) { + createUniqueConstraint( value ); + } + } + + private static void linkJoinColumnWithValueOverridingNameIfImplicit( + PersistentClass referencedEntity, Iterator columnIterator, Ejb3JoinColu= mn[] columns, SimpleValue value + ) { = + for (Ejb3JoinColumn joinCol : columns) { + Column synthCol =3D (Column) columnIterator.next(); = + if ( joinCol.isNameDeferred() ) { + //this has to be the default value + joinCol.linkValueUsingDefaultColumnNaming( synthCol, referencedEntity,= value ); + } + else { + joinCol.linkWithValue( value ); + joinCol.overrideFromReferencedColumnIfNecessary( synthCol ); + } + } + } + + public static void createUniqueConstraint(Value value) { + Iterator iter =3D value.getColumnIterator(); + ArrayList cols =3D new ArrayList(); + while ( iter.hasNext() ) { + cols.add( iter.next() ); + } + value.getTable().createUniqueKey( cols ); + } + + public static void addIndexes(Table hibTable, Index[] indexes, ExtendedMa= ppings mappings) { + for (Index index : indexes) { + //no need to handle inSecondPass here since it is only called from Enti= tyBinder + mappings.addSecondPass( + new IndexOrUniqueKeySecondPass( hibTable, index.name(), index.columnN= ames(), mappings ) + ); + } + } + + public static List buildUniqueConstraints(UniqueConstraint[] co= nstraintsArray) { + List result =3D new ArrayList(); + if ( constraintsArray.length !=3D 0 ) { + for (UniqueConstraint uc : constraintsArray) { + result.add( uc.columnNames() ); + } + } + return result; + } + + public void setDefaultName( + String ownerEntity, String ownerEntityTable, String associatedEntity, S= tring associatedEntityTable, + String propertyName + ) { + this.ownerEntity =3D ownerEntity; + this.ownerEntityTable =3D ownerEntityTable; + this.associatedEntity =3D associatedEntity; + this.associatedEntityTable =3D associatedEntityTable; + this.propertyName =3D propertyName; + this.name =3D null; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/Version.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/Version.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/Version.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,20 @@ +//$Id: Version.java 15098 2008-08-18 17:54:58Z hardy.ferentschik $ +package org.hibernate.cfg.annotations; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Emmanuel Bernard + */ +public class Version { + public static final String VERSION =3D "3.4.0.GA"; + private static Logger log =3D LoggerFactory.getLogger( Version.class ); + + static { + log.info( "Hibernate Annotations {}", VERSION ); + } + + public static void touch() { + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/reflection/EJB3OverridenAnnotationReader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/reflection/EJB3OverridenAnnotationReader.java = (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/reflection/EJB3OverridenAnnotationReader.java 2009-11-24 21:08:28 UT= C (rev 18050) @@ -0,0 +1,2081 @@ +package org.hibernate.cfg.annotations.reflection; + +import java.beans.Introspector; +import java.lang.annotation.Annotation; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.persistence.AssociationOverride; +import javax.persistence.AssociationOverrides; +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.ColumnResult; +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorType; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Embeddable; +import javax.persistence.Embedded; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.EntityListeners; +import javax.persistence.EntityResult; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.ExcludeDefaultListeners; +import javax.persistence.ExcludeSuperclassListeners; +import javax.persistence.FetchType; +import javax.persistence.FieldResult; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.JoinTable; +import javax.persistence.Lob; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.MapKey; +import javax.persistence.MappedSuperclass; +import javax.persistence.NamedNativeQueries; +import javax.persistence.NamedNativeQuery; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.OrderBy; +import javax.persistence.PostLoad; +import javax.persistence.PostPersist; +import javax.persistence.PostRemove; +import javax.persistence.PostUpdate; +import javax.persistence.PrePersist; +import javax.persistence.PreRemove; +import javax.persistence.PreUpdate; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.PrimaryKeyJoinColumns; +import javax.persistence.QueryHint; +import javax.persistence.SecondaryTable; +import javax.persistence.SecondaryTables; +import javax.persistence.SequenceGenerator; +import javax.persistence.SqlResultSetMapping; +import javax.persistence.SqlResultSetMappings; +import javax.persistence.Table; +import javax.persistence.TableGenerator; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import javax.persistence.UniqueConstraint; +import javax.persistence.Version; + +import org.dom4j.Attribute; +import org.dom4j.Element; +import org.hibernate.AnnotationException; +import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.CollectionOfElements; +import org.hibernate.annotations.Columns; +import org.hibernate.annotations.common.annotationfactory.AnnotationDescri= ptor; +import org.hibernate.annotations.common.annotationfactory.AnnotationFactor= y; +import org.hibernate.annotations.common.reflection.AnnotationReader; +import org.hibernate.annotations.common.reflection.Filter; +import org.hibernate.annotations.common.reflection.ReflectionUtil; +import org.hibernate.util.ReflectHelper; +import org.hibernate.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Encapsulates the overriding of Java annotations from an EJB 3.0 descrip= tor. + * + * @author Paolo Perrotta + * @author Davide Marchignoli + * @author Emmanuel Bernard + */ +(a)SuppressWarnings("unchecked") +public class EJB3OverridenAnnotationReader implements AnnotationReader { + private Logger log =3D LoggerFactory.getLogger( EJB3OverridenAnnotationRe= ader.class ); + private static final Map annotationToXml; + private static final String SCHEMA_VALIDATION =3D "Activate schema valida= tion for more informations"; + private static final Filter FILTER =3D new Filter() { + public boolean returnStatic() { + return false; + } + + public boolean returnTransient() { + return false; + } + }; + + static { + annotationToXml =3D new HashMap(); + annotationToXml.put( Entity.class, "entity" ); + annotationToXml.put( MappedSuperclass.class, "mapped-superclass" ); + annotationToXml.put( Embeddable.class, "embeddable" ); + annotationToXml.put( Table.class, "table" ); + annotationToXml.put( SecondaryTable.class, "secondary-table" ); + annotationToXml.put( SecondaryTables.class, "secondary-table" ); + annotationToXml.put( PrimaryKeyJoinColumn.class, "primary-key-join-colum= n" ); + annotationToXml.put( PrimaryKeyJoinColumns.class, "primary-key-join-colu= mn" ); + annotationToXml.put( IdClass.class, "id-class" ); + annotationToXml.put( Inheritance.class, "inheritance" ); + annotationToXml.put( DiscriminatorValue.class, "discriminator-value" ); + annotationToXml.put( DiscriminatorColumn.class, "discriminator-column" ); + annotationToXml.put( SequenceGenerator.class, "sequence-generator" ); + annotationToXml.put( TableGenerator.class, "table-generator" ); + annotationToXml.put( NamedQuery.class, "named-query" ); + annotationToXml.put( NamedQueries.class, "named-query" ); + annotationToXml.put( NamedNativeQuery.class, "named-native-query" ); + annotationToXml.put( NamedNativeQueries.class, "named-native-query" ); + annotationToXml.put( SqlResultSetMapping.class, "sql-result-set-mapping"= ); + annotationToXml.put( SqlResultSetMappings.class, "sql-result-set-mapping= " ); + annotationToXml.put( ExcludeDefaultListeners.class, "exclude-default-lis= teners" ); + annotationToXml.put( ExcludeSuperclassListeners.class, "exclude-supercla= ss-listeners" ); + annotationToXml.put( AccessType.class, "access" ); + annotationToXml.put( AttributeOverride.class, "attribute-override" ); + annotationToXml.put( AttributeOverrides.class, "attribute-override" ); + annotationToXml.put( AttributeOverride.class, "association-override" ); + annotationToXml.put( AttributeOverrides.class, "association-override" ); + annotationToXml.put( Id.class, "id" ); + annotationToXml.put( EmbeddedId.class, "embedded-id" ); + annotationToXml.put( GeneratedValue.class, "generated-value" ); + annotationToXml.put( Column.class, "column" ); + annotationToXml.put( Columns.class, "column" ); + annotationToXml.put( Temporal.class, "temporal" ); + annotationToXml.put( Lob.class, "lob" ); + annotationToXml.put( Enumerated.class, "enumerated" ); + annotationToXml.put( Version.class, "version" ); + annotationToXml.put( Transient.class, "transient" ); + annotationToXml.put( Basic.class, "basic" ); + annotationToXml.put( Embedded.class, "embedded" ); + annotationToXml.put( ManyToOne.class, "many-to-one" ); + annotationToXml.put( OneToOne.class, "one-to-one" ); + annotationToXml.put( OneToMany.class, "one-to-many" ); + annotationToXml.put( ManyToMany.class, "many-to-many" ); + annotationToXml.put( JoinTable.class, "join-table" ); + annotationToXml.put( JoinColumn.class, "join-column" ); + annotationToXml.put( JoinColumns.class, "join-column" ); + annotationToXml.put( MapKey.class, "map-key" ); + annotationToXml.put( OrderBy.class, "order-by" ); + annotationToXml.put( EntityListeners.class, "entity-listeners" ); + annotationToXml.put( PrePersist.class, "pre-persist" ); + annotationToXml.put( PreRemove.class, "pre-remove" ); + annotationToXml.put( PreUpdate.class, "pre-update" ); + annotationToXml.put( PostPersist.class, "post-persist" ); + annotationToXml.put( PostRemove.class, "post-remove" ); + annotationToXml.put( PostUpdate.class, "post-update" ); + annotationToXml.put( PostLoad.class, "post-load" ); + } + + private XMLContext xmlContext; + private String className; + private String propertyName; + private PropertyType propertyType; + private transient Annotation[] annotations; + private transient Map annotationsMap; + private static final String WORD_SEPARATOR =3D "-"; + private transient List elementsForProperty; + private AccessibleObject mirroredAttribute; + private final AnnotatedElement element; + + private enum PropertyType { + PROPERTY, + FIELD, + METHOD + } + + public EJB3OverridenAnnotationReader(AnnotatedElement el, XMLContext xmlC= ontext) { + this.element =3D el; + this.xmlContext =3D xmlContext; + if ( el instanceof Class ) { + Class clazz =3D (Class) el; + className =3D clazz.getName(); + } + else if ( el instanceof Field ) { + Field field =3D (Field) el; + className =3D field.getDeclaringClass().getName(); + propertyName =3D field.getName(); + propertyType =3D PropertyType.FIELD; + String expectedGetter =3D "get" + Character.toUpperCase( propertyName.c= harAt( 0 ) ) + propertyName.substring( + 1 + ); + try { + mirroredAttribute =3D field.getDeclaringClass().getDeclaredMethod( exp= ectedGetter ); + } + catch (NoSuchMethodException e) { + //no method + } + } + else if ( el instanceof Method ) { + Method method =3D (Method) el; + className =3D method.getDeclaringClass().getName(); + propertyName =3D method.getName(); + if ( ReflectionUtil.isProperty( + method, + null, //this is yukky!! we'd rather get the TypeEnvironment() + FILTER + ) ) { + if ( propertyName.startsWith( "get" ) ) { + propertyName =3D Introspector.decapitalize( propertyName.substring( "= get".length() ) ); + } + else if ( propertyName.startsWith( "is" ) ) { + propertyName =3D Introspector.decapitalize( propertyName.substring( "= is".length() ) ); + } + else { + throw new RuntimeException( "Method " + propertyName + " is not a pro= perty getter" ); + } + propertyType =3D PropertyType.PROPERTY; + try { + mirroredAttribute =3D method.getDeclaringClass().getDeclaredField( pr= opertyName ); + } + catch (NoSuchFieldException e) { + //no method + } + } + else { + propertyType =3D PropertyType.METHOD; + } + } + else { + className =3D null; + propertyName =3D null; + } + } + + public T getAnnotation(Class annotationType) { + initAnnotations(); + return (T) annotationsMap.get( annotationType ); + } + + public boolean isAnnotationPresent(Class annota= tionType) { + initAnnotations(); + return (T) annotationsMap.get( annotationType ) !=3D null; + } + + public Annotation[] getAnnotations() { + initAnnotations(); + return annotations; + } + + private void initAnnotations() { + if ( annotations =3D=3D null ) { + XMLContext.Default defaults =3D xmlContext.getDefault( className ); + if ( className !=3D null && propertyName =3D=3D null ) { + //is a class + Element tree =3D xmlContext.getXMLTree( className, null ); + Annotation[] annotations =3D getJavaAnnotations(); + List annotationList =3D new ArrayList( annotat= ions.length + 5 ); + annotationsMap =3D new HashMap( annotations.length = + 5 ); + for (Annotation annotation : annotations) { + if ( !annotationToXml.containsKey( annotation.annotationType() ) ) { + //unknown annotations are left over + annotationList.add( annotation ); + } + } + addIfNotNull( annotationList, getEntity( tree, defaults ) ); + addIfNotNull( annotationList, getMappedSuperclass( tree, defaults ) ); + addIfNotNull( annotationList, getEmbeddable( tree, defaults ) ); + addIfNotNull( annotationList, getTable( tree, defaults ) ); + addIfNotNull( annotationList, getSecondaryTables( tree, defaults ) ); + addIfNotNull( annotationList, getPrimaryKeyJoinColumns( tree, defaults= ) ); + addIfNotNull( annotationList, getIdClass( tree, defaults ) ); + addIfNotNull( annotationList, getInheritance( tree, defaults ) ); + addIfNotNull( annotationList, getDiscriminatorValue( tree, defaults ) = ); + addIfNotNull( annotationList, getDiscriminatorColumn( tree, defaults )= ); + addIfNotNull( annotationList, getSequenceGenerator( tree, defaults ) ); + addIfNotNull( annotationList, getTableGenerator( tree, defaults ) ); + addIfNotNull( annotationList, getNamedQueries( tree, defaults ) ); + addIfNotNull( annotationList, getNamedNativeQueries( tree, defaults ) = ); + addIfNotNull( annotationList, getSqlResultSetMappings( tree, defaults = ) ); + addIfNotNull( annotationList, getExcludeDefaultListeners( tree, defaul= ts ) ); + addIfNotNull( annotationList, getExcludeSuperclassListeners( tree, def= aults ) ); + addIfNotNull( annotationList, getAccessType( tree, defaults ) ); + addIfNotNull( annotationList, getAttributeOverrides( tree, defaults ) = ); + addIfNotNull( annotationList, getAssociationOverrides( tree, defaults = ) ); + addIfNotNull( annotationList, getEntityListeners( tree, defaults ) ); + //FIXME use annotationsMap rather than annotationList this will be fas= ter since the annotation type is usually known at put() time + this.annotations =3D annotationList.toArray( new Annotation[annotation= List.size()] ); + for (Annotation ann : this.annotations) { + annotationsMap.put( ann.annotationType(), ann ); + } + checkForOrphanProperties( tree ); + } + else if ( className !=3D null ) { //&& propertyName !=3D null ) { //alw= ays true but less confusing + Element tree =3D xmlContext.getXMLTree( className, propertyName ); + Annotation[] annotations =3D getJavaAnnotations(); + List annotationList =3D new ArrayList( annotat= ions.length + 5 ); + annotationsMap =3D new HashMap( annotations.length = + 5 ); + for (Annotation annotation : annotations) { + if ( !annotationToXml.containsKey( annotation.annotationType() ) ) { + //unknown annotations are left over + annotationList.add( annotation ); + } + } + preCalculateElementsForProperty( tree ); + Transient transientAnn =3D getTransient( defaults ); + if ( transientAnn !=3D null ) { + annotationList.add( transientAnn ); + } + else { + if ( defaults.canUseJavaAnnotations() ) { + Annotation annotation =3D getJavaAnnotation( AccessType.class ); + addIfNotNull( annotationList, annotation ); + } + getId( annotationList, defaults ); + getEmbeddedId( annotationList, defaults ); + getEmbedded( annotationList, defaults ); + getBasic( annotationList, defaults ); + getVersion( annotationList, defaults ); + getAssociation( ManyToOne.class, annotationList, defaults ); + getAssociation( OneToOne.class, annotationList, defaults ); + getAssociation( OneToMany.class, annotationList, defaults ); + getAssociation( ManyToMany.class, annotationList, defaults ); + addIfNotNull( annotationList, getSequenceGenerator( elementsForProper= ty, defaults ) ); + addIfNotNull( annotationList, getTableGenerator( elementsForProperty,= defaults ) ); + addIfNotNull( annotationList, getAttributeOverrides( elementsForPrope= rty, defaults ) ); + + } + processEventAnnotations( annotationList, defaults ); + //FIXME use annotationsMap rather than annotationList this will be fas= ter since the annotation type is usually known at put() time + this.annotations =3D annotationList.toArray( new Annotation[annotation= List.size()] ); + for (Annotation ann : this.annotations) { + annotationsMap.put( ann.annotationType(), ann ); + } + } + else { + this.annotations =3D getJavaAnnotations(); + annotationsMap =3D new HashMap( annotations.length = + 5 ); + for (Annotation ann : this.annotations) { + annotationsMap.put( ann.annotationType(), ann ); + } + } + } + } + + private void checkForOrphanProperties(Element tree) { + Class clazz; + try { + clazz =3D ReflectHelper.classForName( className, this.getClass() ); + } + catch (ClassNotFoundException e) { + return; //a primitive type most likely + } + Element element =3D tree !=3D null ? tree.element( "attributes" ) : null; + //put entity.attributes elements + if ( element !=3D null ) { + //precompute the list of properties + //TODO is it really useful... + Set properties =3D new HashSet(); + for (Field field : clazz.getFields()) { + properties.add( field.getName() ); + } + for (Method method : clazz.getMethods()) { + String name =3D method.getName(); + if ( name.startsWith( "get" ) ) { + properties.add( Introspector.decapitalize( name.substring( "get".leng= th() ) ) ); + } + else if ( name.startsWith( "is" ) ) { + properties.add( Introspector.decapitalize( name.substring( "is".lengt= h() ) ) ); + } + } + for (Element subelement : (List) element.elements()) { + String propertyName =3D subelement.attributeValue( "name" ); + if ( !properties.contains( propertyName ) ) { + log.warn( "Property {} not found in class" + + " but described in (possible typo error)", + StringHelper.qualify( className, propertyName ) ); + } + } + } + } + + /** + * Addes the Annotation to the list (only if it's not null) and then retu= rns it. + */ + private Annotation addIfNotNull(List annotationList, Annotati= on element) { + if ( element !=3D null ) { + annotationList.add( element ); + } + return element; + } + + //TODO mutualize the next 2 methods + private Annotation getTableGenerator(List elementsForProperty, X= MLContext.Default defaults) { + for (Element element : elementsForProperty) { + Element subelement =3D element !=3D null ? element.element( annotationT= oXml.get( TableGenerator.class ) ) : null; + if ( subelement !=3D null ) { + return buildTableGeneratorAnnotation( subelement, defaults ); + } + } + if ( elementsForProperty.size() =3D=3D 0 && defaults.canUseJavaAnnotatio= ns() ) { + return getJavaAnnotation( TableGenerator.class ); + } + else { + return null; + } + } + + + private Annotation getSequenceGenerator(List elementsForProperty= , XMLContext.Default defaults) { + for (Element element : elementsForProperty) { + Element subelement =3D element !=3D null ? element.element( annotationT= oXml.get( SequenceGenerator.class ) ) : null; + if ( subelement !=3D null ) { + return buildSequenceGeneratorAnnotation( subelement ); + } + } + if ( elementsForProperty.size() =3D=3D 0 && defaults.canUseJavaAnnotatio= ns() ) { + return getJavaAnnotation( SequenceGenerator.class ); + } + else { + return null; + } + } + + private void processEventAnnotations(List annotationList, XML= Context.Default defaults) { + boolean eventElement =3D false; + for (Element element : elementsForProperty) { + String elementName =3D element.getName(); + if ( "pre-persist".equals( elementName ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( PrePersist.class= ); + annotationList.add( AnnotationFactory.create( ad ) ); + eventElement =3D true; + } + else if ( "pre-remove".equals( elementName ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( PreRemove.class = ); + annotationList.add( AnnotationFactory.create( ad ) ); + eventElement =3D true; + } + else if ( "pre-update".equals( elementName ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( PreUpdate.class = ); + annotationList.add( AnnotationFactory.create( ad ) ); + eventElement =3D true; + } + else if ( "post-persist".equals( elementName ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( PostPersist.clas= s ); + annotationList.add( AnnotationFactory.create( ad ) ); + eventElement =3D true; + } + else if ( "post-remove".equals( elementName ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( PostRemove.class= ); + annotationList.add( AnnotationFactory.create( ad ) ); + eventElement =3D true; + } + else if ( "post-update".equals( elementName ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( PostUpdate.class= ); + annotationList.add( AnnotationFactory.create( ad ) ); + eventElement =3D true; + } + else if ( "post-load".equals( elementName ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( PostLoad.class ); + annotationList.add( AnnotationFactory.create( ad ) ); + eventElement =3D true; + } + } + if ( !eventElement && defaults.canUseJavaAnnotations() ) { + Annotation ann =3D getJavaAnnotation( PrePersist.class ); + addIfNotNull( annotationList, ann ); + ann =3D getJavaAnnotation( PreRemove.class ); + addIfNotNull( annotationList, ann ); + ann =3D getJavaAnnotation( PreUpdate.class ); + addIfNotNull( annotationList, ann ); + ann =3D getJavaAnnotation( PostPersist.class ); + addIfNotNull( annotationList, ann ); + ann =3D getJavaAnnotation( PostRemove.class ); + addIfNotNull( annotationList, ann ); + ann =3D getJavaAnnotation( PostUpdate.class ); + addIfNotNull( annotationList, ann ); + ann =3D getJavaAnnotation( PostLoad.class ); + addIfNotNull( annotationList, ann ); + } + } + + private EntityListeners getEntityListeners(Element tree, XMLContext.Defau= lt defaults) { + Element element =3D tree !=3D null ? tree.element( "entity-listeners" ) = : null; + if ( element !=3D null ) { + List entityListenerClasses =3D new ArrayList(); + for (Element subelement : (List) element.elements( "entity-lis= tener" )) { + String className =3D subelement.attributeValue( "class" ); + try { + entityListenerClasses.add( + ReflectHelper.classForName( + XMLContext.buildSafeClassName( className, defaults ), + this.getClass() + ) + ); + } + catch (ClassNotFoundException e) { + throw new AnnotationException( + "Unable to find " + element.getPath() + ".class: " + className, e + ); + } + } + AnnotationDescriptor ad =3D new AnnotationDescriptor( EntityListeners.c= lass ); + ad.setValue( "value", entityListenerClasses.toArray( new Class[entityLi= stenerClasses.size()] ) ); + return AnnotationFactory.create( ad ); + } + else if ( defaults.canUseJavaAnnotations() ) { + return getJavaAnnotation( EntityListeners.class ); + } + else { + return null; + } + } + + private JoinTable overridesDefaultsInJoinTable(Annotation annotation, XML= Context.Default defaults) { + //no element but might have some default or some annotation + boolean defaultToJoinTable =3D !( isJavaAnnotationPresent( JoinColumn.cl= ass ) + || isJavaAnnotationPresent( JoinColumns.class ) ); + final Class annotationClass =3D annotation.annotat= ionType(); + defaultToJoinTable =3D defaultToJoinTable && + ( ( annotationClass =3D=3D ManyToMany.class && StringHelper.isEmpty( (= (ManyToMany) annotation ).mappedBy() ) ) + || ( annotationClass =3D=3D OneToMany.class && StringHelper.isEmpty(= ( (OneToMany) annotation ).mappedBy() ) ) + || ( annotationClass =3D=3D CollectionOfElements.class ) + ); + final Class annotationType =3D JoinTable.class; + if ( defaultToJoinTable + && ( StringHelper.isNotEmpty( defaults.getCatalog() ) + || StringHelper.isNotEmpty( defaults.getSchema() ) ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( annotationType ); + if ( defaults.canUseJavaAnnotations() ) { + JoinTable table =3D getJavaAnnotation( annotationType ); + if ( table !=3D null ) { + ad.setValue( "name", table.name() ); + ad.setValue( "schema", table.schema() ); + ad.setValue( "catalog", table.catalog() ); + ad.setValue( "uniqueConstraints", table.uniqueConstraints() ); + ad.setValue( "joinColumns", table.joinColumns() ); + ad.setValue( "inverseJoinColumns", table.inverseJoinColumns() ); + } + } + if ( StringHelper.isEmpty( (String) ad.valueOf( "schema" ) ) + && StringHelper.isNotEmpty( defaults.getSchema() ) ) { + ad.setValue( "schema", defaults.getSchema() ); + } + if ( StringHelper.isEmpty( (String) ad.valueOf( "catalog" ) ) + && StringHelper.isNotEmpty( defaults.getCatalog() ) ) { + ad.setValue( "catalog", defaults.getCatalog() ); + } + return AnnotationFactory.create( ad ); + } + else if ( defaults.canUseJavaAnnotations() ) { + return getJavaAnnotation( annotationType ); + } + else { + return null; + } + } + + /* + * no partial overriding possible + */ + private void getJoinTable(List annotationList, Element tree, = XMLContext.Default defaults) { + Element subelement =3D tree =3D=3D null ? null : tree.element( "join-tab= le" ); + final Class annotationType =3D JoinTable.class; + if ( subelement !=3D null ) { + //ignore java annotation, an element is defined + AnnotationDescriptor annotation =3D new AnnotationDescriptor( annotatio= nType ); + copyStringAttribute( annotation, subelement, "name", false ); + copyStringAttribute( annotation, subelement, "catalog", false ); + if ( StringHelper.isNotEmpty( defaults.getCatalog() ) + && StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) )= { + annotation.setValue( "catalog", defaults.getCatalog() ); + } + copyStringAttribute( annotation, subelement, "schema", false ); + if ( StringHelper.isNotEmpty( defaults.getSchema() ) + && StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) ) { + annotation.setValue( "schema", defaults.getSchema() ); + } + buildUniqueConstraints( annotation, subelement ); + annotation.setValue( "joinColumns", getJoinColumns( subelement, false )= ); + annotation.setValue( "inverseJoinColumns", getJoinColumns( subelement, = true ) ); + annotationList.add( AnnotationFactory.create( annotation ) ); + } + } + + private void getAssociation( + Class annotationType, List annotation= List, XMLContext.Default defaults + ) { + String xmlName =3D annotationToXml.get( annotationType ); + for (Element element : elementsForProperty) { + if ( xmlName.equals( element.getName() ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( annotationType ); + String className =3D element.attributeValue( "target-entity" ); + if ( className !=3D null ) { + Class clazz; + try { + clazz =3D ReflectHelper.classForName( + XMLContext.buildSafeClassName( className, defaults ), + this.getClass() + ); + } + catch (ClassNotFoundException e) { + throw new AnnotationException( + "Unable to find " + element.getPath() + "target-entity: " + classN= ame, e + ); + } + ad.setValue( "targetEntity", clazz ); + } + getFetchType( ad, element ); + getCascades( ad, element, defaults ); + getJoinTable( annotationList, element, defaults ); + buildJoinColumns( annotationList, element, defaults ); + Annotation annotation =3D getPrimaryKeyJoinColumns( element, defaults = ); + addIfNotNull( annotationList, annotation ); + copyBooleanAttribute( ad, element, "optional" ); + copyStringAttribute( ad, element, "mapped-by", false ); + getOrderBy( annotationList, element, defaults ); + getMapKey( annotationList, element, defaults ); + annotationList.add( AnnotationFactory.create( ad ) ); + } + } + if ( elementsForProperty.size() =3D=3D 0 && defaults.canUseJavaAnnotatio= ns() ) { + Annotation annotation =3D getJavaAnnotation( annotationType ); + if ( annotation !=3D null ) { + annotationList.add( annotation ); + annotation =3D overridesDefaultsInJoinTable( annotation, defaults ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( JoinColumn.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( JoinColumns.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( PrimaryKeyJoinColumn.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( PrimaryKeyJoinColumns.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( MapKey.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( OrderBy.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverrides.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverrides.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Lob.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Enumerated.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Temporal.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Column.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Columns.class ); + addIfNotNull( annotationList, annotation ); + } + else if ( isJavaAnnotationPresent( CollectionOfElements.class ) ) { + annotation =3D overridesDefaultsInJoinTable( getJavaAnnotation( Collec= tionOfElements.class ), defaults ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( JoinColumn.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( JoinColumns.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( PrimaryKeyJoinColumn.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( PrimaryKeyJoinColumns.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( MapKey.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( OrderBy.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverrides.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverrides.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Lob.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Enumerated.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Temporal.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Column.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Columns.class ); + addIfNotNull( annotationList, annotation ); + } + } + } + + private void getOrderBy(List annotationList, Element element,= XMLContext.Default defaults) { + Element subelement =3D element !=3D null ? element.element( "order-by" )= : null; + if ( subelement !=3D null ) { + String orderByString =3D subelement.getTextTrim(); + AnnotationDescriptor ad =3D new AnnotationDescriptor( OrderBy.class ); + if ( StringHelper.isNotEmpty( orderByString ) ) ad.setValue( "value", o= rderByString ); + annotationList.add( AnnotationFactory.create( ad ) ); + } + } + + private void getMapKey(List annotationList, Element element, = XMLContext.Default defaults) { + Element subelement =3D element !=3D null ? element.element( "map-key" ) = : null; + if ( subelement !=3D null ) { + String mapKeyString =3D subelement.attributeValue( "name" ); + AnnotationDescriptor ad =3D new AnnotationDescriptor( MapKey.class ); + if ( StringHelper.isNotEmpty( mapKeyString ) ) ad.setValue( "name", map= KeyString ); + annotationList.add( AnnotationFactory.create( ad ) ); + } + } + + private void buildJoinColumns(List annotationList, Element el= ement, XMLContext.Default defaults) { + JoinColumn[] joinColumns =3D getJoinColumns( element, false ); + if ( joinColumns.length > 0 ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( JoinColumns.class= ); + ad.setValue( "value", joinColumns ); + annotationList.add( AnnotationFactory.create( ad ) ); + } + } + + private void getCascades(AnnotationDescriptor ad, Element element, XMLCon= text.Default defaults) { + List elements =3D element !=3D null ? element.elements( "cascad= e" ) : new ArrayList( 0 ); + List cascades =3D new ArrayList(); + for (Element subelement : elements) { + if ( subelement.element( "cascade-all" ) !=3D null ) cascades.add( Casc= adeType.ALL ); + if ( subelement.element( "cascade-persist" ) !=3D null ) cascades.add( = CascadeType.PERSIST ); + if ( subelement.element( "cascade-merge" ) !=3D null ) cascades.add( Ca= scadeType.MERGE ); + if ( subelement.element( "cascade-remove" ) !=3D null ) cascades.add( C= ascadeType.REMOVE ); + if ( subelement.element( "cascade-refresh" ) !=3D null ) cascades.add( = CascadeType.REFRESH ); + } + if ( Boolean.TRUE.equals( defaults.getCascadePersist() ) + && !cascades.contains( CascadeType.ALL ) && !cascades.contains( Cascad= eType.PERSIST ) ) { + cascades.add( CascadeType.PERSIST ); + } + if ( cascades.size() > 0 ) { + ad.setValue( "cascade", cascades.toArray( new CascadeType[cascades.size= ()] ) ); + } + } + + private void getEmbedded(List annotationList, XMLContext.Defa= ult defaults) { + for (Element element : elementsForProperty) { + if ( "embedded".equals( element.getName() ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( Embedded.class ); + annotationList.add( AnnotationFactory.create( ad ) ); + } + } + if ( elementsForProperty.size() =3D=3D 0 && defaults.canUseJavaAnnotatio= ns() ) { + Annotation annotation =3D getJavaAnnotation( Embedded.class ); + if ( annotation !=3D null ) { + annotationList.add( annotation ); + annotation =3D getJavaAnnotation( AttributeOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverrides.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverrides.class ); + addIfNotNull( annotationList, annotation ); + } + } + } + + private Transient getTransient(XMLContext.Default defaults) { + for (Element element : elementsForProperty) { + if ( "transient".equals( element.getName() ) ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( Transient.class = ); + return AnnotationFactory.create( ad ); + } + } + if ( elementsForProperty.size() =3D=3D 0 && defaults.canUseJavaAnnotatio= ns() ) { + return getJavaAnnotation( Transient.class ); + } + else { + return null; + } + } + + private void getVersion(List annotationList, XMLContext.Defau= lt defaults) { + for (Element element : elementsForProperty) { + if ( "version".equals( element.getName() ) ) { + Annotation annotation =3D buildColumns( element ); + addIfNotNull( annotationList, annotation ); + getTemporal( annotationList, element ); + AnnotationDescriptor basic =3D new AnnotationDescriptor( Version.class= ); + annotationList.add( AnnotationFactory.create( basic ) ); + } + } + if ( elementsForProperty.size() =3D=3D 0 && defaults.canUseJavaAnnotatio= ns() ) { + //we have nothing, so Java annotations might occurs + Annotation annotation =3D getJavaAnnotation( Version.class ); + if ( annotation !=3D null ) { + annotationList.add( annotation ); + annotation =3D getJavaAnnotation( Column.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Columns.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Temporal.class ); + addIfNotNull( annotationList, annotation ); + } + } + } + + private void getBasic(List annotationList, XMLContext.Default= defaults) { + for (Element element : elementsForProperty) { + if ( "basic".equals( element.getName() ) ) { + Annotation annotation =3D buildColumns( element ); + addIfNotNull( annotationList, annotation ); + getTemporal( annotationList, element ); + getLob( annotationList, element ); + getEnumerated( annotationList, element ); + AnnotationDescriptor basic =3D new AnnotationDescriptor( Basic.class ); + getFetchType( basic, element ); + copyBooleanAttribute( basic, element, "optional" ); + annotationList.add( AnnotationFactory.create( basic ) ); + } + } + if ( elementsForProperty.size() =3D=3D 0 && defaults.canUseJavaAnnotatio= ns() ) { + //no annotation presence constraint, basic is the default + Annotation annotation =3D getJavaAnnotation( Basic.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Lob.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Enumerated.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Temporal.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Column.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Columns.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverrides.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverrides.class ); + addIfNotNull( annotationList, annotation ); + } + } + + private void getEnumerated(List annotationList, Element eleme= nt) { + Element subElement =3D element !=3D null ? element.element( "enumerated"= ) : null; + if ( subElement !=3D null ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( Enumerated.class = ); + String enumerated =3D subElement.getTextTrim(); + if ( "ORDINAL".equalsIgnoreCase( enumerated ) ) { + ad.setValue( "value", EnumType.ORDINAL ); + } + else if ( "STRING".equalsIgnoreCase( enumerated ) ) { + ad.setValue( "value", EnumType.STRING ); + } + else if ( StringHelper.isNotEmpty( enumerated ) ) { + throw new AnnotationException( "Unknown EnumType: " + enumerated + ". = " + SCHEMA_VALIDATION ); + } + annotationList.add( AnnotationFactory.create( ad ) ); + } + } + + private void getLob(List annotationList, Element element) { + Element subElement =3D element !=3D null ? element.element( "lob" ) : nu= ll; + if ( subElement !=3D null ) { + annotationList.add( AnnotationFactory.create( new AnnotationDescriptor(= Lob.class ) ) ); + } + } + + private void getFetchType(AnnotationDescriptor descriptor, Element elemen= t) { + String fetchString =3D element !=3D null ? element.attributeValue( "fetc= h" ) : null; + if ( fetchString !=3D null ) { + if ( "eager".equalsIgnoreCase( fetchString ) ) { + descriptor.setValue( "fetch", FetchType.EAGER ); + } + else if ( "lazy".equalsIgnoreCase( fetchString ) ) { + descriptor.setValue( "fetch", FetchType.LAZY ); + } + } + } + + private void getEmbeddedId(List annotationList, XMLContext.De= fault defaults) { + for (Element element : elementsForProperty) { + if ( "embedded-id".equals( element.getName() ) ) { + if ( isProcessingId( defaults ) ) { + Annotation annotation =3D getAttributeOverrides( element, defaults ); + addIfNotNull( annotationList, annotation ); + annotation =3D getAssociationOverrides( element, defaults ); + addIfNotNull( annotationList, annotation ); + AnnotationDescriptor ad =3D new AnnotationDescriptor( EmbeddedId.clas= s ); + annotationList.add( AnnotationFactory.create( ad ) ); + } +// else { +// if ( defaults.canUseJavaAnnotations() ) { +// if ( ! properOverridingOnMetadataNonComplete ) { +// //check that id exists on the other attribute +// //TODO Id too? +// if ( mirroredAttribute =3D=3D null || ! mirroredAttribute.isAnnot= ationPresent( +// EmbeddedId.class +// ) ) { +// throw new AnnotationException( +// "Cannot override an property with not having an = @EmbeddedId already" +// ); +// } +// } +// } +// } + } + } + if ( elementsForProperty.size() =3D=3D 0 && defaults.canUseJavaAnnotatio= ns() ) { + Annotation annotation =3D getJavaAnnotation( EmbeddedId.class ); + if ( annotation !=3D null ) { + annotationList.add( annotation ); + annotation =3D getJavaAnnotation( Column.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Columns.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( GeneratedValue.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Temporal.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( TableGenerator.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( SequenceGenerator.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverrides.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverrides.class ); + addIfNotNull( annotationList, annotation ); + } + } + } + + private void preCalculateElementsForProperty(Element tree) { + elementsForProperty =3D new ArrayList(); + Element element =3D tree !=3D null ? tree.element( "attributes" ) : null; + //put entity.attributes elements + if ( element !=3D null ) { + for (Element subelement : (List) element.elements()) { + if ( propertyName.equals( subelement.attributeValue( "name" ) ) ) { + elementsForProperty.add( subelement ); + } + } + } + //add pre-* etc from entity and pure entity listener classes + if ( tree !=3D null ) { + for (Element subelement : (List) tree.elements()) { + if ( propertyName.equals( subelement.attributeValue( "method-name" ) )= ) { + elementsForProperty.add( subelement ); + } + } + } + } + + private void getId(List annotationList, XMLContext.Default de= faults) { + for (Element element : elementsForProperty) { + if ( "id".equals( element.getName() ) ) { + boolean processId =3D isProcessingId( defaults ); + if ( processId ) { + Annotation annotation =3D buildColumns( element ); + addIfNotNull( annotationList, annotation ); + annotation =3D buildGeneratedValue( element ); + addIfNotNull( annotationList, annotation ); + getTemporal( annotationList, element ); + //FIXME: fix the priority of xml over java for generator names + annotation =3D getTableGenerator( element, defaults ); + addIfNotNull( annotationList, annotation ); + annotation =3D getSequenceGenerator( element, defaults ); + addIfNotNull( annotationList, annotation ); + AnnotationDescriptor id =3D new AnnotationDescriptor( Id.class ); + annotationList.add( AnnotationFactory.create( id ) ); + } +// else { +// if ( defaults.canUseJavaAnnotations() ) { +// if ( ! properOverridingOnMetadataNonComplete ) { +// //check that id exists on the other attribute +// //TODO EmbeddedId too? +// if ( mirroredAttribute =3D=3D null || ! mirroredAttribute.isAnnot= ationPresent( Id.class ) ) { +// throw new AnnotationException( +// "Cannot override a property with it does not have an @Id = already" +// ); +// } +// } +// } +// } + } + } + if ( elementsForProperty.size() =3D=3D 0 && defaults.canUseJavaAnnotatio= ns() ) { + Annotation annotation =3D getJavaAnnotation( Id.class ); + if ( annotation !=3D null ) { + annotationList.add( annotation ); + annotation =3D getJavaAnnotation( Column.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Columns.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( GeneratedValue.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( Temporal.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( TableGenerator.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( SequenceGenerator.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AttributeOverrides.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverride.class ); + addIfNotNull( annotationList, annotation ); + annotation =3D getJavaAnnotation( AssociationOverrides.class ); + addIfNotNull( annotationList, annotation ); + } + } + } + + private boolean isProcessingId(XMLContext.Default defaults) { + boolean isExplicit =3D defaults.getAccess() !=3D null; + boolean correctAccess =3D + ( PropertyType.PROPERTY.equals( propertyType ) && "property".equals( d= efaults.getAccess() ) ) + || ( PropertyType.FIELD.equals( propertyType ) && "field".equals( de= faults.getAccess() ) ); + boolean hasId =3D defaults.canUseJavaAnnotations() + && ( isJavaAnnotationPresent( Id.class ) || isJavaAnnotationPresent( E= mbeddedId.class ) ); + //if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonCo= mplete ) { + boolean mirrorAttributeIsId =3D defaults.canUseJavaAnnotations() && + ( mirroredAttribute !=3D null && + ( mirroredAttribute.isAnnotationPresent( Id.class ) + || mirroredAttribute.isAnnotationPresent( EmbeddedId.class ) ) ); + boolean propertyIsDefault =3D PropertyType.PROPERTY.equals( propertyType= ) + && !mirrorAttributeIsId; + return correctAccess || ( !isExplicit && hasId ) || ( !isExplicit && pro= pertyIsDefault ); + } + + private Columns buildColumns(Element element) { + List subelements =3D element.elements( "column" ); + List columns =3D new ArrayList( subelements.size() ); + for (Element subelement : subelements) { + columns.add( getColumn( subelement, false, element ) ); + } + if ( columns.size() > 0 ) { + AnnotationDescriptor columnsDescr =3D new AnnotationDescriptor( Columns= .class ); + columnsDescr.setValue( "columns", columns.toArray( new Column[columns.s= ize()] ) ); + return AnnotationFactory.create( columnsDescr ); + } + else { + return null; + } + } + + private GeneratedValue buildGeneratedValue(Element element) { + Element subElement =3D element !=3D null ? element.element( "generated-v= alue" ) : null; + if ( subElement !=3D null ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( GeneratedValue.cl= ass ); + String strategy =3D subElement.attributeValue( "strategy" ); + if ( "TABLE".equalsIgnoreCase( strategy ) ) { + ad.setValue( "strategy", GenerationType.TABLE ); + } + else if ( "SEQUENCE".equalsIgnoreCase( strategy ) ) { + ad.setValue( "strategy", GenerationType.SEQUENCE ); + } + else if ( "IDENTITY".equalsIgnoreCase( strategy ) ) { + ad.setValue( "strategy", GenerationType.IDENTITY ); + } + else if ( "AUTO".equalsIgnoreCase( strategy ) ) { + ad.setValue( "strategy", GenerationType.AUTO ); + } + else if ( StringHelper.isNotEmpty( strategy ) ) { + throw new AnnotationException( "Unknown GenerationType: " + strategy += ". " + SCHEMA_VALIDATION ); + } + copyStringAttribute( ad, subElement, "generator", false ); + return AnnotationFactory.create( ad ); + } + else { + return null; + } + } + + private void getTemporal(List annotationList, Element element= ) { + Element subElement =3D element !=3D null ? element.element( "temporal" )= : null; + if ( subElement !=3D null ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( Temporal.class ); + String temporal =3D subElement.getTextTrim(); + if ( "DATE".equalsIgnoreCase( temporal ) ) { + ad.setValue( "value", TemporalType.DATE ); + } + else if ( "TIME".equalsIgnoreCase( temporal ) ) { + ad.setValue( "value", TemporalType.TIME ); + } + else if ( "TIMESTAMP".equalsIgnoreCase( temporal ) ) { + ad.setValue( "value", TemporalType.TIMESTAMP ); + } + else if ( StringHelper.isNotEmpty( temporal ) ) { + throw new AnnotationException( "Unknown TemporalType: " + temporal + "= . " + SCHEMA_VALIDATION ); + } + annotationList.add( AnnotationFactory.create( ad ) ); + } + } + + private AssociationOverrides getAssociationOverrides(Element tree, XMLCon= text.Default defaults) { + List attributes =3D (List) bui= ldAssociationOverrides( tree ); + if ( defaults.canUseJavaAnnotations() ) { + AssociationOverride annotation =3D getJavaAnnotation( AssociationOverri= de.class ); + addAssociationOverrideIfNeeded( annotation, attributes ); + AssociationOverrides annotations =3D getJavaAnnotation( AssociationOver= rides.class ); + if ( annotations !=3D null ) { + for (AssociationOverride current : annotations.value()) { + addAssociationOverrideIfNeeded( current, attributes ); + } + } + } + if ( attributes.size() > 0 ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( AssociationOverri= des.class ); + ad.setValue( "value", attributes.toArray( new AssociationOverride[attri= butes.size()] ) ); + return AnnotationFactory.create( ad ); + } + else { + return null; + } + } + + private List buildAssociationOverrides(Element eleme= nt) { + List subelements =3D element =3D=3D null ? null : element.eleme= nts( "association-override" ); + List overrides =3D new ArrayList(); + if ( subelements !=3D null && subelements.size() > 0 ) { + for (Element current : subelements) { + AnnotationDescriptor override =3D new AnnotationDescriptor( Associatio= nOverride.class ); + copyStringAttribute( override, current, "name", true ); + override.setValue( "joinColumns", getJoinColumns( current, false ) ); + overrides.add( (AssociationOverride) AnnotationFactory.create( overrid= e ) ); + } + } + return overrides; + } + + private JoinColumn[] getJoinColumns(Element element, boolean isInverse) { + List subelements =3D element !=3D null ? + element.elements( isInverse ? "inverse-join-column" : "join-column" ) : + null; + List joinColumns =3D new ArrayList(); + if ( subelements !=3D null ) { + for (Element subelement : subelements) { + AnnotationDescriptor column =3D new AnnotationDescriptor( JoinColumn.c= lass ); + copyStringAttribute( column, subelement, "name", false ); + copyStringAttribute( column, subelement, "referenced-column-name", fal= se ); + copyBooleanAttribute( column, subelement, "unique" ); + copyBooleanAttribute( column, subelement, "nullable" ); + copyBooleanAttribute( column, subelement, "insertable" ); + copyBooleanAttribute( column, subelement, "updatable" ); + copyStringAttribute( column, subelement, "column-definition", false ); + copyStringAttribute( column, subelement, "table", false ); + joinColumns.add( (JoinColumn) AnnotationFactory.create( column ) ); + } + } + return joinColumns.toArray( new JoinColumn[joinColumns.size()] ); + } + + private void addAssociationOverrideIfNeeded(AssociationOverride annotatio= n, List overrides) { + if ( annotation !=3D null ) { + String overrideName =3D annotation.name(); + boolean present =3D false; + for (AssociationOverride current : overrides) { + if ( current.name().equals( overrideName ) ) { + present =3D true; + break; + } + } + if ( !present ) overrides.add( annotation ); + } + } + + private AttributeOverrides getAttributeOverrides(Element tree, XMLContext= .Default defaults) { + List attributes =3D buildAttributeOverrides( tree ); + return mergeAttributeOverrides( defaults, attributes ); + } + + private AttributeOverrides getAttributeOverrides(List elements, = XMLContext.Default defaults) { + List attributes =3D new ArrayList(= ); + for (Element element : elements) { + attributes.addAll( buildAttributeOverrides( element ) ); + } + return mergeAttributeOverrides( defaults, attributes ); + } + + private AttributeOverrides mergeAttributeOverrides(XMLContext.Default def= aults, + List attributes) { + if ( defaults.canUseJavaAnnotations() ) { + AttributeOverride annotation =3D getJavaAnnotation( AttributeOverride.c= lass ); + addAttributeOverrideIfNeeded( annotation, attributes ); + AttributeOverrides annotations =3D getJavaAnnotation( AttributeOverride= s.class ); + if ( annotations !=3D null ) { + for (AttributeOverride current : annotations.value()) { + addAttributeOverrideIfNeeded( current, attributes ); + } + } + } + if ( attributes.size() > 0 ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( AttributeOverride= s.class ); + ad.setValue( "value", attributes.toArray( new AttributeOverride[attribu= tes.size()] ) ); + return AnnotationFactory.create( ad ); + } + else { + return null; + } + } + + private List buildAttributeOverrides(Element element) { + List subelements =3D element =3D=3D null ? null : element.eleme= nts( "attribute-override" ); + return buildAttributeOverrides( subelements ); + } + + private List buildAttributeOverrides(List sub= elements) { + List overrides =3D new ArrayList(); + if ( subelements !=3D null && subelements.size() > 0 ) { + for (Element current : subelements) { + if ( !current.getName().equals( "attribute-override" ) ) continue; + AnnotationDescriptor override =3D new AnnotationDescriptor( AttributeO= verride.class ); + copyStringAttribute( override, current, "name", true ); + Element column =3D current !=3D null ? current.element( "column" ) : n= ull; + override.setValue( "column", getColumn( column, true, current ) ); + overrides.add( (AttributeOverride) AnnotationFactory.create( override = ) ); + } + } + return overrides; + } + + private Column getColumn(Element element, boolean isMandatory, Element cu= rrent) { + //Element subelement =3D element !=3D null ? element.element( "column" )= : null; + if ( element !=3D null ) { + AnnotationDescriptor column =3D new AnnotationDescriptor( Column.class = ); + copyStringAttribute( column, element, "name", false ); + copyBooleanAttribute( column, element, "unique" ); + copyBooleanAttribute( column, element, "nullable" ); + copyBooleanAttribute( column, element, "insertable" ); + copyBooleanAttribute( column, element, "updatable" ); + copyStringAttribute( column, element, "column-definition", false ); + copyStringAttribute( column, element, "table", false ); + copyIntegerAttribute( column, element, "length" ); + copyIntegerAttribute( column, element, "precision" ); + copyIntegerAttribute( column, element, "scale" ); + return (Column) AnnotationFactory.create( column ); + } + else { + if ( isMandatory ) { + throw new AnnotationException( current.getPath() + ".column is mandato= ry. " + SCHEMA_VALIDATION ); + } + return null; + } + } + + private void addAttributeOverrideIfNeeded(AttributeOverride annotation, L= ist overrides) { + if ( annotation !=3D null ) { + String overrideName =3D annotation.name(); + boolean present =3D false; + for (AttributeOverride current : overrides) { + if ( current.name().equals( overrideName ) ) { + present =3D true; + break; + } + } + if ( !present ) overrides.add( annotation ); + } + } + + private AccessType getAccessType(Element tree, XMLContext.Default default= s) { + String access =3D tree =3D=3D null ? null : tree.attributeValue( "access= " ); + if ( "FIELD".equals( access ) || "PROPERTY".equals( access ) ) { + access =3D access.toLowerCase(); + } + if ( access !=3D null ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( AccessType.class = ); + ad.setValue( "value", access ); + return AnnotationFactory.create( ad ); + } + else if ( defaults.canUseJavaAnnotations() && isJavaAnnotationPresent( A= ccessType.class ) ) { + AccessType annotation =3D getJavaAnnotation( AccessType.class ); + return annotation; + } + else if ( defaults.getAccess() !=3D null ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( AccessType.class = ); + ad.setValue( "value", defaults.getAccess() ); + return AnnotationFactory.create( ad ); + } + else { + return null; + } + } + + private ExcludeSuperclassListeners getExcludeSuperclassListeners(Element = tree, XMLContext.Default defaults) { + return (ExcludeSuperclassListeners) getMarkerAnnotation( ExcludeSupercla= ssListeners.class, tree, defaults ); + } + + private ExcludeDefaultListeners getExcludeDefaultListeners(Element tree, = XMLContext.Default defaults) { + return (ExcludeDefaultListeners) getMarkerAnnotation( ExcludeDefaultList= eners.class, tree, defaults ); + } + + private Annotation getMarkerAnnotation( + Class clazz, Element element, XMLContext.Default = defaults + ) { + Element subelement =3D element =3D=3D null ? null : element.element( ann= otationToXml.get( clazz ) ); + if ( subelement !=3D null ) { + return AnnotationFactory.create( new AnnotationDescriptor( clazz ) ); + } + else if ( defaults.canUseJavaAnnotations() ) { + //TODO wonder whether it should be excluded so that user can undone it + return getJavaAnnotation( clazz ); + } + else { + return null; + } + } + + private SqlResultSetMappings getSqlResultSetMappings(Element tree, XMLCon= text.Default defaults) { + List results =3D (List) buildS= qlResultsetMappings( tree, defaults ); + if ( defaults.canUseJavaAnnotations() ) { + SqlResultSetMapping annotation =3D getJavaAnnotation( SqlResultSetMappi= ng.class ); + addSqlResultsetMappingIfNeeded( annotation, results ); + SqlResultSetMappings annotations =3D getJavaAnnotation( SqlResultSetMap= pings.class ); + if ( annotations !=3D null ) { + for (SqlResultSetMapping current : annotations.value()) { + addSqlResultsetMappingIfNeeded( current, results ); + } + } + } + if ( results.size() > 0 ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( SqlResultSetMappi= ngs.class ); + ad.setValue( "value", results.toArray( new SqlResultSetMapping[results.= size()] ) ); + return AnnotationFactory.create( ad ); + } + else { + return null; + } + } + + public static List buildSqlResultsetMappings(Element= element, XMLContext.Default defaults) { + if ( element =3D=3D null ) return new ArrayList(); + List resultsetElementList =3D element.elements( "sql-result-set-mapping"= ); + List resultsets =3D new ArrayList(); + Iterator it =3D resultsetElementList.listIterator(); + while ( it.hasNext() ) { + Element subelement =3D (Element) it.next(); + AnnotationDescriptor ann =3D new AnnotationDescriptor( SqlResultSetMapp= ing.class ); + copyStringAttribute( ann, subelement, "name", true ); + List elements =3D subelement.elements( "entity-result" ); + List entityResults =3D new ArrayList( eleme= nts.size() ); + for (Element entityResult : elements) { + AnnotationDescriptor entityResultDescriptor =3D new AnnotationDescript= or( EntityResult.class ); + String clazzName =3D entityResult.attributeValue( "entity-class" ); + if ( clazzName =3D=3D null ) { + throw new AnnotationException( " without entity-class.= " + SCHEMA_VALIDATION ); + } + Class clazz =3D null; + try { + clazz =3D ReflectHelper.classForName( + XMLContext.buildSafeClassName( clazzName, defaults ), + EJB3OverridenAnnotationReader.class + ); + } + catch (ClassNotFoundException e) { + throw new AnnotationException( "Unable to find entity-class: " + claz= zName, e ); + } + entityResultDescriptor.setValue( "entityClass", clazz ); + copyStringAttribute( entityResultDescriptor, entityResult, "discrimina= tor-column", false ); + List fieldResults =3D new ArrayList(); + for (Element fieldResult : (List) entityResult.elements( "fie= ld-result" )) { + AnnotationDescriptor fieldResultDescriptor =3D new AnnotationDescript= or( FieldResult.class ); + copyStringAttribute( fieldResultDescriptor, fieldResult, "name", true= ); + copyStringAttribute( fieldResultDescriptor, fieldResult, "column", tr= ue ); + fieldResults.add( (FieldResult) AnnotationFactory.create( fieldResult= Descriptor ) ); + } + entityResultDescriptor.setValue( + "fields", fieldResults.toArray( new FieldResult[fieldResults.size()]= ) + ); + entityResults.add( (EntityResult) AnnotationFactory.create( entityResu= ltDescriptor ) ); + } + ann.setValue( "entities", entityResults.toArray( new EntityResult[entit= yResults.size()] ) ); + + elements =3D subelement.elements( "column-result" ); + List columnResults =3D new ArrayList( eleme= nts.size() ); + for (Element columnResult : elements) { + AnnotationDescriptor columnResultDescriptor =3D new AnnotationDescript= or( ColumnResult.class ); + copyStringAttribute( columnResultDescriptor, columnResult, "name", tru= e ); + columnResults.add( (ColumnResult) AnnotationFactory.create( columnResu= ltDescriptor ) ); + } + ann.setValue( "columns", columnResults.toArray( new ColumnResult[column= Results.size()] ) ); + //FIXME there is never such a result-class, get rid of it? + String clazzName =3D subelement.attributeValue( "result-class" ); + if ( StringHelper.isNotEmpty( clazzName ) ) { + Class clazz =3D null; + try { + clazz =3D ReflectHelper.classForName( + XMLContext.buildSafeClassName( clazzName, defaults ), + EJB3OverridenAnnotationReader.class + ); + } + catch (ClassNotFoundException e) { + throw new AnnotationException( "Unable to find entity-class: " + claz= zName, e ); + } + ann.setValue( "resultClass", clazz ); + } + copyStringAttribute( ann, subelement, "result-set-mapping", false ); + resultsets.add( (SqlResultSetMapping) AnnotationFactory.create( ann ) ); + } + return resultsets; + } + + private void addSqlResultsetMappingIfNeeded(SqlResultSetMapping annotatio= n, List resultsets) { + if ( annotation !=3D null ) { + String resultsetName =3D annotation.name(); + boolean present =3D false; + for (SqlResultSetMapping current : resultsets) { + if ( current.name().equals( resultsetName ) ) { + present =3D true; + break; + } + } + if ( !present ) resultsets.add( annotation ); + } + } + + private NamedQueries getNamedQueries(Element tree, XMLContext.Default def= aults) { + //TODO avoid the Proxy Creation (@NamedQueries) when possible + List queries =3D (List) buildNamedQueries( tree,= false, defaults ); + if ( defaults.canUseJavaAnnotations() ) { + NamedQuery annotation =3D getJavaAnnotation( NamedQuery.class ); + addNamedQueryIfNeeded( annotation, queries ); + NamedQueries annotations =3D getJavaAnnotation( NamedQueries.class ); + if ( annotations !=3D null ) { + for (NamedQuery current : annotations.value()) { + addNamedQueryIfNeeded( current, queries ); + } + } + } + if ( queries.size() > 0 ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( NamedQueries.clas= s ); + ad.setValue( "value", queries.toArray( new NamedQuery[queries.size()] )= ); + return AnnotationFactory.create( ad ); + } + else { + return null; + } + } + + private void addNamedQueryIfNeeded(NamedQuery annotation, List queries) { + if ( annotation !=3D null ) { + String queryName =3D annotation.name(); + boolean present =3D false; + for (NamedQuery current : queries) { + if ( current.name().equals( queryName ) ) { + present =3D true; + break; + } + } + if ( !present ) queries.add( annotation ); + } + } + + private NamedNativeQueries getNamedNativeQueries(Element tree, XMLContext= .Default defaults) { + List queries =3D (List) buildNamedQu= eries( tree, true, defaults ); + if ( defaults.canUseJavaAnnotations() ) { + NamedNativeQuery annotation =3D getJavaAnnotation( NamedNativeQuery.cla= ss ); + addNamedNativeQueryIfNeeded( annotation, queries ); + NamedNativeQueries annotations =3D getJavaAnnotation( NamedNativeQuerie= s.class ); + if ( annotations !=3D null ) { + for (NamedNativeQuery current : annotations.value()) { + addNamedNativeQueryIfNeeded( current, queries ); + } + } + } + if ( queries.size() > 0 ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( NamedNativeQuerie= s.class ); + ad.setValue( "value", queries.toArray( new NamedNativeQuery[queries.siz= e()] ) ); + return AnnotationFactory.create( ad ); + } + else { + return null; + } + } + + private void addNamedNativeQueryIfNeeded(NamedNativeQuery annotation, Lis= t queries) { + if ( annotation !=3D null ) { + String queryName =3D annotation.name(); + boolean present =3D false; + for (NamedNativeQuery current : queries) { + if ( current.name().equals( queryName ) ) { + present =3D true; + break; + } + } + if ( !present ) queries.add( annotation ); + } + } + + public static List buildNamedQueries(Element element, boolean isNative, X= MLContext.Default defaults) { + if ( element =3D=3D null ) return new ArrayList(); + List namedQueryElementList =3D isNative ? + element.elements( "named-native-query" ) : + element.elements( "named-query" ); + List namedQueries =3D new ArrayList(); + Iterator it =3D namedQueryElementList.listIterator(); + while ( it.hasNext() ) { + Element subelement =3D (Element) it.next(); + AnnotationDescriptor ann =3D new AnnotationDescriptor( + isNative ? NamedNativeQuery.class : NamedQuery.class + ); + copyStringAttribute( ann, subelement, "name", false ); + Element queryElt =3D subelement.element( "query" ); + if ( queryElt =3D=3D null ) throw new AnnotationException( "No = element found." + SCHEMA_VALIDATION ); + ann.setValue( "query", queryElt.getTextTrim() ); + List elements =3D subelement.elements( "hint" ); + List queryHints =3D new ArrayList( elements.size(= ) ); + for (Element hint : elements) { + AnnotationDescriptor hintDescriptor =3D new AnnotationDescriptor( Quer= yHint.class ); + String value =3D hint.attributeValue( "name" ); + if ( value =3D=3D null ) throw new AnnotationException( " withou= t name. " + SCHEMA_VALIDATION ); + hintDescriptor.setValue( "name", value ); + value =3D hint.attributeValue( "value" ); + if ( value =3D=3D null ) throw new AnnotationException( " withou= t value. " + SCHEMA_VALIDATION ); + hintDescriptor.setValue( "value", value ); + queryHints.add( (QueryHint) AnnotationFactory.create( hintDescriptor )= ); + } + ann.setValue( "hints", queryHints.toArray( new QueryHint[queryHints.siz= e()] ) ); + String clazzName =3D subelement.attributeValue( "result-class" ); + if ( StringHelper.isNotEmpty( clazzName ) ) { + Class clazz =3D null; + try { + clazz =3D ReflectHelper.classForName( + XMLContext.buildSafeClassName( clazzName, defaults ), + EJB3OverridenAnnotationReader.class + ); + } + catch (ClassNotFoundException e) { + throw new AnnotationException( "Unable to find entity-class: " + claz= zName, e ); + } + ann.setValue( "resultClass", clazz ); + } + copyStringAttribute( ann, subelement, "result-set-mapping", false ); + namedQueries.add( AnnotationFactory.create( ann ) ); + } + return namedQueries; + } + + private TableGenerator getTableGenerator(Element tree, XMLContext.Default= defaults) { + Element element =3D tree !=3D null ? tree.element( annotationToXml.get( = TableGenerator.class ) ) : null; + if ( element !=3D null ) { + return buildTableGeneratorAnnotation( element, defaults ); + } + else if ( defaults.canUseJavaAnnotations() && isJavaAnnotationPresent( T= ableGenerator.class ) ) { + TableGenerator tableAnn =3D getJavaAnnotation( TableGenerator.class ); + if ( StringHelper.isNotEmpty( defaults.getSchema() ) + || StringHelper.isNotEmpty( defaults.getCatalog() ) ) { + AnnotationDescriptor annotation =3D new AnnotationDescriptor( TableGen= erator.class ); + annotation.setValue( "name", tableAnn.name() ); + annotation.setValue( "table", tableAnn.table() ); + annotation.setValue( "catalog", tableAnn.table() ); + if ( StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) + && StringHelper.isNotEmpty( defaults.getCatalog() ) ) { + annotation.setValue( "catalog", defaults.getCatalog() ); + } + annotation.setValue( "schema", tableAnn.table() ); + if ( StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) + && StringHelper.isNotEmpty( defaults.getSchema() ) ) { + annotation.setValue( "catalog", defaults.getSchema() ); + } + annotation.setValue( "pkColumnName", tableAnn.pkColumnName() ); + annotation.setValue( "valueColumnName", tableAnn.valueColumnName() ); + annotation.setValue( "pkColumnValue", tableAnn.pkColumnValue() ); + annotation.setValue( "initialValue", tableAnn.initialValue() ); + annotation.setValue( "allocationSize", tableAnn.allocationSize() ); + annotation.setValue( "uniqueConstraints", tableAnn.uniqueConstraints()= ); + return AnnotationFactory.create( annotation ); + } + else { + return tableAnn; + } + } + else { + return null; + } + } + + public static TableGenerator buildTableGeneratorAnnotation(Element elemen= t, XMLContext.Default defaults) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( TableGenerator.cla= ss ); + copyStringAttribute( ad, element, "name", false ); + copyStringAttribute( ad, element, "table", false ); + copyStringAttribute( ad, element, "catalog", false ); + copyStringAttribute( ad, element, "schema", false ); + copyStringAttribute( ad, element, "pk-column-name", false ); + copyStringAttribute( ad, element, "value-column-name", false ); + copyStringAttribute( ad, element, "pk-column-value", false ); + copyIntegerAttribute( ad, element, "initial-value" ); + copyIntegerAttribute( ad, element, "allocation-size" ); + buildUniqueConstraints( ad, element ); + if ( StringHelper.isEmpty( (String) ad.valueOf( "schema" ) ) + && StringHelper.isNotEmpty( defaults.getSchema() ) ) { + ad.setValue( "schema", defaults.getSchema() ); + } + if ( StringHelper.isEmpty( (String) ad.valueOf( "catalog" ) ) + && StringHelper.isNotEmpty( defaults.getCatalog() ) ) { + ad.setValue( "catalog", defaults.getCatalog() ); + } + return AnnotationFactory.create( ad ); + } + + private SequenceGenerator getSequenceGenerator(Element tree, XMLContext.D= efault defaults) { + Element element =3D tree !=3D null ? tree.element( annotationToXml.get( = SequenceGenerator.class ) ) : null; + if ( element !=3D null ) { + return buildSequenceGeneratorAnnotation( element ); + } + else if ( defaults.canUseJavaAnnotations() ) { + return getJavaAnnotation( SequenceGenerator.class ); + } + else { + return null; + } + } + + public static SequenceGenerator buildSequenceGeneratorAnnotation(Element = element) { + if ( element !=3D null ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( SequenceGenerator= .class ); + copyStringAttribute( ad, element, "name", false ); + copyStringAttribute( ad, element, "sequence-name", false ); + copyIntegerAttribute( ad, element, "initial-value" ); + copyIntegerAttribute( ad, element, "allocation-size" ); + return AnnotationFactory.create( ad ); + } + else { + return null; + } + } + + private DiscriminatorColumn getDiscriminatorColumn(Element tree, XMLConte= xt.Default defaults) { + Element element =3D tree !=3D null ? tree.element( "discriminator-column= " ) : null; + if ( element !=3D null ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( DiscriminatorColu= mn.class ); + copyStringAttribute( ad, element, "name", false ); + copyStringAttribute( ad, element, "column-definition", false ); + String value =3D element.attributeValue( "discriminator-type" ); + DiscriminatorType type =3D DiscriminatorType.STRING; + if ( value !=3D null ) { + if ( "STRING".equals( value ) ) { + type =3D DiscriminatorType.STRING; + } + else if ( "CHAR".equals( value ) ) { + type =3D DiscriminatorType.CHAR; + } + else if ( "INTEGER".equals( value ) ) { + type =3D DiscriminatorType.INTEGER; + } + else { + throw new AnnotationException( + "Unknown DiscrimiatorType in XML: " + value + " (" + SCHEMA_VALIDAT= ION + ")" + ); + } + } + ad.setValue( "discriminatorType", type ); + copyIntegerAttribute( ad, element, "length" ); + return AnnotationFactory.create( ad ); + } + else if ( defaults.canUseJavaAnnotations() ) { + return getJavaAnnotation( DiscriminatorColumn.class ); + } + else { + return null; + } + } + + private DiscriminatorValue getDiscriminatorValue(Element tree, XMLContext= .Default defaults) { + Element element =3D tree !=3D null ? tree.element( "discriminator-value"= ) : null; + if ( element !=3D null ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( DiscriminatorValu= e.class ); + copyStringElement( element, ad, "value" ); + return AnnotationFactory.create( ad ); + } + else if ( defaults.canUseJavaAnnotations() ) { + return getJavaAnnotation( DiscriminatorValue.class ); + } + else { + return null; + } + } + + private Inheritance getInheritance(Element tree, XMLContext.Default defau= lts) { + Element element =3D tree !=3D null ? tree.element( "inheritance" ) : nul= l; + if ( element !=3D null ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( Inheritance.class= ); + Attribute attr =3D element.attribute( "strategy" ); + InheritanceType strategy =3D InheritanceType.SINGLE_TABLE; + if ( attr !=3D null ) { + String value =3D attr.getValue(); + if ( "SINGLE_TABLE".equals( value ) ) { + strategy =3D InheritanceType.SINGLE_TABLE; + } + else if ( "JOINED".equals( value ) ) { + strategy =3D InheritanceType.JOINED; + } + else if ( "TABLE_PER_CLASS".equals( value ) ) { + strategy =3D InheritanceType.TABLE_PER_CLASS; + } + else { + throw new AnnotationException( + "Unknown InheritanceType in XML: " + value + " (" + SCHEMA_VALIDATI= ON + ")" + ); + } + } + ad.setValue( "strategy", strategy ); + return AnnotationFactory.create( ad ); + } + else if ( defaults.canUseJavaAnnotations() ) { + return getJavaAnnotation( Inheritance.class ); + } + else { + return null; + } + } + + private IdClass getIdClass(Element tree, XMLContext.Default defaults) { + Element element =3D tree =3D=3D null ? null : tree.element( "id-class" ); + if ( element !=3D null ) { + Attribute attr =3D element.attribute( "class" ); + if ( attr !=3D null ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( IdClass.class ); + Class clazz =3D null; + try { + clazz =3D ReflectHelper.classForName( + XMLContext.buildSafeClassName( attr.getValue(), defaults ), + this.getClass() + ); + } + catch (ClassNotFoundException e) { + throw new AnnotationException( "Unable to find id-class: " + attr.get= Value(), e ); + } + ad.setValue( "value", clazz ); + return AnnotationFactory.create( ad ); + } + else { + throw new AnnotationException( "id-class without class. " + SCHEMA_VAL= IDATION ); + } + } + else if ( defaults.canUseJavaAnnotations() ) { + return getJavaAnnotation( IdClass.class ); + } + else { + return null; + } + } + + private PrimaryKeyJoinColumns getPrimaryKeyJoinColumns(Element element, X= MLContext.Default defaults) { + PrimaryKeyJoinColumn[] columns =3D buildPrimaryKeyJoinColumns( element ); + if ( columns.length =3D=3D 0 && defaults.canUseJavaAnnotations() ) { + PrimaryKeyJoinColumn annotation =3D getJavaAnnotation( PrimaryKeyJoinCo= lumn.class ); + if ( annotation !=3D null ) { + columns =3D new PrimaryKeyJoinColumn[] { annotation }; + } + else { + PrimaryKeyJoinColumns annotations =3D getJavaAnnotation( PrimaryKeyJoi= nColumns.class ); + columns =3D annotations !=3D null ? annotations.value() : columns; + } + } + if ( columns.length > 0 ) { + AnnotationDescriptor ad =3D new AnnotationDescriptor( PrimaryKeyJoinCol= umns.class ); + ad.setValue( "value", columns ); + return AnnotationFactory.create( ad ); + } + else { + return null; + } + } + + private Entity getEntity(Element tree, XMLContext.Default defaults) { + if ( tree =3D=3D null ) { + return defaults.canUseJavaAnnotations() ? getJavaAnnotation( Entity.cla= ss ) : null; + } + else { + if ( "entity".equals( tree.getName() ) ) { + AnnotationDescriptor entity =3D new AnnotationDescriptor( Entity.class= ); + copyStringAttribute( entity, tree, "name", false ); + if ( defaults.canUseJavaAnnotations() + && StringHelper.isEmpty( (String) entity.valueOf( "name" ) ) ) { + Entity javaAnn =3D getJavaAnnotation( Entity.class ); + if ( javaAnn !=3D null ) entity.setValue( "name", javaAnn.name() ); + } + return AnnotationFactory.create( entity ); + } + else { + return null; //this is not an entity + } + } + } + + private MappedSuperclass getMappedSuperclass(Element tree, XMLContext.Def= ault defaults) { + if ( tree =3D=3D null ) { + return defaults.canUseJavaAnnotations() ? getJavaAnnotation( MappedSupe= rclass.class ) : null; + } + else { + if ( "mapped-superclass".equals( tree.getName() ) ) { + AnnotationDescriptor entity =3D new AnnotationDescriptor( MappedSuperc= lass.class ); + return AnnotationFactory.create( entity ); + } + else { + return null; //this is not an entity + } + } + } + + private Embeddable getEmbeddable(Element tree, XMLContext.Default default= s) { + if ( tree =3D=3D null ) { + return defaults.canUseJavaAnnotations() ? getJavaAnnotation( Embeddable= .class ) : null; + } + else { + if ( "embeddable".equals( tree.getName() ) ) { + AnnotationDescriptor entity =3D new AnnotationDescriptor( Embeddable.c= lass ); + return AnnotationFactory.create( entity ); + } + else { + return null; //this is not an entity + } + } + } + + private Table getTable(Element tree, XMLContext.Default defaults) { + Element subelement =3D tree =3D=3D null ? null : tree.element( "table" ); + if ( subelement =3D=3D null ) { + //no element but might have some default or some annotation + if ( StringHelper.isNotEmpty( defaults.getCatalog() ) + || StringHelper.isNotEmpty( defaults.getSchema() ) ) { + AnnotationDescriptor annotation =3D new AnnotationDescriptor( Table.cl= ass ); + if ( defaults.canUseJavaAnnotations() ) { + Table table =3D getJavaAnnotation( Table.class ); + if ( table !=3D null ) { + annotation.setValue( "name", table.name() ); + annotation.setValue( "schema", table.schema() ); + annotation.setValue( "catalog", table.catalog() ); + annotation.setValue( "uniqueConstraints", table.uniqueConstraints() = ); + } + } + if ( StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) + && StringHelper.isNotEmpty( defaults.getSchema() ) ) { + annotation.setValue( "schema", defaults.getSchema() ); + } + if ( StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) + && StringHelper.isNotEmpty( defaults.getCatalog() ) ) { + annotation.setValue( "catalog", defaults.getCatalog() ); + } + return AnnotationFactory.create( annotation ); + } + else if ( defaults.canUseJavaAnnotations() ) { + return getJavaAnnotation( Table.class ); + } + else { + return null; + } + } + else { + //ignore java annotation, an element is defined + AnnotationDescriptor annotation =3D new AnnotationDescriptor( Table.cla= ss ); + copyStringAttribute( annotation, subelement, "name", false ); + copyStringAttribute( annotation, subelement, "catalog", false ); + if ( StringHelper.isNotEmpty( defaults.getCatalog() ) + && StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) )= { + annotation.setValue( "catalog", defaults.getCatalog() ); + } + copyStringAttribute( annotation, subelement, "schema", false ); + if ( StringHelper.isNotEmpty( defaults.getSchema() ) + && StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) ) { + annotation.setValue( "schema", defaults.getSchema() ); + } + buildUniqueConstraints( annotation, subelement ); + return AnnotationFactory.create( annotation ); + } + } + + private SecondaryTables getSecondaryTables(Element tree, XMLContext.Defau= lt defaults) { + List elements =3D tree =3D=3D null ? + new ArrayList() : + (List) tree.elements( "secondary-table" ); + List secondaryTables =3D new ArrayList( = 3 ); + for (Element element : elements) { + AnnotationDescriptor annotation =3D new AnnotationDescriptor( Secondary= Table.class ); + copyStringAttribute( annotation, element, "name", false ); + copyStringAttribute( annotation, element, "catalog", false ); + if ( StringHelper.isNotEmpty( defaults.getCatalog() ) + && StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) )= { + annotation.setValue( "catalog", defaults.getCatalog() ); + } + copyStringAttribute( annotation, element, "schema", false ); + if ( StringHelper.isNotEmpty( defaults.getSchema() ) + && StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) ) { + annotation.setValue( "schema", defaults.getSchema() ); + } + buildUniqueConstraints( annotation, element ); + annotation.setValue( "pkJoinColumns", buildPrimaryKeyJoinColumns( eleme= nt ) ); + secondaryTables.add( (SecondaryTable) AnnotationFactory.create( annotat= ion ) ); + } + /* + * You can't have both secondary table in XML and Java, + * since there would be no way to "remove" a secondary table + */ + if ( secondaryTables.size() =3D=3D 0 && defaults.canUseJavaAnnotations()= ) { + SecondaryTable secTableAnn =3D getJavaAnnotation( SecondaryTable.class = ); + overridesDefaultInSecondaryTable( secTableAnn, defaults, secondaryTable= s ); + SecondaryTables secTablesAnn =3D getJavaAnnotation( SecondaryTables.cla= ss ); + if ( secTablesAnn !=3D null ) { + for (SecondaryTable table : secTablesAnn.value()) { + overridesDefaultInSecondaryTable( table, defaults, secondaryTables ); + } + } + } + if ( secondaryTables.size() > 0 ) { + AnnotationDescriptor descriptor =3D new AnnotationDescriptor( Secondary= Tables.class ); + descriptor.setValue( "value", secondaryTables.toArray( new SecondaryTab= le[secondaryTables.size()] ) ); + return AnnotationFactory.create( descriptor ); + } + else { + return null; + } + } + + private void overridesDefaultInSecondaryTable( + SecondaryTable secTableAnn, XMLContext.Default defaults, List secondaryTables + ) { + if ( secTableAnn !=3D null ) { + //handle default values + if ( StringHelper.isNotEmpty( defaults.getCatalog() ) + || StringHelper.isNotEmpty( defaults.getSchema() ) ) { + AnnotationDescriptor annotation =3D new AnnotationDescriptor( Secondar= yTable.class ); + annotation.setValue( "name", secTableAnn.name() ); + annotation.setValue( "schema", secTableAnn.schema() ); + annotation.setValue( "catalog", secTableAnn.catalog() ); + annotation.setValue( "uniqueConstraints", secTableAnn.uniqueConstraint= s() ); + annotation.setValue( "pkJoinColumns", secTableAnn.pkJoinColumns() ); + if ( StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) + && StringHelper.isNotEmpty( defaults.getSchema() ) ) { + annotation.setValue( "schema", defaults.getSchema() ); + } + if ( StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) + && StringHelper.isNotEmpty( defaults.getCatalog() ) ) { + annotation.setValue( "catalog", defaults.getCatalog() ); + } + secondaryTables.add( (SecondaryTable) AnnotationFactory.create( annota= tion ) ); + } + else { + secondaryTables.add( secTableAnn ); + } + } + } + + private static void buildUniqueConstraints(AnnotationDescriptor annotatio= n, Element element) { + List uniqueConstraintElementList =3D element.elements( "unique-constrain= t" ); + UniqueConstraint[] uniqueConstraints =3D new UniqueConstraint[uniqueCons= traintElementList.size()]; + int ucIndex =3D 0; + Iterator ucIt =3D uniqueConstraintElementList.listIterator(); + while ( ucIt.hasNext() ) { + Element subelement =3D (Element) ucIt.next(); + List columnNamesElements =3D subelement.elements( "column-name= " ); + String[] columnNames =3D new String[columnNamesElements.size()]; + int columnNameIndex =3D 0; + Iterator it =3D columnNamesElements.listIterator(); + while ( it.hasNext() ) { + Element columnNameElt =3D (Element) it.next(); + columnNames[columnNameIndex++] =3D columnNameElt.getTextTrim(); + } + AnnotationDescriptor ucAnn =3D new AnnotationDescriptor( UniqueConstrai= nt.class ); + ucAnn.setValue( "columnNames", columnNames ); + uniqueConstraints[ucIndex++] =3D AnnotationFactory.create( ucAnn ); + } + annotation.setValue( "uniqueConstraints", uniqueConstraints ); + } + + private PrimaryKeyJoinColumn[] buildPrimaryKeyJoinColumns(Element element= ) { + if ( element =3D=3D null ) return new PrimaryKeyJoinColumn[] { }; + List pkJoinColumnElementList =3D element.elements( "primary-key-join-col= umn" ); + PrimaryKeyJoinColumn[] pkJoinColumns =3D new PrimaryKeyJoinColumn[pkJoin= ColumnElementList.size()]; + int index =3D 0; + Iterator pkIt =3D pkJoinColumnElementList.listIterator(); + while ( pkIt.hasNext() ) { + Element subelement =3D (Element) pkIt.next(); + AnnotationDescriptor pkAnn =3D new AnnotationDescriptor( PrimaryKeyJoin= Column.class ); + copyStringAttribute( pkAnn, subelement, "name", false ); + copyStringAttribute( pkAnn, subelement, "referenced-column-name", false= ); + copyStringAttribute( pkAnn, subelement, "column-definition", false ); + pkJoinColumns[index++] =3D AnnotationFactory.create( pkAnn ); + } + return pkJoinColumns; + } + + private static void copyStringAttribute( + AnnotationDescriptor annotation, Element element, String attributeName,= boolean mandatory + ) { + String attribute =3D element.attributeValue( attributeName ); + if ( attribute !=3D null ) { + String annotationAttributeName =3D getJavaAttributeNameFromXMLOne( attr= ibuteName ); + annotation.setValue( annotationAttributeName, attribute ); + } + else { + if ( mandatory ) { + throw new AnnotationException( + element.getName() + "." + attributeName + " is mandatory in XML over= ring. " + SCHEMA_VALIDATION + ); + } + } + } + + private static void copyIntegerAttribute(AnnotationDescriptor annotation,= Element element, String attributeName) { + String attribute =3D element.attributeValue( attributeName ); + if ( attribute !=3D null ) { + String annotationAttributeName =3D getJavaAttributeNameFromXMLOne( attr= ibuteName ); + annotation.setValue( annotationAttributeName, attribute ); + try { + int length =3D Integer.parseInt( attribute ); + annotation.setValue( annotationAttributeName, length ); + } + catch (NumberFormatException e) { + throw new AnnotationException( + element.getPath() + attributeName + " not parseable: " + attribute += " (" + SCHEMA_VALIDATION + ")" + ); + } + } + } + + private static String getJavaAttributeNameFromXMLOne(String attributeName= ) { + StringBuilder annotationAttributeName =3D new StringBuilder( attributeNa= me ); + int index =3D annotationAttributeName.indexOf( WORD_SEPARATOR ); + while ( index !=3D -1 ) { + annotationAttributeName.deleteCharAt( index ); + annotationAttributeName.setCharAt( + index, Character.toUpperCase( annotationAttributeName.charAt( index )= ) + ); + index =3D annotationAttributeName.indexOf( WORD_SEPARATOR ); + } + return annotationAttributeName.toString(); + } + + private static void copyStringElement(Element element, AnnotationDescript= or ad, String annotationAttribute) { + String discr =3D element.getTextTrim(); + ad.setValue( annotationAttribute, discr ); + } + + private static void copyBooleanAttribute(AnnotationDescriptor descriptor,= Element element, String attribute) { + String attributeValue =3D element.attributeValue( attribute ); + if ( StringHelper.isNotEmpty( attributeValue ) ) { + String javaAttribute =3D getJavaAttributeNameFromXMLOne( attribute ); + descriptor.setValue( javaAttribute, Boolean.parseBoolean( attributeValu= e ) ); + } + } + + private T getJavaAnnotation(Class annotationTyp= e) { + return element.getAnnotation( annotationType ); + } + + private boolean isJavaAnnotationPresent(Class a= nnotationType) { + return element.isAnnotationPresent( annotationType ); + } + + private Annotation[] getJavaAnnotations() { + return element.getAnnotations(); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/reflection/EJB3ReflectionManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/reflection/EJB3ReflectionManager.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/reflection/EJB3ReflectionManager.java 2009-11-24 21:08:28 UTC (rev 1= 8050) @@ -0,0 +1,101 @@ +package org.hibernate.cfg.annotations.reflection; + +import java.lang.reflect.AnnotatedElement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.persistence.EntityListeners; +import javax.persistence.NamedNativeQuery; +import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; +import javax.persistence.SqlResultSetMapping; +import javax.persistence.TableGenerator; + +import org.dom4j.Element; +import org.hibernate.annotations.common.reflection.AnnotationReader; +import org.hibernate.annotations.common.reflection.java.JavaReflectionMana= ger; +import org.hibernate.util.ReflectHelper; + +public class EJB3ReflectionManager extends JavaReflectionManager { + + private XMLContext xmlContext =3D new XMLContext(); + private HashMap defaults =3D null; + + public AnnotationReader buildAnnotationReader(AnnotatedElement annotatedE= lement) { + if ( xmlContext.hasContext() ) { + return new EJB3OverridenAnnotationReader( annotatedElement, xmlContext = ); + } + else { + return super.buildAnnotationReader( annotatedElement ); + } + } + + public Map getDefaults() { + if ( defaults =3D=3D null ) { + defaults =3D new HashMap(); + XMLContext.Default xmlDefaults =3D xmlContext.getDefault( null ); + List entityListeners =3D new ArrayList(); + for (String className : xmlContext.getDefaultEntityListeners()) { + try { + entityListeners.add( ReflectHelper.classForName( className, this.getC= lass() ) ); + } + catch (ClassNotFoundException e) { + throw new IllegalStateException( "Default entity listener class not f= ound: " + className ); + } + } + defaults.put( EntityListeners.class, entityListeners ); + for (Element element : xmlContext.getAllDocuments()) { + + List elements =3D element.elements( "sequence-generator" ); + List sequenceGenerators =3D (List) defaults.get( SequenceGenerator.class ); + if ( sequenceGenerators =3D=3D null ) { + sequenceGenerators =3D new ArrayList(); + defaults.put( SequenceGenerator.class, sequenceGenerators ); + } + for (Element subelement : elements) { + sequenceGenerators.add( EJB3OverridenAnnotationReader.buildSequenceGe= neratorAnnotation( subelement ) ); + } + + elements =3D element.elements( "table-generator" ); + List tableGenerators =3D (List) defaul= ts.get( TableGenerator.class ); + if ( tableGenerators =3D=3D null ) { + tableGenerators =3D new ArrayList(); + defaults.put( TableGenerator.class, tableGenerators ); + } + for (Element subelement : elements) { + tableGenerators.add( EJB3OverridenAnnotationReader.buildTableGenerato= rAnnotation( subelement, xmlDefaults ) ); + } + + List namedQueries =3D (List) defaults.get( Nam= edQuery.class ); + if ( namedQueries =3D=3D null ) { + namedQueries =3D new ArrayList(); + defaults.put( NamedQuery.class, namedQueries ); + } + List currentNamedQueries =3D EJB3OverridenAnnotationReader= .buildNamedQueries( element, false, xmlDefaults ); + namedQueries.addAll( currentNamedQueries ); + + List namedNativeQueries =3D (List)= defaults.get( NamedNativeQuery.class ); + if ( namedNativeQueries =3D=3D null ) { + namedNativeQueries =3D new ArrayList(); + defaults.put( NamedNativeQuery.class, namedNativeQueries ); + } + List currentNamedNativeQueries =3D EJB3OverridenAnno= tationReader.buildNamedQueries( element, true, xmlDefaults ); + namedNativeQueries.addAll( currentNamedNativeQueries ); + + List sqlResultSetMappings =3D (List) defaults.get( SqlResultSetMapping.class ); + if ( sqlResultSetMappings =3D=3D null ) { + sqlResultSetMappings =3D new ArrayList(); + defaults.put( SqlResultSetMapping.class, sqlResultSetMappings ); + } + List currentSqlResultSetMappings =3D EJB3Override= nAnnotationReader.buildSqlResultsetMappings( element, xmlDefaults ); + sqlResultSetMappings.addAll( currentSqlResultSetMappings ); + } + } + return defaults; + } + + public XMLContext getXMLContext() { + return xmlContext; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/an= notations/reflection/XMLContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/reflection/XMLContext.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annot= ations/reflection/XMLContext.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,255 @@ +//$Id: XMLContext.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.cfg.annotations.reflection; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.dom4j.Document; +import org.dom4j.Element; +import org.hibernate.util.StringHelper; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; + +/** + * @author Emmanuel Bernard + */ +public class XMLContext { + private Logger log =3D LoggerFactory.getLogger( XMLContext.class ); + private Default globalDefaults; + private Map classOverriding =3D new HashMap(); + private Map defaultsOverriding =3D new HashMap(); + private List defaultElements =3D new ArrayList(); + private List defaultEntityListeners =3D new ArrayList(); + private boolean hasContext =3D false; + + /** + * Add a document and return the list of added classes names + */ + public List addDocument(Document doc) { + hasContext =3D true; + List addedClasses =3D new ArrayList(); + Element root =3D doc.getRootElement(); + //global defaults + Element metadata =3D root.element( "persistence-unit-metadata" ); + if ( metadata !=3D null ) { + if ( globalDefaults =3D=3D null ) { + globalDefaults =3D new Default(); + globalDefaults.setMetadataComplete( + metadata.element( "xml-mapping-metadata-complete" ) !=3D null ? + Boolean.TRUE : + null + ); + Element defaultElement =3D metadata.element( "persistence-unit-default= s" ); + if ( defaultElement !=3D null ) { + Element unitElement =3D defaultElement.element( "schema" ); + globalDefaults.setSchema( unitElement !=3D null ? unitElement.getText= Trim() : null ); + unitElement =3D defaultElement.element( "catalog" ); + globalDefaults.setCatalog( unitElement !=3D null ? unitElement.getTex= tTrim() : null ); + unitElement =3D defaultElement.element( "access" ); + globalDefaults.setAccess( unitElement !=3D null ? unitElement.getText= Trim() : null ); + unitElement =3D defaultElement.element( "cascade-persist" ); + globalDefaults.setCascadePersist( unitElement !=3D null ? Boolean.TRU= E : null ); + defaultEntityListeners.addAll( addEntityListenerClasses( defaultEleme= nt, null, addedClasses ) ); + } + } + else { + log.warn( "Found more than one , subsequent= ignored" ); + } + } + + //entity mapping default + Default entityMappingDefault =3D new Default(); + Element unitElement =3D root.element( "package" ); + String packageName =3D unitElement !=3D null ? unitElement.getTextTrim()= : null; + entityMappingDefault.setPackageName( packageName ); + unitElement =3D root.element( "schema" ); + entityMappingDefault.setSchema( unitElement !=3D null ? unitElement.getT= extTrim() : null ); + unitElement =3D root.element( "catalog" ); + entityMappingDefault.setCatalog( unitElement !=3D null ? unitElement.get= TextTrim() : null ); + unitElement =3D root.element( "access" ); + entityMappingDefault.setAccess( unitElement !=3D null ? unitElement.getT= extTrim() : null ); + defaultElements.add( root ); + + List entities =3D (List) root.elements( "entity" ); + addClass( entities, packageName, entityMappingDefault, addedClasses ); + + entities =3D (List) root.elements( "mapped-superclass" ); + addClass( entities, packageName, entityMappingDefault, addedClasses ); + + entities =3D (List) root.elements( "embeddable" ); + addClass( entities, packageName, entityMappingDefault, addedClasses ); + return addedClasses; + } + + private void addClass(List entities, String packageName, Default= defaults, List addedClasses) { + for (Element element : entities) { + String className =3D buildSafeClassName( element.attributeValue( "class= " ), packageName ); + if ( classOverriding.containsKey( className ) ) { + //maybe switch it to warn? + throw new IllegalStateException( "Duplicate XML entry for " + classNam= e ); + } + addedClasses.add( className ); + classOverriding.put( className, element ); + Default localDefault =3D new Default(); + localDefault.override( defaults ); + String metadataCompleteString =3D element.attributeValue( "metadata-com= plete" ); + if ( metadataCompleteString !=3D null ) { + localDefault.setMetadataComplete( Boolean.parseBoolean( metadataComple= teString ) ); + } + String access =3D element.attributeValue( "access" ); + if ( access !=3D null ) localDefault.setAccess( access ); + defaultsOverriding.put( className, localDefault ); + + log.debug( "Adding XML overriding information for {}", className ); + addEntityListenerClasses( element, packageName, addedClasses ); + } + } + + private List addEntityListenerClasses(Element element, String pac= kageName, List addedClasses) { + List localAddedClasses =3D new ArrayList(); + Element listeners =3D element.element( "entity-listeners" ); + if ( listeners !=3D null ) { + List elements =3D (List) listeners.elements( "entity-= listener" ); + for (Element listener : elements) { + String listenerClassName =3D buildSafeClassName( listener.attributeVal= ue( "class" ), packageName ); + if ( classOverriding.containsKey( listenerClassName ) ) { + //maybe switch it to warn? + if ( "entity-listener".equals( classOverriding.get( listenerClassName= ).getName() ) ) { + log.info( + "entity-listener duplication, first event definition will be used:= {}", + listenerClassName + ); + continue; + } + else { + throw new IllegalStateException( "Duplicate XML entry for " + listen= erClassName ); + } + } + localAddedClasses.add( listenerClassName ); + classOverriding.put( listenerClassName, listener ); + } + } + log.debug( "Adding XML overriding information for listener: {}", listene= rs ); + addedClasses.addAll( localAddedClasses ); + return localAddedClasses; + } + + public static String buildSafeClassName(String className, String defaultP= ackageName) { + if ( className.indexOf( '.' ) < 0 && StringHelper.isNotEmpty( defaultPac= kageName ) ) { + className =3D StringHelper.qualify( defaultPackageName, className ); + } + return className; + } + + public static String buildSafeClassName(String className, XMLContext.Defa= ult defaults) { + return buildSafeClassName( className, defaults.getPackageName() ); + } + + public Default getDefault(String className) { + Default xmlDefault =3D new Default(); + xmlDefault.override( globalDefaults ); + if ( className !=3D null ) { + Default entityMappingOverriding =3D defaultsOverriding.get( className ); + xmlDefault.override( entityMappingOverriding ); + } + return xmlDefault; + } + + public Element getXMLTree(String className, String methodName) { + return classOverriding.get( className ); + } + + public List getAllDocuments() { + return defaultElements; + } + + public boolean hasContext() { + return hasContext; + } + + public static class Default { + private String access; + private String packageName; + private String schema; + private String catalog; + private Boolean metadataComplete; + private Boolean cascadePersist; + + public String getAccess() { + return access; + } + + protected void setAccess(String access) { + if ( "FIELD".equals( access ) || "PROPERTY".equals( access ) ) { + this.access =3D access.toLowerCase(); + } + else { + this.access =3D access; + } + } + + public String getCatalog() { + return catalog; + } + + protected void setCatalog(String catalog) { + this.catalog =3D catalog; + } + + public String getPackageName() { + return packageName; + } + + protected void setPackageName(String packageName) { + this.packageName =3D packageName; + } + + public String getSchema() { + return schema; + } + + protected void setSchema(String schema) { + this.schema =3D schema; + } + + public Boolean getMetadataComplete() { + return metadataComplete; + } + + public boolean canUseJavaAnnotations() { + return metadataComplete =3D=3D null || !metadataComplete.booleanValue(); + } + + protected void setMetadataComplete(Boolean metadataComplete) { + this.metadataComplete =3D metadataComplete; + } + + public Boolean getCascadePersist() { + return cascadePersist; + } + + void setCascadePersist(Boolean cascadePersist) { + this.cascadePersist =3D cascadePersist; + } + + public void override(Default globalDefault) { + if ( globalDefault !=3D null ) { + if ( globalDefault.getAccess() !=3D null ) access =3D globalDefault.ge= tAccess(); + if ( globalDefault.getPackageName() !=3D null ) packageName =3D global= Default.getPackageName(); + if ( globalDefault.getSchema() !=3D null ) schema =3D globalDefault.ge= tSchema(); + if ( globalDefault.getCatalog() !=3D null ) catalog =3D globalDefault.= getCatalog(); + if ( globalDefault.getMetadataComplete() !=3D null ) { + metadataComplete =3D globalDefault.getMetadataComplete(); + } + //TODO fix that in stone if cascade-persist is set already? + if ( globalDefault.getCascadePersist() !=3D null ) cascadePersist =3D = globalDefault.getCascadePersist(); + } + } + } + + public List getDefaultEntityListeners() { + return defaultEntityListeners; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/se= arch/HibernateSearchEventListenerRegister.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/searc= h/HibernateSearchEventListenerRegister.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/searc= h/HibernateSearchEventListenerRegister.java 2009-11-24 21:08:28 UTC (rev 18= 050) @@ -0,0 +1,224 @@ +// $Id: HibernateSearchEventListenerRegister.java 14991 2008-07-29 18:20:4= 7Z epbernard $ +package org.hibernate.cfg.search; + +import java.util.Properties; + +import org.hibernate.AnnotationException; +import org.hibernate.event.EventListeners; +import org.hibernate.event.PostCollectionRecreateEventListener; +import org.hibernate.event.PostCollectionRemoveEventListener; +import org.hibernate.event.PostCollectionUpdateEventListener; +import org.hibernate.event.PostDeleteEventListener; +import org.hibernate.event.PostInsertEventListener; +import org.hibernate.event.PostUpdateEventListener; +import org.hibernate.util.ReflectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Helper methods initializing Hibernate Search event listeners. + * = + * @deprecated as of release 3.4.0.CR2, replaced by Hibernate Search's {@l= ink org.hibernate.search.cfg.EventListenerRegister} + * @author Emmanuel Bernard + * @author Hardy Ferentschik + */ +(a)Deprecated = +public class HibernateSearchEventListenerRegister { + + private static final Logger log =3D LoggerFactory.getLogger(HibernateSear= chEventListenerRegister.class); + + /** + * Class name of the class needed to enable Search. + */ + private static final String FULL_TEXT_INDEX_EVENT_LISTENER_CLASS =3D "org= .hibernate.search.event.FullTextIndexEventListener"; + + /** + * @deprecated as of release 3.4.0.CR2, replaced by Hibernate Search's {@= link org.hibernate.search.cfg.EventListenerRegister#enableHibernateSearch(E= ventListeners, Properties)} + */ + @SuppressWarnings("unchecked") + @Deprecated = + public static void enableHibernateSearch(EventListeners eventListeners, P= roperties properties) { + // check whether search is explicitly enabled - if so there is nothing + // to do + String enableSearchListeners =3D properties.getProperty( "hibernate.sear= ch.autoregister_listeners" ); + if("false".equalsIgnoreCase(enableSearchListeners )) { + log.info("Property hibernate.search.autoregister_listeners is set to fa= lse." + + " No attempt will be made to register Hibernate Search event listener= s."); + return; + } + = + // add search events if the jar is available and class can be loaded + Class searchEventListenerClass =3D attemptToLoadSearchEventListener(); + if ( searchEventListenerClass =3D=3D null ) { + log.info("Unable to find {} on the classpath. Hibernate Search is not e= nabled.", FULL_TEXT_INDEX_EVENT_LISTENER_CLASS); + return; + } + = + Object searchEventListener =3D instantiateEventListener(searchEventListe= nerClass); + = + //TODO Generalize this. Pretty much the same code all the time. Reflecet= ion? = + { + boolean present =3D false; + PostInsertEventListener[] listeners =3D eventListeners + .getPostInsertEventListeners(); + if (listeners !=3D null) { + for (Object eventListener : listeners) { + // not isAssignableFrom since the user could subclass + present =3D present + || searchEventListenerClass =3D=3D eventListener + .getClass(); + } + if (!present) { + int length =3D listeners.length + 1; + PostInsertEventListener[] newListeners =3D new PostInsertEventListene= r[length]; + System.arraycopy(listeners, 0, newListeners, 0, length - 1); + newListeners[length - 1] =3D (PostInsertEventListener) searchEventLis= tener; + eventListeners.setPostInsertEventListeners(newListeners); + } + } else { + eventListeners + .setPostInsertEventListeners(new PostInsertEventListener[] { (PostIn= sertEventListener) searchEventListener }); + } + } + { + boolean present =3D false; + PostUpdateEventListener[] listeners =3D eventListeners + .getPostUpdateEventListeners(); + if (listeners !=3D null) { + for (Object eventListener : listeners) { + // not isAssignableFrom since the user could subclass + present =3D present + || searchEventListenerClass =3D=3D eventListener + .getClass(); + } + if (!present) { + int length =3D listeners.length + 1; + PostUpdateEventListener[] newListeners =3D new PostUpdateEventListene= r[length]; + System.arraycopy(listeners, 0, newListeners, 0, length - 1); + newListeners[length - 1] =3D (PostUpdateEventListener) searchEventLis= tener; + eventListeners.setPostUpdateEventListeners(newListeners); + } + } else { + eventListeners + .setPostUpdateEventListeners(new PostUpdateEventListener[] { (PostUp= dateEventListener) searchEventListener }); + } + } + { + boolean present =3D false; + PostDeleteEventListener[] listeners =3D eventListeners + .getPostDeleteEventListeners(); + if (listeners !=3D null) { + for (Object eventListener : listeners) { + // not isAssignableFrom since the user could subclass + present =3D present + || searchEventListenerClass =3D=3D eventListener + .getClass(); + } + if (!present) { + int length =3D listeners.length + 1; + PostDeleteEventListener[] newListeners =3D new PostDeleteEventListene= r[length]; + System.arraycopy(listeners, 0, newListeners, 0, length - 1); + newListeners[length - 1] =3D (PostDeleteEventListener) searchEventLis= tener; + eventListeners.setPostDeleteEventListeners(newListeners); + } + } else { + eventListeners + .setPostDeleteEventListeners(new PostDeleteEventListener[] { (PostDe= leteEventListener) searchEventListener }); + } + } = + { + boolean present =3D false; + PostCollectionRecreateEventListener[] listeners =3D eventListeners.getP= ostCollectionRecreateEventListeners(); + if ( listeners !=3D null ) { + for (Object eventListener : listeners) { + //not isAssignableFrom since the user could subclass + present =3D present || searchEventListenerClass =3D=3D eventListener.= getClass(); + } + if ( !present ) { + int length =3D listeners.length + 1; + PostCollectionRecreateEventListener[] newListeners =3D new PostCollec= tionRecreateEventListener[length]; + System.arraycopy( listeners, 0, newListeners, 0, length - 1 ); + newListeners[length - 1] =3D (PostCollectionRecreateEventListener) se= archEventListener; + eventListeners.setPostCollectionRecreateEventListeners( newListeners = ); + } + } + else { + eventListeners.setPostCollectionRecreateEventListeners( + new PostCollectionRecreateEventListener[] { (PostCollectionRecreateE= ventListener) searchEventListener } + ); + } + } + { + boolean present =3D false; + PostCollectionRemoveEventListener[] listeners =3D eventListeners.getPos= tCollectionRemoveEventListeners(); + if ( listeners !=3D null ) { + for (Object eventListener : listeners) { + //not isAssignableFrom since the user could subclass + present =3D present || searchEventListenerClass =3D=3D eventListener.= getClass(); + } + if ( !present ) { + int length =3D listeners.length + 1; + PostCollectionRemoveEventListener[] newListeners =3D new PostCollecti= onRemoveEventListener[length]; + System.arraycopy( listeners, 0, newListeners, 0, length - 1 ); + newListeners[length - 1] =3D (PostCollectionRemoveEventListener) sear= chEventListener; + eventListeners.setPostCollectionRemoveEventListeners( newListeners ); + } + } + else { + eventListeners.setPostCollectionRemoveEventListeners( + new PostCollectionRemoveEventListener[] { (PostCollectionRemoveEvent= Listener) searchEventListener } + ); + } + } + { + boolean present =3D false; + PostCollectionUpdateEventListener[] listeners =3D eventListeners.getPos= tCollectionUpdateEventListeners(); + if ( listeners !=3D null ) { + for (Object eventListener : listeners) { + //not isAssignableFrom since the user could subclass + present =3D present || searchEventListenerClass =3D=3D eventListener.= getClass(); + } + if ( !present ) { + int length =3D listeners.length + 1; + PostCollectionUpdateEventListener[] newListeners =3D new PostCollecti= onUpdateEventListener[length]; + System.arraycopy( listeners, 0, newListeners, 0, length - 1 ); + newListeners[length - 1] =3D (PostCollectionUpdateEventListener) sear= chEventListener; + eventListeners.setPostCollectionUpdateEventListeners( newListeners ); + } + } + else { + eventListeners.setPostCollectionUpdateEventListeners( + new PostCollectionUpdateEventListener[] { (PostCollectionUpdateEvent= Listener) searchEventListener } + ); + } + } = + } + + /** + * Tries to load Hibernate Search event listener. + * = + * @return An event listener instance in case the jar was available. + */ + private static Class attemptToLoadSearchEventListener() { + Class searchEventListenerClass =3D null; + try { + searchEventListenerClass =3D ReflectHelper.classForName( + FULL_TEXT_INDEX_EVENT_LISTENER_CLASS, + HibernateSearchEventListenerRegister.class); + } catch (ClassNotFoundException e) { + log.debug("Search not present in classpath, ignoring event listener reg= istration."); + } + return searchEventListenerClass; + } + + private static Object instantiateEventListener(Class clazz) { + Object searchEventListener; + try { + searchEventListener =3D clazz.newInstance(); + } catch (Exception e) { + throw new AnnotationException( + "Unable to load Search event listener", e); + } + return searchEventListener; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/mappin= g/IdGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/mapping/I= dGenerator.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/mapping/I= dGenerator.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,52 @@ +//$Id: IdGenerator.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.mapping; + +import java.io.Serializable; +import java.util.Properties; + +/** + * Identifier generator container, + * Useful to keep named generator in annotations + * + * @author Emmanuel Bernard + */ +public class IdGenerator implements Serializable { + private String name; + private String identifierGeneratorStrategy; + private Properties params =3D new Properties(); + + + /** + * @return identifier generator strategy + */ + public String getIdentifierGeneratorStrategy() { + return identifierGeneratorStrategy; + } + + /** + * @return generator name + */ + public String getName() { + return name; + } + + /** + * @return generator configuration parameters + */ + public Properties getParams() { + return params; + } + + public void setIdentifierGeneratorStrategy(String string) { + identifierGeneratorStrategy =3D string; + } + + public void setName(String string) { + name =3D string; + } + + public void addParam(String key, String value) { + params.setProperty( key, value ); + } + +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/A= bstractLobType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Abst= ractLobType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Abst= ractLobType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,67 @@ +//$Id: AbstractLobType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.type; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.hibernate.EntityMode; +import org.hibernate.HibernateException; +import org.hibernate.MappingException; +import org.hibernate.engine.Mapping; +import org.hibernate.engine.SessionImplementor; + +/** + * @author Emmanuel Bernard + */ +public abstract class AbstractLobType extends AbstractType implements Seri= alizable { + public boolean isDirty(Object old, Object current, boolean[] checkable, S= essionImplementor session) + throws HibernateException { + return checkable[0] ? ! isEqual( old, current, session.getEntityMode() )= : false; + } + + @Override + public boolean isEqual(Object x, Object y, EntityMode entityMode) { + return isEqual( x, y, entityMode, null ); + } + + @Override + public int getHashCode(Object x, EntityMode entityMode) { + return getHashCode( x, entityMode, null ); + } + + public String getName() { + return this.getClass().getName(); + } + + public int getColumnSpan(Mapping mapping) throws MappingException { + return 1; + } + + protected abstract Object get(ResultSet rs, String name) throws SQLExcept= ion; + + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplemento= r session, Object owner) + throws HibernateException, SQLException { + return get( rs, names[0] ); + } + + public Object nullSafeGet(ResultSet rs, String name, SessionImplementor s= ession, Object owner) + throws HibernateException, SQLException { + return get( rs, name ); + } + + public void nullSafeSet( + PreparedStatement st, Object value, int index, boolean[] settable, Sess= ionImplementor session + ) throws HibernateException, SQLException { + if ( settable[0] ) set( st, value, index, session ); + } + + protected abstract void set(PreparedStatement st, Object value, int index= , SessionImplementor session) + throws SQLException; + + public void nullSafeSet(PreparedStatement st, Object value, int index, Se= ssionImplementor session) + throws HibernateException, SQLException { + set( st, value, index, session ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/B= yteArrayBlobType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Byte= ArrayBlobType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Byte= ArrayBlobType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,195 @@ +//$Id: ByteArrayBlobType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik= $ +package org.hibernate.type; + +import java.io.ByteArrayInputStream; +import java.sql.Blob; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.Map; + +import org.dom4j.Node; +import org.hibernate.EntityMode; +import org.hibernate.HibernateException; +import org.hibernate.MappingException; +import org.hibernate.engine.Mapping; +import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.lob.BlobImpl; +import org.hibernate.util.ArrayHelper; + +/** + * Map a Byte[] into a Blob + * Experimental + * + * @author Emmanuel Bernard + */ +public class ByteArrayBlobType extends AbstractLobType { + + public int[] sqlTypes(Mapping mapping) throws MappingException { + return new int[]{Types.BLOB}; + } + + @Override + public boolean isEqual(Object x, Object y, EntityMode entityMode, Session= FactoryImplementor factory) { + if ( x =3D=3D y ) return true; + if ( x =3D=3D null || y =3D=3D null ) return false; + if ( x instanceof Byte[] ) { + Object[] o1 =3D (Object[]) x; + Object[] o2 =3D (Object[]) y; + return ArrayHelper.isEquals( o1, o2 ); + } + else { + byte[] c1 =3D (byte[]) x; + byte[] c2 =3D (byte[]) y; + return ArrayHelper.isEquals( c1, c2 ); + } + } + + public int getHashCode(Object x, EntityMode entityMode, SessionFactoryImp= lementor factory) { + if ( x instanceof Character[] ) { + Object[] o =3D (Object[]) x; + return ArrayHelper.hash( o ); + } + else { + byte[] c =3D (byte[]) x; + return ArrayHelper.hash( c ); + } + } + + public Object deepCopy(Object value, EntityMode entityMode, SessionFactor= yImplementor factory) + throws HibernateException { + if ( value =3D=3D null ) return null; + if ( value instanceof Byte[] ) { + Byte[] array =3D (Byte[]) value; + int length =3D array.length; + Byte[] copy =3D new Byte[length]; + for ( int index =3D 0; index < length ; index++ ) { + copy[index] =3D Byte.valueOf( array[index].byteValue() ); + } + return copy; + } + else { + byte[] array =3D (byte[]) value; + int length =3D array.length; + byte[] copy =3D new byte[length]; + System.arraycopy( array, 0, copy, 0, length ); + return copy; + } + } + + public Class getReturnedClass() { + return Byte[].class; + } + + protected Object get(ResultSet rs, String name) throws SQLException { + Blob blob =3D rs.getBlob( name ); + if ( rs.wasNull() ) return null; + int length =3D (int) blob.length(); + byte[] primaryResult =3D blob.getBytes( 1, length ); + return wrap( primaryResult ); + } + + protected void set(PreparedStatement st, Object value, int index, Session= Implementor session) throws SQLException { + if ( value =3D=3D null ) { + st.setNull( index, sqlTypes( null )[0] ); + } + else { + byte[] toSet =3D unWrap( value ); + final boolean useInputStream =3D session.getFactory().getDialect().useI= nputStreamToInsertBlob(); + + if ( useInputStream ) { + st.setBinaryStream( index, new ByteArrayInputStream( toSet ), toSet.le= ngth ); + } + else { + st.setBlob( index, new BlobImpl( toSet ) ); + } + } + } + + public void setToXMLNode(Node node, Object value, SessionFactoryImplement= or factory) throws HibernateException { + node.setText( toString( value ) ); + } + + public String toString(Object val) { + byte[] bytes =3D unWrap( val ); + StringBuilder buf =3D new StringBuilder( 2 * bytes.length ); + for ( int i =3D 0; i < bytes.length ; i++ ) { + String hexStr =3D Integer.toHexString( bytes[i] - Byte.MIN_VALUE ); + if ( hexStr.length() =3D=3D 1 ) buf.append( '0' ); + buf.append( hexStr ); + } + return buf.toString(); + } + + public String toLoggableString(Object value, SessionFactoryImplementor fa= ctory) { + return value =3D=3D null ? "null" : toString( value ); + } + + public Object fromXMLNode(Node xml, Mapping factory) throws HibernateExce= ption { + String xmlText =3D xml.getText(); + return xmlText =3D=3D null || xmlText.length() =3D=3D 0 ? null : fromStr= ing( xmlText ); + } + + private Object fromString(String xmlText) { + if ( xmlText =3D=3D null ) { + return null; + } + if ( xmlText.length() % 2 !=3D 0 ) { + throw new IllegalArgumentException( "The string is not a valid xml repr= esentation of a binary content." ); + } + byte[] bytes =3D new byte[xmlText.length() / 2]; + for ( int i =3D 0; i < bytes.length ; i++ ) { + String hexStr =3D xmlText.substring( i * 2, ( i + 1 ) * 2 ); + bytes[i] =3D (byte) ( Integer.parseInt( hexStr, 16 ) + Byte.MIN_VALUE ); + } + return wrap( bytes ); + } + + protected Object wrap(byte[] bytes) { + return wrapPrimitive( bytes ); + } + + protected byte[] unWrap(Object bytes) { + return unwrapNonPrimitive( (Byte[]) bytes ); + } + + private byte[] unwrapNonPrimitive(Byte[] bytes) { + int length =3D bytes.length; + byte[] result =3D new byte[length]; + for ( int i =3D 0; i < length ; i++ ) { + result[i] =3D bytes[i].byteValue(); + } + return result; + } + + private Byte[] wrapPrimitive(byte[] bytes) { + int length =3D bytes.length; + Byte[] result =3D new Byte[length]; + for ( int index =3D 0; index < length ; index++ ) { + result[index] =3D Byte.valueOf( bytes[index] ); + } + return result; + } + + public boolean isMutable() { + return true; + } + + public Object replace( + Object original, + Object target, + SessionImplementor session, + Object owner, + Map copyCache + ) + throws HibernateException { + if ( isEqual( original, target, session.getEntityMode() ) ) return origi= nal; + return deepCopy( original, session.getEntityMode(), session.getFactory()= ); + } + + public boolean[] toColumnNullness(Object value, Mapping mapping) { + return value =3D=3D null ? ArrayHelper.FALSE : ArrayHelper.TRUE; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/C= haracterArrayClobType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Char= acterArrayClobType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Char= acterArrayClobType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,148 @@ +//$Id: CharacterArrayClobType.java 14736 2008-06-04 14:23:42Z hardy.ferent= schik $ +package org.hibernate.type; + +import java.io.CharArrayReader; +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.ArrayList; + +import org.hibernate.HibernateException; +import org.hibernate.usertype.UserType; +import org.hibernate.util.ArrayHelper; + +/** + * Map a Character[] to a Clob + * Experimental + * + * @author Emmanuel Bernard + */ +public class CharacterArrayClobType implements UserType, Serializable { + public static final int BUFFER_SIZE =3D 4096; + + public int[] sqlTypes() { + return new int[]{Types.CLOB}; + } + + public Class returnedClass() { + return Character[].class; + } + + public boolean equals(Object x, Object y) throws HibernateException { + if ( x =3D=3D y ) return true; + if ( x =3D=3D null || y =3D=3D null ) return false; + if ( x instanceof Character[] ) { + Object[] o1 =3D (Object[]) x; + Object[] o2 =3D (Object[]) y; + return ArrayHelper.isEquals( o1, o2 ); + } + else { + char[] c1 =3D (char[]) x; + char[] c2 =3D (char[]) y; + return ArrayHelper.isEquals( c1, c2 ); + } + } + + public int hashCode(Object x) throws HibernateException { + if ( x instanceof Character[] ) { + Object[] o =3D (Object[]) x; + return ArrayHelper.hash( o ); + } + else { + char[] c =3D (char[]) x; + return ArrayHelper.hash( c ); + } + } + + public Object nullSafeGet(ResultSet rs, String[] names, Object owner) thr= ows HibernateException, SQLException { + Reader reader =3D rs.getCharacterStream( names[0] ); + if ( reader =3D=3D null ) return null; + ArrayList result =3D new ArrayList(); + try { + char[] charbuf =3D new char[BUFFER_SIZE]; + for ( int i =3D reader.read( charbuf ); i > 0 ; i =3D reader.read( char= buf ) ) { + result.ensureCapacity( result.size() + BUFFER_SIZE ); + for ( int charIndex =3D 0; charIndex < i ; charIndex++ ) { + result.add( Character.valueOf( charbuf[charIndex] ) ); + } + } + } + catch (IOException e) { + throw new SQLException( e.getMessage() ); + } + if ( returnedClass().equals( Character[].class ) ) { + return result.toArray( new Character[ result.size() ] ); + } + else { + //very suboptimal + int length =3D result.size(); + char[] chars =3D new char[length]; + for ( int index =3D 0; index < length ; index++ ) { + chars[index] =3D ( (Character) result.get( index ) ).charValue(); + } + return chars; + } + } + + public void nullSafeSet(PreparedStatement st, Object value, int index) th= rows HibernateException, SQLException { + if ( value !=3D null ) { + char[] chars; + if ( value instanceof Character[] ) { + Character[] character =3D (Character[]) value; + int length =3D character.length; + chars =3D new char[length]; + for ( int i =3D 0; i < length ; i++ ) { + chars[i] =3D character[i].charValue(); + } + } + else { + chars =3D (char[]) value; + } + CharArrayReader reader =3D new CharArrayReader( chars ); + st.setCharacterStream( index, reader, chars.length ); + } + else { + st.setNull( index, sqlTypes()[0] ); + } + } + + public Object deepCopy(Object value) throws HibernateException { + if ( value =3D=3D null ) return null; + if ( value instanceof Character[] ) { + Character[] array =3D (Character[]) value; + int length =3D array.length; + Character[] copy =3D new Character[length]; + for ( int index =3D 0; index < length ; index++ ) { + copy[index] =3D Character.valueOf( array[index].charValue() ); + } + return copy; + } + else { + char[] array =3D (char[]) value; + int length =3D array.length; + char[] copy =3D new char[length]; + System.arraycopy( array, 0, copy, 0, length ); + return copy; + } + } + + public boolean isMutable() { + return true; + } + + public Serializable disassemble(Object value) throws HibernateException { + return (Serializable) deepCopy( value ); + } + + public Object assemble(Serializable cached, Object owner) throws Hibernat= eException { + return deepCopy( cached ); + } + + public Object replace(Object original, Object target, Object owner) throw= s HibernateException { + return deepCopy( original ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/E= numType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Enum= Type.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Enum= Type.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,269 @@ +//$Id: EnumType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.type; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.Serializable; +import java.lang.reflect.Method; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.hibernate.AssertionFailure; +import org.hibernate.HibernateException; +import org.hibernate.annotations.common.util.StringHelper; +import org.hibernate.usertype.EnhancedUserType; +import org.hibernate.usertype.ParameterizedType; +import org.hibernate.util.ReflectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Enum type mapper + * Try and find the appropriate SQL type depending on column metadata + * + * @author Emmanuel Bernard + */ +//TODO implements readobject/writeobject to recalculate the enumclasses +public class EnumType implements EnhancedUserType, ParameterizedType, Seri= alizable { + /** + * This is the old scheme where logging of parameter bindings and value e= xtractions + * was controlled by the trace level enablement on the 'org.hibernate.typ= e' package... + *

    + * Originally was cached such because of performance of looking up the lo= gger each time + * in order to check the trace-enablement. Driving this via a central Lo= g-specific class + * would alleviate that performance hit, and yet still allow more "normal= " logging usage/config. + */ + private static final boolean IS_VALUE_TRACING_ENABLED =3D LoggerFactory.g= etLogger( StringHelper.qualifier( Type.class.getName() ) ).isTraceEnabled(); + private transient Logger log; + + private Logger log() { + if ( log =3D=3D null ) { + log =3D LoggerFactory.getLogger( getClass() ); + } + return log; + } + + public static final String ENUM =3D "enumClass"; + public static final String SCHEMA =3D "schema"; + public static final String CATALOG =3D "catalog"; + public static final String TABLE =3D "table"; + public static final String COLUMN =3D "column"; + public static final String TYPE =3D "type"; + + private static Map enumValues =3D new HashMap(); + + private Class enumClass; + private String column; + private String table; + private String catalog; + private String schema; + private boolean guessed =3D false; + private int sqlType =3D Types.INTEGER; //before any guessing + + public int[] sqlTypes() { + return new int[]{sqlType}; + } + + public Class returnedClass() { + return enumClass; + } + + public boolean equals(Object x, Object y) throws HibernateException { + return x =3D=3D y; + } + + public int hashCode(Object x) throws HibernateException { + return x =3D=3D null ? 0 : x.hashCode(); + } + + public Object nullSafeGet(ResultSet rs, String[] names, Object owner) thr= ows HibernateException, SQLException { + Object object =3D rs.getObject( names[0] ); + if ( rs.wasNull() ) { + if ( IS_VALUE_TRACING_ENABLED ) { + log().debug( "Returning null as column {}", names[0] ); + } + return null; + } + if ( object instanceof Number ) { + Object[] values =3D enumValues.get( enumClass ); + if ( values =3D=3D null ) throw new AssertionFailure( "enumValues not p= reprocessed: " + enumClass ); + int ordinal =3D ( (Number) object ).intValue(); + if ( ordinal < 0 || ordinal >=3D values.length ) { + throw new IllegalArgumentException( "Unknown ordinal value for enum " = + enumClass + ": " + ordinal ); + } + if ( IS_VALUE_TRACING_ENABLED ) { + log().debug( "Returning '{}' as column {}", ordinal, names[0] ); + } + return values[ordinal]; + } + else { + String name =3D (String) object; + if ( IS_VALUE_TRACING_ENABLED ) { + log().debug( "Returning '{}' as column {}", name, names[0] ); + } + try { + return Enum.valueOf( enumClass, name ); + } + catch (IllegalArgumentException iae) { + throw new IllegalArgumentException( "Unknown name value for enum " + e= numClass + ": " + name, iae ); + } + } + } + + public void nullSafeSet(PreparedStatement st, Object value, int index) th= rows HibernateException, SQLException { + //if (!guessed) guessType( st, index ); + if ( value =3D=3D null ) { + if ( IS_VALUE_TRACING_ENABLED ) log().debug( "Binding null to parameter= : {}", index ); + st.setNull( index, sqlType ); + } + else { + boolean isOrdinal =3D isOrdinal( sqlType ); + if ( isOrdinal ) { + int ordinal =3D ( (Enum) value ).ordinal(); + if ( IS_VALUE_TRACING_ENABLED ) { + log().debug( "Binding '{}' to parameter: {}", ordinal, index ); + } + st.setObject( index, Integer.valueOf( ordinal ), sqlType ); + } + else { + String enumString =3D ( (Enum) value ).name(); + if ( IS_VALUE_TRACING_ENABLED ) { + log().debug( "Binding '{}' to parameter: {}", enumString, index ); + } + st.setObject( index, enumString, sqlType ); + } + } + } + + private boolean isOrdinal(int paramType) { + switch ( paramType ) { + case Types.INTEGER: + case Types.NUMERIC: + case Types.SMALLINT: + case Types.TINYINT: + case Types.BIGINT: + case Types.DECIMAL: //for Oracle Driver + case Types.DOUBLE: //for Oracle Driver + case Types.FLOAT: //for Oracle Driver + return true; + case Types.CHAR: + case Types.LONGVARCHAR: + case Types.VARCHAR: + return false; + default: + throw new HibernateException( "Unable to persist an Enum in a column o= f SQL Type: " + paramType ); + } + } + + public Object deepCopy(Object value) throws HibernateException { + return value; + } + + public boolean isMutable() { + return false; + } + + public Serializable disassemble(Object value) throws HibernateException { + return (Serializable) value; + } + + public Object assemble(Serializable cached, Object owner) throws Hibernat= eException { + return cached; + } + + public Object replace(Object original, Object target, Object owner) throw= s HibernateException { + return original; + } + + public void setParameterValues(Properties parameters) { + String enumClassName =3D parameters.getProperty( ENUM ); + try { + enumClass =3D ReflectHelper.classForName( enumClassName, this.getClass(= ) ).asSubclass( Enum.class ); + } + catch (ClassNotFoundException exception) { + throw new HibernateException( "Enum class not found", exception ); + } + //this is threadsafe to do it here, setParameterValues() is called seque= ncially + initEnumValue(); + //nullify unnullified properties yuck! + schema =3D parameters.getProperty( SCHEMA ); + if ( "".equals( schema ) ) schema =3D null; + catalog =3D parameters.getProperty( CATALOG ); + if ( "".equals( catalog ) ) catalog =3D null; + table =3D parameters.getProperty( TABLE ); + column =3D parameters.getProperty( COLUMN ); + String type =3D parameters.getProperty( TYPE ); + if ( type !=3D null ) { + sqlType =3D Integer.decode( type ).intValue(); + guessed =3D true; + } + } + + private void initEnumValue() { + Object[] values =3D enumValues.get( enumClass ); + if ( values =3D=3D null ) { + try { + Method method =3D null; + method =3D enumClass.getDeclaredMethod( "values", new Class[0] ); + values =3D (Object[]) method.invoke( null, new Object[0] ); + enumValues.put( enumClass, values ); + } + catch (Exception e) { + throw new HibernateException( "Error while accessing enum.values(): " = + enumClass, e ); + } + } + } + + private void readObject(ObjectInputStream ois) throws IOException, ClassN= otFoundException { + //FIXME Hum, I think I break the thread safety here + ois.defaultReadObject(); + initEnumValue(); + } + + public String objectToSQLString(Object value) { + boolean isOrdinal =3D isOrdinal( sqlType ); + if ( isOrdinal ) { + int ordinal =3D ( (Enum) value ).ordinal(); + return Integer.toString( ordinal ); + } + else { + return '\'' + ( (Enum) value ).name() + '\''; + } + } + + public String toXMLString(Object value) { + boolean isOrdinal =3D isOrdinal( sqlType ); + if ( isOrdinal ) { + int ordinal =3D ( (Enum) value ).ordinal(); + return Integer.toString( ordinal ); + } + else { + return ( (Enum) value ).name(); + } + } + + public Object fromXMLString(String xmlValue) { + try { + int ordinal =3D Integer.parseInt( xmlValue ); + Object[] values =3D enumValues.get( enumClass ); + if ( values =3D=3D null ) throw new AssertionFailure( "enumValues not p= reprocessed: " + enumClass ); + if ( ordinal < 0 || ordinal >=3D values.length ) { + throw new IllegalArgumentException( "Unknown ordinal value for enum " = + enumClass + ": " + ordinal ); + } + return values[ordinal]; + } + catch(NumberFormatException e) { + try { + return Enum.valueOf( enumClass, xmlValue ); + } + catch (IllegalArgumentException iae) { + throw new IllegalArgumentException( "Unknown name value for enum " + e= numClass + ": " + xmlValue, iae ); + } + } + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/P= rimitiveByteArrayBlobType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Prim= itiveByteArrayBlobType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Prim= itiveByteArrayBlobType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,21 @@ +//$Id: PrimitiveByteArrayBlobType.java 14736 2008-06-04 14:23:42Z hardy.fe= rentschik $ +package org.hibernate.type; + +/** + * Map a byte[] to a Blob + * + * @author Emmanuel Bernard + */ +public class PrimitiveByteArrayBlobType extends ByteArrayBlobType { + public Class getReturnedClass() { + return byte[].class; + } + + protected Object wrap(byte[] bytes) { + return bytes; + } + + protected byte[] unWrap(Object bytes) { + return (byte[]) bytes; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/P= rimitiveCharacterArrayClobType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Prim= itiveCharacterArrayClobType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Prim= itiveCharacterArrayClobType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,14 @@ +//$Id: PrimitiveCharacterArrayClobType.java 14736 2008-06-04 14:23:42Z har= dy.ferentschik $ +package org.hibernate.type; + + +/** + * Map a char[] to a Clob + * + * @author Emmanuel Bernard + */ +public class PrimitiveCharacterArrayClobType extends CharacterArrayClobTyp= e { + public Class returnedClass() { + return char[].class; + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/S= erializableToBlobType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Seri= alizableToBlobType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Seri= alizableToBlobType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,135 @@ +//$Id: SerializableToBlobType.java 17982 2009-11-14 13:18:39Z stliu $ +package org.hibernate.type; + +import java.io.ByteArrayInputStream; +import java.io.Serializable; +import java.sql.Blob; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.Map; +import java.util.Properties; + +import org.dom4j.Node; +import org.hibernate.EntityMode; +import org.hibernate.HibernateException; +import org.hibernate.MappingException; +import org.hibernate.engine.Mapping; +import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.lob.BlobImpl; +import org.hibernate.usertype.ParameterizedType; +import org.hibernate.util.ReflectHelper; +import org.hibernate.util.SerializationHelper; + +/** + * @author Emmanuel Bernard + */ +public class SerializableToBlobType extends AbstractLobType implements Par= ameterizedType { + /** + * class name of the serialisable class + */ + public static final String CLASS_NAME =3D "classname"; + private Class serializableClass; + private SerializableType type; + + public int[] sqlTypes(Mapping mapping) throws MappingException { + return new int[]{Types.BLOB}; + } + + public Class getReturnedClass() { + return serializableClass; + } + + @Override + public boolean isEqual(Object x, Object y, EntityMode entityMode, Session= FactoryImplementor factory) { + return type.isEqual( x, y ); + } + + + @Override + public int getHashCode(Object x, EntityMode entityMode, SessionFactoryImp= lementor session) { + return type.getHashCode( x, null ); + } + + public Object get(ResultSet rs, String name) throws SQLException { + Blob blob =3D rs.getBlob( name ); + if ( rs.wasNull() ) return null; + int length =3D (int) blob.length(); + byte[] primaryResult =3D blob.getBytes( 1, length ); + return fromBytes( primaryResult ); + } + + private static byte[] toBytes(Object object) throws SerializationExceptio= n { + return SerializationHelper.serialize( (Serializable) object ); + } + + private Object fromBytes(byte[] bytes) throws SerializationException { + return SerializationHelper.deserialize( bytes, getReturnedClass().getCla= ssLoader() ); + } + + public void set(PreparedStatement st, Object value, int index, SessionImp= lementor session) throws SQLException { + if ( value !=3D null ) { + byte[] toSet; + toSet =3D toBytes( value ); + if ( session.getFactory().getDialect().useInputStreamToInsertBlob() ) { + st.setBinaryStream( index, new ByteArrayInputStream( toSet ), toSet.le= ngth ); + } + else { + st.setBlob( index, new BlobImpl( toSet ) ); + } + } + else { + st.setNull( index, sqlTypes( null )[0] ); + } + } + + public void setToXMLNode(Node node, Object value, SessionFactoryImplement= or factory) throws HibernateException { + type.setToXMLNode( node, value, factory ); + } + + public String toLoggableString(Object value, SessionFactoryImplementor fa= ctory) throws HibernateException { + return type.toLoggableString( value, factory ); + } + + public Object fromXMLNode(Node xml, Mapping factory) throws HibernateExce= ption { + return type.fromXMLNode( xml, factory ); + } + + public Object deepCopy(Object value, EntityMode entityMode, SessionFactor= yImplementor factory) + throws HibernateException { + return type.deepCopy( value, null, null ); + } + + public boolean isMutable() { + return type.isMutable(); + } + + public Object replace(Object original, Object target, SessionImplementor = session, Object owner, Map copyCache) + throws HibernateException { + return type.replace( original, target, session, owner, copyCache ); + } + + public boolean[] toColumnNullness(Object value, Mapping mapping) { + return type.toColumnNullness( value, mapping ); + } + + public void setParameterValues(Properties parameters) { + if ( parameters !=3D null ) { + String className =3D parameters.getProperty( CLASS_NAME ); + if ( className =3D=3D null ) { + throw new MappingException( + "No class name defined for type: " + SerializableToBlobType.class.ge= tName() + ); + } + try { + serializableClass =3D ReflectHelper.classForName( className ); + } + catch (ClassNotFoundException e) { + throw new MappingException( "Unable to load class from " + CLASS_NAME = + " parameter", e ); + } + } + type =3D new SerializableType( serializableClass ); + } +} Added: annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/S= tringClobType.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Stri= ngClobType.java (rev 0) +++ annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/type/Stri= ngClobType.java 2009-11-24 21:08:28 UTC (rev 18050) @@ -0,0 +1,85 @@ +//$Id: StringClobType.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $ +package org.hibernate.type; + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.StringReader; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; + +import org.hibernate.HibernateException; +import org.hibernate.usertype.UserType; + +/** + * Map a String to a Clob + * + * @author Emmanuel Bernard + */ +public class StringClobType implements UserType, Serializable { + public int[] sqlTypes() { + return new int[]{Types.CLOB}; + } + + public Class returnedClass() { + return String.class; + } + + public boolean equals(Object x, Object y) throws HibernateException { + return ( x =3D=3D y ) || ( x !=3D null && x.equals( y ) ); + } + + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + + public Object nullSafeGet(ResultSet rs, String[] names, Object owner) thr= ows HibernateException, SQLException { + Reader reader =3D rs.getCharacterStream( names[0] ); + if ( reader =3D=3D null ) return null; + StringBuilder result =3D new StringBuilder( 4096 ); + try { + char[] charbuf =3D new char[4096]; + for ( int i =3D reader.read( charbuf ); i > 0 ; i =3D reader.read( char= buf ) ) { + result.append( charbuf, 0, i ); + } + } + catch (IOException e) { + throw new SQLException( e.getMessage() ); + } + return result.toString(); + } + + public void nullSafeSet(PreparedStatement st, Object value, int index) th= rows HibernateException, SQLException { + if ( value !=3D null ) { + String string =3D (String) value; + StringReader reader =3D new StringReader( string ); + st.setCharacterStream( index, reader, string.length() ); + } + else { + st.setNull( index, sqlTypes()[0] ); + } + } + + public Object deepCopy(Object value) throws HibernateException { + //returning value should be OK since String are immutable + return value; + } + + public boolean isMutable() { + return false; + } + + public Serializable disassemble(Object value) throws HibernateException { + return (Serializable) value; + } + + public Object assemble(Serializable cached, Object owner) throws Hibernat= eException { + return cached; + } + + public Object replace(Object original, Object target, Object owner) throw= s HibernateException { + return original; + } +} --===============7939145156186056277==-- From hibernate-commits at lists.jboss.org Tue Nov 24 16:14:30 2009 Content-Type: multipart/mixed; boundary="===============3733507623778360722==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18051 - annotations/branches/v3_4_0_GA_CP/src. Date: Tue, 24 Nov 2009 16:14:30 -0500 Message-ID: <200911242114.nAOLEUX3003025@svn01.web.mwc.hst.phx2.redhat.com> --===============3733507623778360722== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-24 16:14:30 -0500 (Tue, 24 Nov 2009) New Revision: 18051 Removed: annotations/branches/v3_4_0_GA_CP/src/java/ Log: JBPAPP-3150 change the build tool of Hibernate Annotations(eap 5 cp branch) --===============3733507623778360722==-- From hibernate-commits at lists.jboss.org Tue Nov 24 17:28:06 2009 Content-Type: multipart/mixed; boundary="===============4220835117825460654==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18052 - validator/trunk/hibernate-validator-tck-runner. Date: Tue, 24 Nov 2009 17:28:05 -0500 Message-ID: <200911242228.nAOMS53R016815@svn01.web.mwc.hst.phx2.redhat.com> --===============4220835117825460654== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-24 17:28:05 -0500 (Tue, 24 Nov 2009) New Revision: 18052 Modified: validator/trunk/hibernate-validator-tck-runner/pom.xml Log: upgraded TCK version Modified: validator/trunk/hibernate-validator-tck-runner/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-11-24 21:14= :30 UTC (rev 18051) +++ validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-11-24 22:28= :05 UTC (rev 18052) @@ -32,7 +32,7 @@ org.hibernate.jsr303.tck jsr303-tck - 1.0.2-SNAPSHOT + 1.0.2.GA org.jboss.test-harness --===============4220835117825460654==-- From hibernate-commits at lists.jboss.org Tue Nov 24 18:59:51 2009 Content-Type: multipart/mixed; boundary="===============9150947960728072676==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18053 - in core/trunk: core/src/main/java/org/hibernate/engine and 9 other directories. Date: Tue, 24 Nov 2009 18:59:51 -0500 Message-ID: <200911242359.nAONxpZR031544@svn01.web.mwc.hst.phx2.redhat.com> --===============9150947960728072676== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: smarlow(a)redhat.com Date: 2009-11-24 18:59:50 -0500 (Tue, 24 Nov 2009) New Revision: 18053 Added: core/trunk/core/src/main/java/org/hibernate/LockOptions.java Removed: core/trunk/core/src/main/java/org/hibernate/LockRequest.java Modified: core/trunk/core/src/main/java/org/hibernate/Session.java core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgrad= eEventListener.java core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventLi= stener.java core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventLi= stener.java core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEven= tListener.java core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWal= ker.java core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntity= Loader.java core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalk= er.java core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityLoader.j= ava core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEnt= ityPersister.java core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPersi= ster.java core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityM= anagerImpl.java core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersi= ster.java Log: HHH-4546 add JPA 2.0 locking. Introduce LockOptions as the wrapper and ses= sion.buildLockRequest() (replaces session.lock()). Copied: core/trunk/core/src/main/java/org/hibernate/LockOptions.java (from = rev 18016, core/trunk/core/src/main/java/org/hibernate/LockRequest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/LockOptions.java = (rev 0) +++ core/trunk/core/src/main/java/org/hibernate/LockOptions.java 2009-11-24= 23:59:50 UTC (rev 18053) @@ -0,0 +1,114 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2009, 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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; + +/** + * Contains locking details (LockMode, Timeout and Scope). + * = + * @author Scott Marlow + */ +public class LockOptions +{ + + public static final int NO_WAIT =3D 0; + public static final int WAIT_FOREVER =3D -1; + + private LockMode lockMode =3D LockMode.NONE; + + private int timeout =3D WAIT_FOREVER; // timeout in milliseconds, 0 =3D n= o wait, -1 =3D wait indefinitely + + private boolean scope=3Dfalse;// if true, cascade (pessimistic only) lock= to collections and relationships + // owned by the entity. + + public LockOptions() { + + } + + + public LockOptions( LockMode lockMode) { + this.lockMode =3D lockMode; + } + + /** + * Get the lock mode. + * @return the lock mode. + */ + public LockMode getLockMode() { + return lockMode; + } + + /** + * Specify the LockMode to be used. The default is LockMode.none. + * + * @param lockMode + * @return this LockRequest instance for operation chaining. + */ + public LockOptions setLockMode(LockMode lockMode) { + this.lockMode =3D lockMode; + return this; + } + + /** + * Get the timeout setting. + * + * @return timeout in milliseconds, -1 for indefinite wait and 0 for no w= ait. + */ + public int getTimeOut() { + return timeout; + } + + /** + * Specify the pessimistic lock timeout (check if your dialect supports t= his option). + * The default pessimistic lock behavior is to wait forever for the lock. + * + * @param timeout is time in milliseconds to wait for lock. -1 means wai= t forever and 0 means no wait. + * @return this LockRequest instance for operation chaining. + */ + public LockOptions setTimeOut(int timeout) { + this.timeout =3D timeout; + return this; + } + + /** + * Check if locking is cascaded to owned collections and relationships. + * @return true if locking will be extended to owned collections and rela= tionships. + */ + public boolean getScope() { + return scope; + } + + /** + * Specify if LockMode should be cascaded to owned collections and relati= onships. + * The association must be mapped with cascade=3D"lock" for scope=3Dt= rue to work. + * + * @param scope + * @return + */ + public LockOptions setScope(boolean scope) { + this.scope =3D scope; + return this; + } + +} Deleted: core/trunk/core/src/main/java/org/hibernate/LockRequest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/LockRequest.java 2009-11-24= 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/LockRequest.java 2009-11-24= 23:59:50 UTC (rev 18053) @@ -1,115 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2009, 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, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * 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; - -/** - * Contains locking details (LockMode, Timeout and Scope). - * = - * @author Scott Marlow - */ -public class LockRequest -{ - - public static final int NO_WAIT =3D 0; - public static final int WAIT_FOREVER =3D -1; - - private LockMode lockMode =3D LockMode.NONE; - - private int timeout =3D WAIT_FOREVER; // timeout in milliseconds, 0 =3D n= o wait, -1 =3D wait indefinitely - - private boolean scope=3Dfalse;// if true, cascade (pessimistic only) lock= to collections and relationships - // owned by the entity. - - public LockRequest() { - - } - = - public LockRequest( LockMode lockMode, int timeout, boolean scope ) { - this.lockMode =3D lockMode; - this.timeout =3D timeout; - this.scope =3D scope; - } - - /** - * Get the lock mode. - * @return the lock mode. - */ - public LockMode getLockMode() { - return lockMode; - } - - /** - * Specify the LockMode to be used. The default is LockMode.none. - * - * @param lockMode - * @return this LockRequest instance for operation chaining. - */ - public LockRequest setLockMode(LockMode lockMode) { - this.lockMode =3D lockMode; - return this; - } - - /** - * Get the timeout setting. - * - * @return timeout in milliseconds, -1 for indefinite wait and 0 for no w= ait. - */ - public int getTimeOut() { - return timeout; - } - - /** - * Specify the pessimistic lock timeout (check if your dialect supports t= his option). - * The default pessimistic lock behavior is to wait forever for the lock. - * - * @param timeout is time in milliseconds to wait for lock. -1 means wai= t forever and 0 means no wait. - * @return this LockRequest instance for operation chaining. - */ - public LockRequest setTimeOut(int timeout) { - this.timeout =3D timeout; - return this; - } - - /** - * Check if locking is cascaded to owned collections and relationships. - * @return true if locking will be extended to owned collections and rela= tionships. - */ - public boolean getScope() { - return scope; - } - - /** - * Specify if LockMode should be cascaded to owned collections and relati= onships. - * The association must be mapped with cascade=3D"lock" for scope=3Dt= rue to work. - * - * @param scope - * @return - */ - public LockRequest setScope(boolean scope) { - this.scope =3D scope; - return this; - } - -} Modified: core/trunk/core/src/main/java/org/hibernate/Session.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/Session.java 2009-11-24 22:= 28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/Session.java 2009-11-24 23:= 59:50 UTC (rev 18053) @@ -270,7 +270,7 @@ * @param lockMode the lock level * @return the persistent instance or proxy * @throws HibernateException - * @deprecated LockMode parameter should be replaced with a LockRequest + * @deprecated LockMode parameter should be replaced with LockOptions */ public Object load(Class theClass, Serializable id, LockMode lockMode) th= rows HibernateException; = @@ -280,11 +280,11 @@ * * @param theClass a persistent class * @param id a valid identifier of an existing persistent instance of the= class - * @param lockRequest contains the lock level + * @param lockOptions contains the lock level * @return the persistent instance or proxy * @throws HibernateException */ - public Object load(Class theClass, Serializable id, LockRequest lockReque= st) throws HibernateException; + public Object load(Class theClass, Serializable id, LockOptions lockOptio= ns) throws HibernateException; = /** * Return the persistent instance of the given entity class with the give= n identifier, @@ -295,7 +295,7 @@ * @param lockMode the lock level * @return the persistent instance or proxy * @throws HibernateException - * @deprecated LockMode parameter should be replaced with a LockRequest + * @deprecated LockMode parameter should be replaced with LockOptions */ public Object load(String entityName, Serializable id, LockMode lockMode)= throws HibernateException; = @@ -305,11 +305,11 @@ * * @param entityName a persistent class * @param id a valid identifier of an existing persistent instance of the= class - * @param lockRequest contains the lock level + * @param lockOptions contains the lock level * @return the persistent instance or proxy * @throws HibernateException */ - public Object load(String entityName, Serializable id, LockRequest lockRe= quest) throws HibernateException; + public Object load(String entityName, Serializable id, LockOptions lockOp= tions) throws HibernateException; = /** * Return the persistent instance of the given entity class with the give= n identifier, @@ -533,7 +533,7 @@ * @param object a persistent or transient instance * @param lockMode the lock level * @throws HibernateException - * @deprecated LockMode parameter should be replaced with a LockRequest + * @deprecated instead call buildLockRequest(LockMode).lock(object) */ public void lock(Object object, LockMode lockMode) throws HibernateExcept= ion; = @@ -542,51 +542,27 @@ * perform a version check (LockMode.OPTIMISTIC), to upgrade to = a pessimistic * lock (LockMode.PESSIMISTIC_WRITE), or to simply reassociate a= transient instance * with a session (LockMode.NONE). This operation cascades to as= sociated - * instances if the association is mapped with cascade=3D"lock" and l= ockRequest.getScope() =3D=3D true. - * - * @param object a persistent or transient instance - * @param lockRequest contains the lock level - * @throws HibernateException - */ - public void lock(Object object, LockRequest lockRequest) throws Hibernate= Exception; - - /** - * Obtain the specified lock level upon the given object. This may be use= d to - * perform a version check (LockMode.OPTIMISTIC), to upgrade to = a pessimistic - * lock (LockMode.PESSIMISTIC_WRITE), or to simply reassociate a= transient instance - * with a session (LockMode.NONE). This operation cascades to as= sociated * instances if the association is mapped with cascade=3D"lock". * * @param object a persistent or transient instance * @param lockMode the lock level * @throws HibernateException - * @deprecated LockMode parameter should be replaced with a LockRequest + * @deprecated instead call buildLockRequest(LockMode).lock(entityName, o= bject) */ public void lock(String entityName, Object object, LockMode lockMode) thr= ows HibernateException; = /** - * Obtain the specified lock level upon the given object. This may be use= d to - * perform a version check (LockMode.OPTIMISTIC), to upgrade to = a pessimistic - * lock (LockMode.PESSIMISTIC_WRITE), or to simply reassociate a= transient instance - * with a session (LockMode.NONE). This operation cascades to as= sociated - * instances if the association is mapped with cascade=3D"lock" and l= ockRequest.getScope() =3D=3D true.. - * - * @param object a persistent or transient instance - * @param lockRequest contains the lock level - * @throws HibernateException - */ - public void lock(String entityName, Object object, LockRequest lockReques= t) throws HibernateException; - - /** * Build a lockRequest that specifies the LockMode, pessimistic lock time= out and lock scope. * timeout and scope is ignored for optimistic locking. * - * Use: LockRequest lr =3D session.buildLockRequest().setLockMode(LockMod= e.PESSIMISTIC_WRITE).setTimeOut(1000 * 60); - * session.lock(entity, lr); + * Use: session.buildLockRequest(). + * setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(1000 * 60).loc= k(entity); * + * @param lockOptions contains the lock level + * @return a lockRequest that can be used to lock the passed object. * @throws HibernateException */ - LockRequest buildLockRequest(); + public LockRequest buildLockRequest(LockOptions lockOptions); = /** * Re-read the state of the given instance from the underlying database. = It is @@ -613,7 +589,7 @@ * @param object a persistent or detached instance * @param lockMode the lock mode to use * @throws HibernateException - * @deprecated LockMode parameter should be replaced with a LockRequest + * @deprecated LockMode parameter should be replaced with LockOptions */ public void refresh(Object object, LockMode lockMode) throws HibernateExc= eption; = @@ -624,10 +600,10 @@ * useful in certain special circumstances. * * @param object a persistent or detached instance - * @param lockRequest contains the lock mode to use + * @param lockOptions contains the lock mode to use * @throws HibernateException */ - public void refresh(Object object, LockRequest lockRequest) throws Hibern= ateException; + public void refresh(Object object, LockOptions lockOptions) throws Hibern= ateException; = /** * Determine the current lock mode of the given object. @@ -766,7 +742,7 @@ * @param lockMode the lock mode * @return a persistent instance or null * @throws HibernateException - * @deprecated LockMode parameter should be replaced with a LockRequest + * @deprecated LockMode parameter should be replaced with LockOptions */ public Object get(Class clazz, Serializable id, LockMode lockMode) throws= HibernateException; = @@ -778,11 +754,11 @@ * * @param clazz a persistent class * @param id an identifier - * @param lockRequest the lock mode + * @param lockOptions the lock mode * @return a persistent instance or null * @throws HibernateException */ - public Object get(Class clazz, Serializable id, LockRequest lockRequest) = throws HibernateException; + public Object get(Class clazz, Serializable id, LockOptions lockOptions) = throws HibernateException; = /** * Return the persistent instance of the given named entity with the give= n identifier, @@ -807,7 +783,7 @@ * @param lockMode the lock mode * @return a persistent instance or null * @throws HibernateException - * @deprecated LockMode parameter should be replaced with a LockRequest + * @deprecated LockMode parameter should be replaced with LockOptions */ public Object get(String entityName, Serializable id, LockMode lockMode) = throws HibernateException; = @@ -819,11 +795,11 @@ * * @param entityName the entity name * @param id an identifier - * @param lockRequest contains the lock mode + * @param lockOptions contains the lock mode * @return a persistent instance or null * @throws HibernateException */ - public Object get(String entityName, Serializable id, LockRequest lockReq= uest) throws HibernateException; + public Object get(String entityName, Serializable id, LockOptions lockOpt= ions) throws HibernateException; = = /** @@ -957,4 +933,68 @@ * @see org.hibernate.engine.profile.FetchProfile for discussion of this = feature */ public void disableFetchProfile(String name) throws UnknownProfileExcepti= on; + + + +/** + * Contains locking details (LockMode, Timeout and Scope). + * + */ + public interface LockRequest + { + + static final int PESSIMISTIC_NO_WAIT =3D 0; + static final int PESSIMISTIC_WAIT_FOREVER =3D -1; + = + /** + * Get the lock mode. + * @return the lock mode. + */ + LockMode getLockMode(); + + /** + * Specify the LockMode to be used. The default is LockMode.none. + * + * @param lockMode + * @return this LockRequest instance for operation chaining. + */ + LockRequest setLockMode(LockMode lockMode); + + /** + * Get the timeout setting. + * + * @return timeout in milliseconds, -1 for indefinite wait and 0 for no = wait. + */ + int getTimeOut(); + + /** + * Specify the pessimistic lock timeout (check if your dialect supports = this option). + * The default pessimistic lock behavior is to wait forever for the lock. + * + * @param timeout is time in milliseconds to wait for lock. -1 means wa= it forever and 0 means no wait. + * @return this LockRequest instance for operation chaining. + */ + LockRequest setTimeOut(int timeout); + + /** + * Check if locking is cascaded to owned collections and relationships. + * @return true if locking will be extended to owned collections and rel= ationships. + */ + boolean getScope(); + + /** + * Specify if LockMode should be cascaded to owned collections and relat= ionships. + * The association must be mapped with cascade=3D"lock" for scope=3D= true to work. + * + * @param scope + * @return + */ + LockRequest setScope(boolean scope); + + void lock(String entityName, Object object) throws HibernateException; + + public void lock(Object object) throws HibernateException; + = + } + } Modified: core/trunk/core/src/main/java/org/hibernate/engine/CascadingActio= n.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java= 2009-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java= 2009-11-24 23:59:50 UTC (rev 18053) @@ -34,7 +34,7 @@ import org.hibernate.LockMode; import org.hibernate.ReplicationMode; import org.hibernate.TransientObjectException; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; import org.hibernate.proxy.HibernateProxy; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.collection.PersistentCollection; @@ -167,16 +167,16 @@ log.trace( "cascading to lock: " + entityName ); } LockMode lockMode =3D LockMode.NONE; - LockRequest lr =3D new LockRequest(); - if ( anything instanceof LockRequest ) { - LockRequest lockRequest =3D (LockRequest)anything; - lr.setTimeOut(lockRequest.getTimeOut()); - lr.setScope( lockRequest.getScope()); - if ( lockRequest.getScope() =3D=3D true ) // cascade specified lockMode - lockMode =3D lockRequest.getLockMode(); + LockOptions lr =3D new LockOptions(); + if ( anything instanceof LockOptions) { + LockOptions lockOptions =3D (LockOptions)anything; + lr.setTimeOut(lockOptions.getTimeOut()); + lr.setScope( lockOptions.getScope()); + if ( lockOptions.getScope() =3D=3D true ) // cascade specified lockMode + lockMode =3D lockOptions.getLockMode(); } lr.setLockMode(lockMode); - session.lock( entityName, child, lr); + session.buildLockRequest(lr).lock(entityName, child); } public Iterator getCascadableChildrenIterator(EventSource session, Colle= ctionType collectionType, Object collection) { // lock doesn't cascade to uninitialized collections Modified: core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java 2009-1= 1-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java 2009-1= 1-24 23:59:50 UTC (rev 18053) @@ -27,7 +27,7 @@ import java.io.Serializable; = import org.hibernate.LockMode; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; = /** * Defines an event class for the loading of an entity. @@ -41,24 +41,24 @@ private Serializable entityId; private String entityClassName; private Object instanceToLoad; - private LockRequest lockRequest; + private LockOptions lockOptions; private boolean isAssociationFetch; private Object result; = public LoadEvent(Serializable entityId, Object instanceToLoad, EventSourc= e source) { - this(entityId, null, instanceToLoad, new LockRequest(), false, source); + this(entityId, null, instanceToLoad, new LockOptions(), false, source); } = public LoadEvent(Serializable entityId, String entityClassName, LockMode = lockMode, EventSource source) { this(entityId, entityClassName, null, lockMode, false, source); } = - public LoadEvent(Serializable entityId, String entityClassName, LockReque= st lockRequest, EventSource source) { - this(entityId, entityClassName, null, lockRequest, false, source); + public LoadEvent(Serializable entityId, String entityClassName, LockOptio= ns lockOptions, EventSource source) { + this(entityId, entityClassName, null, lockOptions, false, source); } = public LoadEvent(Serializable entityId, String entityClassName, boolean i= sAssociationFetch, EventSource source) { - this(entityId, entityClassName, null, new LockRequest(), isAssociationFe= tch, source); + this(entityId, entityClassName, null, new LockOptions(), isAssociationFe= tch, source); } = public boolean isAssociationFetch() { @@ -72,14 +72,14 @@ LockMode lockMode, boolean isAssociationFetch, EventSource source) { - this(entityId, entityClassName, instanceToLoad, new LockRequest().setLoc= kMode(lockMode), isAssociationFetch, source ); + this(entityId, entityClassName, instanceToLoad, new LockOptions().setLoc= kMode(lockMode), isAssociationFetch, source ); } = private LoadEvent( Serializable entityId, String entityClassName, Object instanceToLoad, - LockRequest lockRequest, + LockOptions lockOptions, boolean isAssociationFetch, EventSource source) { = @@ -89,17 +89,17 @@ throw new IllegalArgumentException("id to load is required for loading"= ); } = - if ( lockRequest.getLockMode() =3D=3D LockMode.WRITE ) { + if ( lockOptions.getLockMode() =3D=3D LockMode.WRITE ) { throw new IllegalArgumentException("Invalid lock mode for loading"); } - else if ( lockRequest.getLockMode() =3D=3D null ) { - lockRequest.setLockMode(DEFAULT_LOCK_MODE); + else if ( lockOptions.getLockMode() =3D=3D null ) { + lockOptions.setLockMode(DEFAULT_LOCK_MODE); } = this.entityId =3D entityId; this.entityClassName =3D entityClassName; this.instanceToLoad =3D instanceToLoad; - this.lockRequest =3D lockRequest; + this.lockOptions =3D lockOptions; this.isAssociationFetch =3D isAssociationFetch; } = @@ -127,32 +127,32 @@ this.instanceToLoad =3D instanceToLoad; } = - public LockRequest getLockRequest() { - return lockRequest; + public LockOptions getLockOptions() { + return lockOptions; } = public LockMode getLockMode() { - return lockRequest.getLockMode(); + return lockOptions.getLockMode(); } = public void setLockMode(LockMode lockMode) { - this.lockRequest.setLockMode(lockMode); + this.lockOptions.setLockMode(lockMode); } = public void setLockTimeout(int timeout) { - this.lockRequest.setTimeOut(timeout); + this.lockOptions.setTimeOut(timeout); } = public int getLockTimeout() { - return this.lockRequest.getTimeOut(); + return this.lockOptions.getTimeOut(); } = public void setLockScope(boolean cascade) { - this.lockRequest.setScope(cascade); + this.lockOptions.setScope(cascade); } = public boolean getLockScope() { - return this.lockRequest.getScope(); + return this.lockOptions.getScope(); } = public Object getResult() { Modified: core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java 2009-1= 1-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java 2009-1= 1-24 23:59:50 UTC (rev 18053) @@ -25,7 +25,7 @@ package org.hibernate.event; = import org.hibernate.LockMode; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; = /** * Defines an event class for the locking of an entity. @@ -35,7 +35,7 @@ public class LockEvent extends AbstractEvent { = private Object object; - private LockRequest lockRequest; + private LockOptions lockOptions; private String entityName; = public LockEvent(String entityName, Object original, LockMode lockMode, E= ventSource source) { @@ -43,21 +43,21 @@ this.entityName =3D entityName; } = - public LockEvent(String entityName, Object original, LockRequest lockRequ= est, EventSource source) { - this(original, lockRequest, source); + public LockEvent(String entityName, Object original, LockOptions lockOpti= ons, EventSource source) { + this(original, lockOptions, source); this.entityName =3D entityName; } = public LockEvent(Object object, LockMode lockMode, EventSource source) { super(source); this.object =3D object; - this.lockRequest =3D new LockRequest().setLockMode(lockMode); + this.lockOptions =3D new LockOptions().setLockMode(lockMode); } = - public LockEvent(Object object, LockRequest lockRequest, EventSource sour= ce) { + public LockEvent(Object object, LockOptions lockOptions, EventSource sour= ce) { super(source); this.object =3D object; - this.lockRequest =3D lockRequest; + this.lockOptions =3D lockOptions; } = public Object getObject() { @@ -68,32 +68,32 @@ this.object =3D object; } = - public LockRequest getLockRequest() { - return lockRequest; = + public LockOptions getLockOptions() { + return lockOptions; } = public LockMode getLockMode() { - return lockRequest.getLockMode(); + return lockOptions.getLockMode(); } = public void setLockMode(LockMode lockMode) { - this.lockRequest.setLockMode(lockMode); + this.lockOptions.setLockMode(lockMode); } = public void setLockTimeout(int timeout) { - this.lockRequest.setTimeOut(timeout); + this.lockOptions.setTimeOut(timeout); } = public int getLockTimeout() { - return this.lockRequest.getTimeOut(); + return this.lockOptions.getTimeOut(); } = public void setLockScope(boolean cascade) { - this.lockRequest.setScope(cascade); + this.lockOptions.setScope(cascade); } = public boolean getLockScope() { - return this.lockRequest.getScope(); + return this.lockOptions.getScope(); } = public String getEntityName() { Modified: core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java 200= 9-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java 200= 9-11-24 23:59:50 UTC (rev 18053) @@ -25,7 +25,7 @@ package org.hibernate.event; = import org.hibernate.LockMode; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; = /** * Defines an event class for the refreshing of an object. @@ -35,7 +35,7 @@ public class RefreshEvent extends AbstractEvent { = private Object object; - private LockRequest lockRequest =3D new LockRequest().setLockMode(LockMod= e.READ); + private LockOptions lockOptions =3D new LockOptions().setLockMode(LockMod= e.READ); = public RefreshEvent(Object object, EventSource source) { super(source); @@ -50,34 +50,34 @@ if (lockMode =3D=3D null) { throw new IllegalArgumentException("Attempt to generate refresh event w= ith null lock mode"); } - this.lockRequest.setLockMode(lockMode); + this.lockOptions.setLockMode(lockMode); } = - public RefreshEvent(Object object, LockRequest lockRequest, EventSource s= ource) { + public RefreshEvent(Object object, LockOptions lockOptions, EventSource s= ource) { this(object, source); - if (lockRequest =3D=3D null) { + if (lockOptions =3D=3D null) { throw new IllegalArgumentException("Attempt to generate refresh event w= ith null lock request"); } - this.lockRequest =3D lockRequest; + this.lockOptions =3D lockOptions; } = public Object getObject() { return object; } = - public LockRequest getLockRequest() { - return lockRequest; + public LockOptions getLockOptions() { + return lockOptions; } = public LockMode getLockMode() { - return lockRequest.getLockMode(); + return lockOptions.getLockMode(); } = public int getLockTimeout() { - return this.lockRequest.getTimeOut(); + return this.lockOptions.getTimeOut(); } = public boolean getLockScope() { - return this.lockRequest.getScope(); + return this.lockOptions.getScope(); } } Modified: core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLoc= kUpgradeEventListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgra= deEventListener.java 2009-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgra= deEventListener.java 2009-11-24 23:59:50 UTC (rev 18053) @@ -29,11 +29,8 @@ = import org.hibernate.LockMode; import org.hibernate.ObjectDeletedException; -import org.hibernate.OptimisticLockException; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; import org.hibernate.event.EventSource; -import org.hibernate.action.EntityIncrementVersionProcess; -import org.hibernate.action.EntityVerifyVersionProcess; import org.hibernate.cache.CacheKey; import org.hibernate.cache.access.SoftLock; import org.hibernate.engine.EntityEntry; @@ -56,12 +53,12 @@ * * @param object The entity for which to upgrade the lock. * @param entry The entity's EntityEntry instance. - * @param lockRequest contains the requested lock mode. + * @param lockOptions contains the requested lock mode. * @param source The session which is the source of the event being proce= ssed. */ - protected void upgradeLock(Object object, EntityEntry entry, LockRequest = lockRequest, EventSource source) { + protected void upgradeLock(Object object, EntityEntry entry, LockOptions = lockOptions, EventSource source) { = - LockMode requestedLockMode =3D lockRequest.getLockMode(); + LockMode requestedLockMode =3D lockOptions.getLockMode(); if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) { // The user requested a "greater" (i.e. more restrictive) form of // pessimistic lock Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoad= EventListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventL= istener.java 2009-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventL= istener.java 2009-11-24 23:59:50 UTC (rev 18053) @@ -485,7 +485,7 @@ return INCONSISTENT_RTN_CLASS_MARKER; } } - upgradeLock( old, oldEntry, event.getLockRequest(), event.getSession() = ); + upgradeLock( old, oldEntry, event.getLockOptions(), event.getSession() = ); } = return old; Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLock= EventListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventL= istener.java 2009-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventL= istener.java 2009-11-24 23:59:50 UTC (rev 18053) @@ -83,7 +83,7 @@ cascadeOnLock(event, persister, entity); } = - upgradeLock( entity, entry, event.getLockRequest(), event.getSession() ); + upgradeLock( entity, entry, event.getLockOptions(), event.getSession() ); } = private void cascadeOnLock(LockEvent event, EntityPersister persister, Ob= ject entity) { @@ -91,7 +91,7 @@ source.getPersistenceContext().incrementCascadeLevel(); try { new Cascade(CascadingAction.LOCK, Cascade.AFTER_LOCK, source) - .cascade( persister, entity, event.getLockRequest() ); + .cascade( persister, entity, event.getLockOptions() ); } finally { source.getPersistenceContext().decrementCascadeLevel(); Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefr= eshEventListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEve= ntListener.java 2009-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEve= ntListener.java 2009-11-24 23:59:50 UTC (rev 18053) @@ -142,7 +142,7 @@ = String previousFetchProfile =3D source.getFetchProfile(); source.setFetchProfile("refresh"); - Object result =3D persister.load( id, object, event.getLockRequest(), so= urce ); + Object result =3D persister.load( id, object, event.getLockOptions(), so= urce ); source.setFetchProfile(previousFetchProfile); = UnresolvableObjectException.throwIfNull( result, id, persister.getEntity= Name() ); Modified: core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java 2009-= 11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java 2009-= 11-24 23:59:50 UTC (rev 18053) @@ -69,7 +69,7 @@ import org.hibernate.UnresolvableObjectException; import org.hibernate.UnknownProfileException; import org.hibernate.EntityNameResolver; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; import org.hibernate.collection.PersistentCollection; import org.hibernate.engine.ActionQueue; import org.hibernate.engine.CollectionEntry; @@ -742,21 +742,20 @@ fireLock( new LockEvent(entityName, object, lockMode, this) ); } = - public void lock(String entityName, Object object, LockRequest lockReques= t) throws HibernateException { - fireLock( new LockEvent(entityName, object, lockRequest, this) ); + public LockRequest buildLockRequest(LockOptions lockOptions) { + return new LockRequestImpl(lockOptions); } = - public LockRequest buildLockRequest() { - return new LockRequest(); = - } - public void lock(Object object, LockMode lockMode) throws HibernateExcept= ion { fireLock( new LockEvent(object, lockMode, this) ); } = + private void fireLock(String entityName, Object object, LockOptions optio= ns) { + fireLock( new LockEvent( entityName, object, options, this) ); + } = - public void lock(Object object, LockRequest lockRequest) throws Hibernate= Exception { - fireLock( new LockEvent(object, lockRequest, this) ); + private void fireLock( Object object, LockOptions options) { + fireLock( new LockEvent( object, options, this) ); } = private void fireLock(LockEvent lockEvent) { @@ -1037,8 +1036,8 @@ return load( entityClass.getName(), id, lockMode ); } = - public Object load(Class entityClass, Serializable id, LockRequest lockRe= quest) throws HibernateException { - return load( entityClass.getName(), id, lockRequest ); + public Object load(Class entityClass, Serializable id, LockOptions lockOp= tions) throws HibernateException { + return load( entityClass.getName(), id, lockOptions); } = public Object load(String entityName, Serializable id, LockMode lockMode)= throws HibernateException { @@ -1047,8 +1046,8 @@ return event.getResult(); } = - public Object load(String entityName, Serializable id, LockRequest lockRe= quest) throws HibernateException { - LoadEvent event =3D new LoadEvent(id, entityName, lockRequest, this); + public Object load(String entityName, Serializable id, LockOptions lockOp= tions) throws HibernateException { + LoadEvent event =3D new LoadEvent(id, entityName, lockOptions, this); fireLoad( event, LoadEventListener.LOAD ); return event.getResult(); } @@ -1057,8 +1056,8 @@ return get( entityClass.getName(), id, lockMode ); } = - public Object get(Class entityClass, Serializable id, LockRequest lockReq= uest) throws HibernateException { - return get( entityClass.getName(), id, lockRequest ); + public Object get(Class entityClass, Serializable id, LockOptions lockOpt= ions) throws HibernateException { + return get( entityClass.getName(), id, lockOptions); } = public Object get(String entityName, Serializable id, LockMode lockMode) = throws HibernateException { @@ -1067,8 +1066,8 @@ return event.getResult(); } = - public Object get(String entityName, Serializable id, LockRequest lockReq= uest) throws HibernateException { - LoadEvent event =3D new LoadEvent(id, entityName, lockRequest, this); + public Object get(String entityName, Serializable id, LockOptions lockOpt= ions) throws HibernateException { + LoadEvent event =3D new LoadEvent(id, entityName, lockOptions, this); fireLoad(event, LoadEventListener.GET); return event.getResult(); } @@ -1093,8 +1092,8 @@ fireRefresh( new RefreshEvent(object, lockMode, this) ); } = - public void refresh(Object object, LockRequest lockRequest) throws Hibern= ateException { - fireRefresh( new RefreshEvent(object, lockRequest, this) ); + public void refresh(Object object, LockOptions lockOptions) throws Hibern= ateException { + fireRefresh( new RefreshEvent(object, lockOptions, this) ); } = public void refresh(Object object, Map refreshedAlready) throws Hibernate= Exception { @@ -2217,4 +2216,48 @@ return entity.getClass().getName(); } } + + private class LockRequestImpl implements LockRequest { + private final LockOptions lockOptions; + private LockRequestImpl(LockOptions lo) { + lockOptions =3D new LockOptions(); + lockOptions.setLockMode(lo.getLockMode()); + lockOptions.setScope(lo.getScope()); + lockOptions.setTimeOut(lo.getTimeOut()); + } + + public LockMode getLockMode() { + return lockOptions.getLockMode(); + } + + public LockRequest setLockMode(LockMode lockMode) { + lockOptions.setLockMode(lockMode); + return this; + } + + public int getTimeOut() { + return lockOptions.getTimeOut(); + } + + public LockRequest setTimeOut(int timeout) { + lockOptions.setTimeOut(timeout); + return this; + } + + public boolean getScope() { + return lockOptions.getScope(); + } + + public LockRequest setScope(boolean scope) { + lockOptions.setScope(scope); + return this; + } + + public void lock(String entityName, Object object) throws HibernateExcep= tion { + fireLock( entityName, object, lockOptions ); + } + public void lock(Object object) throws HibernateException { + fireLock( object, lockOptions ); + } + } } Modified: core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntity= JoinWalker.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWa= lker.java 2009-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWa= lker.java 2009-11-24 23:59:50 UTC (rev 18053) @@ -31,7 +31,7 @@ import org.hibernate.FetchMode; import org.hibernate.LockMode; import org.hibernate.MappingException; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; import org.hibernate.engine.CascadeStyle; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.LoadQueryInfluencers; @@ -98,7 +98,7 @@ protected final void initAll( final String whereString, final String orderByString, - final LockRequest lockRequest) throws MappingException { + final LockOptions lockOptions) throws MappingException { walkEntityTree( persister, getAlias() ); List allAssociations =3D new ArrayList(); allAssociations.addAll(associations); @@ -114,8 +114,8 @@ CollectionHelper.EMPTY_MAP ) ); - initPersisters(allAssociations, lockRequest.getLockMode()); - initStatementString( whereString, orderByString, lockRequest.getLockMode= ()); + initPersisters(allAssociations, lockOptions.getLockMode()); + initStatementString( whereString, orderByString, lockOptions.getLockMode= ()); } = protected final void initProjection( Modified: core/trunk/core/src/main/java/org/hibernate/loader/entity/Batchin= gEntityLoader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntit= yLoader.java 2009-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntit= yLoader.java 2009-11-24 23:59:50 UTC (rev 18053) @@ -27,13 +27,11 @@ import java.io.Serializable; import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.Set; = import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.MappingException; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.LoadQueryInfluencers; @@ -132,7 +130,7 @@ public static UniqueEntityLoader createBatchingEntityLoader( final OuterJoinLoadable persister, final int maxBatchSize, - final LockRequest lockRequest, + final LockOptions lockOptions, final SessionFactoryImplementor factory, final LoadQueryInfluencers loadQueryInfluencers) throws MappingException= { = @@ -140,12 +138,12 @@ int[] batchSizesToCreate =3D ArrayHelper.getBatchSizes(maxBatchSize); Loader[] loadersToCreate =3D new Loader[ batchSizesToCreate.length ]; for ( int i=3D0; i READ? return BatchingEntityLoader.createBatchingEntityLoader( this, batchSize, - lockRequest, + lockOptions, getFactory(), loadQueryInfluencers ); @@ -3208,7 +3208,7 @@ ); } = - final UniqueEntityLoader loader =3D getAppropriateLoader( new LockReques= t().setLockMode(lockMode), session ); + final UniqueEntityLoader loader =3D getAppropriateLoader( new LockOption= s().setLockMode(lockMode), session ); return loader.load( id, optionalObject, session ); } = @@ -3216,7 +3216,7 @@ * Load an instance using either the forUpdateLoader or the oute= r joining loader, * depending upon the value of the lock parameter */ - public Object load(Serializable id, Object optionalObject, LockRequest lo= ckRequest, SessionImplementor session) + public Object load(Serializable id, Object optionalObject, LockOptions lo= ckOptions, SessionImplementor session) throws HibernateException { = if ( log.isTraceEnabled() ) { @@ -3226,7 +3226,7 @@ ); } = - final UniqueEntityLoader loader =3D getAppropriateLoader( lockRequest, s= ession ); + final UniqueEntityLoader loader =3D getAppropriateLoader(lockOptions, se= ssion ); return loader.load( id, optionalObject, session ); } = @@ -3249,7 +3249,7 @@ && filterHelper.isAffectedBy( session.getLoadQueryInfluencers().getEna= bledFilters() ); } = - private UniqueEntityLoader getAppropriateLoader(LockRequest lockRequest, = SessionImplementor session) { + private UniqueEntityLoader getAppropriateLoader(LockOptions lockOptions, = SessionImplementor session) { if ( queryLoader !=3D null ) { // if the user specified a custom query loader we need to that // regardless of any other consideration @@ -3258,9 +3258,9 @@ else if ( isAffectedByEnabledFilters( session ) ) { // because filters affect the rows returned (because they add // restirctions) these need to be next in precendence - return createEntityLoader( lockRequest, session.getLoadQueryInfluencers= () ); + return createEntityLoader(lockOptions, session.getLoadQueryInfluencers(= ) ); } - else if ( session.getLoadQueryInfluencers().getInternalFetchProfile() != =3D null && LockMode.UPGRADE.greaterThan( lockRequest.getLockMode() ) ) { + else if ( session.getLoadQueryInfluencers().getInternalFetchProfile() != =3D null && LockMode.UPGRADE.greaterThan( lockOptions.getLockMode() ) ) { // Next, we consider whether an 'internal' fetch profile has been set. // This indicates a special fetch profile Hibernate needs applied // (for its merge loading process e.g.). @@ -3269,10 +3269,10 @@ else if ( isAffectedByEnabledFetchProfiles( session ) ) { // If the session has associated influencers we need to adjust the // SQL query used for loading based on those influencers - return createEntityLoader( lockRequest, session.getLoadQueryInfluencers= () ); + return createEntityLoader(lockOptions, session.getLoadQueryInfluencers(= ) ); } else { - return ( UniqueEntityLoader ) loaders.get( lockRequest.getLockMode() ); + return ( UniqueEntityLoader ) loaders.get( lockOptions.getLockMode() ); } } = Modified: core/trunk/core/src/main/java/org/hibernate/persister/entity/Enti= tyPersister.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPers= ister.java 2009-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPers= ister.java 2009-11-24 23:59:50 UTC (rev 18053) @@ -31,7 +31,7 @@ import org.hibernate.LockMode; import org.hibernate.MappingException; import org.hibernate.EntityMode; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.cache.OptimisticCacheSource; import org.hibernate.cache.access.EntityRegionAccessStrategy; @@ -330,7 +330,7 @@ /** * Load an instance of the persistent class. */ - public Object load(Serializable id, Object optionalObject, LockRequest lo= ckRequest, SessionImplementor session) + public Object load(Serializable id, Object optionalObject, LockOptions lo= ckOptions, SessionImplementor session) throws HibernateException; = /** @@ -342,7 +342,7 @@ /** * Do a version check (optional operation) */ - public void lock(Serializable id, Object version, Object object, LockRequ= est lockRequest, SessionImplementor session) + public void lock(Serializable id, Object version, Object object, LockOpti= ons lockOptions, SessionImplementor session) throws HibernateException; = /** Modified: core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java 2009-= 11-24 22:28:05 UTC (rev 18052) +++ core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java 2009-= 11-24 23:59:50 UTC (rev 18053) @@ -32,7 +32,7 @@ import java.util.List; = import org.hibernate.LockMode; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; import org.hibernate.type.Type; = public final class ArrayHelper { @@ -84,9 +84,9 @@ return array; } = - public static LockMode[] fillArray(LockRequest lockRequest, int length) { + public static LockMode[] fillArray(LockOptions lockOptions, int length) { LockMode[] array =3D new LockMode[length]; - Arrays.fill(array, lockRequest); + Arrays.fill(array, lockOptions); return array; } = Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Abstract= EntityManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntity= ManagerImpl.java 2009-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntity= ManagerImpl.java 2009-11-24 23:59:50 UTC (rev 18053) @@ -29,7 +29,6 @@ import java.io.Serializable; import java.util.Map; import java.util.Set; -import java.util.HashMap; import javax.persistence.EntityNotFoundException; import javax.persistence.EntityTransaction; import javax.persistence.FlushModeType; @@ -521,7 +520,7 @@ if ( !contains( entity ) ) { throw new IllegalArgumentException( "entity not in the persistence con= text" ); } - getSession().lock( entity, getLockRequest(lockModeType, properties) ); + getSession().buildLockRequest(getLockRequest(lockModeType, properties))= .lock( entity ); } catch ( HibernateException he ) { throw convert( he ); @@ -529,31 +528,31 @@ = } = - private LockRequest getLockRequest(LockModeType lockModeType, Map properties) { - LockRequest lockRequest =3D new LockRequest(); - lockRequest.setLockMode(getLockMode(lockModeType)); + private LockOptions getLockRequest(LockModeType lockModeType, Map properties) { + LockOptions lockOptions =3D new LockOptions(); + lockOptions.setLockMode(getLockMode(lockModeType)); if ( properties !=3D null ) { - // lockRequest scope will default to false (PessimisticLockScope.NORMAL) + // lockOptions scope will default to false (PessimisticLockScope.NORMAL) Object value =3D properties.get(PESSIMISTICLOCKSCOPE); if ( value instanceof String && PessimisticLockScope.valueOf((String) v= alue) =3D=3D PessimisticLockScope.EXTENDED) { - lockRequest.setScope(true); + lockOptions.setScope(true); } - // lockRequest timeout will default to LockRequest.FOREVER_WAIT + // lockOptions timeout will default to LockOptions.FOREVER_WAIT value =3D properties.get(PESSIMISTICLOCKTIMEOUT); if ( value instanceof String ) { int timeout =3D Integer.parseInt((String) value); if ( timeout < 0 ) { - lockRequest.setTimeOut(LockRequest.WAIT_FOREVER); + lockOptions.setTimeOut(LockOptions.WAIT_FOREVER); } else if( timeout =3D=3D 0 ) { - lockRequest.setTimeOut(LockRequest.NO_WAIT); + lockOptions.setTimeOut(LockOptions.NO_WAIT); } else { - lockRequest.setTimeOut(timeout); + lockOptions.setTimeOut(timeout); } } } - return lockRequest; + return lockOptions; } = private LockModeType getLockModeType(LockMode lockMode) { Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/Cust= omPersister.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPers= ister.java 2009-11-24 22:28:05 UTC (rev 18052) +++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPers= ister.java 2009-11-24 23:59:50 UTC (rev 18053) @@ -11,9 +11,8 @@ import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.MappingException; -import org.hibernate.LockRequest; +import org.hibernate.LockOptions; import org.hibernate.tuple.entity.EntityMetamodel; -import org.hibernate.cache.CacheConcurrencyStrategy; import org.hibernate.cache.access.EntityRegionAccessStrategy; import org.hibernate.cache.entry.CacheEntryStructure; import org.hibernate.cache.entry.UnstructuredCacheEntry; @@ -281,15 +280,15 @@ } = /** - * @see EntityPersister#load(Serializable, Object, LockRequest, SessionIm= plementor) + * @see EntityPersister#load(Serializable, Object, org.hibernate.LockOpti= ons , SessionImplementor) */ public Object load( Serializable id, Object optionalObject, - LockRequest lockRequest, + LockOptions lockOptions, SessionImplementor session ) throws HibernateException { - return load(id, optionalObject, lockRequest.getLockMode(), session); + return load(id, optionalObject, lockOptions.getLockMode(), session); } = /** @@ -343,7 +342,7 @@ Serializable id, Object version, Object object, - LockRequest lockRequest, + LockOptions lockOptions, SessionImplementor session ) throws HibernateException { = --===============9150947960728072676==-- From hibernate-commits at lists.jboss.org Tue Nov 24 19:05:09 2009 Content-Type: multipart/mixed; boundary="===============4871077364759471477==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18054 - core/trunk/core/src/main/java/org/hibernate. Date: Tue, 24 Nov 2009 19:05:08 -0500 Message-ID: <200911250005.nAP058AR000931@svn01.web.mwc.hst.phx2.redhat.com> --===============4871077364759471477== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: smarlow(a)redhat.com Date: 2009-11-24 19:05:08 -0500 (Tue, 24 Nov 2009) New Revision: 18054 Modified: core/trunk/core/src/main/java/org/hibernate/Session.java Log: HHH-4546 add JPA 2.0 locking. Javadoc change. Modified: core/trunk/core/src/main/java/org/hibernate/Session.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/src/main/java/org/hibernate/Session.java 2009-11-24 23:= 59:50 UTC (rev 18053) +++ core/trunk/core/src/main/java/org/hibernate/Session.java 2009-11-25 00:= 05:08 UTC (rev 18054) @@ -552,8 +552,9 @@ public void lock(String entityName, Object object, LockMode lockMode) thr= ows HibernateException; = /** - * Build a lockRequest that specifies the LockMode, pessimistic lock time= out and lock scope. - * timeout and scope is ignored for optimistic locking. + * Build a LockRequest that specifies the LockMode, pessimistic lock time= out and lock scope. + * timeout and scope is ignored for optimistic locking. After building t= he LockRequest, + * call LockRequest.lock to perform the requested locking. = * * Use: session.buildLockRequest(). * setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(1000 * 60).loc= k(entity); --===============4871077364759471477==-- From hibernate-commits at lists.jboss.org Wed Nov 25 01:06:17 2009 Content-Type: multipart/mixed; boundary="===============0292232435395111817==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18055 - core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter. Date: Wed, 25 Nov 2009 01:06:17 -0500 Message-ID: <200911250606.nAP66Hvi006440@svn01.web.mwc.hst.phx2.redhat.com> --===============0292232435395111817== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-25 01:06:17 -0500 (Wed, 25 Nov 2009) New Revision: 18055 Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/Dynamic= FilterTest.java Log: JBPAPP-3098 HHH-4065 - remove annotations, due to this will be compiled to = 1.4 compatible Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/= DynamicFilterTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/Dynami= cFilterTest.java 2009-11-25 00:05:08 UTC (rev 18054) +++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/Dynami= cFilterTest.java 2009-11-25 06:06:17 UTC (rev 18055) @@ -37,7 +37,6 @@ * * @author Steve */ -(a)SuppressWarnings({ "WhileLoopReplaceableByForEach", "unchecked" }) public class DynamicFilterTest extends FunctionalTestCase { = public DynamicFilterTest(String testName) { --===============0292232435395111817==-- From hibernate-commits at lists.jboss.org Wed Nov 25 02:45:46 2009 Content-Type: multipart/mixed; boundary="===============4616430555698234865==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18056 - core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata. Date: Wed, 25 Nov 2009 02:45:45 -0500 Message-ID: <200911250745.nAP7jjiN025585@svn01.web.mwc.hst.phx2.redhat.com> --===============4616430555698234865== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: adamw Date: 2009-11-25 02:45:45 -0500 (Wed, 25 Nov 2009) New Revision: 18056 Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metad= ata/AuditMetadataGenerator.java Log: HHH-4608: - options to specify default schema/catalog name for audit tables Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuratio= n/metadata/AuditMetadataGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/AuditMetadataGenerator.java 2009-11-25 06:06:17 UTC (rev 18055) +++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/AuditMetadataGenerator.java 2009-11-25 07:45:45 UTC (rev 18056) @@ -40,14 +40,11 @@ import org.hibernate.envers.entities.mapper.SubclassPropertyMapper; import org.hibernate.envers.tools.StringTools; import org.hibernate.envers.tools.Triple; +import org.hibernate.envers.AuditTable; = import org.hibernate.MappingException; import org.hibernate.cfg.Configuration; -import org.hibernate.mapping.Collection; -import org.hibernate.mapping.Join; -import org.hibernate.mapping.PersistentClass; -import org.hibernate.mapping.Property; -import org.hibernate.mapping.Value; +import org.hibernate.mapping.*; import org.hibernate.type.*; = /** @@ -180,6 +177,38 @@ return true; } = + private String getSchema(AuditTable auditTable, Table table) { + // Get the schema from the annotation ... + String schema =3D auditTable.schema(); + // ... if empty, try using the default ... + if (StringTools.isEmpty(schema)) { + schema =3D globalCfg.getDefaultSchemaName(); + + // ... if still empty, use the same as the normal table. + if (StringTools.isEmpty(schema)) { + schema =3D table.getSchema(); + } + } + + return schema; + } + + private String getCatalog(AuditTable auditTable, Table table) { + // Get the catalog from the annotation ... + String catalog =3D auditTable.catalog(); + // ... if empty, try using the default ... + if (StringTools.isEmpty(catalog)) { + catalog =3D globalCfg.getDefaultCatalogName(); + + // ... if still empty, use the same as the normal table. + if (StringTools.isEmpty(catalog)) { + catalog =3D table.getCatalog(); + } + } + + return catalog; + } + @SuppressWarnings({"unchecked"}) private void createJoins(PersistentClass pc, Element parent, ClassAudi= tingData auditingData) { Iterator joins =3D pc.getJoinIterator(); @@ -203,28 +232,9 @@ auditTableName =3D verEntCfg.getAuditEntityName(originalTa= bleName); } = - // Get the schema ... - String schema =3D auditingData.getAuditTable().schema(); - // ... if empty, try using the default ... - if (StringTools.isEmpty(schema)) { - schema =3D globalCfg.getDefaultSchemaName(); + String schema =3D getSchema(auditingData.getAuditTable(), join= .getTable()); + String catalog =3D getCatalog(auditingData.getAuditTable(), jo= in.getTable()); = - // ... if still empty, use the same as the normal table. - if (StringTools.isEmpty(schema)) { - schema =3D join.getTable().getSchema(); - } - } - - // Same for catalogs - String catalog =3D auditingData.getAuditTable().catalog(); - if (StringTools.isEmpty(catalog)) { - catalog =3D globalCfg.getDefaultCatalogName(); - - if (StringTools.isEmpty(catalog)) { - catalog =3D join.getTable().getCatalog(); - } - } - Element joinElement =3D MetadataTools.createJoin(parent, audit= TableName, schema, catalog); joinElements.put(join, joinElement); = @@ -301,16 +311,9 @@ @SuppressWarnings({"unchecked"}) public void generateFirstPass(PersistentClass pc, ClassAuditingData au= ditingData, EntityXmlMappingData xmlMappingData, boo= lean isAudited) { - String schema =3D auditingData.getAuditTable().schema(); - if (StringTools.isEmpty(schema)) { - schema =3D pc.getTable().getSchema(); - } + String schema =3D getSchema(auditingData.getAuditTable(), pc.getTa= ble()); + String catalog =3D getCatalog(auditingData.getAuditTable(), pc.get= Table()); = - String catalog =3D auditingData.getAuditTable().catalog(); - if (StringTools.isEmpty(catalog)) { - catalog =3D pc.getTable().getCatalog(); - } - if (!isAudited) { String entityName =3D pc.getEntityName(); IdMappingData idMapper =3D idMetadataGenerator.addId(pc); --===============4616430555698234865==-- From hibernate-commits at lists.jboss.org Wed Nov 25 02:48:51 2009 Content-Type: multipart/mixed; boundary="===============5131525491677971281==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18057 - core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata. Date: Wed, 25 Nov 2009 02:48:51 -0500 Message-ID: <200911250748.nAP7mpbf026552@svn01.web.mwc.hst.phx2.redhat.com> --===============5131525491677971281== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: adamw Date: 2009-11-25 02:48:51 -0500 (Wed, 25 Nov 2009) New Revision: 18057 Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/co= nfiguration/metadata/AuditMetadataGenerator.java Log: svn merge -r 18035:18056 https://svn.jboss.org/repos/hibernate/core/trunk/e= nvers . Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/en= vers/configuration/metadata/AuditMetadataGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/metadata/AuditMetadataGenerator.java 2009-11-25 07:45:45 UTC (= rev 18056) +++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/metadata/AuditMetadataGenerator.java 2009-11-25 07:48:51 UTC (= rev 18057) @@ -40,14 +40,11 @@ import org.hibernate.envers.entities.mapper.SubclassPropertyMapper; import org.hibernate.envers.tools.StringTools; import org.hibernate.envers.tools.Triple; +import org.hibernate.envers.AuditTable; = import org.hibernate.MappingException; import org.hibernate.cfg.Configuration; -import org.hibernate.mapping.Collection; -import org.hibernate.mapping.Join; -import org.hibernate.mapping.PersistentClass; -import org.hibernate.mapping.Property; -import org.hibernate.mapping.Value; +import org.hibernate.mapping.*; import org.hibernate.type.*; = /** @@ -180,6 +177,38 @@ return true; } = + private String getSchema(AuditTable auditTable, Table table) { + // Get the schema from the annotation ... + String schema =3D auditTable.schema(); + // ... if empty, try using the default ... + if (StringTools.isEmpty(schema)) { + schema =3D globalCfg.getDefaultSchemaName(); + + // ... if still empty, use the same as the normal table. + if (StringTools.isEmpty(schema)) { + schema =3D table.getSchema(); + } + } + + return schema; + } + + private String getCatalog(AuditTable auditTable, Table table) { + // Get the catalog from the annotation ... + String catalog =3D auditTable.catalog(); + // ... if empty, try using the default ... + if (StringTools.isEmpty(catalog)) { + catalog =3D globalCfg.getDefaultCatalogName(); + + // ... if still empty, use the same as the normal table. + if (StringTools.isEmpty(catalog)) { + catalog =3D table.getCatalog(); + } + } + + return catalog; + } + @SuppressWarnings({"unchecked"}) private void createJoins(PersistentClass pc, Element parent, ClassAudi= tingData auditingData) { Iterator joins =3D pc.getJoinIterator(); @@ -203,28 +232,9 @@ auditTableName =3D verEntCfg.getAuditEntityName(originalTa= bleName); } = - // Get the schema ... - String schema =3D auditingData.getAuditTable().schema(); - // ... if empty, try using the default ... - if (StringTools.isEmpty(schema)) { - schema =3D globalCfg.getDefaultSchemaName(); + String schema =3D getSchema(auditingData.getAuditTable(), join= .getTable()); + String catalog =3D getCatalog(auditingData.getAuditTable(), jo= in.getTable()); = - // ... if still empty, use the same as the normal table. - if (StringTools.isEmpty(schema)) { - schema =3D join.getTable().getSchema(); - } - } - - // Same for catalogs - String catalog =3D auditingData.getAuditTable().catalog(); - if (StringTools.isEmpty(catalog)) { - catalog =3D globalCfg.getDefaultCatalogName(); - - if (StringTools.isEmpty(catalog)) { - catalog =3D join.getTable().getCatalog(); - } - } - Element joinElement =3D MetadataTools.createJoin(parent, audit= TableName, schema, catalog); joinElements.put(join, joinElement); = @@ -333,16 +343,9 @@ @SuppressWarnings({"unchecked"}) public void generateFirstPass(PersistentClass pc, ClassAuditingData au= ditingData, EntityXmlMappingData xmlMappingData, boo= lean isAudited) { - String schema =3D auditingData.getAuditTable().schema(); - if (StringTools.isEmpty(schema)) { - schema =3D pc.getTable().getSchema(); - } + String schema =3D getSchema(auditingData.getAuditTable(), pc.getTa= ble()); + String catalog =3D getCatalog(auditingData.getAuditTable(), pc.get= Table()); = - String catalog =3D auditingData.getAuditTable().catalog(); - if (StringTools.isEmpty(catalog)) { - catalog =3D pc.getTable().getCatalog(); - } - if (!isAudited) { String entityName =3D pc.getEntityName(); IdMappingData idMapper =3D idMetadataGenerator.addId(pc); --===============5131525491677971281==-- From hibernate-commits at lists.jboss.org Wed Nov 25 03:01:23 2009 Content-Type: multipart/mixed; boundary="===============7350321209342748053==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18058 - core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter. Date: Wed, 25 Nov 2009 03:01:23 -0500 Message-ID: <200911250801.nAP81NrB029113@svn01.web.mwc.hst.phx2.redhat.com> --===============7350321209342748053== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-25 03:01:22 -0500 (Wed, 25 Nov 2009) New Revision: 18058 Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/Dynamic= FilterTest.java Log: JBPAPP-3098 HHH-4065 - correct this test, due to 1.4 does not support autob= ox Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/= DynamicFilterTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/Dynami= cFilterTest.java 2009-11-25 07:48:51 UTC (rev 18057) +++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/filter/Dynami= cFilterTest.java 2009-11-25 08:01:22 UTC (rev 18058) @@ -88,7 +88,7 @@ ts =3D ( ( SessionImplementor ) session ).getTimestamp(); session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", test= Data.lastMonth.getTime() ); sp =3D ( Salesperson ) session.createQuery( "from Salesperson as s where= s.id =3D :id" ) - .setLong( "id", testData.steveId ) + .setLong( "id", testData.steveId.longValue() ) .uniqueResult(); assertEquals( "Filtered-collection not bypassing 2L-cache", 1, sp.getOrd= ers().size() ); = @@ -196,7 +196,7 @@ assertEquals( "Incorrect order count", 1, ( ( Salesperson ) salespersons= .get( 0 ) ).getOrders().size() ); = List products =3D session.createCriteria( Product.class ) - .add( Restrictions.eq( "stockNumber", 124 ) ) + .add( Restrictions.eq( "stockNumber", Integer.valueOf(124) ) ) .list(); assertEquals( "Incorrect product count", 1, products.size() ); = @@ -605,7 +605,7 @@ = // Force the categories to not get initialized here List result =3D session.createQuery( "from Product as p where p.id =3D := id" ) - .setLong( "id", testData.prod1Id ) + .setLong( "id", testData.prod1Id.longValue() ) .list(); assertTrue( "No products returned from HQL", !result.isEmpty() ); = --===============7350321209342748053==-- From hibernate-commits at lists.jboss.org Wed Nov 25 03:35:23 2009 Content-Type: multipart/mixed; boundary="===============2480841309806909350==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18059 - core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata. Date: Wed, 25 Nov 2009 03:35:23 -0500 Message-ID: <200911250835.nAP8ZNa1004952@svn01.web.mwc.hst.phx2.redhat.com> --===============2480841309806909350== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: adamw Date: 2009-11-25 03:35:22 -0500 (Wed, 25 Nov 2009) New Revision: 18059 Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metad= ata/AuditMetadataGenerator.java core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metad= ata/CollectionMetadataGenerator.java Log: HHH-4608: - options to specify default schema/catalog name for audit tables Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuratio= n/metadata/AuditMetadataGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/AuditMetadataGenerator.java 2009-11-25 08:01:22 UTC (rev 18058) +++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/AuditMetadataGenerator.java 2009-11-25 08:35:22 UTC (rev 18059) @@ -177,9 +177,9 @@ return true; } = - private String getSchema(AuditTable auditTable, Table table) { + protected String getSchema(String schemaFromAnnotation, Table table) { // Get the schema from the annotation ... - String schema =3D auditTable.schema(); + String schema =3D schemaFromAnnotation; // ... if empty, try using the default ... if (StringTools.isEmpty(schema)) { schema =3D globalCfg.getDefaultSchemaName(); @@ -193,9 +193,9 @@ return schema; } = - private String getCatalog(AuditTable auditTable, Table table) { + protected String getCatalog(String catalogFromAnnotation, Table table)= { // Get the catalog from the annotation ... - String catalog =3D auditTable.catalog(); + String catalog =3D catalogFromAnnotation; // ... if empty, try using the default ... if (StringTools.isEmpty(catalog)) { catalog =3D globalCfg.getDefaultCatalogName(); @@ -232,8 +232,8 @@ auditTableName =3D verEntCfg.getAuditEntityName(originalTa= bleName); } = - String schema =3D getSchema(auditingData.getAuditTable(), join= .getTable()); - String catalog =3D getCatalog(auditingData.getAuditTable(), jo= in.getTable()); + String schema =3D getSchema(auditingData.getAuditTable().schem= a(), join.getTable()); + String catalog =3D getCatalog(auditingData.getAuditTable().cat= alog(), join.getTable()); = Element joinElement =3D MetadataTools.createJoin(parent, audit= TableName, schema, catalog); joinElements.put(join, joinElement); @@ -311,8 +311,8 @@ @SuppressWarnings({"unchecked"}) public void generateFirstPass(PersistentClass pc, ClassAuditingData au= ditingData, EntityXmlMappingData xmlMappingData, boo= lean isAudited) { - String schema =3D getSchema(auditingData.getAuditTable(), pc.getTa= ble()); - String catalog =3D getCatalog(auditingData.getAuditTable(), pc.get= Table()); + String schema =3D getSchema(auditingData.getAuditTable().schema(),= pc.getTable()); + String catalog =3D getCatalog(auditingData.getAuditTable().catalog= (), pc.getTable()); = if (!isAudited) { String entityName =3D pc.getEntityName(); Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuratio= n/metadata/CollectionMetadataGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/CollectionMetadataGenerator.java 2009-11-25 08:01:22 UTC (rev 18058) +++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/CollectionMetadataGenerator.java 2009-11-25 08:35:22 UTC (rev 18059) @@ -475,10 +475,8 @@ } = private Element createMiddleEntityXml(String auditMiddleTableName, Str= ing auditMiddleEntityName) { - String schema =3D StringTools.isEmpty(propertyAuditingData.getJoin= Table().schema()) ? - propertyValue.getCollectionTable().getSchema() : propertyA= uditingData.getJoinTable().schema(); - String catalog =3D StringTools.isEmpty(propertyAuditingData.getJoi= nTable().catalog()) ? - propertyValue.getCollectionTable().getCatalog() : property= AuditingData.getJoinTable().catalog(); + String schema =3D mainGenerator.getSchema(propertyAuditingData.get= JoinTable().schema(), propertyValue.getCollectionTable()); + String catalog =3D mainGenerator.getCatalog(propertyAuditingData.g= etJoinTable().catalog(), propertyValue.getCollectionTable()); = Element middleEntityXml =3D MetadataTools.createEntity(xmlMappingD= ata.newAdditionalMapping(), new AuditTableData(auditMiddleEntityName, auditMiddleTable= Name, schema, catalog), null); --===============2480841309806909350==-- From hibernate-commits at lists.jboss.org Wed Nov 25 03:40:09 2009 Content-Type: multipart/mixed; boundary="===============3685671817213379043==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18060 - core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata. Date: Wed, 25 Nov 2009 03:40:09 -0500 Message-ID: <200911250840.nAP8e9Gx005720@svn01.web.mwc.hst.phx2.redhat.com> --===============3685671817213379043== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: adamw Date: 2009-11-25 03:40:09 -0500 (Wed, 25 Nov 2009) New Revision: 18060 Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/co= nfiguration/metadata/AuditMetadataGenerator.java core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/co= nfiguration/metadata/CollectionMetadataGenerator.java Log: svn merge -r 18056:18059 https://svn.jboss.org/repos/hibernate/core/trunk/e= nvers . Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/en= vers/configuration/metadata/AuditMetadataGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/metadata/AuditMetadataGenerator.java 2009-11-25 08:35:22 UTC (= rev 18059) +++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/metadata/AuditMetadataGenerator.java 2009-11-25 08:40:09 UTC (= rev 18060) @@ -177,9 +177,9 @@ return true; } = - private String getSchema(AuditTable auditTable, Table table) { + protected String getSchema(String schemaFromAnnotation, Table table) { // Get the schema from the annotation ... - String schema =3D auditTable.schema(); + String schema =3D schemaFromAnnotation; // ... if empty, try using the default ... if (StringTools.isEmpty(schema)) { schema =3D globalCfg.getDefaultSchemaName(); @@ -193,9 +193,9 @@ return schema; } = - private String getCatalog(AuditTable auditTable, Table table) { + protected String getCatalog(String catalogFromAnnotation, Table table)= { // Get the catalog from the annotation ... - String catalog =3D auditTable.catalog(); + String catalog =3D catalogFromAnnotation; // ... if empty, try using the default ... if (StringTools.isEmpty(catalog)) { catalog =3D globalCfg.getDefaultCatalogName(); @@ -232,8 +232,8 @@ auditTableName =3D verEntCfg.getAuditEntityName(originalTa= bleName); } = - String schema =3D getSchema(auditingData.getAuditTable(), join= .getTable()); - String catalog =3D getCatalog(auditingData.getAuditTable(), jo= in.getTable()); + String schema =3D getSchema(auditingData.getAuditTable().schem= a(), join.getTable()); + String catalog =3D getCatalog(auditingData.getAuditTable().cat= alog(), join.getTable()); = Element joinElement =3D MetadataTools.createJoin(parent, audit= TableName, schema, catalog); joinElements.put(join, joinElement); @@ -343,8 +343,8 @@ @SuppressWarnings({"unchecked"}) public void generateFirstPass(PersistentClass pc, ClassAuditingData au= ditingData, EntityXmlMappingData xmlMappingData, boo= lean isAudited) { - String schema =3D getSchema(auditingData.getAuditTable(), pc.getTa= ble()); - String catalog =3D getCatalog(auditingData.getAuditTable(), pc.get= Table()); + String schema =3D getSchema(auditingData.getAuditTable().schema(),= pc.getTable()); + String catalog =3D getCatalog(auditingData.getAuditTable().catalog= (), pc.getTable()); = if (!isAudited) { String entityName =3D pc.getEntityName(); Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/en= vers/configuration/metadata/CollectionMetadataGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/metadata/CollectionMetadataGenerator.java 2009-11-25 08:35:22 = UTC (rev 18059) +++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/metadata/CollectionMetadataGenerator.java 2009-11-25 08:40:09 = UTC (rev 18060) @@ -475,10 +475,8 @@ } = private Element createMiddleEntityXml(String auditMiddleTableName, Str= ing auditMiddleEntityName) { - String schema =3D StringTools.isEmpty(propertyAuditingData.getJoin= Table().schema()) ? - propertyValue.getCollectionTable().getSchema() : propertyA= uditingData.getJoinTable().schema(); - String catalog =3D StringTools.isEmpty(propertyAuditingData.getJoi= nTable().catalog()) ? - propertyValue.getCollectionTable().getCatalog() : property= AuditingData.getJoinTable().catalog(); + String schema =3D mainGenerator.getSchema(propertyAuditingData.get= JoinTable().schema(), propertyValue.getCollectionTable()); + String catalog =3D mainGenerator.getCatalog(propertyAuditingData.g= etJoinTable().catalog(), propertyValue.getCollectionTable()); = Element middleEntityXml =3D MetadataTools.createEntity(xmlMappingD= ata.newAdditionalMapping(), new AuditTableData(auditMiddleEntityName, auditMiddleTable= Name, schema, catalog), null); --===============3685671817213379043==-- From hibernate-commits at lists.jboss.org Wed Nov 25 04:37:46 2009 Content-Type: multipart/mixed; boundary="===============6741569900277546391==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18061 - core/branches/envers-hibernate-3.3. Date: Wed, 25 Nov 2009 04:37:46 -0500 Message-ID: <200911250937.nAP9bkLI019625@svn01.web.mwc.hst.phx2.redhat.com> --===============6741569900277546391== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: adamw Date: 2009-11-25 04:37:46 -0500 (Wed, 25 Nov 2009) New Revision: 18061 Modified: core/branches/envers-hibernate-3.3/pom.xml Log: Bumping the minor-minor version number Modified: core/branches/envers-hibernate-3.3/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/envers-hibernate-3.3/pom.xml 2009-11-25 08:40:09 UTC (rev= 18060) +++ core/branches/envers-hibernate-3.3/pom.xml 2009-11-25 09:37:46 UTC (rev= 18061) @@ -16,7 +16,7 @@ = Envers Support for entity auditing - 1.2.1-hibernate-3.3-SNAPSHOT + 1.2.2-hibernate-3.3-SNAPSHOT = --===============6741569900277546391==-- From hibernate-commits at lists.jboss.org Wed Nov 25 07:06:11 2009 Content-Type: multipart/mixed; boundary="===============0946523466699430192==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18062 - validator/trunk. Date: Wed, 25 Nov 2009 07:06:11 -0500 Message-ID: <200911251206.nAPC6Bsc014403@svn01.web.mwc.hst.phx2.redhat.com> --===============0946523466699430192== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-25 07:06:11 -0500 (Wed, 25 Nov 2009) New Revision: 18062 Modified: validator/trunk/pom.xml Log: HV-261 Modified: validator/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/pom.xml 2009-11-25 09:37:46 UTC (rev 18061) +++ validator/trunk/pom.xml 2009-11-25 12:06:11 UTC (rev 18062) @@ -188,7 +188,7 @@ Apache License, Version 2.0 - license.txt + http://www.apache.org/licenses/LICENSE-2.0.txt = --===============0946523466699430192==-- From hibernate-commits at lists.jboss.org Wed Nov 25 09:40:27 2009 Content-Type: multipart/mixed; boundary="===============3360503389028282135==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18063 - in beanvalidation/tck/trunk: src/main/assembly and 2 other directories. Date: Wed, 25 Nov 2009 09:40:27 -0500 Message-ID: <200911251440.nAPEeRdC006376@svn01.web.mwc.hst.phx2.redhat.com> --===============3360503389028282135== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-25 09:40:27 -0500 (Wed, 25 Nov 2009) New Revision: 18063 Added: beanvalidation/tck/trunk/src/main/resources/validation-api-java5.sig beanvalidation/tck/trunk/src/main/resources/validation-api-java6.sig Removed: beanvalidation/tck/trunk/src/main/resources/validation-api.sig Modified: beanvalidation/tck/trunk/changelog.txt beanvalidation/tck/trunk/src/main/assembly/assembly.xml beanvalidation/tck/trunk/src/main/docbook/en-US/sigtest.xml Log: BVTCK-5 Modified: beanvalidation/tck/trunk/changelog.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- beanvalidation/tck/trunk/changelog.txt 2009-11-25 12:06:11 UTC (rev 180= 62) +++ beanvalidation/tck/trunk/changelog.txt 2009-11-25 14:40:27 UTC (rev 180= 63) @@ -3,10 +3,17 @@ = See also http://opensource.atlassian.com/projects/hibernate/browse/BVTCK = -1.0.2.GA +1.0.2.GA (25-11-2009) ---------------------- = ** Task + * [BVTCK-5] - Provide separate signature files for Java 5 and Java 6 + = + +1.0.2.GA (24-11-2009) +---------------------- + +** Task * [BVTCK-3] - Create release notes for the distribution package * [BVTCK-4] - Add signature test file to TCK distribution package = = Modified: beanvalidation/tck/trunk/src/main/assembly/assembly.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- beanvalidation/tck/trunk/src/main/assembly/assembly.xml 2009-11-25 12:0= 6:11 UTC (rev 18062) +++ beanvalidation/tck/trunk/src/main/assembly/assembly.xml 2009-11-25 14:4= 0:27 UTC (rev 18063) @@ -51,7 +51,8 @@ tck-audit.xml tck-tests.xml - validation-api.sig + validation-api-java5.sig + validation-api-java6.sig readme.txt = Modified: beanvalidation/tck/trunk/src/main/docbook/en-US/sigtest.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- beanvalidation/tck/trunk/src/main/docbook/en-US/sigtest.xml 2009-11-25 = 12:06:11 UTC (rev 18062) +++ beanvalidation/tck/trunk/src/main/docbook/en-US/sigtest.xml 2009-11-25 = 14:40:27 UTC (rev 18063) @@ -24,12 +24,12 @@

    Creating the signature file = - The TCK package contains the file - validation-api.sig (in the - artifacts directory) which was created using the - following command: + The TCK package contains the files + validation-api-java5.sig and validation-api-java6.sig + (in the artifacts directory) which were created u= sing + the following command (using the corresponding Java version): = - java -jar sigtestdev.jar Setup -classpath %JAVA_HOME%/= jre/lib/rt.jar:lib/validation-api-1.0.0.GA.jar -package javax.validation -f= ilename validation-api.sig + java -jar sigtestdev.jar Setup -classpath %JAVA_HOME%/= jre/lib/rt.jar:lib/validation-api-1.0.0.GA.jar -package javax.validation -f= ilename validation-api-java6.sig = In order to pass the Bean Validation TCK you have to make sure t= hat your API passes the signature tests against @@ -41,11 +41,12 @@ = To run the signature test use: = - java -jar sigtest.jar Test -classpath %JAVA_HOME%/jre/= lib/rt.jar:lib/validation-api-1.0.0.GA.jar -static -package javax.validatio= n -filename validation-api.sig + java -jar sigtest.jar Test -classpath %JAVA_HOME%/jre/= lib/rt.jar:lib/validation-api-1.0.0.GA.jar -static -package javax.validatio= n -filename validation-api-java6.sig = - In order to run against your own Bean Validation API replace - validation-api-1.0.0.GA.jar with your own API jar. You should get the - message "STATUS:Passed.". + You have to chose the right version of the signature file depend= ing + on your Java version. In order to run against your own Bean Validation= API + replace validation-api-1.0.0.GA.jar with your own API jar. You should = get + the message "STATUS:Passed.".
    =
    Added: beanvalidation/tck/trunk/src/main/resources/validation-api-java5.sig =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- beanvalidation/tck/trunk/src/main/resources/validation-api-java5.sig = (rev 0) +++ beanvalidation/tck/trunk/src/main/resources/validation-api-java5.sig 20= 09-11-25 14:40:27 UTC (rev 18063) @@ -0,0 +1,625 @@ +#Signature file v4.0 +#Version = + +CLSS public abstract interface java.io.Serializable + +CLSS public abstract interface java.lang.Comparable<%0 extends java.lang.O= bject> +meth public abstract int compareTo({java.lang.Comparable%0}) + +CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.E= num%0}>> +cons protected Enum(java.lang.String,int) +intf java.io.Serializable +intf java.lang.Comparable<{java.lang.Enum%0}> +meth protected final java.lang.Object clone() throws java.lang.CloneNotSup= portedException +meth public final boolean equals(java.lang.Object) +meth public final int compareTo({java.lang.Enum%0}) +meth public final int hashCode() +meth public final int ordinal() +meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() +meth public final java.lang.String name() +meth public java.lang.String toString() +meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.l= ang.Class<{%%0}>,java.lang.String) +supr java.lang.Object +hfds name,ordinal + +CLSS public java.lang.Exception +cons public Exception() +cons public Exception(java.lang.String) +cons public Exception(java.lang.String,java.lang.Throwable) +cons public Exception(java.lang.Throwable) +supr java.lang.Throwable +hfds serialVersionUID + +CLSS public abstract interface java.lang.Iterable<%0 extends java.lang.Obj= ect> +meth public abstract java.util.Iterator<{java.lang.Iterable%0}> iterator() + +CLSS public java.lang.Object +cons public Object() +meth protected java.lang.Object clone() throws java.lang.CloneNotSupported= Exception +meth protected void finalize() throws java.lang.Throwable +meth public boolean equals(java.lang.Object) +meth public final java.lang.Class getClass() +meth public final void notify() +meth public final void notifyAll() +meth public final void wait() throws java.lang.InterruptedException +meth public final void wait(long) throws java.lang.InterruptedException +meth public final void wait(long,int) throws java.lang.InterruptedException +meth public int hashCode() +meth public java.lang.String toString() + +CLSS public java.lang.RuntimeException +cons public RuntimeException() +cons public RuntimeException(java.lang.String) +cons public RuntimeException(java.lang.String,java.lang.Throwable) +cons public RuntimeException(java.lang.Throwable) +supr java.lang.Exception +hfds serialVersionUID + +CLSS public java.lang.Throwable +cons public Throwable() +cons public Throwable(java.lang.String) +cons public Throwable(java.lang.String,java.lang.Throwable) +cons public Throwable(java.lang.Throwable) +intf java.io.Serializable +meth public java.lang.StackTraceElement[] getStackTrace() +meth public java.lang.String getLocalizedMessage() +meth public java.lang.String getMessage() +meth public java.lang.String toString() +meth public java.lang.Throwable fillInStackTrace() +meth public java.lang.Throwable getCause() +meth public java.lang.Throwable initCause(java.lang.Throwable) +meth public void printStackTrace() +meth public void printStackTrace(java.io.PrintStream) +meth public void printStackTrace(java.io.PrintWriter) +meth public void setStackTrace(java.lang.StackTraceElement[]) +supr java.lang.Object +hfds backtrace,cause,detailMessage,serialVersionUID,stackTrace + +CLSS public abstract interface java.lang.annotation.Annotation +meth public abstract boolean equals(java.lang.Object) +meth public abstract int hashCode() +meth public abstract java.lang.Class annotationType() +meth public abstract java.lang.String toString() + +CLSS public abstract interface !annotation java.lang.annotation.Documented + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation + +CLSS public abstract interface !annotation java.lang.annotation.Retention + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.annotation.RetentionPolicy value() + +CLSS public abstract interface !annotation java.lang.annotation.Target + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.annotation.ElementType[] value() + +CLSS public abstract interface javax.validation.Configuration<%0 extends j= avax.validation.Configuration<{javax.validation.Configuration%0}>> +meth public abstract javax.validation.ConstraintValidatorFactory getDefaul= tConstraintValidatorFactory() +meth public abstract javax.validation.MessageInterpolator getDefaultMessag= eInterpolator() +meth public abstract javax.validation.TraversableResolver getDefaultTraver= sableResolver() +meth public abstract javax.validation.ValidatorFactory buildValidatorFacto= ry() +meth public abstract {javax.validation.Configuration%0} addMapping(java.io= .InputStream) +meth public abstract {javax.validation.Configuration%0} addProperty(java.l= ang.String,java.lang.String) +meth public abstract {javax.validation.Configuration%0} constraintValidato= rFactory(javax.validation.ConstraintValidatorFactory) +meth public abstract {javax.validation.Configuration%0} ignoreXmlConfigura= tion() +meth public abstract {javax.validation.Configuration%0} messageInterpolato= r(javax.validation.MessageInterpolator) +meth public abstract {javax.validation.Configuration%0} traversableResolve= r(javax.validation.TraversableResolver) + +CLSS public abstract interface !annotation javax.validation.Constraint + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.Class>[] validatedBy() + +CLSS public javax.validation.ConstraintDeclarationException +cons public ConstraintDeclarationException() +cons public ConstraintDeclarationException(java.lang.String) +cons public ConstraintDeclarationException(java.lang.String,java.lang.Thro= wable) +cons public ConstraintDeclarationException(java.lang.Throwable) +supr javax.validation.ValidationException + +CLSS public javax.validation.ConstraintDefinitionException +cons public ConstraintDefinitionException() +cons public ConstraintDefinitionException(java.lang.String) +cons public ConstraintDefinitionException(java.lang.String,java.lang.Throw= able) +cons public ConstraintDefinitionException(java.lang.Throwable) +supr javax.validation.ValidationException + +CLSS public abstract interface javax.validation.ConstraintValidator<%0 ext= ends java.lang.annotation.Annotation, %1 extends java.lang.Object> +meth public abstract boolean isValid({javax.validation.ConstraintValidator= %1},javax.validation.ConstraintValidatorContext) +meth public abstract void initialize({javax.validation.ConstraintValidator= %0}) + +CLSS public abstract interface javax.validation.ConstraintValidatorContext +innr public abstract interface static ConstraintViolationBuilder +meth public abstract java.lang.String getDefaultConstraintMessageTemplate() +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder buildConstraintViolationWithTemplate(java.lang.String) +meth public abstract void disableDefaultConstraintViolation() + +CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder +innr public abstract interface static NodeBuilderCustomizableContext +innr public abstract interface static NodeBuilderDefinedContext +innr public abstract interface static NodeContextBuilder +meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderDefinedContext addNode(java.lang.String) + +CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder$NodeBuilderCustomizableContext +meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String) +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeContextBuilder inIterable() + +CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder$NodeBuilderDefinedContext +meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String) + +CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder$NodeContextBuilder +meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String) +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderDefinedContext atIndex(java.lang.Integer) +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderDefinedContext atKey(java.lang.Object) + +CLSS public abstract interface javax.validation.ConstraintValidatorFactory +meth public abstract <%0 extends javax.validation.ConstraintValidator= > {%%0} getInstance(java.lang.Class<{%%0}>) + +CLSS public abstract interface javax.validation.ConstraintViolation<%0 ext= ends java.lang.Object> +meth public abstract java.lang.Class<{javax.validation.ConstraintViolation= %0}> getRootBeanClass() +meth public abstract java.lang.Object getInvalidValue() +meth public abstract java.lang.Object getLeafBean() +meth public abstract java.lang.String getMessage() +meth public abstract java.lang.String getMessageTemplate() +meth public abstract javax.validation.Path getPropertyPath() +meth public abstract javax.validation.metadata.ConstraintDescriptor get= ConstraintDescriptor() +meth public abstract {javax.validation.ConstraintViolation%0} getRootBean() + +CLSS public javax.validation.ConstraintViolationException +cons public ConstraintViolationException(java.lang.String,java.util.Set>) +cons public ConstraintViolationException(java.util.Set>) +meth public java.util.Set> getCons= traintViolations() +supr javax.validation.ValidationException +hfds constraintViolations + +CLSS public javax.validation.GroupDefinitionException +cons public GroupDefinitionException() +cons public GroupDefinitionException(java.lang.String) +cons public GroupDefinitionException(java.lang.String,java.lang.Throwable) +cons public GroupDefinitionException(java.lang.Throwable) +supr javax.validation.ValidationException + +CLSS public abstract interface !annotation javax.validation.GroupSequence + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.Class[] value() + +CLSS public abstract interface javax.validation.MessageInterpolator +innr public abstract interface static Context +meth public abstract java.lang.String interpolate(java.lang.String,javax.v= alidation.MessageInterpolator$Context) +meth public abstract java.lang.String interpolate(java.lang.String,javax.v= alidation.MessageInterpolator$Context,java.util.Locale) + +CLSS public abstract interface static javax.validation.MessageInterpolator= $Context +meth public abstract java.lang.Object getValidatedValue() +meth public abstract javax.validation.metadata.ConstraintDescriptor get= ConstraintDescriptor() + +CLSS public abstract interface !annotation javax.validation.OverridesAttri= bute + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault int constraintIndex() +meth public abstract java.lang.Class constraint() +meth public abstract java.lang.String name() + +CLSS public abstract interface static !annotation javax.validation.Overrid= esAttribute$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.OverridesAttribute[] value() + +CLSS public abstract interface javax.validation.Path +innr public abstract interface static Node +intf java.lang.Iterable + +CLSS public abstract interface static javax.validation.Path$Node +meth public abstract boolean isInIterable() +meth public abstract java.lang.Integer getIndex() +meth public abstract java.lang.Object getKey() +meth public abstract java.lang.String getName() + +CLSS public abstract interface javax.validation.Payload + +CLSS public abstract interface !annotation javax.validation.ReportAsSingle= Violation + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation + +CLSS public abstract interface javax.validation.TraversableResolver +meth public abstract boolean isCascadable(java.lang.Object,javax.validatio= n.Path$Node,java.lang.Class,javax.validation.Path,java.lang.annotation.E= lementType) +meth public abstract boolean isReachable(java.lang.Object,javax.validation= .Path$Node,java.lang.Class,javax.validation.Path,java.lang.annotation.El= ementType) + +CLSS public javax.validation.UnexpectedTypeException +cons public UnexpectedTypeException() +cons public UnexpectedTypeException(java.lang.String) +cons public UnexpectedTypeException(java.lang.String,java.lang.Throwable) +cons public UnexpectedTypeException(java.lang.Throwable) +supr javax.validation.ConstraintDeclarationException + +CLSS public abstract interface !annotation javax.validation.Valid + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation + +CLSS public javax.validation.Validation +cons public Validation() +meth public static <%0 extends javax.validation.Configuration<{%%0}>, %1 e= xtends javax.validation.spi.ValidationProvider<{%%0}>> javax.validation.boo= tstrap.ProviderSpecificBootstrap<{%%0}> byProvider(java.lang.Class<{%%1}>) +meth public static javax.validation.ValidatorFactory buildDefaultValidator= Factory() +meth public static javax.validation.bootstrap.GenericBootstrap byDefaultPr= ovider() +supr java.lang.Object +hcls DefaultValidationProviderResolver,GenericBootstrapImpl,GetClassLoader= ,ProviderSpecificBootstrapImpl + +CLSS public javax.validation.ValidationException +cons public ValidationException() +cons public ValidationException(java.lang.String) +cons public ValidationException(java.lang.String,java.lang.Throwable) +cons public ValidationException(java.lang.Throwable) +supr java.lang.RuntimeException + +CLSS public abstract interface javax.validation.ValidationProviderResolver +meth public abstract java.util.List> getValidationProviders() + +CLSS public abstract interface javax.validation.Validator +meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<= javax.validation.ConstraintViolation<{%%0}>> validate({%%0},java.lang.Class= []) +meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<= javax.validation.ConstraintViolation<{%%0}>> validateProperty({%%0},java.la= ng.String,java.lang.Class[]) +meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<= javax.validation.ConstraintViolation<{%%0}>> validateValue(java.lang.Class<= {%%0}>,java.lang.String,java.lang.Object,java.lang.Class[]) +meth public abstract <%0 extends java.lang.Object> {%%0} unwrap(java.lang.= Class<{%%0}>) +meth public abstract javax.validation.metadata.BeanDescriptor getConstrain= tsForClass(java.lang.Class) + +CLSS public abstract interface javax.validation.ValidatorContext +meth public abstract javax.validation.Validator getValidator() +meth public abstract javax.validation.ValidatorContext constraintValidator= Factory(javax.validation.ConstraintValidatorFactory) +meth public abstract javax.validation.ValidatorContext messageInterpolator= (javax.validation.MessageInterpolator) +meth public abstract javax.validation.ValidatorContext traversableResolver= (javax.validation.TraversableResolver) + +CLSS public abstract interface javax.validation.ValidatorFactory +meth public abstract <%0 extends java.lang.Object> {%%0} unwrap(java.lang.= Class<{%%0}>) +meth public abstract javax.validation.ConstraintValidatorFactory getConstr= aintValidatorFactory() +meth public abstract javax.validation.MessageInterpolator getMessageInterp= olator() +meth public abstract javax.validation.TraversableResolver getTraversableRe= solver() +meth public abstract javax.validation.Validator getValidator() +meth public abstract javax.validation.ValidatorContext usingContext() + +CLSS public abstract interface javax.validation.bootstrap.GenericBootstrap +meth public abstract javax.validation.Configuration configure() +meth public abstract javax.validation.bootstrap.GenericBootstrap providerR= esolver(javax.validation.ValidationProviderResolver) + +CLSS public abstract interface javax.validation.bootstrap.ProviderSpecific= Bootstrap<%0 extends javax.validation.Configuration<{javax.validation.boots= trap.ProviderSpecificBootstrap%0}>> +meth public abstract javax.validation.bootstrap.ProviderSpecificBootstrap<= {javax.validation.bootstrap.ProviderSpecificBootstrap%0}> providerResolver(= javax.validation.ValidationProviderResolver) +meth public abstract {javax.validation.bootstrap.ProviderSpecificBootstrap= %0} configure() + +CLSS public abstract interface !annotation javax.validation.constraints.As= sertFalse + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.AssertFalse$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.AssertFalse[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.As= sertTrue + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.AssertTrue$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.AssertTrue[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.De= cimalMax + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract java.lang.String value() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.DecimalMax$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.DecimalMax[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.De= cimalMin + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract java.lang.String value() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.DecimalMin$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.DecimalMin[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Di= gits + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract int fraction() +meth public abstract int integer() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Digits$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Digits[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Fu= ture + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Future$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Future[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Max + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract long value() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Max$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Max[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Min + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract long value() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Min$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Min[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.No= tNull + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.NotNull$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.NotNull[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Nu= ll + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Null$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Null[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Pa= st + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Past$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Past[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Pa= ttern + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +innr public final static !enum Flag +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract !hasdefault javax.validation.constraints.Pattern$Flag= [] flags() +meth public abstract java.lang.String regexp() + +CLSS public final static !enum javax.validation.constraints.Pattern$Flag +fld public final static javax.validation.constraints.Pattern$Flag CANON_EQ +fld public final static javax.validation.constraints.Pattern$Flag CASE_INS= ENSITIVE +fld public final static javax.validation.constraints.Pattern$Flag COMMENTS +fld public final static javax.validation.constraints.Pattern$Flag DOTALL +fld public final static javax.validation.constraints.Pattern$Flag MULTILINE +fld public final static javax.validation.constraints.Pattern$Flag UNICODE_= CASE +fld public final static javax.validation.constraints.Pattern$Flag UNIX_LIN= ES +meth public final static javax.validation.constraints.Pattern$Flag[] value= s() +meth public int getValue() +meth public static javax.validation.constraints.Pattern$Flag valueOf(java.= lang.String) +supr java.lang.Enum +hfds value + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Pattern$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Pattern[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Si= ze + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault int max() +meth public abstract !hasdefault int min() +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Size$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Size[] value() + +CLSS public abstract interface javax.validation.groups.Default + +CLSS public abstract interface javax.validation.metadata.BeanDescriptor +intf javax.validation.metadata.ElementDescriptor +meth public abstract boolean isBeanConstrained() +meth public abstract java.util.Set getConstrainedProperties() +meth public abstract javax.validation.metadata.PropertyDescriptor getConst= raintsForProperty(java.lang.String) + +CLSS public abstract interface javax.validation.metadata.ConstraintDescrip= tor<%0 extends java.lang.annotation.Annotation> +meth public abstract boolean isReportAsSingleViolation() +meth public abstract java.util.List>> getConstraintValidatorClasses() +meth public abstract java.util.Map getA= ttributes() +meth public abstract java.util.Set> getPayload() +meth public abstract java.util.Set> getGroups() +meth public abstract java.util.Set> getComposingConstraints() +meth public abstract {javax.validation.metadata.ConstraintDescriptor%0} ge= tAnnotation() + +CLSS public abstract interface javax.validation.metadata.ElementDescriptor +innr public abstract interface static ConstraintFinder +meth public abstract boolean hasConstraints() +meth public abstract java.lang.Class getElementClass() +meth public abstract java.util.Set> getConstraintDescriptors() +meth public abstract javax.validation.metadata.ElementDescriptor$Constrain= tFinder findConstraints() + +CLSS public abstract interface static javax.validation.metadata.ElementDes= criptor$ConstraintFinder +meth public abstract !varargs javax.validation.metadata.ElementDescriptor$= ConstraintFinder declaredOn(java.lang.annotation.ElementType[]) +meth public abstract !varargs javax.validation.metadata.ElementDescriptor$= ConstraintFinder unorderedAndMatchingGroups(java.lang.Class[]) +meth public abstract boolean hasConstraints() +meth public abstract java.util.Set> getConstraintDescriptors() +meth public abstract javax.validation.metadata.ElementDescriptor$Constrain= tFinder lookingAt(javax.validation.metadata.Scope) + +CLSS public abstract interface javax.validation.metadata.PropertyDescriptor +intf javax.validation.metadata.ElementDescriptor +meth public abstract boolean isCascaded() +meth public abstract java.lang.String getPropertyName() + +CLSS public final !enum javax.validation.metadata.Scope +fld public final static javax.validation.metadata.Scope HIERARCHY +fld public final static javax.validation.metadata.Scope LOCAL_ELEMENT +meth public final static javax.validation.metadata.Scope[] values() +meth public static javax.validation.metadata.Scope valueOf(java.lang.Strin= g) +supr java.lang.Enum + +CLSS public abstract interface javax.validation.spi.BootstrapState +meth public abstract javax.validation.ValidationProviderResolver getDefaul= tValidationProviderResolver() +meth public abstract javax.validation.ValidationProviderResolver getValida= tionProviderResolver() + +CLSS public abstract interface javax.validation.spi.ConfigurationState +meth public abstract boolean isIgnoreXmlConfiguration() +meth public abstract java.util.Map getP= roperties() +meth public abstract java.util.Set getMappingStreams() +meth public abstract javax.validation.ConstraintValidatorFactory getConstr= aintValidatorFactory() +meth public abstract javax.validation.MessageInterpolator getMessageInterp= olator() +meth public abstract javax.validation.TraversableResolver getTraversableRe= solver() + +CLSS public abstract interface javax.validation.spi.ValidationProvider<%0 = extends javax.validation.Configuration<{javax.validation.spi.ValidationProv= ider%0}>> +meth public abstract javax.validation.Configuration createGenericConfig= uration(javax.validation.spi.BootstrapState) +meth public abstract javax.validation.ValidatorFactory buildValidatorFacto= ry(javax.validation.spi.ConfigurationState) +meth public abstract {javax.validation.spi.ValidationProvider%0} createSpe= cializedConfiguration(javax.validation.spi.BootstrapState) + Copied: beanvalidation/tck/trunk/src/main/resources/validation-api-java6.si= g (from rev 18034, beanvalidation/tck/trunk/src/main/resources/validation-a= pi.sig) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- beanvalidation/tck/trunk/src/main/resources/validation-api-java6.sig = (rev 0) +++ beanvalidation/tck/trunk/src/main/resources/validation-api-java6.sig 20= 09-11-25 14:40:27 UTC (rev 18063) @@ -0,0 +1,626 @@ +#Signature file v4.0 +#Version = + +CLSS public abstract interface java.io.Serializable + +CLSS public abstract interface java.lang.Comparable<%0 extends java.lang.O= bject> +meth public abstract int compareTo({java.lang.Comparable%0}) + +CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.E= num%0}>> +cons protected Enum(java.lang.String,int) +intf java.io.Serializable +intf java.lang.Comparable<{java.lang.Enum%0}> +meth protected final java.lang.Object clone() throws java.lang.CloneNotSup= portedException +meth protected final void finalize() +meth public final boolean equals(java.lang.Object) +meth public final int compareTo({java.lang.Enum%0}) +meth public final int hashCode() +meth public final int ordinal() +meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() +meth public final java.lang.String name() +meth public java.lang.String toString() +meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.l= ang.Class<{%%0}>,java.lang.String) +supr java.lang.Object +hfds name,ordinal + +CLSS public java.lang.Exception +cons public Exception() +cons public Exception(java.lang.String) +cons public Exception(java.lang.String,java.lang.Throwable) +cons public Exception(java.lang.Throwable) +supr java.lang.Throwable +hfds serialVersionUID + +CLSS public abstract interface java.lang.Iterable<%0 extends java.lang.Obj= ect> +meth public abstract java.util.Iterator<{java.lang.Iterable%0}> iterator() + +CLSS public java.lang.Object +cons public Object() +meth protected java.lang.Object clone() throws java.lang.CloneNotSupported= Exception +meth protected void finalize() throws java.lang.Throwable +meth public boolean equals(java.lang.Object) +meth public final java.lang.Class getClass() +meth public final void notify() +meth public final void notifyAll() +meth public final void wait() throws java.lang.InterruptedException +meth public final void wait(long) throws java.lang.InterruptedException +meth public final void wait(long,int) throws java.lang.InterruptedException +meth public int hashCode() +meth public java.lang.String toString() + +CLSS public java.lang.RuntimeException +cons public RuntimeException() +cons public RuntimeException(java.lang.String) +cons public RuntimeException(java.lang.String,java.lang.Throwable) +cons public RuntimeException(java.lang.Throwable) +supr java.lang.Exception +hfds serialVersionUID + +CLSS public java.lang.Throwable +cons public Throwable() +cons public Throwable(java.lang.String) +cons public Throwable(java.lang.String,java.lang.Throwable) +cons public Throwable(java.lang.Throwable) +intf java.io.Serializable +meth public java.lang.StackTraceElement[] getStackTrace() +meth public java.lang.String getLocalizedMessage() +meth public java.lang.String getMessage() +meth public java.lang.String toString() +meth public java.lang.Throwable fillInStackTrace() +meth public java.lang.Throwable getCause() +meth public java.lang.Throwable initCause(java.lang.Throwable) +meth public void printStackTrace() +meth public void printStackTrace(java.io.PrintStream) +meth public void printStackTrace(java.io.PrintWriter) +meth public void setStackTrace(java.lang.StackTraceElement[]) +supr java.lang.Object +hfds backtrace,cause,detailMessage,serialVersionUID,stackTrace + +CLSS public abstract interface java.lang.annotation.Annotation +meth public abstract boolean equals(java.lang.Object) +meth public abstract int hashCode() +meth public abstract java.lang.Class annotationType() +meth public abstract java.lang.String toString() + +CLSS public abstract interface !annotation java.lang.annotation.Documented + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation + +CLSS public abstract interface !annotation java.lang.annotation.Retention + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.annotation.RetentionPolicy value() + +CLSS public abstract interface !annotation java.lang.annotation.Target + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.annotation.ElementType[] value() + +CLSS public abstract interface javax.validation.Configuration<%0 extends j= avax.validation.Configuration<{javax.validation.Configuration%0}>> +meth public abstract javax.validation.ConstraintValidatorFactory getDefaul= tConstraintValidatorFactory() +meth public abstract javax.validation.MessageInterpolator getDefaultMessag= eInterpolator() +meth public abstract javax.validation.TraversableResolver getDefaultTraver= sableResolver() +meth public abstract javax.validation.ValidatorFactory buildValidatorFacto= ry() +meth public abstract {javax.validation.Configuration%0} addMapping(java.io= .InputStream) +meth public abstract {javax.validation.Configuration%0} addProperty(java.l= ang.String,java.lang.String) +meth public abstract {javax.validation.Configuration%0} constraintValidato= rFactory(javax.validation.ConstraintValidatorFactory) +meth public abstract {javax.validation.Configuration%0} ignoreXmlConfigura= tion() +meth public abstract {javax.validation.Configuration%0} messageInterpolato= r(javax.validation.MessageInterpolator) +meth public abstract {javax.validation.Configuration%0} traversableResolve= r(javax.validation.TraversableResolver) + +CLSS public abstract interface !annotation javax.validation.Constraint + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.Class>[] validatedBy() + +CLSS public javax.validation.ConstraintDeclarationException +cons public ConstraintDeclarationException() +cons public ConstraintDeclarationException(java.lang.String) +cons public ConstraintDeclarationException(java.lang.String,java.lang.Thro= wable) +cons public ConstraintDeclarationException(java.lang.Throwable) +supr javax.validation.ValidationException + +CLSS public javax.validation.ConstraintDefinitionException +cons public ConstraintDefinitionException() +cons public ConstraintDefinitionException(java.lang.String) +cons public ConstraintDefinitionException(java.lang.String,java.lang.Throw= able) +cons public ConstraintDefinitionException(java.lang.Throwable) +supr javax.validation.ValidationException + +CLSS public abstract interface javax.validation.ConstraintValidator<%0 ext= ends java.lang.annotation.Annotation, %1 extends java.lang.Object> +meth public abstract boolean isValid({javax.validation.ConstraintValidator= %1},javax.validation.ConstraintValidatorContext) +meth public abstract void initialize({javax.validation.ConstraintValidator= %0}) + +CLSS public abstract interface javax.validation.ConstraintValidatorContext +innr public abstract interface static ConstraintViolationBuilder +meth public abstract java.lang.String getDefaultConstraintMessageTemplate() +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder buildConstraintViolationWithTemplate(java.lang.String) +meth public abstract void disableDefaultConstraintViolation() + +CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder +innr public abstract interface static NodeBuilderCustomizableContext +innr public abstract interface static NodeBuilderDefinedContext +innr public abstract interface static NodeContextBuilder +meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderDefinedContext addNode(java.lang.String) + +CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder$NodeBuilderCustomizableContext +meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String) +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeContextBuilder inIterable() + +CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder$NodeBuilderDefinedContext +meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String) + +CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder$NodeContextBuilder +meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String) +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderDefinedContext atIndex(java.lang.Integer) +meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderDefinedContext atKey(java.lang.Object) + +CLSS public abstract interface javax.validation.ConstraintValidatorFactory +meth public abstract <%0 extends javax.validation.ConstraintValidator= > {%%0} getInstance(java.lang.Class<{%%0}>) + +CLSS public abstract interface javax.validation.ConstraintViolation<%0 ext= ends java.lang.Object> +meth public abstract java.lang.Class<{javax.validation.ConstraintViolation= %0}> getRootBeanClass() +meth public abstract java.lang.Object getInvalidValue() +meth public abstract java.lang.Object getLeafBean() +meth public abstract java.lang.String getMessage() +meth public abstract java.lang.String getMessageTemplate() +meth public abstract javax.validation.Path getPropertyPath() +meth public abstract javax.validation.metadata.ConstraintDescriptor get= ConstraintDescriptor() +meth public abstract {javax.validation.ConstraintViolation%0} getRootBean() + +CLSS public javax.validation.ConstraintViolationException +cons public ConstraintViolationException(java.lang.String,java.util.Set>) +cons public ConstraintViolationException(java.util.Set>) +meth public java.util.Set> getCons= traintViolations() +supr javax.validation.ValidationException +hfds constraintViolations + +CLSS public javax.validation.GroupDefinitionException +cons public GroupDefinitionException() +cons public GroupDefinitionException(java.lang.String) +cons public GroupDefinitionException(java.lang.String,java.lang.Throwable) +cons public GroupDefinitionException(java.lang.Throwable) +supr javax.validation.ValidationException + +CLSS public abstract interface !annotation javax.validation.GroupSequence + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.Class[] value() + +CLSS public abstract interface javax.validation.MessageInterpolator +innr public abstract interface static Context +meth public abstract java.lang.String interpolate(java.lang.String,javax.v= alidation.MessageInterpolator$Context) +meth public abstract java.lang.String interpolate(java.lang.String,javax.v= alidation.MessageInterpolator$Context,java.util.Locale) + +CLSS public abstract interface static javax.validation.MessageInterpolator= $Context +meth public abstract java.lang.Object getValidatedValue() +meth public abstract javax.validation.metadata.ConstraintDescriptor get= ConstraintDescriptor() + +CLSS public abstract interface !annotation javax.validation.OverridesAttri= bute + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault int constraintIndex() +meth public abstract java.lang.Class constraint() +meth public abstract java.lang.String name() + +CLSS public abstract interface static !annotation javax.validation.Overrid= esAttribute$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.OverridesAttribute[] value() + +CLSS public abstract interface javax.validation.Path +innr public abstract interface static Node +intf java.lang.Iterable + +CLSS public abstract interface static javax.validation.Path$Node +meth public abstract boolean isInIterable() +meth public abstract java.lang.Integer getIndex() +meth public abstract java.lang.Object getKey() +meth public abstract java.lang.String getName() + +CLSS public abstract interface javax.validation.Payload + +CLSS public abstract interface !annotation javax.validation.ReportAsSingle= Violation + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation + +CLSS public abstract interface javax.validation.TraversableResolver +meth public abstract boolean isCascadable(java.lang.Object,javax.validatio= n.Path$Node,java.lang.Class,javax.validation.Path,java.lang.annotation.E= lementType) +meth public abstract boolean isReachable(java.lang.Object,javax.validation= .Path$Node,java.lang.Class,javax.validation.Path,java.lang.annotation.El= ementType) + +CLSS public javax.validation.UnexpectedTypeException +cons public UnexpectedTypeException() +cons public UnexpectedTypeException(java.lang.String) +cons public UnexpectedTypeException(java.lang.String,java.lang.Throwable) +cons public UnexpectedTypeException(java.lang.Throwable) +supr javax.validation.ConstraintDeclarationException + +CLSS public abstract interface !annotation javax.validation.Valid + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation + +CLSS public javax.validation.Validation +cons public Validation() +meth public static <%0 extends javax.validation.Configuration<{%%0}>, %1 e= xtends javax.validation.spi.ValidationProvider<{%%0}>> javax.validation.boo= tstrap.ProviderSpecificBootstrap<{%%0}> byProvider(java.lang.Class<{%%1}>) +meth public static javax.validation.ValidatorFactory buildDefaultValidator= Factory() +meth public static javax.validation.bootstrap.GenericBootstrap byDefaultPr= ovider() +supr java.lang.Object +hcls DefaultValidationProviderResolver,GenericBootstrapImpl,GetClassLoader= ,ProviderSpecificBootstrapImpl + +CLSS public javax.validation.ValidationException +cons public ValidationException() +cons public ValidationException(java.lang.String) +cons public ValidationException(java.lang.String,java.lang.Throwable) +cons public ValidationException(java.lang.Throwable) +supr java.lang.RuntimeException + +CLSS public abstract interface javax.validation.ValidationProviderResolver +meth public abstract java.util.List> getValidationProviders() + +CLSS public abstract interface javax.validation.Validator +meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<= javax.validation.ConstraintViolation<{%%0}>> validate({%%0},java.lang.Class= []) +meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<= javax.validation.ConstraintViolation<{%%0}>> validateProperty({%%0},java.la= ng.String,java.lang.Class[]) +meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<= javax.validation.ConstraintViolation<{%%0}>> validateValue(java.lang.Class<= {%%0}>,java.lang.String,java.lang.Object,java.lang.Class[]) +meth public abstract <%0 extends java.lang.Object> {%%0} unwrap(java.lang.= Class<{%%0}>) +meth public abstract javax.validation.metadata.BeanDescriptor getConstrain= tsForClass(java.lang.Class) + +CLSS public abstract interface javax.validation.ValidatorContext +meth public abstract javax.validation.Validator getValidator() +meth public abstract javax.validation.ValidatorContext constraintValidator= Factory(javax.validation.ConstraintValidatorFactory) +meth public abstract javax.validation.ValidatorContext messageInterpolator= (javax.validation.MessageInterpolator) +meth public abstract javax.validation.ValidatorContext traversableResolver= (javax.validation.TraversableResolver) + +CLSS public abstract interface javax.validation.ValidatorFactory +meth public abstract <%0 extends java.lang.Object> {%%0} unwrap(java.lang.= Class<{%%0}>) +meth public abstract javax.validation.ConstraintValidatorFactory getConstr= aintValidatorFactory() +meth public abstract javax.validation.MessageInterpolator getMessageInterp= olator() +meth public abstract javax.validation.TraversableResolver getTraversableRe= solver() +meth public abstract javax.validation.Validator getValidator() +meth public abstract javax.validation.ValidatorContext usingContext() + +CLSS public abstract interface javax.validation.bootstrap.GenericBootstrap +meth public abstract javax.validation.Configuration configure() +meth public abstract javax.validation.bootstrap.GenericBootstrap providerR= esolver(javax.validation.ValidationProviderResolver) + +CLSS public abstract interface javax.validation.bootstrap.ProviderSpecific= Bootstrap<%0 extends javax.validation.Configuration<{javax.validation.boots= trap.ProviderSpecificBootstrap%0}>> +meth public abstract javax.validation.bootstrap.ProviderSpecificBootstrap<= {javax.validation.bootstrap.ProviderSpecificBootstrap%0}> providerResolver(= javax.validation.ValidationProviderResolver) +meth public abstract {javax.validation.bootstrap.ProviderSpecificBootstrap= %0} configure() + +CLSS public abstract interface !annotation javax.validation.constraints.As= sertFalse + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.AssertFalse$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.AssertFalse[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.As= sertTrue + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.AssertTrue$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.AssertTrue[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.De= cimalMax + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract java.lang.String value() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.DecimalMax$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.DecimalMax[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.De= cimalMin + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract java.lang.String value() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.DecimalMin$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.DecimalMin[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Di= gits + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract int fraction() +meth public abstract int integer() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Digits$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Digits[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Fu= ture + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Future$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Future[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Max + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract long value() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Max$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Max[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Min + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract long value() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Min$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Min[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.No= tNull + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.NotNull$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.NotNull[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Nu= ll + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Null$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Null[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Pa= st + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Past$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Past[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Pa= ttern + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +innr public final static !enum Flag +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() +meth public abstract !hasdefault javax.validation.constraints.Pattern$Flag= [] flags() +meth public abstract java.lang.String regexp() + +CLSS public final static !enum javax.validation.constraints.Pattern$Flag +fld public final static javax.validation.constraints.Pattern$Flag CANON_EQ +fld public final static javax.validation.constraints.Pattern$Flag CASE_INS= ENSITIVE +fld public final static javax.validation.constraints.Pattern$Flag COMMENTS +fld public final static javax.validation.constraints.Pattern$Flag DOTALL +fld public final static javax.validation.constraints.Pattern$Flag MULTILINE +fld public final static javax.validation.constraints.Pattern$Flag UNICODE_= CASE +fld public final static javax.validation.constraints.Pattern$Flag UNIX_LIN= ES +meth public final static javax.validation.constraints.Pattern$Flag[] value= s() +meth public int getValue() +meth public static javax.validation.constraints.Pattern$Flag valueOf(java.= lang.String) +supr java.lang.Enum +hfds value + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Pattern$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Pattern[] value() + +CLSS public abstract interface !annotation javax.validation.constraints.Si= ze + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) + anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) +innr public abstract interface static !annotation List +intf java.lang.annotation.Annotation +meth public abstract !hasdefault int max() +meth public abstract !hasdefault int min() +meth public abstract !hasdefault java.lang.Class[] payload() +meth public abstract !hasdefault java.lang.Class[] groups() +meth public abstract !hasdefault java.lang.String message() + +CLSS public abstract interface static !annotation javax.validation.constra= ints.Size$List + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract javax.validation.constraints.Size[] value() + +CLSS public abstract interface javax.validation.groups.Default + +CLSS public abstract interface javax.validation.metadata.BeanDescriptor +intf javax.validation.metadata.ElementDescriptor +meth public abstract boolean isBeanConstrained() +meth public abstract java.util.Set getConstrainedProperties() +meth public abstract javax.validation.metadata.PropertyDescriptor getConst= raintsForProperty(java.lang.String) + +CLSS public abstract interface javax.validation.metadata.ConstraintDescrip= tor<%0 extends java.lang.annotation.Annotation> +meth public abstract boolean isReportAsSingleViolation() +meth public abstract java.util.List>> getConstraintValidatorClasses() +meth public abstract java.util.Map getA= ttributes() +meth public abstract java.util.Set> getPayload() +meth public abstract java.util.Set> getGroups() +meth public abstract java.util.Set> getComposingConstraints() +meth public abstract {javax.validation.metadata.ConstraintDescriptor%0} ge= tAnnotation() + +CLSS public abstract interface javax.validation.metadata.ElementDescriptor +innr public abstract interface static ConstraintFinder +meth public abstract boolean hasConstraints() +meth public abstract java.lang.Class getElementClass() +meth public abstract java.util.Set> getConstraintDescriptors() +meth public abstract javax.validation.metadata.ElementDescriptor$Constrain= tFinder findConstraints() + +CLSS public abstract interface static javax.validation.metadata.ElementDes= criptor$ConstraintFinder +meth public abstract !varargs javax.validation.metadata.ElementDescriptor$= ConstraintFinder declaredOn(java.lang.annotation.ElementType[]) +meth public abstract !varargs javax.validation.metadata.ElementDescriptor$= ConstraintFinder unorderedAndMatchingGroups(java.lang.Class[]) +meth public abstract boolean hasConstraints() +meth public abstract java.util.Set> getConstraintDescriptors() +meth public abstract javax.validation.metadata.ElementDescriptor$Constrain= tFinder lookingAt(javax.validation.metadata.Scope) + +CLSS public abstract interface javax.validation.metadata.PropertyDescriptor +intf javax.validation.metadata.ElementDescriptor +meth public abstract boolean isCascaded() +meth public abstract java.lang.String getPropertyName() + +CLSS public final !enum javax.validation.metadata.Scope +fld public final static javax.validation.metadata.Scope HIERARCHY +fld public final static javax.validation.metadata.Scope LOCAL_ELEMENT +meth public final static javax.validation.metadata.Scope[] values() +meth public static javax.validation.metadata.Scope valueOf(java.lang.Strin= g) +supr java.lang.Enum + +CLSS public abstract interface javax.validation.spi.BootstrapState +meth public abstract javax.validation.ValidationProviderResolver getDefaul= tValidationProviderResolver() +meth public abstract javax.validation.ValidationProviderResolver getValida= tionProviderResolver() + +CLSS public abstract interface javax.validation.spi.ConfigurationState +meth public abstract boolean isIgnoreXmlConfiguration() +meth public abstract java.util.Map getP= roperties() +meth public abstract java.util.Set getMappingStreams() +meth public abstract javax.validation.ConstraintValidatorFactory getConstr= aintValidatorFactory() +meth public abstract javax.validation.MessageInterpolator getMessageInterp= olator() +meth public abstract javax.validation.TraversableResolver getTraversableRe= solver() + +CLSS public abstract interface javax.validation.spi.ValidationProvider<%0 = extends javax.validation.Configuration<{javax.validation.spi.ValidationProv= ider%0}>> +meth public abstract javax.validation.Configuration createGenericConfig= uration(javax.validation.spi.BootstrapState) +meth public abstract javax.validation.ValidatorFactory buildValidatorFacto= ry(javax.validation.spi.ConfigurationState) +meth public abstract {javax.validation.spi.ValidationProvider%0} createSpe= cializedConfiguration(javax.validation.spi.BootstrapState) + Deleted: beanvalidation/tck/trunk/src/main/resources/validation-api.sig =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- beanvalidation/tck/trunk/src/main/resources/validation-api.sig 2009-11-= 25 12:06:11 UTC (rev 18062) +++ beanvalidation/tck/trunk/src/main/resources/validation-api.sig 2009-11-= 25 14:40:27 UTC (rev 18063) @@ -1,626 +0,0 @@ -#Signature file v4.0 -#Version = - -CLSS public abstract interface java.io.Serializable - -CLSS public abstract interface java.lang.Comparable<%0 extends java.lang.O= bject> -meth public abstract int compareTo({java.lang.Comparable%0}) - -CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.E= num%0}>> -cons protected Enum(java.lang.String,int) -intf java.io.Serializable -intf java.lang.Comparable<{java.lang.Enum%0}> -meth protected final java.lang.Object clone() throws java.lang.CloneNotSup= portedException -meth protected final void finalize() -meth public final boolean equals(java.lang.Object) -meth public final int compareTo({java.lang.Enum%0}) -meth public final int hashCode() -meth public final int ordinal() -meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() -meth public final java.lang.String name() -meth public java.lang.String toString() -meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.l= ang.Class<{%%0}>,java.lang.String) -supr java.lang.Object -hfds name,ordinal - -CLSS public java.lang.Exception -cons public Exception() -cons public Exception(java.lang.String) -cons public Exception(java.lang.String,java.lang.Throwable) -cons public Exception(java.lang.Throwable) -supr java.lang.Throwable -hfds serialVersionUID - -CLSS public abstract interface java.lang.Iterable<%0 extends java.lang.Obj= ect> -meth public abstract java.util.Iterator<{java.lang.Iterable%0}> iterator() - -CLSS public java.lang.Object -cons public Object() -meth protected java.lang.Object clone() throws java.lang.CloneNotSupported= Exception -meth protected void finalize() throws java.lang.Throwable -meth public boolean equals(java.lang.Object) -meth public final java.lang.Class getClass() -meth public final void notify() -meth public final void notifyAll() -meth public final void wait() throws java.lang.InterruptedException -meth public final void wait(long) throws java.lang.InterruptedException -meth public final void wait(long,int) throws java.lang.InterruptedException -meth public int hashCode() -meth public java.lang.String toString() - -CLSS public java.lang.RuntimeException -cons public RuntimeException() -cons public RuntimeException(java.lang.String) -cons public RuntimeException(java.lang.String,java.lang.Throwable) -cons public RuntimeException(java.lang.Throwable) -supr java.lang.Exception -hfds serialVersionUID - -CLSS public java.lang.Throwable -cons public Throwable() -cons public Throwable(java.lang.String) -cons public Throwable(java.lang.String,java.lang.Throwable) -cons public Throwable(java.lang.Throwable) -intf java.io.Serializable -meth public java.lang.StackTraceElement[] getStackTrace() -meth public java.lang.String getLocalizedMessage() -meth public java.lang.String getMessage() -meth public java.lang.String toString() -meth public java.lang.Throwable fillInStackTrace() -meth public java.lang.Throwable getCause() -meth public java.lang.Throwable initCause(java.lang.Throwable) -meth public void printStackTrace() -meth public void printStackTrace(java.io.PrintStream) -meth public void printStackTrace(java.io.PrintWriter) -meth public void setStackTrace(java.lang.StackTraceElement[]) -supr java.lang.Object -hfds backtrace,cause,detailMessage,serialVersionUID,stackTrace - -CLSS public abstract interface java.lang.annotation.Annotation -meth public abstract boolean equals(java.lang.Object) -meth public abstract int hashCode() -meth public abstract java.lang.Class annotationType() -meth public abstract java.lang.String toString() - -CLSS public abstract interface !annotation java.lang.annotation.Documented - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) -intf java.lang.annotation.Annotation - -CLSS public abstract interface !annotation java.lang.annotation.Retention - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) -intf java.lang.annotation.Annotation -meth public abstract java.lang.annotation.RetentionPolicy value() - -CLSS public abstract interface !annotation java.lang.annotation.Target - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) -intf java.lang.annotation.Annotation -meth public abstract java.lang.annotation.ElementType[] value() - -CLSS public abstract interface javax.validation.Configuration<%0 extends j= avax.validation.Configuration<{javax.validation.Configuration%0}>> -meth public abstract javax.validation.ConstraintValidatorFactory getDefaul= tConstraintValidatorFactory() -meth public abstract javax.validation.MessageInterpolator getDefaultMessag= eInterpolator() -meth public abstract javax.validation.TraversableResolver getDefaultTraver= sableResolver() -meth public abstract javax.validation.ValidatorFactory buildValidatorFacto= ry() -meth public abstract {javax.validation.Configuration%0} addMapping(java.io= .InputStream) -meth public abstract {javax.validation.Configuration%0} addProperty(java.l= ang.String,java.lang.String) -meth public abstract {javax.validation.Configuration%0} constraintValidato= rFactory(javax.validation.ConstraintValidatorFactory) -meth public abstract {javax.validation.Configuration%0} ignoreXmlConfigura= tion() -meth public abstract {javax.validation.Configuration%0} messageInterpolato= r(javax.validation.MessageInterpolator) -meth public abstract {javax.validation.Configuration%0} traversableResolve= r(javax.validation.TraversableResolver) - -CLSS public abstract interface !annotation javax.validation.Constraint - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) -intf java.lang.annotation.Annotation -meth public abstract java.lang.Class>[] validatedBy() - -CLSS public javax.validation.ConstraintDeclarationException -cons public ConstraintDeclarationException() -cons public ConstraintDeclarationException(java.lang.String) -cons public ConstraintDeclarationException(java.lang.String,java.lang.Thro= wable) -cons public ConstraintDeclarationException(java.lang.Throwable) -supr javax.validation.ValidationException - -CLSS public javax.validation.ConstraintDefinitionException -cons public ConstraintDefinitionException() -cons public ConstraintDefinitionException(java.lang.String) -cons public ConstraintDefinitionException(java.lang.String,java.lang.Throw= able) -cons public ConstraintDefinitionException(java.lang.Throwable) -supr javax.validation.ValidationException - -CLSS public abstract interface javax.validation.ConstraintValidator<%0 ext= ends java.lang.annotation.Annotation, %1 extends java.lang.Object> -meth public abstract boolean isValid({javax.validation.ConstraintValidator= %1},javax.validation.ConstraintValidatorContext) -meth public abstract void initialize({javax.validation.ConstraintValidator= %0}) - -CLSS public abstract interface javax.validation.ConstraintValidatorContext -innr public abstract interface static ConstraintViolationBuilder -meth public abstract java.lang.String getDefaultConstraintMessageTemplate() -meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder buildConstraintViolationWithTemplate(java.lang.String) -meth public abstract void disableDefaultConstraintViolation() - -CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder -innr public abstract interface static NodeBuilderCustomizableContext -innr public abstract interface static NodeBuilderDefinedContext -innr public abstract interface static NodeContextBuilder -meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() -meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderDefinedContext addNode(java.lang.String) - -CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder$NodeBuilderCustomizableContext -meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() -meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String) -meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeContextBuilder inIterable() - -CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder$NodeBuilderDefinedContext -meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() -meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String) - -CLSS public abstract interface static javax.validation.ConstraintValidator= Context$ConstraintViolationBuilder$NodeContextBuilder -meth public abstract javax.validation.ConstraintValidatorContext addConstr= aintViolation() -meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String) -meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderDefinedContext atIndex(java.lang.Integer) -meth public abstract javax.validation.ConstraintValidatorContext$Constrain= tViolationBuilder$NodeBuilderDefinedContext atKey(java.lang.Object) - -CLSS public abstract interface javax.validation.ConstraintValidatorFactory -meth public abstract <%0 extends javax.validation.ConstraintValidator= > {%%0} getInstance(java.lang.Class<{%%0}>) - -CLSS public abstract interface javax.validation.ConstraintViolation<%0 ext= ends java.lang.Object> -meth public abstract java.lang.Class<{javax.validation.ConstraintViolation= %0}> getRootBeanClass() -meth public abstract java.lang.Object getInvalidValue() -meth public abstract java.lang.Object getLeafBean() -meth public abstract java.lang.String getMessage() -meth public abstract java.lang.String getMessageTemplate() -meth public abstract javax.validation.Path getPropertyPath() -meth public abstract javax.validation.metadata.ConstraintDescriptor get= ConstraintDescriptor() -meth public abstract {javax.validation.ConstraintViolation%0} getRootBean() - -CLSS public javax.validation.ConstraintViolationException -cons public ConstraintViolationException(java.lang.String,java.util.Set>) -cons public ConstraintViolationException(java.util.Set>) -meth public java.util.Set> getCons= traintViolations() -supr javax.validation.ValidationException -hfds constraintViolations - -CLSS public javax.validation.GroupDefinitionException -cons public GroupDefinitionException() -cons public GroupDefinitionException(java.lang.String) -cons public GroupDefinitionException(java.lang.String,java.lang.Throwable) -cons public GroupDefinitionException(java.lang.Throwable) -supr javax.validation.ValidationException - -CLSS public abstract interface !annotation javax.validation.GroupSequence - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[TYPE]) -intf java.lang.annotation.Annotation -meth public abstract java.lang.Class[] value() - -CLSS public abstract interface javax.validation.MessageInterpolator -innr public abstract interface static Context -meth public abstract java.lang.String interpolate(java.lang.String,javax.v= alidation.MessageInterpolator$Context) -meth public abstract java.lang.String interpolate(java.lang.String,javax.v= alidation.MessageInterpolator$Context,java.util.Locale) - -CLSS public abstract interface static javax.validation.MessageInterpolator= $Context -meth public abstract java.lang.Object getValidatedValue() -meth public abstract javax.validation.metadata.ConstraintDescriptor get= ConstraintDescriptor() - -CLSS public abstract interface !annotation javax.validation.OverridesAttri= bute - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault int constraintIndex() -meth public abstract java.lang.Class constraint() -meth public abstract java.lang.String name() - -CLSS public abstract interface static !annotation javax.validation.Overrid= esAttribute$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.OverridesAttribute[] value() - -CLSS public abstract interface javax.validation.Path -innr public abstract interface static Node -intf java.lang.Iterable - -CLSS public abstract interface static javax.validation.Path$Node -meth public abstract boolean isInIterable() -meth public abstract java.lang.Integer getIndex() -meth public abstract java.lang.Object getKey() -meth public abstract java.lang.String getName() - -CLSS public abstract interface javax.validation.Payload - -CLSS public abstract interface !annotation javax.validation.ReportAsSingle= Violation - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[ANNOTATION_TYPE]) -intf java.lang.annotation.Annotation - -CLSS public abstract interface javax.validation.TraversableResolver -meth public abstract boolean isCascadable(java.lang.Object,javax.validatio= n.Path$Node,java.lang.Class,javax.validation.Path,java.lang.annotation.E= lementType) -meth public abstract boolean isReachable(java.lang.Object,javax.validation= .Path$Node,java.lang.Class,javax.validation.Path,java.lang.annotation.El= ementType) - -CLSS public javax.validation.UnexpectedTypeException -cons public UnexpectedTypeException() -cons public UnexpectedTypeException(java.lang.String) -cons public UnexpectedTypeException(java.lang.String,java.lang.Throwable) -cons public UnexpectedTypeException(java.lang.Throwable) -supr javax.validation.ConstraintDeclarationException - -CLSS public abstract interface !annotation javax.validation.Valid - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation - -CLSS public javax.validation.Validation -cons public Validation() -meth public static <%0 extends javax.validation.Configuration<{%%0}>, %1 e= xtends javax.validation.spi.ValidationProvider<{%%0}>> javax.validation.boo= tstrap.ProviderSpecificBootstrap<{%%0}> byProvider(java.lang.Class<{%%1}>) -meth public static javax.validation.ValidatorFactory buildDefaultValidator= Factory() -meth public static javax.validation.bootstrap.GenericBootstrap byDefaultPr= ovider() -supr java.lang.Object -hcls DefaultValidationProviderResolver,GenericBootstrapImpl,GetClassLoader= ,ProviderSpecificBootstrapImpl - -CLSS public javax.validation.ValidationException -cons public ValidationException() -cons public ValidationException(java.lang.String) -cons public ValidationException(java.lang.String,java.lang.Throwable) -cons public ValidationException(java.lang.Throwable) -supr java.lang.RuntimeException - -CLSS public abstract interface javax.validation.ValidationProviderResolver -meth public abstract java.util.List> getValidationProviders() - -CLSS public abstract interface javax.validation.Validator -meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<= javax.validation.ConstraintViolation<{%%0}>> validate({%%0},java.lang.Class= []) -meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<= javax.validation.ConstraintViolation<{%%0}>> validateProperty({%%0},java.la= ng.String,java.lang.Class[]) -meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<= javax.validation.ConstraintViolation<{%%0}>> validateValue(java.lang.Class<= {%%0}>,java.lang.String,java.lang.Object,java.lang.Class[]) -meth public abstract <%0 extends java.lang.Object> {%%0} unwrap(java.lang.= Class<{%%0}>) -meth public abstract javax.validation.metadata.BeanDescriptor getConstrain= tsForClass(java.lang.Class) - -CLSS public abstract interface javax.validation.ValidatorContext -meth public abstract javax.validation.Validator getValidator() -meth public abstract javax.validation.ValidatorContext constraintValidator= Factory(javax.validation.ConstraintValidatorFactory) -meth public abstract javax.validation.ValidatorContext messageInterpolator= (javax.validation.MessageInterpolator) -meth public abstract javax.validation.ValidatorContext traversableResolver= (javax.validation.TraversableResolver) - -CLSS public abstract interface javax.validation.ValidatorFactory -meth public abstract <%0 extends java.lang.Object> {%%0} unwrap(java.lang.= Class<{%%0}>) -meth public abstract javax.validation.ConstraintValidatorFactory getConstr= aintValidatorFactory() -meth public abstract javax.validation.MessageInterpolator getMessageInterp= olator() -meth public abstract javax.validation.TraversableResolver getTraversableRe= solver() -meth public abstract javax.validation.Validator getValidator() -meth public abstract javax.validation.ValidatorContext usingContext() - -CLSS public abstract interface javax.validation.bootstrap.GenericBootstrap -meth public abstract javax.validation.Configuration configure() -meth public abstract javax.validation.bootstrap.GenericBootstrap providerR= esolver(javax.validation.ValidationProviderResolver) - -CLSS public abstract interface javax.validation.bootstrap.ProviderSpecific= Bootstrap<%0 extends javax.validation.Configuration<{javax.validation.boots= trap.ProviderSpecificBootstrap%0}>> -meth public abstract javax.validation.bootstrap.ProviderSpecificBootstrap<= {javax.validation.bootstrap.ProviderSpecificBootstrap%0}> providerResolver(= javax.validation.ValidationProviderResolver) -meth public abstract {javax.validation.bootstrap.ProviderSpecificBootstrap= %0} configure() - -CLSS public abstract interface !annotation javax.validation.constraints.As= sertFalse - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.AssertFalse$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.AssertFalse[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.As= sertTrue - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.AssertTrue$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.AssertTrue[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.De= cimalMax - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() -meth public abstract java.lang.String value() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.DecimalMax$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.DecimalMax[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.De= cimalMin - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() -meth public abstract java.lang.String value() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.DecimalMin$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.DecimalMin[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.Di= gits - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() -meth public abstract int fraction() -meth public abstract int integer() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.Digits$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.Digits[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.Fu= ture - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.Future$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.Future[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.Max - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() -meth public abstract long value() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.Max$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.Max[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.Min - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() -meth public abstract long value() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.Min$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.Min[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.No= tNull - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.NotNull$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.NotNull[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.Nu= ll - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.Null$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.Null[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.Pa= st - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.Past$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.Past[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.Pa= ttern - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -innr public final static !enum Flag -intf java.lang.annotation.Annotation -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() -meth public abstract !hasdefault javax.validation.constraints.Pattern$Flag= [] flags() -meth public abstract java.lang.String regexp() - -CLSS public final static !enum javax.validation.constraints.Pattern$Flag -fld public final static javax.validation.constraints.Pattern$Flag CANON_EQ -fld public final static javax.validation.constraints.Pattern$Flag CASE_INS= ENSITIVE -fld public final static javax.validation.constraints.Pattern$Flag COMMENTS -fld public final static javax.validation.constraints.Pattern$Flag DOTALL -fld public final static javax.validation.constraints.Pattern$Flag MULTILINE -fld public final static javax.validation.constraints.Pattern$Flag UNICODE_= CASE -fld public final static javax.validation.constraints.Pattern$Flag UNIX_LIN= ES -meth public final static javax.validation.constraints.Pattern$Flag[] value= s() -meth public int getValue() -meth public static javax.validation.constraints.Pattern$Flag valueOf(java.= lang.String) -supr java.lang.Enum -hfds value - -CLSS public abstract interface static !annotation javax.validation.constra= ints.Pattern$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.Pattern[] value() - -CLSS public abstract interface !annotation javax.validation.constraints.Si= ze - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) - anno 0 javax.validation.Constraint(java.lang.Class>[] validatedBy=3D[]) -innr public abstract interface static !annotation List -intf java.lang.annotation.Annotation -meth public abstract !hasdefault int max() -meth public abstract !hasdefault int min() -meth public abstract !hasdefault java.lang.Class[] payload() -meth public abstract !hasdefault java.lang.Class[] groups() -meth public abstract !hasdefault java.lang.String message() - -CLSS public abstract interface static !annotation javax.validation.constra= ints.Size$List - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolic= y value=3DRUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] val= ue=3D[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER]) -intf java.lang.annotation.Annotation -meth public abstract javax.validation.constraints.Size[] value() - -CLSS public abstract interface javax.validation.groups.Default - -CLSS public abstract interface javax.validation.metadata.BeanDescriptor -intf javax.validation.metadata.ElementDescriptor -meth public abstract boolean isBeanConstrained() -meth public abstract java.util.Set getConstrainedProperties() -meth public abstract javax.validation.metadata.PropertyDescriptor getConst= raintsForProperty(java.lang.String) - -CLSS public abstract interface javax.validation.metadata.ConstraintDescrip= tor<%0 extends java.lang.annotation.Annotation> -meth public abstract boolean isReportAsSingleViolation() -meth public abstract java.util.List>> getConstraintValidatorClasses() -meth public abstract java.util.Map getA= ttributes() -meth public abstract java.util.Set> getPayload() -meth public abstract java.util.Set> getGroups() -meth public abstract java.util.Set> getComposingConstraints() -meth public abstract {javax.validation.metadata.ConstraintDescriptor%0} ge= tAnnotation() - -CLSS public abstract interface javax.validation.metadata.ElementDescriptor -innr public abstract interface static ConstraintFinder -meth public abstract boolean hasConstraints() -meth public abstract java.lang.Class getElementClass() -meth public abstract java.util.Set> getConstraintDescriptors() -meth public abstract javax.validation.metadata.ElementDescriptor$Constrain= tFinder findConstraints() - -CLSS public abstract interface static javax.validation.metadata.ElementDes= criptor$ConstraintFinder -meth public abstract !varargs javax.validation.metadata.ElementDescriptor$= ConstraintFinder declaredOn(java.lang.annotation.ElementType[]) -meth public abstract !varargs javax.validation.metadata.ElementDescriptor$= ConstraintFinder unorderedAndMatchingGroups(java.lang.Class[]) -meth public abstract boolean hasConstraints() -meth public abstract java.util.Set> getConstraintDescriptors() -meth public abstract javax.validation.metadata.ElementDescriptor$Constrain= tFinder lookingAt(javax.validation.metadata.Scope) - -CLSS public abstract interface javax.validation.metadata.PropertyDescriptor -intf javax.validation.metadata.ElementDescriptor -meth public abstract boolean isCascaded() -meth public abstract java.lang.String getPropertyName() - -CLSS public final !enum javax.validation.metadata.Scope -fld public final static javax.validation.metadata.Scope HIERARCHY -fld public final static javax.validation.metadata.Scope LOCAL_ELEMENT -meth public final static javax.validation.metadata.Scope[] values() -meth public static javax.validation.metadata.Scope valueOf(java.lang.Strin= g) -supr java.lang.Enum - -CLSS public abstract interface javax.validation.spi.BootstrapState -meth public abstract javax.validation.ValidationProviderResolver getDefaul= tValidationProviderResolver() -meth public abstract javax.validation.ValidationProviderResolver getValida= tionProviderResolver() - -CLSS public abstract interface javax.validation.spi.ConfigurationState -meth public abstract boolean isIgnoreXmlConfiguration() -meth public abstract java.util.Map getP= roperties() -meth public abstract java.util.Set getMappingStreams() -meth public abstract javax.validation.ConstraintValidatorFactory getConstr= aintValidatorFactory() -meth public abstract javax.validation.MessageInterpolator getMessageInterp= olator() -meth public abstract javax.validation.TraversableResolver getTraversableRe= solver() - -CLSS public abstract interface javax.validation.spi.ValidationProvider<%0 = extends javax.validation.Configuration<{javax.validation.spi.ValidationProv= ider%0}>> -meth public abstract javax.validation.Configuration createGenericConfig= uration(javax.validation.spi.BootstrapState) -meth public abstract javax.validation.ValidatorFactory buildValidatorFacto= ry(javax.validation.spi.ConfigurationState) -meth public abstract {javax.validation.spi.ValidationProvider%0} createSpe= cializedConfiguration(javax.validation.spi.BootstrapState) - --===============3360503389028282135==-- From hibernate-commits at lists.jboss.org Wed Nov 25 09:46:20 2009 Content-Type: multipart/mixed; boundary="===============8347672871872908715==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18064 - beanvalidation/tck/trunk. Date: Wed, 25 Nov 2009 09:46:20 -0500 Message-ID: <200911251446.nAPEkKDf007535@svn01.web.mwc.hst.phx2.redhat.com> --===============8347672871872908715== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-25 09:46:20 -0500 (Wed, 25 Nov 2009) New Revision: 18064 Modified: beanvalidation/tck/trunk/pom.xml Log: [maven-release-plugin] prepare release v1_0_3_GA Modified: beanvalidation/tck/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- beanvalidation/tck/trunk/pom.xml 2009-11-25 14:40:27 UTC (rev 18063) +++ beanvalidation/tck/trunk/pom.xml 2009-11-25 14:46:20 UTC (rev 18064) @@ -4,7 +4,7 @@ org.hibernate.jsr303.tck jsr303-tck jar - 1.0.3-SNAPSHOT + 1.0.3.GA JSR-303 TCK http://validator.hibernate.org = @@ -299,8 +299,8 @@ = - scm:svn:http://anonsvn.jboss.org/repos/hibernate/beanv= alidation/tck/trunk - scm:svn:https://svn.jboss.org/repos/hibernate= /beanvalidation/tck/trunk + scm:svn:http://anonsvn.jboss.org/repos/hibernate/beanv= alidation/tck/tags/v1_0_3_GA + scm:svn:https://svn.jboss.org/repos/hibernate= /beanvalidation/tck/tags/v1_0_3_GA = --===============8347672871872908715==-- From hibernate-commits at lists.jboss.org Wed Nov 25 09:46:44 2009 Content-Type: multipart/mixed; boundary="===============8011246813625672564==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18065 - beanvalidation/tck/tags. Date: Wed, 25 Nov 2009 09:46:43 -0500 Message-ID: <200911251446.nAPEkhD4007577@svn01.web.mwc.hst.phx2.redhat.com> --===============8011246813625672564== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-25 09:46:43 -0500 (Wed, 25 Nov 2009) New Revision: 18065 Added: beanvalidation/tck/tags/v1_0_3_GA/ Log: [maven-scm] copy for tag v1_0_3_GA Copied: beanvalidation/tck/tags/v1_0_3_GA (from rev 18064, beanvalidation/t= ck/trunk) --===============8011246813625672564==-- From hibernate-commits at lists.jboss.org Wed Nov 25 09:46:52 2009 Content-Type: multipart/mixed; boundary="===============4066311240692915445==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18066 - beanvalidation/tck/trunk. Date: Wed, 25 Nov 2009 09:46:52 -0500 Message-ID: <200911251446.nAPEkq2s007595@svn01.web.mwc.hst.phx2.redhat.com> --===============4066311240692915445== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-25 09:46:52 -0500 (Wed, 25 Nov 2009) New Revision: 18066 Modified: beanvalidation/tck/trunk/pom.xml Log: [maven-release-plugin] prepare for next development iteration Modified: beanvalidation/tck/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- beanvalidation/tck/trunk/pom.xml 2009-11-25 14:46:43 UTC (rev 18065) +++ beanvalidation/tck/trunk/pom.xml 2009-11-25 14:46:52 UTC (rev 18066) @@ -4,7 +4,7 @@ org.hibernate.jsr303.tck jsr303-tck jar - 1.0.3.GA + 1.0.4-SNAPSHOT JSR-303 TCK http://validator.hibernate.org = @@ -299,8 +299,8 @@ = - scm:svn:http://anonsvn.jboss.org/repos/hibernate/beanv= alidation/tck/tags/v1_0_3_GA - scm:svn:https://svn.jboss.org/repos/hibernate= /beanvalidation/tck/tags/v1_0_3_GA + scm:svn:http://anonsvn.jboss.org/repos/hibernate/beanv= alidation/tck/trunk + scm:svn:https://svn.jboss.org/repos/hibernate= /beanvalidation/tck/trunk = --===============4066311240692915445==-- From hibernate-commits at lists.jboss.org Wed Nov 25 10:24:25 2009 Content-Type: multipart/mixed; boundary="===============5241218342111565219==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18067 - core/branches/Branch_3_3_2_GA_CP/distribution/src/assembly. Date: Wed, 25 Nov 2009 10:24:24 -0500 Message-ID: <200911251524.nAPFOOuJ014630@svn01.web.mwc.hst.phx2.redhat.com> --===============5241218342111565219== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-25 10:24:24 -0500 (Wed, 25 Nov 2009) New Revision: 18067 Modified: core/branches/Branch_3_3_2_GA_CP/distribution/src/assembly/dist.xml Log: JBPAPP-3162 hibernate core distro does not contains asm = Modified: core/branches/Branch_3_3_2_GA_CP/distribution/src/assembly/dist.x= ml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3_2_GA_CP/distribution/src/assembly/dist.xml 200= 9-11-25 14:46:52 UTC (rev 18066) +++ core/branches/Branch_3_3_2_GA_CP/distribution/src/assembly/dist.xml 200= 9-11-25 15:24:24 UTC (rev 18067) @@ -140,6 +140,7 @@ lib/bytecode/cglib cglib:cglib + asm:asm = --===============5241218342111565219==-- From hibernate-commits at lists.jboss.org Wed Nov 25 11:32:05 2009 Content-Type: multipart/mixed; boundary="===============7081644143248077191==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18068 - in core/trunk/envers: src/main/java/org/hibernate/envers/configuration and 3 other directories. Date: Wed, 25 Nov 2009 11:32:05 -0500 Message-ID: <200911251632.nAPGW5wW030989@svn01.web.mwc.hst.phx2.redhat.com> --===============7081644143248077191== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: adamw Date: 2009-11-25 11:32:05 -0500 (Wed, 25 Nov 2009) New Revision: 18068 Added: core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/reven= tity/CustomRevEntityColumnMapping.java core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/re= ventity/CustomColumnMapping.java Modified: core/trunk/envers/pom.xml core/trunk/envers/src/main/java/org/hibernate/envers/configuration/Revis= ionInfoConfiguration.java core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metad= ata/AuditMetadataGenerator.java core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metad= ata/MetadataTools.java Log: HHH-4611: - handling the case when the revision number in the revision entity uses a = @Column(columnDefinition=3D): the sql-type is property is then set on the R= EV property of audit entities Modified: core/trunk/envers/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/pom.xml 2009-11-25 15:24:24 UTC (rev 18067) +++ core/trunk/envers/pom.xml 2009-11-25 16:32:05 UTC (rev 18068) @@ -106,6 +106,12 @@ test + mysql + mysql-connector-java + 5.1.10 + test + + cglib cglib test Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuratio= n/RevisionInfoConfiguration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/Revi= sionInfoConfiguration.java 2009-11-25 15:24:24 UTC (rev 18067) +++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/Revi= sionInfoConfiguration.java 2009-11-25 16:32:05 UTC (rev 18068) @@ -49,6 +49,8 @@ import org.hibernate.type.LongType; import org.hibernate.type.Type; = +import javax.persistence.Column; + /** * @author Adam Warski (adam at warski dot org) */ @@ -59,6 +61,7 @@ private Type revisionInfoTimestampType; = private String revisionPropType; + private Column revisionPropColumn; = public RevisionInfoConfiguration() { revisionInfoEntityName =3D "org.hibernate.envers.DefaultRevisionEn= tity"; @@ -90,10 +93,15 @@ = private Element generateRevisionInfoRelationMapping() { Document document =3D DocumentHelper.createDocument(); - Element rev_rel_mapping =3Ddocument.addElement("key-many-to-one"); + Element rev_rel_mapping =3D document.addElement("key-many-to-one"); rev_rel_mapping.addAttribute("type", revisionPropType); rev_rel_mapping.addAttribute("class", revisionInfoEntityName); = + if (revisionPropColumn !=3D null) { + // Putting a fake name to make Hibernate happy. It will be rep= laced later anyway. + MetadataTools.addColumn(rev_rel_mapping, "*" , null, 0, 0, rev= isionPropColumn.columnDefinition()); + } + return rev_rel_mapping; } = @@ -125,6 +133,11 @@ throw new MappingException("The field annotated with @= RevisionNumber must be of type " + "int, Integer, long or Long"); } + + // Getting the @Column definition of the revision number p= roperty, to later use that info to + // generate the same mapping for the relation from an audi= t table's revision number to the + // revision entity revision number. + revisionPropColumn =3D property.getAnnotation(Column.class= ); } = if (revisionTimestamp !=3D null) { Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuratio= n/metadata/AuditMetadataGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/AuditMetadataGenerator.java 2009-11-25 15:24:24 UTC (rev 18067) +++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/AuditMetadataGenerator.java 2009-11-25 16:32:05 UTC (rev 18068) @@ -40,7 +40,6 @@ import org.hibernate.envers.entities.mapper.SubclassPropertyMapper; import org.hibernate.envers.tools.StringTools; import org.hibernate.envers.tools.Triple; -import org.hibernate.envers.AuditTable; = import org.hibernate.MappingException; import org.hibernate.cfg.Configuration; @@ -90,8 +89,9 @@ void addRevisionInfoRelation(Element any_mapping) { Element rev_mapping =3D (Element) revisionInfoRelationMapping.clon= e(); rev_mapping.addAttribute("name", verEntCfg.getRevisionFieldName()); - MetadataTools.addColumn(rev_mapping, verEntCfg.getRevisionFieldNam= e(), null, 0, 0, null); = + MetadataTools.addOrModifyColumn(rev_mapping, verEntCfg.getRevision= FieldName()); + any_mapping.add(rev_mapping); } = Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuratio= n/metadata/MetadataTools.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/MetadataTools.java 2009-11-25 15:24:24 UTC (rev 18067) +++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/meta= data/MetadataTools.java 2009-11-25 16:32:05 UTC (rev 18068) @@ -68,6 +68,25 @@ return prop_mapping; } = + public static Element addOrModifyColumn(Element parent, String name) { + Element column_mapping =3D parent.element("column"); + + if (column_mapping =3D=3D null) { + return addColumn(parent, name, null, 0, 0, null); + } + + if (!StringTools.isEmpty(name)) { + Attribute nameAttribute =3D column_mapping.attribute("name"); + if (nameAttribute =3D=3D null) { + column_mapping.addAttribute("name", name); + } else { + nameAttribute.setValue(name); + } + } + + return column_mapping; + } + public static Element addColumn(Element parent, String name, Integer l= ength, Integer scale, Integer precision, String sqlType) { Element column_mapping =3D parent.addElement("column"); @@ -82,7 +101,7 @@ if (precision !=3D 0) { column_mapping.addAttribute("precision", Integer.toString(precision)); } - if (sqlType !=3D null) { + if (!StringTools.isEmpty(sqlType)) { column_mapping.addAttribute("sql-type", sqlType); } = Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/= reventity/CustomRevEntityColumnMapping.java (from rev 18023, core/trunk/env= ers/src/test/java/org/hibernate/envers/test/entities/reventity/CustomRevEnt= ity.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/reve= ntity/CustomRevEntityColumnMapping.java (rev 0) +++ core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/reve= ntity/CustomRevEntityColumnMapping.java 2009-11-25 16:32:05 UTC (rev 18068) @@ -0,0 +1,85 @@ +/* + * 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.entities.reventity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Column; + +import org.hibernate.envers.RevisionEntity; +import org.hibernate.envers.RevisionNumber; +import org.hibernate.envers.RevisionTimestamp; + +/** + * @author Adam Warski (adam at warski dot org) + */ +(a)Entity +(a)RevisionEntity +public class CustomRevEntityColumnMapping { + @Id + @GeneratedValue + @Column(columnDefinition =3D "int") + @RevisionNumber + private Long customId; + + @RevisionTimestamp + private long customTimestamp; + + public Long getCustomId() { + return customId; + } + + public void setCustomId(Long customId) { + this.customId =3D customId; + } + + public long getCustomTimestamp() { + return customTimestamp; + } + + public void setCustomTimestamp(long customTimestamp) { + this.customTimestamp =3D customTimestamp; + } + + @Override + public boolean equals(Object o) { + if (this =3D=3D o) return true; + if (o =3D=3D null || getClass() !=3D o.getClass()) return false; + + CustomRevEntityColumnMapping that =3D (CustomRevEntityColumnMappin= g) o; + + if (customTimestamp !=3D that.customTimestamp) return false; + if (customId !=3D null ? !customId.equals(that.customId) : that.cu= stomId !=3D null) return false; + + return true; + } + + @Override + public int hashCode() { + int result =3D customId !=3D null ? customId.hashCode() : 0; + result =3D 31 * result + (int) (customTimestamp ^ (customTimestamp= >>> 32)); + return result; + } +} \ No newline at end of file Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integrati= on/reventity/CustomColumnMapping.java (from rev 18023, core/trunk/envers/sr= c/test/java/org/hibernate/envers/test/integration/reventity/Custom.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/r= eventity/CustomColumnMapping.java (rev 0) +++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/r= eventity/CustomColumnMapping.java 2009-11-25 16:32:05 UTC (rev 18068) @@ -0,0 +1,137 @@ +/* + * 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.reventity; + +import java.util.Arrays; +import java.util.Date; +import javax.persistence.EntityManager; + +import org.hibernate.envers.AuditReader; +import org.hibernate.envers.exception.RevisionDoesNotExistException; +import org.hibernate.envers.test.AbstractEntityTest; +import org.hibernate.envers.test.entities.StrTestEntity; +import org.hibernate.envers.test.entities.reventity.CustomRevEntityColumnM= apping; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import org.hibernate.ejb.Ejb3Configuration; + +/** + * Test which checks if auditing when the revision number in the revision = entity has a @Column annotation with + * a columnDefinition specified works. + * @author Adam Warski (adam at warski dot org) + */ +public class CustomColumnMapping extends AbstractEntityTest { + private Integer id; + private long timestamp1; + private long timestamp2; + private long timestamp3; + + public void configure(Ejb3Configuration cfg) { + cfg.addAnnotatedClass(StrTestEntity.class); + cfg.addAnnotatedClass(CustomRevEntityColumnMapping.class); + } + + @BeforeClass(dependsOnMethods =3D "init") + public void initData() throws InterruptedException { + timestamp1 =3D System.currentTimeMillis(); + + Thread.sleep(100); + + // Revision 1 + EntityManager em =3D getEntityManager(); + em.getTransaction().begin(); + StrTestEntity te =3D new StrTestEntity("x"); + em.persist(te); + id =3D te.getId(); + em.getTransaction().commit(); + + timestamp2 =3D System.currentTimeMillis(); + + Thread.sleep(100); + + // Revision 2 + em.getTransaction().begin(); + te =3D em.find(StrTestEntity.class, id); + te.setStr("y"); + em.getTransaction().commit(); + + timestamp3 =3D System.currentTimeMillis(); + } + + @Test(expectedExceptions =3D RevisionDoesNotExistException.class) + public void testTimestamps1() { + getAuditReader().getRevisionNumberForDate(new Date(timestamp1)); + } + + @Test + public void testTimestamps() { + assert getAuditReader().getRevisionNumberForDate(new Date(timestam= p2)).intValue() =3D=3D 1; + assert getAuditReader().getRevisionNumberForDate(new Date(timestam= p3)).intValue() =3D=3D 2; + } + + @Test + public void testDatesForRevisions() { + AuditReader vr =3D getAuditReader(); + assert vr.getRevisionNumberForDate(vr.getRevisionDate(1l)).intValu= e() =3D=3D 1; + assert vr.getRevisionNumberForDate(vr.getRevisionDate(2l)).intValu= e() =3D=3D 2; + } + + @Test + public void testRevisionsForDates() { + AuditReader vr =3D getAuditReader(); + + assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(tim= estamp2))).getTime() <=3D timestamp2; + assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(tim= estamp2)).longValue()+1l).getTime() > timestamp2; + + assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(tim= estamp3))).getTime() <=3D timestamp3; + } + + @Test + public void testFindRevision() { + AuditReader vr =3D getAuditReader(); + + long rev1Timestamp =3D vr.findRevision(CustomRevEntityColumnMappin= g.class, 1l).getCustomTimestamp(); + assert rev1Timestamp > timestamp1; + assert rev1Timestamp <=3D timestamp2; + + long rev2Timestamp =3D vr.findRevision(CustomRevEntityColumnMappin= g.class, 2l).getCustomTimestamp(); + assert rev2Timestamp > timestamp2; + assert rev2Timestamp <=3D timestamp3; + } + + @Test + public void testRevisionsCounts() { + assert Arrays.asList(1l, 2l).equals(getAuditReader().getRevisions(= StrTestEntity.class, id)); + } + + @Test + public void testHistoryOfId1() { + StrTestEntity ver1 =3D new StrTestEntity("x", id); + StrTestEntity ver2 =3D new StrTestEntity("y", id); + + assert getAuditReader().find(StrTestEntity.class, id, 1l).equals(v= er1); + assert getAuditReader().find(StrTestEntity.class, id, 2l).equals(v= er2); + } +} \ No newline at end of file --===============7081644143248077191==-- From hibernate-commits at lists.jboss.org Wed Nov 25 11:44:59 2009 Content-Type: multipart/mixed; boundary="===============1580873812348972276==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18069 - in core/branches/envers-hibernate-3.3: src/main/java/org/hibernate/envers/configuration and 3 other directories. Date: Wed, 25 Nov 2009 11:44:59 -0500 Message-ID: <200911251644.nAPGixBA001040@svn01.web.mwc.hst.phx2.redhat.com> --===============1580873812348972276== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: adamw Date: 2009-11-25 11:44:58 -0500 (Wed, 25 Nov 2009) New Revision: 18069 Added: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/te= st/entities/reventity/CustomRevEntityColumnMapping.java core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/te= st/integration/reventity/CustomColumnMapping.java Modified: core/branches/envers-hibernate-3.3/pom.xml core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/co= nfiguration/RevisionInfoConfiguration.java core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/co= nfiguration/metadata/AuditMetadataGenerator.java core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/co= nfiguration/metadata/MetadataTools.java Log: svn merge -r 18059:18068 https://svn.jboss.org/repos/hibernate/core/trunk/e= nvers . Modified: core/branches/envers-hibernate-3.3/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/envers-hibernate-3.3/pom.xml 2009-11-25 16:32:05 UTC (rev= 18068) +++ core/branches/envers-hibernate-3.3/pom.xml 2009-11-25 16:44:58 UTC (rev= 18069) @@ -108,6 +108,12 @@ test + mysql + mysql-connector-java + 5.1.10 + test + + cglib cglib 2.2 Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/en= vers/configuration/RevisionInfoConfiguration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/RevisionInfoConfiguration.java 2009-11-25 16:32:05 UTC (rev 18= 068) +++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/RevisionInfoConfiguration.java 2009-11-25 16:44:58 UTC (rev 18= 069) @@ -49,6 +49,8 @@ import org.hibernate.type.LongType; import org.hibernate.type.Type; = +import javax.persistence.Column; + /** * @author Adam Warski (adam at warski dot org) */ @@ -59,6 +61,7 @@ private Type revisionInfoTimestampType; = private String revisionPropType; + private Column revisionPropColumn; = public RevisionInfoConfiguration() { revisionInfoEntityName =3D "org.hibernate.envers.DefaultRevisionEn= tity"; @@ -90,10 +93,15 @@ = private Element generateRevisionInfoRelationMapping() { Document document =3D DocumentHelper.createDocument(); - Element rev_rel_mapping =3Ddocument.addElement("key-many-to-one"); + Element rev_rel_mapping =3D document.addElement("key-many-to-one"); rev_rel_mapping.addAttribute("type", revisionPropType); rev_rel_mapping.addAttribute("class", revisionInfoEntityName); = + if (revisionPropColumn !=3D null) { + // Putting a fake name to make Hibernate happy. It will be rep= laced later anyway. + MetadataTools.addColumn(rev_rel_mapping, "*" , null, 0, 0, rev= isionPropColumn.columnDefinition()); + } + return rev_rel_mapping; } = @@ -125,6 +133,11 @@ throw new MappingException("The field annotated with @= RevisionNumber must be of type " + "int, Integer, long or Long"); } + + // Getting the @Column definition of the revision number p= roperty, to later use that info to + // generate the same mapping for the relation from an audi= t table's revision number to the + // revision entity revision number. + revisionPropColumn =3D property.getAnnotation(Column.class= ); } = if (revisionTimestamp !=3D null) { Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/en= vers/configuration/metadata/AuditMetadataGenerator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/metadata/AuditMetadataGenerator.java 2009-11-25 16:32:05 UTC (= rev 18068) +++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/metadata/AuditMetadataGenerator.java 2009-11-25 16:44:58 UTC (= rev 18069) @@ -40,7 +40,6 @@ import org.hibernate.envers.entities.mapper.SubclassPropertyMapper; import org.hibernate.envers.tools.StringTools; import org.hibernate.envers.tools.Triple; -import org.hibernate.envers.AuditTable; = import org.hibernate.MappingException; import org.hibernate.cfg.Configuration; @@ -90,8 +89,9 @@ void addRevisionInfoRelation(Element any_mapping) { Element rev_mapping =3D (Element) revisionInfoRelationMapping.clon= e(); rev_mapping.addAttribute("name", verEntCfg.getRevisionFieldName()); - MetadataTools.addColumn(rev_mapping, verEntCfg.getRevisionFieldNam= e(), null, 0, 0, null); = + MetadataTools.addOrModifyColumn(rev_mapping, verEntCfg.getRevision= FieldName()); + any_mapping.add(rev_mapping); } = Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/en= vers/configuration/metadata/MetadataTools.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/metadata/MetadataTools.java 2009-11-25 16:32:05 UTC (rev 18068) +++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/c= onfiguration/metadata/MetadataTools.java 2009-11-25 16:44:58 UTC (rev 18069) @@ -68,6 +68,25 @@ return prop_mapping; } = + public static Element addOrModifyColumn(Element parent, String name) { + Element column_mapping =3D parent.element("column"); + + if (column_mapping =3D=3D null) { + return addColumn(parent, name, null, 0, 0, null); + } + + if (!StringTools.isEmpty(name)) { + Attribute nameAttribute =3D column_mapping.attribute("name"); + if (nameAttribute =3D=3D null) { + column_mapping.addAttribute("name", name); + } else { + nameAttribute.setValue(name); + } + } + + return column_mapping; + } + public static Element addColumn(Element parent, String name, Integer l= ength, Integer scale, Integer precision, String sqlType) { Element column_mapping =3D parent.addElement("column"); @@ -82,7 +101,7 @@ if (precision !=3D 0) { column_mapping.addAttribute("precision", Integer.toString(precision)); } - if (sqlType !=3D null) { + if (!StringTools.isEmpty(sqlType)) { column_mapping.addAttribute("sql-type", sqlType); } = Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/enve= rs/test/entities/reventity/CustomRevEntityColumnMapping.java (from rev 1806= 8, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/reven= tity/CustomRevEntityColumnMapping.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/t= est/entities/reventity/CustomRevEntityColumnMapping.java = (rev 0) +++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/t= est/entities/reventity/CustomRevEntityColumnMapping.java 2009-11-25 16:44:5= 8 UTC (rev 18069) @@ -0,0 +1,85 @@ +/* + * 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.entities.reventity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Column; + +import org.hibernate.envers.RevisionEntity; +import org.hibernate.envers.RevisionNumber; +import org.hibernate.envers.RevisionTimestamp; + +/** + * @author Adam Warski (adam at warski dot org) + */ +(a)Entity +(a)RevisionEntity +public class CustomRevEntityColumnMapping { + @Id + @GeneratedValue + @Column(columnDefinition =3D "int") + @RevisionNumber + private Long customId; + + @RevisionTimestamp + private long customTimestamp; + + public Long getCustomId() { + return customId; + } + + public void setCustomId(Long customId) { + this.customId =3D customId; + } + + public long getCustomTimestamp() { + return customTimestamp; + } + + public void setCustomTimestamp(long customTimestamp) { + this.customTimestamp =3D customTimestamp; + } + + @Override + public boolean equals(Object o) { + if (this =3D=3D o) return true; + if (o =3D=3D null || getClass() !=3D o.getClass()) return false; + + CustomRevEntityColumnMapping that =3D (CustomRevEntityColumnMappin= g) o; + + if (customTimestamp !=3D that.customTimestamp) return false; + if (customId !=3D null ? !customId.equals(that.customId) : that.cu= stomId !=3D null) return false; + + return true; + } + + @Override + public int hashCode() { + int result =3D customId !=3D null ? customId.hashCode() : 0; + result =3D 31 * result + (int) (customTimestamp ^ (customTimestamp= >>> 32)); + return result; + } +} \ No newline at end of file Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/enve= rs/test/integration/reventity/CustomColumnMapping.java (from rev 18068, cor= e/trunk/envers/src/test/java/org/hibernate/envers/test/integration/reventit= y/CustomColumnMapping.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/t= est/integration/reventity/CustomColumnMapping.java = (rev 0) +++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/t= est/integration/reventity/CustomColumnMapping.java 2009-11-25 16:44:58 UTC = (rev 18069) @@ -0,0 +1,137 @@ +/* + * 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, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.reventity; + +import java.util.Arrays; +import java.util.Date; +import javax.persistence.EntityManager; + +import org.hibernate.envers.AuditReader; +import org.hibernate.envers.exception.RevisionDoesNotExistException; +import org.hibernate.envers.test.AbstractEntityTest; +import org.hibernate.envers.test.entities.StrTestEntity; +import org.hibernate.envers.test.entities.reventity.CustomRevEntityColumnM= apping; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import org.hibernate.ejb.Ejb3Configuration; + +/** + * Test which checks if auditing when the revision number in the revision = entity has a @Column annotation with + * a columnDefinition specified works. + * @author Adam Warski (adam at warski dot org) + */ +public class CustomColumnMapping extends AbstractEntityTest { + private Integer id; + private long timestamp1; + private long timestamp2; + private long timestamp3; + + public void configure(Ejb3Configuration cfg) { + cfg.addAnnotatedClass(StrTestEntity.class); + cfg.addAnnotatedClass(CustomRevEntityColumnMapping.class); + } + + @BeforeClass(dependsOnMethods =3D "init") + public void initData() throws InterruptedException { + timestamp1 =3D System.currentTimeMillis(); + + Thread.sleep(100); + + // Revision 1 + EntityManager em =3D getEntityManager(); + em.getTransaction().begin(); + StrTestEntity te =3D new StrTestEntity("x"); + em.persist(te); + id =3D te.getId(); + em.getTransaction().commit(); + + timestamp2 =3D System.currentTimeMillis(); + + Thread.sleep(100); + + // Revision 2 + em.getTransaction().begin(); + te =3D em.find(StrTestEntity.class, id); + te.setStr("y"); + em.getTransaction().commit(); + + timestamp3 =3D System.currentTimeMillis(); + } + + @Test(expectedExceptions =3D RevisionDoesNotExistException.class) + public void testTimestamps1() { + getAuditReader().getRevisionNumberForDate(new Date(timestamp1)); + } + + @Test + public void testTimestamps() { + assert getAuditReader().getRevisionNumberForDate(new Date(timestam= p2)).intValue() =3D=3D 1; + assert getAuditReader().getRevisionNumberForDate(new Date(timestam= p3)).intValue() =3D=3D 2; + } + + @Test + public void testDatesForRevisions() { + AuditReader vr =3D getAuditReader(); + assert vr.getRevisionNumberForDate(vr.getRevisionDate(1l)).intValu= e() =3D=3D 1; + assert vr.getRevisionNumberForDate(vr.getRevisionDate(2l)).intValu= e() =3D=3D 2; + } + + @Test + public void testRevisionsForDates() { + AuditReader vr =3D getAuditReader(); + + assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(tim= estamp2))).getTime() <=3D timestamp2; + assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(tim= estamp2)).longValue()+1l).getTime() > timestamp2; + + assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(tim= estamp3))).getTime() <=3D timestamp3; + } + + @Test + public void testFindRevision() { + AuditReader vr =3D getAuditReader(); + + long rev1Timestamp =3D vr.findRevision(CustomRevEntityColumnMappin= g.class, 1l).getCustomTimestamp(); + assert rev1Timestamp > timestamp1; + assert rev1Timestamp <=3D timestamp2; + + long rev2Timestamp =3D vr.findRevision(CustomRevEntityColumnMappin= g.class, 2l).getCustomTimestamp(); + assert rev2Timestamp > timestamp2; + assert rev2Timestamp <=3D timestamp3; + } + + @Test + public void testRevisionsCounts() { + assert Arrays.asList(1l, 2l).equals(getAuditReader().getRevisions(= StrTestEntity.class, id)); + } + + @Test + public void testHistoryOfId1() { + StrTestEntity ver1 =3D new StrTestEntity("x", id); + StrTestEntity ver2 =3D new StrTestEntity("y", id); + + assert getAuditReader().find(StrTestEntity.class, id, 1l).equals(v= er1); + assert getAuditReader().find(StrTestEntity.class, id, 2l).equals(v= er2); + } +} \ No newline at end of file --===============1580873812348972276==-- From hibernate-commits at lists.jboss.org Thu Nov 26 02:48:17 2009 Content-Type: multipart/mixed; boundary="===============4545985867592576931==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18070 - search/trunk/src/main/java/org/hibernate/search/bridge/builtin. Date: Thu, 26 Nov 2009 02:48:17 -0500 Message-ID: <200911260748.nAQ7mHiM016833@svn01.web.mwc.hst.phx2.redhat.com> --===============4545985867592576931== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: sannegrinovero Date: 2009-11-26 02:48:17 -0500 (Thu, 26 Nov 2009) New Revision: 18070 Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CalendarB= ridge.java search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateBridg= e.java Log: cosmetic changes in Calendar and Date Bridges, and SearchException vs Hiber= nateException. Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/Ca= lendarBridge.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/Calendar= Bridge.java 2009-11-25 16:44:58 UTC (rev 18069) +++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/Calendar= Bridge.java 2009-11-26 07:48:17 UTC (rev 18070) @@ -1,11 +1,34 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.bridge.builtin; = +import org.hibernate.search.SearchException; import org.hibernate.search.annotations.Resolution; import org.hibernate.search.bridge.ParameterizedBridge; import org.hibernate.search.bridge.TwoWayStringBridge; import org.hibernate.util.StringHelper; -import org.hibernate.AssertionFailure; -import org.hibernate.HibernateException; import org.apache.lucene.document.DateTools; = import java.util.Date; @@ -14,7 +37,6 @@ import java.util.Map; import java.text.ParseException; = - public class CalendarBridge implements TwoWayStringBridge, ParameterizedBr= idge { = private DateTools.Resolution resolution; @@ -26,7 +48,6 @@ public static final TwoWayStringBridge CALENDAR_SECOND =3D new CalendarBr= idge( Resolution.SECOND ); public static final TwoWayStringBridge CALENDAR_MILLISECOND =3D new Calen= darBridge( Resolution.MILLISECOND ); = - public CalendarBridge() { } = @@ -46,19 +67,17 @@ resolution =3D DateResolutionUtil.getLuceneResolution( hibResolution ); } = - = - = public Object stringToObject(String stringValue) { - if ( StringHelper.isEmpty( stringValue )) { + if ( StringHelper.isEmpty( stringValue ) ) { return null; } try { - Date date =3D DateTools.stringToDate(stringValue); - Calendar calendar =3D Calendar.getInstance(); - calendar.setTime(date); + Date date =3D DateTools.stringToDate( stringValue ); + Calendar calendar =3D Calendar.getInstance(); + calendar.setTime( date ); return calendar; } catch (ParseException e) { - throw new HibernateException( "Unable to parse into calendar: = " + stringValue, e ); + throw new SearchException( "Unable to parse into calendar: " += stringValue, e ); } } = Property changes on: search/trunk/src/main/java/org/hibernate/search/bridge= /builtin/CalendarBridge.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/Da= teBridge.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateBrid= ge.java 2009-11-25 16:44:58 UTC (rev 18069) +++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/DateBrid= ge.java 2009-11-26 07:48:17 UTC (rev 18070) @@ -30,8 +30,7 @@ import java.util.Map; = import org.apache.lucene.document.DateTools; -import org.hibernate.AssertionFailure; -import org.hibernate.HibernateException; +import org.hibernate.search.SearchException; import org.hibernate.search.bridge.ParameterizedBridge; import org.hibernate.search.annotations.Resolution; import org.hibernate.search.bridge.TwoWayStringBridge; @@ -78,7 +77,7 @@ return DateTools.stringToDate( stringValue ); } catch (ParseException e) { - throw new HibernateException( "Unable to parse into date: " + stringVal= ue, e ); + throw new SearchException( "Unable to parse into date: " + stringValue,= e ); } } = @@ -97,8 +96,7 @@ else { hibResolution =3D (Resolution) resolution; } - this.resolution =3D DateResolutionUtil.getLuceneResolution(hibResolution= ); + this.resolution =3D DateResolutionUtil.getLuceneResolution( hibResolutio= n ); } - = } --===============4545985867592576931==-- From hibernate-commits at lists.jboss.org Thu Nov 26 03:02:24 2009 Content-Type: multipart/mixed; boundary="===============3545611094720788061==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18071 - in search/trunk/src: test/java/org/hibernate/search/test/configuration and 1 other directories. Date: Thu, 26 Nov 2009 03:02:24 -0500 Message-ID: <200911260802.nAQ82OfJ019305@svn01.web.mwc.hst.phx2.redhat.com> --===============3545611094720788061== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: sannegrinovero Date: 2009-11-26 03:02:23 -0500 (Thu, 26 Nov 2009) New Revision: 18071 Modified: search/trunk/src/main/java/org/hibernate/search/cfg/CalendarBridgeMappin= g.java search/trunk/src/main/java/org/hibernate/search/cfg/ContainedInMapping.j= ava search/trunk/src/main/java/org/hibernate/search/cfg/DateBridgeMapping.ja= va search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilterDefMap= ping.java search/trunk/src/main/java/org/hibernate/search/cfg/IndexEmbeddedMapping= .java search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMapping.ja= va search/trunk/src/test/java/org/hibernate/search/test/configuration/Addre= ss.java search/trunk/src/test/java/org/hibernate/search/test/configuration/BlogE= ntry.java search/trunk/src/test/java/org/hibernate/search/test/configuration/Item.= java search/trunk/src/test/java/org/hibernate/search/test/configuration/Produ= ctCatalog.java search/trunk/src/test/java/org/hibernate/search/test/configuration/Provi= dedIdEntry.java search/trunk/src/test/java/org/hibernate/search/test/configuration/Secur= ityFilterFactory.java search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Manua= lTransactionContext.java search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Provi= dedIdTest.java search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Stand= aloneConf.java Log: missing copyrights, unused imports, SVN properties = Modified: search/trunk/src/main/java/org/hibernate/search/cfg/CalendarBridg= eMapping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/CalendarBridgeMappi= ng.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/main/java/org/hibernate/search/cfg/CalendarBridgeMappi= ng.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.cfg; = import java.lang.annotation.ElementType; Property changes on: search/trunk/src/main/java/org/hibernate/search/cfg/Ca= lendarBridgeMapping.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/main/java/org/hibernate/search/cfg/ContainedInMa= pping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/ContainedInMapping.= java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/main/java/org/hibernate/search/cfg/ContainedInMapping.= java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.cfg; = import java.lang.annotation.ElementType; Property changes on: search/trunk/src/main/java/org/hibernate/search/cfg/Co= ntainedInMapping.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/main/java/org/hibernate/search/cfg/DateBridgeMap= ping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/DateBridgeMapping.j= ava 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/main/java/org/hibernate/search/cfg/DateBridgeMapping.j= ava 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.cfg; = import java.lang.annotation.ElementType; Property changes on: search/trunk/src/main/java/org/hibernate/search/cfg/Da= teBridgeMapping.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilte= rDefMapping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilterDefMa= pping.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilterDefMa= pping.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.cfg; = import java.lang.annotation.ElementType; Property changes on: search/trunk/src/main/java/org/hibernate/search/cfg/Fu= llTextFilterDefMapping.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/main/java/org/hibernate/search/cfg/IndexEmbedded= Mapping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/IndexEmbeddedMappin= g.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/main/java/org/hibernate/search/cfg/IndexEmbeddedMappin= g.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.cfg; = import java.lang.annotation.ElementType; @@ -12,7 +36,6 @@ private final Map indexEmbedded; private EntityDescriptor entity; private PropertyDescriptor property; - = public IndexEmbeddedMapping(SearchMapping mapping, PropertyDescriptor pro= perty, EntityDescriptor entity) { this.mapping =3D mapping; Property changes on: search/trunk/src/main/java/org/hibernate/search/cfg/In= dexEmbeddedMapping.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMappin= g.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java= 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java= 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.cfg; = import java.lang.annotation.ElementType; Property changes on: search/trunk/src/main/java/org/hibernate/search/cfg/In= dexedMapping.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMap= ping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMapping.j= ava 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMapping.j= ava 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.cfg; = import java.lang.annotation.ElementType; Property changes on: search/trunk/src/main/java/org/hibernate/search/cfg/Pr= ovidedIdMapping.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/test/java/org/hibernate/search/test/configuratio= n/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/configuration/Addr= ess.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Addr= ess.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -32,8 +32,6 @@ import javax.persistence.Id; import javax.persistence.ManyToOne; = -import org.hibernate.search.test.embedded.nested.Place; - /** * @author Emmanuel Bernard */ Modified: search/trunk/src/test/java/org/hibernate/search/test/configuratio= n/BlogEntry.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/configuration/Blog= Entry.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Blog= Entry.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.test.configuration; = import java.util.Date; Property changes on: search/trunk/src/test/java/org/hibernate/search/test/c= onfiguration/BlogEntry.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/test/java/org/hibernate/search/test/configuratio= n/Item.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/configuration/Item= .java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Item= .java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.test.configuration; = import javax.persistence.CascadeType; Property changes on: search/trunk/src/test/java/org/hibernate/search/test/c= onfiguration/Item.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/test/java/org/hibernate/search/test/configuratio= n/ProductCatalog.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/configuration/Prod= uctCatalog.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Prod= uctCatalog.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.test.configuration; = import java.util.ArrayList; Property changes on: search/trunk/src/test/java/org/hibernate/search/test/c= onfiguration/ProductCatalog.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/test/java/org/hibernate/search/test/configuratio= n/ProvidedIdEntry.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/configuration/Prov= idedIdEntry.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Prov= idedIdEntry.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.test.configuration; = import java.io.Serializable; Property changes on: search/trunk/src/test/java/org/hibernate/search/test/c= onfiguration/ProvidedIdEntry.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/test/java/org/hibernate/search/test/configuratio= n/SecurityFilterFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/configuration/Secu= rityFilterFactory.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Secu= rityFilterFactory.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.test.configuration; = import java.io.IOException; @@ -8,7 +32,6 @@ import org.apache.lucene.search.CachingWrapperFilter; import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.Filter; -import org.apache.lucene.search.QueryWrapperFilter; import org.apache.lucene.util.OpenBitSet; import org.hibernate.search.annotations.Factory; import org.hibernate.search.annotations.Key; Property changes on: search/trunk/src/test/java/org/hibernate/search/test/c= onfiguration/SecurityFilterFactory.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/test/java/org/hibernate/search/test/id/providedI= d/ManualTransactionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Manu= alTransactionContext.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Manu= alTransactionContext.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.test.id.providedId; = import java.util.List; Property changes on: search/trunk/src/test/java/org/hibernate/search/test/i= d/providedId/ManualTransactionContext.java ___________________________________________________________________ Name: svn:keywords + Id Modified: search/trunk/src/test/java/org/hibernate/search/test/id/providedI= d/ProvidedIdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Prov= idedIdTest.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Prov= idedIdTest.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -29,19 +29,11 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.TopDocs; - -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.search.FullTextSession; -import org.hibernate.search.Search; -import org.hibernate.search.SearchFactory; -import org.hibernate.search.engine.SearchFactoryImplementor; import org.hibernate.search.backend.Work; import org.hibernate.search.backend.WorkType; -import org.hibernate.search.cfg.SearchConfiguration; +import org.hibernate.search.engine.SearchFactoryImplementor; import org.hibernate.search.impl.SearchFactoryImpl; import org.hibernate.search.store.DirectoryProvider; -import org.hibernate.search.test.SearchTestCase; = /** * @author Navin Surtani @@ -89,5 +81,4 @@ searcher.close(); } = - } Modified: search/trunk/src/test/java/org/hibernate/search/test/id/providedI= d/StandaloneConf.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Stan= daloneConf.java 2009-11-26 07:48:17 UTC (rev 18070) +++ search/trunk/src/test/java/org/hibernate/search/test/id/providedId/Stan= daloneConf.java 2009-11-26 08:02:23 UTC (rev 18071) @@ -1,3 +1,27 @@ +/* $Id$ + * = + * Hibernate, Relational Persistence for Idiomatic Java + * = + * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc. + * = + * This copyrighted material is made available to anyone wishing to use, m= odify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Founda= tion. + * = + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY + * 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.search.test.id.providedId; = import java.util.Iterator; @@ -2,4 +26,2 @@ import java.util.Properties; -import java.util.List; -import java.util.ArrayList; import java.util.Map; Property changes on: search/trunk/src/test/java/org/hibernate/search/test/i= d/providedId/StandaloneConf.java ___________________________________________________________________ Name: svn:keywords + Id --===============3545611094720788061==-- From hibernate-commits at lists.jboss.org Thu Nov 26 15:28:46 2009 Content-Type: multipart/mixed; boundary="===============8180538922551636578==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18072 - in core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate: bytecode and 16 other directories. Date: Thu, 26 Nov 2009 15:28:46 -0500 Message-ID: <200911262028.nAQKSkXi005811@svn01.web.mwc.hst.phx2.redhat.com> --===============8180538922551636578== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-26 15:28:45 -0500 (Thu, 26 Nov 2009) New Revision: 18072 Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/CallbackException.ja= va core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/SessionFactory.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/cglib/Acces= sOptimizerAdapter.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/cglib/Insta= ntiationOptimizerAdapter.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/javassist/A= ccessOptimizerAdapter.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/javassist/I= nstantiationOptimizerAdapter.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/package.html core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/util/ByteCo= deHelper.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/OSCacheProvide= r.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/OptimisticTree= CacheProvider.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/TreeCacheProvi= der.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/Connectio= nProvider.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/Connectio= nProviderFactory.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Criterion.= java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Restrictio= ns.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Subqueries= .java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracle9Diale= ct.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracle9iDial= ect.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/loading/Entit= yLoadContext.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/loading/LoadC= ontexts.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/event/LoadEventListe= ner.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/ExceptionU= tils.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/SQLExcepti= onConverter.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/SQLExcepti= onConverterFactory.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/util/Literal= Processor.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/loader/DefaultEntity= Aliases.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/mapping/ForeignKey.j= ava core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/persister/entity/Que= ryable.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/sql/InFragment.java core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/Type.java Log: JBPAPP-3169 update hibernate core javadoc Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/CallbackExcep= tion.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/CallbackException.j= ava 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/CallbackException.j= ava 2009-11-26 20:28:45 UTC (rev 18072) @@ -6,8 +6,8 @@ * Should be thrown by persistent objects from Lifecycle * or Interceptor callbacks. * - * @see Lifecycle - * @see Interceptor + * @see org.hibernate.classic.Lifecycle + * @see org.hibernate.Interceptor * @author Gavin King */ = Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/SessionFactor= y.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/SessionFactory.java= 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/SessionFactory.java= 2009-11-26 20:28:45 UTC (rev 18072) @@ -14,12 +14,12 @@ import org.hibernate.engine.FilterDefinition; = /** - * Creates Sessions. Usually an application has a single Sess= ionFactory. + * Creates Sessions. Usually an application has a single Sess= ionFactory. * Threads servicing client requests obtain Sessions from the fac= tory.
    *
    * Implementors must be threadsafe.
    *
    - * SessionFactorys are immutable. The behaviour of a SessionF= actory is + * SessionFactorys are immutable. The behavior of a SessionFa= ctory is * controlled by properties supplied at configuration time. These properti= es are defined * on Environment. * Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/cgli= b/AccessOptimizerAdapter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/cglib/Acce= ssOptimizerAdapter.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/cglib/Acce= ssOptimizerAdapter.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -13,7 +13,7 @@ = /** * The {@link ReflectionOptimizer.AccessOptimizer} implementation for CGLIB - * which simply acts as an adpater to the {@link BulkBean} class. + * which simply acts as an adapter to the {@link BulkBean} class. * * @author Steve Ebersole */ Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/cgli= b/InstantiationOptimizerAdapter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/cglib/Inst= antiationOptimizerAdapter.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/cglib/Inst= antiationOptimizerAdapter.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -11,7 +11,7 @@ = /** * The {@link ReflectionOptimizer.InstantiationOptimizer} implementation f= or CGLIB - * which simply acts as an adpater to the {@link FastClass} class. + * which simply acts as an adapter to the {@link FastClass} class. * * @author Steve Ebersole */ Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/java= ssist/AccessOptimizerAdapter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/javassist/= AccessOptimizerAdapter.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/javassist/= AccessOptimizerAdapter.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -6,8 +6,8 @@ import java.io.Serializable; = /** - * The {@link ReflectionOptimizer.AccessOptimizer} implementation for Java= ssist - * which simply acts as an adpater to the {@link BulkAccessor} class. + * The {@link ReflectionOptimizer#AccessOptimizer} implementation for Java= ssist + * which simply acts as an adapter to the {@link BulkAccessor} class. * * @author Steve Ebersole */ Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/java= ssist/InstantiationOptimizerAdapter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/javassist/= InstantiationOptimizerAdapter.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/javassist/= InstantiationOptimizerAdapter.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -6,8 +6,8 @@ import java.io.Serializable; = /** - * The {@link ReflectionOptimizer.InstantiationOptimizer} implementation f= or Javassist - * which simply acts as an adpater to the {@link FastClass} class. + * The {@link ReflectionOptimizer#InstantiationOptimizer} implementation f= or Javassist + * which simply acts as an adapter to the {@link FastClass} class. * * @author Steve Ebersole */ Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/pack= age.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/package.ht= ml 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/package.ht= ml 2009-11-26 20:28:45 UTC (rev 18072) @@ -24,7 +24,7 @@ Currently, both CGLIB and Javassist are supported out-of-the-box.

    - Note that for field-level interception, simply plugging in a new {@link= BytecodeProvider} + Note that for field-level interception, simply plugging in a new {@link= org.hibernate.bytecode.BytecodeProvider BytecodeProvider} is not enough for Hibernate to be able to recognize new providers. You= would additionally need to make appropriate code changes to the {@link org.hibernate.inter= cept.Helper} class. This is because the detection of these enhanced classes is need= ed in a static Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/util= /ByteCodeHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/util/ByteC= odeHelper.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/util/ByteC= odeHelper.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -23,7 +23,7 @@ * The stream is closed within this method! * * @param inputStream - * @return + * @return class byte array * @throws IOException */ public static byte[] readByteCode(InputStream inputStream) throws IOExcep= tion { Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/OSCache= Provider.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/OSCacheProvid= er.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/OSCacheProvid= er.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -39,7 +39,7 @@ * * @param region * @param properties - * @return + * @return cache instance * @throws CacheException */ public Cache buildCache(String region, Properties properties) throws Cach= eException { Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/Optimis= ticTreeCacheProvider.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/OptimisticTre= eCacheProvider.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/OptimisticTre= eCacheProvider.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -26,7 +26,7 @@ public class OptimisticTreeCacheProvider implements CacheProvider { = /** - * @deprecated use {@link Environment.CACHE_PROVIDER_CONFIG} + * @deprecated use {@link Environment#CACHE_PROVIDER_CONFIG} */ public static final String CONFIG_RESOURCE =3D "hibernate.cache.opt_tree_= cache.config"; public static final String DEFAULT_CONFIG =3D "treecache.xml"; Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/TreeCac= heProvider.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/TreeCacheProv= ider.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/cache/TreeCacheProv= ider.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -20,7 +20,7 @@ public class TreeCacheProvider implements CacheProvider { = /** - * @deprecated use {@link org.hibernate.cfg.Environment.CACHE_PROVIDER_CO= NFIG} + * @deprecated use {@link org.hibernate.cfg.Environment#CACHE_PROVIDER_CO= NFIG} */ public static final String CONFIG_RESOURCE =3D "hibernate.cache.tree_cach= e.config"; public static final String DEFAULT_CONFIG =3D "treecache.xml"; Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/Co= nnectionProvider.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/Connecti= onProvider.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/Connecti= onProvider.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -50,7 +50,7 @@ * Does this connection provider support aggressive release of JDBC * connections and re-acquistion of those connections (if need be) later? *

    - * This is used in conjunction with {@link org.hibernate.cfg.Environment.= RELEASE_CONNECTIONS} + * This is used in conjunction with {@link org.hibernate.cfg.Environment#= RELEASE_CONNECTIONS} * to aggressively release JDBC connections. However, the configured Con= nectionProvider * must support re-acquisition of the same underlying connection for that= semantic to work. *

    Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/Co= nnectionProviderFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/Connecti= onProviderFactory.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/Connecti= onProviderFactory.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -60,7 +60,7 @@ * Instantiate a ConnectionProvider using given properties. * Method newConnectionProvider. * @param properties hibernate SessionFactory properties - * @Param connectionProviderInjectionData object to be injected in the co= nenction provided + * @param connectionProviderInjectionData object to be injected in the co= nenction provided * @return ConnectionProvider * @throws HibernateException */ Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Cri= terion.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Criterion= .java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Criterion= .java 2009-11-26 20:28:45 UTC (rev 18072) @@ -23,8 +23,8 @@ = /** * Render the SQL fragment + * @param criteria * @param criteriaQuery - * @param alias * @return String * @throws HibernateException */ Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Res= trictions.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Restricti= ons.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Restricti= ons.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -25,7 +25,6 @@ = /** * Apply an "equal" constraint to the identifier property - * @param propertyName * @param value * @return Criterion */ Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Sub= queries.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Subquerie= s.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/criterion/Subquerie= s.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -5,7 +5,7 @@ * Factory class for criterion instances that represent expressions * involving subqueries. * = - * @see Restriction + * @see org.hibernate.criterion.Restrictions * @see Projection * @see org.hibernate.Criteria * @author Gavin King Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracl= e9Dialect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracle9Dial= ect.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracle9Dial= ect.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -25,7 +25,7 @@ /** * An SQL dialect for Oracle 9 (uses ANSI-style syntax where possible). * - * @deprecated Use either Oracle9iDialect or Oracle10gDialect instead + * @deprecated Use either {@link Oracle9iDialect} or {@link Oracle10gDiale= ct} instead * @author Gavin King, David Channon */ public class Oracle9Dialect extends Dialect { Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracl= e9iDialect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracle9iDia= lect.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracle9iDia= lect.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -8,7 +8,7 @@ /** * A dialect for Oracle 9i databases. *

    - * Unlike the older (deprecated) {@Link Oracl9Dialect), this version speci= fies + * Unlike the older {@link org.hibernate.dialect.Oracle9Dialect}, this ver= sion specifies * to not use "ANSI join syntax" because 9i does not seem to properly * handle it in all cases. * Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/loadin= g/EntityLoadContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/loading/Enti= tyLoadContext.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/loading/Enti= tyLoadContext.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -8,7 +8,7 @@ import org.apache.commons.logging.LogFactory; = /** - * {@inheritDoc} + * = * * @author Steve Ebersole */ Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/loadin= g/LoadContexts.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/loading/Load= Contexts.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/engine/loading/Load= Contexts.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -25,7 +25,7 @@ *

    * Implementation note: internally an {@link IdentityMap} is used to maint= ain * the mappings; {@link IdentityMap} was chosen because I'd rather not be - * dependent upon potentially bad {@link ResultSet#equals} and {ResultSet#= hashCode} + * dependent upon potentially bad {@link ResultSet#equals} and {@link Resu= ltSet#hashCode} * implementations. *

    * Considering the JDBC-redesign work, would further like this contextual = info Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/event/LoadEve= ntListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/event/LoadEventList= ener.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/event/LoadEventList= ener.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -16,7 +16,6 @@ * Handle the given load event. * * @param event The load event to be handled. - * @return The result (i.e., the loaded entity). * @throws HibernateException */ public void onLoad(LoadEvent event, LoadType loadType) throws HibernateEx= ception; Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/Exc= eptionUtils.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/Exception= Utils.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/Exception= Utils.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -147,8 +147,8 @@ *

    The method searches for methods with specific names that return a * Throwable object. This will pick up most wrapping excepti= ons, * including those from JDK 1.4, and - * {@link org.apache.commons.lang.exception.NestableException NestableExc= eption}. - * The method names can be added to using {@link #addCauseMethodName(Stri= ng)}.

    + * {@link org.hibernate.exception.NestableException NestableException}. + * The method names can be added to using {@link ExceptionUtils#addCauseM= ethodName(String)}.

    *

    *

    The default list searched for are:

    *
      Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/SQL= ExceptionConverter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/SQLExcept= ionConverter.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/SQLExcept= ionConverter.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -26,7 +26,10 @@ * @param sqlException The SQLException to be converted. * @param message An optional error message. * @return The resulting JDBCException. - * @see ConstraintViolationException, JDBCConnectionException, SQLGrammar= Exception, LockAcquisitionException + * @see ConstraintViolationException + * @see JDBCConnectionException + * @see SQLGrammarException + * @see LockAcquisitionException */ public JDBCException convert(SQLException sqlException, String message, S= tring sql); } Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/SQL= ExceptionConverterFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/SQLExcept= ionConverterFactory.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/exception/SQLExcept= ionConverterFactory.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -30,7 +30,7 @@ /** * Build a SQLExceptionConverter instance. *

      - * First, looks for a {@link Environment.SQL_EXCEPTION_CONVERTER} propert= y to see + * First, looks for a {@link Environment#SQL_EXCEPTION_CONVERTER} propert= y to see * if the configuration specified the class of a specific converter to us= e. If this * property is set, attempt to construct an instance of that class. If n= ot set, or * if construction fails, the converter specific to the dialect will be u= sed. Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/util/= LiteralProcessor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/util/Litera= lProcessor.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/util/Litera= lProcessor.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -49,7 +49,8 @@ /** * In what format should Float and Double literal values be sent * to the database? - * @see #EXACT, #APPROXIMATE + * @see #EXACT + * @see #APPROXIMATE */ public static int DECIMAL_LITERAL_FORMAT =3D EXACT; = Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/loader/Defaul= tEntityAliases.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/loader/DefaultEntit= yAliases.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/loader/DefaultEntit= yAliases.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -28,7 +28,9 @@ = /** * Calculate and cache select-clause suffixes. - * @param map = + * @param userProvidedAliases = + * @param persister + * @param suffix */ public DefaultEntityAliases(Map userProvidedAliases, Loadable persister, = String suffix) { this.suffix =3D suffix; Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/mapping/Forei= gnKey.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/mapping/ForeignKey.= java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/mapping/ForeignKey.= java 2009-11-26 20:28:45 UTC (rev 18072) @@ -67,7 +67,6 @@ * Validates that columnspan of the foreignkey and the primarykey is the = same. * = * Furthermore it aligns the length of the underlying tables columns. - * @param referencedTable */ public void alignColumns() { if ( isReferenceToPrimaryKey() ) alignColumns(referencedTable); Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/persister/ent= ity/Queryable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/persister/entity/Qu= eryable.java 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/persister/entity/Qu= eryable.java 2009-11-26 20:28:45 UTC (rev 18072) @@ -118,7 +118,7 @@ * array. * * @param number The index into the internal array. - * @return + * @return subClass table name */ public String getSubclassTableName(int number); = Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/sql/InFragmen= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/sql/InFragment.java= 2009-11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/sql/InFragment.java= 2009-11-26 20:28:45 UTC (rev 18072) @@ -23,7 +23,7 @@ private List values =3D new ArrayList(); = /** - * @param value, an SQL literal, NULL, or NOT_NULL + * @param value an SQL literal, NULL, or NOT_NULL */ public InFragment addValue(Object value) { values.add(value); Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/Type.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/Type.java 2009= -11-26 08:02:23 UTC (rev 18071) +++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/Type.java 2009= -11-26 20:28:45 UTC (rev 18072) @@ -249,7 +249,6 @@ * * @param value * @param factory - * @return String * @throws HibernateException */ public void setToXMLNode(Node node, Object value, SessionFactoryImplement= or factory) --===============8180538922551636578==-- From hibernate-commits at lists.jboss.org Thu Nov 26 15:29:18 2009 Content-Type: multipart/mixed; boundary="===============8550003191651092373==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18073 - core/branches/Branch_3_2_4_SP1_CP/doc/api. Date: Thu, 26 Nov 2009 15:29:18 -0500 Message-ID: <200911262029.nAQKTIQO005863@svn01.web.mwc.hst.phx2.redhat.com> --===============8550003191651092373== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-26 15:29:18 -0500 (Thu, 26 Nov 2009) New Revision: 18073 Modified: core/branches/Branch_3_2_4_SP1_CP/doc/api/package.html Log: JBPAPP-3169 update hibernate core javadoc Modified: core/branches/Branch_3_2_4_SP1_CP/doc/api/package.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/doc/api/package.html 2009-11-26 20:28= :45 UTC (rev 18072) +++ core/branches/Branch_3_2_4_SP1_CP/doc/api/package.html 2009-11-26 20:29= :18 UTC (rev 18073) @@ -33,7 +33,4 @@ @see org.hibernate.Criteria @see org.hibernate.ScrollableResults @see org.hibernate.cfg.Configuration -(a)see org.hibernate.expression.Expression -(a)see org.hibernate.expression.Order -(a)see org.hibernate.expression.Example --===============8550003191651092373==-- From hibernate-commits at lists.jboss.org Thu Nov 26 15:41:05 2009 Content-Type: multipart/mixed; boundary="===============1052001531913867661==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18074 - core/branches/Branch_3_2_4_SP1_CP. Date: Thu, 26 Nov 2009 15:41:05 -0500 Message-ID: <200911262041.nAQKf5Xx007889@svn01.web.mwc.hst.phx2.redhat.com> --===============1052001531913867661== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-26 15:41:04 -0500 (Thu, 26 Nov 2009) New Revision: 18074 Modified: core/branches/Branch_3_2_4_SP1_CP/build.xml Log: JBPAPP-3170 update build.xml in hibernate-core (branch_3_2_4_SP1_CP) Modified: core/branches/Branch_3_2_4_SP1_CP/build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/build.xml 2009-11-26 20:29:18 UTC (re= v 18073) +++ core/branches/Branch_3_2_4_SP1_CP/build.xml 2009-11-26 20:41:04 UTC (re= v 18074) @@ -38,7 +38,6 @@ - = @@ -51,8 +50,6 @@ - - @@ -65,7 +62,6 @@ - = @@ -143,9 +139,6 @@ = - - - @@ -341,7 +334,6 @@ - @@ -369,7 +361,6 @@ - @@ -391,7 +382,6 @@ - @@ -414,7 +404,6 @@ - @@ -433,17 +422,16 @@ - - - - + + + = - + = + + + = = - = @@ -770,11 +761,6 @@ = - - - - - = @@ -782,29 +768,14 @@ - + = - - - = - - - - - - - - - - --===============1052001531913867661==-- From hibernate-commits at lists.jboss.org Fri Nov 27 11:44:35 2009 Content-Type: multipart/mixed; boundary="===============6014460922906123993==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18075 - in search/trunk: src/main/java/org/hibernate/search/batchindexing and 1 other directories. Date: Fri, 27 Nov 2009 11:44:35 -0500 Message-ID: <200911271644.nARGiZPt012693@svn01.web.mwc.hst.phx2.redhat.com> --===============6014460922906123993== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: epbernard Date: 2009-11-27 11:44:34 -0500 (Fri, 27 Nov 2009) New Revision: 18075 Modified: search/trunk/pom.xml search/trunk/src/main/java/org/hibernate/search/batchindexing/Identifier= Producer.java search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityM= anagerImpl.java search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryIm= pl.java Log: HSEARCH-423 Migrate to Hibernate Core 3.5 beta2 and JPA 2.0 CR1 Modified: search/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/pom.xml 2009-11-26 20:41:04 UTC (rev 18074) +++ search/trunk/pom.xml 2009-11-27 16:44:34 UTC (rev 18075) @@ -53,7 +53,7 @@ 1.5.8 2.4.1 - 3.5.0.Beta-1 + 3.5.0-Beta-2 3.2.0.Beta1 = @@ -79,7 +79,7 @@ org.hibernate.java-persistence jpa-api - 2.0.Beta-20090815 + 2.0-cr-1 org.apache.lucene Modified: search/trunk/src/main/java/org/hibernate/search/batchindexing/Ide= ntifierProducer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/batchindexing/Identifie= rProducer.java 2009-11-26 20:41:04 UTC (rev 18074) +++ search/trunk/src/main/java/org/hibernate/search/batchindexing/Identifie= rProducer.java 2009-11-27 16:44:34 UTC (rev 18075) @@ -111,14 +111,14 @@ } = private void loadAllIdentifiers(final StatelessSession session) throws In= terruptedException { - Integer totalCount =3D (Integer) session + Long totalCount =3D (Long) session .createCriteria( indexedType ) .setProjection( Projections.count( "id" ) ) .setCacheable( false ) .uniqueResult(); = if ( objectsLimit !=3D 0 && objectsLimit < totalCount.intValue() ) { - totalCount =3D objectsLimit; + totalCount =3D new Long(objectsLimit); } log.debug( "going to fetch {} primary keys", totalCount); monitor.addToTotalCount( totalCount ); Modified: search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullText= EntityManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntity= ManagerImpl.java 2009-11-26 20:41:04 UTC (rev 18074) +++ search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntity= ManagerImpl.java 2009-11-27 16:44:34 UTC (rev 18075) @@ -36,7 +36,7 @@ import javax.persistence.TypedQuery; import javax.persistence.metamodel.Metamodel; import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.QueryBuilder; +import javax.persistence.criteria.CriteriaBuilder; = import org.hibernate.search.jpa.FullTextEntityManager; import org.hibernate.search.jpa.FullTextQuery; @@ -212,10 +212,6 @@ return null; //To change body of implemented methods use File | Setting= s | File Templates. } = - public Set getSupportedProperties() { - return null; //To change body of implemented methods use File | Setting= s | File Templates. - } - public Query createQuery(String ejbqlString) { return em.createQuery( ejbqlString ); } @@ -276,7 +272,7 @@ return null; //To change body of implemented methods use File | Setting= s | File Templates. } = - public QueryBuilder getQueryBuilder() { + public CriteriaBuilder getCriteriaBuilder() { return null; //To change body of implemented methods use File | Setting= s | File Templates. } = @@ -284,6 +280,7 @@ return null; //To change body of implemented methods use File | Setting= s | File Templates. } = + public MassIndexer createIndexer(Class... types) { return getFullTextSession().createIndexer( types ); } Modified: search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullText= QueryImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryI= mpl.java 2009-11-26 20:41:04 UTC (rev 18074) +++ search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryI= mpl.java 2009-11-27 16:44:34 UTC (rev 18075) @@ -278,6 +278,18 @@ return null; //To change body of implemented methods use File | Setting= s | File Templates. } = + public Query setParameter(Parameter tParameter, T t) { + return null; //To change body of implemented methods use File | Setting= s | File Templates. + } + + public Query setParameter(Parameter calendarParameter, Calendar= calendar, TemporalType temporalType) { + return null; //To change body of implemented methods use File | Setting= s | File Templates. + } + + public Query setParameter(Parameter dateParameter, Date date, Tempo= ralType temporalType) { + return null; //To change body of implemented methods use File | Setting= s | File Templates. + } + public Set getSupportedHints() { return null; //To change body of implemented methods use File | Setting= s | File Templates. } --===============6014460922906123993==-- From hibernate-commits at lists.jboss.org Fri Nov 27 11:51:43 2009 Content-Type: multipart/mixed; boundary="===============5239981255095336636==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18076 - search/trunk/src/main/docbook/en-US/modules. Date: Fri, 27 Nov 2009 11:51:42 -0500 Message-ID: <200911271651.nARGpgjT013972@svn01.web.mwc.hst.phx2.redhat.com> --===============5239981255095336636== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: epbernard Date: 2009-11-27 11:51:42 -0500 (Fri, 27 Nov 2009) New Revision: 18076 Modified: search/trunk/src/main/docbook/en-US/modules/mapping.xml Log: HSEARCH-410 Write documentation for what's available of the programmatic ma= pping API (Amin Mohammed-Coleman) Modified: search/trunk/src/main/docbook/en-US/modules/mapping.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/docbook/en-US/modules/mapping.xml 2009-11-27 16:4= 4:34 UTC (rev 18075) +++ search/trunk/src/main/docbook/en-US/modules/mapping.xml 2009-11-27 16:5= 1:42 UTC (rev 18076) @@ -1507,4 +1507,648 @@

- + +
+ Programmatic API + + + This feature is considered experimental. While stable code-w= ise, + the API is subject to change in the future. + Although the recommended approach for mapping indexed enti= ties + is to use annotations, it is sometimes more convenient to use a differ= ent + approach: + + + + the same entity is mapped differently depending on deployment + needs (customization for clients) + + + + some automatization process requires the dynamic mapping of = many + entities sharing a common traits + + + + While it has been a popular demand in the past, the Hibernate te= am + never found the idea of an XML alternative to annotations appealing du= e to + it's heavy duplication, lack of code refactoring safety, because it did + not cover all the use case spectrum and because we are in the 21st cen= tury + :) + + Th idea of a programmatic API was much more appealing and has now + become a reality. You can programmatically and safely define your mapp= ing + using a programmatic API: you define entities and fields as indexable = by + using mapping classes which effectively mirror the annotation concepts= in + Hibernate Search. Note that fan(s) of XML approach can design their own + schema and use the programmatic API to create the mapping while parsing + the XML stream. + + In order to use the programmatic model you must first construct a + SearchMapping object. This object is passed to + Hibernate Search via a property set to the Configuration + object. The property key is + hibernate.search.mapping_model. + + SearchMapping mapping =3D new SearchMapping(); +[...] +configuration.setProperty( "hibernate.search.mapping_model", mapping ); + +//or in JPA +SearchMapping mapping =3D new SearchMapping(); +[...] +Map<String,String> properties =3D new HashMap<String,String)(1); +properties.put( "hibernate.search.mapping_model", mapping ); +EntityManagerFactory emf =3D Persistence.createEntityManagerFactory( "user= PU", properties ); + + The SearchMapping is the root object which + contains all the necessary indexable entities and fields. From there, = the + SearchMapping object exposes a fluent (and thus + intuitive) API to express your mappings: it contextually exposes the + relevant mapping options in a type-safe way, just let your IDE + autocompletion feature guide you through. + + Today, the programmatic API cannot be used on a class annotated = with + Hibernate Search annotations, chose one approach or the other. Also no= te + that the same default values apply in annotations and the programmatic + API. For example, the @Field.name is defaulte= d to + the property name and does not have to be set. + + Each core concept of the programmatic API has a corresponding + example to depict how the same definition would look using annotation. + Therefore seeing an annotation example of the programmatic approach sh= ould + give you a clear picture of what Hibernate Search will build with the + marked entities and associated properties. + +
+ Mapping an entity as indexable + + The first concept of the programmatic API is to define an enti= ty + as indexable. Using the annotation approach a user would mark the en= tity + as @Indexed, the following example demonstrat= es + how to programmatically achieve this. + + + Marking an entity indexable + + SearchMapping mapping =3D new SearchMapping(); + +mapping.entity(Address.class) + .indexed() + .indexName("Address_Index"); //optional + +cfg.getProperties().put( "hibernate.search.mapping_model", mapping ); + + As you can see you must first create a + SearchMapping object which is the root ob= ject + that is then passed to the Configuration + object as property. You must declare an entity and if you wish to + make that entity as indexable then you must call the + indexed() method. The index= ed() + method has an optional indexName(String + indexName) which can be used to change the default + index name that is created by Hibernate Search. Using the annota= tion + model the above can be achieved as: + + + Annotation example of indexing entity + + @Entity +(a)Indexed(index=3D"Address_Index") +public class Address { +.... +} + + +
+ +
+ Adding DocumentId to indexed entity + + To set a property as a document id: + + + Enabling document id with programmatic model + + SearchMapping mapping =3D new SearchMapping(); + +mapping.entity(Address.class).indexed() + .property("addressId", ElementType.FIELD) //field access + .documentId() + .name("id"); + +cfg.getProperties().put( "hibernate.search.mapping_model", mapping); + + The above is equivalent to annotating a property in the en= tity + as @DocumentId as seen in the following + example: + + + DocumentId annotation definition + + @Entity +(a)Indexed +public class Address { + @Id + @GeneratedValue + @DocumentId(name=3D"id") + private Long addressId; + + .... +} + + The next section demonstrates how to programmatically de= fine + analyzers. +
+ +
+ Defining analyzers + + Analyzers can be programmatically defined using the + analyzerDef(String analyzerDef, Class<? extends + TokenizerFactory> tokenizerFactory) method. This met= hod + also enables you to define filters for the analyzer definition. Each + filter that you define can optionally take in parameters as seen in = the + following example : + + + Defining analyzers using programmatic model + + SearchMapping mapping =3D new SearchMapping(); + +mapping + .analyzerDef( "ngram", StandardTokenizerFactor= y.class ) + .filter( LowerCaseFilterFactory.class ) + .filter( NGramFilterFactory.class ) + .param( "minGramSize", "3" ) + .param( "maxGramSize", "3" ) + .analyzerDef( "en", StandardTokenizerFactory.class ) + .filter( LowerCaseFilterFactory.class ) + .filter( EnglishPorterFilterFactory.class ) + .analyzerDef( "de", StandardTokenizerFactory.class ) + .filter( LowerCaseFilterFactory.class ) + .filter( GermanStemFilterFactory.class ) + .entity(Address.class).indexed() + .property("addressId", ElementType.METHOD) //getter access + .documentId() + .name("id"); + +cfg.getProperties().put( "hibernate.search.mapping_model", mapping ); + + The analyzer mapping defined above is equivalent to the + annotation model using @AnalyzerDef in + conjunction with @AnalyzerDefs: + + Analyzer definition using annotation + + @Indexed +(a)Entity +(a)AnalyzerDefs({ + @AnalyzerDef(name =3D "ngram", + tokenizer =3D @TokenizerDef(factory =3D StandardTokenizerFactory.class= ), + filters =3D { + @TokenFilterDef(factory =3D LowerCaseFilterFactory.class), + @TokenFilterDef(factory =3D NGramFilterFactory.class, = + params =3D { + @Parameter(name =3D "minGramSize",value =3D "3"), + @Parameter(name =3D "maxGramSize",value =3D "3") = + }) + }), + @AnalyzerDef(name =3D "en", + tokenizer =3D @TokenizerDef(factory =3D StandardTokenizerFactory.class= ), + filters =3D { + @TokenFilterDef(factory =3D LowerCaseFilterFactory.class), + @TokenFilterDef(factory =3D EnglishPorterFilterFactory.class) + }), + + @AnalyzerDef(name =3D "de", + tokenizer =3D @TokenizerDef(factory =3D StandardTokenizerFactory.class= ), + filters =3D { + @TokenFilterDef(factory =3D LowerCaseFilterFactory.class), + @TokenFilterDef(factory =3D GermanStemFilterFactory.class) + }) + +}) +public class Address { +... +} + +
+ +
+ Defining fields for indexing + + When defining fields for indexing using the programmatic API, = call + field() on the property(String + propertyName, ElementType elementType) method. From + field() you can specify the nam= e, + index, store, + bridge and analyzer + definitions. + + + Indexing fields using programmatic API + + SearchMapping mapping =3D new SearchMapping(); + +mapping + .analyzerDef( "en", StandardTokenizerFactory.class ) + .filter( LowerCaseFilterFactory.class ) + .filter( EnglishPorterFilterFactory.class ) + .entity(Address.class).indexed() + .property("addressId", ElementType.METHOD) + .documentId() + .name("id") + .property("street1", ElementType.METHOD) + .field() + .analyzer("en") + .store(Store.YES) + .index(Index.TOKENIZED) //no useful here as it's the defau= lt + .field() + .name("address_data") + .analyzer("en"); + +cfg.getProperties().put( "hibernate.search.mapping_model", mapping ); + + The above example of marking fields as indexable is equiva= lent + to defining fields using @Field as seen + below: + + Indexing fields using annotation + + @Entity +(a)Indexed +(a)AnalyzerDefs({ + @AnalyzerDef(name =3D "en", + tokenizer =3D @TokenizerDef(factory =3D StandardTokenizerFactory.class= ), + filters =3D { + @TokenFilterDef(factory =3D LowerCaseFilterFactory.class), + @TokenFilterDef(factory =3D EnglishPorterFilterFactory.class) + }) +}) +public class Address { + = + @Id + @GeneratedValue + @DocumentId(name=3D"id") + private Long getAddressId() {...}; + + @Fields({ + @Field(index=3DIndex.TOKENIZED, store=3DStore.YES, = + analyzer=3D@Analyzer(definition=3D"en")), + @Field(name=3D"address_data", analyzer=3D@Analyzer(definition=3D"en"= )) + }) + public String getAddress1() {...} + + ...... +} + + + +
+ +
+ Defining full text filter definitions + + The programmatic API provides easy mechanism for defining full + text filter definitions which is available via + @FullTextFilterDef and + @FullTextFilterDefs. The next example depicts= the + creation of full text filter definition using the + fullTextFilterDef method. + + + Defining full text definition programmatically + + SearchMapping mapping =3D new SearchMapping(); + +mapping + .analyzerDef( "en", StandardTokenizerFactory.class ) + .filter( LowerCaseFilterFactory.class ) + .filter( EnglishPorterFilterFactory.class ) + .entity(Address.class) + .indexed() + .fullTextFilterDef("security", SecurityFil= terFactory.class) + .cache(FilterCacheModeType.INSTANCE_ONLY) + .property("addressId", ElementType.METHOD) + .documentId() + .name("id") + .property("street1", ElementType.METHOD) + .field() + .analyzer("en") + .store(Store.YES) + .field() + .name("address_data") + .analyzer("en") + .store(Store.NO); + +cfg.getProperties().put( "hibernate.search.mapping_model", mapping ); + + The previous example can effectively been seen as annotati= ng + your entity with @FullTextFilterDef like below: + + Using annotation to define full text filter + definition + + @Entity +(a)Indexed +(a)AnalyzerDefs({ + @AnalyzerDef(name =3D "en", + tokenizer =3D @TokenizerDef(factory =3D StandardTokenizerFactory.class= ), + filters =3D { + @TokenFilterDef(factory =3D LowerCaseFilterFactory.class), + @TokenFilterDef(factory =3D EnglishPorterFilterFactory.class) + }) +}) +(a)FullTextFilterDefs({ + @FullTextFilterDef(name =3D "security", impl =3D SecurityFilterFactory.cl= ass, cache =3D FilterCacheModeType.INSTANCE_ONLY) +}) +public class Address { + = + @Id + @GeneratedValue + @DocumentId(name=3D"id") + pubblic Long getAddressId() {...}; + + @Fields({ + @Field(index=3DIndex.TOKENIZED, store=3DStore.YES, = + analyzer=3D@Analyzer(definition=3D"en")), + @Field(name=3D"address_data", analyzer=3D@Analyzer(definition=3D"en"= )) + }) + public String getAddress1() {...}; + + ...... + = +} + +
+ +
+ Programmatically defining embedded entities + + In this section you will see how to programmatically define + entities to be embedded into the indexed entity similar to using the + @IndexEmbedded model. In order to define this= you + must mark the property as indexEmbedded. Th= e is + the option to add a prefix to the embedded entity definition and this + can be done by calling prefix as seen in the + example below: + + + Programmatically defining embedded entites + + SearchMapping mapping =3D new SearchMapping(); + +mappping + .entity(ProductCatalog.class) + .indexed() + .property("catalogId", ElementType.METHOD) + .documentId() + .name("id") + .property("title", ElementType.METHOD) + .field() + .index(Index.TOKENIZED) + .store(Store.NO) + .property("description", ElementType.METHOD) + .field() + .index(Index.TOKENIZED) + .store(Store.NO) + .property("items", ElementType.METHOD) + .indexEmbedded() + .prefix("catalog.items"); //optional + +cfg.getProperties().put( "hibernate.search.mapping_model", mapping ); + + The next example shows the same definition using annotation + (@IndexEmbedded): + + Using @IndexEmbedded + + @Entity +(a)Indexed +public class ProductCatalog { + @Id + @GeneratedValue + @DocumentId(name=3D"id") + public Long getCatalogId() {...} + = + @Field(store=3DStore.NO, index=3DIndex.TOKENIZED) + public String getTitle() {...} + + @Field(store=3DStore.NO, index=3DIndex.TOKENIZED) + public String getDescription(); + = + @OneToMany(fetch =3D FetchType.LAZY) + @IndexColumn(name =3D "list_position") + @Cascade(org.hibernate.annotations.CascadeType.ALL) + @IndexEmbedded(prefix=3D"catalog.items") + public List<Item> getItems() {...} + + ... + +} + +
+ +
+ Contained In definition + + @ContainedIn can be define as seen in t= he + example below: + Programmatically defining ContainedIn + + SearchMapping mapping =3D new SearchMapping(); + +mappping + .entity(ProductCatalog.class) + .indexed() + .property("catalogId", ElementType.METHOD) + .documentId() + .property("title", ElementType.METHOD) + .field() + .property("description", ElementType.METHOD) + .field() + .property("items", ElementType.METHOD) + .indexEmbedded() + + .entity(Item.class) + .property("description", ElementType.METHOD) + .field() + .property("productCatalog", ElementType.METHOD) + .containedIn(); + +cfg.getProperties().put( "hibernate.search.mapping_model", mapping ); + + This is equivalent to defining + @ContainedIn in your entity: + + + Annotation approach for ContainedIn + + @Entity +(a)Indexed +public class ProductCatalog { + = + @Id + @GeneratedValue + @DocumentId + public Long getCatalogId() {...} + = + @Field + public String getTitle() {...} + + @Field + public String getDescription() {...} + = + @OneToMany(fetch =3D FetchType.LAZY) + @IndexColumn(name =3D "list_position") + @Cascade(org.hibernate.annotations.CascadeType.ALL) + @IndexEmbedded + private List<Item> getItems() {...} + + ... + +} + + +(a)Entity +public class Item { + = + @Id + @GeneratedValue + private Long itemId; + + @Field + public String getDescription() {...} + = + @ManyToOne( cascade =3D { CascadeType.PERSIST, CascadeType.REMOVE } ) + @ContainedIn + public ProductCatalog getProductCatalog() {...} + + ... +} + + +
+ +
+ Date/Calendar Bridge + + In order to define a calendar or date bridge mapping, call the + dateBridge(Resolution resolution) or + calendarBridge(Resolution resolution) metho= ds + after you have defined a field() in the + SearchMapping hierarchy. + + + Programmatic model for defining calendar/date bridge</tit= le> + + <programlisting>SearchMapping mapping =3D new SearchMapping(); + +mapping + .entity(Address.class) + .indexed() + .property("addressId", ElementType.FIELD) + .documentId() + .property("street1", ElementType.FIELD() + .field() + .property("createdOn", ElementType.FIELD) + .field() + <emphasis role=3D"bold">.dateBridge(Resolution.DAY)</emphasis> + .property("lastUpdated", ElementType.FIELD) + <emphasis role=3D"bold">.calendarBridge(Resolution.DAY)</emphasis>; + +cfg.getProperties().put( "hibernate.search.mapping_model", mapping );</pro= gramlisting> + + <para>See below for defining the above using + <classname>@CalendarBridge</classname> and + <classname>@DateBridge</classname>:</para> + </example><example> + <title>@CalendarBridge and @DateBridge definition + + @Entity +(a)Indexed +public class Address { + = + @Id + @GeneratedValue + @DocumentId + private Long addressId; + + @Field + private String address1; + + @Field + @DateBridge(resolution=3DResolution.DAY) + private Date createdOn; + + @CalendarBridge(resolution=3DResolution.DAY) + private Calendar lastUpdated; + + ... +} + +
+ +
+ Defining bridges + + It is possible to associate bridges to programmatically defined + fields. When you define a field() + programmatically you can use the bridge(Class<?> + impl) to associate a FieldBridge + implementation class. The bridge method also provides + optional methods to include any parameters required for the bridge + class. The below shows an example of programmatically defining a + bridge: + + + Defining field bridges programmatically + + SearchMapping mapping =3D new SearchMapping(); + +mapping + .entity(Address.class) + .indexed() + .property("addressId", ElementType.FIELD) + .documentId() + .property("street1", ElementType.FIELD) + .field() + .field() + .name("street1_abridged") + .bridge( ConcatStringBridge.class ) + .param( "size", "4" ); + = +cfg.getProperties().put( "hibernate.search.mapping_model", mapping ); + + The above can equally be defined using annotations, as see= n in + the next example. + + + Defining field bridges using annotation + + @Entity +(a)Indexed + +public class Address { + = + @Id + @GeneratedValue + @DocumentId(name=3D"id") + private Long addressId; + + @Fields({ + @Field, + @Field(name=3D"street1_abridged", = + bridge=3D @FieldBridge(impl =3D ConcatStringBridge.class, = + params =3D @Parameter( name=3D"size", value=3D"4" )) + }) + private String address1; + + ... +} + + +
+
+ \ No newline at end of file --===============5239981255095336636==-- From hibernate-commits at lists.jboss.org Fri Nov 27 11:53:34 2009 Content-Type: multipart/mixed; boundary="===============3991960753886418614==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18077 - in core/trunk/cache-infinispan: src/test/java/org/hibernate/test/cache/infinispan/functional and 1 other directory. Date: Fri, 27 Nov 2009 11:53:34 -0500 Message-ID: <200911271653.nARGrYxW014149@svn01.web.mwc.hst.phx2.redhat.com> --===============3991960753886418614== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: galder.zamarreno(a)jboss.com Date: 2009-11-27 11:53:33 -0500 (Fri, 27 Nov 2009) New Revision: 18077 Modified: core/trunk/cache-infinispan/pom.xml core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infin= ispan/functional/ConcurrentWriteTest.java Log: [ISPN-277] (LRU data container endlesly looping or exhibiting heavy content= ion) Update to trunk and check if testManyUsers runs fine now. Modified: core/trunk/cache-infinispan/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/pom.xml 2009-11-27 16:51:42 UTC (rev 18076) +++ core/trunk/cache-infinispan/pom.xml 2009-11-27 16:53:33 UTC (rev 18077) @@ -17,7 +17,7 @@ Integration of Hibernate with Infinispan = - 4.0.0.CR2 + 4.0.0-SNAPSHOT 1.8.0.2 2.2 3.4.GA Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cach= e/infinispan/functional/ConcurrentWriteTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/ConcurrentWriteTest.java 2009-11-27 16:51:42 UTC (rev 180= 76) +++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infi= nispan/functional/ConcurrentWriteTest.java 2009-11-27 16:53:33 UTC (rev 180= 77) @@ -189,40 +189,40 @@ = } = -// /** -// * TODO: This will fail until ISPN-??? has been fixed. -// * = -// * @throws Exception -// */ -// public void testManyUsers() throws Throwable { -// try { -// // setup - create users -// for (int i =3D 0; i < USER_COUNT; i++) { -// Customer customer =3D createCustomer(0); -// getCustomerIDs().add(customer.getId()); -// } -// assertEquals("failed to create enough Customers", USER_COUNT, g= etCustomerIDs().size()); -// -// final ExecutorService executor =3D Executors.newFixedThreadPool= (USER_COUNT); -// -// CyclicBarrier barrier =3D new CyclicBarrier(USER_COUNT + 1); -// List> futures =3D new ArrayList>(USER= _COUNT); -// for (Integer customerId : getCustomerIDs()) { -// Future future =3D executor.submit(new UserRunner(custo= merId, barrier)); -// futures.add(future); -// Thread.sleep(LAUNCH_INTERVAL_MILLIS); // rampup -// } -//// barrier.await(); // wait for all threads to be ready -// barrier.await(45, TimeUnit.SECONDS); // wait for all threads to= finish -// log.info("All threads finished, let's shutdown the executor and= check whether any exceptions were reported"); -// for (Future future : futures) future.get(); -// log.info("All future gets checked"); -// } catch (Throwable t) { -// log.error("Error running test", t); -// throw t; -// } -// } + /** + * TODO: This will fail until ISPN-??? has been fixed. + * = + * @throws Exception + */ + public void testManyUsers() throws Throwable { + try { + // setup - create users + for (int i =3D 0; i < USER_COUNT; i++) { + Customer customer =3D createCustomer(0); + getCustomerIDs().add(customer.getId()); + } + assertEquals("failed to create enough Customers", USER_COUNT, get= CustomerIDs().size()); = + final ExecutorService executor =3D Executors.newFixedThreadPool(U= SER_COUNT); + + CyclicBarrier barrier =3D new CyclicBarrier(USER_COUNT + 1); + List> futures =3D new ArrayList>(USER_C= OUNT); + for (Integer customerId : getCustomerIDs()) { + Future future =3D executor.submit(new UserRunner(custome= rId, barrier)); + futures.add(future); + Thread.sleep(LAUNCH_INTERVAL_MILLIS); // rampup + } +// barrier.await(); // wait for all threads to be ready + barrier.await(45, TimeUnit.SECONDS); // wait for all threads to f= inish + log.info("All threads finished, let's shutdown the executor and c= heck whether any exceptions were reported"); + for (Future future : futures) future.get(); + log.info("All future gets checked"); + } catch (Throwable t) { + log.error("Error running test", t); + throw t; + } + } + public void cleanup() throws Exception { getCustomerIDs().clear(); String deleteContactHQL =3D "delete from Contact"; --===============3991960753886418614==-- From hibernate-commits at lists.jboss.org Fri Nov 27 12:30:33 2009 Content-Type: multipart/mixed; boundary="===============3752904843280994846==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18078 - in search/trunk/src: main/java/org/hibernate/search/cfg and 2 other directories. Date: Fri, 27 Nov 2009 12:30:32 -0500 Message-ID: <200911271730.nARHUWXL021741@svn01.web.mwc.hst.phx2.redhat.com> --===============3752904843280994846== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: epbernard Date: 2009-11-27 12:30:32 -0500 (Fri, 27 Nov 2009) New Revision: 18078 Modified: search/trunk/src/main/docbook/en-US/modules/mapping.xml search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilterDefMap= ping.java search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMapping.ja= va search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMappin= g.java search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadat= aProvider.java search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.j= ava search/trunk/src/test/java/org/hibernate/search/test/configuration/Progr= ammaticMappingTest.java Log: HSEARCH-411 fix various issues on programmatic API Modified: search/trunk/src/main/docbook/en-US/modules/mapping.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/docbook/en-US/modules/mapping.xml 2009-11-27 16:5= 3:33 UTC (rev 18077) +++ search/trunk/src/main/docbook/en-US/modules/mapping.xml 2009-11-27 17:3= 0:32 UTC (rev 18078) @@ -1548,7 +1548,7 @@ SearchMapping object. This object is passed to Hibernate Search via a property set to the Configuration object. The property key is - hibernate.search.mapping_model. + hibernate.search.mapping_model. = SearchMapping mapping =3D new SearchMapping(); [...] @@ -1736,18 +1736,19 @@
=
- Defining fields for indexing + Defining full text filter definitions = - When defining fields for indexing using the programmatic API, = call - field() on the property(String - propertyName, ElementType elementType) method. From - field() you can specify the nam= e, - index, store, - bridge and analyzer - definitions. + The programmatic API provides easy mechanism for defining full + text filter definitions which is available via + @FullTextFilterDef and + @FullTextFilterDefs. Note that contrary to the + annotation equivalent, full text filter definitions are a global + construct and are not tied to an entity. The next example depicts the + creation of full text filter definition using the + fullTextFilterDef method. = - Indexing fields using programmatic API + Defining full text definition programmatically = SearchMapping mapping =3D new SearchMapping(); = @@ -1755,26 +1756,30 @@ .analyzerDef( "en", StandardTokenizerFactory.class ) .filter( LowerCaseFilterFactory.class ) .filter( EnglishPorterFilterFactory.class ) - .entity(Address.class).indexed() + .fullTextFilterDef("security", SecurityFilterF= actory.class) + .cache(FilterCacheModeType.INSTANCE_ONLY) + .entity(Address.class) + .indexed() .property("addressId", ElementType.METHOD) .documentId() .name("id") .property("street1", ElementType.METHOD) - .field() + .field() .analyzer("en") .store(Store.YES) - .index(Index.TOKENIZED) //no useful here as it's the defau= lt .field() .name("address_data") - .analyzer("en"); + .analyzer("en") + .store(Store.NO); = cfg.getProperties().put( "hibernate.search.mapping_model", mapping ); = - The above example of marking fields as indexable is equiva= lent - to defining fields using @Field as seen + The previous example can effectively been seen as annotati= ng + your entity with @FullTextFilterDef like below: - Indexing fields using annotation + Using annotation to define full text filter + definition = @Entity @Indexed @@ -1786,39 +1791,42 @@ @TokenFilterDef(factory =3D EnglishPorterFilterFactory.class) }) }) +(a)FullTextFilterDefs({ + @FullTextFilterDef(name =3D "security", impl =3D SecurityFilterFactory.cl= ass, cache =3D FilterCacheModeType.INSTANCE_ONLY) +}) public class Address { = @Id @GeneratedValue @DocumentId(name=3D"id") - private Long getAddressId() {...}; + pubblic Long getAddressId() {...}; = @Fields({ @Field(index=3DIndex.TOKENIZED, store=3DStore.YES, = analyzer=3D@Analyzer(definition=3D"en")), @Field(name=3D"address_data", analyzer=3D@Analyzer(definition=3D"en"= )) }) - public String getAddress1() {...} + public String getAddress1() {...}; = ...... + = } - -
=
- Defining full text filter definitions + Defining fields for indexing = - The programmatic API provides easy mechanism for defining full - text filter definitions which is available via - @FullTextFilterDef and - @FullTextFilterDefs. The next example depicts= the - creation of full text filter definition using the - fullTextFilterDef method. + When defining fields for indexing using the programmatic API, = call + field() on the property(String + propertyName, ElementType elementType) method. From + field() you can specify the nam= e, + index, store, + bridge and analyzer + definitions. = - Defining full text definition programmatically + Indexing fields using programmatic API = SearchMapping mapping =3D new SearchMapping(); = @@ -1826,29 +1834,26 @@ .analyzerDef( "en", StandardTokenizerFactory.class ) .filter( LowerCaseFilterFactory.class ) .filter( EnglishPorterFilterFactory.class ) - .entity(Address.class) - .indexed() - .fullTextFilterDef("security", SecurityFil= terFactory.class) - .cache(FilterCacheModeType.INSTANCE_ONLY) + .entity(Address.class).indexed() .property("addressId", ElementType.METHOD) .documentId() .name("id") .property("street1", ElementType.METHOD) - .field() + .field() .analyzer("en") .store(Store.YES) + .index(Index.TOKENIZED) //no useful here as it's the defau= lt .field() .name("address_data") - .analyzer("en") - .store(Store.NO); + .analyzer("en"); = cfg.getProperties().put( "hibernate.search.mapping_model", mapping ); = - The previous example can effectively been seen as annotati= ng - your entity with @FullTextFilterDef like below: + The above example of marking fields as indexable is equiva= lent + to defining fields using @Field as seen + below: - Using annotation to define full text filter - definition + Indexing fields using annotation = @Entity @Indexed @@ -1860,26 +1865,24 @@ @TokenFilterDef(factory =3D EnglishPorterFilterFactory.class) }) }) -(a)FullTextFilterDefs({ - @FullTextFilterDef(name =3D "security", impl =3D SecurityFilterFactory.cl= ass, cache =3D FilterCacheModeType.INSTANCE_ONLY) -}) public class Address { = @Id @GeneratedValue @DocumentId(name=3D"id") - pubblic Long getAddressId() {...}; + private Long getAddressId() {...}; = @Fields({ @Field(index=3DIndex.TOKENIZED, store=3DStore.YES, = analyzer=3D@Analyzer(definition=3D"en")), @Field(name=3D"address_data", analyzer=3D@Analyzer(definition=3D"en"= )) }) - public String getAddress1() {...}; + public String getAddress1() {...} = ...... - = } + +
= Modified: search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java = 2009-11-27 16:53:33 UTC (rev 18077) +++ search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java = 2009-11-27 17:30:32 UTC (rev 18078) @@ -70,7 +70,7 @@ = = public FullTextFilterDefMapping fullTextFilterDef(String name, Class i= mpl) { - return new FullTextFilterDefMapping(mapping, entity, name, impl); + return new FullTextFilterDefMapping(mapping,name, impl); } = public PropertyMapping property(String name, ElementType type) { Modified: search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilte= rDefMapping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilterDefMa= pping.java 2009-11-27 16:53:33 UTC (rev 18077) +++ search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilterDefMa= pping.java 2009-11-27 17:30:32 UTC (rev 18078) @@ -39,15 +39,13 @@ = private final SearchMapping mapping; private final Map fullTextFilterDef; - private final EntityDescriptor entity; = - public FullTextFilterDefMapping(SearchMapping mapping, EntityDescriptor e= ntity, String name, Class impl) { + public FullTextFilterDefMapping(SearchMapping mapping, String name, Class= impl) { this.mapping =3D mapping; - this.entity =3D entity; this.fullTextFilterDef =3Dnew HashMap(); this.fullTextFilterDef.put("name", name); this.fullTextFilterDef.put("impl", impl); - entity.addFulltextFilterDef(fullTextFilterDef); + mapping.addFulltextFilterDef(fullTextFilterDef); } = /** @@ -61,13 +59,9 @@ } = public FullTextFilterDefMapping fullTextFilterDef(String name, Class i= mpl) { - return new FullTextFilterDefMapping(mapping,entity,name, impl); + return new FullTextFilterDefMapping(mapping, name, impl); } = - public PropertyMapping property(String name, ElementType type) { - return new PropertyMapping(name, type, entity, mapping); - } - public AnalyzerDefMapping analyzerDef(String name, Class tokenizerFactory) { return new AnalyzerDefMapping(name, tokenizerFactory, mapping); } @@ -75,10 +69,4 @@ public EntityMapping entity(Class entityType) { return new EntityMapping(entityType, mapping); } - - public ProvidedIdMapping providedId() { - return new ProvidedIdMapping(mapping,entity); - } - - = } Modified: search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMappin= g.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java= 2009-11-27 16:53:33 UTC (rev 18077) +++ search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java= 2009-11-27 17:30:32 UTC (rev 18078) @@ -74,7 +74,7 @@ = = public FullTextFilterDefMapping fullTextFilterDef(String name, Class i= mpl) { - return new FullTextFilterDefMapping(mapping, entity, name, impl); + return new FullTextFilterDefMapping(mapping, name, impl); } = public PropertyMapping property(String name, ElementType type) { Modified: search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMap= ping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMapping.j= ava 2009-11-27 16:53:33 UTC (rev 18077) +++ search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMapping.j= ava 2009-11-27 17:30:32 UTC (rev 18078) @@ -53,7 +53,7 @@ } = public FullTextFilterDefMapping fullTextFilterDef(String name, Class i= mpl) { - return new FullTextFilterDefMapping(searchMapping, entity, name, impl); + return new FullTextFilterDefMapping(searchMapping, name, impl); } = public PropertyMapping property(String name, ElementType type) { Modified: search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java = 2009-11-27 16:53:33 UTC (rev 18077) +++ search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java = 2009-11-27 17:30:32 UTC (rev 18078) @@ -38,12 +38,17 @@ */ public class SearchMapping { private Set> analyzerDefs =3D new HashSet>(); + private Set> fullTextFilterDefs =3D new HashSet>(); private Map, EntityDescriptor> entities =3D new HashMap= , EntityDescriptor>(); = public Set> getAnalyzerDefs() { return analyzerDefs; } = + public Set> getFullTextFilerDefs() { + return fullTextFilterDefs; + } + = public EntityDescriptor getEntityDescriptor(Class entityType) { return entities.get( entityType ); } @@ -51,18 +56,23 @@ public AnalyzerDefMapping analyzerDef(String name, Class tokenizerFactory) { return new AnalyzerDefMapping(name, tokenizerFactory, this); } - + = public EntityMapping entity(Class entityType) { return new EntityMapping(entityType, this); } + = + public FullTextFilterDefMapping fullTextFilterDef(String name, Class i= mpl) { + return new FullTextFilterDefMapping(this, name, impl ); + } = /** * eg @Containing(things=3D{@Thing(...), @Thing(...)} * Map addedThing =3D addElementToAnnotationArray(contain= ing, "things"); */ + static Map addElementToAnnotationArray(Map containingAnnotation, String attributeName) { - List> array =3D (List>) containi= ngAnnotation.get( attributeName ); + @SuppressWarnings("unchecked") List> array =3D (List= >) containingAnnotation.get( attributeName ); if ( array =3D=3D null) { array =3D new ArrayList>(); containingAnnotation.put( attributeName, array ); @@ -84,5 +94,9 @@ } return entity; } + + void addFulltextFilterDef(Map fullTextFilterDef) { + fullTextFilterDefs.add(fullTextFilterDef); + } = } Modified: search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDe= fMapping.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMappi= ng.java 2009-11-27 16:53:33 UTC (rev 18077) +++ search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMappi= ng.java 2009-11-27 17:30:32 UTC (rev 18078) @@ -69,4 +69,8 @@ return new AnalyzerDefMapping(name, tokenizerFactory, mapping); } = + public FullTextFilterDefMapping fullTextFilterDef(String name, Class i= mpl) { + return new FullTextFilterDefMapping(mapping, name, impl ); + } + } Modified: search/trunk/src/main/java/org/hibernate/search/impl/MappingModel= MetadataProvider.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetada= taProvider.java 2009-11-27 16:53:33 UTC (rev 18077) +++ search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetada= taProvider.java 2009-11-27 17:30:32 UTC (rev 18078) @@ -101,10 +101,15 @@ new HashMap() : new HashMap(delegateDefaults); defaults.put( AnalyzerDefs.class, createAnalyzerDefArray() ); + if (!mapping.getFullTextFilerDefs().isEmpty()) { + defaults.put(FullTextFilterDefs.class, createFullTextFilterDefsForMapp= ing()); + } } return defaults; } = + = + public AnnotationReader getAnnotationReader(AnnotatedElement annotatedEle= ment) { AnnotationReader reader =3D cache.get(annotatedElement); if (reader =3D=3D null) { @@ -124,7 +129,36 @@ return defs; } = + private FullTextFilterDef[] createFullTextFilterDefsForMapping() { + Set> fullTextFilterDefs =3D mapping.getFullTextFiler= Defs(); + FullTextFilterDef[] filters =3D new FullTextFilterDef[fullTextFilterDefs= .size()]; + int index =3D 0; + for(Map filterDef : fullTextFilterDefs) { + filters[index] =3D createFullTextFilterDef(filterDef); + index++; + } + return filters; + } = + private static FullTextFilterDef createFullTextFilterDef(Map filterDef) { + AnnotationDescriptor fullTextFilterDefAnnotation =3D new AnnotationDescr= iptor( FullTextFilterDef.class ); + for (Entry entry : filterDef.entrySet()) { + fullTextFilterDefAnnotation.setValue(entry.getKey(), entry.getValue()); + } + = + return AnnotationFactory.create( fullTextFilterDefAnnotation ); + } + + private static FullTextFilterDef[] createFullTextFilterDefArray(Set> fullTextFilterDefs) { + FullTextFilterDef[] filters =3D new FullTextFilterDef[fullTextFilterDefs= .size()]; + int index =3D 0; + for(Map filterDef : fullTextFilterDefs) { + filters[index] =3D createFullTextFilterDef(filterDef); + index++; + } + return filters; + } + = private AnalyzerDef createAnalyzerDef(Map analyzerDef) { AnnotationDescriptor analyzerDefAnnotation =3D new AnnotationDescriptor(= AnalyzerDef.class ); for ( Map.Entry entry : analyzerDef.entrySet() ) { @@ -436,7 +470,7 @@ } if (entity.getFullTextFilterDefs().size() > 0) { AnnotationDescriptor fullTextFilterDefsAnnotation =3D new AnnotationDe= scriptor( FullTextFilterDefs.class ); - FullTextFilterDef[] fullTextFilterDefArray =3D createFullTextFilterDef= Array(entity); + FullTextFilterDef[] fullTextFilterDefArray =3D createFullTextFilterDef= Array(entity.getFullTextFilterDefs()); fullTextFilterDefsAnnotation.setValue("value", fullTextFilterDefArray); annotations.put( FullTextFilterDefs.class, AnnotationFactory.create( f= ullTextFilterDefsAnnotation ) ); } @@ -469,27 +503,6 @@ annotations.put( ProvidedId.class, AnnotationFactory.create( annotation= ) ); } = - = - private FullTextFilterDef[] createFullTextFilterDefArray(EntityDescripto= r entity) { - Set> fullTextFilterDefs =3D entity.getFullTextFilte= rDefs(); - FullTextFilterDef[] filters =3D new FullTextFilterDef[fullTextFilterDef= s.size()]; - int index =3D 0; - for(Map filterDef : fullTextFilterDefs) { - filters[index] =3D createFullTextFilterDef(filterDef); - index++; - } - return filters; - } - = - private FullTextFilterDef createFullTextFilterDef(Map fil= terDef) { - AnnotationDescriptor fullTextFilterDefAnnotation =3D new AnnotationDesc= riptor( FullTextFilterDef.class ); - for (Entry entry : filterDef.entrySet()) { - fullTextFilterDefAnnotation.setValue(entry.getKey(), entry.getValue()); - } - = - return AnnotationFactory.create( fullTextFilterDefAnnotation ); - } - = private void populateAnnotationArray() { annotationsArray =3D new Annotation[ annotations.size() ]; int index =3D 0; Modified: search/trunk/src/main/java/org/hibernate/search/impl/SearchFactor= yImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.= java 2009-11-27 16:53:33 UTC (rev 18077) +++ search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.= java 2009-11-27 17:30:32 UTC (rev 18078) @@ -281,6 +281,20 @@ } } } + = + = + private void initProgrammaticallyDefinedFilterDef(ReflectionManager refle= ctionManager) { + @SuppressWarnings("unchecked") Map defaults =3D reflectionManager.getDef= aults(); + FullTextFilterDef[] filterDefs =3D (FullTextFilterDef[]) defaults.get(Fu= llTextFilterDefs.class); + if (filterDefs !=3D null && filterDefs.length !=3D 0) { + for (FullTextFilterDef defAnn : filterDefs) { + if ( filterDefinitions.containsKey( defAnn.name() ) ) { + throw new SearchException("Multiple definition of @FullTextFilterDef.= name=3D" + defAnn.name()); + } + bindFullTextFilterDef(defAnn); + } + } + } = private void bindFilterDef(FullTextFilterDef defAnn, XClass mappedXClass)= { if ( filterDefinitions.containsKey( defAnn.name() ) ) { @@ -290,6 +304,10 @@ ); } = + bindFullTextFilterDef(defAnn); + } + + private void bindFullTextFilterDef(FullTextFilterDef defAnn) { FilterDef filterDef =3D new FilterDef( defAnn ); if ( filterDef.getImpl().equals( ShardSensitiveOnlyFilter.class ) ) { //this is a placeholder don't process regularly @@ -463,6 +481,7 @@ DirectoryProviderFactory factory =3D new DirectoryProviderFactory(); = initProgrammaticAnalyzers(context, reflectionManager); + initProgrammaticallyDefinedFilterDef(reflectionManager); = while ( iter.hasNext() ) { Class mappedClass =3D iter.next(); Modified: search/trunk/src/test/java/org/hibernate/search/test/configuratio= n/ProgrammaticMappingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/java/org/hibernate/search/test/configuration/Prog= rammaticMappingTest.java 2009-11-27 16:53:33 UTC (rev 18077) +++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Prog= rammaticMappingTest.java 2009-11-27 17:30:32 UTC (rev 18078) @@ -44,7 +44,6 @@ import org.apache.solr.analysis.NGramFilterFactory; import org.apache.solr.analysis.SnowballPorterFilterFactory; import org.apache.solr.analysis.StandardTokenizerFactory; -import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.hibernate.search.FullTextQuery; @@ -54,12 +53,16 @@ import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.Resolution; import org.hibernate.search.annotations.Store; +import org.hibernate.search.backend.Work; +import org.hibernate.search.backend.WorkType; import org.hibernate.search.bridge.builtin.LongBridge; import org.hibernate.search.cfg.ConcatStringBridge; import org.hibernate.search.cfg.SearchMapping; +import org.hibernate.search.engine.SearchFactoryImplementor; import org.hibernate.search.store.DirectoryProvider; import org.hibernate.search.test.SearchTestCase; import org.hibernate.search.test.analyzer.inheritance.ISOLatin1Analyzer; +import org.hibernate.search.test.id.providedId.ManualTransactionContext; = /** * @author Emmanuel Bernard @@ -320,6 +323,9 @@ = = public void testProvidedIdMapping() throws Exception{ + FullTextSession fullTextSession =3D Search.getFullTextSession( openSessi= on() ); + SearchFactoryImplementor sf =3D (SearchFactoryImplementor) fullTextSessi= on.getSearchFactory(); + = ProvidedIdEntry person1 =3D new ProvidedIdEntry(); person1.setName( "Big Goat" ); person1.setBlurb( "Eats grass" ); @@ -332,17 +338,18 @@ person3.setName( "Regular goat" ); person3.setBlurb( "Is anorexic" ); = - Session session =3D openSession(); - FullTextSession fullTextSession =3D Search.getFullTextSession( session ); - Transaction transaction =3D session.beginTransaction(); - session.persist( person1 ); - session.persist( person2 ); - session.persist( person3 ); + ManualTransactionContext tc =3D new ManualTransactionContext(); = - transaction.commit(); - session.clear(); + Work work =3D new Work( person1, 1, Wo= rkType.INDEX ); + sf.getWorker().performWork( work, tc ); + work =3D new Work( person2, 2, WorkType.INDEX ); + sf.getWorker().performWork( work, tc ); + Work work2 =3D new Work( person3, 3, W= orkType.INDEX ); + sf.getWorker().performWork( work2, tc ); = - transaction =3D fullTextSession.beginTransaction(); + tc.end(); + = + Transaction transaction =3D fullTextSession.beginTransaction(); = QueryParser parser =3D new QueryParser( "providedidentry.name", new Stan= dardAnalyzer() ); Query luceneQuery =3D parser.parse( "Goat" ); @@ -364,7 +371,7 @@ = = = - public void testFullTextFilterDef() throws Exception{ + public void testFullTextFilterDefAtMappingLevel() throws Exception{ FullTextSession s =3D Search.getFullTextSession( openSession() ); Transaction tx =3D s.beginTransaction(); = @@ -408,7 +415,6 @@ s.close(); } = - = public void testIndexEmbedded() throws Exception{ FullTextSession s =3D Search.getFullTextSession( openSession() ); Transaction tx =3D s.beginTransaction(); @@ -514,7 +520,8 @@ //cfg.setProperty( "hibernate.search.default.directory_provider", FSDire= ctoryProvider.class.getName() ); SearchMapping mapping =3D new SearchMapping(); = - mapping.analyzerDef( "ngram", StandardTokenizerFactory.class ) + mapping.fullTextFilterDef("security", SecurityFilterFactory.class).cache= (FilterCacheModeType.INSTANCE_ONLY) + .analyzerDef( "ngram", StandardTokenizerFactory.class ) .filter( LowerCaseFilterFactory.class ) .filter( NGramFilterFactory.class ) .param( "minGramSize", "3" ) @@ -525,10 +532,10 @@ .analyzerDef( "de", StandardTokenizerFactory.class ) .filter( LowerCaseFilterFactory.class ) .filter( GermanStemFilterFactory.class ) - .entity( Address.class ).indexed() + .entity( Address.class ) + .indexed() .similarity( DefaultSimilarity.class ) .boost( 2 ) - .fullTextFilterDef("security", SecurityFilterFactory.class).cache(Fil= terCacheModeType.INSTANCE_ONLY) .property( "addressId", ElementType.FIELD ).documentId().name( "id" ) .property("lastUpdated", ElementType.FIELD) .field().name("last-updated") --===============3752904843280994846==-- From hibernate-commits at lists.jboss.org Fri Nov 27 15:04:42 2009 Content-Type: multipart/mixed; boundary="===============4925159512642852186==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18079 - annotations/branches. Date: Fri, 27 Nov 2009 15:04:42 -0500 Message-ID: <200911272004.nARK4gbr016032@svn01.web.mwc.hst.phx2.redhat.com> --===============4925159512642852186== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 15:04:42 -0500 (Fri, 27 Nov 2009) New Revision: 18079 Added: annotations/branches/v3_4_0_GA_CP-r17982/ Log: JBPAPP-3150 create branch v3_4_0_GA_CP-r17982, for resurrectting the log in= fo Copied: annotations/branches/v3_4_0_GA_CP-r17982 (from rev 17982, annotatio= ns/branches/v3_4_0_GA_CP) --===============4925159512642852186==-- From hibernate-commits at lists.jboss.org Fri Nov 27 15:37:45 2009 Content-Type: multipart/mixed; boundary="===============3569156963624774377==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18080 - annotations/branches/v3_4_0_GA_CP-r17982. Date: Fri, 27 Nov 2009 15:37:44 -0500 Message-ID: <200911272037.nARKbiVj021259@svn01.web.mwc.hst.phx2.redhat.com> --===============3569156963624774377== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 15:37:44 -0500 (Fri, 27 Nov 2009) New Revision: 18080 Removed: annotations/branches/v3_4_0_GA_CP-r17982/build.properties.dist annotations/branches/v3_4_0_GA_CP-r17982/build.xml annotations/branches/v3_4_0_GA_CP-r17982/common-build.xml annotations/branches/v3_4_0_GA_CP-r17982/ivy.xml annotations/branches/v3_4_0_GA_CP-r17982/ivy/ annotations/branches/v3_4_0_GA_CP-r17982/jdbc/ annotations/branches/v3_4_0_GA_CP-r17982/lib/ Modified: annotations/branches/v3_4_0_GA_CP-r17982/pom.xml Log: JBPAPP-3150 remove unnecessary ivy stuff and update pom.xml Deleted: annotations/branches/v3_4_0_GA_CP-r17982/build.properties.dist =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/build.properties.dist 2009-11-= 27 20:04:42 UTC (rev 18079) +++ annotations/branches/v3_4_0_GA_CP-r17982/build.properties.dist 2009-11-= 27 20:37:44 UTC (rev 18080) @@ -1,3 +0,0 @@ -common.dir=3D. -src.dir=3Dsrc -test.dir=3Dtest Deleted: annotations/branches/v3_4_0_GA_CP-r17982/build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/build.xml 2009-11-27 20:04:42 = UTC (rev 18079) +++ annotations/branches/v3_4_0_GA_CP-r17982/build.xml 2009-11-27 20:37:44 = UTC (rev 18080) @@ -1,232 +0,0 @@ - - - - = - - - - = - - - - - - - - - - - - = - - - = - - = - - - - - - - - - - = - - - - - - - - - - - - = - - - - - - - - - - = - - = - - - - - - - - - - - - = - - - - - - - = - - - - - - - - - - - - - - - - - - - = - - - - - - - - Running against db: @{db} - - - - - - - - - - - - = - - - - - - - - - Running against db: @{db} - - - - - - - - - - = - - - - - - - - - - = - - - = - - - - - - - = - - - - - - - - - - - = - - - - - - - - - - - - - = - = - - - = - - - - - = - - - - - - - - - = - Deleted: annotations/branches/v3_4_0_GA_CP-r17982/common-build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/common-build.xml 2009-11-27 20= :04:42 UTC (rev 18079) +++ annotations/branches/v3_4_0_GA_CP-r17982/common-build.xml 2009-11-27 20= :37:44 UTC (rev 18080) @@ -1,455 +0,0 @@ - - - Common properties and targets for the HibernateExt - project - = - = - - - = - - - - = - = - - - - - - - - - - - - - - - = - - - = - - - - - - - = - - - - - - = - - - = - - - - - - - - - - = - - - - - - - - - - = - - - - - - - - - = - - - - - - - - = - - - - = - - = - - - - - = - - - = - - - - - - - - = - - - - - - - - - - - = - - - - - = - - - - - = - - - - = - - - - - - - - = - - - - - - - - - = - - - - - = - - - - - - - - = - - - = - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - - - - - = - - - - = - = - - - - = - = - - - - - - - = - - - - - - - - - - - - - - - - - - - - - = - - - - - - - - - - - - = - - - - - - - - - = - - - - - = - - - - - = - - = - - - - - - - - - = - - - - - - - - - - - - - - - - - - = - - - - - - - - - = - - - - - - - - - - - - - - - - = - - - - - - - - - - - = - - = - - - - = - - - - - - - - - = - = - - - - - - - - Running against db: @{db} - - - - - - - - - - - - = - - - - - - - - - = - - - - - - - - - - = - - - - - - - - = - - - - = - - - - - - - - - = - - = - - - - = - - - - - - - - - = - Deleted: annotations/branches/v3_4_0_GA_CP-r17982/ivy.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/ivy.xml 2009-11-27 20:04:42 UT= C (rev 18079) +++ annotations/branches/v3_4_0_GA_CP-r17982/ivy.xml 2009-11-27 20:37:44 UT= C (rev 18080) @@ -1,36 +0,0 @@ - - - - - - - - - - - - - default"/> - default"/> - default"/> - default"/> - default"/> - - - - default"/> - default"/> - - - default"/> - d= efault"/> - default"/> - default"/> - default"/> - default"/> - default"/> - - \ No newline at end of file Modified: annotations/branches/v3_4_0_GA_CP-r17982/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/pom.xml 2009-11-27 20:04:42 UT= C (rev 18079) +++ annotations/branches/v3_4_0_GA_CP-r17982/pom.xml 2009-11-27 20:37:44 UT= C (rev 18080) @@ -1,52 +1,653 @@ - + 4.0.0 org.hibernate hibernate-annotations jar - @version@ + 3.4.0.GA = Hibernate Annotations Annotations metadata for Hibernate http://annotations.hibernate.org = + + Hibernate.org + http://hibernate.org + + - GNU LESSER GENERAL PUBLIC LICENSE - http://www.gnu.org/licenses/lgpl.txt + GNU Lesser General Public License + http://www.gnu.org/licenses/lgpl-2.1.html + See discussion at http://hibernate.org/356.html for more + details. + repo + + JIRA + http://opensource.atlassian.com/projects/hibernate/browse/ANN= + + + scm:svn:http://anonsvn.jboss.org/repos/hibernate/annot= ations/branches/v3_4_0_GA_CP + scm:svn:https://svn.jboss.org/repos/hibernate= /annotations/branches/v3_4_0_GA_CP + http://fisheye.jboss.com/browse/Hibernate/annotations/branche= s/v3_4_0_GA_CP + = org.hibernate + hibernate-core + 3.3.2.GA + + + org.hibernate ejb3-persistence 1.0.2.GA - + org.hibernate hibernate-commons-annotations 3.1.0.GA - - org.hibernate - hibernate-core - 3.3.0.SP1 + + org.slf4j + slf4j-api + ${slf4jVersion} - org.slf4j - slf4j-api - 1.4.2 - - dom4j dom4j 1.6.1 - + + + + + junit + junit + 3.8.1 + test + + + org.slf4j + jcl-over-slf4j + ${slf4jVersion} + test + + + org.slf4j + slf4j-log4j12 + ${slf4jVersion} + test + + + commons-logging + commons-logging + 99.0-does-not-exist + test + + + commons-logging + commons-logging-api + 99.0-does-not-exist + test + + + javassist + javassist + 3.9.0.GA + test + + + cglib + cglib + 2.2 + test + = + + + + + false + src/test/java + + **/*.xml + + + + true + src/test/resources + + + + + org.jboss.maven.plugins + maven-injection-plugin + 1.0.0 + + + compile + + bytecode + + + + + + + ${pom.version} + + + org.hibernate.cfg.annotations.Version + VERSION + > + + + + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-java + + enforce + + + + + [1.5,) + + + (2.0.7,) + + + + + + + + org.jboss.maven.plugins + maven-test-ext-plugin + 1.1.0 + + + + extend + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + org.apache.maven.plugins + maven-jar-plugin + + + false + + true + true + + + jcp.org + 1.0 + Java Persistence + hibernate.org + http://annotations.hibernate.org + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + maven-assembly-plugin + + + src/main/assembly/dist.xml + + + + + org.jboss.maven.plugins + maven-jdocbook-plugin + 2.2.0 + true + + + org.hibernate + hibernate-jdocbook-style + 2.0.0 + jdocbook-style + + + + master.xml + ${basedir}/src/main/docbook + en + + ${basedir}/src/main/docbook/en/= images + + + + pdf + classpath:/xslt/or= g/hibernate/jdocbook/xslt/pdf.xsl + hibernate_annotations_refer= ence.pdf + + + html_single + classpath:/xslt/or= g/hibernate/jdocbook/xslt/xhtml-single.xsl + + index.html + + + html + classpath:/xslt/or= g/hibernate/jdocbook/xslt/xhtml.xsl + + index.html + + + + true + saxon + + + 1.72.0 + - + + + + + make-doc + package + + resources + generate + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + http://java.sun.com/j2se/1.5.0/docs/api/ + http://java.sun.com/javaee/5/docs/api/ + + ${basedir}/src/main/javadoc/jdstyle.css + + + + make-doc + package + + javadoc + + + + + + + + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.4.3 + + = + + org.apache.maven.plugins + maven-jxr-plugin + 2.1 + + + org.apache.maven.plugins + maven-pmd-plugin + 2.2 + + true + 100 + 1.5 + + + + org.codehaus.mojo + taglist-maven-plugin + 2.1 + + + @FIXME + @fixme + FIXME + fixme + @TODO + @todo + TODO + todo + + + + + + org.codehaus.mojo + javancss-maven-plugin + 2.0-beta-2 + + + org.codehaus.mojo + findbugs-maven-plugin + 1.1.1 + + org.hibernate.* + + + + + + + + + + hsqldb + + true + + + + hsqldb + hsqldb + 1.8.0.2 + + + + org.hibernate.dialect.HSQLDialect + org.hsqldb.jdbcDriver + jdbc:hsqldb:target/test/db/hsqldb/hibernate + sa + + + + + + + + h2 + + + org.h2database + h2database + 1.0.20061217 + + + + org.hibernate.dialect.H2Dialect + org.h2.Driver + jdbc:h2:mem:target/test/db/h2/hibernate + sa + + + + + + + + + + mysql5 + + + mysql + mysql-connector-java + 5.0.5 + + + + org.hibernate.dialect.MySQL5InnoDBDialect + com.mysql.jdbc.Driver + jdbc:mysql://vmg08.mw.lab.eng.bos.redhat.com/hibbr330 + hibbr330 + hibbr330 + + + + + + + postgresql823 + + + postgresql + postgresql + 8.2-504 + jdbc3 + + + + org.hibernate.dialect.PostgreSQLDialect + org.postgresql.Driver + jdbc:postgresql://dev01.qa.atl.jboss.com:5432:hibbr330 + hibbr330 + hibbr330 + + + + + + + + + db2v82 + + + com.ibm + db2jcc + 3.1.57 + + + com.ibm + db2jcc_license_cu + 3.1.57 + + + + org.hibernate.dialect.DB2Dialect + com.ibm.db2.jcc.DB2Driver + jdbc:db2://dev32.qa.atl.jboss.com:50000/jbossqa + hibbr330 + hibbr330 + + + + + + + db2v91 + + + com.ibm + db2jcc + 3.1.57 + + + com.ibm + db2jcc_license_cu + 3.1.57 + + + + org.hibernate.dialect.DB2Dialect + com.ibm.db2.jcc.DB2Driver + jdbc:db2://dev67.qa.atl.jboss.com:50000/jbossqa + hibbr330 + hibbr330 + + + + + + + oracle9i + + + com.oracle + ojdbc14 + + 10.0.2.0 + + + + org.hibernate.dialect.Oracle9iDialect + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa + hibbr330 + hibbr330 + + + + + + + oracle10g + + + com.oracle + ojdbc14 + + 10.0.2.0 + + + + org.hibernate.dialect.Oracle10gDialect + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@dev01.qa.atl.jboss.com:1521:qadb01 + hibbr330 + hibbr330 + + + + + + + sybase15 + + + com.sybase + jconnect + 6.0.5 + + + + org.hibernate.dialect.SybaseASE15Dialect + com.sybase.jdbc3.jdbc.SybDriver + jdbc:sybase:Tds:dev77.qa.atl2.redhat.com:5000/hibbr330 + hibbr330 + hibbr330 + + + + + + + mssql2005 + + + com.microsoft.sqlserver + msjdbc + 1.1 + + + + org.hibernate.dialect.SQLServerDialect + com.microsoft.sqlserver.jdbc.SQLServerDriver + jdbc:sqlserver://dev30.qa.atl.jboss.com:3918 + hibbr330 + hibbr330 + 4096 + + + + + + 1.5.8 + \ No newline at end of file --===============3569156963624774377==-- From hibernate-commits at lists.jboss.org Fri Nov 27 15:43:04 2009 Content-Type: multipart/mixed; boundary="===============7530649761214245623==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18081 - in annotations/branches/v3_4_0_GA_CP-r17982/src: main and 1 other directories. Date: Fri, 27 Nov 2009 15:43:03 -0500 Message-ID: <200911272043.nARKh33L022480@svn01.web.mwc.hst.phx2.redhat.com> --===============7530649761214245623== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 15:43:03 -0500 (Fri, 27 Nov 2009) New Revision: 18081 Added: annotations/branches/v3_4_0_GA_CP-r17982/src/main/ annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/ Removed: annotations/branches/v3_4_0_GA_CP-r17982/src/filters/ annotations/branches/v3_4_0_GA_CP-r17982/src/java/ Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/org/hibernate/ann= otations/SQLDelete.java annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/org/hibernate/ann= otations/SQLInsert.java annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/org/hibernate/ann= otations/SQLUpdate.java Log: create src/main directory move src/java into src/main/java remove src/filters directory = Copied: annotations/branches/v3_4_0_GA_CP-r17982/src/main/java (from rev 18= 079, annotations/branches/v3_4_0_GA_CP-r17982/src/java) Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/org/hibern= ate/annotations/SQLDelete.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/java/org/hibernate/annotat= ions/SQLDelete.java 2009-11-27 20:04:42 UTC (rev 18079) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/org/hibernate/an= notations/SQLDelete.java 2009-11-27 20:43:03 UTC (rev 18081) @@ -1,4 +1,4 @@ -//$Id:$ +//$Id$ package org.hibernate.annotations; = import static java.lang.annotation.ElementType.TYPE; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/org/hibern= ate/annotations/SQLInsert.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/java/org/hibernate/annotat= ions/SQLInsert.java 2009-11-27 20:04:42 UTC (rev 18079) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/org/hibernate/an= notations/SQLInsert.java 2009-11-27 20:43:03 UTC (rev 18081) @@ -1,4 +1,4 @@ -//$Id:$ +//$Id$ package org.hibernate.annotations; = import static java.lang.annotation.ElementType.TYPE; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/org/hibern= ate/annotations/SQLUpdate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/java/org/hibernate/annotat= ions/SQLUpdate.java 2009-11-27 20:04:42 UTC (rev 18079) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/org/hibernate/an= notations/SQLUpdate.java 2009-11-27 20:43:03 UTC (rev 18081) @@ -1,4 +1,4 @@ -//$Id:$ +//$Id$ package org.hibernate.annotations; = import static java.lang.annotation.ElementType.TYPE; --===============7530649761214245623==-- From hibernate-commits at lists.jboss.org Fri Nov 27 15:48:53 2009 Content-Type: multipart/mixed; boundary="===============3949024414185086731==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18082 - in annotations/branches/v3_4_0_GA_CP-r17982: src/main and 1 other directory. Date: Fri, 27 Nov 2009 15:48:52 -0500 Message-ID: <200911272048.nARKmqkF023097@svn01.web.mwc.hst.phx2.redhat.com> --===============3949024414185086731== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 15:48:52 -0500 (Fri, 27 Nov 2009) New Revision: 18082 Added: annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/ annotations/branches/v3_4_0_GA_CP-r17982/src/main/javadoc/ Removed: annotations/branches/v3_4_0_GA_CP-r17982/doc/api/ annotations/branches/v3_4_0_GA_CP-r17982/doc/reference/ Log: move doc/api into src/main/javadoc move doc/reference into src/main/docbook Copied: annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook (from rev= 18079, annotations/branches/v3_4_0_GA_CP-r17982/doc/reference) Copied: annotations/branches/v3_4_0_GA_CP-r17982/src/main/javadoc (from rev= 18079, annotations/branches/v3_4_0_GA_CP-r17982/doc/api) --===============3949024414185086731==-- From hibernate-commits at lists.jboss.org Fri Nov 27 15:56:32 2009 Content-Type: multipart/mixed; boundary="===============1391785063439616773==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18083 - annotations/branches/v3_4_0_GA_CP-r17982. Date: Fri, 27 Nov 2009 15:56:32 -0500 Message-ID: <200911272056.nARKuWh8024276@svn01.web.mwc.hst.phx2.redhat.com> --===============1391785063439616773== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 15:56:32 -0500 (Fri, 27 Nov 2009) New Revision: 18083 Removed: annotations/branches/v3_4_0_GA_CP-r17982/doc/ Log: JBPAPP-3150 remove doc directory, now the doc source has been moved into sr= c/main/docbook directory --===============1391785063439616773==-- From hibernate-commits at lists.jboss.org Fri Nov 27 15:58:26 2009 Content-Type: multipart/mixed; boundary="===============1375376222079405557==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18084 - annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook. Date: Fri, 27 Nov 2009 15:58:26 -0500 Message-ID: <200911272058.nARKwQiC024416@svn01.web.mwc.hst.phx2.redhat.com> --===============1375376222079405557== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 15:58:26 -0500 (Fri, 27 Nov 2009) New Revision: 18084 Removed: annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/README annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/build.xml annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/docbook-common= -build.xml annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/support/ Log: JBPAPP-3510 remove unnecessary docbook build script, now the docbook will b= e built by maven jdocbook plugin Deleted: annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/README =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/README 2009-1= 1-27 20:56:32 UTC (rev 18083) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/README 2009-1= 1-27 20:58:26 UTC (rev 18084) @@ -1,9 +0,0 @@ -We're using the DocBook XSL distribution for HTML and PDF -generation. The best results can be achieved with the -Saxon XSLT processor (don't use Xalan!) and the Apache -FOP library. - -The documentation is generated with the distribution -build.xml target 'doc'. - -christian(a)hibernate.org Deleted: annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/build.xml 200= 9-11-27 20:56:32 UTC (rev 18083) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/build.xml 200= 9-11-27 20:58:26 UTC (rev 18084) @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - Deleted: annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/docbook-= common-build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/docbook-commo= n-build.xml 2009-11-27 20:56:32 UTC (rev 18083) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/main/docbook/docbook-commo= n-build.xml 2009-11-27 20:58:26 UTC (rev 18084) @@ -1,209 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --===============1375376222079405557==-- From hibernate-commits at lists.jboss.org Fri Nov 27 16:01:32 2009 Content-Type: multipart/mixed; boundary="===============1265640233424392461==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18085 - in annotations/branches/v3_4_0_GA_CP-r17982/src/main: assembly and 1 other directory. Date: Fri, 27 Nov 2009 16:01:31 -0500 Message-ID: <200911272101.nARL1V1e025098@svn01.web.mwc.hst.phx2.redhat.com> --===============1265640233424392461== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 16:01:31 -0500 (Fri, 27 Nov 2009) New Revision: 18085 Added: annotations/branches/v3_4_0_GA_CP-r17982/src/main/assembly/ annotations/branches/v3_4_0_GA_CP-r17982/src/main/assembly/dist.xml Log: JBPAPP-3150 add assembly/dist.xml for assembing the distribution Added: annotations/branches/v3_4_0_GA_CP-r17982/src/main/assembly/dist.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/main/assembly/dist.xml = (rev 0) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/main/assembly/dist.xml 200= 9-11-27 21:01:31 UTC (rev 18085) @@ -0,0 +1,43 @@ + + + dist + + + zip + + + + + false + lib + runtime + + + + + + target + . + + *.jar + + + + target/site/apidocs + docs/api + + + target/docbook/publish/en + docs/manual/en + + + . + + true + + **/target/** + + + + --===============1265640233424392461==-- From hibernate-commits at lists.jboss.org Fri Nov 27 16:06:08 2009 Content-Type: multipart/mixed; boundary="===============2767541737640126167==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18086 - in annotations/branches/v3_4_0_GA_CP-r17982/src/main: java/org/hibernate and 3 other directories. Date: Fri, 27 Nov 2009 16:06:08 -0500 Message-ID: <200911272106.nARL68HT026003@svn01.web.mwc.hst.phx2.redhat.com> --===============2767541737640126167== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 16:06:07 -0500 (Fri, 27 Nov 2009) New Revision: 18086 Added: annotations/branches/v3_4_0_GA_CP-r17982/src/main/resources/ annotations/branches/v3_4_0_GA_CP-r17982/src/main/resources/org/ annotations/branches/v3_4_0_GA_CP-r17982/src/main/resources/org/hibernat= e/ annotations/branches/v3_4_0_GA_CP-r17982/src/main/resources/org/hibernat= e/ejb/ Removed: annotations/branches/v3_4_0_GA_CP-r17982/src/main/java/org/hibernate/ejb/ Log: JBPAPP-3150 move orm_1_0.xsd from java directory into resource directory Copied: annotations/branches/v3_4_0_GA_CP-r17982/src/main/resources/org/hib= ernate/ejb (from rev 18084, annotations/branches/v3_4_0_GA_CP-r17982/src/ma= in/java/org/hibernate/ejb) --===============2767541737640126167==-- From hibernate-commits at lists.jboss.org Fri Nov 27 16:12:07 2009 Content-Type: multipart/mixed; boundary="===============4049223248766688139==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18087 - in annotations/branches/v3_4_0_GA_CP-r17982/src: test and 6 other directories. Date: Fri, 27 Nov 2009 16:12:07 -0500 Message-ID: <200911272112.nARLC70l027636@svn01.web.mwc.hst.phx2.redhat.com> --===============4049223248766688139== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 16:12:06 -0500 (Fri, 27 Nov 2009) New Revision: 18087 Added: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/ annotations/branches/v3_4_0_GA_CP-r17982/src/test/resources/ Removed: annotations/branches/v3_4_0_GA_CP-r17982/src/test-resources/ annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/ Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/RequiresDialect.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/A.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/A_PK.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/B.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/C.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/ClassA.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/ClassB.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/ClassC.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/ClassD.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/D.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/D_PK.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/fkcircularity/FkCircularityTest.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/id/entities/Planet.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/namingstrategy/Address.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/namingstrategy/DummyNamingStrategy.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/namingstrategy/NamingStrategyTest.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/tes= t/annotations/namingstrategy/Person.java annotations/branches/v3_4_0_GA_CP-r17982/src/test/resources/hibernate.pr= operties Log: JBPAPP-3150 update test directory - move test/org into test/java - move test-resource/* into test/resources - update hibernate.properties = Copied: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org (from re= v 18082, annotations/branches/v3_4_0_GA_CP-r17982/src/test/org) Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/RequiresDialect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/RequiresDialect.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/RequiresDialect.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations; = import java.lang.annotation.ElementType; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/A.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/A.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/A.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import javax.persistence.EmbeddedId; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/A_PK.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/A_PK.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/A_PK.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import java.io.Serializable; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/B.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/B.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/B.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import javax.persistence.Entity; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/C.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/C.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/C.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import javax.persistence.Entity; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/ClassA.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/ClassA.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/ClassA.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import javax.persistence.Column; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/ClassB.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/ClassB.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/ClassB.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import javax.persistence.Entity; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/ClassC.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/ClassC.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/ClassC.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import javax.persistence.Entity; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/ClassD.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/ClassD.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/ClassD.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import javax.persistence.Entity; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/D.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/D.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/D.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import javax.persistence.EmbeddedId; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/D_PK.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/D_PK.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/D_PK.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import java.io.Serializable; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/fkcircularity/FkCircularityTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/fkcircularity/FkCircularityTest.java 2009-11-27 20:48:52 UTC (rev= 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/fkcircularity/FkCircularityTest.java 2009-11-27 21:12:06 UTC= (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.fkcircularity; = import java.io.PrintWriter; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/id/entities/Planet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/id/entities/Planet.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/id/entities/Planet.java 2009-11-27 21:12:06 UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.id.entities; = public enum Planet { Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/namingstrategy/Address.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/namingstrategy/Address.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/namingstrategy/Address.java 2009-11-27 21:12:06 UTC (rev 180= 87) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.namingstrategy; = import javax.persistence.Entity; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/namingstrategy/DummyNamingStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/namingstrategy/DummyNamingStrategy.java 2009-11-27 20:48:52 UTC (= rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/namingstrategy/DummyNamingStrategy.java 2009-11-27 21:12:06 = UTC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.namingstrategy; = import org.hibernate.cfg.EJB3NamingStrategy; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/namingstrategy/NamingStrategyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/namingstrategy/NamingStrategyTest.java 2009-11-27 20:48:52 UTC (r= ev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/namingstrategy/NamingStrategyTest.java 2009-11-27 21:12:06 U= TC (rev 18087) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.namingstrategy; = import java.io.PrintWriter; Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibern= ate/test/annotations/namingstrategy/Person.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test/org/hibernate/test/an= notations/namingstrategy/Person.java 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/java/org/hibernate/te= st/annotations/namingstrategy/Person.java 2009-11-27 21:12:06 UTC (rev 1808= 7) @@ -1,4 +1,4 @@ -// $Id:$ +// $Id$ package org.hibernate.test.annotations.namingstrategy; = import java.util.HashSet; Copied: annotations/branches/v3_4_0_GA_CP-r17982/src/test/resources (from r= ev 18082, annotations/branches/v3_4_0_GA_CP-r17982/src/test-resources) Modified: annotations/branches/v3_4_0_GA_CP-r17982/src/test/resources/hiber= nate.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- annotations/branches/v3_4_0_GA_CP-r17982/src/test-resources/hibernate.p= roperties 2009-11-27 20:48:52 UTC (rev 18082) +++ annotations/branches/v3_4_0_GA_CP-r17982/src/test/resources/hibernate.p= roperties 2009-11-27 21:12:06 UTC (rev 18087) @@ -19,12 +19,14 @@ ### Platforms ### ################# = -hibernate.dialect @hibernate.dialect@ -hibernate.connection.driver_class @hibernate.connection.driver_class@ -hibernate.connection.username @hibernate.connection.username@ -hibernate.connection.password @hibernate.connection.password@ -hibernate.connection.url @hibernate.connection.url@ +hibernate.dialect ${db.dialect} +hibernate.connection.driver_class ${jdbc.driver} +hibernate.connection.url ${jdbc.url} +hibernate.connection.username ${jdbc.user} +hibernate.connection.password ${jdbc.pass} +hibernate.connection.isolation ${jdbc.isolation} = + ################################# ### Hibernate Connection Pool ### ################################# --===============4049223248766688139==-- From hibernate-commits at lists.jboss.org Fri Nov 27 16:20:16 2009 Content-Type: multipart/mixed; boundary="===============5890168590211808105==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18088 - annotations/branches. Date: Fri, 27 Nov 2009 16:20:16 -0500 Message-ID: <200911272120.nARLKG4u029226@svn01.web.mwc.hst.phx2.redhat.com> --===============5890168590211808105== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 16:20:16 -0500 (Fri, 27 Nov 2009) New Revision: 18088 Removed: annotations/branches/v3_4_0_GA_CP/ Log: JBPAPP-3150 delete this branch, will recreate it later, from branch v3_4_0_= GA_CP --===============5890168590211808105==-- From hibernate-commits at lists.jboss.org Fri Nov 27 16:22:33 2009 Content-Type: multipart/mixed; boundary="===============7320329711879286734==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18089 - annotations/branches. Date: Fri, 27 Nov 2009 16:22:33 -0500 Message-ID: <200911272122.nARLMXdg029655@svn01.web.mwc.hst.phx2.redhat.com> --===============7320329711879286734== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 16:22:33 -0500 (Fri, 27 Nov 2009) New Revision: 18089 Added: annotations/branches/v3_4_0_GA_CP/ Removed: annotations/branches/v3_4_0_GA_CP-r17982/ Log: JBPAPP-3150 recreate branch v3_4_0_GA_CP branch from branch v3_4_0_GA_CP-r1= 7982 Copied: annotations/branches/v3_4_0_GA_CP (from rev 18088, annotations/bran= ches/v3_4_0_GA_CP-r17982) --===============7320329711879286734==-- From hibernate-commits at lists.jboss.org Fri Nov 27 20:12:19 2009 Content-Type: multipart/mixed; boundary="===============9056394060547402003==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18090 - core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test. Date: Fri, 27 Nov 2009 20:12:19 -0500 Message-ID: <200911280112.nAS1CJ1r016090@svn01.web.mwc.hst.phx2.redhat.com> --===============9056394060547402003== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: stliu Date: 2009-11-27 20:12:19 -0500 (Fri, 27 Nov 2009) New Revision: 18090 Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/AllTests.java Log: JBPAPP-3179 add MigrationTest into AllTest Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/AllTest= s.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/AllTests.java= 2009-11-27 21:22:33 UTC (rev 18089) +++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/AllTests.java= 2009-11-28 01:12:19 UTC (rev 18090) @@ -110,6 +110,7 @@ import org.hibernate.test.readonly.ReadOnlyVersionedNodesTest; import org.hibernate.test.reattachment.ReattachmentSuite; import org.hibernate.test.rowid.RowIdTest; +import org.hibernate.test.schemaupdate.MigrationTest; import org.hibernate.test.sorted.SortTest; import org.hibernate.test.sql.NativeSqlSupportSuite; import org.hibernate.test.stats.SessionStatsTest; @@ -311,7 +312,7 @@ suite.addTest( DialectUnitTestsSuite.suite() ); suite.addTest( InsertOrderingTest.suite() ); suite.addTest( ReattachmentSuite.suite() ); - + suite.addTest( MigrationTest.suite() ); return suite; } = --===============9056394060547402003==-- From hibernate-commits at lists.jboss.org Sun Nov 29 11:13:55 2009 Content-Type: multipart/mixed; boundary="===============8378674867170184934==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18091 - in search/trunk: hibernate-search-archetype and 4 other directories. Date: Sun, 29 Nov 2009 11:13:55 -0500 Message-ID: <200911291613.nATGDte2013072@svn01.web.mwc.hst.phx2.redhat.com> --===============8378674867170184934== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-29 11:13:55 -0500 (Sun, 29 Nov 2009) New Revision: 18091 Modified: search/trunk/changelog.txt search/trunk/hibernate-search-archetype/pom.xml search/trunk/hibernate-search-archetype/src/main/resources/archetype-res= ources/pom.xml search/trunk/pom.xml search/trunk/readme.txt search/trunk/src/main/docbook/en-US/master.xml search/trunk/src/main/docbook/en-US/modules/getting-started.xml search/trunk/src/main/java/org/hibernate/search/Version.java Log: Fixed configuration of release plugin. Updated all version references to re= fer to 3.2.0.Beta1 Modified: search/trunk/changelog.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/changelog.txt 2009-11-28 01:12:19 UTC (rev 18090) +++ search/trunk/changelog.txt 2009-11-29 16:13:55 UTC (rev 18091) @@ -1,6 +1,65 @@ Hibernate Search Changelog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D = +3.2.0.Beta1 (30-11-2009) +------------------------ + +** Sub-task + * [HSEARCH-410] - Write documentation for what's available of the prog= rammatic mapping API (Amin Mohammed-Coleman) + * [HSEARCH-412] - Provide the main mapping artifacts programmatically + +** Bug + * [HSEARCH-178] - Out of transaction work causes collection lazy loadi= ng to throw AssertionFailure + * [HSEARCH-332] - documentation errors: org.hibernate.Query should be= javax.persistence.Query + * [HSEARCH-353] - removing an entity and adding another with same PK = (in same TX) will not add second entity to index + * [HSEARCH-355] - FilterOptimizationHelper was improperly using method= overloading + * [HSEARCH-357] - IdBridge being applied on null entity during purgeAl= l() + * [HSEARCH-366] - typo in Discriminator.getAnanyzerDefinitionName() + * [HSEARCH-367] - Support only one kind of Similarity per index + * [HSEARCH-380] - Duplicate classes from Maven transitive dependencies= (incompatible version of solr-lucene-core) + * [HSEARCH-391] - Two-Level embedded objects don't get an index update + * [HSEARCH-394] - @ProvidedId gets ignored + * [HSEARCH-398] - NPE when named FullTextFilter is disabled without be= ing enabled first + * [HSEARCH-418] - ProvidedIdTest fails + +** Deprecation + * [HSEARCH-201] - IndexWriter settings meant for transactional operati= ons won't be inherited by the settings meant for batch operations + +** Improvement + * [HSEARCH-246] - Run optimize at the end of the transaction even if f= lushToIndexes() is used + * [HSEARCH-284] - Be able to configure a LockFactory + * [HSEARCH-301] - Refactor JMSMasterTest and JMSSlaveTest + * [HSEARCH-327] - Capability to reuse IndexWriter instances across tra= nsactions + * [HSEARCH-328] - Add a builtin bridge for Calendar (Amin Mohammed-Col= eman) + * [HSEARCH-358] - @ClassBridge.impl is no longer defaulted + * [HSEARCH-365] - Update pom.xml to include database profiles for QA L= ab + * [HSEARCH-369] - typos in documentation + * [HSEARCH-384] - improve error messages for loading plugins and add c= onsistency to the performed checks + * [HSEARCH-404] - Update database profiles in pom.xml + +** New Feature + * [HSEARCH-218] - add indexAll( Class type ) to rebuild indexes from a= ll data + * [HSEARCH-251] - Query on a shard subset based on a filter activation= (Chase Seibert) + * [HSEARCH-324] - @DynamicBoost(BoostStrategy.class) + * [HSEARCH-334] - Create a builtin bridge for Character + * [HSEARCH-345] - Use any custom LockFactory + * [HSEARCH-347] - Adding a blackhole backend + * [HSEARCH-392] - Provide a JGroups based backend + + +** Task + * [HSEARCH-82] - Migrate from ant to maven2 + * [HSEARCH-326] - Drop support for IndexReader usage to update indexes. + * [HSEARCH-348] - Upgrade to Lucene 2.4.1 + * [HSEARCH-359] - Fix usage of deprecated Hibernate commons-annotation= s methods + * [HSEARCH-375] - Create pot files in order to allow translation of do= cumentation + * [HSEARCH-403] - Fix copyright notice and end-of-line terminators in = source code + * [HSEARCH-409] - Write documentation for JGroups based configuration = (Lukasz Moren) + * [HSEARCH-413] - Document all new features + * [HSEARCH-419] - Create a proper @ProvidedId test + * [HSEARCH-423] - Migrate to Hibernate Core 3.5 beta2 and JPA 2.0 CR1 + + 3.1.1.GA (28-05-2009) --------------------- = Modified: search/trunk/hibernate-search-archetype/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search-archetype/pom.xml 2009-11-28 01:12:19 UTC= (rev 18090) +++ search/trunk/hibernate-search-archetype/pom.xml 2009-11-29 16:13:55 UTC= (rev 18091) @@ -3,5 +3,5 @@ org.hibernate hibernate-search-quickstart jar - 3.1.0.GA + 3.2.0.Beta1 Modified: search/trunk/hibernate-search-archetype/src/main/resources/archet= ype-resources/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search-archetype/src/main/resources/archetype-re= sources/pom.xml 2009-11-28 01:12:19 UTC (rev 18090) +++ search/trunk/hibernate-search-archetype/src/main/resources/archetype-re= sources/pom.xml 2009-11-29 16:13:55 UTC (rev 18091) @@ -11,7 +11,7 @@ org.hibernate hibernate-search - 3.1.0.GA + 3.2.0.Beta1 cglib Modified: search/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/pom.xml 2009-11-28 01:12:19 UTC (rev 18090) +++ search/trunk/pom.xml 2009-11-29 16:13:55 UTC (rev 18091) @@ -290,8 +290,8 @@ maven-release-plugin release - package javadoc:javadoc org.jboss.maven.plugins= :maven-jdocbook-plugin:2.1.0:resources - org.jboss.maven.plugins:maven-jdocbook-plugin:2.1.= 0:generate assembly:assembly + package javadoc:javadoc org.jboss.maven.plugins= :maven-jdocbook-plugin:2.2.0:resources + org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.= 0:generate assembly:assembly Modified: search/trunk/readme.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/readme.txt 2009-11-28 01:12:19 UTC (rev 18090) +++ search/trunk/readme.txt 2009-11-29 16:13:55 UTC (rev 18091) @@ -1,6 +1,6 @@ Hibernate Search =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D -Version: 3.1.0.GA, 4.12.2008 +Version: 3.2.0.Beta1, 30.11.2009 = Description ----------- Modified: search/trunk/src/main/docbook/en-US/master.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/docbook/en-US/master.xml 2009-11-28 01:12:19 UTC = (rev 18090) +++ search/trunk/src/main/docbook/en-US/master.xml 2009-11-29 16:13:55 UTC = (rev 18091) @@ -25,7 +25,7 @@ --> + ]> Modified: search/trunk/src/main/docbook/en-US/modules/getting-started.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/docbook/en-US/modules/getting-started.xml 2009-11= -28 01:12:19 UTC (rev 18090) +++ search/trunk/src/main/docbook/en-US/modules/getting-started.xml 2009-11= -29 16:13:55 UTC (rev 18091) @@ -129,7 +129,7 @@ <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-search</artifactId> - <version>3.1.0.GA</version> + <version>3.2.0.Beta1</version> </dependency> <dependency> <groupId>org.hibernate</groupId> @@ -620,7 +620,7 @@ mvn archetype:create \ = -DarchetypeGroupId=3Dorg.hibernate \ -DarchetypeArtifactId=3Dhibernate-search-quickstart \ = - -DarchetypeVersion=3D3.1.0.GA \ + -DarchetypeVersion=3D3.2.0.Beta1 \ -DgroupId=3Dmy.company -DartifactId=3Dquickstart = Modified: search/trunk/src/main/java/org/hibernate/search/Version.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/java/org/hibernate/search/Version.java 2009-11-28= 01:12:19 UTC (rev 18090) +++ search/trunk/src/main/java/org/hibernate/search/Version.java 2009-11-29= 16:13:55 UTC (rev 18091) @@ -31,7 +31,7 @@ */ public class Version { = - public static final String VERSION =3D "3.2.0-SNAPSHOT"; + public static final String VERSION =3D "3.2.0.Beta1"; = static { LoggerFactory.make().info( "Hibernate Search {}", VERSION ); --===============8378674867170184934==-- From hibernate-commits at lists.jboss.org Mon Nov 30 06:26:55 2009 Content-Type: multipart/mixed; boundary="===============3040976408763876305==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18092 - search/trunk/hibernate-search-archetype/src/main/resources/archetype-resources. Date: Mon, 30 Nov 2009 06:26:55 -0500 Message-ID: <200911301126.nAUBQtRM002482@svn01.web.mwc.hst.phx2.redhat.com> --===============3040976408763876305== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-30 06:26:55 -0500 (Mon, 30 Nov 2009) New Revision: 18092 Modified: search/trunk/hibernate-search-archetype/src/main/resources/archetype-res= ources/pom.xml Log: updated archtype pom Modified: search/trunk/hibernate-search-archetype/src/main/resources/archet= ype-resources/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search-archetype/src/main/resources/archetype-re= sources/pom.xml 2009-11-29 16:13:55 UTC (rev 18091) +++ search/trunk/hibernate-search-archetype/src/main/resources/archetype-re= sources/pom.xml 2009-11-30 11:26:55 UTC (rev 18092) @@ -14,20 +14,10 @@ 3.2.0.Beta1 - cglib - cglib - 2.1_3 - = - org.hibernate - hibernate-annotations - 3.4.0.GA - - - org.hibernate hibernate-entitymanager - 3.4.0.GA - + 3.5.0-Beta-2 + = org.apache.solr solr-common @@ -41,7 +31,7 @@ org.apache.lucene lucene-snowball - 2.4.0 + 2.4.1 org.slf4j --===============3040976408763876305==-- From hibernate-commits at lists.jboss.org Mon Nov 30 07:41:17 2009 Content-Type: multipart/mixed; boundary="===============6197917246053316462==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18093 - in search/trunk/hibernate-search-archetype: src and 8 other directories. Date: Mon, 30 Nov 2009 07:41:16 -0500 Message-ID: <200911301241.nAUCfGPI021452@svn01.web.mwc.hst.phx2.redhat.com> --===============6197917246053316462== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-30 07:41:16 -0500 (Mon, 30 Nov 2009) New Revision: 18093 Added: search/trunk/hibernate-search-archetype/src/main/archetype/ search/trunk/hibernate-search-archetype/src/main/archetype/archetype.pro= perties search/trunk/hibernate-search-archetype/src/main/java/ search/trunk/hibernate-search-archetype/src/main/resources/META-INF/pers= istence.xml search/trunk/hibernate-search-archetype/src/main/resources/log4j.propert= ies search/trunk/hibernate-search-archetype/src/test/ search/trunk/hibernate-search-archetype/src/test/java/example/ Removed: search/trunk/hibernate-search-archetype/src/main/resources/META-INF/mave= n/ search/trunk/hibernate-search-archetype/src/main/resources/archetype-res= ources/pom.xml search/trunk/hibernate-search-archetype/src/main/resources/archetype-res= ources/src/ search/trunk/hibernate-search-archetype/src/test/java/java/example/ Modified: search/trunk/hibernate-search-archetype/pom.xml search/trunk/hibernate-search-archetype/src/test/java/example/IndexAndSe= archTest.java Log: HSEARCH-426 Modified: search/trunk/hibernate-search-archetype/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search-archetype/pom.xml 2009-11-30 11:26:55 UTC= (rev 18092) +++ search/trunk/hibernate-search-archetype/pom.xml 2009-11-30 12:41:16 UTC= (rev 18093) @@ -1,7 +1,104 @@ + - 4.0.0 - org.hibernate - hibernate-search-quickstart - jar - 3.2.0.Beta1 + 4.0.0 + org.hibernate + hibernate-search-quickstart + jar + 3.2.0-Beta1 + A custom project + http://www.myorganization.org + + + org.hibernate + hibernate-search + 3.2.0-SNAPSHOT + + + org.hibernate + hibernate-entitymanager + 3.5.0-Beta-2 + + + org.apache.solr + solr-common + 1.3.0 + true + + + org.apache.solr + solr-core + 1.3.0 + true + + + commons-httpclient + commons-httpclient + + + org.apache.solr + solr-solrj + + + woodstox + wstx-asl + + + net.java.dev.stax-utils + stax-utils + + + commons-logging + commons-logging + + + org.apache.solr + solr-lucene-core + + + + + org.apache.lucene + lucene-snowball + 2.4.1 + + + org.apache.lucene + lucene-analyzers + 2.4.1 + + + org.slf4j + slf4j-api + 1.4.2 + + + org.slf4j + slf4j-log4j12 + 1.4.2 + + + hsqldb + hsqldb + 1.8.0.2 + + + junit + junit + 4.4 + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.5 + 1.5 + + + + Added: search/trunk/hibernate-search-archetype/src/main/archetype/archetype= .properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search-archetype/src/main/archetype/archetype.pr= operties (rev 0) +++ search/trunk/hibernate-search-archetype/src/main/archetype/archetype.pr= operties 2009-11-30 12:41:16 UTC (rev 18093) @@ -0,0 +1,4 @@ +archetype.groupId=3Dorg.hibernate +archetype.artifactId=3Dhibernate-search-quickstart +archetype.version=3D3.2.0-Beta1 + Copied: search/trunk/hibernate-search-archetype/src/main/java (from rev 180= 90, search/trunk/hibernate-search-archetype/src/main/resources/archetype-re= sources/src/main/java) Copied: search/trunk/hibernate-search-archetype/src/main/resources/META-INF= /persistence.xml (from rev 18090, search/trunk/hibernate-search-archetype/s= rc/main/resources/archetype-resources/src/main/resources/META-INF/persisten= ce.xml) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search-archetype/src/main/resources/META-INF/per= sistence.xml (rev 0) +++ search/trunk/hibernate-search-archetype/src/main/resources/META-INF/per= sistence.xml 2009-11-30 12:41:16 UTC (rev 18093) @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + = + + + + + Deleted: search/trunk/hibernate-search-archetype/src/main/resources/archety= pe-resources/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search-archetype/src/main/resources/archetype-re= sources/pom.xml 2009-11-30 11:26:55 UTC (rev 18092) +++ search/trunk/hibernate-search-archetype/src/main/resources/archetype-re= sources/pom.xml 2009-11-30 12:41:16 UTC (rev 18093) @@ -1,71 +0,0 @@ - - - 4.0.0 - ${groupId} - ${artifactId} - jar - ${version} - A custom project - http://www.myorganization.org - - - org.hibernate - hibernate-search - 3.2.0.Beta1 - - - org.hibernate - hibernate-entitymanager - 3.5.0-Beta-2 - = - - org.apache.solr - solr-common - 1.3.0 - - - org.apache.solr - solr-core - 1.3.0 - - - org.apache.lucene - lucene-snowball - 2.4.1 - - - org.slf4j - slf4j-api - 1.4.2 - - - org.slf4j - slf4j-log4j12 - 1.4.2 - - - hsqldb - hsqldb - 1.8.0.2 - - - junit - junit - 4.4 - test - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.0.2 - - 1.5 - 1.5 - - - - - Copied: search/trunk/hibernate-search-archetype/src/main/resources/log4j.pr= operties (from rev 18090, search/trunk/hibernate-search-archetype/src/main/= resources/archetype-resources/src/main/resources/log4j.properties) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search-archetype/src/main/resources/log4j.proper= ties (rev 0) +++ search/trunk/hibernate-search-archetype/src/main/resources/log4j.proper= ties 2009-11-30 12:41:16 UTC (rev 18093) @@ -0,0 +1,31 @@ +### direct log messages to stdout ### +log4j.appender.stdout=3Dorg.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=3DSystem.out +log4j.appender.stdout.layout=3Dorg.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=3D%d{ABSOLUTE} %5p %c{1}:%L= - %m%n + +### direct messages to file hibernate.log ### +log4j.appender.file=3Dorg.apache.log4j.FileAppender +log4j.appender.file.File=3Dhibernate.log +log4j.appender.file.layout=3Dorg.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=3D%d{ABSOLUTE} %5p %c{1}:%L -= %m%n + +### direct messages to socket - chainsaw ### +log4j.appender.socket=3Dorg.apache.log4j.net.SocketAppender +log4j.appender.socket.remoteHost=3Dlocalhost +log4j.appender.socket.port=3D4560 +log4j.appender.socket.locationInfo=3Dtrue + +### set log levels - for more verbose logging change 'info' to 'debug' ### + +log4j.rootLogger=3Dinfo, stdout + +log4j.logger.org.hibernate=3Dinfo + +### log just the SQL +log4j.logger.org.hibernate.SQL=3Ddebug + +### log schema export/update ### +log4j.logger.org.hibernate.tool.hbm2ddl=3Ddebug + + Copied: search/trunk/hibernate-search-archetype/src/test (from rev 18090, s= earch/trunk/hibernate-search-archetype/src/main/resources/archetype-resourc= es/src/test) Copied: search/trunk/hibernate-search-archetype/src/test/java/example (from= rev 18090, search/trunk/hibernate-search-archetype/src/main/resources/arch= etype-resources/src/test/java/java/example) Modified: search/trunk/hibernate-search-archetype/src/test/java/example/Ind= exAndSearchTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search-archetype/src/main/resources/archetype-re= sources/src/test/java/java/example/IndexAndSearchTest.java 2009-11-28 01:12= :19 UTC (rev 18090) +++ search/trunk/hibernate-search-archetype/src/test/java/example/IndexAndS= earchTest.java 2009-11-30 12:41:16 UTC (rev 18093) @@ -117,6 +117,7 @@ for (Object obj : results) { ftSession.index(obj); } + ftSession.flushToIndexes(); } = private void purge() { --===============6197917246053316462==-- From hibernate-commits at lists.jboss.org Mon Nov 30 07:43:26 2009 Content-Type: multipart/mixed; boundary="===============7611122384287491829==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18094 - search/trunk/hibernate-search-archetype/src/main/resources. Date: Mon, 30 Nov 2009 07:43:26 -0500 Message-ID: <200911301243.nAUChQ28021724@svn01.web.mwc.hst.phx2.redhat.com> --===============7611122384287491829== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-30 07:43:26 -0500 (Mon, 30 Nov 2009) New Revision: 18094 Removed: search/trunk/hibernate-search-archetype/src/main/resources/archetype-res= ources/ Log: HSEARCH-426 --===============7611122384287491829==-- From hibernate-commits at lists.jboss.org Mon Nov 30 07:48:15 2009 Content-Type: multipart/mixed; boundary="===============7602967199243724398==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18095 - search/trunk. Date: Mon, 30 Nov 2009 07:48:15 -0500 Message-ID: <200911301248.nAUCmFcJ022658@svn01.web.mwc.hst.phx2.redhat.com> --===============7602967199243724398== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-30 07:48:15 -0500 (Mon, 30 Nov 2009) New Revision: 18095 Modified: search/trunk/changelog.txt Log: Updated changelog Modified: search/trunk/changelog.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/changelog.txt 2009-11-30 12:43:26 UTC (rev 18094) +++ search/trunk/changelog.txt 2009-11-30 12:48:15 UTC (rev 18095) @@ -58,6 +58,7 @@ * [HSEARCH-413] - Document all new features * [HSEARCH-419] - Create a proper @ProvidedId test * [HSEARCH-423] - Migrate to Hibernate Core 3.5 beta2 and JPA 2.0 CR1 + * [HSEARCH-426] - Update archetype sources = = = 3.1.1.GA (28-05-2009) --===============7602967199243724398==-- From hibernate-commits at lists.jboss.org Mon Nov 30 08:14:53 2009 Content-Type: multipart/mixed; boundary="===============0088949885675187291==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18096 - search/trunk/src/main/assembly. Date: Mon, 30 Nov 2009 08:14:53 -0500 Message-ID: <200911301314.nAUDErVk029087@svn01.web.mwc.hst.phx2.redhat.com> --===============0088949885675187291== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-30 08:14:52 -0500 (Mon, 30 Nov 2009) New Revision: 18096 Modified: search/trunk/src/main/assembly/dist.xml Log: excluded the archetype directory from the dist package Modified: search/trunk/src/main/assembly/dist.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/main/assembly/dist.xml 2009-11-30 12:48:15 UTC (rev 18= 095) +++ search/trunk/src/main/assembly/dist.xml 2009-11-30 13:14:52 UTC (rev 18= 096) @@ -36,7 +36,8 @@ true - **/target/** + target/** + hibernate-search-archetype/** --===============0088949885675187291==-- From hibernate-commits at lists.jboss.org Mon Nov 30 08:27:55 2009 Content-Type: multipart/mixed; boundary="===============3243106216949654398==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18097 - search/trunk. Date: Mon, 30 Nov 2009 08:27:55 -0500 Message-ID: <200911301327.nAUDRtYh032119@svn01.web.mwc.hst.phx2.redhat.com> --===============3243106216949654398== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-30 08:27:54 -0500 (Mon, 30 Nov 2009) New Revision: 18097 Modified: search/trunk/pom.xml Log: [maven-release-plugin] prepare release v3_2_0_Beta1 Modified: search/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/pom.xml 2009-11-30 13:14:52 UTC (rev 18096) +++ search/trunk/pom.xml 2009-11-30 13:27:54 UTC (rev 18097) @@ -1,10 +1,8 @@ - + 4.0.0 org.hibernate hibernate-search - 3.2.0-SNAPSHOT + 3.2.0.Beta1 Hibernate Search Hibernate Search http://search.hibernate.org @@ -14,9 +12,9 @@ http://opensource.atlassian.com/projects/hibernate/browse/HSE= ARCH - scm:svn:http://anonsvn.jboss.org/repos/hibernate/searc= h/ - scm:svn:https://svn.jboss.org/repos/hibernate= /search/ - http://fisheye.jboss.com/browse/Hibernate/search + scm:svn:http://anonsvn.jboss.org/repos/hibernate/searc= h/tags/v3_2_0_Beta1 + scm:svn:https://svn.jboss.org/repos/hibernate= /search/tags/v3_2_0_Beta1 + http://fisheye.jboss.com/browse/Hibernate/search/tags/v3_2_0_= Beta1 = @@ -345,8 +343,8 @@ org.hsqldb.jdbcDriver jdbc:hsqldb:. sa - - + + - - - - org.hibernate - hibernate-core - ${hibernateVersion} - - - org.hibernate - hibernate-commons-annotations - ${hibernateCommonsAnnotationVersion} - - - - org.hibernate.java-persistence - jpa-api - 2.0-cr-1 - - - org.apache.lucene - lucene-core - ${luceneVersion} - - - org.slf4j - slf4j-api - ${slf4jVersion} - - - javax.transaction - jta - 1.1 - - - - - - - org.apache.activemq - activemq-core - 5.2.0 - test - - - commons-logging - commons-logging - - - - - junit - junit - 3.8.1 - test - - - org.slf4j - slf4j-log4j12 - ${slf4jVersion} - test - - - - - test - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - org.apache.maven.plugins - maven-jar-plugin - - - - ${name} - ${version} - hibernate.org - hibernate.org - http://search.hibernate.or= g - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - pertest - true - - - build.dir - ${basedir}/target - - - - jgroups.bind_addr - 127.0.0.1 - - - - java.net.preferIPv4Stack - true - - - - **/*.java - - - - - org.jboss.maven.plugins - maven-jdocbook-plugin - 2.2.0 - true - - - org.hibernate - hibernate-jdocbook-style - 2.0.0 - jdocbook-style - - - - master.xml - ${basedir}/src/main/docbook - en-US - - zh-CN - - - ${basedir}/src/main/docbook/en-US/image= s - - - - pdf - classpath:/xslt/org/hibern= ate/jdocbook/xslt/pdf.xsl - hibernate_reference.pdf - - - html_single - classpath:/xslt/org/hibern= ate/jdocbook/xslt/xhtml-single.xsl - index.html - - - html - classpath:/xslt/org/hibern= ate/jdocbook/xslt/xhtml.xsl - index.html - - - - true - saxon - - - 1.72.0 - - - - - - - make-doc - site - - translate - resources - generate - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.1 - - - attach-sources - verify - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - ${basedir}/src/main/javadoc/jdstyle.cs= s - - - - make-javadoc - package - - javadoc - - - - - - maven-assembly-plugin - - - src/main/assembly/dist.xml - - - - - maven-release-plugin - - release - package javadoc:javadoc org.jboss.maven.plugins= :maven-jdocbook-plugin:2.2.0:resources - org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.= 0:generate assembly:assembly - - - - - - - true - src/test/resources - - **/*.properties - **/*.xml - - - - - - - - - - - repository.jboss.org - file://${maven.repository.root} - - - snapshots.jboss.org - JBoss Snapshot Repository - dav:https://snapshots.jboss.org/maven2 - - - - - - - - - - hsqldb - - true - - - - hsqldb - hsqldb - 1.8.0.2 - - - - org.hibernate.dialect.HSQLDialect - org.hsqldb.jdbcDriver - jdbc:hsqldb:. - sa - - - - - - - - - mysql5 - - - mysql - mysql-connector-java - 5.0.5 - - - - org.hibernate.dialect.MySQL5InnoDBDialect - com.mysql.jdbc.Driver - jdbc:mysql://vmg08.mw.lab.eng.bos.redhat.com/sea= rctru - searctru - searctru - - - - - - - mysql51 - - - mysql - mysql-connector-java - 5.0.5 - - - - org.hibernate.dialect.MySQL5InnoDBDialect - com.mysql.jdbc.Driver - jdbc:mysql://vmg02.mw.lab.eng.bos.redhat.com/sea= rctru - searctru - searctru - - - - - - - mysql51-cluster - - - mysql - mysql-connector-java - 5.0.5 - - - - org.hibernate.dialect.MySQL5Dialect - com.mysql.jdbc.Driver - jdbc:mysql:loadbalance://dev61.qa.atl2.redhat.co= m:3306,dev62.qa.atl2.redhat.com:3306/searctru - searctru - searctru - - - - - - - postgresql824 - - - postgresql - postgresql - 8.2-504 - jdbc3 - - - - org.hibernate.dialect.PostgreSQLDialect - org.postgresql.Driver - jdbc:postgresql://vmg01.mw.lab.eng.bos.redhat.co= m:5432:searctru - searctru - searctru - - - - - - - postgresql837 - - - postgresql - postgresql - 8.2-504 - jdbc3 - - - - org.hibernate.dialect.PostgreSQLDialect - org.postgresql.Driver - jdbc:postgresql://vmg03.mw.lab.eng.bos.redhat.co= m:5432:searctru - searctru - searctru - - - - - - - - - db2v82 - - - com.ibm - db2jcc - 3.1.57 - - - com.ibm - db2jcc_license_cu - 3.1.57 - - - - org.hibernate.dialect.DB2Dialect - com.ibm.db2.jcc.DB2Driver - jdbc:db2://dev32.qa.atl.jboss.com:50000/jbossqa<= /jdbc.url> - searctru - searctru - - - - - - - db2v91 - - - com.ibm - db2jcc - 3.8.47 - - - com.ibm - db2jcc_license_cu - 3.8.47 - - - - org.hibernate.dialect.DB2Dialect - com.ibm.db2.jcc.DB2Driver - jdbc:db2://dev67.qa.atl.jboss.com:50000/jbossqa<= /jdbc.url> - searctru - searctru - - - - - - - db2v97 - - - com.ibm - db2jcc - 3.57.86 - - - com.ibm - db2jcc_license_cu - 3.57.86 - - - - org.hibernate.dialect.DB2Dialect - com.ibm.db2.jcc.DB2Driver - jdbc:db2://vmg06.mw.lab.eng.bos.redhat.com:50000= /jbossqa - searctru - searctru - - - - - - - oracle9i - - - com.oracle - ojdbc14 - - 10.0.2.0 - - - - org.hibernate.dialect.Oracle9iDialect - oracle.jdbc.driver.OracleDriver - jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa= - searctru - searctru - - - - - - - oracle10g - - - com.oracle - ojdbc14 - - 10.0.2.0 - - - - org.hibernate.dialect.Oracle10gDialect - oracle.jdbc.driver.OracleDriver - jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.co= m:1521:qaora10 - searctru - searctru - - - - - - - oracle11g - - - com.oracle - ojdbc5 - 11.1.0.7.0 - - - - org.hibernate.dialect.Oracle10gDialect - oracle.jdbc.driver.OracleDriver - jdbc:oracle:thin:@dev04.qa.atl2.redhat.com:1521:= qaora11 - searctru - searctru - - - - - - - oracle11gRAC - - - com.oracle - ojdbc5 - 11.1.0.7.0 - - - - org.hibernate.dialect.Oracle10gDialect - oracle.jdbc.driver.OracleDriver - jdbc:oracle:thin:@(DESCRIPTION=3D(ADDRESS_LIST= =3D(LOAD_BALANCE=3DON)(ADDRESS=3D(PROTOCOL=3DTCP)(HOST=3Dvmg24-vip.mw.lab.e= ng.bos.redhat.com)(PORT=3D1521))(ADDRESS=3D(PROTOCOL=3DTCP)(HOST=3Dvmg25-vi= p.mw.lab.eng.bos.redhat.com)(PORT=3D1521)))(CONNECT_DATA=3D(SERVICE_NAME=3D= qarac.jboss))) - searctru - searctru - - - - - - - sybase15 - - - com.sybase - jconnect - 6.0.5 - - - - org.hibernate.dialect.SybaseASE15Dialect - com.sybase.jdbc3.jdbc.SybDriver - jdbc:sybase:Tds:vmg07.mw.lab.eng.bos.redhat.com:= 5000/searctru - searctru - searctru - - - - - - - mssql2005 - - - com.microsoft.sqlserver - msjdbc - 2.0.1008.2 - - - - org.hibernate.dialect.SQLServerDialect - com.microsoft.sqlserver.jdbc.SQLServerDriver<= /jdbc.driver> - jdbc:sqlserver://dev30.qa.atl.jboss.com:3918 - searctru - searctru - 4096 - - - - - - mssql2008 - - - com.microsoft.sqlserver - msjdbc - 2.0.1008.2 - - - - org.hibernate.dialect.SQLServerDialect - com.microsoft.sqlserver.jdbc.SQLServerDriver<= /jdbc.driver> - jdbc:sqlserver://vmg04.mw.lab.eng.bos.redhat.com= :1433 - searctru - searctru - 4096 - - - - - - - - - with-optional-jars - - true - - - - - - - org.hibernate - hibernate-annotations - ${hibernateVersion} - true - - - org.hibernate - hibernate-entitymanager - ${hibernateVersion} - true - - - org.apache.solr - solr-common - 1.3.0 - true - - - org.apache.solr - solr-core - 1.3.0 - true - - - commons-httpclient - commons-httpclient - - - org.apache.solr - solr-solrj - - - woodstox - wstx-asl - - - net.java.dev.stax-utils - stax-utils - - - commons-logging - commons-logging - - - org.apache.solr - solr-lucene-core - - - - - org.apache.lucene - lucene-snowball - ${luceneVersion} - true - - - org.apache.lucene - lucene-analyzers - ${luceneVersion} - true - - - org.apache.commons - commons-codec - 1.3 - true - - - org.apache.commons - commons-io - 1.3.2 - true - - - javax.jms - jms - 1.1 - provided - true - - - jgroups - jgroups - 2.6.7.GA - true - - - javax.annotation - jsr250-api - 1.0 - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - pertest - true - - **/classloading/*.java - **/*PerfTest.java - - - - - - - - without-optional-jars - - - javassist - javassist - 3.4.GA - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - pertest - true - - none - **/*PerfTest.java - - - **/classloading/*Test.java - - - - - - - - Copied: search/tags/v3_2_0_Beta1/pom.xml (from rev 18099, search/trunk/pom.= xml) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/tags/v3_2_0_Beta1/pom.xml (rev 0) +++ search/tags/v3_2_0_Beta1/pom.xml 2009-11-30 13:37:22 UTC (rev 18100) @@ -0,0 +1,838 @@ + + 4.0.0 + org.hibernate + hibernate-search + 3.2.0.Beta1 + Hibernate Search + Hibernate Search + http://search.hibernate.org + + + JIRA + http://opensource.atlassian.com/projects/hibernate/browse/HSE= ARCH + + + scm:svn:http://anonsvn.jboss.org/repos/hibernate/searc= h/tags/v3_2_0_Beta1 + scm:svn:https://svn.jboss.org/repos/hibernate= /search/tags/v3_2_0_Beta1 + http://fisheye.jboss.com/browse/Hibernate/search/tags/v3_2_0_= Beta1 + + + + Hibernate + http://www.hibernate.org + + + + + LGPL + lgpl.txt + + + + + + epbernard + Emmanuel Bernard + emmanuel(a)hibernate.org + http://in.relation.to/Bloggers/Emmanuel + + + hardy.ferentschik + Hardy Ferentschik + http://in.relation.to/Bloggers/Hardy + + + + + Sanne Grinovero + + + + + 1.5.8 + 2.4.1 + 3.5.0-Beta-2 + 3.2.0.Beta1 + + + + + + + + org.hibernate + hibernate-core + ${hibernateVersion} + + + org.hibernate + hibernate-commons-annotations + ${hibernateCommonsAnnotationVersion} + + + + org.hibernate.java-persistence + jpa-api + 2.0-cr-1 + + + org.apache.lucene + lucene-core + ${luceneVersion} + + + org.slf4j + slf4j-api + ${slf4jVersion} + + + javax.transaction + jta + 1.1 + + + + + + + org.apache.activemq + activemq-core + 5.2.0 + test + + + commons-logging + commons-logging + + + + + junit + junit + 3.8.1 + test + + + org.slf4j + slf4j-log4j12 + ${slf4jVersion} + test + + + + + test + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-jar-plugin + + + + ${name} + ${version} + hibernate.org + hibernate.org + http://search.hibernate.or= g + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + pertest + true + + + build.dir + ${basedir}/target + + + + jgroups.bind_addr + 127.0.0.1 + + + + java.net.preferIPv4Stack + true + + + + **/*.java + + + + + org.jboss.maven.plugins + maven-jdocbook-plugin + 2.2.0 + true + + + org.hibernate + hibernate-jdocbook-style + 2.0.0 + jdocbook-style + + + + master.xml + ${basedir}/src/main/docbook + en-US + + zh-CN + + + ${basedir}/src/main/docbook/en-US/image= s + + + + pdf + classpath:/xslt/org/hibern= ate/jdocbook/xslt/pdf.xsl + hibernate_reference.pdf + + + html_single + classpath:/xslt/org/hibern= ate/jdocbook/xslt/xhtml-single.xsl + index.html + + + html + classpath:/xslt/org/hibern= ate/jdocbook/xslt/xhtml.xsl + index.html + + + + true + saxon + + + 1.72.0 + - + + + + + make-doc + site + + translate + resources + generate + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.1 + + + attach-sources + verify + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + ${basedir}/src/main/javadoc/jdstyle.cs= s + + + + make-javadoc + package + + javadoc + + + + + + maven-assembly-plugin + + + src/main/assembly/dist.xml + + + + + maven-release-plugin + + release + package javadoc:javadoc org.jboss.maven.plugins= :maven-jdocbook-plugin:2.2.0:resources + org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.= 0:generate assembly:assembly + + + + + + + true + src/test/resources + + **/*.properties + **/*.xml + + + + + + + + + + + repository.jboss.org + file://${maven.repository.root} + + + snapshots.jboss.org + JBoss Snapshot Repository + dav:https://snapshots.jboss.org/maven2 + + + + + + + + + + hsqldb + + true + + + + hsqldb + hsqldb + 1.8.0.2 + + + + org.hibernate.dialect.HSQLDialect + org.hsqldb.jdbcDriver + jdbc:hsqldb:. + sa + + + + + + + + + mysql5 + + + mysql + mysql-connector-java + 5.0.5 + + + + org.hibernate.dialect.MySQL5InnoDBDialect + com.mysql.jdbc.Driver + jdbc:mysql://vmg08.mw.lab.eng.bos.redhat.com/sea= rctru + searctru + searctru + + + + + + + mysql51 + + + mysql + mysql-connector-java + 5.0.5 + + + + org.hibernate.dialect.MySQL5InnoDBDialect + com.mysql.jdbc.Driver + jdbc:mysql://vmg02.mw.lab.eng.bos.redhat.com/sea= rctru + searctru + searctru + + + + + + + mysql51-cluster + + + mysql + mysql-connector-java + 5.0.5 + + + + org.hibernate.dialect.MySQL5Dialect + com.mysql.jdbc.Driver + jdbc:mysql:loadbalance://dev61.qa.atl2.redhat.co= m:3306,dev62.qa.atl2.redhat.com:3306/searctru + searctru + searctru + + + + + + + postgresql824 + + + postgresql + postgresql + 8.2-504 + jdbc3 + + + + org.hibernate.dialect.PostgreSQLDialect + org.postgresql.Driver + jdbc:postgresql://vmg01.mw.lab.eng.bos.redhat.co= m:5432:searctru + searctru + searctru + + + + + + + postgresql837 + + + postgresql + postgresql + 8.2-504 + jdbc3 + + + + org.hibernate.dialect.PostgreSQLDialect + org.postgresql.Driver + jdbc:postgresql://vmg03.mw.lab.eng.bos.redhat.co= m:5432:searctru + searctru + searctru + + + + + + + + + db2v82 + + + com.ibm + db2jcc + 3.1.57 + + + com.ibm + db2jcc_license_cu + 3.1.57 + + + + org.hibernate.dialect.DB2Dialect + com.ibm.db2.jcc.DB2Driver + jdbc:db2://dev32.qa.atl.jboss.com:50000/jbossqa<= /jdbc.url> + searctru + searctru + + + + + + + db2v91 + + + com.ibm + db2jcc + 3.8.47 + + + com.ibm + db2jcc_license_cu + 3.8.47 + + + + org.hibernate.dialect.DB2Dialect + com.ibm.db2.jcc.DB2Driver + jdbc:db2://dev67.qa.atl.jboss.com:50000/jbossqa<= /jdbc.url> + searctru + searctru + + + + + + + db2v97 + + + com.ibm + db2jcc + 3.57.86 + + + com.ibm + db2jcc_license_cu + 3.57.86 + + + + org.hibernate.dialect.DB2Dialect + com.ibm.db2.jcc.DB2Driver + jdbc:db2://vmg06.mw.lab.eng.bos.redhat.com:50000= /jbossqa + searctru + searctru + + + + + + + oracle9i + + + com.oracle + ojdbc14 + + 10.0.2.0 + + + + org.hibernate.dialect.Oracle9iDialect + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa= + searctru + searctru + + + + + + + oracle10g + + + com.oracle + ojdbc14 + + 10.0.2.0 + + + + org.hibernate.dialect.Oracle10gDialect + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.co= m:1521:qaora10 + searctru + searctru + + + + + + + oracle11g + + + com.oracle + ojdbc5 + 11.1.0.7.0 + + + + org.hibernate.dialect.Oracle10gDialect + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@dev04.qa.atl2.redhat.com:1521:= qaora11 + searctru + searctru + + + + + + + oracle11gRAC + + + com.oracle + ojdbc5 + 11.1.0.7.0 + + + + org.hibernate.dialect.Oracle10gDialect + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@(DESCRIPTION=3D(ADDRESS_LIST= =3D(LOAD_BALANCE=3DON)(ADDRESS=3D(PROTOCOL=3DTCP)(HOST=3Dvmg24-vip.mw.lab.e= ng.bos.redhat.com)(PORT=3D1521))(ADDRESS=3D(PROTOCOL=3DTCP)(HOST=3Dvmg25-vi= p.mw.lab.eng.bos.redhat.com)(PORT=3D1521)))(CONNECT_DATA=3D(SERVICE_NAME=3D= qarac.jboss))) + searctru + searctru + + + + + + + sybase15 + + + com.sybase + jconnect + 6.0.5 + + + + org.hibernate.dialect.SybaseASE15Dialect + com.sybase.jdbc3.jdbc.SybDriver + jdbc:sybase:Tds:vmg07.mw.lab.eng.bos.redhat.com:= 5000/searctru + searctru + searctru + + + + + + + mssql2005 + + + com.microsoft.sqlserver + msjdbc + 2.0.1008.2 + + + + org.hibernate.dialect.SQLServerDialect + com.microsoft.sqlserver.jdbc.SQLServerDriver<= /jdbc.driver> + jdbc:sqlserver://dev30.qa.atl.jboss.com:3918 + searctru + searctru + 4096 + + + + + + mssql2008 + + + com.microsoft.sqlserver + msjdbc + 2.0.1008.2 + + + + org.hibernate.dialect.SQLServerDialect + com.microsoft.sqlserver.jdbc.SQLServerDriver<= /jdbc.driver> + jdbc:sqlserver://vmg04.mw.lab.eng.bos.redhat.com= :1433 + searctru + searctru + 4096 + + + + + + + + + with-optional-jars + + true + + + + + + + org.hibernate + hibernate-annotations + ${hibernateVersion} + true + + + org.hibernate + hibernate-entitymanager + ${hibernateVersion} + true + + + org.apache.solr + solr-common + 1.3.0 + true + + + org.apache.solr + solr-core + 1.3.0 + true + + + commons-httpclient + commons-httpclient + + + org.apache.solr + solr-solrj + + + woodstox + wstx-asl + + + net.java.dev.stax-utils + stax-utils + + + commons-logging + commons-logging + + + org.apache.solr + solr-lucene-core + + + + + org.apache.lucene + lucene-snowball + ${luceneVersion} + true + + + org.apache.lucene + lucene-analyzers + ${luceneVersion} + true + + + org.apache.commons + commons-codec + 1.3 + true + + + org.apache.commons + commons-io + 1.3.2 + true + + + javax.jms + jms + 1.1 + provided + true + + + jgroups + jgroups + 2.6.7.GA + true + + + javax.annotation + jsr250-api + 1.0 + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + pertest + true + + **/classloading/*.java + **/*PerfTest.java + + + + + + + + without-optional-jars + + + javassist + javassist + 3.4.GA + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + pertest + true + + none + **/*PerfTest.java + + + **/classloading/*Test.java + + + + + + + + --===============9213597511912502991==-- From hibernate-commits at lists.jboss.org Mon Nov 30 08:37:32 2009 Content-Type: multipart/mixed; boundary="===============1953045989025323091==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18101 - search/trunk. Date: Mon, 30 Nov 2009 08:37:32 -0500 Message-ID: <200911301337.nAUDbWpd001610@svn01.web.mwc.hst.phx2.redhat.com> --===============1953045989025323091== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-30 08:37:31 -0500 (Mon, 30 Nov 2009) New Revision: 18101 Modified: search/trunk/pom.xml Log: [maven-release-plugin] prepare for next development iteration Modified: search/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/pom.xml 2009-11-30 13:37:22 UTC (rev 18100) +++ search/trunk/pom.xml 2009-11-30 13:37:31 UTC (rev 18101) @@ -2,7 +2,7 @@ 4.0.0 org.hibernate hibernate-search - 3.2.0.Beta1 + 3.2.0.Beta2-SNAPSHOT Hibernate Search Hibernate Search http://search.hibernate.org --===============1953045989025323091==-- From hibernate-commits at lists.jboss.org Mon Nov 30 10:59:09 2009 Content-Type: multipart/mixed; boundary="===============5810417219113461231==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18102 - in validator/trunk: hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap and 12 other directories. Date: Mon, 30 Nov 2009 10:59:09 -0500 Message-ID: <200911301559.nAUFx9uG028668@svn01.web.mwc.hst.phx2.redhat.com> --===============5810417219113461231== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2009-11-30 10:59:09 -0500 (Mon, 30 Nov 2009) New Revision: 18102 Added: validator/trunk/hibernate-validator-annotation-processor/src/main/java/o= rg/hibernate/validator/ap/ConstraintAnnotationVisitor.java validator/trunk/hibernate-validator-annotation-processor/src/main/java/o= rg/hibernate/validator/ap/util/ validator/trunk/hibernate-validator-annotation-processor/src/main/java/o= rg/hibernate/validator/ap/util/AnnotationApiHelper.java validator/trunk/hibernate-validator-annotation-processor/src/main/java/o= rg/hibernate/validator/ap/util/CollectionHelper.java validator/trunk/hibernate-validator-annotation-processor/src/main/java/o= rg/hibernate/validator/ap/util/ConstraintHelper.java validator/trunk/hibernate-validator-annotation-processor/src/main/resour= ces/org/ validator/trunk/hibernate-validator-annotation-processor/src/main/resour= ces/org/hibernate/ validator/trunk/hibernate-validator-annotation-processor/src/main/resour= ces/org/hibernate/validator/ validator/trunk/hibernate-validator-annotation-processor/src/main/resour= ces/org/hibernate/validator/ap/ validator/trunk/hibernate-validator-annotation-processor/src/main/resour= ces/org/hibernate/validator/ap/ValidationProcessorMessages.properties validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/ConstraintValidationProcessorTest.java validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/testmodel/ validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/testmodel/FieldLevelValidationUsingBuiltInConstra= ints.java validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/testmodel/MethodLevelValidationUsingBuiltInConstr= aints.java validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/testmodel/customconstraints/ validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/testmodel/customconstraints/CaseMode.java validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/testmodel/customconstraints/CheckCase.java validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/testmodel/customconstraints/CheckCaseValidator.ja= va validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/testmodel/customconstraints/FieldLevelValidationU= singCustomConstraints.java validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/testutil/ validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/testutil/CompilerTestHelper.java validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/util/ validator/trunk/hibernate-validator-annotation-processor/src/test/java/o= rg/hibernate/validator/ap/util/DiagnosticExpection.java Modified: validator/trunk/hibernate-validator-annotation-processor/pom.xml validator/trunk/hibernate-validator-annotation-processor/src/main/java/o= rg/hibernate/validator/ap/ConstraintValidationProcessor.java validator/trunk/hibernate-validator-tck-runner/pom.xml Log: HV-269 (patch from Gunnar) Added first cut of annotation processor Made some minor changes to how pathToBeanValidationApiJar is specified usin= g the maven-dependecy-plugin Modified: validator/trunk/hibernate-validator-annotation-processor/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/pom.xml 2009-1= 1-30 13:37:31 UTC (rev 18101) +++ validator/trunk/hibernate-validator-annotation-processor/pom.xml 2009-1= 1-30 15:59:09 UTC (rev 18102) @@ -19,8 +19,54 @@ -proc:none - - + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + generate-test-sources + + copy + + + true + + + javax.validation + validation-api + true + ${project.build.direc= tory}/lib + + + + + + = + + org.apache.maven.plugins + maven-surefire-plugin + + + + testSourceBaseDir + ${basedir}/src/test/java + + + + pathToBeanValidationApiJar + ${project.build.directory}/lib/validation-= api.jar + + + + + + org.hibernate Added: validator/trunk/hibernate-validator-annotation-processor/src/main/ja= va/org/hibernate/validator/ap/ConstraintAnnotationVisitor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/main/java/= org/hibernate/validator/ap/ConstraintAnnotationVisitor.java = (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/main/java/= org/hibernate/validator/ap/ConstraintAnnotationVisitor.java 2009-11-30 15:5= 9:09 UTC (rev 18102) @@ -0,0 +1,124 @@ +// $Id: ConstraintAnnotationVisitor.java 17946 2009-11-06 18:23:48Z hardy.= ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap; + +import java.text.MessageFormat; +import java.util.List; +import java.util.ResourceBundle; + +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.ElementVisitor; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.util.ElementKindVisitor6; +import javax.tools.Diagnostic.Kind; + +import org.hibernate.validator.ap.util.ConstraintHelper; + +/** + * An {@link ElementVisitor} that visits elements (type declarations, meth= ods + * and fields) annotated with constraint annotations from the Bean Validat= ion + * API. + * = + * TODO GM: visit type declarations. + * = + * @author Gunnar Morling. + * = + */ +final class ConstraintAnnotationVisitor extends + ElementKindVisitor6> { + = + private ProcessingEnvironment processingEnvironment; + = + private ResourceBundle errorMessages; + + //TODO GM: make configurable using Options API + private Kind messagingKind =3D Kind.ERROR; + + public ConstraintAnnotationVisitor(ProcessingEnvironment processingEnviro= nment) { + = + this.processingEnvironment =3D processingEnvironment; + errorMessages =3D ResourceBundle.getBundle("org.hibernate.validator.ap.V= alidationProcessorMessages"); + } + = + /** + *

+ * Checks whether the given mirrors representing one or more constraint a= nnotations are correctly + * specified at the given method. The following checks are performed:

+ *
    + *
  • + * The method must be a JavaBeans getter method. + *
  • = + *
  • + * TODO GM: + * The return type of the method must be supported by the constraints. + *
  • + *
+ */ + @Override + public Void visitExecutableAsMethod(ExecutableElement element, + List mirrors) { + = + for (AnnotationMirror oneAnnotationMirror : mirrors) { + if(!isJavaBeanGetterName(element.getSimpleName().toString())) { + = + processingEnvironment.getMessager().printMessage( + messagingKind, + errorMessages.getString("ONLY_GETTERS_MAY_BE_ANNOTATED"), element, on= eAnnotationMirror); + } + } + return null; + } + + /** + *

+ * Checks whether the given mirrors representing one or more constraint a= nnotations are correctly + * specified at the given field. The following checks are performed:

+ *
    + *
  • + * The type of the field must be supported by the constraints. + *
  • + *
+ */ + @Override + public Void visitVariableAsField(VariableElement annotatedField, List mirrors) { + = + for (AnnotationMirror oneAnnotationMirror : mirrors) { + = + ConstraintHelper builtInConstraintHelper =3D = + new ConstraintHelper(processingEnvironment.getElementUtils(), processi= ngEnvironment.getTypeUtils()); + = + boolean annotationAllowedAtElementType =3D = + builtInConstraintHelper.isAnnotationAllowedAtElement(oneAnnotationMirr= or.getAnnotationType(), annotatedField); + = + if(!annotationAllowedAtElementType) { + processingEnvironment.getMessager().printMessage( + messagingKind, + MessageFormat.format(errorMessages.getString("NOT_SUPPORTED_TYPE"), o= neAnnotationMirror.getAnnotationType().asElement().getSimpleName()), annota= tedField, oneAnnotationMirror); + } + } + = + return null; + } + = + private boolean isJavaBeanGetterName(String name) { + return name.startsWith("is") || name.startsWith("has") || name.startsWit= h("get"); + } + = +} \ No newline at end of file Modified: validator/trunk/hibernate-validator-annotation-processor/src/main= /java/org/hibernate/validator/ap/ConstraintValidationProcessor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/main/java/= org/hibernate/validator/ap/ConstraintValidationProcessor.java 2009-11-30 13= :37:31 UTC (rev 18101) +++ validator/trunk/hibernate-validator-annotation-processor/src/main/java/= org/hibernate/validator/ap/ConstraintValidationProcessor.java 2009-11-30 15= :59:09 UTC (rev 18102) @@ -1,4 +1,4 @@ -// $Id: JPAMetaModelEntityProcessor.java 17946 2009-11-06 18:23:48Z hardy.= ferentschik $ +// $Id: ConstraintValidationProcessor.java 17946 2009-11-06 18:23:48Z hard= y.ferentschik $ /* * JBoss, Home of Professional Open Source * Copyright 2009, Red Hat Middleware LLC, and individual contributors @@ -17,52 +17,68 @@ */ package org.hibernate.validator.ap; = +import java.util.List; +import java.util.Set; = -import java.util.Set; import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.Messager; -import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; import javax.annotation.processing.SupportedSourceVersion; -import static javax.lang.model.SourceVersion.RELEASE_6; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; = -import javax.tools.Diagnostic; +import org.hibernate.validator.ap.util.AnnotationApiHelper; +import org.hibernate.validator.ap.util.ConstraintHelper; = = /** * Annotation processor for validating Bean Validation constraints. * * @author Hardy Ferentschik + * @author Gunnar Morling */ @SupportedAnnotationTypes("*") -(a)SupportedSourceVersion(RELEASE_6) +(a)SupportedSourceVersion(SourceVersion.RELEASE_6) public class ConstraintValidationProcessor extends AbstractProcessor { - private static final Boolean ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS = =3D Boolean.FALSE; - private Messager messager; - - public void init(ProcessingEnvironment env) { - super.init( env ); - messager =3D env.getMessager(); - messager.printMessage( Diagnostic.Kind.NOTE, "Init Processor " + this ); - } - + = + /** + * Whether this processor claims all processed annotations exclusively or= not. + */ + private static final boolean ANNOTATIONS_CLAIMED_EXCLUSIVELY =3D false; + = + = @Override - public boolean process(final Set annotations, - final RoundEnvironment roundEnvironment) { - - if ( roundEnvironment.processingOver() ) { - messager.printMessage( Diagnostic.Kind.NOTE, "Last processing round." ); - return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS; - } - - Set elements =3D roundEnvironment.getRootElements(); - for ( Element element : elements ) { - messager.printMessage( Diagnostic.Kind.NOTE, "Processing " + element.to= String() ); - } - - return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS; + public boolean process( + final Set annotations, + final RoundEnvironment roundEnvironment) { + = + AnnotationApiHelper typeHelper =3D new AnnotationApiHelper(processingEnv= .getElementUtils(), processingEnv.getTypeUtils()); + ConstraintAnnotationVisitor v =3D new ConstraintAnnotationVisitor(proces= singEnv); + ConstraintHelper constraintHelper =3D new ConstraintHelper(processingEnv= .getElementUtils(), processingEnv.getTypeUtils()); + = + for (TypeElement oneAnnotation : annotations) { + = + //only constraint annotations are relevant + if(!constraintHelper.isConstraintAnnotation(oneAnnotation)) { + continue; + } + = + Set elementsWithConstraintAnnotation =3D = + roundEnvironment.getElementsAnnotatedWith(oneAnnotation); + = + for (Element oneAnnotatedElement : elementsWithConstraintAnnotation) { + = + List mirrorsOfCurrentAnnotation =3D = + typeHelper.filterByType(oneAnnotatedElement.getAnnotationMirrors(), o= neAnnotation.asType()); + = + = + oneAnnotatedElement.accept(v, mirrorsOfCurrentAnnotation); = + } + } = + = + return ANNOTATIONS_CLAIMED_EXCLUSIVELY; } + = } Added: validator/trunk/hibernate-validator-annotation-processor/src/main/ja= va/org/hibernate/validator/ap/util/AnnotationApiHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/main/java/= org/hibernate/validator/ap/util/AnnotationApiHelper.java = (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/main/java/= org/hibernate/validator/ap/util/AnnotationApiHelper.java 2009-11-30 15:59:0= 9 UTC (rev 18102) @@ -0,0 +1,99 @@ +// $Id: ConstraintHelper.java 17946 2009-11-06 18:23:48Z hardy.ferentschik= $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.util; + +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.List; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.Elements; +import javax.lang.model.util.Types; + +/** + * A helper class providing some useful methods to work with types + * from the JSR-269-API. + * = + * @author Gunnar Morling + * + */ +public class AnnotationApiHelper { + + private Elements elementUtils; + = + private Types typeUtils; + + public AnnotationApiHelper(Elements elementUtils, Types typeUtils) { + + this.elementUtils =3D elementUtils; + this.typeUtils =3D typeUtils; + } + = + /** + * Returns a list containing those annotation mirrors from the input list, + * which are of type annotationType. The input collection + * remains untouched. + * = + * @param annotationMirrors + * A list of annotation mirrors. + * @param annotationType + * The type to be compared against. + * = + * @return A list with those annotation mirrors from the input list, which + * are of type annotationType. May be empty but never + * null. + */ + public List filterByType(List annotationMirrors, TypeMirror annotationType) { + + List theValue =3D new ArrayList(); + + if(annotationMirrors =3D=3D null || annotationType =3D=3D null) { + return theValue; + } + = + for (AnnotationMirror oneAnnotationMirror : annotationMirrors) { + + if (typeUtils.isSameType(oneAnnotationMirror.getAnnotationType(), annot= ationType)) { + theValue.add(oneAnnotationMirror); + } + } + + return theValue; + } + = + public AnnotationMirror getMirror(List ann= otationMirrors, Class annotationClazz) { + = + if(annotationMirrors =3D=3D null || annotationClazz =3D=3D null) { + return null; + } + = + for (AnnotationMirror oneAnnotationMirror : annotationMirrors) { + + TypeElement typeElement =3D elementUtils.getTypeElement(annotationClazz= .getCanonicalName()); + = + if (typeUtils.isSameType(oneAnnotationMirror.getAnnotationType(), typeE= lement.asType())) { + return oneAnnotationMirror; + } + } + + return null; + } + +} Added: validator/trunk/hibernate-validator-annotation-processor/src/main/ja= va/org/hibernate/validator/ap/util/CollectionHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/main/java/= org/hibernate/validator/ap/util/CollectionHelper.java = (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/main/java/= org/hibernate/validator/ap/util/CollectionHelper.java 2009-11-30 15:59:09 U= TC (rev 18102) @@ -0,0 +1,50 @@ +// $Id: CollectionHelper.java 17946 2009-11-06 18:23:48Z hardy.ferentschik= $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.util; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +/** + * Provides some methods for simplified collection instantiation. + * = + * @author Gunnar Morling + */ +public class CollectionHelper { + + public static HashMap newHashMap() { + return new HashMap(); + } + = + public static HashSet newHashSet() { + return new HashSet(); + } + = + public static ArrayList newArrayList() { + return new ArrayList(); + } + = + public static Set asSet(T ...ts) { + = + return new HashSet(Arrays.asList(ts)); + } + = +} \ No newline at end of file Added: validator/trunk/hibernate-validator-annotation-processor/src/main/ja= va/org/hibernate/validator/ap/util/ConstraintHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/main/java/= org/hibernate/validator/ap/util/ConstraintHelper.java = (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/main/java/= org/hibernate/validator/ap/util/ConstraintHelper.java 2009-11-30 15:59:09 U= TC (rev 18102) @@ -0,0 +1,295 @@ +// $Id: ConstraintHelper.java 17946 2009-11-06 18:23:48Z hardy.ferentschik= $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.util; + +import java.lang.annotation.Annotation; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Name; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.Elements; +import javax.lang.model.util.Types; +import javax.validation.Constraint; +import javax.validation.ConstraintValidator; +import javax.validation.constraints.AssertTrue; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * Helper class that deals with all constraint-related stuff, such as + * determining whether a given annotation represents a constraint annotati= on or + * whether a given annotation is allowed to be declared at a given element. + * = + * @author Gunnar Morling + * = + */ +public class ConstraintHelper { + + /** + * The name of the package containing JSR 303 standard annotations + * ("javax.validation.constraints"). + */ + private final Name CONSTRAINT_ANNOTATION_PACKAGE_NAME; + = + private static Map> builtInConstraints; + = + private Elements elementUtils; + = + private Types typeUtils; + + public ConstraintHelper(Elements elementUtils, Types typeUtils) { + + this.elementUtils =3D elementUtils; + this.typeUtils =3D typeUtils; + = + CONSTRAINT_ANNOTATION_PACKAGE_NAME =3D elementUtils.getName(Size.class.g= etPackage().getName()); + = + builtInConstraints =3D CollectionHelper.newHashMap(); + = + //TODO GM: register all types + registerAllowedTypesForBuiltInConstraint(Size.class, CollectionHelper.>asSet(Collection.class, String.class)); + registerAllowedTypesForBuiltInConstraint(AssertTrue.class, CollectionHel= per.>asSet(Boolean.class, boolean.class)); + registerAllowedTypesForBuiltInConstraint(NotNull.class, CollectionHelper= .>asSet(Object.class)); + registerAllowedTypesForBuiltInConstraint(Min.class, CollectionHelper.>asSet(Integer.class, Long.class)); + } + + /** + * Checks, whether the given type element represents a constraint annotat= ion + * or not. That's the case, if the given element is annotated with the + * {@link Constraint} meta-annotation (which is only allowed at annotation + * declarations). + * = + * @param The + * element of interest. + * @return True, if the given element is a constraint annotation type, fa= lse + * otherwise. + */ + public boolean isConstraintAnnotation(TypeElement typeElement) { + return typeElement.getAnnotation(Constraint.class) !=3D null; + } + + public boolean isAnnotationAllowedAtElement(DeclaredType annotationType, = Element annotatedElement) { + = + Set allowedTypesForConstraint =3D getAllowedTypesForConstra= int(annotationType); + = + if(allowedTypesForConstraint.isEmpty()) { + return false; + } + = + Element typeElementOfAnnotatedElement =3D typeUtils.asElement(annotatedE= lement.asType()); + = + = + if(allowedTypesForConstraint.contains(typeElementOfAnnotatedElement)) { + return true; + } + = + List directSupertypes =3D typeUtils.directSupertyp= es(annotatedElement.asType()); + = + while(!directSupertypes.isEmpty()) { + List nextSupertypes =3D CollectionHelper.newArrayList(); + for (TypeMirror oneSuperType : directSupertypes) { + = + Element oneSuperTypeAsElement =3D typeUtils.asElement(oneSuperType); + = + if(allowedTypesForConstraint.contains(oneSuperTypeAsElement)) { + return true; + } + = + nextSupertypes.addAll(typeUtils.directSupertypes(oneSuperType)); + } + = + directSupertypes =3D nextSupertypes; + } + = + = + return false; + } + + // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + // private API below + // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + = + /** + * Returns a set with all those type elements, at which the given constra= int annotation + * type may be specified. + * = + * @param annotationType + * @return + */ + private Set getAllowedTypesForConstraint(DeclaredType annota= tionType) { + = + if(isBuiltInConstraint(annotationType)) { + return getAllowedTypesFromBuiltInConstraint(annotationType); + } + else { + return getAllowedTypesFromCustomConstraint(annotationType); + } + } + = + private Set getAllowedTypesFromBuiltInConstraint(DeclaredTyp= e builtInAnnotationType) { + = + Set theValue =3D builtInConstraints.get(builtInAnnotationTy= pe.asElement().getSimpleName()); + = + if(theValue =3D=3D null) { + theValue =3D Collections.emptySet(); + } = + = + return theValue; + } + = + /** + * Returns a set containing all those types, at which the specified custom + * constraint-annotation is allowed. + * = + * @param customInAnnotationType + * A custom constraint type. + * = + * @return A set with all types supported by the given constraint. May be + * empty in case of constraint composition, if there is no common + * type supported by all composing constraints. + * = + * TODO GM: consider constraint composition + */ + private Set getAllowedTypesFromCustomConstraint(DeclaredType= customInAnnotationType) { + = + Set theValue =3D CollectionHelper.newHashSet(); + = + //the Constraint meta-annotation at the type declaration, e.g. "@Constra= int(validatedBy =3D CheckCaseValidator.class)" + AnnotationMirror constraintMetaAnnotation =3D getConstraintMetaAnnotatio= n(customInAnnotationType); + = + if(constraintMetaAnnotation =3D=3D null) { + return theValue; + } + = + //the validator classes, e.g. [CheckCaseValidator.class] + List validatorClassReferences =3D getValidato= rClassesFromConstraintMetaAnnotation(constraintMetaAnnotation); + + for (AnnotationValue oneValidatorClassReference : validatorClassReferenc= es) { + = + DeclaredType validatorType =3D (DeclaredType)oneValidatorClassReference= .getValue(); + = + //contains the bindings of the type parameters from the implemented Con= straintValidator + //interface, e.g. "ConstraintValidator" + DeclaredType constraintValidatorImplementation =3D getConstraintValidat= orSuperType(validatorType); + = + if(constraintValidatorImplementation !=3D null) { + = + //2nd type parameter contains the data type supported by current valid= ator class, e.g. "String" + TypeMirror supportedTypeParameter =3D constraintValidatorImplementatio= n.getTypeArguments().get(1); + theValue.add((TypeElement)typeUtils.asElement(supportedTypeParameter)); + } + } + = + return theValue; + } + = + private DeclaredType getConstraintValidatorSuperType(DeclaredType type) { + = + List directSupertypes =3D typeUtils.directSupertyp= es(type); + = + for (TypeMirror typeMirror : directSupertypes) { + if(typeUtils.asElement(typeMirror).getSimpleName().contentEquals(Constr= aintValidator.class.getSimpleName())) { + return (DeclaredType)typeMirror; + } + } + = + return null; + } + = + /** + * Retrieves the {@link Constraint} meta-annotation from the given constr= aint annotation. + * = + * @param annotationType A constraint type. + * = + * @return The Constraint meta-annotation or null if it isn't specified a= t the given type. + */ + private AnnotationMirror getConstraintMetaAnnotation(DeclaredType annotat= ionType) { + = + List annotationMirrors =3D annotationType.as= Element().getAnnotationMirrors(); + = + return new AnnotationApiHelper(elementUtils, typeUtils).getMirror(annota= tionMirrors, Constraint.class); + } + = + private List getValidatorClassesFromConstraint= MetaAnnotation(AnnotationMirror constraintMetaAnnotation) { + = + Map elementValue= s =3D constraintMetaAnnotation.getElementValues(); + = + for (Entry oneEl= ementValue : elementValues.entrySet()) { + = + if(oneElementValue.getKey().getSimpleName().contentEquals("validatedBy"= )) { + = + //this is save, as we know that the "validatedBy" attribute is an arra= y of classes + @SuppressWarnings("unchecked") + List validatorClasses =3D (List)oneElementValue.getValue().getValue(); + = + return validatorClasses; + } + } + = + return Collections.emptyList(); + } + = + private void registerAllowedTypesForBuiltInConstraint(Class annotation, Set> allowedTypes) { + = + Set allowedTypesAsElements =3D CollectionHelper.newHashSet(= ); + = + for (Class oneType : allowedTypes) { + TypeElement typeElement =3D elementUtils.getTypeElement(oneType.getCano= nicalName()); + = + if(typeElement !=3D null) { + allowedTypesAsElements.add(typeElement); + } + } + + builtInConstraints.put(elementUtils.getName(annotation.getSimpleName()),= allowedTypesAsElements); + } + = + /** + * Checks, whether the given type is a built-in constraint annotation (wh= ich + * is the case, if is annotated with the {@link Constraint} meta-annotati= on + * and is declared in the package javax.validation.constraints). + * = + * @param annotationType + * The type to check. + * @return True, if the given type is a constraint annotation, false + * otherwise. + */ + private boolean isBuiltInConstraint(DeclaredType annotationType) { + = + Element element =3D annotationType.asElement(); + = + if(element.getAnnotation(Constraint.class) =3D=3D null) { + return false; + } + = + return CONSTRAINT_ANNOTATION_PACKAGE_NAME.equals(elementUtils.getPackage= Of(element).getQualifiedName()); + } + = +} \ No newline at end of file Added: validator/trunk/hibernate-validator-annotation-processor/src/main/re= sources/org/hibernate/validator/ap/ValidationProcessorMessages.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/main/resou= rces/org/hibernate/validator/ap/ValidationProcessorMessages.properties = (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/main/resou= rces/org/hibernate/validator/ap/ValidationProcessorMessages.properties 2009= -11-30 15:59:09 UTC (rev 18102) @@ -0,0 +1,6 @@ +# $Id: ValidationProcessorMessages.properties 17927 2009-11-05 09:51:52Z h= ardy.ferentschik $ +# +# Contains error messages to be used by the ConstraintValidationProcessor. + +ONLY_GETTERS_MAY_BE_ANNOTATED=3DConstraint annotations must not be specifi= ed at methods, which are no valid JavaBeans getter methods. +NOT_SUPPORTED_TYPE=3DThe annotation @{0} is disallowed for this data type. \ No newline at end of file Added: validator/trunk/hibernate-validator-annotation-processor/src/test/ja= va/org/hibernate/validator/ap/ConstraintValidationProcessorTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/ConstraintValidationProcessorTest.java = (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/ConstraintValidationProcessorTest.java 2009-11-3= 0 15:59:09 UTC (rev 18102) @@ -0,0 +1,111 @@ +// $Id: ConstraintValidationProcessorTest.java 17946 2009-11-06 18:23:48Z = hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap; + +import static org.hibernate.validator.ap.testutil.CompilerTestHelper.asser= tDiagnostics; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; + +import java.io.File; + +import javax.tools.DiagnosticCollector; +import javax.tools.JavaFileObject; +import javax.tools.ToolProvider; +import javax.tools.Diagnostic.Kind; + +import org.hibernate.validator.ap.testmodel.FieldLevelValidationUsingBuilt= InConstraints; +import org.hibernate.validator.ap.testmodel.MethodLevelValidationUsingBuil= tInConstraints; +import org.hibernate.validator.ap.testmodel.customconstraints.CaseMode; +import org.hibernate.validator.ap.testmodel.customconstraints.CheckCase; +import org.hibernate.validator.ap.testmodel.customconstraints.CheckCaseVal= idator; +import org.hibernate.validator.ap.testmodel.customconstraints.FieldLevelVa= lidationUsingCustomConstraints; +import org.hibernate.validator.ap.testutil.CompilerTestHelper; +import org.hibernate.validator.ap.util.DiagnosticExpection; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Test for {@link ConstraintValidationProcessor} using the Java compiler + * API as defined by JSR 199. + * = + * @author Gunnar Morling. + * + */ +public class ConstraintValidationProcessorTest { + + private static CompilerTestHelper compilerHelper; + = + @BeforeClass + public static void setUpCompilerHelper() { + + String testSourceBaseDir =3D System.getProperty("testSourceBaseDir"); + String pathToBeanValidationApiJar =3D System.getProperty("pathToBeanVali= dationApiJar"); + = + assertNotNull(testSourceBaseDir, "The system property testSourceBaseDir = has to be set and point to the base directory of the test java sources."); + assertNotNull(pathToBeanValidationApiJar, "The system property pathToBea= nValidationApiJar has to be set and point to the BV API Jars."); + = + compilerHelper =3D = + new CompilerTestHelper(ToolProvider.getSystemJavaCompiler(), testSource= BaseDir, pathToBeanValidationApiJar); + } + + @Test + public void fieldLevelValidationUsingBuiltInConstraints() { + + DiagnosticCollector diagnostics =3D new DiagnosticCollec= tor(); + = + File sourceFile =3D compilerHelper.getSourceFile(FieldLevelValidationUsi= ngBuiltInConstraints.class); + = + boolean compilationResult =3D = + compilerHelper.compile(new ConstraintValidationProcessor(), diagnostics= , sourceFile); + + assertFalse(compilationResult); + assertDiagnostics(diagnostics, new DiagnosticExpection(Kind.ERROR, 48)); + } + = + @Test + public void fieldLevelValidationUsingCustomConstraints() { + + DiagnosticCollector diagnostics =3D new DiagnosticCollec= tor(); + = + File sourceFile1 =3D compilerHelper.getSourceFile(FieldLevelValidationUs= ingCustomConstraints.class); + File sourceFile2 =3D compilerHelper.getSourceFile(CheckCase.class); + File sourceFile3 =3D compilerHelper.getSourceFile(CaseMode.class); + File sourceFile4 =3D compilerHelper.getSourceFile(CheckCaseValidator.cla= ss); + = + boolean compilationResult =3D = + compilerHelper.compile(new ConstraintValidationProcessor(), diagnostics= , sourceFile1, sourceFile2, sourceFile3, sourceFile4); + + assertFalse(compilationResult); + assertDiagnostics(diagnostics, new DiagnosticExpection(Kind.ERROR, 30)); + } + = + @Test + public void methodLevelValidationUsingBuiltInConstraints() { + + DiagnosticCollector diagnostics =3D new DiagnosticCollec= tor(); + = + File sourceFile =3D compilerHelper.getSourceFile(MethodLevelValidationUs= ingBuiltInConstraints.class); + = + boolean compilationResult =3D = + compilerHelper.compile(new ConstraintValidationProcessor(), diagnostics= , sourceFile); + + assertFalse(compilationResult); + assertDiagnostics(diagnostics, new DiagnosticExpection(Kind.ERROR, 32)); + } + = +} \ No newline at end of file Added: validator/trunk/hibernate-validator-annotation-processor/src/test/ja= va/org/hibernate/validator/ap/testmodel/FieldLevelValidationUsingBuiltInCon= straints.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/FieldLevelValidationUsingBuiltInConstr= aints.java (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/FieldLevelValidationUsingBuiltInConstr= aints.java 2009-11-30 15:59:09 UTC (rev 18102) @@ -0,0 +1,51 @@ +// $Id: FieldLevelValidationUsingBuiltInConstraints.java 17946 2009-11-06 = 18:23:48Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.testmodel; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import javax.validation.constraints.Size; + +public class FieldLevelValidationUsingBuiltInConstraints { + + @Size(min=3D10) + public String string; + = + @Size(min=3D10) + public Collection collection; + = + //TODO GM: support array-typed elements + = +// @Size(min=3D10) +// public boolean[] array; + = + /** + * Allowed, as List extends Collection. + */ + @Size(min=3D10) + public List list; + = + /** + * Not allowed. + */ + @Size(min=3D10) + public Date date; + +} Added: validator/trunk/hibernate-validator-annotation-processor/src/test/ja= va/org/hibernate/validator/ap/testmodel/MethodLevelValidationUsingBuiltInCo= nstraints.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/MethodLevelValidationUsingBuiltInConst= raints.java (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/MethodLevelValidationUsingBuiltInConst= raints.java 2009-11-30 15:59:09 UTC (rev 18102) @@ -0,0 +1,37 @@ +// $Id: MethodLevelValidationUsingBuiltInConstraints.java 17946 2009-11-06= 18:23:48Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.testmodel; + +import javax.validation.constraints.Size; + +public class MethodLevelValidationUsingBuiltInConstraints { + + @Size(min=3D10) + public String getString() { + return null; + } + = + /** + * Not allowed. Method is no getter. + */ + @Size(min=3D10) + public void setString() { + = + } + +} Added: validator/trunk/hibernate-validator-annotation-processor/src/test/ja= va/org/hibernate/validator/ap/testmodel/customconstraints/CaseMode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/customconstraints/CaseMode.java = (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/customconstraints/CaseMode.java 2009-1= 1-30 15:59:09 UTC (rev 18102) @@ -0,0 +1,26 @@ +// $Id: CaseMode.java 17946 2009-11-06 18:23:48Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.testmodel.customconstraints; + +public enum CaseMode { + + UPPER, = + = + LOWER; + +} Added: validator/trunk/hibernate-validator-annotation-processor/src/test/ja= va/org/hibernate/validator/ap/testmodel/customconstraints/CheckCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/customconstraints/CheckCase.java = (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/customconstraints/CheckCase.java 2009-= 11-30 15:59:09 UTC (rev 18102) @@ -0,0 +1,43 @@ +// $Id: CheckCase.java 17946 2009-11-06 18:23:48Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.testmodel.customconstraints; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.validation.Constraint; + +(a)Target( { METHOD, FIELD, ANNOTATION_TYPE }) +(a)Retention(RUNTIME) +(a)Constraint(validatedBy =3D CheckCaseValidator.class) +(a)Documented +public @interface CheckCase { + + String message() default "{validator.checkcase}"; + + Class[] groups() default {}; + = + CaseMode value(); + +} Added: validator/trunk/hibernate-validator-annotation-processor/src/test/ja= va/org/hibernate/validator/ap/testmodel/customconstraints/CheckCaseValidato= r.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/customconstraints/CheckCaseValidator.j= ava (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/customconstraints/CheckCaseValidator.j= ava 2009-11-30 15:59:09 UTC (rev 18102) @@ -0,0 +1,44 @@ +// $Id: CheckCaseValidator.java 17946 2009-11-06 18:23:48Z hardy.ferentsch= ik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.testmodel.customconstraints; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; + +public class CheckCaseValidator implements +ConstraintValidator { + + private CaseMode caseMode; + + public void initialize(CheckCase constraintAnnotation) { + this.caseMode =3D constraintAnnotation.value(); + } + + public boolean isValid(String object, + ConstraintValidatorContext constraintContext) { + + if (object =3D=3D null) + return true; + + if (caseMode =3D=3D CaseMode.UPPER) + return object.equals(object.toUpperCase()); + else + return object.equals(object.toLowerCase()); + } + +} Added: validator/trunk/hibernate-validator-annotation-processor/src/test/ja= va/org/hibernate/validator/ap/testmodel/customconstraints/FieldLevelValidat= ionUsingCustomConstraints.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/customconstraints/FieldLevelValidation= UsingCustomConstraints.java (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testmodel/customconstraints/FieldLevelValidation= UsingCustomConstraints.java 2009-11-30 15:59:09 UTC (rev 18102) @@ -0,0 +1,33 @@ +// $Id: FieldLevelValidationUsingCustomConstraints.java 17946 2009-11-06 1= 8:23:48Z hardy.ferentschik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.testmodel.customconstraints; + +import java.util.Date; + +public class FieldLevelValidationUsingCustomConstraints { + + @CheckCase(CaseMode.UPPER) + public String string; + = + /** + * Not allowed. + */ + @CheckCase(CaseMode.UPPER) + public Date date; + +} Added: validator/trunk/hibernate-validator-annotation-processor/src/test/ja= va/org/hibernate/validator/ap/testutil/CompilerTestHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testutil/CompilerTestHelper.java = (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/testutil/CompilerTestHelper.java 2009-11-30 15:5= 9:09 UTC (rev 18102) @@ -0,0 +1,105 @@ +// $Id: CompilerTestHelper.java 17946 2009-11-06 18:23:48Z hardy.ferentsch= ik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.testutil; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.processing.Processor; +import javax.tools.DiagnosticCollector; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.JavaCompiler.CompilationTask; + +import org.hibernate.validator.ap.util.DiagnosticExpection; + +/** + * Infrastructure for unit tests based on the Java Compiler API. + * = + * @author Gunnar Morling + * + */ +public class CompilerTestHelper { + + private final JavaCompiler compiler; + = + private final String sourceBaseDir; + + /** + * TODO GM: How can JavaCompiler access all dependencies of the project? = This works within + * Eclipse, but not on the command line. + */ + private final String pathToBeanValidationApiJar; + = + public CompilerTestHelper(JavaCompiler compiler, String sourceBaseDir, St= ring pathToBeanValidationApiJar) { + + this.compiler =3D compiler; + this.sourceBaseDir =3D sourceBaseDir; + this.pathToBeanValidationApiJar =3D pathToBeanValidationApiJar; + } + + public File getSourceFile(Class clazz) { + = + String sourceFileName =3D + File.separator + clazz.getName().replace(".", File.separator) + ".java"; + = + return new File(sourceBaseDir + sourceFileName); + } + = + public boolean compile( + Processor annotationProcessor, DiagnosticCollector diagn= ostics, File... sourceFiles) { + = + StandardJavaFileManager fileManager =3D = + compiler.getStandardFileManager(null, null, null); + = + Iterable compilationUnits =3D fileManager.getJ= avaFileObjects(sourceFiles); + List optionList =3D new ArrayList(); + optionList.addAll(Arrays.asList("-classpath", pathToBeanValidationApiJar= )); + + CompilationTask task =3D compiler.getTask(null, fileManager, diagnostics= , optionList, null, compilationUnits); + + task.setProcessors(Arrays.asList(annotationProcessor)); + = + return task.call(); + } + = + public static void assertDiagnostics(DiagnosticCollector = diagnostics, DiagnosticExpection... expections) { + = + if(expections =3D=3D null) { + assertTrue(diagnostics.getDiagnostics().isEmpty()); + } + else { + = + assertEquals(diagnostics.getDiagnostics().size(), expections.length); + = + int i =3D 0; + for (DiagnosticExpection oneExpection : expections) { + = + assertEquals(diagnostics.getDiagnostics().get(i).getKind(), oneExpecti= on.getKind()); + assertEquals(diagnostics.getDiagnostics().get(i).getLineNumber(), oneE= xpection.getLineNumber()); + } + } + } + = +} Added: validator/trunk/hibernate-validator-annotation-processor/src/test/ja= va/org/hibernate/validator/ap/util/DiagnosticExpection.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/util/DiagnosticExpection.java = (rev 0) +++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/= org/hibernate/validator/ap/util/DiagnosticExpection.java 2009-11-30 15:59:0= 9 UTC (rev 18102) @@ -0,0 +1,47 @@ +// $Id: DiagnosticExpection.java 17946 2009-11-06 18:23:48Z hardy.ferentsc= hik $ +/* +* JBoss, Home of Professional Open Source +* Copyright 2009, Red Hat Middleware LLC, and individual contributors +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.hibernate.validator.ap.util; + +import javax.tools.Diagnostic; +import javax.tools.Diagnostic.Kind; + +/** + * Expectation value to be matched against a given {@link Diagnostic}. + * = + * @author Gunnar Morling + */ +public class DiagnosticExpection { + = + private final Kind kind; + = + private final long lineNumber; + = + public DiagnosticExpection(Kind kind, long lineNumber) { + = + this.kind =3D kind; + this.lineNumber =3D lineNumber; + } + + public Kind getKind() { + return kind; + } + + public long getLineNumber() { + return lineNumber; + } +} \ No newline at end of file Modified: validator/trunk/hibernate-validator-tck-runner/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-11-30 13:37= :31 UTC (rev 18101) +++ validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-11-30 15:59= :09 UTC (rev 18102) @@ -32,7 +32,7 @@ org.hibernate.jsr303.tck jsr303-tck - 1.0.2.GA + 1.0.3.GA org.jboss.test-harness --===============5810417219113461231==-- From hibernate-commits at lists.jboss.org Mon Nov 30 11:50:25 2009 Content-Type: multipart/mixed; boundary="===============2302986862733125378==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18103 - core/trunk/annotations/src/main/java/org/hibernate/cfg. Date: Mon, 30 Nov 2009 11:50:25 -0500 Message-ID: <200911301650.nAUGoPC7005804@svn01.web.mwc.hst.phx2.redhat.com> --===============2302986862733125378== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: epbernard Date: 2009-11-30 11:50:25 -0500 (Mon, 30 Nov 2009) New Revision: 18103 Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.= java Log: minor doc enhancement Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/Annotation= Binder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder= .java 2009-11-30 15:59:09 UTC (rev 18102) +++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder= .java 2009-11-30 16:50:25 UTC (rev 18103) @@ -889,6 +889,7 @@ null; } else { + //the are the root entity but we might have mapped superclasses that co= ntain the id class AccessType access =3D clazzToProcess.getAnnotation( AccessType.class ); explicitAccessType =3D access !=3D null ? access.value() : @@ -926,7 +927,6 @@ exceptionWhileWalkingElements =3D e; } = - //TODO remember why it should be !inheritanceState.hasParents if ( !hasIdentifier && !inheritanceState.hasParents ) { if ( isExplicitPropertyAnnotated !=3D null ) { //the original exception is legitimate --===============2302986862733125378==-- From hibernate-commits at lists.jboss.org Mon Nov 30 13:18:28 2009 Content-Type: multipart/mixed; boundary="===============8859634115965191924==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18104 - core/branches/Branch_3_3/core. Date: Mon, 30 Nov 2009 13:18:28 -0500 Message-ID: <200911301818.nAUIISmd020601@svn01.web.mwc.hst.phx2.redhat.com> --===============8859634115965191924== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-30 13:18:28 -0500 (Mon, 30 Nov 2009) New Revision: 18104 Modified: core/branches/Branch_3_3/core/pom.xml Log: HHH-4625 : upgrade injection plugin Modified: core/branches/Branch_3_3/core/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/Branch_3_3/core/pom.xml 2009-11-30 16:50:25 UTC (rev 1810= 3) +++ core/branches/Branch_3_3/core/pom.xml 2009-11-30 18:18:28 UTC (rev 1810= 4) @@ -97,7 +97,7 @@ org.jboss.maven.plugins maven-injection-plugin - 1.0.0 + 1.0.1 compile --===============8859634115965191924==-- From hibernate-commits at lists.jboss.org Mon Nov 30 13:18:44 2009 Content-Type: multipart/mixed; boundary="===============7098918015952603217==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18105 - core/trunk/core. Date: Mon, 30 Nov 2009 13:18:44 -0500 Message-ID: <200911301818.nAUIIiRP020649@svn01.web.mwc.hst.phx2.redhat.com> --===============7098918015952603217== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2009-11-30 13:18:44 -0500 (Mon, 30 Nov 2009) New Revision: 18105 Modified: core/trunk/core/pom.xml Log: HHH-4625 : upgrade injection plugin Modified: core/trunk/core/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/core/pom.xml 2009-11-30 18:18:28 UTC (rev 18104) +++ core/trunk/core/pom.xml 2009-11-30 18:18:44 UTC (rev 18105) @@ -98,7 +98,7 @@ org.jboss.maven.plugins maven-injection-plugin - 1.0.0 + 1.0.1 compile --===============7098918015952603217==--