Hibernate SVN: r19641 - in validator/trunk: hibernate-validator-archetype and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-06-01 08:46:16 -0400 (Tue, 01 Jun 2010)
New Revision: 19641
Removed:
validator/trunk/hibernate-validator-archetype/src/main/archetype/
Modified:
validator/trunk/hibernate-validator-archetype/pom.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml
Log:
Updated docs and archetype
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 2010-06-01 12:16:12 UTC (rev 19640)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml 2010-06-01 12:46:16 UTC (rev 19641)
@@ -100,21 +100,15 @@
<title>Using Maven's archetype plugin to create a sample project using
Hibernate Validator</title>
- <programlisting>mvn archetype:generate \
- -DarchetypeCatalog=http://repository.jboss.com/maven2/archetype-catalog.xml \
- -DgroupId=com.mycompany \
- -DartifactId=beanvalidation-gettingstarted \
- -Dversion=1.0-SNAPSHOT \
- -Dpackage=com.mycompany</programlisting>
+ <programlisting>mvn archetype:create -DarchetypeGroupId=org.hibernate \
+ -DarchetypeArtifactId=hibernate-validator-quickstart-archetype \
+ -DarchetypeVersion=&version; \
+ -DgroupId=com.mycompany
+ -DartifactId=hv-quickstart</programlisting>
</example></para>
- <para>When presented with the list of available archetypes in the JBoss
- Maven Repository select the
- <emphasis>hibernate-validator-quickstart-archetype. </emphasis>After Maven
- has downloaded all dependencies confirm the settings by just pressing
- enter. Maven will create your project in the directory
- <filename>beanvalidation-gettingstarted</filename>. Change into this
- directory and run:</para>
+ <para>Maven will create your project in the directory hv-quickstart.
+ Change into this directory and run:</para>
<para><programlisting>mvn test</programlisting>Maven will compile the
example code and run the implemented unit tests. Let's have a look at the
Modified: validator/trunk/hibernate-validator-archetype/pom.xml
===================================================================
--- validator/trunk/hibernate-validator-archetype/pom.xml 2010-06-01 12:16:12 UTC (rev 19640)
+++ validator/trunk/hibernate-validator-archetype/pom.xml 2010-06-01 12:46:16 UTC (rev 19641)
@@ -68,7 +68,7 @@
<repositories>
<repository>
<id>jboss</id>
- <url>http://repository.jboss.com/maven2</url>
+ <url>https://repository.jboss.org/nexus/content/repositories/public</url>
</repository>
</repositories>
</project>
14 years, 6 months
Hibernate SVN: r19640 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validator/test/bootstrap and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-06-01 08:16:12 -0400 (Tue, 01 Jun 2010)
New Revision: 19640
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConfigurationImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/bootstrap/ValidationTest.java
Log:
HV-328
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConfigurationImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConfigurationImpl.java 2010-06-01 11:52:20 UTC (rev 19639)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConfigurationImpl.java 2010-06-01 12:16:12 UTC (rev 19640)
@@ -116,6 +116,9 @@
}
public HibernateValidatorConfiguration addMapping(InputStream stream) {
+ if ( mapping == null ) {
+ throw new IllegalArgumentException( "The stream cannot be null." );
+ }
validationBootstrapParameters.mappings.add( stream );
return this;
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/bootstrap/ValidationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/bootstrap/ValidationTest.java 2010-06-01 11:52:20 UTC (rev 19639)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/bootstrap/ValidationTest.java 2010-06-01 12:16:12 UTC (rev 19640)
@@ -27,18 +27,19 @@
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
+import org.hibernate.validator.HibernateValidator;
+import org.hibernate.validator.HibernateValidatorConfiguration;
import org.hibernate.validator.constraints.impl.NotNullValidator;
import org.hibernate.validator.engine.ConfigurationImpl;
import org.hibernate.validator.engine.ConstraintValidatorFactoryImpl;
-import org.hibernate.validator.HibernateValidatorConfiguration;
import org.hibernate.validator.engine.ValidatorFactoryImpl;
-import org.hibernate.validator.HibernateValidator;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
/**
* Tests the Bean Validation bootstrapping.
*
@@ -96,6 +97,16 @@
assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
+ /**
+ * HV-328
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testNullInputStream() {
+ Configuration<?> configuration = Validation.byDefaultProvider().configure();
+ configuration.addMapping( null );
+ configuration.buildValidatorFactory();
+ }
+
private void assertDefaultBuilderAndFactory(Configuration configuration) {
assertNotNull( configuration );
assertTrue( configuration instanceof ConfigurationImpl );
14 years, 6 months
Hibernate SVN: r19639 - in validator/trunk/hibernate-validator/src: main/docbook/en-US/modules and 5 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-06-01 07:52:20 -0400 (Tue, 01 Jun 2010)
New Revision: 19639
Removed:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extensions.xml
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/annotationprocessor.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/programmaticapi.xml
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/HibernateValidatorConfiguration.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertFalseDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertTrueDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/CreditCardNumberDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMaxDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMinDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DigitsDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/EmailDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/FutureDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/GenericConstraintDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/LengthDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MaxDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MinDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotBlankDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotEmptyDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotNullDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NullDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PastDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PatternDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/RangeDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/ScriptAssertDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/SizeDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/URLDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConfigurationImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java
Log:
HV-274 Added documentation and moved message, groups and payload into the ConstraintDef base class
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2010-06-01 11:52:20 UTC (rev 19639)
@@ -68,9 +68,12 @@
<xi:include href="modules/integration.xml"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
- <xi:include href="modules/extensions.xml"
+ <xi:include href="modules/programmaticapi.xml"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
+ <xi:include href="modules/annotationprocessor.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
<xi:include href="modules/furtherreading.xml"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
</book>
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/annotationprocessor.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/annotationprocessor.xml 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/annotationprocessor.xml 2010-06-01 11:52:20 UTC (rev 19639)
@@ -21,9 +21,8 @@
<!ENTITY % BOOK_ENTITIES SYSTEM "../hv.ent">
%BOOK_ENTITIES;
]>
-<section>
- <title id="annotation-processor">Hibernate Validator Annotation
- Processor (EXPERIMENTAL)</title>
+<chapter>
+ <title id="annotation-processor">Annotation Processor (EXPERIMENTAL)</title>
<para>Have you ever caught yourself by unintentionally doing things
like</para>
@@ -482,4 +481,4 @@
</listitem>
</itemizedlist>
</section>
-</section>
+</chapter>
Deleted: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extensions.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extensions.xml 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extensions.xml 2010-06-01 11:52:20 UTC (rev 19639)
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- $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.
--->
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
-"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "../hv.ent">
-%BOOK_ENTITIES;
-]>
-<chapter id="extensions">
- <title>Hibernate Validator Specific Extensions</title>
-
- <para>Hibernate Validator offers on top of the Bean Validation requirements additional extensions which are described in the following sections.</para>
-
- <xi:include href="programmaticapi.xml"
- xmlns:xi="http://www.w3.org/2001/XInclude"/>
- <xi:include href="annotationprocessor.xml"
- xmlns:xi="http://www.w3.org/2001/XInclude"/>
-
-</chapter>
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/programmaticapi.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/programmaticapi.xml 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/programmaticapi.xml 2010-06-01 11:52:20 UTC (rev 19639)
@@ -21,31 +21,101 @@
<!ENTITY % BOOK_ENTITIES SYSTEM "../hv.ent">
%BOOK_ENTITIES;
]>
-<section id="programmaticapi">
- <title>Programmatic constraint definitions</title>
+<chapter id="programmaticapi">
+ <title>Programmatic constraint definition</title>
- <para><example>
- <title>Creating a Hibernate Validator specific configuration</title>
+ <note>
+ <para>Use of the features described in the following sections is not
+ portable between Bean Validation providers/implementations.</para>
+ </note>
- <programlisting>HibernateValidatorConfiguration config = Validation.byProvider( HibernateValidator.class ).configure();</programlisting>
- </example></para>
+ <para>Hibernate Validator allows to configure constraints not only via
+ annotations and xml, but also via a programmatic API. This API can be used
+ exclusively or in combination with annotations and xml. If used in
+ combination programmatic constraints are additive to otherwise configured
+ constraints.</para>
- <para><example>
+ <para>The programmatic API is centered around the
+ <classname>ConstraintMapping</classname> class which can be found together
+ with its supporting classes in the
+ <package>org.hibernate.validator.cfg</package> package.
+ <classname>ConstraintMapping</classname> is the entry point to a fluent API
+ allowing the definition of constraints. <xref lang=""
+ linkend="example-constraint-mapping" /> shows how the API can be
+ used.</para>
+
+ <para><example id="example-constraint-mapping">
<title>Programmatic constraint definition</title>
<programlisting>ConstraintMapping mapping = new ConstraintMapping();
-mapping.type( Marathon.class )
- .property( "name", METHOD )
+mapping.type( Car.class )
+ .property( "manufacturer", FIELD )
.constraint( NotNullDef.class )
- .property( "numberOfHelpers", FIELD )
- .constraint( MinDef.class ).value( 1 );
+ .property( "licensePlate", FIELD )
+ .constraint( NotNullDef.class )
+ .constraint( SizeDef.class )
+ .min( 2 )
+ .max( 14 )
+ .property( "seatCount", FIELD )
+ .constraint( MinDef.class )
+ .value ( 2 )
+.type( RentalCar.class )
+ .property( "rentalStation", METHOD)
+ .constraint( NotNullDef.class ); </programlisting>
+ </example></para>
+ <para>As you can see you can configure constraints on multiple classes and
+ properties using method chaining. The constraint definition classes
+ <classname>NotNullDef</classname>, <classname>SizeDef</classname> and
+ <classname>MinDef</classname> are helper classes which allow to configure
+ constraint parameters in a type-safe fashion. Definition classes exists for
+ all built-in constraints in the
+ <classname>org.hibernate.validator.cfg.defs</classname> package. For a
+ custom constraint you can either create your own definition class extending
+ <classname>ConstraintDef</classname> or you can use
+ <classname>GenericConstraintDef</classname> as seen in <xref
+ linkend="example-generic-constraint-mapping" />.</para>
+ <para><example id="example-generic-constraint-mapping">
+ <title>Programmatic constraint definition using
+ <classname>GenericConstraintDef</classname></title>
+
+ <programlisting>ConstraintMapping mapping = new ConstraintMapping();
+mapping.type( Car.class )
+ .property( "licensePlate", FIELD )
+ .constraint( GenericConstraintDef.class )
+ .constraintType( CheckCase.class )
+ .param( "value", CaseMode.UPPER ); </programlisting>
+ </example></para>
+
+ <para>Last but not least, you can also define cascading constraints as well
+ as the default group sequence of an entity.</para>
+
+ <para><example>
+ <title>Cascading constraints and group redefinition</title>
+
+ <programlisting>ConstraintMapping mapping = new ConstraintMapping();
+mapping.type( Car.class )
+ .valid( "driver", FIELD )
+.type( RentalCar.class)
+ .defaultGroupSequence( RentalCar.class, CarChecks.class ); </programlisting>
+ </example></para>
+
+ <para>Once you have your <classname>ConstraintMapping</classname> you will
+ have to pass it to the configuration. Since the programmatic configuration
+ is not part of the official Bean Validation specification you will have to
+ get hold of the Hibernate Validator specific configuration instance. See
+ <xref linkend="example-hibernate-specific-config" />.</para>
+
+ <para><example id="example-hibernate-specific-config">
+ <title>Creating a Hibernate Validator specific configuration</title>
+
+ <programlisting>ConstraintMapping mapping = new ConstraintMapping();
+// configure mapping instance
+
HibernateValidatorConfiguration config = Validation.byProvider( HibernateValidator.class ).configure();
+config.addMapping( mapping );
ValidatorFactory factory = config.buildValidatorFactory();
-Validator validator = factory.getValidator();
-validator.validate( new Marathon() );</programlisting>
-
- <para></para>
+Validator validator = factory.getValidator();</programlisting>
</example></para>
-</section>
+</chapter>
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/HibernateValidatorConfiguration.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/HibernateValidatorConfiguration.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/HibernateValidatorConfiguration.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -63,5 +63,15 @@
*/
ResourceBundleLocator getDefaultResourceBundleLocator();
+ /**
+ * Adds the specified {@link ConstraintMapping} instance to the configuration. Constraints configured in {@code mapping}
+ * will be added to the constraints configured via annotations and/or xml.
+ *
+ * @param mapping {@code ConstraintMapping} instance containing programmatic configured constraints
+ *
+ * @return {@code this} following the chaining method pattern
+ *
+ * @throws IllegalArgumentException if {@code mapping} is {@code null}
+ */
HibernateValidatorConfiguration addMapping(ConstraintMapping mapping);
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -22,6 +22,7 @@
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
+import javax.validation.Payload;
import javax.validation.ValidationException;
import org.hibernate.validator.util.ReflectionHelper;
@@ -29,7 +30,7 @@
/**
* @author Hardy Ferentschik
*/
-public class ConstraintDef<A extends Annotation> {
+public abstract class ConstraintDef<A extends Annotation> {
protected Class<A> constraintType;
protected final Map<String, Object> parameters;
protected final Class<?> beanType;
@@ -76,6 +77,21 @@
return this;
}
+ public ConstraintDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public ConstraintDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public ConstraintDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
public <A extends Annotation, T extends ConstraintDef<A>> T constraint(Class<T> definition) {
final Constructor<T> constructor = ReflectionHelper.getConstructor(
definition, Class.class, String.class, ElementType.class, ConstraintMapping.class
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertFalseDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertFalseDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertFalseDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -18,7 +18,6 @@
package org.hibernate.validator.cfg.defs;
import java.lang.annotation.ElementType;
-import javax.validation.Payload;
import javax.validation.constraints.AssertFalse;
import org.hibernate.validator.cfg.ConstraintDef;
@@ -31,19 +30,4 @@
public AssertFalseDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
super( beanType, AssertFalse.class, property, elementType, mapping );
}
-
- public AssertFalseDef message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public AssertFalseDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public AssertFalseDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertTrueDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertTrueDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertTrueDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -18,7 +18,6 @@
package org.hibernate.validator.cfg.defs;
import java.lang.annotation.ElementType;
-import javax.validation.Payload;
import javax.validation.constraints.AssertTrue;
import org.hibernate.validator.cfg.ConstraintDef;
@@ -31,19 +30,4 @@
public AssertTrueDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
super( beanType, AssertTrue.class, property, elementType, mapping );
}
-
- public AssertTrueDef message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public AssertTrueDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public AssertTrueDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/CreditCardNumberDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/CreditCardNumberDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/CreditCardNumberDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -19,7 +19,6 @@
package org.hibernate.validator.cfg.defs;
import java.lang.annotation.ElementType;
-import javax.validation.Payload;
import org.hibernate.validator.cfg.ConstraintDef;
import org.hibernate.validator.cfg.ConstraintMapping;
@@ -32,19 +31,4 @@
public CreditCardNumberDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
super( beanType, CreditCardNumber.class, property, elementType, mapping );
}
-
- public CreditCardNumberDef message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public CreditCardNumberDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public CreditCardNumberDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMaxDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMaxDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMaxDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -35,17 +35,17 @@
}
public DecimalMaxDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public DecimalMaxDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public DecimalMaxDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMinDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMinDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMinDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -34,17 +34,17 @@
}
public DecimalMinDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public DecimalMinDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public DecimalMinDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DigitsDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DigitsDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DigitsDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -35,17 +35,17 @@
}
public DigitsDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public DigitsDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public DigitsDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/EmailDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/EmailDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/EmailDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -19,7 +19,6 @@
package org.hibernate.validator.cfg.defs;
import java.lang.annotation.ElementType;
-import javax.validation.Payload;
import org.hibernate.validator.cfg.ConstraintDef;
import org.hibernate.validator.cfg.ConstraintMapping;
@@ -32,19 +31,4 @@
public EmailDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
super( beanType, Email.class, property, elementType, mapping );
}
-
- public EmailDef message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public EmailDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public EmailDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/FutureDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/FutureDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/FutureDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -18,7 +18,6 @@
package org.hibernate.validator.cfg.defs;
import java.lang.annotation.ElementType;
-import javax.validation.Payload;
import javax.validation.constraints.Future;
import org.hibernate.validator.cfg.ConstraintDef;
@@ -31,19 +30,4 @@
public FutureDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
super( beanType, Future.class, property, elementType, mapping );
}
-
- public FutureDef message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public FutureDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public FutureDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/GenericConstraintDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/GenericConstraintDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/GenericConstraintDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -27,7 +27,7 @@
/**
* A {@code ConstraintDef} class which can be used to configure any constraint type. For this purpose the class defines
- * a {@code constraintType} method to specify the constraint type and a generic {@code param(Stringkey,Objectvalue)}
+ * a {@code constraintType} method to specify the constraint type and a generic {@code param(String key,Object value)}
* to add arbitrary constraint parameters.
*
* @author Hardy Ferentschik
@@ -39,17 +39,17 @@
}
public GenericConstraintDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public GenericConstraintDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public GenericConstraintDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/LengthDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/LengthDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/LengthDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -36,17 +36,17 @@
}
public LengthDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public LengthDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public LengthDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MaxDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MaxDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MaxDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -34,17 +34,17 @@
}
public MaxDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public MaxDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public MaxDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MinDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MinDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MinDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -34,17 +34,17 @@
}
public MinDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public MinDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public MinDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotBlankDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotBlankDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotBlankDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -18,7 +18,6 @@
package org.hibernate.validator.cfg.defs;
import java.lang.annotation.ElementType;
-import javax.validation.Payload;
import org.hibernate.validator.cfg.ConstraintDef;
import org.hibernate.validator.cfg.ConstraintMapping;
@@ -31,19 +30,4 @@
public NotBlankDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
super( beanType, NotBlank.class, property, elementType, mapping );
}
-
- public NotBlankDef message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public NotBlankDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public NotBlankDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotEmptyDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotEmptyDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotEmptyDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -18,7 +18,6 @@
package org.hibernate.validator.cfg.defs;
import java.lang.annotation.ElementType;
-import javax.validation.Payload;
import org.hibernate.validator.cfg.ConstraintDef;
import org.hibernate.validator.cfg.ConstraintMapping;
@@ -31,19 +30,4 @@
public NotEmptyDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
super( beanType, NotEmpty.class, property, elementType, mapping );
}
-
- public NotEmptyDef message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public NotEmptyDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public NotEmptyDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotNullDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotNullDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotNullDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -18,7 +18,6 @@
package org.hibernate.validator.cfg.defs;
import java.lang.annotation.ElementType;
-import javax.validation.Payload;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.cfg.ConstraintDef;
@@ -31,19 +30,4 @@
public NotNullDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
super( beanType, NotNull.class, property, elementType, mapping );
}
-
- public NotNullDef message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public NotNullDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public NotNullDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NullDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NullDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NullDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -18,7 +18,6 @@
package org.hibernate.validator.cfg.defs;
import java.lang.annotation.ElementType;
-import javax.validation.Payload;
import javax.validation.constraints.Null;
import org.hibernate.validator.cfg.ConstraintDef;
@@ -31,19 +30,4 @@
public NullDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
super( beanType, Null.class, property, elementType, mapping );
}
-
- public NullDef message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public NullDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public NullDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PastDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PastDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PastDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -18,7 +18,6 @@
package org.hibernate.validator.cfg.defs;
import java.lang.annotation.ElementType;
-import javax.validation.Payload;
import javax.validation.constraints.Past;
import org.hibernate.validator.cfg.ConstraintDef;
@@ -31,19 +30,4 @@
public PastDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
super( beanType, Past.class, property, elementType, mapping );
}
-
- public PastDef message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public PastDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public PastDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PatternDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PatternDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PatternDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -35,17 +35,17 @@
}
public PatternDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public PatternDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public PatternDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/RangeDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/RangeDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/RangeDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -34,17 +34,17 @@
}
public RangeDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public RangeDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public RangeDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/ScriptAssertDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/ScriptAssertDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/ScriptAssertDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -34,17 +34,17 @@
}
public ScriptAssertDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public ScriptAssertDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public ScriptAssertDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/SizeDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/SizeDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/SizeDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -35,17 +35,17 @@
}
public SizeDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public SizeDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public SizeDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/URLDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/URLDef.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/URLDef.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -33,17 +33,17 @@
}
public URLDef message(String message) {
- addParameter( "message", message );
+ super.message( message );
return this;
}
public URLDef groups(Class<?>... groups) {
- addParameter( "groups", groups );
+ super.groups( groups );
return this;
}
public URLDef payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
+ super.payload( payload );
return this;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConfigurationImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConfigurationImpl.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConfigurationImpl.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -120,6 +120,14 @@
return this;
}
+ public HibernateValidatorConfiguration addMapping(ConstraintMapping mapping) {
+ if ( mapping == null ) {
+ throw new IllegalArgumentException( "The mapping cannot be null." );
+ }
+ this.mapping = mapping;
+ return this;
+ }
+
public HibernateValidatorConfiguration addProperty(String name, String value) {
if ( value != null ) {
validationBootstrapParameters.configProperties.put( name, value );
@@ -212,11 +220,6 @@
return defaultResourceBundleLocator;
}
- public HibernateValidatorConfiguration addMapping(ConstraintMapping mapping) {
- this.mapping = mapping;
- return this;
- }
-
public ConstraintMapping getMapping() {
return mapping;
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java 2010-06-01 09:59:49 UTC (rev 19638)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java 2010-06-01 11:52:20 UTC (rev 19639)
@@ -55,6 +55,13 @@
public class ConstraintMappingTest {
private static final Logger log = LoggerFactory.make();
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testNullConstraintMapping() {
+ HibernateValidatorConfiguration config = TestUtil.getConfiguration( HibernateValidator.class );
+ config.addMapping( ( ConstraintMapping ) null );
+ config.buildValidatorFactory();
+ }
+
@Test
public void testConstraintMapping() {
ConstraintMapping mapping = new ConstraintMapping();
14 years, 6 months
Hibernate SVN: r19638 - in branches/Branch_3_2/HibernateExt/tools/src: test/org/hibernate/tool/hbm2x/hbm2hbmxml and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: dgeraskov
Date: 2010-06-01 05:59:49 -0400 (Tue, 01 Jun 2010)
New Revision: 19638
Modified:
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/any.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/array.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/component.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/idbag.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/list.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/map.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/set.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IdBagTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/OneToOneTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PersonAddressOneToOnePrimaryKey.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Properties.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/SetElementTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup2.hbm.xml
Log:
https://jira.jboss.org/browse/JBIDE-6349
Added "access" attribute to export for: any, component, map, set bag, idbag, list, array, primitive-array elements.
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/any.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/any.hbm.ftl 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/any.hbm.ftl 2010-06-01 09:59:49 UTC (rev 19638)
@@ -4,6 +4,9 @@
meta-type="${value.getMetaType()}"
<#if property.cascade != "none">
cascade="${property.cascade}"
+ </#if>
+ <#if !property.basicPropertyAccessor>
+ access="${property.propertyAccessorName}"
</#if>>
<#assign metaattributable=property>
<#include "meta.hbm.ftl">
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/array.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/array.hbm.ftl 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/array.hbm.ftl 2010-06-01 09:59:49 UTC (rev 19638)
@@ -10,6 +10,9 @@
<#if property.cascade != "none">
cascade="${property.cascade}"
</#if>
+ <#if !property.basicPropertyAccessor>
+ access="${property.propertyAccessorName}"
+ </#if>
<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>>
<#assign metaattributable=property>
<#include "meta.hbm.ftl">
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl 2010-06-01 09:59:49 UTC (rev 19638)
@@ -10,6 +10,9 @@
<#if property.cascade != "none">
cascade="${property.cascade}"
</#if>
+ <#if !property.basicPropertyAccessor>
+ access="${property.propertyAccessorName}"
+ </#if>
<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>>
<#assign metaattributable=property>
<#include "meta.hbm.ftl">
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/component.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/component.hbm.ftl 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/component.hbm.ftl 2010-06-01 09:59:49 UTC (rev 19638)
@@ -1,7 +1,10 @@
<component
name="${property.name}"
- class="${property.value.componentClassName}">
+ class="${property.value.componentClassName}"
+ <#if !property.basicPropertyAccessor>
+ access="${property.propertyAccessorName}"
+ </#if>>
<#assign metaattributable=property>
<#include "meta.hbm.ftl">
<#foreach property in c2h.getProperties(property.value)>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/idbag.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/idbag.hbm.ftl 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/idbag.hbm.ftl 2010-06-01 09:59:49 UTC (rev 19638)
@@ -9,6 +9,9 @@
<#if property.cascade != "none">
cascade="${property.cascade}"
</#if>
+ <#if !property.basicPropertyAccessor>
+ access="${property.propertyAccessorName}"
+ </#if>
<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>>
<#assign metaattributable=property>
<#include "meta.hbm.ftl">
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/list.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/list.hbm.ftl 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/list.hbm.ftl 2010-06-01 09:59:49 UTC (rev 19638)
@@ -10,7 +10,9 @@
<#if property.cascade != "none">
cascade="${property.cascade}"
</#if>
-
+ <#if !property.basicPropertyAccessor>
+ access="${property.propertyAccessorName}"
+ </#if>
<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>>
<#assign metaattributable=property>
<#include "meta.hbm.ftl">
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/map.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/map.hbm.ftl 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/map.hbm.ftl 2010-06-01 09:59:49 UTC (rev 19638)
@@ -10,6 +10,9 @@
<#if property.cascade != "none">
cascade="${property.cascade}"
</#if>
+ <#if !property.basicPropertyAccessor>
+ access="${property.propertyAccessorName}"
+ </#if>
<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>>
<#assign metaattributable=property><#include "meta.hbm.ftl">
<#-- TODO table attributes-->
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl 2010-06-01 09:59:49 UTC (rev 19638)
@@ -2,7 +2,10 @@
<#assign table = value.collectionTable.name>
<#assign dependentValue = value.getKey()>
-<primitive-array name="${property.name}" table="${table}">
+<primitive-array name="${property.name}" table="${table}"
+<#if !property.basicPropertyAccessor>
+ access="${property.propertyAccessorName}"
+</#if>>
<#assign metaattributable=property>
<#include "meta.hbm.ftl">
<key>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/set.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/set.hbm.ftl 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/set.hbm.ftl 2010-06-01 09:59:49 UTC (rev 19638)
@@ -10,6 +10,9 @@
<#if property.cascade != "none">
cascade="${property.cascade}"
</#if>
+ <#if !property.basicPropertyAccessor>
+ access="${property.propertyAccessorName}"
+ </#if>
<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>
>
<#assign metaattributable=property>
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IdBagTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IdBagTest.java 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IdBagTest.java 2010-06-01 09:59:49 UTC (rev 19638)
@@ -85,6 +85,7 @@
assertEquals(node.attribute( "table" ).getText(),"`UserGroups`");
assertEquals(node.attribute( "name" ).getText(),"groups");
assertEquals(node.attribute( "lazy" ).getText(),"false");
+ assertEquals(node.attribute( "access" ).getText(),"field");
} catch (DocumentException e) {
fail("Can't parse file " + outputXml.getAbsolutePath());
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java 2010-06-01 09:59:49 UTC (rev 19638)
@@ -95,6 +95,7 @@
assertEquals(node.attribute( "id-type" ).getText(),"long");
assertEquals(node.attribute( "meta-type" ).getText(),"string");
assertEquals(node.attribute( "cascade" ).getText(), "all");
+ assertEquals(node.attribute( "access" ).getText(), "field");
list = node.elements("column");
assertEquals("Expected to get two column elements", 2, list.size());
@@ -148,8 +149,8 @@
assertEquals(node.attribute( "table" ).getText(),"T_GEN_PROPS");
assertEquals(node.attribute( "lazy" ).getText(),"true");
assertEquals(node.attribute( "cascade" ).getText(), "all");
+ assertEquals(node.attribute( "access" ).getText(), "field");
-
list = node.elements("key");
assertEquals("Expected to get one key element", 1, list.size());
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/OneToOneTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/OneToOneTest.java 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/OneToOneTest.java 2010-06-01 09:59:49 UTC (rev 19638)
@@ -20,12 +20,9 @@
import org.dom4j.XPath;
import org.dom4j.io.SAXReader;
import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
import org.hibernate.tool.NonReflectiveTestCase;
-import org.hibernate.tool.hbm2ddl.SchemaValidator;
import org.hibernate.tool.hbm2x.Exporter;
import org.hibernate.tool.hbm2x.HibernateMappingExporter;
-import org.hibernate.util.DTDEntityResolver;
@@ -86,8 +83,8 @@
node = (Element) list.get(0);
assertEquals(node.attribute( "name" ).getText(),"person");
assertEquals(node.attribute( "constrained" ).getText(),"true");
+ assertEquals(node.attribute( "access" ).getText(), "field");
-
}
private Document getXMLDocument(String location) throws DocumentException {
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PersonAddressOneToOnePrimaryKey.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PersonAddressOneToOnePrimaryKey.hbm.xml 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PersonAddressOneToOnePrimaryKey.hbm.xml 2010-06-01 09:59:49 UTC (rev 19638)
@@ -19,6 +19,6 @@
</generator>
</id>
<one-to-one name="person"
- constrained="true"/>
+ constrained="true" access="field"/>
</class>
</hibernate-mapping>
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Properties.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Properties.hbm.xml 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Properties.hbm.xml 2010-06-01 09:59:49 UTC (rev 19638)
@@ -10,14 +10,14 @@
<generator class="increment"/>
</id>
<property name="name" column="NAME" type="string"/>
- <any name="someSpecificProperty" id-type="long" meta-type="string" cascade="all">
+ <any name="someSpecificProperty" id-type="long" meta-type="string" cascade="all" access="field">
<meta-value value="I" class="IntegerPropertyValue"/>
<meta-value value="S" class="StringPropertyValue"/>
<meta-value value="C" class="ComplexPropertyValue" />
<column name="S_S_PROP_TYPE"/>
<column name="S_S_PROP_ID"/>
</any>
- <map name="generalProperties" table="T_GEN_PROPS" lazy="true" cascade="all">
+ <map name="generalProperties" table="T_GEN_PROPS" lazy="true" cascade="all" access="field">
<key column="PROP_SET_ID"/>
<map-key type="string" column="GEN_PROP_NAME"/>
<many-to-any id-type="long" meta-type="string">
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.hbm.xml 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.hbm.xml 2010-06-01 09:59:49 UTC (rev 19638)
@@ -11,7 +11,7 @@
<class name="Search">
<id name="searchString"/>
- <set name="searchResults" sort="natural">
+ <set name="searchResults" sort="natural" access="field">
<key column="searchString"/>
<element column="text" type="string"/>
</set>
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/SetElementTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/SetElementTest.java 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/SetElementTest.java 2010-06-01 09:59:49 UTC (rev 19638)
@@ -16,7 +16,6 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
@@ -27,7 +26,6 @@
import org.hibernate.tool.NonReflectiveTestCase;
import org.hibernate.tool.hbm2x.Exporter;
import org.hibernate.tool.hbm2x.HibernateMappingExporter;
-import org.hibernate.util.DTDEntityResolver;
/**
* @author Dmitry Geraskov
@@ -105,8 +103,8 @@
assertEquals("Expected to get one set element", 1, list.size());
Element node = (Element) list.get(0);
assertEquals(node.attribute( "name" ).getText(),"searchResults");
+ assertEquals(node.attribute( "access" ).getText(),"field");
-
xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/element");
list = xpath.selectNodes(document);
assertEquals("Expected to get one element 'element'", 1, list.size());
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup2.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup2.hbm.xml 2010-05-31 14:55:26 UTC (rev 19637)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup2.hbm.xml 2010-06-01 09:59:49 UTC (rev 19638)
@@ -18,7 +18,7 @@
<idbag name="groups"
order-by="groupName asc"
- table="`UserGroups`" lazy="false">
+ table="`UserGroups`" lazy="false" access="field">
<collection-id column="userGroupId"
type="long">
<generator class="increment"/>
14 years, 6 months