Hibernate SVN: r18267 - core/branches/envers-hibernate-3.3.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-12-18 07:01:33 -0500 (Fri, 18 Dec 2009)
New Revision: 18267
Modified:
core/branches/envers-hibernate-3.3/pom.xml
Log:
Updating the pom after the release
Modified: core/branches/envers-hibernate-3.3/pom.xml
===================================================================
--- core/branches/envers-hibernate-3.3/pom.xml 2009-12-18 11:26:07 UTC (rev 18266)
+++ core/branches/envers-hibernate-3.3/pom.xml 2009-12-18 12:01:33 UTC (rev 18267)
@@ -16,7 +16,7 @@
<name>Envers</name>
<description>Support for entity auditing</description>
- <version>1.2.2.GA-hibernate-3.3</version>
+ <version>1.2.3-hibernate-3.3-SNAPSHOT</version>
<build>
<plugins>
14 years, 12 months
Hibernate SVN: r18266 - in search/trunk/src: main/java/org/hibernate/search/cfg and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-12-18 06:26:07 -0500 (Fri, 18 Dec 2009)
New Revision: 18266
Added:
search/trunk/src/main/java/org/hibernate/search/cfg/DynamicEntityBoostMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/DynamicFieldBoostMapping.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomBoostStrategy.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomFieldBoostStrategy.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/DynamicBoostedDescLibrary.java
Modified:
search/trunk/src/main/docbook/en-US/modules/mapping.xml
search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java
search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java
search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java
search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticSearchMappingFactory.java
Log:
HSEARCH-411 hopefully the last feature :)
Modified: search/trunk/src/main/docbook/en-US/modules/mapping.xml
===================================================================
--- search/trunk/src/main/docbook/en-US/modules/mapping.xml 2009-12-18 11:02:25 UTC (rev 18265)
+++ search/trunk/src/main/docbook/en-US/modules/mapping.xml 2009-12-18 11:26:07 UTC (rev 18266)
@@ -1548,8 +1548,8 @@
<classname>SearchMapping</classname> object. This object is passed to
Hibernate Search via a property set to the <classname>Configuration
</classname>object. The property key is
- <literal>hibernate.search.mapping_model</literal> or it's tpye-safe representation
- <classname>Environment.MODEL_MAPPING</classname>.</para>
+ <literal>hibernate.search.model_mapping</literal> or it's type-safe
+ representation <classname>Environment.MODEL_MAPPING</classname>.</para>
<programlisting>SearchMapping mapping = new SearchMapping();
[...]
@@ -2158,8 +2158,8 @@
<section>
<title>Mapping class bridge</title>
- <para>You can define class bridges on entities programmatically.
- This is shown in the next example:</para>
+ <para>You can define class bridges on entities programmatically. This is
+ shown in the next example:</para>
<example>
<title>Defining class briges using API</title>
@@ -2214,8 +2214,63 @@
....
}</programlisting>
- </example> </para>
+ </example></para>
</example>
</section>
+
+ <section>
+ <title>Mapping dynamic boost</title>
+
+ <para>You can apply a dynamic boost
+ factor on either a field or a whole entity: </para>
+
+ <example>
+ <title>DynamicBoost mapping using programmatic model</title>
+
+ <programlisting>SearchMapping mapping = new SearchMapping();
+
+mapping
+ .entity(DynamicBoostedDescLibrary.class)
+ .indexed()
+ <emphasis>.dynamicBoost(CustomBoostStrategy.class)</emphasis>
+ .property("libraryId", ElementType.FIELD)
+ .documentId().name("id")
+ .property("name", ElementType.FIELD)
+ .field()
+ .store(Store.YES)
+ <emphasis>.dynamicBoost(CustomFieldBoostStrategy.class)</emphasis>;
+
+cfg.getProperties().put( "hibernate.search.model_mapping", mapping );</programlisting>
+
+ <para>The next example shows the equivalent mapping using the
+ <classname>@DynamicBoost</classname> annotation: <example>
+ <title>Using the @DynamicBoost </title>
+
+ <programlisting>@Entity
+@Indexed
+@DynamicBoost(impl = CustomBoostStrategy.class)
+public class DynamicBoostedDescriptionLibrary {
+
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private int id;
+
+ private float dynScore;
+
+ @Field(store = Store.YES)
+ @DynamicBoost(impl = CustomFieldBoostStrategy.class)
+ private String name;
+
+ public DynamicBoostedDescriptionLibrary() {
+ dynScore = 1.0f;
+ }
+
+ .......
+
+}</programlisting>
+ </example></para>
+ </example>
+ </section>
</section>
</chapter>
Added: search/trunk/src/main/java/org/hibernate/search/cfg/DynamicEntityBoostMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/DynamicEntityBoostMapping.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/DynamicEntityBoostMapping.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -0,0 +1,47 @@
+package org.hibernate.search.cfg;
+
+import java.lang.annotation.ElementType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.solr.analysis.TokenizerFactory;
+import org.hibernate.search.engine.BoostStrategy;
+
+public class DynamicEntityBoostMapping {
+
+ private final SearchMapping mapping;
+ private final Map<String,Object> dynamicEntityBoost;
+ private final EntityDescriptor entity;
+ private final EntityMapping entityMapping;
+
+ public DynamicEntityBoostMapping(SearchMapping mapping, Class<? extends BoostStrategy> impl, EntityDescriptor entity, EntityMapping entityMapping) {
+ this.mapping = mapping;
+ this.entity = entity;
+ this.entityMapping = entityMapping;
+ this.dynamicEntityBoost = new HashMap<String, Object>();
+ this.entity.setDynamicEntityBoost(dynamicEntityBoost);
+ this.dynamicEntityBoost.put("impl", impl);
+
+ }
+
+ public FullTextFilterDefMapping fullTextFilterDef(String name, Class<?> 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<? extends TokenizerFactory> tokenizerFactory) {
+ return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
+ }
+
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
+ }
+
+ public ClassBridgeMapping classBridge(Class<?> impl) {
+ return new ClassBridgeMapping(mapping, entity, impl, entityMapping);
+ }
+
+}
Added: search/trunk/src/main/java/org/hibernate/search/cfg/DynamicFieldBoostMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/DynamicFieldBoostMapping.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/DynamicFieldBoostMapping.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -0,0 +1,59 @@
+package org.hibernate.search.cfg;
+
+import java.lang.annotation.ElementType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.solr.analysis.TokenizerFactory;
+import org.hibernate.search.annotations.Resolution;
+import org.hibernate.search.engine.BoostStrategy;
+
+public class DynamicFieldBoostMapping {
+
+ private final SearchMapping mapping;
+ private final EntityDescriptor entity;
+ private final Map<String,Object> dynamicFieldBoost;
+ private final PropertyDescriptor property;
+
+ public DynamicFieldBoostMapping(SearchMapping mapping, Class<? extends BoostStrategy> impl, PropertyDescriptor property, EntityDescriptor entity) {
+ this.mapping = mapping;
+ this.property = property;
+ this.entity = entity;
+ dynamicFieldBoost = new HashMap<String, Object>();
+ this.property.setDynamicFieldBoost(dynamicFieldBoost);
+ dynamicFieldBoost.put("impl", impl);
+ }
+
+ public FieldMapping field() {
+ return new FieldMapping(property, entity, mapping);
+ }
+
+ public PropertyMapping property(String name, ElementType type) {
+ return new PropertyMapping(name, type, entity, mapping);
+ }
+
+ public DateBridgeMapping dateBridge(Resolution resolution) {
+ return new DateBridgeMapping(mapping, entity, property, resolution);
+ }
+
+ public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
+ return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
+ }
+
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
+ }
+
+ public CalendarBridgeMapping calendarBridge(Resolution resolution) {
+ return new CalendarBridgeMapping(mapping,entity,property, resolution);
+ }
+
+ public IndexEmbeddedMapping indexEmbedded() {
+ return new IndexEmbeddedMapping(mapping,property,entity);
+ }
+
+ public ContainedInMapping containedIn() {
+ return new ContainedInMapping(mapping, property, entity);
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java 2009-12-18 11:02:25 UTC (rev 18265)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -43,6 +43,7 @@
private Set<Map<String, Object>> fullTextFilterDefs = new HashSet<Map<String, Object>>();
private Map<String,Object> providedId;
private Set<Map<String,Object>> classBridges = new HashSet<Map<String,Object>>();
+ private Map<String, Object> dynamicEntityBoost;
public Map<String, Object> getIndexed() {
return indexed;
@@ -119,6 +120,14 @@
return this.providedId;
}
+ public void setDynamicEntityBoost(Map<String, Object> dynamicEntityBoost) {
+ this.dynamicEntityBoost = dynamicEntityBoost;
+ }
+
+ public Map<String, Object> getDynamicEntityBoost() {
+ return this.dynamicEntityBoost;
+ }
+
private static class PropertyKey {
private String name;
private ElementType type;
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java 2009-12-18 11:02:25 UTC (rev 18265)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -29,11 +29,11 @@
import java.util.Map;
import org.apache.solr.analysis.TokenizerFactory;
-
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Resolution;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.TermVector;
+import org.hibernate.search.engine.BoostStrategy;
/**
* @author Emmanuel Bernard
@@ -120,4 +120,8 @@
return new CalendarBridgeMapping(mapping,entity,property, resolution);
}
+ public DynamicFieldBoostMapping dynamicBoost(Class<? extends BoostStrategy> impl) {
+ return new DynamicFieldBoostMapping(mapping, impl, property, entity);
+ }
+
}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java 2009-12-18 11:02:25 UTC (rev 18265)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -30,6 +30,7 @@
import org.apache.solr.analysis.TokenizerFactory;
import org.hibernate.search.analyzer.Discriminator;
+import org.hibernate.search.engine.BoostStrategy;
public class IndexedMapping {
@@ -92,5 +93,9 @@
public ProvidedIdMapping providedId() {
return new ProvidedIdMapping(mapping,entity);
}
+
+ public DynamicEntityBoostMapping dynamicBoost(Class<? extends BoostStrategy> impl) {
+ return new DynamicEntityBoostMapping(mapping, impl, entity, entityMapping);
+ }
}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java 2009-12-18 11:02:25 UTC (rev 18265)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -44,6 +44,7 @@
private Map<String, Object> documentId;
private Map<String, Object> analyzerDiscriminator;
+ private Map<String, Object> dynamicFieldBoost;
public PropertyDescriptor(String name, ElementType type) {
this.name = name;
@@ -105,4 +106,12 @@
this.containedIn = containedIn;
}
+ public void setDynamicFieldBoost(Map<String, Object> dynamicFieldBoost) {
+ this.dynamicFieldBoost = dynamicFieldBoost;
+ }
+
+ public Map<String,Object> getDynamicFieldBoost() {
+ return this.dynamicFieldBoost;
+ }
+
}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java 2009-12-18 11:02:25 UTC (rev 18265)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -31,6 +31,7 @@
import java.util.Map;
import java.util.Set;
+import org.apache.lucene.analysis.Tokenizer;
import org.apache.solr.analysis.TokenizerFactory;
/**
Modified: search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java 2009-12-18 11:02:25 UTC (rev 18265)
+++ search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -56,6 +56,7 @@
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.DynamicBoost;
import org.hibernate.search.annotations.FieldBridge;
import org.hibernate.search.annotations.Fields;
import org.hibernate.search.annotations.FullTextFilterDef;
@@ -314,6 +315,17 @@
populateAnnotationArray();
}
}
+
+ private void createDynamicFieldBoost(PropertyDescriptor property) {
+ if (property.getDynamicFieldBoost() != null) {
+ AnnotationDescriptor dynamicBoostAnn = new AnnotationDescriptor( DynamicBoost.class );
+ Set<Entry<String,Object>> entrySet = property.getDynamicFieldBoost().entrySet();
+ for (Entry<String, Object> entry : entrySet) {
+ dynamicBoostAnn.setValue(entry.getKey(), entry.getValue());
+ }
+ annotations.put(DynamicBoost.class, AnnotationFactory.create( dynamicBoostAnn ));
+ }
+ }
private void createDateBridge(PropertyDescriptor property) {
Map<String, Object> map = property.getDateBridge();
@@ -405,10 +417,12 @@
final org.hibernate.search.annotations.Field[] fieldArray =
new org.hibernate.search.annotations.Field[fieldAnnotations.size()];
final org.hibernate.search.annotations.Field[] fieldAsArray = fieldAnnotations.toArray( fieldArray );
+
fieldsAnnotation.setValue( "value", fieldAsArray );
annotations.put( Fields.class, AnnotationFactory.create( fieldsAnnotation ) );
createDateBridge(property);
createCalendarBridge(property);
+ createDynamicFieldBoost(property);
}
@@ -486,6 +500,15 @@
annotations.put(ClassBridges.class, AnnotationFactory.create( classBridgesAnn ));
}
+ if (entity.getDynamicEntityBoost() != null) {
+ AnnotationDescriptor dynamicBoostAnn = new AnnotationDescriptor( DynamicBoost.class );
+ Set<Entry<String,Object>> entrySet = entity.getDynamicEntityBoost().entrySet();
+ for (Entry<String, Object> entry : entrySet) {
+ dynamicBoostAnn.setValue(entry.getKey(), entry.getValue());
+ }
+ annotations.put(DynamicBoost.class, AnnotationFactory.create( dynamicBoostAnn ));
+ }
+
}
private ClassBridge[] createClassBridgesDefArray(Set<Map<String, Object>> classBridgeDefs) {
Added: search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomBoostStrategy.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomBoostStrategy.java (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomBoostStrategy.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -0,0 +1,42 @@
+/* $Id: CustomBoostStrategy.java 17630 2009-10-06 13:38:43Z sannegrinovero $
+ *
+ * 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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.configuration;
+
+import org.hibernate.search.engine.BoostStrategy;
+
+/**
+ * Example for a custom <code>BoostStrategy</code> implementation.
+ *
+ * @author Sanne Grinovero
+ * @author Hardy Ferentschik
+ * @see org.hibernate.search.engine.BoostStrategy
+ */
+public class CustomBoostStrategy implements BoostStrategy {
+
+ public float defineBoost(Object value) {
+ DynamicBoostedDescLibrary indexed = ( DynamicBoostedDescLibrary ) value;
+ return indexed.getDynScore();
+ }
+}
Added: search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomFieldBoostStrategy.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomFieldBoostStrategy.java (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/CustomFieldBoostStrategy.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -0,0 +1,46 @@
+/* $Id: CustomFieldBoostStrategy.java 17630 2009-10-06 13:38:43Z sannegrinovero $
+ *
+ * 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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.configuration;
+
+import org.hibernate.search.engine.BoostStrategy;
+
+/**
+ * Example for a custom <code>BoostStrategy</code> implementation.
+ *
+ * @author Hardy Ferentschik
+ * @see org.hibernate.search.engine.BoostStrategy
+ */
+public class CustomFieldBoostStrategy implements BoostStrategy {
+
+ public float defineBoost(Object value) {
+ String name = ( String ) value;
+ if ( "foobar".equals( name ) ) {
+ return 3.0f;
+ }
+ else {
+ return 1.0f;
+ }
+ }
+}
Added: search/trunk/src/test/java/org/hibernate/search/test/configuration/DynamicBoostedDescLibrary.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/DynamicBoostedDescLibrary.java (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/DynamicBoostedDescLibrary.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -0,0 +1,75 @@
+/* $Id: DynamicBoostedDescriptionLibrary.java 17630 2009-10-06 13:38:43Z sannegrinovero $
+ *
+ * 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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.configuration;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * Test entity using a custom <code>CustomBoostStrategy</code> to set
+ * the document boost as the dynScore field.
+ *
+ * @author Sanne Grinovero
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class DynamicBoostedDescLibrary {
+
+ @Id
+ @GeneratedValue
+ private int libraryId;
+ private float dynScore;
+ private String name;
+
+ public DynamicBoostedDescLibrary() {
+ dynScore = 1.0f;
+ }
+
+
+ public int getLibraryId() {
+ return libraryId;
+ }
+
+ public void setLibraryId(int id) {
+ this.libraryId = id;
+ }
+
+ public float getDynScore() {
+ return dynScore;
+ }
+
+ public void setDynScore(float dynScore) {
+ this.dynScore = dynScore;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java 2009-12-18 11:02:25 UTC (rev 18265)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -33,32 +33,29 @@
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
-import org.apache.solr.analysis.EnglishPorterFilterFactory;
-import org.apache.solr.analysis.GermanStemFilterFactory;
import org.apache.solr.analysis.LowerCaseFilterFactory;
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.Environment;
import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
+import org.hibernate.search.ProjectionConstants;
import org.hibernate.search.Search;
-import org.hibernate.search.Environment;
-import org.hibernate.search.annotations.FilterCacheModeType;
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;
@@ -576,6 +573,89 @@
s.close();
}
+
+ public void testDynamicBoosts() throws Exception {
+
+ Session session = openSession();
+ session.beginTransaction();
+
+ DynamicBoostedDescLibrary lib1 = new DynamicBoostedDescLibrary();
+ lib1.setName( "one" );
+ session.persist( lib1 );
+
+ DynamicBoostedDescLibrary lib2 = new DynamicBoostedDescLibrary();
+ lib2.setName( "two" );
+ session.persist( lib2 );
+
+ session.getTransaction().commit();
+ session.close();
+
+ float lib1Score = getScore( new TermQuery( new Term( "name", "one" ) ) );
+ float lib2Score = getScore( new TermQuery( new Term( "name", "two" ) ) );
+ assertEquals( "The scores should be equal", lib1Score, lib2Score );
+
+ // set dynamic score and reindex!
+ session = openSession();
+ session.beginTransaction();
+
+ session.refresh( lib2 );
+ lib2.setDynScore( 2.0f );
+
+ session.getTransaction().commit();
+ session.close();
+
+ lib1Score = getScore( new TermQuery( new Term( "name", "one" ) ) );
+ lib2Score = getScore( new TermQuery( new Term( "name", "two" ) ) );
+ assertTrue( "lib2score should be greater than lib1score", lib1Score < lib2Score );
+
+
+
+ lib1Score = getScore( new TermQuery( new Term( "name", "foobar" ) ) );
+ assertEquals( "lib1score should be 0 since term is not yet indexed.", 0.0f, lib1Score );
+
+ // index foobar
+ session = openSession();
+ session.beginTransaction();
+
+ session.refresh( lib1 );
+ lib1.setName( "foobar" );
+
+ session.getTransaction().commit();
+ session.close();
+
+ lib1Score = getScore( new TermQuery( new Term( "name", "foobar" ) ) );
+ lib2Score = getScore( new TermQuery( new Term( "name", "two" ) ) );
+ assertTrue( "lib1score should be greater than lib2score", lib1Score > lib2Score );
+ }
+
+ private float getScore(Query query) {
+ Session session = openSession();
+ Object[] queryResult;
+ float score;
+ try {
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+ List<?> resultList = fullTextSession
+ .createFullTextQuery( query, DynamicBoostedDescLibrary.class )
+ .setProjection( ProjectionConstants.SCORE, ProjectionConstants.EXPLANATION )
+ .setMaxResults( 1 )
+ .list();
+
+ if ( resultList.size() == 0 ) {
+ score = 0.0f;
+ }
+ else {
+ queryResult = ( Object[] ) resultList.get( 0 );
+ score = ( Float ) queryResult[0];
+ String explanation = queryResult[1].toString();
+ log.debug( "score: " + score + " explanation: " + explanation );
+ }
+ }
+ finally {
+ session.close();
+ }
+ return score;
+ }
+
private int nbrOfMatchingResults(String field, String token, FullTextSession s) throws ParseException {
QueryParser parser = new QueryParser( field, new StandardAnalyzer() );
org.apache.lucene.search.Query luceneQuery = parser.parse( token );
@@ -636,8 +716,6 @@
protected void configure(Configuration cfg) {
super.configure( cfg );
cfg.getProperties().put( Environment.MODEL_MAPPING, ProgrammaticSearchMappingFactory.class.getName() );
- //cfg.setProperty( "hibernate.search.default.directory_provider", FSDirectoryProvider.class.getName() );
-
}
public void NotUseddefineMapping() {
@@ -685,6 +763,7 @@
ProductCatalog.class,
Item.class,
Departments.class,
+ DynamicBoostedDescLibrary.class
};
}
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticSearchMappingFactory.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticSearchMappingFactory.java 2009-12-18 11:02:25 UTC (rev 18265)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticSearchMappingFactory.java 2009-12-18 11:26:07 UTC (rev 18266)
@@ -79,6 +79,14 @@
.field().name("description").analyzer("en").index(Index.TOKENIZED).store(Store.YES)
.property("productCatalog", ElementType.FIELD)
.containedIn()
+ .entity(DynamicBoostedDescLibrary.class)
+ .indexed()
+ .dynamicBoost(CustomBoostStrategy.class)
+ .property("libraryId", ElementType.FIELD)
+ .documentId().name("id")
+ .property("name", ElementType.FIELD)
+ .field().store(Store.YES)
+ .dynamicBoost(CustomFieldBoostStrategy.class)
.entity(Departments.class)
.classBridge(CatDeptsFieldsClassBridge.class)
.name("branchnetwork")
14 years, 12 months
Hibernate SVN: r18265 - core/tags.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-12-18 06:02:25 -0500 (Fri, 18 Dec 2009)
New Revision: 18265
Added:
core/tags/envers-1.2.2.GA-hibernate-3.3/
Log:
Tagging the 1.2.2.GA release
Copied: core/tags/envers-1.2.2.GA-hibernate-3.3 (from rev 18264, core/branches/envers-hibernate-3.3)
14 years, 12 months
Hibernate SVN: r18264 - core/branches/envers-hibernate-3.3.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-12-18 05:59:41 -0500 (Fri, 18 Dec 2009)
New Revision: 18264
Modified:
core/branches/envers-hibernate-3.3/pom.xml
Log:
Preparing the 1.2.2.GA release
Modified: core/branches/envers-hibernate-3.3/pom.xml
===================================================================
--- core/branches/envers-hibernate-3.3/pom.xml 2009-12-18 10:02:26 UTC (rev 18263)
+++ core/branches/envers-hibernate-3.3/pom.xml 2009-12-18 10:59:41 UTC (rev 18264)
@@ -16,7 +16,7 @@
<name>Envers</name>
<description>Support for entity auditing</description>
- <version>1.2.2-hibernate-3.3-SNAPSHOT</version>
+ <version>1.2.2.GA-hibernate-3.3</version>
<build>
<plugins>
14 years, 12 months
Hibernate SVN: r18263 - in core/trunk: annotations/src/test/resources/org/hibernate/test/annotations/xml/ejb3 and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-12-18 05:02:26 -0500 (Fri, 18 Dec 2009)
New Revision: 18263
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm.xml
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm3.xml
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
Log:
HHH-4667 accept orm 2 and orm 1 files. Also improved error reports
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java 2009-12-18 06:23:17 UTC (rev 18262)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java 2009-12-18 10:02:26 UTC (rev 18263)
@@ -26,6 +26,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.StringReader;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -54,6 +55,8 @@
import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.ErrorHandler;
import org.hibernate.AnnotationException;
import org.hibernate.DuplicateMappingException;
@@ -67,6 +70,7 @@
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
+import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.cfg.annotations.Version;
import org.hibernate.cfg.annotations.reflection.JPAMetadataProvider;
import org.hibernate.cfg.beanvalidation.BeanValidationActivator;
@@ -839,32 +843,76 @@
@Override
public AnnotationConfiguration addInputStream(InputStream xmlInputStream) throws MappingException {
try {
- List errors = new ArrayList();
- SAXReader saxReader = xmlHelper.createSAXReader( "XML InputStream", errors, getEntityResolver() );
+ /*
+ * try and parse the document:
+ * - try and validate the document with orm_2_0.xsd
+ * - if it fails because of the version attribute mismatch, try and validate the document with orm_1_0.xsd
+ */
+ List<SAXParseException> errors = new ArrayList<SAXParseException>();
+ SAXReader saxReader = new SAXReader( );
+ saxReader.setEntityResolver( getEntityResolver() );
+ saxReader.setErrorHandler( new ErrorLogger(errors) );
+ saxReader.setMergeAdjacentText(true);
+ saxReader.setValidation(true);
+
+ setValidationFor( saxReader, "orm_2_0.xsd" );
+
+ org.dom4j.Document doc = null;
try {
- saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
- //saxReader.setFeature( "http://apache.org/xml/features/validation/dynamic", 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"
- );
+ doc = saxReader.read( new InputSource( xmlInputStream ) );
}
- catch ( SAXException e ) {
- saxReader.setValidation( false );
+ catch ( DocumentException e ) {
+ //the document is syntactically incorrect
+
+ //DOM4J sometimes wraps the SAXParseException wo much interest
+ final Throwable throwable = e.getCause();
+ if ( e.getCause() == null || !( throwable instanceof SAXParseException ) ) {
+ throw new MappingException( "Could not parse JPA mapping document", e );
+ }
+ errors.add( (SAXParseException) throwable );
}
- org.dom4j.Document doc = saxReader
- .read( new InputSource( xmlInputStream ) );
+ boolean isV1Schema = false;
if ( errors.size() != 0 ) {
- throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) );
+ SAXParseException exception = errors.get( 0 );
+ final String errorMessage = exception.getMessage();
+ //does the error look like a schema mismatch?
+ isV1Schema = doc != null
+ && errorMessage.contains("1.0")
+ && errorMessage.contains("2.0")
+ && errorMessage.contains("version");
}
+ if (isV1Schema) {
+ //reparse with v1
+ errors.clear();
+ setValidationFor( saxReader, "orm_1_0.xsd" );
+ try {
+ //too bad we have to reparse to validate again :(
+ saxReader.read( new StringReader( doc.asXML() ) );
+ }
+ catch ( DocumentException e ) {
+ //oops asXML fails even if the core doc parses initially
+ new AssertionFailure("Error in DOM4J leads to a bug in Hibernate", e);
+ }
+
+ }
+ if ( errors.size() != 0 ) {
+ //report errors in exception
+ StringBuilder errorMessage = new StringBuilder( );
+ for (SAXParseException error : errors) {
+ errorMessage.append("Error parsing XML (line")
+ .append(error.getLineNumber())
+ .append(" : column ")
+ .append(error.getColumnNumber())
+ .append("): ")
+ .append(error.getMessage())
+ .append("\n");
+ }
+ throw new MappingException( "Invalid ORM mapping file.\n" + errorMessage.toString() );
+ }
add( doc );
return this;
}
- catch ( DocumentException e ) {
- throw new MappingException( "Could not parse mapping document in input stream", e );
- }
finally {
try {
xmlInputStream.close();
@@ -875,6 +923,40 @@
}
}
+ private static class ErrorLogger implements ErrorHandler {
+ private List<SAXParseException> errors;
+
+ public ErrorLogger(List<SAXParseException> errors) {
+ this.errors = errors;
+ }
+
+ public void warning(SAXParseException exception) throws SAXException {
+ errors.add( exception );
+ }
+
+ public void error(SAXParseException exception) throws SAXException {
+ errors.add( exception );
+ }
+
+ public void fatalError(SAXParseException exception) throws SAXException {
+ }
+ }
+
+ private void setValidationFor(SAXReader saxReader, String xsd) {
+ try {
+ saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
+ //saxReader.setFeature( "http://apache.org/xml/features/validation/dynamic", true );
+ //set the default schema locators
+ saxReader.setProperty(
+ "http://apache.org/xml/properties/schema/external-schemaLocation",
+ "http://java.sun.com/xml/ns/persistence/orm " + xsd
+ );
+ }
+ catch ( SAXException e ) {
+ saxReader.setValidation( false );
+ }
+ }
+
public SessionFactory buildSessionFactory() throws HibernateException {
enableLegacyHibernateValidator();
enableBeanValidation();
Modified: core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm.xml
===================================================================
--- core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm.xml 2009-12-18 06:23:17 UTC (rev 18262)
+++ core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm.xml 2009-12-18 10:02:26 UTC (rev 18263)
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- version="1.0"
- >
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ version="2.0">
<!-- no grammar specified should pass -->
<persistence-unit-metadata>
<persistence-unit-defaults>
Modified: core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm3.xml
===================================================================
--- core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm3.xml 2009-12-18 06:23:17 UTC (rev 18262)
+++ core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm3.xml 2009-12-18 10:02:26 UTC (rev 18263)
@@ -2,9 +2,8 @@
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
- version="1.0"
- >
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm/orm_2_0.xsd"
+ version="2.0">
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Lighter" access="FIELD" metadata-complete="true">
<attributes>
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2009-12-18 06:23:17 UTC (rev 18262)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2009-12-18 10:02:26 UTC (rev 18263)
@@ -68,6 +68,11 @@
}
private static Document loadURL(URL configURL, EntityResolver resolver) throws Exception {
+ /*
+ * try and parse the document:
+ * - try and validate the document with persistence_2_0.xsd
+ * - if it fails because of the version attribute mismatch, try and validate the document with persistence_1_0.xsd
+ */
InputStream is = null;
if (configURL != null) {
URLConnection conn = configURL.openConnection();
@@ -75,8 +80,9 @@
is = conn.getInputStream();
}
if ( is == null ) {
- throw new IOException( "Failed to obtain InputStream from url: " + configURL );
+ throw new IOException( "Failed to obtain InputStream while reading persistence.xml file: " + configURL );
}
+
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware( true );
final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
@@ -91,6 +97,8 @@
docBuilder.setEntityResolver( resolver );
List<SAXParseException> errors = new ArrayList<SAXParseException>();
Document doc = null;
+
+ //first sparse document and collect syntaxic errors
try {
doc = docBuilder.parse( source );
}
@@ -99,7 +107,7 @@
}
if (errors.size() == 0) {
- v2Validator.setErrorHandler( new ErrorLogger( "XML InputStream", errors, resolver ) );
+ v2Validator.setErrorHandler( new ErrorLogger( errors ) );
log.trace("Validate with persistence_2_0.xsd schema on file {}", configURL);
v2Validator.validate( new DOMSource( doc ) );
boolean isV1Schema = false;
@@ -108,6 +116,7 @@
log.trace("Found error with persistence_2_0.xsd schema on file {}", configURL);
SAXParseException exception = errors.get( 0 );
final String errorMessage = exception.getMessage();
+ //is it a validation error due to a v1 schema validated by a v2
isV1Schema = errorMessage.contains("1.0")
&& errorMessage.contains("2.0")
&& errorMessage.contains("version");
@@ -116,11 +125,12 @@
if (isV1Schema) {
log.trace("Validate with persistence_1_0.xsd schema on file {}", configURL);
errors.clear();
- v1Validator.setErrorHandler( new ErrorLogger( "XML InputStream", errors, resolver ) );
+ v1Validator.setErrorHandler( new ErrorLogger( errors ) );
v1Validator.validate( new DOMSource( doc ) );
}
}
if ( errors.size() != 0 ) {
+ //report all errors in the exception
StringBuilder errorMessage = new StringBuilder( );
for (SAXParseException error : errors) {
errorMessage.append("Error parsing XML (line")
@@ -310,17 +320,14 @@
}
public static class ErrorLogger implements ErrorHandler {
- private String file;
- private List errors;
- private EntityResolver resolver;
+ private List<SAXParseException> errors;
- ErrorLogger(String file, List errors, EntityResolver resolver) {
- this.file = file;
+ ErrorLogger(List<SAXParseException> errors) {
this.errors = errors;
- this.resolver = resolver;
}
public void error(SAXParseException error) {
+ //what was this commented code about?
// if ( resolver instanceof EJB3DTDEntityResolver ) {
// if ( ( (EJB3DTDEntityResolver) resolver ).isResolved() == false ) return;
// }
14 years, 12 months
Hibernate SVN: r18262 - core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/connection.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-12-18 01:23:17 -0500 (Fri, 18 Dec 2009)
New Revision: 18262
Modified:
core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java
Log:
minor change, correct javadoc spell
Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java 2009-12-18 03:38:16 UTC (rev 18261)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java 2009-12-18 06:23:17 UTC (rev 18262)
@@ -83,7 +83,7 @@
* Create a connection provider based on the given information.
*
* @param properties Properties being used to build the {@link org.hibernate.SessionFactory}.
- * @param connectionProviderInjectionData Soemthing to be injected in the conenction provided
+ * @param connectionProviderInjectionData Something to be injected in the connection provided
* @return The created connection provider
* @throws HibernateException
*/
@@ -145,7 +145,7 @@
* Transform JDBC connection properties.
*
* Passed in the form <tt>hibernate.connection.*</tt> to the
- * format accepted by <tt>DriverManager</tt> by triming the leading "<tt>hibernate.connection</tt>".
+ * format accepted by <tt>DriverManager</tt> by trimming the leading "<tt>hibernate.connection</tt>".
*/
public static Properties getConnectionProperties(Properties properties) {
14 years, 12 months
Hibernate SVN: r18261 - in core/trunk: testsuite/src/test/java/org/hibernate/test/readonly and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2009-12-17 22:38:16 -0500 (Thu, 17 Dec 2009)
New Revision: 18261
Modified:
core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java
core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java
Log:
HHH-4715 : Unexpected results when an entity that is already modifiable is set to modifiable again
Modified: core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java 2009-12-17 21:14:07 UTC (rev 18260)
+++ core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java 2009-12-18 03:38:16 UTC (rev 18261)
@@ -262,6 +262,11 @@
}
public void setReadOnly(boolean readOnly, Object entity) {
+ if ( ( readOnly && status == Status.READ_ONLY ) ||
+ ( ( ! readOnly ) && status == Status.MANAGED ) ) {
+ // simply return since the status is not being changed
+ return;
+ }
if (status!=Status.MANAGED && status!=Status.READ_ONLY) {
throw new HibernateException("instance was not in a valid state");
}
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java 2009-12-17 21:14:07 UTC (rev 18260)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java 2009-12-18 03:38:16 UTC (rev 18261)
@@ -127,6 +127,71 @@
s.close();
}
+ public void testSetUpdateReadOnlyTwice() throws Exception {
+ Session s = openSession();
+ s.beginTransaction();
+ VersionedNode node = new VersionedNode( "node", "node" );
+ s.persist( node );
+ s.getTransaction().commit();
+ s.close();
+
+ clearCounts();
+
+ s = openSession();
+
+ s.beginTransaction();
+ node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
+ node.setName( "node-name" );
+ s.setReadOnly( node, true );
+ s.setReadOnly( node, true );
+ s.getTransaction().commit();
+ s.close();
+
+ assertUpdateCount( 0 );
+ assertInsertCount( 0 );
+
+ s = openSession();
+ s.beginTransaction();
+ node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
+ assertEquals( "node", node.getName() );
+ assertEquals( 0, node.getVersion() );
+ s.delete( node );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testUpdateSetModifiable() throws Exception {
+ Session s = openSession();
+ s.beginTransaction();
+ VersionedNode node = new VersionedNode( "node", "node" );
+ s.persist( node );
+ s.getTransaction().commit();
+ s.close();
+
+ clearCounts();
+
+ s = openSession();
+
+ s.beginTransaction();
+ node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
+ node.setName( "node-name" );
+ s.setReadOnly( node, false );
+ s.getTransaction().commit();
+ s.close();
+
+ assertUpdateCount( 1 );
+ assertInsertCount( 0 );
+
+ s = openSession();
+ s.beginTransaction();
+ node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
+ assertEquals( "node-name", node.getName() );
+ assertEquals( 1, node.getVersion() );
+ s.delete( node );
+ s.getTransaction().commit();
+ s.close();
+ }
+
public void testAddNewChildToReadOnlyParent() throws Exception {
Session s = openSession();
s.beginTransaction();
14 years, 12 months
Hibernate SVN: r18260 - in core/trunk/annotations/src: main/java/org/hibernate/cfg/annotations and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-12-17 16:14:07 -0500 (Thu, 17 Dec 2009)
New Revision: 18260
Added:
core/trunk/annotations/src/main/java/org/hibernate/cfg/AccessType.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyContainer.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Closet.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Foobar.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Bed.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Being.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/BigBed.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Chair.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess2.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess3.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess4.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseFieldAccess.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CoursePropertyAccess.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Furniture.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Gardenshed.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Person.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Student.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Thingy.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/User.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Woody.java
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/InheritanceState.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyData.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyInferredData.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/WrappedInferredData.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java
Log:
HHH-4527 - first cut for supporting JPA2 @Access annotation. Not quite complete and needs some more tests.
Added: core/trunk/annotations/src/main/java/org/hibernate/cfg/AccessType.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AccessType.java (rev 0)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AccessType.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,85 @@
+// $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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.cfg;
+
+/**
+ * Enum defining deifferent access strategies for accessing entity values.
+ *
+ * @author Hardy Ferentschik
+ */
+public enum AccessType {
+ /**
+ * Default access strategy is property
+ */
+ DEFAULT( "property" ),
+
+ /**
+ * Access to value via property
+ */
+ PROPERTY( "property" ),
+
+ /**
+ * Access to value via field
+ */
+ FIELD( "field" );
+
+ private final String accessType;
+
+ AccessType(String type) {
+ this.accessType = type;
+ }
+
+ public String getType() {
+ return accessType;
+ }
+
+ public static AccessType getAccessStrategy(String type) {
+ if ( type == null ) {
+ return DEFAULT;
+ }
+ else if ( FIELD.getType().equals( type ) ) {
+ return FIELD;
+ }
+ else if ( PROPERTY.getType().equals( type ) ) {
+ return PROPERTY;
+ }
+ else {
+ // TODO historically if the type string could not be matched default access was used. Maybe this should be an exception though!?
+ return DEFAULT;
+ }
+ }
+
+ public static AccessType getAccessStrategy(javax.persistence.AccessType type) {
+ if ( javax.persistence.AccessType.PROPERTY.equals( type ) ) {
+ return PROPERTY;
+ }
+ else if ( javax.persistence.AccessType.FIELD.equals( type ) ) {
+ return FIELD;
+ }
+ else {
+ return DEFAULT;
+ }
+ }
+}
Property changes on: core/trunk/annotations/src/main/java/org/hibernate/cfg/AccessType.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -1,3 +1,4 @@
+// $Id:$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@@ -24,8 +25,8 @@
package org.hibernate.cfg;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -34,6 +35,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import javax.persistence.Access;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.DiscriminatorType;
@@ -68,7 +70,6 @@
import javax.persistence.SqlResultSetMappings;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
-import javax.persistence.Transient;
import javax.persistence.Version;
import javax.persistence.ElementCollection;
import javax.persistence.CollectionTable;
@@ -83,7 +84,6 @@
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;
@@ -116,10 +116,8 @@
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;
@@ -424,6 +422,11 @@
/**
* Bind a class having JSR175 annotations
* The subclasses <b>have to</b> be binded after its mother class
+ *
+ * @param clazzToProcess entity to bind as {@code XClass} instance
+ * @param inheritanceStatePerClass Meta data about the inheritance relationships for all mapped classes
+ * @param mappings Mapping meta data
+ * @throws MappingException in case there is an configuration error
*/
public static void bindClass(
XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings
@@ -516,12 +519,12 @@
entityBinder.setWhere( whereAnn );
entityBinder.setCache( cacheAnn );
entityBinder.setInheritanceState( inheritanceState );
-
+
//Filters are not allowed on subclasses
if ( !inheritanceState.hasParents() ) {
bindFilters(clazzToProcess, entityBinder, mappings);
}
-
+
entityBinder.bindEntity();
if ( inheritanceState.hasTable() ) {
@@ -621,7 +624,7 @@
// check properties
List<PropertyData> elements =
getElementsToProcess(
- persistentClass, clazzToProcess, inheritanceStatePerClass, propertyHolder, entityBinder, mappings
+ persistentClass, clazzToProcess, inheritanceStatePerClass, entityBinder, mappings
);
if ( elements == null ) {
throw new AnnotationException( "No identifier specified for entity: " + propertyHolder.getEntityName() );
@@ -650,8 +653,7 @@
if ( idClass != null ) {
XClass compositeClass = mappings.getReflectionManager().toXClass( idClass.value() );
boolean isComponent = true;
- boolean propertyAnnotated = entityBinder.isPropertyAnnotated( compositeClass );
- String propertyAccessor = entityBinder.getPropertyAccessor( compositeClass );
+ AccessType propertyAccessor = entityBinder.getPropertyAccessor( compositeClass );
String generatorType = "assigned";
String generator = BinderHelper.ANNOTATION_STRING_DEFAULT;
PropertyData inferredData = new PropertyPreloadedData(
@@ -672,7 +674,6 @@
propertyHolder,
localGenerators,
isComponent,
- propertyAnnotated,
propertyAccessor, entityBinder,
true,
false, mappings, inheritanceStatePerClass
@@ -684,7 +685,6 @@
propertyHolder,
inferredData,
baseInferredData,
- propertyAnnotated,
propertyAccessor, false,
entityBinder,
true, true,
@@ -875,11 +875,11 @@
.getName()
);
}
-
+
return true;
}
- /**
+ /*
* Get the annotated elements
* Guess the annotated element from @Id or @EmbeddedId presence
* Change EntityBinder by side effect
@@ -887,9 +887,15 @@
private static List<PropertyData> getElementsToProcess(
PersistentClass persistentClass, XClass clazzToProcess,
Map<XClass, InheritanceState> inheritanceStatePerClass,
- PropertyHolder propertyHolder, EntityBinder entityBinder, ExtendedMappings mappings
+ EntityBinder entityBinder, ExtendedMappings mappings
) {
InheritanceState inheritanceState = inheritanceStatePerClass.get( clazzToProcess );
+ assert !inheritanceState.isEmbeddableSuperclass();
+
+ AccessType accessType = determineExplicitAccessType(
+ clazzToProcess, inheritanceStatePerClass, mappings, inheritanceState
+ );
+
List<XClass> classesToProcess = getMappedSuperclassesTillNextEntityOrdered(
persistentClass, clazzToProcess, inheritanceStatePerClass, mappings
);
@@ -897,53 +903,14 @@
int deep = classesToProcess.size();
boolean hasIdentifier = false;
- assert !inheritanceState.isEmbeddableSuperclass();
- Boolean isExplicitPropertyAnnotated = null;
- String explicitAccessType;
- if ( inheritanceState.hasParents() ) {
- InheritanceState superEntityState =
- InheritanceState.getInheritanceStateOfSuperEntity(
- clazzToProcess, inheritanceStatePerClass, mappings.getReflectionManager()
- );
- isExplicitPropertyAnnotated = superEntityState != null ?
- superEntityState.isPropertyAnnotated() :
- null;
- explicitAccessType = superEntityState != null ?
- superEntityState.getAccessType() :
- null;
- }
- else {
- //the are the root entity but we might have mapped superclasses that contain the id class
- AccessType access = clazzToProcess.getAnnotation( AccessType.class );
- explicitAccessType = access != null ?
- access.value() :
- null;
- if ( "property".equals( explicitAccessType ) ) {
- isExplicitPropertyAnnotated = Boolean.TRUE;
- }
- else if ( "field".equals( explicitAccessType ) ) {
- isExplicitPropertyAnnotated = Boolean.FALSE;
- }
- }
- Boolean isPropertyAnnotated = isExplicitPropertyAnnotated == null ?
- Boolean.TRUE :
- //default to property and fallback if needed
- isExplicitPropertyAnnotated;
- String accessType = explicitAccessType != null ?
- explicitAccessType :
- "property";
/*
* delay the exception in case field access is used
*/
AnnotationException exceptionWhileWalkingElements = null;
try {
for (int index = 0; index < deep; index++) {
- XClass clazz = classesToProcess.get( index );
-
- boolean currentHasIdentifier = addElementsOfAClass(
- elements, propertyHolder, isPropertyAnnotated,
- accessType, clazz, mappings
- );
+ PropertyContainer properyContainer = new PropertyContainer( classesToProcess.get( index ) );
+ boolean currentHasIdentifier = addElementsOfClass( elements, accessType , properyContainer, mappings );
hasIdentifier = hasIdentifier || currentHasIdentifier;
}
}
@@ -952,43 +919,85 @@
}
if ( !hasIdentifier && !inheritanceState.hasParents() ) {
- if ( isExplicitPropertyAnnotated != null ) {
+ if ( AccessType.PROPERTY.equals( accessType ) ) {
//the original exception is legitimate
if ( exceptionWhileWalkingElements != null) throw exceptionWhileWalkingElements;
return null; //explicit but no @Id: the upper layer will raise an exception
}
- isPropertyAnnotated = !isPropertyAnnotated;
- accessType = "field";
+ accessType = AccessType.FIELD;
elements.clear();
for (int index = 0; index < deep; index++) {
- XClass clazz = classesToProcess.get( index );
- boolean currentHasIdentifier = addElementsOfAClass(
- elements, propertyHolder, isPropertyAnnotated,
- accessType, clazz, mappings
- );
+ PropertyContainer properyContainer = new PropertyContainer( classesToProcess.get( index ) );
+ boolean currentHasIdentifier = addElementsOfClass(elements, accessType, properyContainer, mappings );
hasIdentifier = hasIdentifier || currentHasIdentifier;
}
}
- //the field show no id, fallback tot he original exception
+ //the field show no id, fallback to he original exception
if (!hasIdentifier && exceptionWhileWalkingElements != null) throw exceptionWhileWalkingElements;
- //TODO set the access type here?
- entityBinder.setPropertyAnnotated( isPropertyAnnotated );
entityBinder.setPropertyAccessor( accessType );
- inheritanceState.setPropertyAnnotated( isPropertyAnnotated );
inheritanceState.setAccessType( accessType );
return hasIdentifier || inheritanceState.hasParents() ?
elements :
null;
}
+ /*
+ * Check whether either the class itself or any of its super classes explicitly defines a value access strategy.
+ *
+ * @return {@code AccessType.FIELD} or {@code AccessType.PROPERTY} in case there is an explicit value,
+ * {@code AccessType.DEFAULT} otherwise.
+ */
+ private static AccessType determineExplicitAccessType(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings, InheritanceState inheritanceState) {
+ AccessType explicitAccessType = AccessType.DEFAULT;
+
+ // check whether any of the super classes or the class itself
+ if ( inheritanceState.hasParents() ) {
+ InheritanceState superEntityState =
+ InheritanceState.getInheritanceStateOfSuperEntity(
+ clazzToProcess, inheritanceStatePerClass, mappings.getReflectionManager()
+ );
+ if ( superEntityState != null ) {
+ explicitAccessType = superEntityState.getAccessType();
+ }
+ }
+ else {
+ AccessType hibernateExplicitAccessType = AccessType.DEFAULT;
+ AccessType jpaExplicitAccessType = AccessType.DEFAULT;
+
+ //the are the root entity but we might have mapped superclasses that contain the id class
+ org.hibernate.annotations.AccessType accessType = clazzToProcess.getAnnotation( org.hibernate.annotations.AccessType.class );
+ if ( accessType != null ) {
+ hibernateExplicitAccessType = AccessType.getAccessStrategy( accessType.value() );
+ }
+
+ Access access = clazzToProcess.getAnnotation( Access.class );
+ if( access != null ) {
+ jpaExplicitAccessType = AccessType.getAccessStrategy( access.value() );
+ }
+
+ if ( hibernateExplicitAccessType != AccessType.DEFAULT
+ && jpaExplicitAccessType != AccessType.DEFAULT
+ && hibernateExplicitAccessType != jpaExplicitAccessType ) {
+ throw new MappingException( "@AccessType and @Access specified with contradicting values. Use of @Access only is recommended. " );
+ }
+
+ if(hibernateExplicitAccessType != AccessType.DEFAULT) {
+ explicitAccessType = hibernateExplicitAccessType;
+ } else {
+ explicitAccessType = jpaExplicitAccessType;
+ }
+ }
+ return explicitAccessType;
+ }
+
private static List<XClass> getMappedSuperclassesTillNextEntityOrdered(
PersistentClass persistentClass, XClass annotatedClass,
Map<XClass, InheritanceState> inheritanceStatePerClass,
ExtendedMappings mappings
) {
-
+
//ordered to allow proper messages on properties subclassing
List<XClass> classesToProcess = new ArrayList<XClass>();
XClass currentClassInHierarchy = annotatedClass;
@@ -1034,17 +1043,17 @@
}
return classesToProcess;
}
-
- /**
- * Process the filters defined on the given class, as well as all filters defined
- * on the MappedSuperclass(s) in the inheritance hierarchy
+
+ /*
+ * Process the filters defined on the given class, as well as all filters defined
+ * on the MappedSuperclass(s) in the inheritance hierarchy
*/
- private static void bindFilters(XClass annotatedClass, EntityBinder entityBinder,
+ private static void bindFilters(XClass annotatedClass, EntityBinder entityBinder,
ExtendedMappings mappings) {
-
+
bindFilters(annotatedClass, entityBinder);
-
- XClass classToProcess = annotatedClass.getSuperclass();
+
+ XClass classToProcess = annotatedClass.getSuperclass();
while (classToProcess != null) {
AnnotatedClassType classType = mappings.getClassType( classToProcess );
if ( AnnotatedClassType.EMBEDDABLE_SUPERCLASS.equals( classType ) ) {
@@ -1052,24 +1061,24 @@
}
classToProcess = classToProcess.getSuperclass();
}
-
+
}
-
+
private static void bindFilters(XAnnotatedElement annotatedElement, EntityBinder entityBinder) {
-
+
Filters filtersAnn = annotatedElement.getAnnotation( Filters.class );
if ( filtersAnn != null ) {
for (Filter filter : filtersAnn.value()) {
entityBinder.addFilter( filter.name(), filter.condition() );
}
}
-
+
Filter filterAnn = annotatedElement.getAnnotation( Filter.class );
if ( filterAnn != null ) {
entityBinder.addFilter( filterAnn.name(), filterAnn.condition() );
}
}
-
+
private static void bindFilterDefs(XAnnotatedElement annotatedElement, ExtendedMappings mappings) {
FilterDef defAnn = annotatedElement.getAnnotation( FilterDef.class );
FilterDefs defsAnn = annotatedElement.getAnnotation( FilterDefs.class );
@@ -1111,13 +1120,13 @@
for (Parameter param : defAnn.parameters()) {
params.setProperty( param.name(), param.value() );
}
-
+
if (BinderHelper.isDefault(defAnn.name()) && defAnn.defaultForType().equals(void.class)) {
throw new AnnotationException(
- "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " +
+ "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " +
defAnn.typeClass().getName());
}
-
+
if (!BinderHelper.isDefault(defAnn.name())) {
log.info( "Binding type definition: {}", defAnn.name() );
mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params );
@@ -1126,10 +1135,10 @@
log.info( "Binding type definition: {}", defAnn.defaultForType().getName() );
mappings.addTypeDef( defAnn.defaultForType().getName(), defAnn.typeClass().getName(), params );
}
-
+
}
-
-
+
+
private static void bindDiscriminatorToPersistentClass(
RootClass rootClass,
Ejb3DiscriminatorColumn discriminatorColumn, Map<String, Join> secondaryTables,
@@ -1151,95 +1160,35 @@
}
/**
- * Add elements of a class
+ *
+ * @param elements List of {@code ProperyData} instances
+ * @param propertyAccessor The default value access strategy which has to be used in case no explicit local access
+ * strategy is used
+ * @param propertyContainer Metadata about a class and its properties
+ * @param mappings Mapping meta data
+ * @return {@code true} in case an id property was found while iterating the elements of {@code annoatedClass} using
+ * the determined access strategy, {@code false} otherwise.
*/
- private static boolean addElementsOfAClass(
- List<PropertyData> elements, PropertyHolder propertyHolder, boolean isPropertyAnnotated,
- String propertyAccessor, final XClass annotatedClass, ExtendedMappings mappings
+ private static boolean addElementsOfClass(
+ List<PropertyData> elements, AccessType propertyAccessor, PropertyContainer propertyContainer, ExtendedMappings mappings
) {
boolean hasIdentifier = false;
- AccessType access = annotatedClass.getAnnotation( AccessType.class );
- String localPropertyAccessor = access != null ?
- access.value() :
- null;
- String accessType;
- if ( "property".equals( localPropertyAccessor ) || "field".equals( localPropertyAccessor ) ) {
- accessType = localPropertyAccessor;
- }
- else {
- if ( localPropertyAccessor == null ) {
- localPropertyAccessor = propertyAccessor;
- }
+ AccessType classDefinedAccessType = propertyContainer.getDefaultAccessStrategy();
- if ( isPropertyAnnotated ) {
- accessType = "property";
- }
- else {
- accessType = "field";
- }
+ if ( classDefinedAccessType.equals( AccessType.DEFAULT ) ) {
+ classDefinedAccessType = propertyAccessor;
}
- log.debug( "Processing {} {} annotation", propertyHolder.getEntityName(), accessType );
- List<XProperty> properties = annotatedClass.getDeclaredProperties( accessType );
- //order so that property are used in the same order when binding native query
- Collections.sort( properties, new Comparator<XProperty>() {
- public int compare(XProperty property1, XProperty property2) {
- return property1.getName().compareTo( property2.getName() );
- }
- } );
- for (XProperty p : properties) {
- if ( !p.isTypeResolved() && !discoverTypeWithoutReflection( p ) && !mustBeSkipped( 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=) or use an explicit @Type"
- );
- }
- final boolean currentHasIdentifier = addProperty( annotatedClass, p, elements, localPropertyAccessor, mappings );
+ Collection<XProperty> properties = propertyContainer.getProperties( classDefinedAccessType );
+ for ( XProperty p : properties ) {
+ final boolean currentHasIdentifier = addProperty(
+ propertyContainer.getXClass(), p, elements, classDefinedAccessType.getType(), mappings
+ );
hasIdentifier = hasIdentifier || currentHasIdentifier;
}
return hasIdentifier;
}
- private static boolean discoverTypeWithoutReflection(XProperty p) {
- if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToOne.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 non 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(
XClass declaringClass, XProperty property, List<PropertyData> annElts,
String propertyAccessor, ExtendedMappings mappings
@@ -1248,32 +1197,25 @@
PropertyData propertyAnnotatedElement = new PropertyInferredData(
declaringClass, property, propertyAccessor,
mappings.getReflectionManager() );
- if ( !mustBeSkipped( propertyAnnotatedElement.getProperty(), mappings ) ) {
- /*
- * put element annotated by @Id in front
- * since it has to be parsed before any association by Hibernate
- */
- final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
- if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
- annElts.add( 0, propertyAnnotatedElement );
- hasIdentifier = true;
- }
- else {
- annElts.add( propertyAnnotatedElement );
- hasIdentifier = false;
- }
+
+ /*
+ * put element annotated by @Id in front
+ * since it has to be parsed before any association by Hibernate
+ */
+ final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
+ if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
+ annElts.add( 0, propertyAnnotatedElement );
+ hasIdentifier = true;
}
+ else {
+ annElts.add( propertyAnnotatedElement );
+ hasIdentifier = false;
+ }
+
return hasIdentifier;
}
- private static boolean mustBeSkipped(XProperty property, ExtendedMappings mappings) {
- //TODO make those hardcoded tests more portable (through the bytecode provider?)
- return property.isAnnotationPresent( Transient.class )
- || "net.sf.cglib.transform.impl.InterceptFieldCallback".equals( property.getType().getName() )
- || "org.hibernate.bytecode.javassist.FieldHandler".equals( property.getType().getName() );
- }
-
- /**
+ /*
* Process annotation of a particular property
*/
private static void processElementAnnotations(
@@ -1434,9 +1376,7 @@
//guess if its a component and find id data access (property, field etc)
final boolean isComponent = returnedClass.isAnnotationPresent( Embeddable.class )
|| property.isAnnotationPresent( EmbeddedId.class );
- boolean propertyAnnotated = entityBinder.isPropertyAnnotated( returnedClass );
- String propertyAccessor = entityBinder.getPropertyAccessor( returnedClass );
- //if ( isComponent && embeddableAnn != null && embeddableAnn.access() == AccessType.FIELD ) propertyAccess = false;
+ AccessType propertyAccessor = entityBinder.getPropertyAccessor( returnedClass );
GeneratedValue generatedValue = property.getAnnotation( GeneratedValue.class );
String generatorType = generatedValue != null ?
@@ -1446,7 +1386,7 @@
generatedValue.generator() :
BinderHelper.ANNOTATION_STRING_DEFAULT;
if ( isComponent ) generatorType = "assigned"; //a component must not have any generator
-
+
bindId(
generatorType,
generator,
@@ -1455,14 +1395,13 @@
propertyHolder,
localGenerators,
isComponent,
- propertyAnnotated,
propertyAccessor, entityBinder,
false,
isIdentifierMapper,
mappings,
inheritanceStatePerClass
);
-
+
log.debug(
"Bind {} on {}", ( isComponent ? "@EmbeddedId" : "@Id" ), inferredData.getPropertyName()
);
@@ -1491,7 +1430,7 @@
propBinder.setName( inferredData.getPropertyName() );
propBinder.setReturnedClassName( inferredData.getTypeName() );
propBinder.setLazy( false );
- propBinder.setPropertyAccessorName( inferredData.getDefaultAccess() );
+ propBinder.setAccessType( inferredData.getDefaultAccess() );
propBinder.setColumns( columns );
propBinder.setHolder( propertyHolder ); //PropertyHolderBuilder.buildPropertyHolder(rootClass)
propBinder.setProperty( property );
@@ -1515,7 +1454,7 @@
//we know the property is on the actual entity
rootClass.setDeclaredVersion( prop );
}
-
+
SimpleValue simpleValue = (SimpleValue) prop.getValue();
simpleValue.setNullValue( "undefined" );
rootClass.setOptimisticLockMode( Versioning.OPTIMISTIC_LOCK_VERSION );
@@ -1630,7 +1569,7 @@
if ( property.isAnnotationPresent( OrderColumn.class ) ) {
indexColumn = IndexColumn.buildColumnFromAnnotation(
- property.getAnnotation(OrderColumn.class),
+ property.getAnnotation(OrderColumn.class),
propertyHolder,
inferredData,
entityBinder.getSecondaryTables(),
@@ -1673,7 +1612,7 @@
collectionBinder.setIgnoreNotFound( ignoreNotFound );
collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() );
collectionBinder.setMappings( mappings );
- collectionBinder.setPropertyAccessorName( inferredData.getDefaultAccess() );
+ collectionBinder.setAccessType( inferredData.getDefaultAccess() );
Ejb3Column[] elementColumns;
PropertyData virtualProperty = new WrappedInferredData( inferredData, "element" );
@@ -1732,7 +1671,7 @@
//nullify empty array
keyColumns = keyColumns != null && keyColumns.length > 0 ? keyColumns : null;
-
+
PropertyData mapKeyVirtualProperty = new WrappedInferredData( inferredData, "mapkey" );
Ejb3Column[] mapColumns = Ejb3Column.buildColumnFromAnnotation(
keyColumns,
@@ -1887,13 +1826,9 @@
isComponent = embeddedAnn != null || embeddableAnn != null;
if ( isComponent ) {
- //process component object
- //boolean propertyAccess = true;
- //if ( embeddableAnn != null && embeddableAnn.access() == AccessType.FIELD ) propertyAccess = false;
- boolean propertyAnnotated = entityBinder.isPropertyAnnotated( property );
- String propertyAccessor = entityBinder.getPropertyAccessor( property );
+ AccessType propertyAccessor = entityBinder.getPropertyAccessor( property );
bindComponent(
- inferredData, propertyHolder, propertyAnnotated, propertyAccessor, entityBinder,
+ inferredData, propertyHolder, propertyAccessor, entityBinder,
isIdentifierMapper,
mappings, isComponentEmbedded, inheritanceStatePerClass
);
@@ -1919,7 +1854,7 @@
propBinder.setName( inferredData.getPropertyName() );
propBinder.setReturnedClassName( inferredData.getTypeName() );
propBinder.setLazy( lazy );
- propBinder.setPropertyAccessorName( inferredData.getDefaultAccess() );
+ propBinder.setAccessType( inferredData.getDefaultAccess() );
propBinder.setColumns( columns );
propBinder.setHolder( propertyHolder );
propBinder.setProperty( property );
@@ -1938,7 +1873,7 @@
Index index = property.getAnnotation( Index.class );
if ( index != null ) {
if ( joinColumns != null ) {
-
+
for (Ejb3Column column : joinColumns) {
column.addIndex( index, inSecondPass );
}
@@ -2038,14 +1973,13 @@
private static void bindComponent(
PropertyData inferredData,
PropertyHolder propertyHolder,
- boolean propertyAnnotated,
- String propertyAccessor, EntityBinder entityBinder,
+ AccessType propertyAccessor, EntityBinder entityBinder,
boolean isIdentifierMapper,
ExtendedMappings mappings, boolean isComponentEmbedded,
Map<XClass, InheritanceState> inheritanceStatePerClass
) {
Component comp = fillComponent(
- propertyHolder, inferredData, propertyAnnotated, propertyAccessor, true, entityBinder,
+ propertyHolder, inferredData, propertyAccessor, true, entityBinder,
isComponentEmbedded, isIdentifierMapper,
false, mappings, inheritanceStatePerClass
);
@@ -2056,32 +1990,31 @@
binder.setName( inferredData.getPropertyName() );
binder.setValue( comp );
binder.setProperty( inferredData.getProperty() );
- binder.setPropertyAccessorName( inferredData.getDefaultAccess() );
+ binder.setAccessType( inferredData.getDefaultAccess() );
Property prop = binder.make();
propertyHolder.addProperty( prop, inferredData.getDeclaringClass() );
}
public static Component fillComponent(
PropertyHolder propertyHolder, PropertyData inferredData,
- boolean propertyAnnotated, String propertyAccessor, boolean isNullable,
+ AccessType propertyAccessor, boolean isNullable,
EntityBinder entityBinder,
boolean isComponentEmbedded, boolean isIdentifierMapper, boolean inSecondPass,
ExtendedMappings mappings, Map<XClass, InheritanceState> inheritanceStatePerClass
) {
-
- return fillComponent(propertyHolder, inferredData, null, propertyAnnotated, propertyAccessor,
+
+ return fillComponent(propertyHolder, inferredData, null, propertyAccessor,
isNullable, entityBinder, isComponentEmbedded, isIdentifierMapper, inSecondPass, mappings,
inheritanceStatePerClass);
}
-
+
public static Component fillComponent(
PropertyHolder propertyHolder, PropertyData inferredData, PropertyData baseInferredData,
- boolean propertyAnnotated, String propertyAccessor, boolean isNullable,
- EntityBinder entityBinder,
+ AccessType propertyAccessor, boolean isNullable, EntityBinder entityBinder,
boolean isComponentEmbedded, boolean isIdentifierMapper, boolean inSecondPass, ExtendedMappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass
) {
-
+
/**
* 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, hence second pass
@@ -2104,48 +2037,33 @@
comp, subpath,
inferredData, propertyHolder, mappings
);
-
+
List<PropertyData> classElements = new ArrayList<PropertyData>();
XClass returnedClassOrElement = inferredData.getClassOrElement();
-
+
List<PropertyData> baseClassElements = null;
XClass baseReturnedClassOrElement;
PropertyHolder baseSubHolder;
if(baseInferredData != null)
{
- baseSubHolder = PropertyHolderBuilder.buildPropertyHolder(
- comp, subpath,
- inferredData, propertyHolder, mappings
- );
baseClassElements = new ArrayList<PropertyData>();
baseReturnedClassOrElement = baseInferredData.getClassOrElement();
bindTypeDefs(baseReturnedClassOrElement, mappings);
- addElementsOfAClass(
- baseClassElements,
- baseSubHolder,
- propertyAnnotated,
- propertyAccessor, baseReturnedClassOrElement, mappings
- );
+ PropertyContainer propContainer = new PropertyContainer( baseReturnedClassOrElement );
+ addElementsOfClass( baseClassElements, propertyAccessor, propContainer, mappings );
}
//embeddable elements can have type defs
bindTypeDefs(returnedClassOrElement, mappings);
- addElementsOfAClass(
- classElements,
- subHolder,
- propertyAnnotated,
- propertyAccessor, returnedClassOrElement, mappings
- );
+ PropertyContainer propContainer = new PropertyContainer( returnedClassOrElement );
+ addElementsOfClass( classElements, propertyAccessor, propContainer, mappings);
+
//add elements of the embeddable superclass
XClass superClass = inferredData.getPropertyClass().getSuperclass();
while ( superClass != null && superClass.isAnnotationPresent( MappedSuperclass.class ) ) {
//FIXME: proper support of typevariables incl var resolved at upper levels
- addElementsOfAClass(
- classElements,
- subHolder,
- entityBinder.isPropertyAnnotated( superClass ),
- propertyAccessor, superClass, mappings
- );
+ propContainer = new PropertyContainer( superClass );
+ addElementsOfClass( classElements, propertyAccessor, propContainer, mappings );
superClass = superClass.getSuperclass();
}
if ( baseClassElements != null ) {
@@ -2173,28 +2091,26 @@
PropertyData inferredData, Ejb3Column[] columns, PropertyHolder propertyHolder,
Map<String, IdGenerator> localGenerators,
boolean isComposite,
- boolean isPropertyAnnotated,
- String propertyAccessor, EntityBinder entityBinder, boolean isEmbedded,
+ AccessType propertyAccessor, EntityBinder entityBinder, boolean isEmbedded,
boolean isIdentifierMapper, ExtendedMappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass
) {
-
+
bindId(generatorType, generatorName, inferredData, null, columns, propertyHolder,
- localGenerators, isComposite, isPropertyAnnotated, propertyAccessor, entityBinder,
+ localGenerators, isComposite, propertyAccessor, entityBinder,
isEmbedded, isIdentifierMapper, mappings, inheritanceStatePerClass);
}
-
+
private static void bindId(
String generatorType, String generatorName, PropertyData inferredData,
PropertyData baseInferredData, Ejb3Column[] columns, PropertyHolder propertyHolder,
Map<String, IdGenerator> localGenerators,
boolean isComposite,
- boolean isPropertyAnnotated,
- String propertyAccessor, EntityBinder entityBinder, boolean isEmbedded,
+ AccessType propertyAccessor, EntityBinder entityBinder, boolean isEmbedded,
boolean isIdentifierMapper, ExtendedMappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass
) {
-
+
/*
* Fill simple value and property since and Id is a property
*/
@@ -2210,7 +2126,7 @@
SimpleValue id;
if ( isComposite ) {
id = fillComponent(
- propertyHolder, inferredData, baseInferredData, isPropertyAnnotated, propertyAccessor,
+ propertyHolder, inferredData, baseInferredData, propertyAccessor,
false, entityBinder, isEmbedded, isIdentifierMapper, false, mappings, inheritanceStatePerClass
);
Component componentId = (Component) id;
@@ -2247,7 +2163,7 @@
PropertyBinder binder = new PropertyBinder();
binder.setName( inferredData.getPropertyName() );
binder.setValue( id );
- binder.setPropertyAccessorName( inferredData.getDefaultAccess() );
+ binder.setAccessType( inferredData.getDefaultAccess() );
binder.setProperty( inferredData.getProperty() );
Property prop = binder.make();
rootClass.setIdentifierProperty( prop );
@@ -2345,7 +2261,7 @@
binder.setInsertable( columns[0].isInsertable() );
binder.setUpdatable( columns[0].isUpdatable() );
}
- binder.setPropertyAccessorName( inferredData.getDefaultAccess() );
+ binder.setAccessType( inferredData.getDefaultAccess() );
binder.setCascade( cascadeStrategy );
binder.setProperty(inferredData.getProperty());
Property prop = binder.make();
@@ -2496,7 +2412,7 @@
binder.setInsertable( columns[0].isInsertable() );
binder.setUpdatable( columns[0].isUpdatable() );
}
- binder.setPropertyAccessorName( inferredData.getDefaultAccess() );
+ binder.setAccessType( inferredData.getDefaultAccess() );
binder.setCascade( cascadeStrategy );
Property prop = binder.make();
//composite FK columns are in the same table so its OK
@@ -2556,15 +2472,12 @@
hibernateCascadeAnnotation.value();
if ( hibernateCascades != null && hibernateCascades.length > 0 ) {
- for (CascadeType cascadeType : hibernateCascades) {
- hibernateCascadeSet.add( cascadeType );
- }
+ hibernateCascadeSet.addAll( Arrays.asList( hibernateCascades ) );
}
StringBuilder cascade = new StringBuilder();
- Iterator<CascadeType> cascadeType = hibernateCascadeSet.iterator();
- while ( cascadeType.hasNext() ) {
- switch ( cascadeType.next() ) {
+ for ( CascadeType aHibernateCascadeSet : hibernateCascadeSet ) {
+ switch ( aHibernateCascadeSet ) {
case ALL:
cascade.append( "," ).append( "all" );
break;
Property changes on: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
___________________________________________________________________
Name: svn:keywords
- Date Revision Author Id
+ Id
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/InheritanceState.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/InheritanceState.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/InheritanceState.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -60,8 +60,7 @@
/**
* only defined on embedded superclasses
*/
- private String accessType = null;
- private Boolean isPropertyAnnotated;
+ private AccessType accessType = AccessType.DEFAULT;
private void extractInheritanceType() {
XAnnotatedElement element = getClazz();
@@ -108,7 +107,9 @@
do {
superclass = superclass.getSuperclass();
InheritanceState currentState = states.get( superclass );
- if ( currentState != null ) return currentState;
+ if ( currentState != null ) {
+ return currentState;
+ }
}
while ( superclass != null && !reflectionManager.equals( superclass, Object.class ) );
return null;
@@ -154,19 +155,11 @@
isEmbeddableSuperclass = embeddableSuperclass;
}
- public String getAccessType() {
+ public AccessType getAccessType() {
return accessType;
}
- public void setAccessType(String accessType) {
- this.accessType = accessType;
+ public void setAccessType(AccessType type) {
+ this.accessType = type;
}
-
- public Boolean isPropertyAnnotated() {
- return isPropertyAnnotated;
- }
-
- public void setPropertyAnnotated(Boolean propertyAnnotated) {
- isPropertyAnnotated = propertyAnnotated;
- }
}
Property changes on: core/trunk/annotations/src/main/java/org/hibernate/cfg/InheritanceState.java
___________________________________________________________________
Name: svn:keywords
- Date Revision Author Id
+ Id
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -111,7 +111,7 @@
binder.setName( propertyName );
binder.setValue( value );
binder.setCascade( cascadeStrategy );
- binder.setPropertyAccessorName( inferredData.getDefaultAccess() );
+ binder.setAccessType( inferredData.getDefaultAccess() );
Property prop = binder.make();
if ( BinderHelper.isDefault( mappedBy ) ) {
/*
Added: core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyContainer.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyContainer.java (rev 0)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyContainer.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,233 @@
+// $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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.cfg;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.TreeMap;
+import javax.persistence.Access;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Transient;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.AnnotationException;
+import org.hibernate.MappingException;
+import org.hibernate.annotations.ManyToAny;
+import org.hibernate.annotations.Target;
+import org.hibernate.annotations.Type;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
+
+/**
+ * @author Hardy Ferentschik
+ */
+
+/**
+ * A temporary class where we keep the {@code XProperty}s of a class ordered by access type.
+ */
+class PropertyContainer {
+
+ private static final Logger log = LoggerFactory.getLogger( AnnotationBinder.class );
+ private final TreeMap<String, XProperty> fieldAccessMap;
+ private final TreeMap<String, XProperty> propertyAccessMap;
+ private final XClass xClass;
+ private final AccessType defaultAccessType;
+
+ PropertyContainer(XClass clazz) {
+ this.xClass = clazz;
+ fieldAccessMap = initProperties( AccessType.FIELD );
+ propertyAccessMap = initProperties( AccessType.PROPERTY );
+ defaultAccessType = determineClassDefinedAccessStrategy();
+ checkForJpaAccess();
+
+
+ }
+
+ public XClass getXClass() {
+ return xClass;
+ }
+
+ public AccessType getDefaultAccessStrategy() {
+ return defaultAccessType;
+ }
+
+ public Collection<XProperty> getProperties(AccessType accessType) {
+ if ( AccessType.DEFAULT == accessType || AccessType.PROPERTY == accessType ) {
+ return propertyAccessMap.values();
+ }
+ else {
+ return fieldAccessMap.values();
+ }
+ }
+
+ private void checkForJpaAccess() {
+ List<XProperty> tmpList = new ArrayList<XProperty>();
+ for ( XProperty property : fieldAccessMap.values() ) {
+ Access access = property.getAnnotation( Access.class );
+ if ( access == null ) {
+ continue;
+ }
+
+ AccessType accessType = AccessType.getAccessStrategy( access.value() );
+ if ( accessType == AccessType.PROPERTY ) {
+ log.warn( "Placing @Access(AccessType.PROPERTY) on a field does not have any effect." );
+ continue;
+ }
+
+ tmpList.add( property );
+ }
+ for ( XProperty property : tmpList ) {
+ fieldAccessMap.remove( property.getName() );
+ propertyAccessMap.put( property.getName(), property );
+ }
+
+
+ tmpList.clear();
+ for ( XProperty property : propertyAccessMap.values() ) {
+ Access access = property.getAnnotation( Access.class );
+ if ( access == null ) {
+ continue;
+ }
+
+ AccessType accessType = AccessType.getAccessStrategy( access.value() );
+ if ( accessType == AccessType.FIELD ) {
+ log.warn( "Placing @Access(AccessType.FIELD) on a field does not have any effect." );
+ continue;
+ }
+
+ tmpList.add( property );
+ }
+ for ( XProperty property : tmpList ) {
+ propertyAccessMap.remove( property.getName() );
+ fieldAccessMap.put( property.getName(), property );
+ }
+ }
+
+ private TreeMap<String, XProperty> initProperties(AccessType access) {
+ //order so that property are used in the same order when binding native query
+ TreeMap<String, XProperty> propertiesMap = new TreeMap<String, XProperty>();
+ List<XProperty> properties = xClass.getDeclaredProperties( access.getType() );
+ for ( XProperty property : properties ) {
+// if ( !property.isTypeResolved() && !discoverTypeWithoutReflection( property )
+// && !mustBeSkipped( property ) ) {
+// String msg = "Property " + StringHelper.qualify( xClass.getName(), property.getName() ) +
+// " has an unbound type and no explicit target entity. Resolve this Generic usage issue" +
+// " or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type";
+// throw new AnnotationException( msg );
+// }
+ if ( !mustBeSkipped( property ) ) {
+ propertiesMap.put( property.getName(), property );
+ }
+ }
+ return propertiesMap;
+ }
+
+ private AccessType determineClassDefinedAccessStrategy() {
+ AccessType classDefinedAccessType;
+
+ AccessType hibernateDefinedAccessType = AccessType.DEFAULT;
+ AccessType jpaDefinedAccessType = AccessType.DEFAULT;
+
+ org.hibernate.annotations.AccessType accessType = xClass.getAnnotation( org.hibernate.annotations.AccessType.class );
+ if ( accessType != null ) {
+ hibernateDefinedAccessType = AccessType.getAccessStrategy( accessType.value() );
+ }
+
+ Access access = xClass.getAnnotation( Access.class );
+ if ( access != null ) {
+ jpaDefinedAccessType = AccessType.getAccessStrategy( access.value() );
+ }
+
+ if ( hibernateDefinedAccessType != AccessType.DEFAULT
+ && jpaDefinedAccessType != AccessType.DEFAULT
+ && hibernateDefinedAccessType != jpaDefinedAccessType ) {
+ throw new MappingException(
+ "@AccessType and @Access specified with contradicting values. Use of @Access only is recommended. "
+ );
+ }
+
+ if ( hibernateDefinedAccessType != AccessType.DEFAULT ) {
+ classDefinedAccessType = hibernateDefinedAccessType;
+ }
+ else {
+ classDefinedAccessType = jpaDefinedAccessType;
+ }
+ return classDefinedAccessType;
+ }
+
+ private static boolean discoverTypeWithoutReflection(XProperty p) {
+ if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToOne.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 non 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 mustBeSkipped(XProperty property) {
+ //TODO make those hardcoded tests more portable (through the bytecode provider?)
+ return property.isAnnotationPresent( Transient.class )
+ || "net.sf.cglib.transform.impl.InterceptFieldCallback".equals( property.getType().getName() )
+ || "org.hibernate.bytecode.javassist.FieldHandler".equals( property.getType().getName() );
+ }
+}
+
+
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyData.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyData.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyData.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -33,7 +33,7 @@
* @return default member access (whether field or property)
* @throws MappingException No getter or field found or wrong JavaBean spec usage
*/
- String getDefaultAccess();
+ AccessType getDefaultAccess();
/**
* @return property name
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyInferredData.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyInferredData.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyInferredData.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -23,8 +23,9 @@
*/
package org.hibernate.cfg;
+import javax.persistence.Access;
+
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;
@@ -37,7 +38,7 @@
* @author Paolo Perrotta
*/
public class PropertyInferredData implements PropertyData {
- private final String defaultAccess;
+ private final AccessType defaultAccess;
private final XProperty property;
private final ReflectionManager reflectionManager;
@@ -50,15 +51,45 @@
public PropertyInferredData(XClass declaringClass, XProperty property, String propertyAccessor, ReflectionManager reflectionManager) {
this.declaringClass = declaringClass;
this.property = property;
- this.defaultAccess = propertyAccessor;
+ this.defaultAccess = AccessType.getAccessStrategy( propertyAccessor );
this.reflectionManager = reflectionManager;
}
- public String getDefaultAccess() throws MappingException {
- // if(skip())
- // return defaultAccess;
- AccessType access = property.getAnnotation( AccessType.class );
- return access != null ? access.value() : defaultAccess;
+ public AccessType getDefaultAccess() throws MappingException {
+ AccessType accessType = defaultAccess;
+
+ AccessType hibernateAccessType = AccessType.DEFAULT;
+ AccessType jpaAccessType = AccessType.DEFAULT;
+
+ org.hibernate.annotations.AccessType accessTypeAnnotation = property.getAnnotation( org.hibernate.annotations.AccessType.class );
+ if ( accessTypeAnnotation != null ) {
+ hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() );
+ }
+
+ Access access = property.getAnnotation( Access.class );
+ if ( access != null ) {
+ jpaAccessType = AccessType.getAccessStrategy( access.value() );
+ }
+
+ if ( hibernateAccessType != AccessType.DEFAULT
+ && jpaAccessType != AccessType.DEFAULT
+ && hibernateAccessType != jpaAccessType ) {
+
+ StringBuilder builder = new StringBuilder();
+ builder.append( property.toString() );
+ builder.append(
+ " defines @AccessType and @Access with contradicting values. Use of @Access only is recommended."
+ );
+ throw new MappingException( builder.toString() );
+ }
+
+ if ( hibernateAccessType != AccessType.DEFAULT ) {
+ accessType = hibernateAccessType;
+ }
+ else if ( jpaAccessType != AccessType.DEFAULT ) {
+ accessType = jpaAccessType;
+ }
+ return accessType;
}
public String getPropertyName() throws MappingException {
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -28,19 +28,19 @@
import org.hibernate.annotations.common.reflection.XProperty;
public class PropertyPreloadedData implements PropertyData {
- private final String defaultAccess;
+ private final AccessType defaultAccess;
private final String propertyName;
private final XClass returnedClass;
- public PropertyPreloadedData(String defaultAccess, String propertyName, XClass returnedClass) {
+ public PropertyPreloadedData(AccessType defaultAccess, String propertyName, XClass returnedClass) {
this.defaultAccess = defaultAccess;
this.propertyName = propertyName;
this.returnedClass = returnedClass;
}
- public String getDefaultAccess() throws MappingException {
+ public AccessType getDefaultAccess() throws MappingException {
return defaultAccess;
}
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/WrappedInferredData.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/WrappedInferredData.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/WrappedInferredData.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -43,7 +43,7 @@
return wrappedInferredData.getClassOrElementName();
}
- public String getDefaultAccess() {
+ public AccessType getDefaultAccess() {
return wrappedInferredData.getDefaultAccess();
}
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -76,6 +76,7 @@
import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.cfg.AccessType;
import org.hibernate.cfg.AnnotatedClassType;
import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.BinderHelper;
@@ -157,6 +158,7 @@
protected Map<XClass, InheritanceState> inheritanceStatePerClass;
private XClass declaringClass;
private boolean declaringClassSet;
+ private AccessType accessType;
public void setUpdatable(boolean updatable) {
this.updatable = updatable;
@@ -170,17 +172,14 @@
this.insertable = insertable;
}
-
public void setCascadeStrategy(String cascadeStrategy) {
this.cascadeStrategy = cascadeStrategy;
}
- public void setPropertyAccessorName(String propertyAccessorName) {
- this.propertyAccessorName = propertyAccessorName;
+ public void setAccessType(AccessType accessType) {
+ this.accessType = accessType;
}
- private String propertyAccessorName;
-
public void setInverseJoinColumns(Ejb3JoinColumn[] inverseJoinColumns) {
this.inverseJoinColumns = inverseJoinColumns;
}
@@ -491,7 +490,7 @@
if ( cascadeStrategy != null && cascadeStrategy.indexOf( "delete-orphan" ) >= 0 ) {
collection.setOrphanDelete( true );
}
- binder.setPropertyAccessorName( propertyAccessorName );
+ binder.setAccessType( accessType );
binder.setProperty( property );
binder.setInsertable( insertable );
binder.setUpdatable( updatable );
@@ -1296,11 +1295,10 @@
throw new AssertionFailure( "Unable to guess collection property accessor name" );
}
- //boolean propertyAccess = embeddable == null || AccessType.PROPERTY.equals( embeddable.access() );
- PropertyData inferredData = new PropertyPreloadedData( "property", "element", elementClass );
+ PropertyData inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass );
//TODO be smart with isNullable
Component component = AnnotationBinder.fillComponent(
- holder, inferredData, isPropertyAnnotated, isPropertyAnnotated ? "property" : "field", true,
+ holder, inferredData, isPropertyAnnotated ? AccessType.PROPERTY : AccessType.FIELD, true,
entityBinder, false, false,
true, mappings, inheritanceStatePerClass
);
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import javax.persistence.Access;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
@@ -38,7 +39,6 @@
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;
@@ -60,6 +60,7 @@
import org.hibernate.annotations.Where;
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.cfg.AccessType;
import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3JoinColumn;
@@ -99,7 +100,6 @@
private ExtendedMappings mappings;
private Logger log = LoggerFactory.getLogger( EntityBinder.class );
private String discriminatorValue = "";
- private boolean isPropertyAnnotated = false;
private boolean dynamicInsert;
private boolean dynamicUpdate;
private boolean explicitHibernateEntityAnnotation;
@@ -118,12 +118,8 @@
private InheritanceState inheritanceState;
private boolean ignoreIdAnnotations;
private boolean cacheLazyProperty;
- private String propertyAccessor;
+ private AccessType propertyAccessor = AccessType.DEFAULT;
- public boolean isPropertyAnnotated() {
- return isPropertyAnnotated;
- }
-
/**
* Use as a fake one for Collection of elements
*/
@@ -847,36 +843,41 @@
}
}
- public void setPropertyAnnotated(boolean propertyAnnotated) {
- this.isPropertyAnnotated = propertyAnnotated;
- }
-
- public String getPropertyAccessor() {
+ public AccessType getPropertyAccessor() {
return propertyAccessor;
}
- public void setPropertyAccessor(String propertyAccessor) {
+ public void setPropertyAccessor(AccessType propertyAccessor) {
this.propertyAccessor = propertyAccessor;
}
- public boolean isPropertyAnnotated(XAnnotatedElement element) {
- AccessType access = element.getAnnotation( AccessType.class );
- if ( access == null ) return isPropertyAnnotated;
- String propertyAccessor = access.value();
- if ( "property".equals( propertyAccessor ) ) {
- return Boolean.TRUE;
+ public AccessType getPropertyAccessor(XAnnotatedElement element) {
+ AccessType accessType = propertyAccessor;
+
+ AccessType hibernateAccessType = null;
+ AccessType jpaAccessType = null;
+
+ org.hibernate.annotations.AccessType accessTypeAnnotation = element.getAnnotation( org.hibernate.annotations.AccessType.class );
+ if ( accessTypeAnnotation != null ) {
+ hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() );
}
- else if ( "field".equals( propertyAccessor ) ) {
- return Boolean.FALSE;
+
+ Access access = element.getAnnotation( Access.class );
+ if ( access != null ) {
+ jpaAccessType = AccessType.getAccessStrategy( access.value() );
}
- else {
- return isPropertyAnnotated;
+
+ if ( hibernateAccessType != null && jpaAccessType != null && hibernateAccessType != jpaAccessType ) {
+ throw new MappingException( " " );
}
- }
- public String getPropertyAccessor(XAnnotatedElement element) {
- AccessType access = element.getAnnotation( AccessType.class );
- if ( access == null ) return propertyAccessor;
- return access.value();
+ if ( hibernateAccessType != null ) {
+ accessType = hibernateAccessType;
+ }
+ else if ( jpaAccessType != null ) {
+ accessType = jpaAccessType;
+ }
+
+ return accessType;
}
}
Property changes on: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java
___________________________________________________________________
Name: svn:keywords
- Date Revision Author Id
+ Id
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -39,6 +39,7 @@
import org.hibernate.annotations.MapKeyManyToMany;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.cfg.AccessType;
import org.hibernate.cfg.AnnotatedClassType;
import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.BinderHelper;
@@ -227,10 +228,10 @@
//boolean propertyAccess = embeddable == null || AccessType.PROPERTY.equals( embeddable.access() );
//FIXME "index" is it right?
- PropertyData inferredData = new PropertyPreloadedData( "property", "index", elementClass );
+ PropertyData inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "index", elementClass );
//TODO be smart with isNullable
Component component = AnnotationBinder.fillComponent(
- holder, inferredData, isPropertyAnnotated, isPropertyAnnotated ? "property" : "field", true,
+ holder, inferredData, isPropertyAnnotated ? AccessType.PROPERTY : AccessType.FIELD, true,
entityBinder, false, false,
true, mappings, inheritanceStatePerClass
);
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java 2009-12-17 15:34:04 UTC (rev 18259)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -35,6 +35,7 @@
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.annotations.common.AssertionFailure;
+import org.hibernate.cfg.AccessType;
import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.PropertyHolder;
@@ -54,7 +55,7 @@
private String name;
private String returnedClassName;
private boolean lazy;
- private String propertyAccessorName;
+ private AccessType accessType;
private Ejb3Column[] columns;
private PropertyHolder holder;
private ExtendedMappings mappings;
@@ -94,8 +95,8 @@
this.lazy = lazy;
}
- public void setPropertyAccessorName(String propertyAccessorName) {
- this.propertyAccessorName = propertyAccessorName;
+ public void setAccessType(AccessType accessType) {
+ this.accessType = accessType;
}
public void setColumns(Ejb3Column[] columns) {
@@ -170,7 +171,7 @@
prop.setValue( value );
prop.setLazy( lazy );
prop.setCascade( cascade );
- prop.setPropertyAccessorName( propertyAccessorName );
+ prop.setPropertyAccessorName( accessType.getType() );
Generated ann = property != null ?
property.getAnnotation( Generated.class ) :
null;
@@ -231,5 +232,5 @@
public SimpleValueBinder getSimpleValueBinder() {
return simpleValueBinder;
}
-
+
}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Closet.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Closet.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Closet.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,30 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.test.annotations.access;
+
+import javax.persistence.Embeddable;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Embeddable
+public class Closet extends Furniture {
+ int numberOfDoors;
+}
+
+
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Closet.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Foobar.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Foobar.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Foobar.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,31 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.test.annotations.access;
+
+import javax.persistence.Entity;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Foobar {
+ String foo;
+}
+
+
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Foobar.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,154 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import junit.framework.TestCase;
+
+import org.hibernate.EntityMode;
+import org.hibernate.MappingException;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.property.BasicPropertyAccessor;
+import org.hibernate.property.DirectPropertyAccessor;
+import org.hibernate.tuple.entity.EntityMetamodel;
+import org.hibernate.tuple.entity.PojoEntityTuplizer;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class AccessMappingTest extends TestCase {
+
+ public void testInconsistentAnnotationPlacement() throws Exception {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+ cfg.addAnnotatedClass( Course.class );
+ cfg.addAnnotatedClass( Student.class );
+ try {
+ cfg.buildSessionFactory();
+ fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
+ }
+ catch ( MappingException e ) {
+ // success
+ }
+ }
+
+ public void testFieldAnnotationPlacement() throws Exception {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+ Class<?> classUnderTest = CourseFieldAccess.class;
+ cfg.addAnnotatedClass( classUnderTest );
+ cfg.addAnnotatedClass( Student.class );
+ SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
+ EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
+ .getEntityMetamodel();
+ PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
+ assertTrue(
+ "Field access should be used.",
+ tuplizer.getIdentifierGetter() instanceof DirectPropertyAccessor.DirectGetter
+ );
+ }
+
+ public void testPropertyAnnotationPlacement() throws Exception {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+ Class<?> classUnderTest = CoursePropertyAccess.class;
+ cfg.addAnnotatedClass( classUnderTest );
+ cfg.addAnnotatedClass( Student.class );
+ SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
+ EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
+ .getEntityMetamodel();
+ PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
+ assertTrue(
+ "Property access should be used.",
+ tuplizer.getIdentifierGetter() instanceof BasicPropertyAccessor.BasicGetter
+ );
+ }
+
+ public void testExplicitPropertyAccessAnnotationsOnProperty() throws Exception {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+ Class<?> classUnderTest = CourseExplicitPropertyAccess.class;
+ cfg.addAnnotatedClass( classUnderTest );
+ cfg.addAnnotatedClass( Student.class );
+ SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
+ EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
+ .getEntityMetamodel();
+ PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
+ assertTrue(
+ "Property access should be used.",
+ tuplizer.getIdentifierGetter() instanceof BasicPropertyAccessor.BasicGetter
+ );
+ }
+
+ public void testExplicitPropertyAccessAnnotationsOnField() throws Exception {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+ cfg.addAnnotatedClass( CourseExplicitPropertyAccess3.class );
+ cfg.addAnnotatedClass( Student.class );
+ try {
+ cfg.buildSessionFactory();
+ fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
+ }
+ catch ( MappingException e ) {
+ // success
+ }
+ }
+
+ public void testExplicitPropertyAccessAnnotationsWithHibernateStyleOverride() throws Exception {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+ Class<?> classUnderTest = CourseExplicitPropertyAccess2.class;
+ cfg.addAnnotatedClass( classUnderTest );
+ cfg.addAnnotatedClass( Student.class );
+ SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
+ EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
+ .getEntityMetamodel();
+ PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
+ assertTrue(
+ "Field access should be used.",
+ tuplizer.getIdentifierGetter() instanceof DirectPropertyAccessor.DirectGetter
+ );
+
+ assertTrue(
+ "Property access should be used.",
+ tuplizer.getGetter( 0 ) instanceof BasicPropertyAccessor.BasicGetter
+ );
+ }
+
+ public void testExplicitPropertyAccessAnnotationsWithJpaStyleOverride() throws Exception {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+ Class<?> classUnderTest = CourseExplicitPropertyAccess4.class;
+ cfg.addAnnotatedClass( classUnderTest );
+ cfg.addAnnotatedClass( Student.class );
+ SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
+ EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
+ .getEntityMetamodel();
+ PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
+ assertTrue(
+ "Field access should be used.",
+ tuplizer.getIdentifierGetter() instanceof DirectPropertyAccessor.DirectGetter
+ );
+
+ assertTrue(
+ "Property access should be used.",
+ tuplizer.getGetter( 0 ) instanceof BasicPropertyAccessor.BasicGetter
+ );
+ }
+}
\ No newline at end of file
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java (from rev 18194, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/AccessTest.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,184 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.access.Closet;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class AccessTest extends TestCase {
+
+ public void testDefaultConfigurationModeIsInherited() throws Exception {
+ User john = new User();
+ john.setFirstname( "John" );
+ john.setLastname( "Doe" );
+ List<User> friends = new ArrayList<User>();
+ User friend = new User();
+ friend.setFirstname( "Jane" );
+ friend.setLastname( "Doe" );
+ friends.add( friend );
+ john.setFriends( friends );
+
+ Session s = openSession();
+ s.persist( john );
+ Transaction tx = s.beginTransaction();
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ john = (User) s.get( User.class, john.getId() );
+ assertEquals("Wrong number of friends", 1, john.getFriends().size() );
+ assertNull( john.firstname );
+
+ s.delete( john );
+ tx.commit();
+ s.close();
+ }
+
+ public void testSuperclassOverriding() throws Exception {
+ Furniture fur = new Furniture();
+ fur.setColor( "Black" );
+ fur.setName( "Beech" );
+ fur.isAlive = true;
+ Session s = openSession();
+ s.persist( fur );
+ Transaction tx = s.beginTransaction();
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ fur = (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 = new Furniture();
+ fur.setGod( "Buddha" );
+ Session s = openSession();
+ s.persist( fur );
+ Transaction tx = s.beginTransaction();
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ fur = (Furniture) s.get( Furniture.class, fur.getId() );
+ assertNotNull( fur.getGod() );
+ s.delete( fur );
+ tx.commit();
+ s.close();
+ }
+
+ public void testPropertyOverriding() throws Exception {
+ Furniture fur = new Furniture();
+ fur.weight = 3;
+ Session s = openSession();
+ s.persist( fur );
+ Transaction tx = s.beginTransaction();
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ fur = (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 = new Chair();
+ chair.setPillow( "Blue" );
+ Session s = openSession();
+ s.persist( chair );
+ Transaction tx = s.beginTransaction();
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ chair = (Chair) s.get( Chair.class, chair.getId() );
+ assertNull( chair.getPillow() );
+ s.delete( chair );
+ tx.commit();
+ s.close();
+
+ }
+
+ public void testOverridenSubclass() throws Exception {
+ BigBed bed = new BigBed();
+ bed.size = 5;
+ bed.setQuality( "good" );
+ Session s = openSession();
+ s.persist( bed );
+ Transaction tx = s.beginTransaction();
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ bed = (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 = new Gardenshed();
+ gs.floors = 4;
+ Session s = openSession();
+ s.persist( gs );
+ Transaction tx = s.beginTransaction();
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ gs = (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,
+ Closet.class,
+ Person.class,
+ User.class
+ };
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Bed.java (from rev 18194, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Bed.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Bed.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Bed.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,49 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.Entity;
+import javax.persistence.Transient;
+
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+(a)Access(AccessType.PROPERTY)
+public class Bed extends Furniture {
+ String quality;
+
+ @Transient
+ public String getQuality() {
+ return quality;
+ }
+
+ public void setQuality(String quality) {
+ this.quality = quality;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Bed.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Being.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Being.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Being.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,49 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Being {
+ @Id
+ @GeneratedValue
+ private long id;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+}
+
+
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Being.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/BigBed.java (from rev 18194, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/BigBed.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/BigBed.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/BigBed.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,37 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class BigBed extends Bed {
+ @Column(name = "bed_size")
+ public int size;
+}
\ No newline at end of file
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/BigBed.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Chair.java (from rev 18194, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Chair.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Chair.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Chair.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,46 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.Transient;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Chair extends Furniture {
+
+ @Transient
+ private String pillow;
+
+ public String getPillow() {
+ return pillow;
+ }
+
+ public void setPillow(String pillow) {
+ this.pillow = pillow;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Chair.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,74 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Course {
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String title;
+
+ private List<Student> students;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @OneToMany(cascade = CascadeType.ALL)
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
+
+
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,75 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)Access(AccessType.PROPERTY)
+public class CourseExplicitPropertyAccess {
+ private long id;
+
+ private String title;
+
+ private List<Student> students;
+
+ @Id
+ @GeneratedValue
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @OneToMany(cascade = CascadeType.ALL)
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess2.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess2.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess2.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,77 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)Access(AccessType.PROPERTY)
+public class CourseExplicitPropertyAccess2 {
+ private long id;
+
+ private String title;
+
+
+ private List<Student> students;
+
+ @Id
+ @GeneratedValue
+ @org.hibernate.annotations.AccessType("field")
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @OneToMany(cascade = CascadeType.ALL)
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess3.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess3.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess3.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,75 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)Access(AccessType.PROPERTY)
+public class CourseExplicitPropertyAccess3 {
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String title;
+
+ @OneToMany(cascade = CascadeType.ALL)
+ private List<Student> students;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess4.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess4.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess4.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,77 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)Access(AccessType.PROPERTY)
+public class CourseExplicitPropertyAccess4 {
+
+ @Access(AccessType.FIELD)
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String title;
+
+ private List<Student> students;
+
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @ManyToMany
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseFieldAccess.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseFieldAccess.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseFieldAccess.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,72 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class CourseFieldAccess {
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String title;
+
+ @OneToMany(cascade = CascadeType.ALL)
+ private List<Student> students;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CoursePropertyAccess.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CoursePropertyAccess.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CoursePropertyAccess.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,72 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class CoursePropertyAccess {
+ private long id;
+
+ private String title;
+
+ private List<Student> students;
+
+ @Id
+ @GeneratedValue
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @OneToMany(cascade = CascadeType.ALL)
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Furniture.java (from rev 18194, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Furniture.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Furniture.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Furniture.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,72 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Access;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Transient;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+(a)Access(javax.persistence.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 = brand;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Access(javax.persistence.AccessType.PROPERTY)
+ public long weight;
+
+ public long getWeight() {
+ return weight + 1;
+ }
+
+ public void setWeight(long weight) {
+ this.weight = weight + 1;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Furniture.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Gardenshed.java (from rev 18194, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Gardenshed.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Gardenshed.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Gardenshed.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,78 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Access;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Transient;
+
+/**
+ * This is the opposite of the Furniture test, as this tries to override the class AccessType("property") with
+ * the property AccessType("field").
+ *
+ * @author Dennis Fleurbaaij
+ * @since 2007-05-31
+ */
+@Entity
+(a)Access(javax.persistence.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 = brand;
+ }
+
+ @Id
+ @GeneratedValue
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ // These 2 functions should not return in Hibernate, but the value should come from the field "floors"
+
+ @Access(javax.persistence.AccessType.FIELD)
+ public long getFloors() {
+ return this.floors + 2;
+ }
+
+ public void setFloors(long floors) {
+ this.floors = floors + 2;
+ }
+}
\ No newline at end of file
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Person.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Person.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Person.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,60 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Access;
+import javax.persistence.Entity;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+// explicitly override the access type to be property (default is field, see Being)
+(a)Access(javax.persistence.AccessType.PROPERTY)
+public class Person extends Being {
+
+ String firstname;
+
+ private String lastname;
+
+ public String getFirstname() {
+ return null;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+}
+
+
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Person.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Student.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Student.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Student.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,59 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Student {
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String name;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
+
+
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Thingy.java (from rev 18194, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Thingy.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Thingy.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Thingy.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,45 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+public class Thingy {
+ private String god;
+
+ @Transient
+ public String getGod() {
+ return god;
+ }
+
+ public void setGod(String god) {
+ this.god = god;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Thingy.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/User.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/User.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/User.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,48 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class User extends Person {
+
+ @OneToMany(cascade = CascadeType.ALL)
+ private List<User> friends;
+
+ public List<User> getFriends() {
+ return friends;
+ }
+
+ public void setFriends(List<User> friends) {
+ this.friends = friends;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/User.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Woody.java (from rev 18194, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/Woody.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Woody.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Woody.java 2009-12-17 21:14:07 UTC (rev 18260)
@@ -0,0 +1,55 @@
+//$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, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Access;
+import javax.persistence.MappedSuperclass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+(a)Access(javax.persistence.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 = color;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Woody.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
14 years, 12 months
Hibernate SVN: r18259 - in core/trunk: entitymanager and 21 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-12-17 10:34:04 -0500 (Thu, 17 Dec 2009)
New Revision: 18259
Added:
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/META-INF/
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/META-INF/orm.xml
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/META-INF/persistence.xml
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/org/
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/org/hibernate/
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/org/hibernate/ejb/
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/org/hibernate/ejb/test/
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/org/hibernate/ejb/test/pack/
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/org/hibernate/ejb/test/pack/defaultpar_1_0/
core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/org/hibernate/ejb/test/pack/defaultpar_1_0/Mouse1.hbm.xml
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/ApplicationServer1.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/IncrementListener1.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Lighter1.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Money1.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Mouse1.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/OtherIncrementListener1.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Version1.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/package-info.java
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/EJB3DTDEntityResolver.java
core/trunk/entitymanager/build.xml
core/trunk/entitymanager/pom.xml
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
core/trunk/entitymanager/src/test/bundles/defaultpar/META-INF/persistence.xml
core/trunk/entitymanager/src/test/bundles/excludehbmpar/META-INF/persistence.xml
core/trunk/entitymanager/src/test/bundles/explicitpar/META-INF/persistence.xml
core/trunk/entitymanager/src/test/bundles/explodedpar/META-INF/persistence.xml
core/trunk/entitymanager/src/test/bundles/overridenpar/META-INF/persistence.xml
core/trunk/entitymanager/src/test/bundles/space par/META-INF/persistence.xml
core/trunk/entitymanager/src/test/bundles/war/WEB-INF/classes/META-INF/persistence.xml
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/PackagedEntityManagerTest.java
Log:
HHH-4711 HHH-4667 validate persistence.xml and make sure it works for both persistence_1_0.xsd and persistence_2_0.xsd
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/EJB3DTDEntityResolver.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/EJB3DTDEntityResolver.java 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/EJB3DTDEntityResolver.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -32,6 +32,8 @@
import org.slf4j.LoggerFactory;
/**
+ * Resolve JPA xsd files locally
+ *
* @author Emmanuel Bernard
*/
public class EJB3DTDEntityResolver extends DTDEntityResolver {
@@ -41,50 +43,39 @@
boolean resolved = false;
+ /**
+ * Persistence.xml has been resolved locally
+ * @return true if it has
+ */
public boolean isResolved() {
return resolved;
}
public InputSource resolveEntity(String publicId, String systemId) {
+ log.trace("Resolving XML entity {} : {}", publicId, systemId);
InputSource is = super.resolveEntity( publicId, systemId );
if ( is == null ) {
if ( systemId != 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 = "org/hibernate/ejb/" + "orm_1_0.xsd";
- InputStream dtdStream = resolveInHibernateNamespace( path );
- if ( dtdStream == null ) {
- log.debug( "unable to locate [{}] on classpath", systemId );
- }
- else {
- log.debug( "located [{}] in classpath", systemId );
- InputSource source = new InputSource( dtdStream );
- source.setPublicId( publicId );
- source.setSystemId( systemId );
- resolved = false;
- return source;
- }
+ InputStream dtdStream = getStreamFromClasspath( "orm_1_0.xsd" );
+ final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
+ if (source != null) return source;
}
+ else if ( systemId.endsWith( "orm_2_0.xsd" ) ) {
+ InputStream dtdStream = getStreamFromClasspath( "orm_2_0.xsd" );
+ final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
+ if (source != null) 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 = "org/hibernate/ejb/" + "persistence_1_0.xsd";
- InputStream dtdStream = resolveInHibernateNamespace( path );
- if ( dtdStream == null ) {
- log.debug( "unable to locate [{}] on classpath", systemId );
- }
- else {
- log.debug( "located [{}] in classpath", systemId );
- InputSource source = new InputSource( dtdStream );
- source.setPublicId( publicId );
- source.setSystemId( systemId );
- resolved = true;
- return source;
- }
+ InputStream dtdStream = getStreamFromClasspath( "persistence_1_0.xsd" );
+ final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
+ if (source != null) return source;
}
+ else if ( systemId.endsWith( "persistence_2_0.xsd" ) ) {
+ InputStream dtdStream = getStreamFromClasspath( "persistence_2_0.xsd" );
+ final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
+ if (source != null) return source;
+ }
}
}
else {
@@ -94,4 +85,28 @@
//use the default behavior
return null;
}
+
+ private InputSource buildInputSource(String publicId, String systemId, InputStream dtdStream, boolean resolved) {
+ if ( dtdStream == null ) {
+ log.trace( "unable to locate [{}] on classpath", systemId );
+ return null;
+ }
+ else {
+ log.trace( "located [{}] in classpath", systemId );
+ InputSource source = new InputSource( dtdStream );
+ source.setPublicId( publicId );
+ source.setSystemId( systemId );
+ this.resolved = resolved;
+ return source;
+ }
+ }
+
+ private InputStream getStreamFromClasspath(String fileName) {
+ log.trace(
+ "recognized JPA ORM namespace; attempting to resolve on classpath under org/hibernate/ejb"
+ );
+ String path = "org/hibernate/ejb/" + fileName;
+ InputStream dtdStream = resolveInHibernateNamespace( path );
+ return dtdStream;
+ }
}
Modified: core/trunk/entitymanager/build.xml
===================================================================
--- core/trunk/entitymanager/build.xml 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/build.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -45,6 +45,10 @@
<param name="extension" value="par"/>
<param name="jarname" value="defaultpar"/>
</antcall>
+ <antcall target="packjar" inheritall="true">
+ <param name="extension" value="par"/>
+ <param name="jarname" value="defaultpar_1_0"/>
+ </antcall>
<antcall target="packjar" inheritall="true">
<param name="extension" value="par"/>
<param name="jarname" value="space par"/>
Modified: core/trunk/entitymanager/pom.xml
===================================================================
--- core/trunk/entitymanager/pom.xml 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/pom.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -181,6 +181,7 @@
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/target/test-packages/cfgxmlpar.par</additionalClasspathElement>
<additionalClasspathElement>${basedir}/target/test-packages/defaultpar.par</additionalClasspathElement>
+ <additionalClasspathElement>${basedir}/target/test-packages/defaultpar_1_0.par</additionalClasspathElement>
<additionalClasspathElement>${basedir}/target/test-packages/excludehbmpar.par</additionalClasspathElement>
<additionalClasspathElement>${basedir}/target/test-packages/explicitpar.par</additionalClasspathElement>
<additionalClasspathElement>${basedir}/target/test-packages/explodedpar.par</additionalClasspathElement>
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -84,19 +84,54 @@
final Validator v2Validator = v2Schema.newValidator();
final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
.newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
- final Validator v1Validator = v2Schema.newValidator();
+ final Validator v1Validator = v1Schema.newValidator();
InputSource source = new InputSource( is );
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
docBuilder.setEntityResolver( resolver );
- Document doc = docBuilder.parse( source );
+ List<SAXParseException> errors = new ArrayList<SAXParseException>();
+ Document doc = null;
+ try {
+ doc = docBuilder.parse( source );
+ }
+ catch ( SAXParseException e ) {
+ errors.add( e );
+ }
- List errors = new ArrayList();
- v2Validator.setErrorHandler( new ErrorLogger( "XML InputStream", errors, resolver ) );
- v2Validator.validate( new DOMSource( doc ) );
-
+ if (errors.size() == 0) {
+ v2Validator.setErrorHandler( new ErrorLogger( "XML InputStream", errors, resolver ) );
+ log.trace("Validate with persistence_2_0.xsd schema on file {}", configURL);
+ v2Validator.validate( new DOMSource( doc ) );
+ boolean isV1Schema = false;
+ if ( errors.size() != 0 ) {
+ //v2 fails, it could be because the file is v1.
+ log.trace("Found error with persistence_2_0.xsd schema on file {}", configURL);
+ SAXParseException exception = errors.get( 0 );
+ final String errorMessage = exception.getMessage();
+ isV1Schema = errorMessage.contains("1.0")
+ && errorMessage.contains("2.0")
+ && errorMessage.contains("version");
+
+ }
+ if (isV1Schema) {
+ log.trace("Validate with persistence_1_0.xsd schema on file {}", configURL);
+ errors.clear();
+ v1Validator.setErrorHandler( new ErrorLogger( "XML InputStream", errors, resolver ) );
+ v1Validator.validate( new DOMSource( doc ) );
+ }
+ }
if ( errors.size() != 0 ) {
- throw new PersistenceException( "Invlid persistence.xml. Check the error logs for parsing errors", (Throwable) errors.get( 0 ) );
+ StringBuilder errorMessage = new StringBuilder( );
+ for (SAXParseException error : errors) {
+ errorMessage.append("Error parsing XML (line")
+ .append(error.getLineNumber())
+ .append(" : column ")
+ .append(error.getColumnNumber())
+ .append("): ")
+ .append(error.getMessage())
+ .append("\n");
+ }
+ throw new PersistenceException( "Invalid persistence.xml.\n" + errorMessage.toString() );
}
return doc;
}
@@ -289,30 +324,14 @@
// if ( resolver instanceof EJB3DTDEntityResolver ) {
// if ( ( (EJB3DTDEntityResolver) resolver ).isResolved() == false ) return;
// }
-
- log.error( "Error parsing XML (line {}: column {}): {}",
- new Object[] {
- error.getLineNumber(),
- error.getColumnNumber(),
- error.getMessage() } );
errors.add( error );
}
public void fatalError(SAXParseException error) {
- log.error( "Error parsing XML (line {}: column {}): {}",
- new Object[] {
- error.getLineNumber(),
- error.getColumnNumber(),
- error.getMessage() } );
errors.add( error );
}
public void warning(SAXParseException warn) {
- log.warn( "Warning parsing XML (line {}: column {}): {}",
- new Object[] {
- warn.getLineNumber(),
- warn.getColumnNumber(),
- warn.getMessage() } );
}
}
Modified: core/trunk/entitymanager/src/test/bundles/defaultpar/META-INF/persistence.xml
===================================================================
--- core/trunk/entitymanager/src/test/bundles/defaultpar/META-INF/persistence.xml 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/src/test/bundles/defaultpar/META-INF/persistence.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -2,10 +2,11 @@
<!-- example of a default persistence.xml -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
- version="1.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
<persistence-unit name="defaultpar">
<class>org.hibernate.ejb.test.pack.defaultpar.Lighter</class>
+ <validation-mode>CALLBACK</validation-mode>
<properties>
<property name="hibernate.dialect" value="${db.dialect}"/>
<property name="hibernate.connection.driver_class" value="${jdbc.driver}"/>
Added: core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/META-INF/orm.xml
===================================================================
--- core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/META-INF/orm.xml (rev 0)
+++ core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/META-INF/orm.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
+ version="1.0"
+ >
+ <persistence-unit-metadata>
+ <persistence-unit-defaults>
+ <entity-listeners>
+ <entity-listener class="org.hibernate.ejb.test.pack.defaultpar_1_0.IncrementListener1">
+ <pre-persist method-name="increment"/>
+ </entity-listener>
+ </entity-listeners>
+ </persistence-unit-defaults>
+ </persistence-unit-metadata>
+ <package>org.hibernate.ejb.test.pack.defaultpar_1_0</package>
+ <entity class="org.hibernate.ejb.test.pack.defaultpar_1_0.Lighter1" access="FIELD" metadata-complete="true">
+ <attributes>
+ <id name="name">
+ <column name="fld_id"/>
+ </id>
+ <basic name="power"></basic>
+ </attributes>
+ </entity>
+ <entity class="org.hibernate.ejb.test.pack.defaultpar_1_0.ApplicationServer1">
+ <entity-listeners>
+ <entity-listener class="OtherIncrementListener1">
+ <pre-persist method-name="increment"/>
+ </entity-listener>
+ </entity-listeners>
+ </entity>
+</entity-mappings>
\ No newline at end of file
Added: core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/META-INF/persistence.xml
===================================================================
--- core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/META-INF/persistence.xml (rev 0)
+++ core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/META-INF/persistence.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- example of a default persistence.xml -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="defaultpar_1_0">
+ <class>org.hibernate.ejb.test.pack.defaultpar.Lighter</class>
+ <properties>
+ <property name="hibernate.dialect" value="${db.dialect}"/>
+ <property name="hibernate.connection.driver_class" value="${jdbc.driver}"/>
+ <property name="hibernate.connection.username" value="${jdbc.user}"/>
+ <property name="hibernate.connection.password" value="${jdbc.pass}"/>
+ <property name="hibernate.connection.url" value="${jdbc.url}"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/org/hibernate/ejb/test/pack/defaultpar_1_0/Mouse1.hbm.xml
===================================================================
--- core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/org/hibernate/ejb/test/pack/defaultpar_1_0/Mouse1.hbm.xml (rev 0)
+++ core/trunk/entitymanager/src/test/bundles/defaultpar_1_0/org/hibernate/ejb/test/pack/defaultpar_1_0/Mouse1.hbm.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping
+ package="org.hibernate.ejb.test.pack.defaultpar_1_0"
+ >
+
+ <class name="Mouse1">
+
+ <id name="id">
+ <generator class="native"/>
+ </id>
+ <property name="name"/>
+
+ </class>
+
+</hibernate-mapping>
Modified: core/trunk/entitymanager/src/test/bundles/excludehbmpar/META-INF/persistence.xml
===================================================================
--- core/trunk/entitymanager/src/test/bundles/excludehbmpar/META-INF/persistence.xml 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/src/test/bundles/excludehbmpar/META-INF/persistence.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -2,8 +2,8 @@
<!-- example of a default persistence.xml -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
- version="1.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
<persistence-unit name="excludehbmpar" transaction-type="RESOURCE_LOCAL">
<mapping-file>META-INF/orm2.xml</mapping-file>
<properties>
Modified: core/trunk/entitymanager/src/test/bundles/explicitpar/META-INF/persistence.xml
===================================================================
--- core/trunk/entitymanager/src/test/bundles/explicitpar/META-INF/persistence.xml 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/src/test/bundles/explicitpar/META-INF/persistence.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
- version="1.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
<persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
<jar-file>./target/test-packages/externaljar.jar</jar-file>
<class>org.hibernate.ejb.test.Cat</class>
Modified: core/trunk/entitymanager/src/test/bundles/explodedpar/META-INF/persistence.xml
===================================================================
--- core/trunk/entitymanager/src/test/bundles/explodedpar/META-INF/persistence.xml 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/src/test/bundles/explodedpar/META-INF/persistence.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -2,8 +2,8 @@
<!-- example of a default persistence.xml -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
- version="1.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
<persistence-unit name="explodedpar" transaction-type="RESOURCE_LOCAL">
<properties>
Modified: core/trunk/entitymanager/src/test/bundles/overridenpar/META-INF/persistence.xml
===================================================================
--- core/trunk/entitymanager/src/test/bundles/overridenpar/META-INF/persistence.xml 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/src/test/bundles/overridenpar/META-INF/persistence.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
- version="1.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
<persistence-unit name="overridenpar">
<jta-data-source>java:/unreachableDS</jta-data-source>
<properties>
Modified: core/trunk/entitymanager/src/test/bundles/space par/META-INF/persistence.xml
===================================================================
--- core/trunk/entitymanager/src/test/bundles/space par/META-INF/persistence.xml 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/src/test/bundles/space par/META-INF/persistence.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -2,8 +2,8 @@
<!-- example of a default persistence.xml -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
- version="1.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
<persistence-unit name="space par">
<properties>
<property name="hibernate.dialect" value="${db.dialect}"/>
Modified: core/trunk/entitymanager/src/test/bundles/war/WEB-INF/classes/META-INF/persistence.xml
===================================================================
--- core/trunk/entitymanager/src/test/bundles/war/WEB-INF/classes/META-INF/persistence.xml 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/src/test/bundles/war/WEB-INF/classes/META-INF/persistence.xml 2009-12-17 15:34:04 UTC (rev 18259)
@@ -2,8 +2,8 @@
<!-- example of a default persistence.xml -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
- version="1.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
<persistence-unit name="defaultpar">
<class>org.hibernate.ejb.test.pack.defaultpar.Lighter</class>
<properties>
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/PackagedEntityManagerTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2009-12-17 15:32:42 UTC (rev 18258)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -25,6 +25,10 @@
import org.hibernate.ejb.test.pack.spacepar.Bug;
import org.hibernate.ejb.test.pack.various.Airplane;
import org.hibernate.ejb.test.pack.various.Seat;
+import org.hibernate.ejb.test.pack.defaultpar_1_0.ApplicationServer1;
+import org.hibernate.ejb.test.pack.defaultpar_1_0.Version1;
+import org.hibernate.ejb.test.pack.defaultpar_1_0.Mouse1;
+import org.hibernate.ejb.test.pack.defaultpar_1_0.Lighter1;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.event.EventListeners;
import org.hibernate.stat.Statistics;
@@ -74,6 +78,36 @@
emf.close();
}
+ public void testDefaultParForPersistence_1_0() throws Exception {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory( "defaultpar_1_0", new HashMap() );
+ EntityManager em = emf.createEntityManager();
+ ApplicationServer1 as = new ApplicationServer1();
+ as.setName( "JBoss AS" );
+ Version1 v = new Version1();
+ v.setMajor( 4 );
+ v.setMinor( 0 );
+ v.setMicro( 3 );
+ as.setVersion( v );
+ Mouse1 mouse = new Mouse1();
+ mouse.setName( "mickey" );
+ em.getTransaction().begin();
+ em.persist( as );
+ em.persist( mouse );
+ assertEquals( 1, em.createNamedQuery( "allMouse_1_0" ).getResultList().size() );
+ Lighter1 lighter = new Lighter1();
+ lighter.name = "main";
+ lighter.power = " 250 W";
+ em.persist( lighter );
+ em.flush();
+ em.remove( lighter );
+ em.remove( mouse );
+ assertNotNull( as.getId() );
+ em.remove( as );
+ em.getTransaction().commit();
+ em.close();
+ emf.close();
+ }
+
public void testListenersDefaultPar() throws Exception {
IncrementListener.reset();
OtherIncrementListener.reset();
Copied: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/ApplicationServer1.java (from rev 18240, core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar/ApplicationServer.java)
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/ApplicationServer1.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/ApplicationServer1.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,42 @@
+//$Id$
+package org.hibernate.ejb.test.pack.defaultpar_1_0;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class ApplicationServer1 {
+ private Integer id;
+ private String name;
+ private Version1 version;
+
+ @Id
+ @GeneratedValue
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Version1 getVersion() {
+ return version;
+ }
+
+ public void setVersion(Version1 version) {
+ this.version = version;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/ApplicationServer1.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/IncrementListener1.java (from rev 18240, core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar/IncrementListener.java)
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/IncrementListener1.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/IncrementListener1.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,24 @@
+//$Id$
+package org.hibernate.ejb.test.pack.defaultpar_1_0;
+
+import javax.persistence.PrePersist;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class IncrementListener1 {
+ private static int increment;
+
+ public static int getIncrement() {
+ return increment;
+ }
+
+ public static void reset() {
+ increment = 0;
+ }
+
+ @PrePersist
+ public void increment(Object entity) {
+ increment++;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/IncrementListener1.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Lighter1.java (from rev 18240, core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar/Lighter.java)
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Lighter1.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Lighter1.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,10 @@
+//$Id$
+package org.hibernate.ejb.test.pack.defaultpar_1_0;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Lighter1 {
+ public String name;
+ public String power;
+}
\ No newline at end of file
Property changes on: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Lighter1.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Money1.java (from rev 18240, core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar/Money.java)
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Money1.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Money1.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,24 @@
+//$Id$
+package org.hibernate.ejb.test.pack.defaultpar_1_0;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Money1 {
+ private Integer id;
+
+ @Id @GeneratedValue
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+}
\ No newline at end of file
Property changes on: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Money1.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Mouse1.java (from rev 18240, core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar/Mouse.java)
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Mouse1.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Mouse1.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,29 @@
+//$Id$
+package org.hibernate.ejb.test.pack.defaultpar_1_0;
+
+import javax.persistence.ExcludeDefaultListeners;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@ExcludeDefaultListeners
+public class Mouse1 {
+ private Integer id;
+ private String name;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Mouse1.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/OtherIncrementListener1.java (from rev 18240, core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar/OtherIncrementListener.java)
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/OtherIncrementListener1.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/OtherIncrementListener1.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,21 @@
+//$Id$
+package org.hibernate.ejb.test.pack.defaultpar_1_0;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class OtherIncrementListener1 {
+ private static int increment;
+
+ public static int getIncrement() {
+ return OtherIncrementListener1.increment;
+ }
+
+ public static void reset() {
+ increment = 0;
+ }
+
+ public void increment(Object entity) {
+ OtherIncrementListener1.increment++;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/OtherIncrementListener1.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Version1.java (from rev 18240, core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar/Version.java)
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Version1.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Version1.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,43 @@
+//$Id$
+package org.hibernate.ejb.test.pack.defaultpar_1_0;
+
+import javax.persistence.Embeddable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Embeddable
+public class Version1 {
+ private static final String DOT = ".";
+ private int major;
+ private int minor;
+ private int micro;
+
+ public int getMajor() {
+ return major;
+ }
+
+ public void setMajor(int major) {
+ this.major = major;
+ }
+
+ public int getMinor() {
+ return minor;
+ }
+
+ public void setMinor(int minor) {
+ this.minor = minor;
+ }
+
+ public int getMicro() {
+ return micro;
+ }
+
+ public void setMicro(int micro) {
+ this.micro = micro;
+ }
+
+ public String toString() {
+ return new StringBuffer( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString();
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/Version1.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/package-info.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/package-info.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/pack/defaultpar_1_0/package-info.java 2009-12-17 15:34:04 UTC (rev 18259)
@@ -0,0 +1,5 @@
+@NamedQuery(name = "allMouse_1_0",
+ query = "select m from ApplicationServer1 m")
+package org.hibernate.ejb.test.pack.defaultpar_1_0;
+
+import org.hibernate.annotations.NamedQuery;
\ No newline at end of file
14 years, 12 months
Hibernate SVN: r18258 - in validator/trunk/hibernate-validator/src/main/docbook/en-US: modules and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-12-17 10:32:42 -0500 (Thu, 17 Dec 2009)
New Revision: 18258
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/bootstrapping.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/defineconstraints.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/furtherreading.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/introduction.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/preface.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml
Log:
HV-279 - fixed license header in docbook files
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY versionNumber "4.0.2.GA">
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/bootstrapping.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/bootstrapping.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/bootstrapping.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-bootstrapping">
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-customconstraints">
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/defineconstraints.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/defineconstraints.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/defineconstraints.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-defineconstraints">
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/furtherreading.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/furtherreading.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/furtherreading.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: bootstrapping.xml 17523 2009-09-16 15:51:58Z hardy.ferentschik $ -->
<!--
- ~ 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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter>
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-gettingstarted">
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-checkconstraints">
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/introduction.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/introduction.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/introduction.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,29 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
-
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-introduction">
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/preface.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/preface.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/preface.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: bootstrapping.xml 17523 2009-09-16 15:51:58Z hardy.ferentschik $ -->
<!--
- ~ 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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<preface id="preface" revision="2">
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-usingvalidator">
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml 2009-12-17 13:29:55 UTC (rev 18257)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml 2009-12-17 15:32:42 UTC (rev 18258)
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $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, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
+-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-xmlconfiguration">
14 years, 12 months