Hibernate SVN: r16109 - in jpa-api/trunk: doc and 5 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-08 14:17:49 -0400 (Sun, 08 Mar 2009)
New Revision: 16109
Added:
jpa-api/trunk/license.txt
jpa-api/trunk/src/main/
jpa-api/trunk/src/main/java/
jpa-api/trunk/src/main/java/javax/
jpa-api/trunk/src/main/javadoc/
jpa-api/trunk/src/main/javadoc/jdstyle.css
jpa-api/trunk/src/main/javadoc/package.html
Removed:
jpa-api/trunk/.cvsignore
jpa-api/trunk/doc/api/
jpa-api/trunk/etc/
jpa-api/trunk/ivy.xml
jpa-api/trunk/ivy/
jpa-api/trunk/src/javax/
Modified:
jpa-api/trunk/
jpa-api/trunk/pom.xml
Log:
switched to a maven build prior to importing jpa 2 api
Property changes on: jpa-api/trunk
___________________________________________________________________
Name: svn:ignore
+ build
target
Deleted: jpa-api/trunk/.cvsignore
===================================================================
--- jpa-api/trunk/.cvsignore 2009-03-08 15:46:33 UTC (rev 16108)
+++ jpa-api/trunk/.cvsignore 2009-03-08 18:17:49 UTC (rev 16109)
@@ -1,3 +0,0 @@
-build
-.settings
-build.properties
Deleted: jpa-api/trunk/ivy.xml
===================================================================
--- jpa-api/trunk/ivy.xml 2009-03-08 15:46:33 UTC (rev 16108)
+++ jpa-api/trunk/ivy.xml 2009-03-08 18:17:49 UTC (rev 16109)
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ivy-module version="1.3"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation=
- "http://www.jayasoft.org/misc/ivy/ivy.xsd">
- <info organisation="org.hibernate" module="ejb3-persistence" revision="1.0.2.GA" status="release"/>
- <publications>
- <artifact name="ejb3-persistence" type="jar" />
- </publications>
-</ivy-module>
\ No newline at end of file
Copied: jpa-api/trunk/license.txt (from rev 16107, jpa-api/trunk/etc/license.txt)
===================================================================
--- jpa-api/trunk/license.txt (rev 0)
+++ jpa-api/trunk/license.txt 2009-03-08 18:17:49 UTC (rev 16109)
@@ -0,0 +1,119 @@
+Specification: JSR-000220 Enterprise JavaBeans v.3.0 ("Specification")
+Version: 3.0
+Status: Final Release
+Release: 8 May 2006
+Copyright 2006 SUN MICROSYSTEMS, INC.
+4150 Network Circle, Santa Clara, California 95054, U.S.A
+All rights reserved.
+LIMITED LICENSE GRANTS
+1. _License for Evaluation Purposes_. Sun hereby grants you a fully-paid, non-exclusive, non-transferable,
+worldwide, limited license (without the right to sublicense), under Sun�s applicable intellectual
+property rights to view, download, use and reproduce the Specification only for the purpose of internal
+evaluation. This includes (i) developing applications intended to run on an implementation of the Specification,
+provided that such applications do not themselves implement any portion(s) of the Specification,
+and (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the
+Specification in oral or written communications which discuss the Specification provided that such excerpts
+do not in the aggregate constitute a significant portion of the Specification.
+2. _License for the Distribution of Compliant Implementations_. Sun also grants you a perpetual, nonexclusive,
+non-transferable, worldwide, fully paid-up, royalty free, limited license (without the right to
+sublicense) under any applicable copyrights or, subject to the provisions of subsection 4 below, patent
+rights it may have covering the Specification to create and/or distribute an Independent Implementation
+of the Specification that: (a) fully implements the Specification including all its required interfaces and
+functionality; (b) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include
+any public or protected packages, classes, Java interfaces, fields or methods within the Licensor
+Name Space other than those required/authorized by the Specification or Specifications being implemented;
+and (c) passes the Technology Compatibility Kit (including satisfying the requirements of the
+applicable TCK Users Guide) for such Specification ("Compliant Implementation"). In addition, the
+foregoing license is expressly conditioned on your not acting outside its scope. No license is granted
+hereunder for any other purpose (including, for example, modifying the Specification, other than to the
+extent of your fair use rights, or distributing the Specification to third parties). Also, no right, title, or
+interest in or to any trademarks, service marks, or trade names of Sun or Sun�s licensors is granted hereunder.
+Java, and Java-related logos, marks and names are trademarks or registered trademarks of Sun Microsystems,
+Inc. in the U.S. and other countries.
+3. _Pass-through Conditions_. You need not include limitations (a)-(c) from the previous paragraph or
+any other particular "pass through" requirements in any license You grant concerning the use of your Independent
+Implementation or products derived from it. However, except with respect to Independent Implementations
+(and products derived from them) that satisfy limitations (a)-(c) from the previous
+paragraph, You may neither: (a) grant or otherwise pass through to your licensees any licenses under
+Sun�s applicable intellectual property rights; nor (b) authorize your licensees to make any claims concerning
+their implementation�s compliance with the Specification in question.
+4. _Reciprocity Concerning Patent Licenses_.
+a. With respect to any patent claims covered by the license granted under subparagraph 2 above that
+would be infringed by all technically feasible implementations of the Specification, such license is conditioned
+upon your offering on fair, reasonable and non-discriminatory terms, to any party seeking it
+from You, a perpetual, non-exclusive, non-transferable, worldwide license under Your patent rights
+which are or would be infringed by all technically feasible implementations of the Specification to develop,
+distribute and use a Compliant Implementation.
+b With respect to any patent claims owned by Sun and covered by the license granted under subparagraph
+2, whether or not their infringement can be avoided in a technically feasible manner when implementing
+the Specification, such license shall terminate with respect to such claims if You initiate a claim against
+Sun that it has, in the course of performing its responsibilities as the Specification Lead, induced any other
+entity to infringe Your patent rights.
+c Also with respect to any patent claims owned by Sun and covered by the license granted under subparagraph
+2 above, where the infringement of such claims can be avoided in a technically feasible manner
+when implementing the Specification such license, with respect to such claims, shall terminate if You
+initiate a claim against Sun that its making, having made, using, offering to sell, selling or importing a
+Compliant Implementation infringes Your patent rights.
+5. _Definitions_. For the purposes of this Agreement: "Independent Implementation" shall mean an implementation
+of the Specification that neither derives from any of Sun�s source code or binary code materials
+nor, except with an appropriate and separate license from Sun, includes any of Sun�s source code
+or binary code materials; "Licensor Name Space" shall mean the public class or interface declarations
+whose names begin with "java", "javax", "com.sun" or their equivalents in any subsequent naming convention
+adopted by Sun through the Java Community Process, or any recognized successors or replacements
+thereof; and "Technology Compatibility Kit" or "TCK" shall mean the test suite and
+accompanying TCK User�s Guide provided by Sun which corresponds to the Specification and that was
+available either (i) from Sun 120 days before the first release of Your Independent Implementation that
+allows its use for commercial purposes, or (ii) more recently than 120 days from such release but against
+which You elect to test Your implementation of the Specification.
+This Agreement will terminate immediately without notice from Sun if you breach the Agreement or act
+outside the scope of the licenses granted above.
+DISCLAIMER OF WARRANTIES
+THE SPECIFICATION IS PROVIDED "AS IS". SUN MAKES NO REPRESENTATIONS OR WARRANTIES,
+EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT
+(INCLUDING AS A CONSEQUENCE OF ANY PRACTICE OR IMPLEMENTATION
+OF THE SPECIFICATION), OR THAT THE CONTENTS OF THE SPECIFICATION ARE
+SUITABLE FOR ANY PURPOSE. This document does not represent any commitment to release or implement
+any portion of the Specification in any product. In addition, the Specification could include technical
+inaccuracies or typographical errors.
+LIMITATION OF LIABILITY
+TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL SUN OR ITS LICENSORS
+BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE,
+PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ARISING OUT OF OR RELATED IN ANY WAY TO YOUR HAVING, IMPLEMENTING OR
+OTHERWISE USING THE SPECIFICATION, EVEN IF SUN AND/OR ITS LICENSORS HAVE
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+You will indemnify, hold harmless, and defend Sun and its licensors from any claims arising or resulting
+from: (i) your use of the Specification; (ii) the use or distribution of your Java application, applet and/or
+implementation; and/or (iii) any claims that later versions or releases of any Specification furnished to
+you are incompatible with the Specification provided to you under this license.
+
+RESTRICTED RIGHTS LEGEND
+U.S. Government: If this Specification is being acquired by or on behalf of the U.S. Government or by a
+U.S. Government prime contractor or subcontractor (at any tier), then the Government�s rights in the
+Software and accompanying documentation shall be only as set forth in this license; this is in accordance
+with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with
+48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
+REPORT
+If you provide Sun with any comments or suggestions concerning the Specification ("Feedback"), you
+hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii)
+grant Sun a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense
+through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the
+Feedback for any purpose.
+GENERAL TERMS
+Any action related to this Agreement will be governed by California law and controlling U.S. federal law.
+The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction
+will not apply.
+The Specification is subject to U.S. export control laws and may be subject to export or import regulations
+in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges
+that it has the responsibility to obtain such licenses to export, re-export or import as may be
+required after delivery to Licensee.
+This Agreement is the parties� entire agreement relating to its subject matter. It supersedes all prior or
+contemporaneous oral or written communications, proposals, conditions, representations and warranties
+and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication
+between the parties relating to its subject matter during the term of this Agreement. No modification
+to this Agreement will be binding, unless in writing and signed by an authorized representative
+of each party.
+Rev. April, 2006
+Sun/Final/Full
\ No newline at end of file
Property changes on: jpa-api/trunk/license.txt
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Modified: jpa-api/trunk/pom.xml
===================================================================
--- jpa-api/trunk/pom.xml 2009-03-08 15:46:33 UTC (rev 16108)
+++ jpa-api/trunk/pom.xml 2009-03-08 18:17:49 UTC (rev 16109)
@@ -1,15 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <modelVersion>4.0.0</modelVersion>
+ <groupId>javax.persistence</groupId>
+ <artifactId>jpa-api</artifactId>
+ <version>2.0.Beta1</version>
+ <packaging>jar</packaging>
+ <name>Persistence API</name>
- <groupId>org.hibernate</groupId>
- <artifactId>ejb3-persistence</artifactId>
- <packaging>pom</packaging>
- <version>1.0.2.GA</version>
+ <description>Persistence API. </description>
- <name>Java Persistence API</name>
- <description>Java Persistence API</description>
- <url>http://www.hibernate.org</url>
+ <inceptionYear>2007</inceptionYear>
+
+ <licenses>
+ <license>
+ <url>license.txt</url>
+ </license>
+ </licenses>
+
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/hibernate/jpa-api/trunk</connection>
+ <url>http://fisheye.jboss.org/browse/Hibernate/jpa-api/trunk/</url>
+ </scm>
+
+ <developers>
+ <developer>
+ <id>epbernard</id>
+ <name>Emmanuel Bernard</name>
+ <email>emmanuel(a)hibernate.org</email>
+ <organization>JBoss, a division of Red Hat</organization>
+ <url>http://in.relation.to/Bloggers/Emmanuel</url>
+ </developer>
+ <developer>
+ <id>hardy.ferentschik</id>
+ <name>Hardy Ferentschik</name>
+ <email>hferents(a)redhat.com</email>
+ <organization>JBoss, a division of Red Hat</organization>
+ <url>http://in.relation.to/Bloggers/Hardy</url>
+ </developer>
+ </developers>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ <version>1.0-beta-2</version>
+ </extension>
+ </extensions>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Built-By>hibernate.org</Built-By>
+ <Specification-Title>EJB 3.0</Specification-Title>
+ <Specification-Version>${pom.version}</Specification-Version>
+ <Specification-Vendor>Sun Microsystems, Inc.</Specification-Vendor>
+ <Implementation-Version>${pom.version}</Implementation-Version>
+ <Implementation-Vendor>hibernate.org</Implementation-Vendor>
+ <Implementation-Title>EJB</Implementation-Title>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <packagenames>javax.persistence.*</packagenames>
+ <use>true</use>
+ <protected>true</protected>
+ <version>true</version>
+ <overview>${basedir}/src/main/javadoc/package.html</overview>
+ <windowtitle>EJB 3.0 Persistence API Documentation</windowtitle>
+ <doctitle>EJB 3.0 Persistence API Documentation</doctitle>
+ <link>http://java.sun.com/j2se/1.5/docs/api</link>
+ <stylesheetfile>${basedir}/src/main/javadoc/jdstyle.css</stylesheetfile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <releaseProfiles>release</releaseProfiles>
+ <goals>package</goals>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <distributionManagement>
+ <repository>
+ <!-- Copy the dist to the local checkout of the JBoss maven2 repo ${maven.repository.root} -->
+ <!-- It is anticipated that ${maven.repository.root} be set in user's settings.xml -->
+ <!-- todo : replace this with direct svn access once the svnkit providers are available -->
+ <id>repository.jboss.org</id>
+ <url>file://${maven.repository.root}</url>
+ </repository>
+ <snapshotRepository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <url>dav:https://snapshots.jboss.org/maven2</url>
+ </snapshotRepository>
+ </distributionManagement>
</project>
Copied: jpa-api/trunk/src/main/java/javax (from rev 16107, jpa-api/trunk/src/javax)
Property changes on: jpa-api/trunk/src/main/java/javax
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jpa-api/trunk/src/main/javadoc/jdstyle.css (from rev 16107, jpa-api/trunk/etc/jdstyle.css)
===================================================================
--- jpa-api/trunk/src/main/javadoc/jdstyle.css (rev 0)
+++ jpa-api/trunk/src/main/javadoc/jdstyle.css 2009-03-08 18:17:49 UTC (rev 16109)
@@ -0,0 +1,117 @@
+/* Javadoc style sheet */
+
+/* Define colors, fonts and other style attributes here to override the defaults */
+
+/* Page background color */
+body { font-family: Arial;
+ background-color: white;
+ font-size: 10pt;
+ }
+td { font-family: Arial;
+ font-size: 10pt;
+ }
+/* Table colors */
+.TableHeadingColor { background: #F4F4F4 }
+.TableSubHeadingColor { background: #F4F4F4 }
+.TableRowColor { background: #FFFFFF }
+
+/* Font used in left-hand frame lists */
+.FrameTitleFont { font-size: normal; font-family: Arial }
+.FrameHeadingFont { font-size: normal; font-family: Arial }
+.FrameItemFont { font-size: normal; font-family: Arial }
+
+/* Example of smaller, sans-serif font in frames */
+/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */
+
+/* Navigation bar fonts and colors */
+.NavBarCell1 { background-color:#F4F4F4;}
+.NavBarCell1Rev { background-color:silver;}
+
+.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;}
+.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
+
+.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
+.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
+
+A {
+ color: #003399;
+}
+
+A:active {
+ color: #003399;
+}
+
+A:visited {
+ color: #888888;
+}
+
+P, OL, UL, LI, DL, DT, DD, BLOCKQUOTE {
+ color: #000000;
+}
+
+TD, TH, SPAN {
+ color: #000000;
+}
+
+BLOCKQUOTE {
+ margin-right: 0px;
+}
+
+
+/*H1, H2, H3, H4, H5, H6 {
+ color: #000000;
+ font-weight:500;
+ margin-top:10px;
+ padding-top:15px;
+}
+
+H1 { font-size: 150%; }
+H2 { font-size: 140%; }
+H3 { font-size: 110%; font-weight: bold; }
+H4 { font-size: 110%; font-weight: bold;}
+H5 { font-size: 100%; font-style: italic; }
+H6 { font-size: 100%; font-style: italic; }*/
+
+TT {
+font-size: 90%;
+ font-family: "Courier New", Courier, monospace;
+ color: #000000;
+}
+
+PRE {
+font-size: 90%;
+ padding: 5px;
+ border-style: solid;
+ border-width: 1px;
+ border-color: #CCCCCC;
+ background-color: #F4F4F4;
+}
+
+UL, OL, LI {
+ list-style: disc;
+}
+
+HR {
+ width: 100%;
+ height: 1px;
+ background-color: #CCCCCC;
+ border-width: 0px;
+ padding: 0px;
+ color: #CCCCCC;
+}
+
+.variablelist {
+ padding-top: 10;
+ padding-bottom:10;
+ margin:0;
+}
+
+.itemizedlist, UL {
+ padding-top: 0;
+ padding-bottom:0;
+ margin:0;
+}
+
+.term {
+ font-weight:bold;
+}
Property changes on: jpa-api/trunk/src/main/javadoc/jdstyle.css
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jpa-api/trunk/src/main/javadoc/package.html (from rev 16107, jpa-api/trunk/doc/api/package.html)
===================================================================
--- jpa-api/trunk/src/main/javadoc/package.html (rev 0)
+++ jpa-api/trunk/src/main/javadoc/package.html 2009-03-08 18:17:49 UTC (rev 16109)
@@ -0,0 +1 @@
+<body></body>
\ No newline at end of file
Property changes on: jpa-api/trunk/src/main/javadoc/package.html
___________________________________________________________________
Name: svn:mergeinfo
+
15 years, 9 months
Hibernate SVN: r16108 - jpa-api/tags.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-08 11:46:33 -0400 (Sun, 08 Mar 2009)
New Revision: 16108
Added:
jpa-api/tags/before_jpa2/
Log:
Created tag before_jpa2.
Copied: jpa-api/tags/before_jpa2 (from rev 16107, jpa-api/trunk)
15 years, 9 months
Hibernate SVN: r16107 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-08 10:28:40 -0400 (Sun, 08 Mar 2009)
New Revision: 16107
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
Log:
HV-125 override paramters are not longer kept as class members
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-07 17:57:46 UTC (rev 16106)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-08 14:28:40 UTC (rev 16107)
@@ -44,7 +44,7 @@
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
/**
- * Describe a single constraint.
+ * Describe a single constraint (including it's composing constraints).
*
* @author Emmanuel Bernard
* @author Hardy Ferentschik
@@ -63,7 +63,7 @@
* The set of classes implementing the validation for this constraint. See also
* <code>ConstraintValidator</code> resolution algorithm.
*/
- private final List<Class<? extends ConstraintValidator<T, ?>>> constraintClasses = new ArrayList<Class<? extends ConstraintValidator<T, ?>>>();
+ private final List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorDefinitonClasses = new ArrayList<Class<? extends ConstraintValidator<T, ?>>>();
/**
* The groups for which to apply this constraint.
@@ -82,11 +82,6 @@
private final Set<ConstraintDescriptor<?>> composingConstraints = new HashSet<ConstraintDescriptor<?>>();
/**
- * Override paramter values used for composing constraints.
- */
- private final Map<ClassIndexWrapper, Map<String, Object>> overrideParameters = new HashMap<ClassIndexWrapper, Map<String, Object>>();
-
- /**
* Flag indicating if in case of a composing constraint a single error or multiple errors should be raised.
*/
private final boolean isReportAsSingleInvalidConstraint;
@@ -119,18 +114,16 @@
ReportAsSingleViolation.class
);
-
findConstraintClasses();
- parseOverrideParameters();
- parseComposingConstraints();
+ Map<ClassIndexWrapper, Map<String, Object>> overrideParameters = parseOverrideParameters();
+ parseComposingConstraints( overrideParameters );
}
private void findConstraintClasses() {
if ( constraintHelper.isBuiltinConstraint( annotation ) ) {
- constraintClasses.addAll( constraintHelper.getBuiltInConstraints( annotation ) );
+ constraintValidatorDefinitonClasses.addAll( constraintHelper.getBuiltInConstraints( annotation ) );
}
else {
- //TODO are we sure a @Constraint is there?
final Class<? extends Annotation> annotationType = annotation.annotationType();
Class<? extends ConstraintValidator<?, ?>>[] validatedBy = annotationType
.getAnnotation( Constraint.class )
@@ -140,7 +133,7 @@
//FIXME if yes wrap into VE, if no we need to test the type here
//Once resolved,we can @SuppressWarning("unchecked") on the cast
Class<? extends ConstraintValidator<T, ?>> safeValidator = ( Class<? extends ConstraintValidator<T, ?>> ) validator;
- constraintClasses.add( safeValidator );
+ constraintValidatorDefinitonClasses.add( safeValidator );
}
}
}
@@ -163,7 +156,7 @@
* {@inheritDoc}
*/
public List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorClasses() {
- return Collections.unmodifiableList( constraintClasses );
+ return Collections.unmodifiableList( constraintValidatorDefinitonClasses );
}
/**
@@ -191,7 +184,7 @@
public String toString() {
return "ConstraintDescriptorImpl{" +
"annotation=" + annotation +
- ", constraintClasses=" + constraintClasses.toString() +
+ ", constraintValidatorDefinitonClasses=" + constraintValidatorDefinitonClasses.toString() +
", groups=" + groups +
", parameters=" + parameters +
", composingConstraints=" + composingConstraints +
@@ -216,18 +209,6 @@
return Collections.unmodifiableMap( parameters );
}
- private void addOverrideParameter(Map<ClassIndexWrapper, Map<String, Object>> overrideParameters, Object value, OverridesParameter... parameters) {
- for ( OverridesParameter parameter : parameters ) {
- ClassIndexWrapper wrapper = new ClassIndexWrapper( parameter.constraint(), parameter.index() );
- Map<String, Object> map = overrideParameters.get( wrapper );
- if ( map == null ) {
- map = new HashMap<String, Object>();
- overrideParameters.put( wrapper, map );
- }
- map.put( parameter.parameter(), value );
- }
- }
-
private Object getMethodValue(Annotation annotation, Method m) {
Object value;
try {
@@ -243,7 +224,8 @@
return value;
}
- private void parseOverrideParameters() {
+ private Map<ClassIndexWrapper, Map<String, Object>> parseOverrideParameters() {
+ Map<ClassIndexWrapper, Map<String, Object>> overrideParameters = new HashMap<ClassIndexWrapper, Map<String, Object>>();
for ( Method m : annotation.annotationType().getMethods() ) {
if ( m.getAnnotation( OverridesParameter.class ) != null ) {
addOverrideParameter(
@@ -258,14 +240,27 @@
);
}
}
+ return overrideParameters;
}
- private void parseComposingConstraints() {
+ private void addOverrideParameter(Map<ClassIndexWrapper, Map<String, Object>> overrideParameters, Object value, OverridesParameter... parameters) {
+ for ( OverridesParameter parameter : parameters ) {
+ ClassIndexWrapper wrapper = new ClassIndexWrapper( parameter.constraint(), parameter.index() );
+ Map<String, Object> map = overrideParameters.get( wrapper );
+ if ( map == null ) {
+ map = new HashMap<String, Object>();
+ overrideParameters.put( wrapper, map );
+ }
+ map.put( parameter.parameter(), value );
+ }
+ }
+
+ private void parseComposingConstraints(Map<ClassIndexWrapper, Map<String, Object>> overrideParameters) {
for ( Annotation declaredAnnotation : annotation.annotationType().getDeclaredAnnotations() ) {
if ( constraintHelper.isConstraintAnnotation( declaredAnnotation )
|| constraintHelper.isBuiltinConstraint( declaredAnnotation ) ) {
ConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor(
- declaredAnnotation, OVERRIDES_PARAMETER_DEFAULT_INDEX
+ declaredAnnotation, overrideParameters, OVERRIDES_PARAMETER_DEFAULT_INDEX
);
composingConstraints.add( descriptor );
log.debug( "Adding composing constraint: " + descriptor );
@@ -275,7 +270,7 @@
int index = 1;
for ( Annotation constraintAnnotation : multiValueConstraints ) {
ConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor(
- constraintAnnotation, index
+ constraintAnnotation, overrideParameters, index
);
composingConstraints.add( descriptor );
log.debug( "Adding composing constraint: " + descriptor );
@@ -285,19 +280,20 @@
}
}
- private <U extends Annotation> ConstraintDescriptorImpl<U> createComposingConstraintDescriptor(U declaredAnnotation, int index) {
+ private <U extends Annotation> ConstraintDescriptorImpl<U> createComposingConstraintDescriptor(U declaredAnnotation, Map<ClassIndexWrapper, Map<String, Object>> overrideParameters, int index) {
//TODO don't quite understand this warning
//TODO assuming U.getClass() returns Class<U>
@SuppressWarnings("unchecked")
final Class<U> annotationType = ( Class<U> ) declaredAnnotation.annotationType();
return createComposingConstraintDescriptor(
+ overrideParameters,
index,
declaredAnnotation,
annotationType
);
}
- private <U extends Annotation> ConstraintDescriptorImpl<U> createComposingConstraintDescriptor(int index, U constraintAnnotation, Class<U> annotationType) {
+ private <U extends Annotation> ConstraintDescriptorImpl<U> createComposingConstraintDescriptor(Map<ClassIndexWrapper, Map<String, Object>> overrideParameters, int index, U constraintAnnotation, Class<U> annotationType) {
AnnotationDescriptor<U> annotationDescriptor = new AnnotationDescriptor<U>(
annotationType, getAnnotationParameters( constraintAnnotation )
);
15 years, 9 months
Hibernate SVN: r16106 - in validator/trunk/hibernate-validator/src: main/java/org/hibernate/validation/util and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-07 12:57:46 -0500 (Sat, 07 Mar 2009)
New Revision: 16106
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Auditable.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Order.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
Log:
HV-115 Implicit grouping
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-03-07 08:33:16 UTC (rev 16105)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-03-07 17:57:46 UTC (rev 16106)
@@ -176,7 +176,7 @@
private <A extends Annotation> void initFieldConstraints(Class clazz) {
for ( Field field : clazz.getDeclaredFields() ) {
- List<ConstraintDescriptorImpl> fieldMetadata = findFieldLevelConstraints( field );
+ List<ConstraintDescriptorImpl> fieldMetadata = findConstraints( field );
for ( ConstraintDescriptorImpl constraintDescription : fieldMetadata ) {
ReflectionHelper.setAccessibility( field );
MetaConstraint<T, A> metaConstraint = new MetaConstraint<T, A>(
@@ -186,7 +186,6 @@
}
if ( field.isAnnotationPresent( Valid.class ) ) {
ReflectionHelper.setAccessibility( field );
- String name = field.getName();
cascadedFields.add( field );
addPropertyDescriptorForMember( field );
}
@@ -195,7 +194,7 @@
private <A extends Annotation> void initMethodConstraints(Class clazz) {
for ( Method method : clazz.getDeclaredMethods() ) {
- List<ConstraintDescriptorImpl> methodMetadata = findMethodLevelConstraints( method );
+ List<ConstraintDescriptorImpl> methodMetadata = findConstraints( method );
for ( ConstraintDescriptorImpl constraintDescription : methodMetadata ) {
ReflectionHelper.setAccessibility( method );
MetaConstraint<T, A> metaConstraint = new MetaConstraint<T, A>(
@@ -238,12 +237,13 @@
/**
* Examines the given annotation to see whether it is a single or multi valued constraint annotation.
*
+ * @param clazz the class we are currently processing.
* @param annotation The annotation to examine.
*
* @return A list of constraint descriptors or the empty list in case <code>annotation</code> is neither a
* single nor multi value annotation.
*/
- private <A extends Annotation> List<ConstraintDescriptorImpl> findConstraintAnnotations(A annotation) {
+ private <A extends Annotation> List<ConstraintDescriptorImpl> findConstraintAnnotations(Class<?> clazz, A annotation) {
List<ConstraintDescriptorImpl> constraintDescriptors = new ArrayList<ConstraintDescriptorImpl>();
List<Annotation> constraints = new ArrayList<Annotation>();
@@ -256,16 +256,23 @@
constraints.addAll( constraintHelper.getMultiValueConstraints( annotation ) );
for ( Annotation constraint : constraints ) {
- final ConstraintDescriptorImpl constraintDescriptor = buildConstraintDescriptor( constraint );
+ final ConstraintDescriptorImpl constraintDescriptor = buildConstraintDescriptor( clazz, constraint );
constraintDescriptors.add( constraintDescriptor );
}
return constraintDescriptors;
}
@SuppressWarnings("unchecked")
- private <A extends Annotation> ConstraintDescriptorImpl buildConstraintDescriptor(A annotation) {
+ private <A extends Annotation> ConstraintDescriptorImpl buildConstraintDescriptor(Class<?> clazz, A annotation) {
Class<?>[] groups = ReflectionHelper.getAnnotationParameter( annotation, "groups", Class[].class );
- return new ConstraintDescriptorImpl( annotation, groups, constraintHelper );
+ ConstraintDescriptorImpl constraintDescriptor;
+ if ( clazz.isInterface() ) {
+ constraintDescriptor = new ConstraintDescriptorImpl( annotation, groups, constraintHelper, clazz );
+ }
+ else {
+ constraintDescriptor = new ConstraintDescriptorImpl( annotation, groups, constraintHelper );
+ }
+ return constraintDescriptor;
}
/**
@@ -276,10 +283,10 @@
*
* @return A list of constraint descriptors for all constraint specified on the given class.
*/
- private List<ConstraintDescriptorImpl> findClassLevelConstraints(Class beanClass) {
+ private List<ConstraintDescriptorImpl> findClassLevelConstraints(Class<?> beanClass) {
List<ConstraintDescriptorImpl> metadata = new ArrayList<ConstraintDescriptorImpl>();
for ( Annotation annotation : beanClass.getAnnotations() ) {
- metadata.addAll( findConstraintAnnotations( annotation ) );
+ metadata.addAll( findConstraintAnnotations( beanClass, annotation ) );
}
for ( ConstraintDescriptorImpl constraintDescriptor : metadata ) {
beanDescriptor.addConstraintDescriptor( constraintDescriptor );
@@ -287,61 +294,39 @@
return metadata;
}
+
/**
- * Finds all constraint annotations defined for the given methods and returns them in a list of
+ * Finds all constraint annotations defined for the given field/method and returns them in a list of
* constraint descriptors.
*
- * @param method The method to check for constraints annotations.
+ * @param member The fiels or method to check for constraints annotations.
*
- * @return A list of constraint descriptors for all constraint specified for the given method.
+ * @return A list of constraint descriptors for all constraint specified for the given field or method.
*/
- private List<ConstraintDescriptorImpl> findMethodLevelConstraints(Method method) {
+ private List<ConstraintDescriptorImpl> findConstraints(Member member) {
+ assert member instanceof Field || member instanceof Method;
+
List<ConstraintDescriptorImpl> metadata = new ArrayList<ConstraintDescriptorImpl>();
- for ( Annotation annotation : method.getAnnotations() ) {
- metadata.addAll( findConstraintAnnotations( annotation ) );
+ for ( Annotation annotation : ( ( AnnotatedElement ) member ).getAnnotations() ) {
+ metadata.addAll( findConstraintAnnotations( member.getDeclaringClass(), annotation ) );
}
- String methodName = ReflectionHelper.getPropertyName( method );
+ String name = ReflectionHelper.getPropertyName( member );
for ( ConstraintDescriptorImpl constraintDescriptor : metadata ) {
- if ( methodName == null ) {
+ if ( member instanceof Method && name == null ) { // can happen if member is a Method which does not follow the bean convention
throw new ValidationException(
- "Annotated methods must follow the JavaBeans naming convention. " + method.getName() + "() does not."
+ "Annotated methods must follow the JavaBeans naming convention. " + member.getName() + "() does not."
);
}
- PropertyDescriptorImpl propertyDescriptor = ( PropertyDescriptorImpl ) propertyDescriptors.get( methodName );
+ PropertyDescriptorImpl propertyDescriptor = ( PropertyDescriptorImpl ) propertyDescriptors.get( name );
if ( propertyDescriptor == null ) {
- propertyDescriptor = addPropertyDescriptorForMember( method );
+ propertyDescriptor = addPropertyDescriptorForMember( member );
}
propertyDescriptor.addConstraintDescriptor( constraintDescriptor );
}
return metadata;
}
- /**
- * Finds all constraint annotations defined for the given field and returns them in a list of
- * constraint descriptors.
- *
- * @param field The field to check for constraints annotations.
- *
- * @return A list of constraint descriptors for all constraint specified on the given field.
- */
- private List<ConstraintDescriptorImpl> findFieldLevelConstraints(Field field) {
- List<ConstraintDescriptorImpl> metadata = new ArrayList<ConstraintDescriptorImpl>();
- for ( Annotation annotation : field.getAnnotations() ) {
- metadata.addAll( findConstraintAnnotations( annotation ) );
- }
-
- String fieldName = field.getName();
- for ( ConstraintDescriptorImpl constraintDescriptor : metadata ) {
- PropertyDescriptorImpl propertyDescriptor = ( PropertyDescriptorImpl ) propertyDescriptors.get( fieldName );
- if ( propertyDescriptor == null ) {
- propertyDescriptor = addPropertyDescriptorForMember( field );
- }
- propertyDescriptor.addConstraintDescriptor( constraintDescriptor );
- }
- return metadata;
- }
-
public Class<T> getBeanClass() {
return beanClass;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-07 08:33:16 UTC (rev 16105)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-07 17:57:46 UTC (rev 16106)
@@ -96,6 +96,11 @@
*/
private final ConstraintHelper constraintHelper;
+ public ConstraintDescriptorImpl(T annotation, Class<?>[] groups, ConstraintHelper constraintHelper, Class<?> implicitGroup) {
+ this( annotation, groups, constraintHelper );
+ this.groups.add( implicitGroup );
+ }
+
public ConstraintDescriptorImpl(T annotation, Class<?>[] groups, ConstraintHelper constraintHelper) {
this( annotation, new HashSet<Class<?>>(), constraintHelper );
if ( groups.length == 0 ) {
@@ -127,14 +132,14 @@
else {
//TODO are we sure a @Constraint is there?
final Class<? extends Annotation> annotationType = annotation.annotationType();
- Class<? extends ConstraintValidator<?,?>>[] validatedBy = annotationType
+ Class<? extends ConstraintValidator<?, ?>>[] validatedBy = annotationType
.getAnnotation( Constraint.class )
.validatedBy();
- for (Class<? extends ConstraintValidator<?,?>> validator : validatedBy) {
+ for ( Class<? extends ConstraintValidator<?, ?>> validator : validatedBy ) {
//FIXME does this create a CCE at runtime?
//FIXME if yes wrap into VE, if no we need to test the type here
//Once resolved,we can @SuppressWarning("unchecked") on the cast
- Class<? extends ConstraintValidator<T,?>> safeValidator = (Class<? extends ConstraintValidator<T,?>>) validator;
+ Class<? extends ConstraintValidator<T, ?>> safeValidator = ( Class<? extends ConstraintValidator<T, ?>> ) validator;
constraintClasses.add( safeValidator );
}
}
@@ -165,14 +170,14 @@
* {@inheritDoc}
*/
public Map<String, Object> getParameters() {
- return Collections.unmodifiableMap(parameters);
+ return Collections.unmodifiableMap( parameters );
}
/**
* {@inheritDoc}
*/
public Set<ConstraintDescriptor<?>> getComposingConstraints() {
- return Collections.unmodifiableSet(composingConstraints);
+ return Collections.unmodifiableSet( composingConstraints );
}
/**
@@ -259,7 +264,9 @@
for ( Annotation declaredAnnotation : annotation.annotationType().getDeclaredAnnotations() ) {
if ( constraintHelper.isConstraintAnnotation( declaredAnnotation )
|| constraintHelper.isBuiltinConstraint( declaredAnnotation ) ) {
- ConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor( declaredAnnotation, OVERRIDES_PARAMETER_DEFAULT_INDEX );
+ ConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor(
+ declaredAnnotation, OVERRIDES_PARAMETER_DEFAULT_INDEX
+ );
composingConstraints.add( descriptor );
log.debug( "Adding composing constraint: " + descriptor );
}
@@ -268,7 +275,7 @@
int index = 1;
for ( Annotation constraintAnnotation : multiValueConstraints ) {
ConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor(
- constraintAnnotation, index
+ constraintAnnotation, index
);
composingConstraints.add( descriptor );
log.debug( "Adding composing constraint: " + descriptor );
@@ -282,12 +289,12 @@
//TODO don't quite understand this warning
//TODO assuming U.getClass() returns Class<U>
@SuppressWarnings("unchecked")
- final Class<U> annotationType = (Class<U>) declaredAnnotation.annotationType();
+ final Class<U> annotationType = ( Class<U> ) declaredAnnotation.annotationType();
return createComposingConstraintDescriptor(
- index,
- declaredAnnotation,
- annotationType
- );
+ index,
+ declaredAnnotation,
+ annotationType
+ );
}
private <U extends Annotation> ConstraintDescriptorImpl<U> createComposingConstraintDescriptor(int index, U constraintAnnotation, Class<U> annotationType) {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java 2009-03-07 08:33:16 UTC (rev 16105)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java 2009-03-07 17:57:46 UTC (rev 16106)
@@ -142,6 +142,26 @@
}
/**
+ * Returns the type of the field of return type of a method.
+ *
+ * @param member the member for which to get the type.
+ *
+ * @return Returns the type of the field of return type of a method.
+ */
+ public static Class<?> getAnnotations(Member member) {
+
+ Class<?> type = null;
+ if ( member instanceof Field ) {
+ type = ( ( Field ) member ).getType();
+ }
+
+ if ( member instanceof Method ) {
+ type = ( ( Method ) member ).getReturnType();
+ }
+ return type;
+ }
+
+ /**
* @param member The <code>Member</code> instance for which to retrieve the type.
*
* @return Retrurns the <code>Type</code> of the given <code>Field</code> or <code>Method</code>.
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Auditable.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Auditable.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Auditable.java 2009-03-07 17:57:46 UTC (rev 16106)
@@ -0,0 +1,37 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine.groups;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface Auditable {
+ @NotNull
+ String getCreationDate();
+
+ @NotNull
+ String getLastUpdate();
+
+ @NotNull
+ String getLastModifier();
+
+ @NotNull
+ String getLastReader();
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Auditable.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java 2009-03-07 08:33:16 UTC (rev 16105)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java 2009-03-07 17:57:46 UTC (rev 16106)
@@ -18,11 +18,13 @@
package org.hibernate.validation.engine.groups;
import java.util.Set;
+import javax.validation.BeanDescriptor;
import javax.validation.ConstraintViolation;
import javax.validation.ValidationException;
import javax.validation.Validator;
import javax.validation.groups.Default;
+import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
@@ -344,7 +346,11 @@
1,
constraintViolations.size()
);
- assertEquals( "Wrong constraint", "length must be between 2 and 20", constraintViolations.iterator().next().getMessage() );
+ assertEquals(
+ "Wrong constraint",
+ "length must be between 2 and 20",
+ constraintViolations.iterator().next().getMessage()
+ );
constraintViolations = validator.validateProperty( car, "type" );
assertEquals(
@@ -352,7 +358,11 @@
1,
constraintViolations.size()
);
- assertEquals( "Wrong constraint", "length must be between 2 and 20", constraintViolations.iterator().next().getMessage() );
+ assertEquals(
+ "Wrong constraint",
+ "length must be between 2 and 20",
+ constraintViolations.iterator().next().getMessage()
+ );
constraintViolations = validator.validateValue( Car.class, "type", "A" );
assertEquals(
@@ -360,7 +370,11 @@
1,
constraintViolations.size()
);
- assertEquals( "Wrong constraint", "length must be between 2 and 20", constraintViolations.iterator().next().getMessage() );
+ assertEquals(
+ "Wrong constraint",
+ "length must be between 2 and 20",
+ constraintViolations.iterator().next().getMessage()
+ );
}
/**
@@ -380,4 +394,25 @@
);
}
}
+
+ /**
+ * HV-115
+ */
+ @Test
+ public void testImplicitGroup() {
+ Validator validator = TestUtil.getValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ assertTrue( beanDescriptor.isBeanConstrained() );
+
+ Set<String> constraintProperties = beanDescriptor.getConstrainedProperties();
+ assertTrue( "Each of the properties should have at least one constraint.", constraintProperties.size() == 5 );
+
+ Order order = new Order();
+ Set<ConstraintViolation<Order>> violations = validator.validate( order );
+ assertTrue( "All 5 NotNull constraints should fail.", violations.size() == 5 );
+
+ // use implicit group Auditable
+ violations = validator.validate( order, Auditable.class );
+ assertTrue( "All 4 NotNull constraints on Auditable should fail.", violations.size() == 4 );
+ }
}
\ No newline at end of file
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Order.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Order.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Order.java 2009-03-07 17:57:46 UTC (rev 16106)
@@ -0,0 +1,54 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine.groups;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Order implements Auditable {
+ private String creationDate;
+ private String lastUpdate;
+ private String lastModifier;
+ private String lastReader;
+ private String orderNumber;
+
+ public String getCreationDate() {
+ return this.creationDate;
+ }
+
+ public String getLastUpdate() {
+ return this.lastUpdate;
+ }
+
+ public String getLastModifier() {
+ return this.lastModifier;
+ }
+
+ public String getLastReader() {
+ return this.lastReader;
+ }
+
+ @NotNull
+ @Size(min = 10, max = 10)
+ public String getOrderNumber() {
+ return this.orderNumber;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Order.java
___________________________________________________________________
Name: svn:keywords
+ Id
15 years, 9 months
Hibernate SVN: r16105 - validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-07 03:33:16 -0500 (Sat, 07 Mar 2009)
New Revision: 16105
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java
Log:
HV-95, HV-84 Added some test.
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java 2009-03-07 08:25:39 UTC (rev 16104)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java 2009-03-07 08:33:16 UTC (rev 16105)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -77,6 +77,9 @@
assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( "foobar" ) );
+ // TODO Is this corect or should we get a IllegalArgumentException
+ assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( null ) );
+
beanDescriptor = validator.getConstraintsForClass( Customer.class );
propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
assertEquals(
15 years, 9 months
Hibernate SVN: r16104 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-07 03:25:39 -0500 (Sat, 07 Mar 2009)
New Revision: 16104
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
Log:
HV-95, HV-84 Added some test.
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java 2009-03-06 22:29:35 UTC (rev 16103)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java 2009-03-07 08:25:39 UTC (rev 16104)
@@ -39,7 +39,7 @@
/**
* Return the property descriptor for a given property.
- * Return null if the property does not exist or has no
+ * Return <code>null</code> if the property does not exist or has no
* constraint nor is marked as cascaded (see {@link #getConstrainedProperties()} )
* <p/>
* The returned object (and associated objects including ConstraintDescriptors)
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java 2009-03-06 22:29:35 UTC (rev 16103)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java 2009-03-07 08:25:39 UTC (rev 16104)
@@ -11,8 +11,8 @@
public class BeanDescriptorImpl<T> extends ElementDescriptorImpl implements BeanDescriptor {
private final BeanMetaData<T> metadataBean;
- public BeanDescriptorImpl(Class<T> returnType, BeanMetaData<T> metadataBean) {
- super( returnType );
+ public BeanDescriptorImpl(BeanMetaData<T> metadataBean) {
+ super( metadataBean.getBeanClass() );
this.metadataBean = metadataBean;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-03-06 22:29:35 UTC (rev 16103)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-03-07 08:25:39 UTC (rev 16104)
@@ -104,7 +104,7 @@
* for this validator and create meta data.
*/
private void createMetaData() {
- beanDescriptor = new BeanDescriptorImpl<T>( beanClass, this );
+ beanDescriptor = new BeanDescriptorImpl<T>( this );
initDefaultGroupSequence( beanClass );
List<Class> classes = new ArrayList<Class>();
computeClassHierarchy( beanClass, classes );
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java 2009-03-06 22:29:35 UTC (rev 16103)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java 2009-03-07 08:25:39 UTC (rev 16104)
@@ -41,6 +41,9 @@
constraintDescriptors.add( constraintDescriptor );
}
+ /**
+ * {@inheritDoc}
+ */
public boolean hasConstraints() {
return constraintDescriptors.size() != 0;
}
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java 2009-03-07 08:25:39 UTC (rev 16104)
@@ -0,0 +1,144 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine;
+
+import java.util.Set;
+import javax.validation.BeanDescriptor;
+import javax.validation.ConstraintDescriptor;
+import javax.validation.ElementDescriptor;
+import javax.validation.PropertyDescriptor;
+import javax.validation.Validator;
+
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+import org.hibernate.validation.eg.Account;
+import org.hibernate.validation.eg.Customer;
+import org.hibernate.validation.eg.Order;
+import org.hibernate.validation.eg.UnconstraintEntity;
+import org.hibernate.validation.util.TestUtil;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class BeanDescriptorImplTest {
+
+ @Test
+ public void testHasConstraintsAndIsBeanConstrained() {
+ Validator validator = TestUtil.getValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
+
+ assertFalse( "There should be no direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
+ assertTrue( "Bean should be constrainted due to @valid ", beanDescriptor.isBeanConstrained() );
+
+ beanDescriptor = validator.getConstraintsForClass( Account.class );
+ assertTrue(
+ "Bean should be constrainted due to @valid", beanDescriptor.isBeanConstrained()
+ );
+ }
+
+ @Test
+ public void testUnconstraintClass() {
+ Validator validator = TestUtil.getValidator();
+ assertFalse(
+ "There should be no constraints",
+ validator.getConstraintsForClass( UnconstraintEntity.class ).hasConstraints()
+ );
+ }
+
+ @Test
+ public void testGetConstraintsForProperty() {
+ Validator validator = TestUtil.getValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
+ assertEquals(
+ "There should be one constraint descriptor", 1, propertyDescriptor.getConstraintDescriptors().size()
+ );
+
+ assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( "foobar" ) );
+
+ beanDescriptor = validator.getConstraintsForClass( Customer.class );
+ propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
+ assertEquals(
+ "There should be no constraint descriptors", 0, propertyDescriptor.getConstraintDescriptors().size()
+ );
+ assertTrue( "The property should be cascaded", propertyDescriptor.isCascaded() );
+ }
+
+ /**
+ * HV-95
+ */
+ @Test
+ public void testGetConstrainedProperties() {
+ Validator validator = TestUtil.getValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ Set<String> constraintProperties = beanDescriptor.getConstrainedProperties();
+ assertEquals( "There should be only one property", 1, constraintProperties.size() );
+ assertTrue( "Wrong property", constraintProperties.contains( "orderNumber" ) );
+
+ try {
+ constraintProperties.add( "foobar" );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+
+ }
+
+ try {
+ constraintProperties.remove( "orderNumber" );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+
+ }
+ }
+
+ /**
+ * HV-95
+ */
+ @Test
+ public void testElementDescriptorImmutable() {
+ Validator validator = TestUtil.getValidator();
+ ElementDescriptor elementDescriptor = validator.getConstraintsForClass( Order.class )
+ .getConstraintsForProperty( "orderNumber" );
+ Set<ConstraintDescriptor<?>> constraintDescriptors = elementDescriptor.getConstraintDescriptors();
+ assertTrue( "There should be a ConstraintDescriptor", constraintDescriptors.size() == 1 );
+ ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
+
+ try {
+ constraintDescriptors.add( descriptor );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+
+ }
+
+ try {
+ constraintDescriptors.remove( descriptor );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+
+ }
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-03-06 22:29:35 UTC (rev 16103)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-03-07 08:25:39 UTC (rev 16104)
@@ -39,7 +39,6 @@
import org.hibernate.validation.eg.Engine;
import org.hibernate.validation.eg.Order;
import org.hibernate.validation.eg.Person;
-import org.hibernate.validation.eg.UnconstraintEntity;
import org.hibernate.validation.eg.groups.First;
import org.hibernate.validation.eg.groups.Last;
import org.hibernate.validation.eg.groups.Second;
@@ -59,7 +58,8 @@
@Test
public void testWrongMethodName() {
try {
- TestUtil.getValidator().getConstraintsForClass( Boy.class ).hasConstraints();
+ Boy boy = new Boy();
+ TestUtil.getValidator().validate( boy );
fail();
}
catch ( ValidationException e ) {
@@ -76,28 +76,6 @@
TestUtil.getValidator().getConstraintsForClass( null );
}
- @Test
- public void testUnconstraintClass() {
- Validator validator = TestUtil.getValidator();
- assertTrue(
- "There should be no constraints",
- !validator.getConstraintsForClass( UnconstraintEntity.class ).hasConstraints()
- );
- }
-
- @Test
- public void testHasConstraintsAndIsBeanConstrained() {
- Validator validator = TestUtil.getValidator();
- assertTrue(
- "There should not be constraints", !validator.getConstraintsForClass( Customer.class ).hasConstraints()
- );
- assertTrue(
- "It should be constrainted", validator.getConstraintsForClass( Customer.class ).isBeanConstrained()
- );
- // TODO fix test
-// assertTrue( "It should be constrainted even if it has no constraint annotations - not implemented yet", validator.getConstraintsForClass( Account.class ).isBeanConstrained() );
- }
-
@Test(expected = IllegalArgumentException.class)
public void testValidateWithNull() {
Validator validator = TestUtil.getValidator();
@@ -433,6 +411,25 @@
assertEquals( "Wrong number of constraints", 0, constraintViolations.size() );
}
+ @Test
+ public void testObjectTraversion() {
+ Validator validator = TestUtil.getValidator();
+
+ Customer customer = new Customer();
+ customer.setFirstName( "John" );
+ customer.setLastName( "Doe" );
+
+ for ( int i = 0; i < 100; i++ ) {
+ Order order = new Order();
+ customer.addOrder( order );
+ }
+
+ Set<ConstraintViolation<Customer>> constraintViolations = validator.validate(
+ customer, Default.class, First.class, Second.class, Last.class
+ );
+ assertEquals( "Wrong number of constraints", 100, constraintViolations.size() );
+ }
+
/**
* HV-120
*/
@@ -445,7 +442,7 @@
Set<ConstraintDescriptor<?>> descriptors = propertyDescriptor.getConstraintDescriptors();
assertEquals( "There should be only one constraint descriptor", 1, descriptors.size() );
- ConstraintDescriptor descriptor = descriptors.iterator().next();
+ ConstraintDescriptor<?> descriptor = descriptors.iterator().next();
Set<Class<?>> groups = descriptor.getGroups();
assertTrue( "There should be only one group", groups.size() == 1 );
assertEquals(
@@ -454,23 +451,4 @@
groups.iterator().next()
);
}
-
- @Test
- public void testObjectTraversion() {
- Validator validator = TestUtil.getValidator();
-
- Customer customer = new Customer();
- customer.setFirstName( "John" );
- customer.setLastName( "Doe" );
-
- for ( int i = 0; i < 100; i++ ) {
- Order order = new Order();
- customer.addOrder( order );
- }
-
- Set<ConstraintViolation<Customer>> constraintViolations = validator.validate(
- customer, Default.class, First.class, Second.class, Last.class
- );
- assertEquals( "Wrong number of constraints", 100, constraintViolations.size() );
- }
}
15 years, 9 months
Hibernate SVN: r16103 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-06 17:29:35 -0500 (Fri, 06 Mar 2009)
New Revision: 16103
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
Log:
HV-95
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-06 22:23:09 UTC (rev 16102)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-06 22:29:35 UTC (rev 16103)
@@ -151,7 +151,7 @@
* {@inheritDoc}
*/
public Set<Class<?>> getGroups() {
- return groups;
+ return Collections.unmodifiableSet( groups );
}
/**
@@ -165,14 +165,14 @@
* {@inheritDoc}
*/
public Map<String, Object> getParameters() {
- return parameters;
+ return Collections.unmodifiableMap(parameters);
}
/**
* {@inheritDoc}
*/
public Set<ConstraintDescriptor<?>> getComposingConstraints() {
- return composingConstraints;
+ return Collections.unmodifiableSet(composingConstraints);
}
/**
15 years, 9 months
Hibernate SVN: r16102 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-06 17:23:09 -0500 (Fri, 06 Mar 2009)
New Revision: 16102
Added:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/PropertyDescriptorImpl.java
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/PropertyDescriptor.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
Log:
HV-84 Introduced a proper implementation for PropertyDescriptor and refactored code.
Also made some javadoc changes to the api.
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java 2009-03-06 20:34:24 UTC (rev 16101)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java 2009-03-06 22:23:09 UTC (rev 16102)
@@ -21,18 +21,19 @@
/**
* Describe a constrained Java Bean and the constraints associated to it.
- *
+ *
* @author Emmanuel Bernard
*/
public interface BeanDescriptor extends ElementDescriptor {
/**
* Returns true if the bean involves validation:
- * - a constraint is hosted on the bean itself
- * - a constraint is hosted on one of the bean properties
- * - or a bean property is marked for cascade (@Valid)
+ * <ul>
+ * <li> a constraint is hosted on the bean itself </li>
+ * <li> a constraint is hosted on one of the bean properties </li>
+ * <li> or a bean property is marked for cascade (@Valid) </li>
+ * </ul>
*
- * @return true if the bean nvolves validation
- *
+ * @return <code>true</code> if the bean involves validation, <code>false</code> otherwise.
*/
boolean isBeanConstrained();
@@ -40,17 +41,19 @@
* Return the property descriptor for a given property.
* Return null if the property does not exist or has no
* constraint nor is marked as cascaded (see {@link #getConstrainedProperties()} )
- *
+ * <p/>
* The returned object (and associated objects including ConstraintDescriptors)
- * are immutable.
+ * are immutable.
*
* @param propertyName property evaludated
+ *
+ * @return the property descriptor for a given property.
*/
PropertyDescriptor getConstraintsForProperty(String propertyName);
/**
- * return the property names having at least a constraint defined or marked
- * as cascaded (@Valid)
+ * @return the property names having at least one constraint defined or which are marked
+ * as cascaded (@Valid).
*/
Set<String> getConstrainedProperties();
}
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java 2009-03-06 20:34:24 UTC (rev 16101)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java 2009-03-06 22:23:09 UTC (rev 16102)
@@ -28,7 +28,7 @@
public interface ElementDescriptor {
/**
- * return true if at least one constraint declaration is present on the element.
+ * @return <code>true</code> if at least one constraint declaration is present on the element, <code>false</code> otherwise.
*/
boolean hasConstraints();
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/PropertyDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/PropertyDescriptor.java 2009-03-06 20:34:24 UTC (rev 16101)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/PropertyDescriptor.java 2009-03-06 22:23:09 UTC (rev 16102)
@@ -11,13 +11,13 @@
public interface PropertyDescriptor extends ElementDescriptor {
/**
* Is the property marked by the <code>@Valid</code> annotation.
- * @return true if the annotation is present
+ * @return <code>true</code> if the annotation is present, <code>false</code> otherwise.
*/
boolean isCascaded();
/**
* Name of the property acording to the Java Bean specification.
- * @return property name
+ * @return property name.
*/
String getPropertyName();
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java 2009-03-06 20:34:24 UTC (rev 16101)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java 2009-03-06 22:23:09 UTC (rev 16102)
@@ -1,33 +1,30 @@
package org.hibernate.validation.engine;
-import java.util.Collections;
import java.util.Set;
import javax.validation.BeanDescriptor;
import javax.validation.PropertyDescriptor;
/**
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
public class BeanDescriptorImpl<T> extends ElementDescriptorImpl implements BeanDescriptor {
private final BeanMetaData<T> metadataBean;
public BeanDescriptorImpl(Class<T> returnType, BeanMetaData<T> metadataBean) {
- super(returnType, false, "");
+ super( returnType );
this.metadataBean = metadataBean;
}
- /**
- * @todo add child validation
- */
public boolean isBeanConstrained() {
- return metadataBean.geMetaConstraintList().size() > 0;
+ return metadataBean.getConstrainedProperties().size() > 0;
}
public PropertyDescriptor getConstraintsForProperty(String propertyName) {
- return metadataBean.getPropertyDescriptors().get( propertyName );
+ return metadataBean.getPropertyDescriptor( propertyName );
}
public Set<String> getConstrainedProperties() {
- return Collections.unmodifiableSet( metadataBean.getPropertyDescriptors().keySet() );
+ return metadataBean.getConstrainedProperties();
}
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java 2009-03-06 20:34:24 UTC (rev 16101)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java 2009-03-06 22:23:09 UTC (rev 16102)
@@ -21,9 +21,8 @@
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.List;
-import java.util.Map;
+import java.util.Set;
import javax.validation.BeanDescriptor;
-import javax.validation.ElementDescriptor;
import javax.validation.PropertyDescriptor;
/**
@@ -70,12 +69,18 @@
List<MetaConstraint<T, ?>> geMetaConstraintList();
/**
- * @return A map keying the property name of a constraint to its <code>ElementDescriptor</code>.
+ * Return <code>PropertyDescriptor</code> for the given property.
*
- * @todo Maybe needs to be removed since this data structure is ambigious. There could be conflicts between field and
- * methods.
+ * @param property the property for which to retrieve the descriptor.
+ *
+ * @return Returns the <code>PropertyDescriptor</code> for the given property or <code>null</code> in case the
+ * property does not have a descriptor.
*/
- Map<String, PropertyDescriptor> getPropertyDescriptors();
+ PropertyDescriptor getPropertyDescriptor(String property);
- ElementDescriptor getPropertyDescriptors(String property);
+ /**
+ * @return the property names having at least one constraint defined or which are marked
+ * as cascaded (@Valid).
+ */
+ Set<String> getConstrainedProperties();
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-03-06 20:34:24 UTC (rev 16101)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-03-06 22:23:09 UTC (rev 16102)
@@ -18,14 +18,17 @@
package org.hibernate.validation.engine;
import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.validation.BeanDescriptor;
import javax.validation.GroupSequence;
import javax.validation.PropertyDescriptor;
@@ -155,7 +158,7 @@
defaultGroupSequence.add( Default.class );
}
else if ( group.getName().equals( Default.class.getName() ) ) {
- throw new ValidationException( "'Default.class' cannot appear in default group sequence list." );
+ throw new ValidationException( "'Default.class' cannot appear in default group sequence list." );
}
else {
defaultGroupSequence.add( group );
@@ -171,17 +174,21 @@
}
}
- private <A extends Annotation >void initFieldConstraints(Class clazz) {
+ private <A extends Annotation> void initFieldConstraints(Class clazz) {
for ( Field field : clazz.getDeclaredFields() ) {
List<ConstraintDescriptorImpl> fieldMetadata = findFieldLevelConstraints( field );
for ( ConstraintDescriptorImpl constraintDescription : fieldMetadata ) {
ReflectionHelper.setAccessibility( field );
- MetaConstraint<T, A> metaConstraint = new MetaConstraint<T, A>( field, beanClass, constraintDescription );
+ MetaConstraint<T, A> metaConstraint = new MetaConstraint<T, A>(
+ field, beanClass, constraintDescription
+ );
metaConstraintList.add( metaConstraint );
}
if ( field.isAnnotationPresent( Valid.class ) ) {
ReflectionHelper.setAccessibility( field );
+ String name = field.getName();
cascadedFields.add( field );
+ addPropertyDescriptorForMember( field );
}
}
}
@@ -191,16 +198,35 @@
List<ConstraintDescriptorImpl> methodMetadata = findMethodLevelConstraints( method );
for ( ConstraintDescriptorImpl constraintDescription : methodMetadata ) {
ReflectionHelper.setAccessibility( method );
- MetaConstraint<T, A> metaConstraint = new MetaConstraint<T, A>( method, beanClass, constraintDescription );
+ MetaConstraint<T, A> metaConstraint = new MetaConstraint<T, A>(
+ method, beanClass, constraintDescription
+ );
metaConstraintList.add( metaConstraint );
}
if ( method.isAnnotationPresent( Valid.class ) ) {
ReflectionHelper.setAccessibility( method );
cascadedMethods.add( method );
+ addPropertyDescriptorForMember( method );
}
}
}
+ private PropertyDescriptorImpl addPropertyDescriptorForMember(Member member) {
+ String name = ReflectionHelper.getPropertyName( member );
+ PropertyDescriptorImpl propertyDescriptor = ( PropertyDescriptorImpl ) propertyDescriptors.get(
+ name
+ );
+ if ( propertyDescriptor == null ) {
+ propertyDescriptor = new PropertyDescriptorImpl(
+ ReflectionHelper.getType( member ),
+ ( ( AnnotatedElement ) member ).isAnnotationPresent( Valid.class ),
+ name
+ );
+ propertyDescriptors.put( name, propertyDescriptor );
+ }
+ return propertyDescriptor;
+ }
+
private <A extends Annotation> void initClassConstraints(Class clazz) {
List<ConstraintDescriptorImpl> classMetadata = findClassLevelConstraints( clazz );
for ( ConstraintDescriptorImpl constraintDescription : classMetadata ) {
@@ -282,16 +308,11 @@
"Annotated methods must follow the JavaBeans naming convention. " + method.getName() + "() does not."
);
}
- ElementDescriptorImpl elementDescriptor = ( ElementDescriptorImpl ) propertyDescriptors.get( methodName );
- if ( elementDescriptor == null ) {
- elementDescriptor = new ElementDescriptorImpl(
- method.getReturnType(),
- method.isAnnotationPresent( Valid.class ),
- methodName
- );
- propertyDescriptors.put( methodName, elementDescriptor );
+ PropertyDescriptorImpl propertyDescriptor = ( PropertyDescriptorImpl ) propertyDescriptors.get( methodName );
+ if ( propertyDescriptor == null ) {
+ propertyDescriptor = addPropertyDescriptorForMember( method );
}
- elementDescriptor.addConstraintDescriptor( constraintDescriptor );
+ propertyDescriptor.addConstraintDescriptor( constraintDescriptor );
}
return metadata;
}
@@ -312,16 +333,11 @@
String fieldName = field.getName();
for ( ConstraintDescriptorImpl constraintDescriptor : metadata ) {
- ElementDescriptorImpl elementDescriptor = ( ElementDescriptorImpl ) propertyDescriptors.get( fieldName );
- if ( elementDescriptor == null ) {
- elementDescriptor = new ElementDescriptorImpl(
- field.getType(),
- field.isAnnotationPresent( Valid.class ),
- fieldName
- );
- propertyDescriptors.put( field.getName(), elementDescriptor );
+ PropertyDescriptorImpl propertyDescriptor = ( PropertyDescriptorImpl ) propertyDescriptors.get( fieldName );
+ if ( propertyDescriptor == null ) {
+ propertyDescriptor = addPropertyDescriptorForMember( field );
}
- elementDescriptor.addConstraintDescriptor( constraintDescriptor );
+ propertyDescriptor.addConstraintDescriptor( constraintDescriptor );
}
return metadata;
}
@@ -353,15 +369,15 @@
return metaConstraintList;
}
- public Map<String, PropertyDescriptor> getPropertyDescriptors() {
- return propertyDescriptors;
- }
-
- public PropertyDescriptor getPropertyDescriptors(String property) {
+ public PropertyDescriptor getPropertyDescriptor(String property) {
return propertyDescriptors.get( property );
}
public List<Class<?>> getDefaultGroupSequence() {
return defaultGroupSequence;
}
+
+ public Set<String> getConstrainedProperties() {
+ return Collections.unmodifiableSet( propertyDescriptors.keySet() );
+ }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java 2009-03-06 20:34:24 UTC (rev 16101)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java 2009-03-06 22:23:09 UTC (rev 16102)
@@ -21,28 +21,20 @@
import java.util.HashSet;
import java.util.Set;
import javax.validation.ConstraintDescriptor;
-import javax.validation.PropertyDescriptor;
+import javax.validation.ElementDescriptor;
/**
* Describe a validated element (class, field or property).
*
* @author Emmanuel Bernard
* @author Hardy Ferentschik
- * @todo Should returnType be renamed to type?
- * @todo Handle problem in descirbing cyclic dependecies for propertyPath
*/
-//FIXME I implement both interfaces on the same object as a quick hack, we need to fix that.
-public class ElementDescriptorImpl implements PropertyDescriptor {
- private final Class<?> returnType;
- private final boolean cascaded;
+public class ElementDescriptorImpl implements ElementDescriptor {
+ private final Class<?> type;
private final Set<ConstraintDescriptor<?>> constraintDescriptors = new HashSet<ConstraintDescriptor<?>>();
- private final String propertyPath;
-
- public ElementDescriptorImpl(Class<?> returnType, boolean cascaded, String propertyPath) {
- this.returnType = returnType;
- this.cascaded = cascaded;
- this.propertyPath = propertyPath;
+ public ElementDescriptorImpl(Class<?> type) {
+ this.type = type;
}
public void addConstraintDescriptor(ConstraintDescriptorImpl constraintDescriptor) {
@@ -55,31 +47,15 @@
/**
* {@inheritDoc}
- *
- * @todo Generic type or regular type?
*/
- public Class getType() {
- return returnType;
+ public Class<?> getType() {
+ return type;
}
/**
* {@inheritDoc}
*/
- public boolean isCascaded() {
- return cascaded;
- }
-
- /**
- * {@inheritDoc}
- */
public Set<ConstraintDescriptor<?>> getConstraintDescriptors() {
return Collections.unmodifiableSet( constraintDescriptors );
}
-
- /**
- * {@inheritDoc}
- */
- public String getPropertyName() {
- return propertyPath;
- }
}
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/PropertyDescriptorImpl.java (from rev 16096, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/PropertyDescriptorImpl.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/PropertyDescriptorImpl.java 2009-03-06 22:23:09 UTC (rev 16102)
@@ -0,0 +1,52 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine;
+
+import javax.validation.PropertyDescriptor;
+
+/**
+ * Describe a validated element (class, field or property).
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public class PropertyDescriptorImpl extends ElementDescriptorImpl implements PropertyDescriptor {
+ private final boolean cascaded;
+ private final String property;
+
+
+ public PropertyDescriptorImpl(Class<?> returnType, boolean cascaded, String property) {
+ super( returnType );
+ this.cascaded = cascaded;
+ this.property = property;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isCascaded() {
+ return cascaded;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getPropertyName() {
+ return property;
+ }
+}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java 2009-03-06 20:34:24 UTC (rev 16101)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java 2009-03-06 22:23:09 UTC (rev 16102)
@@ -122,6 +122,26 @@
}
/**
+ * Returns the type of the field of return type of a method.
+ *
+ * @param member the member for which to get the type.
+ *
+ * @return Returns the type of the field of return type of a method.
+ */
+ public static Class<?> getType(Member member) {
+
+ Class<?> type = null;
+ if ( member instanceof Field ) {
+ type = ( ( Field ) member ).getType();
+ }
+
+ if ( member instanceof Method ) {
+ type = ( ( Method ) member ).getReturnType();
+ }
+ return type;
+ }
+
+ /**
* @param member The <code>Member</code> instance for which to retrieve the type.
*
* @return Retrurns the <code>Type</code> of the given <code>Field</code> or <code>Method</code>.
15 years, 9 months
Hibernate SVN: r16101 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validation/constraints and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-06 15:34:24 -0500 (Fri, 06 Mar 2009)
New Revision: 16101
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForNumber.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForString.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArray.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForCollection.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForMap.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForString.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java
Log:
HV-119 Added exception cases and tests
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForNumber.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForNumber.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForNumber.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -20,6 +20,7 @@
import java.math.BigDecimal;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
import javax.validation.constraints.Digits;
/**
@@ -28,7 +29,6 @@
*
* @author Alaa Nassef
* @author Hardy Ferentschik
- * @todo Implement exception handling in initalize once exception behaviour is specified BVAL-117
*/
public class DigitsValidatorForNumber implements ConstraintValidator<Digits, Number> {
@@ -38,6 +38,7 @@
public void initialize(Digits constraintAnnotation) {
this.maxIntegerLength = constraintAnnotation.integer();
this.maxFractionLength = constraintAnnotation.fraction();
+ validateParameters();
}
public boolean isValid(Number num, ConstraintValidatorContext constraintValidatorContext) {
@@ -50,13 +51,22 @@
if ( num instanceof BigDecimal ) {
bigNum = ( BigDecimal ) num;
}
- else {
+ else {
bigNum = new BigDecimal( num.toString() );
}
int integerPartLength = bigNum.precision() - bigNum.scale();
- int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale() ;
+ int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();
return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
}
+
+ private void validateParameters() {
+ if ( maxIntegerLength < 0 ) {
+ throw new ValidationException( "The length of the interger part cannot be negative." );
+ }
+ if ( maxFractionLength < 0 ) {
+ throw new ValidationException( "The length of the fraction part cannot be negative." );
+ }
+ }
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForString.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForString.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForString.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -20,6 +20,7 @@
import java.math.BigDecimal;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
import javax.validation.constraints.Digits;
/**
@@ -28,7 +29,6 @@
*
* @author Alaa Nassef
* @author Hardy Ferentschik
- *
*/
public class DigitsValidatorForString implements ConstraintValidator<Digits, String> {
@@ -38,6 +38,7 @@
public void initialize(Digits constraintAnnotation) {
this.maxIntegerLength = constraintAnnotation.integer();
this.maxFractionLength = constraintAnnotation.fraction();
+ validateParameters();
}
public boolean isValid(String str, ConstraintValidatorContext constraintValidatorContext) {
@@ -52,7 +53,7 @@
}
int integerPartLength = bigNum.precision() - bigNum.scale();
- int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale() ;
+ int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();
return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
}
@@ -67,4 +68,13 @@
}
return bd;
}
+
+ private void validateParameters() {
+ if ( maxIntegerLength < 0 ) {
+ throw new ValidationException( "The length of the interger part cannot be negative." );
+ }
+ if ( maxFractionLength < 0 ) {
+ throw new ValidationException( "The length of the fraction part cannot be negative." );
+ }
+ }
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthValidator.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthValidator.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -19,6 +19,7 @@
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
/**
* Check that a string's length is between min and max.
@@ -33,6 +34,7 @@
public void initialize(Length parameters) {
min = parameters.min();
max = parameters.max();
+ validateParameters();
}
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
@@ -43,4 +45,15 @@
return length >= min && length <= max;
}
+ private void validateParameters() {
+ if ( min < 0 ) {
+ throw new ValidationException( "The min parameter cannot be negative." );
+ }
+ if ( max < 0 ) {
+ throw new ValidationException( "The max paramter cannot be negative." );
+ }
+ if ( max < min ) {
+ throw new ValidationException( "The length cannot be negative." );
+ }
+ }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternValidator.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternValidator.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -18,8 +18,10 @@
package org.hibernate.validation.constraints;
import java.util.regex.Matcher;
+import java.util.regex.PatternSyntaxException;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
import javax.validation.constraints.Pattern;
/**
@@ -31,16 +33,17 @@
public void initialize(Pattern parameters) {
Pattern.Flag flags[] = parameters.flags();
- if ( flags.length == 0 ) {
- pattern = java.util.regex.Pattern.compile( parameters.regexp() );
+ int intFlag = 0;
+ for ( Pattern.Flag flag : flags ) {
+ intFlag = intFlag | mapFlagToInt( flag );
}
- else {
- int intFlag = 0;
- for ( Pattern.Flag flag : flags ) {
- intFlag = intFlag | mapFlagToInt( flag );
- }
+
+ try {
pattern = java.util.regex.Pattern.compile( parameters.regexp(), intFlag );
}
+ catch ( PatternSyntaxException e ) {
+ throw new ValidationException( "Invalid regular expression.", e );
+ }
}
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArray.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArray.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArray.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -20,6 +20,7 @@
import java.lang.reflect.Array;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
import javax.validation.constraints.Size;
/**
@@ -34,6 +35,7 @@
public void initialize(Size parameters) {
min = parameters.min();
max = parameters.max();
+ validateParameters();
}
/**
@@ -53,4 +55,16 @@
int length = Array.getLength( array );
return length >= min && length <= max;
}
+
+ private void validateParameters() {
+ if ( min < 0 ) {
+ throw new ValidationException( "The min parameter cannot be negative." );
+ }
+ if ( max < 0 ) {
+ throw new ValidationException( "The max paramter cannot be negative." );
+ }
+ if ( max < min ) {
+ throw new ValidationException( "The length cannot be negative." );
+ }
+ }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForCollection.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForCollection.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForCollection.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -20,6 +20,7 @@
import java.util.Collection;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
import javax.validation.constraints.Size;
/**
@@ -34,6 +35,7 @@
public void initialize(Size parameters) {
min = parameters.min();
max = parameters.max();
+ validateParameters();
}
/**
@@ -53,4 +55,16 @@
int length = collection.size();
return length >= min && length <= max;
}
+
+ private void validateParameters() {
+ if ( min < 0 ) {
+ throw new ValidationException( "The min parameter cannot be negative." );
+ }
+ if ( max < 0 ) {
+ throw new ValidationException( "The max paramter cannot be negative." );
+ }
+ if ( max < min ) {
+ throw new ValidationException( "The length cannot be negative." );
+ }
+ }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForMap.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForMap.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForMap.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -20,6 +20,7 @@
import java.util.Map;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
import javax.validation.constraints.Size;
/**
@@ -34,6 +35,7 @@
public void initialize(Size parameters) {
min = parameters.min();
max = parameters.max();
+ validateParameters();
}
/**
@@ -53,4 +55,16 @@
int size = map.size();
return size >= min && size <= max;
}
+
+ private void validateParameters() {
+ if ( min < 0 ) {
+ throw new ValidationException( "The min parameter cannot be negative." );
+ }
+ if ( max < 0 ) {
+ throw new ValidationException( "The max paramter cannot be negative." );
+ }
+ if ( max < min ) {
+ throw new ValidationException( "The length cannot be negative." );
+ }
+ }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForString.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForString.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForString.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -19,6 +19,7 @@
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
import javax.validation.constraints.Size;
/**
@@ -35,6 +36,7 @@
public void initialize(Size parameters) {
min = parameters.min();
max = parameters.max();
+ validateParameters();
}
/**
@@ -53,4 +55,16 @@
int length = s.length();
return length >= min && length <= max;
}
+
+ private void validateParameters() {
+ if ( min < 0 ) {
+ throw new ValidationException( "The min parameter cannot be negative." );
+ }
+ if ( max < 0 ) {
+ throw new ValidationException( "The max paramter cannot be negative." );
+ }
+ if ( max < min ) {
+ throw new ValidationException( "The length cannot be negative." );
+ }
+ }
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -18,6 +18,7 @@
package org.hibernate.validation.constraints;
import java.math.BigDecimal;
+import javax.validation.ValidationException;
import javax.validation.constraints.Digits;
import static org.junit.Assert.assertFalse;
@@ -36,7 +37,7 @@
@Test
public void testIsValid() {
- AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor( Digits.class );
+ AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
descriptor.setValue( "integer", 5 );
descriptor.setValue( "fraction", 2 );
descriptor.setValue( "message", "{validator.digits}" );
@@ -64,7 +65,7 @@
@Test
public void testIsValidZeroLength() {
- AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor( Digits.class );
+ AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
descriptor.setValue( "integer", 0 );
descriptor.setValue( "fraction", 0 );
descriptor.setValue( "message", "{validator.digits}" );
@@ -79,4 +80,29 @@
assertFalse( constraint.isValid( Double.valueOf( "500.2" ), null ) );
}
+ @Test(expected = ValidationException.class)
+ public void testNegativeIntegerLength() {
+
+ AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+ descriptor.setValue( "integer", -1 );
+ descriptor.setValue( "fraction", 1 );
+ descriptor.setValue( "message", "{validator.digits}" );
+ Digits p = AnnotationFactory.create( descriptor );
+
+ DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
+ constraint.initialize( p );
+ }
+
+ @Test(expected = ValidationException.class)
+ public void testNegativeFractionLength() {
+
+ AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+ descriptor.setValue( "integer", 1 );
+ descriptor.setValue( "fraction", -1 );
+ descriptor.setValue( "message", "{validator.digits}" );
+ Digits p = AnnotationFactory.create( descriptor );
+
+ DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
+ constraint.initialize( p );
+ }
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -17,6 +17,7 @@
*/
package org.hibernate.validation.constraints;
+import javax.validation.ValidationException;
import javax.validation.constraints.Digits;
import static org.junit.Assert.assertFalse;
@@ -37,7 +38,7 @@
@BeforeClass
public static void init() {
- AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor( Digits.class );
+ AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
descriptor.setValue( "integer", 5 );
descriptor.setValue( "fraction", 2 );
descriptor.setValue( "message", "{validator.digits}" );
@@ -60,4 +61,30 @@
assertFalse( constraint.isValid( "256874.0", null ) );
assertFalse( constraint.isValid( "12.0001", null ) );
}
+
+ @Test(expected = ValidationException.class)
+ public void testNegativeIntegerLength() {
+
+ AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+ descriptor.setValue( "integer", -1 );
+ descriptor.setValue( "fraction", 1 );
+ descriptor.setValue( "message", "{validator.digits}" );
+ Digits p = AnnotationFactory.create( descriptor );
+
+ DigitsValidatorForString constraint = new DigitsValidatorForString();
+ constraint.initialize( p );
+ }
+
+ @Test(expected = ValidationException.class)
+ public void testNegativeFractionLength() {
+
+ AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+ descriptor.setValue( "integer", 1 );
+ descriptor.setValue( "fraction", -1 );
+ descriptor.setValue( "message", "{validator.digits}" );
+ Digits p = AnnotationFactory.create( descriptor );
+
+ DigitsValidatorForString constraint = new DigitsValidatorForString();
+ constraint.initialize( p );
+ }
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -17,9 +17,10 @@
*/
package org.hibernate.validation.constraints;
+import javax.validation.ValidationException;
+
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
@@ -32,22 +33,15 @@
*/
public class LengthValidatorTest {
- private static LengthValidator constraint;
-
- @BeforeClass
- public static void init() {
+ @Test
+ public void testIsValid() {
AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
descriptor.setValue( "min", 1 );
descriptor.setValue( "max", 3 );
descriptor.setValue( "message", "{validator.length}" );
Length l = AnnotationFactory.create( descriptor );
- constraint = new LengthValidator();
+ LengthValidator constraint = new LengthValidator();
constraint.initialize( l );
- }
-
- @Test
- public void testIsValid() {
-
assertTrue( constraint.isValid( null, null ) );
assertFalse( constraint.isValid( "", null ) );
assertTrue( constraint.isValid( "f", null ) );
@@ -55,4 +49,40 @@
assertTrue( constraint.isValid( "foo", null ) );
assertFalse( constraint.isValid( "foobar", null ) );
}
+
+ @Test(expected = ValidationException.class)
+ public void testNegativeMinValue() {
+ AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
+ descriptor.setValue( "min", -1 );
+ descriptor.setValue( "max", 1 );
+ descriptor.setValue( "message", "{validator.length}" );
+ Length p = AnnotationFactory.create( descriptor );
+
+ LengthValidator constraint = new LengthValidator();
+ constraint.initialize( p );
+ }
+
+ @Test(expected = ValidationException.class)
+ public void testNegativeMaxValue() {
+ AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
+ descriptor.setValue( "min", 1 );
+ descriptor.setValue( "max", -1 );
+ descriptor.setValue( "message", "{validator.length}" );
+ Length p = AnnotationFactory.create( descriptor );
+
+ LengthValidator constraint = new LengthValidator();
+ constraint.initialize( p );
+ }
+
+ @Test(expected = ValidationException.class)
+ public void testNegativeLength() {
+ AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
+ descriptor.setValue( "min", 5 );
+ descriptor.setValue( "max", 4 );
+ descriptor.setValue( "message", "{validator.length}" );
+ Length p = AnnotationFactory.create( descriptor );
+
+ LengthValidator constraint = new LengthValidator();
+ constraint.initialize( p );
+ }
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -21,9 +21,8 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
import org.junit.BeforeClass;
+import org.junit.Test;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
@@ -37,7 +36,7 @@
@BeforeClass
public static void init() {
- AnnotationDescriptor<Max> descriptor = new AnnotationDescriptor( Max.class );
+ AnnotationDescriptor<Max> descriptor = new AnnotationDescriptor<Max>( Max.class );
descriptor.setValue( "value", 15l );
descriptor.setValue( "message", "{validator.max}" );
Max m = AnnotationFactory.create( descriptor );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -36,7 +36,7 @@
@BeforeClass
public static void init() {
- AnnotationDescriptor<Min> descriptor = new AnnotationDescriptor( Min.class );
+ AnnotationDescriptor<Min> descriptor = new AnnotationDescriptor<Min>( Min.class );
descriptor.setValue( "value", 15l );
descriptor.setValue( "message", "{validator.min}" );
Min m = AnnotationFactory.create( descriptor );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java 2009-03-06 18:42:49 UTC (rev 16100)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java 2009-03-06 20:34:24 UTC (rev 16101)
@@ -17,11 +17,11 @@
*/
package org.hibernate.validation.constraints;
+import javax.validation.ValidationException;
import javax.validation.constraints.Pattern;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
@@ -32,26 +32,31 @@
*/
public class PatternValidatorTest {
- private static PatternValidator constraint;
-
- @BeforeClass
- public static void init() {
-
- AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor( Pattern.class );
+ @Test
+ public void testIsValid() {
+ AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
descriptor.setValue( "regexp", "foobar" );
descriptor.setValue( "message", "{validator.pattern}" );
Pattern p = AnnotationFactory.create( descriptor );
- constraint = new PatternValidator();
+ PatternValidator constraint = new PatternValidator();
constraint.initialize( p );
- }
- @Test
- public void testIsValid() {
assertTrue( constraint.isValid( null, null ) );
assertFalse( constraint.isValid( "", null ) );
assertFalse( constraint.isValid( "bla bla", null ) );
assertFalse( constraint.isValid( "This test is not foobar", null ) );
}
+
+ @Test(expected = ValidationException.class)
+ public void testInvalidRegularExpression() {
+ AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
+ descriptor.setValue( "regexp", "(unbalanced parentheses" );
+ descriptor.setValue( "message", "{validator.pattern}" );
+ Pattern p = AnnotationFactory.create( descriptor );
+
+ PatternValidator constraint = new PatternValidator();
+ constraint.initialize( p );
+ }
}
15 years, 9 months
Hibernate SVN: r16100 - in core/trunk: documentation/manual/src/main/docbook/en-US/content and 11 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-03-06 13:42:49 -0500 (Fri, 06 Mar 2009)
New Revision: 16100
Modified:
core/trunk/core/src/main/java/org/hibernate/sql/OracleJoinFragment.java
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml
core/trunk/etc/hibernate.properties
core/trunk/testsuite/src/test/java/org/hibernate/test/cut/CompositeUserTypeTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/dialect/functional/cache/SQLFunctionsInterSystemsTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/generated/ComponentOwner.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/generated/GeneratedPropertyEntity.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/generated/PartiallyGeneratedComponentTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/select/MyEntity.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/IJTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/MasterDetailTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLLoaderTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/rowid/RowIdTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/check/OracleCheckStyleTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/oracle/OracleCustomSQLTest.java
Log:
HHH-3214 - Update unit tests and config files to use non-depracated Oracle dialects
Modified: core/trunk/core/src/main/java/org/hibernate/sql/OracleJoinFragment.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/sql/OracleJoinFragment.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/core/src/main/java/org/hibernate/sql/OracleJoinFragment.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -114,7 +114,7 @@
addLeftOuterJoinCondition( on );
}
else {
- throw new UnsupportedOperationException( "join type not supported by OracleJoinFragment (use Oracle9Dialect)" );
+ throw new UnsupportedOperationException( "join type not supported by OracleJoinFragment (use Oracle9iDialect/Oracle10gDialect)" );
}
}
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2009-03-06 18:42:49 UTC (rev 16100)
@@ -3585,8 +3585,8 @@
...
<database-object>
<definition class="MyTriggerDefinition"/>
- <dialect-scope name="org.hibernate.dialect.Oracle9Dialect"/>
- <dialect-scope name="org.hibernate.dialect.OracleDialect"/>
+ <dialect-scope name="org.hibernate.dialect.Oracle9iDialect"/>
+ <dialect-scope name="org.hibernate.dialect.Oracle10gDialect"/>
</database-object>
</hibernate-mapping>]]></programlisting>
</sect1>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml 2009-03-06 18:42:49 UTC (rev 16100)
@@ -1050,7 +1050,7 @@
other properties listed above. This means that you will not have to specify them manually.
</para>
- <table frame="topbot" id="sql-dialects" revision="2">
+ <table frame="topbot" id="sql-dialects" revision="3">
<title>Hibernate SQL Dialects (<literal>hibernate.dialect</literal>)</title>
<tgroup cols="2">
<!--
@@ -1089,9 +1089,12 @@
<entry>Oracle (any version)</entry> <entry><literal>org.hibernate.dialect.OracleDialect</literal></entry>
</row>
<row>
- <entry>Oracle 9i/10g</entry> <entry><literal>org.hibernate.dialect.Oracle9Dialect</literal></entry>
+ <entry>Oracle 9i</entry> <entry><literal>org.hibernate.dialect.Oracle9iDialect</literal></entry>
</row>
<row>
+ <entry>Oracle 10g</entry> <entry><literal>org.hibernate.dialect.Oracle10gDialect</literal></entry>
+ </row>
+ <row>
<entry>Sybase</entry> <entry><literal>org.hibernate.dialect.SybaseDialect</literal></entry>
</row>
<row>
Modified: core/trunk/etc/hibernate.properties
===================================================================
--- core/trunk/etc/hibernate.properties 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/etc/hibernate.properties 2009-03-06 18:42:49 UTC (rev 16100)
@@ -59,8 +59,9 @@
## Oracle
-#hibernate.dialect org.hibernate.dialect.OracleDialect
-#hibernate.dialect org.hibernate.dialect.Oracle9Dialect
+#hibernate.dialect org.hibernate.dialect.Oracle8iDialect
+#hibernate.dialect org.hibernate.dialect.Oracle9iDialect
+#hibernate.dialect org.hibernate.dialect.Oracle10gDialect
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
#hibernate.connection.username ora
#hibernate.connection.password ora
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/cut/CompositeUserTypeTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/cut/CompositeUserTypeTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/cut/CompositeUserTypeTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -9,7 +9,6 @@
import org.hibernate.Session;
import org.hibernate.dialect.HSQLDialect;
-import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -45,7 +44,7 @@
result = s.createQuery("from Transaction tran where tran.value.amount > 1.0 and tran.value.currency = 'AUD'").list();
assertEquals( result.size(), 1 );
- if ( !(getDialect() instanceof HSQLDialect) && ! (getDialect() instanceof Oracle9Dialect) ) {
+ if ( !(getDialect() instanceof HSQLDialect) ) {
result = s.createQuery("from Transaction txn where txn.value = (1.5, 'AUD')").list();
assertEquals( result.size(), 1 );
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/dialect/functional/cache/SQLFunctionsInterSystemsTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/dialect/functional/cache/SQLFunctionsInterSystemsTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/dialect/functional/cache/SQLFunctionsInterSystemsTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -26,7 +26,6 @@
import org.hibernate.dialect.InterbaseDialect;
import org.hibernate.dialect.MckoiDialect;
import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.dialect.function.SQLFunction;
@@ -176,7 +175,6 @@
}
public void testBroken() throws Exception {
- if (getDialect() instanceof Oracle9Dialect) return;
Session s = openSession();
Transaction t = s.beginTransaction();
Broken b = new Fixed();
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/generated/ComponentOwner.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/generated/ComponentOwner.hbm.xml 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/generated/ComponentOwner.hbm.xml 2009-03-06 18:42:49 UTC (rev 16100)
@@ -31,8 +31,8 @@
<drop>
<![CDATA[DROP TRIGGER t_iu_part_gen_comp]]>
</drop>
- <dialect-scope name="org.hibernate.dialect.Oracle9Dialect"/>
- <dialect-scope name="org.hibernate.dialect.OracleDialect"/>
+ <dialect-scope name="org.hibernate.dialect.Oracle9iDialect"/>
+ <dialect-scope name="org.hibernate.dialect.Oracle10gDialect"/>
</database-object>
</hibernate-mapping>
\ No newline at end of file
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/generated/GeneratedPropertyEntity.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/generated/GeneratedPropertyEntity.hbm.xml 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/generated/GeneratedPropertyEntity.hbm.xml 2009-03-06 18:42:49 UTC (rev 16100)
@@ -35,8 +35,8 @@
<drop>
<![CDATA[DROP TRIGGER t_iu_gen_prop]]>
</drop>
- <dialect-scope name="org.hibernate.dialect.Oracle9Dialect"/>
- <dialect-scope name="org.hibernate.dialect.OracleDialect"/>
+ <dialect-scope name="org.hibernate.dialect.Oracle9iDialect"/>
+ <dialect-scope name="org.hibernate.dialect.Oracle10gDialect"/>
</database-object>
</hibernate-mapping>
\ No newline at end of file
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/generated/PartiallyGeneratedComponentTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/generated/PartiallyGeneratedComponentTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/generated/PartiallyGeneratedComponentTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -5,7 +5,7 @@
import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.Session;
/**
@@ -27,7 +27,7 @@
}
public boolean appliesTo(Dialect dialect) {
- return dialect instanceof Oracle9Dialect;
+ return dialect instanceof Oracle9iDialect;
}
public void testPartialComponentGeneration() {
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -1,12 +1,11 @@
// $Id: TriggerGeneratedValuesWithCachingTest.java 10977 2006-12-12 23:28:04Z steve.ebersole(a)jboss.com $
package org.hibernate.test.generated;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* Implementation of TriggerGeneratedValuesWithoutCachingTest.
@@ -26,7 +25,7 @@
public boolean appliesTo(Dialect dialect) {
// currently have only defined triggers for oracle...
// TODO : add more triggers for dialects which allow mods in triggers...
- return ( dialect instanceof Oracle9Dialect );
+ return ( dialect instanceof Oracle9iDialect );
}
public static Test suite() {
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -4,7 +4,7 @@
import junit.framework.Test;
import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
@@ -25,7 +25,7 @@
public boolean appliesTo(Dialect dialect) {
// currently have only defined triggers for oracle...
// TODO : add more triggers for dialects which allow mods in triggers...
- return ( dialect instanceof Oracle9Dialect );
+ return ( dialect instanceof Oracle9iDialect );
}
public String getCacheConcurrencyStrategy() {
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/select/MyEntity.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/select/MyEntity.hbm.xml 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/select/MyEntity.hbm.xml 2009-03-06 18:42:49 UTC (rev 16100)
@@ -29,8 +29,8 @@
<drop>
<![CDATA[DROP TRIGGER t_i_my_entity]]>
</drop>
- <dialect-scope name="org.hibernate.dialect.Oracle9Dialect"/>
- <dialect-scope name="org.hibernate.dialect.OracleDialect"/>
+ <dialect-scope name="org.hibernate.dialect.Oracle9iDialect"/>
+ <dialect-scope name="org.hibernate.dialect.Oracle10gDialect"/>
</database-object>
</hibernate-mapping>
\ No newline at end of file
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -3,9 +3,8 @@
import junit.framework.Test;
import org.hibernate.Session;
-import org.hibernate.dialect.DataDirectOracle9Dialect;
import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -24,7 +23,7 @@
}
public boolean appliesTo(Dialect dialect) {
- return ( dialect instanceof Oracle9Dialect );
+ return ( dialect instanceof Oracle9iDialect );
}
public static Test suite() {
@@ -32,10 +31,6 @@
}
public void testJDBC3GetGeneratedKeysSupportOnOracle() {
- if ( getDialect() instanceof DataDirectOracle9Dialect ) {
- reportSkip( "DataDirect drivers known to not support JDBC3 getGeneratedKeys for Oracle", "oracle getGeneratedKeys support" );
- return;
- }
Session session = openSession();
session.beginTransaction();
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -4,9 +4,8 @@
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
-import org.hibernate.dialect.DataDirectOracle9Dialect;
import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -25,7 +24,7 @@
public boolean appliesTo(Dialect dialect) {
// the DataDirect driver for Oracle known to not support
// JDBC3 getGeneratedKeys...
- return ( dialect instanceof Oracle9Dialect ) && ( ! ( dialect instanceof DataDirectOracle9Dialect ) ) ;
+ return ( dialect instanceof Oracle9iDialect );
}
public String[] getMappings() {
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -13,6 +13,8 @@
import java.util.Map;
import junit.framework.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
@@ -27,14 +29,14 @@
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.Oracle8iDialect;
+
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SQLServerDialect;
-import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.Sybase11Dialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.dialect.SybaseAnywhereDialect;
-import org.hibernate.dialect.Oracle8iDialect;
+import org.hibernate.dialect.SybaseDialect;
import org.hibernate.hql.ast.ASTQueryTranslatorFactory;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -54,9 +56,6 @@
import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Tests the integration of the new AST parser into the loading of query results using
* the Hibernate persisters and loaders.
@@ -1242,7 +1241,7 @@
String dateStr1 = (String) session.createQuery("select str(current_date) from Animal").uniqueResult();
String dateStr2 = (String) session.createQuery("select str(year(current_date))||'-'||str(month(current_date))||'-'||str(day(current_date)) from Animal").uniqueResult();
System.out.println(dateStr1 + '=' + dateStr2);
- if ( ! ( getDialect() instanceof Oracle9Dialect || getDialect() instanceof Oracle8iDialect ) ) { //Oracle renders the name of the month :(
+ if ( ! ( getDialect() instanceof Oracle8iDialect ) ) { //Oracle renders the name of the month :(
String[] dp1 = StringHelper.split("-", dateStr1);
String[] dp2 = StringHelper.split("-", dateStr2);
for (int i=0; i<3; i++) {
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -14,18 +14,16 @@
import org.hibernate.Hibernate;
import org.hibernate.QueryException;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SQLServerDialect;
-import org.hibernate.dialect.SybaseAnywhereDialect;
-import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.Sybase11Dialect;
import org.hibernate.dialect.SybaseASE15Dialect;
-import org.hibernate.dialect.Oracle8iDialect;
+import org.hibernate.dialect.SybaseAnywhereDialect;
+import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.query.HQLQueryPlan;
@@ -38,9 +36,10 @@
import org.hibernate.hql.ast.QueryTranslatorImpl;
import org.hibernate.hql.ast.tree.ConstructorNode;
import org.hibernate.hql.ast.tree.DotNode;
+import org.hibernate.hql.ast.tree.FromReferenceNode;
import org.hibernate.hql.ast.tree.IndexNode;
import org.hibernate.hql.ast.tree.SelectClause;
-import org.hibernate.hql.ast.tree.FromReferenceNode;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests cases where the AST based query translator and the 'classic' query translator generate identical SQL.
@@ -677,7 +676,6 @@
}
public void testGroupByFunction() {
- if ( getDialect() instanceof Oracle9Dialect ) return;
if ( getDialect() instanceof Oracle8iDialect ) return; // the new hiearchy...
if ( getDialect() instanceof PostgreSQLDialect ) return;
assertTranslation( "select count(*) from Human h group by year(h.birthdate)" );
@@ -856,7 +854,6 @@
public void testClassProperty() throws Exception {
// This test causes failures on theta-join dialects because the SQL is different.
// The queries are semantically the same however.
- if ( getDialect() instanceof Oracle9Dialect ) return;
if ( getDialect() instanceof Oracle8iDialect ) return;
assertTranslation( "from Animal a where a.mother.class = Reptile" );
}
@@ -1132,7 +1129,6 @@
// This test causes failures on theta-join dialects because the SQL is different. The old parser
// duplicates the condition, whereas the new parser does not. The queries are semantically the
// same however.
- if ( getDialect() instanceof Oracle9Dialect ) return;
if ( getDialect() instanceof Oracle8iDialect ) return;
assertTranslation( "select an.mother.bodyWeight from Animal an join an.mother m where an.mother.bodyWeight > 10" );
assertTranslation( "select an.mother.bodyWeight from Animal an where an.mother.bodyWeight > 10" );
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -51,19 +51,18 @@
import org.hibernate.dialect.MckoiDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle8iDialect;
-import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.OracleDialect;
+//import org.hibernate.dialect.Oracle9Dialect;
+//import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.PointbaseDialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SAPDBDialect;
-import org.hibernate.dialect.SQLServerDialect;
-import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.Sybase11Dialect;
import org.hibernate.dialect.SybaseASE15Dialect;
+import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import org.hibernate.mapping.RootClass;
+//import org.hibernate.mapping.RootClass;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.type.Type;
import org.hibernate.util.JoinedIterator;
@@ -99,13 +98,6 @@
};
}
- public void configure(Configuration cfg) {
- super.configure( cfg );
- if ( Dialect.getDialect() instanceof OracleDialect ) {
- ( (RootClass) cfg.getClassMapping("org.hibernate.test.legacy.Foo") ).setForceDiscriminator(false);
- }
- }
-
public static Test suite() {
return new FunctionalTestClassTestSuite( FooBarTest.class );
}
@@ -682,7 +674,7 @@
s.find("from Foo foo where foo.integer not between 1 and 5 and foo.string not in ('cde', 'abc') and foo.string is not null and foo.integer<=3");
s.find("from Baz baz inner join baz.collectionComponent.nested.foos foo where foo.string is null");
- if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof PointbaseDialect) /*&& !(dialect instanceof Oracle9Dialect)*/ ) {
+ if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof PointbaseDialect) ) {
s.find("from Baz baz inner join baz.fooSet where '1' in (from baz.fooSet foo where foo.string is not null)");
s.find("from Baz baz where 'a' in elements(baz.collectionComponent.nested.foos) and 1.0 in elements(baz.collectionComponent.nested.floats)");
s.find("from Baz baz where 'b' in elements(baz.collectionComponent.nested.foos) and 1.0 in elements(baz.collectionComponent.nested.floats)");
@@ -2138,7 +2130,7 @@
s.find("select count(*) from Baz as baz where 1 in indices(baz.fooArray)");
s.find("select count(*) from Bar as bar where 'abc' in elements(bar.baz.fooArray)");
s.find("select count(*) from Bar as bar where 1 in indices(bar.baz.fooArray)");
- if ( !(getDialect() instanceof DB2Dialect) && !(getDialect() instanceof Oracle9Dialect) && !(getDialect() instanceof Oracle8iDialect ) && !( getDialect() instanceof SybaseDialect ) && !( getDialect() instanceof Sybase11Dialect ) && !( getDialect() instanceof SybaseASE15Dialect )) {
+ if ( !(getDialect() instanceof DB2Dialect) && !(getDialect() instanceof Oracle8iDialect ) && !( getDialect() instanceof SybaseDialect ) && !( getDialect() instanceof Sybase11Dialect ) && !( getDialect() instanceof SybaseASE15Dialect )) {
// SybaseAnywhereDialect supports implicit conversions from strings to ints
s.find("select count(*) from Bar as bar, bar.component.glarch.proxyArray as g where g.id in indices(bar.baz.fooArray)");
s.find("select max( elements(bar.baz.fooArray) ) from Bar as bar, bar.component.glarch.proxyArray as g where g.id in indices(bar.baz.fooArray)");
@@ -3304,73 +3296,81 @@
}
public void testScrollableIterator() throws Exception {
- if ( getDialect() instanceof DB2Dialect || getDialect() instanceof OracleDialect || getDialect() instanceof SybaseDialect || getDialect() instanceof HSQLDialect ) {
- Session s = openSession();
- Transaction txn = s.beginTransaction();
- s.save( new Foo() );
- s.save( new Foo() );
- s.save( new Foo() );
- s.save( new Bar() );
- Query query = s.createQuery("select f, f.integer from Foo f");
- assertTrue( query.getReturnTypes().length==2 );
- ScrollableResults iter = query.scroll();
- assertTrue( iter.next() );
- assertTrue( iter.scroll(1) );
- FooProxy f2 = (FooProxy) iter.get()[0];
- assertTrue( f2!=null );
- assertTrue( iter.scroll(-1) );
- Object f1 = iter.get(0);
- iter.next();
- assertTrue( f1!=null && iter.get(0)==f2 );
- iter.getInteger(1);
+ // skip if not one of these named dialects
+ boolean match = getDialect() instanceof DB2Dialect
+ || getDialect() instanceof SybaseDialect
+ || getDialect() instanceof HSQLDialect
+ || getDialect() instanceof Oracle8iDialect // 9i/10g too because of inheritence...
+ ;
+ if ( ! match ) {
+ return;
+ }
- assertTrue( !iter.scroll(100) );
- assertTrue( iter.first() );
- assertTrue( iter.scroll(3) );
- Object f4 = iter.get(0);
- assertTrue( f4!=null );
- assertTrue( !iter.next() );
- assertTrue( iter.first() );
- assertTrue( iter.get(0)==f1 );
- assertTrue( iter.last() );
- assertTrue( iter.get(0)==f4 );
- assertTrue( iter.previous() );
- txn.commit();
- s.close();
+ Session s = openSession();
+ Transaction txn = s.beginTransaction();
+ s.save( new Foo() );
+ s.save( new Foo() );
+ s.save( new Foo() );
+ s.save( new Bar() );
+ Query query = s.createQuery("select f, f.integer from Foo f");
+ assertTrue( query.getReturnTypes().length==2 );
+ ScrollableResults iter = query.scroll();
+ assertTrue( iter.next() );
+ assertTrue( iter.scroll(1) );
+ FooProxy f2 = (FooProxy) iter.get()[0];
+ assertTrue( f2!=null );
+ assertTrue( iter.scroll(-1) );
+ Object f1 = iter.get(0);
+ iter.next();
+ assertTrue( f1!=null && iter.get(0)==f2 );
+ iter.getInteger(1);
- s = openSession();
- txn = s.beginTransaction();
- query = s.createQuery("select f, f.integer from Foo f");
- assertTrue( query.getReturnTypes().length==2 );
- iter = query.scroll();
- assertTrue( iter.next() );
- assertTrue( iter.scroll(1) );
- f2 = (FooProxy) iter.get()[0];
- assertTrue( f2!=null );
- assertTrue( f2.getString()!=null && f2.getComponent().getImportantDates().length > 0 );
- assertTrue( iter.scroll(-1) );
- f1 = iter.get(0);
- iter.next();
- assertTrue( f1!=null && iter.get(0)==f2 );
- iter.getInteger(1);
+ assertTrue( !iter.scroll(100) );
+ assertTrue( iter.first() );
+ assertTrue( iter.scroll(3) );
+ Object f4 = iter.get(0);
+ assertTrue( f4!=null );
+ assertTrue( !iter.next() );
+ assertTrue( iter.first() );
+ assertTrue( iter.get(0)==f1 );
+ assertTrue( iter.last() );
+ assertTrue( iter.get(0)==f4 );
+ assertTrue( iter.previous() );
+ txn.commit();
+ s.close();
- assertTrue( !iter.scroll(100) );
- assertTrue( iter.first() );
- assertTrue( iter.scroll(3) );
- f4 = iter.get(0);
- assertTrue( f4!=null );
- assertTrue( !iter.next() );
- assertTrue( iter.first() );
- assertTrue( iter.get(0)==f1 );
- assertTrue( iter.last() );
- assertTrue( iter.get(0)==f4 );
- assertTrue( iter.previous() );
- assertTrue( s.delete("from Foo")==4 );
- s.flush();
- assertTrue( s.find("from java.lang.Object").size()==0 );
- txn.commit();
- s.close();
- }
+ s = openSession();
+ txn = s.beginTransaction();
+ query = s.createQuery("select f, f.integer from Foo f");
+ assertTrue( query.getReturnTypes().length==2 );
+ iter = query.scroll();
+ assertTrue( iter.next() );
+ assertTrue( iter.scroll(1) );
+ f2 = (FooProxy) iter.get()[0];
+ assertTrue( f2!=null );
+ assertTrue( f2.getString()!=null && f2.getComponent().getImportantDates().length > 0 );
+ assertTrue( iter.scroll(-1) );
+ f1 = iter.get(0);
+ iter.next();
+ assertTrue( f1!=null && iter.get(0)==f2 );
+ iter.getInteger(1);
+
+ assertTrue( !iter.scroll(100) );
+ assertTrue( iter.first() );
+ assertTrue( iter.scroll(3) );
+ f4 = iter.get(0);
+ assertTrue( f4!=null );
+ assertTrue( !iter.next() );
+ assertTrue( iter.first() );
+ assertTrue( iter.get(0)==f1 );
+ assertTrue( iter.last() );
+ assertTrue( iter.get(0)==f4 );
+ assertTrue( iter.previous() );
+ assertTrue( s.delete("from Foo")==4 );
+ s.flush();
+ assertTrue( s.find("from java.lang.Object").size()==0 );
+ txn.commit();
+ s.close();
}
public void testMultiColumnQueries() throws Exception {
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/IJTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/IJTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/IJTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -8,7 +8,6 @@
import org.hibernate.LockMode;
import org.hibernate.classic.Session;
import org.hibernate.dialect.HSQLDialect;
-import org.hibernate.dialect.OracleDialect;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
@@ -29,7 +28,7 @@
}
public void testFormulaDiscriminator() throws Exception {
- if ( ( getDialect() instanceof OracleDialect ) || ( getDialect() instanceof HSQLDialect ) ) return;
+ if ( getDialect() instanceof HSQLDialect ) return;
Session s = getSessions().openSession();
I i = new I();
i.setName( "i" );
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/MasterDetailTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/MasterDetailTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/MasterDetailTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -22,7 +22,6 @@
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MckoiDialect;
import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.SAPDBDialect;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.MetaAttribute;
@@ -316,7 +315,7 @@
assertTrue( "generated id returned", s.save(d2)!=null);
master.addDetail(d1);
master.addDetail(d2);
- if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof Oracle9Dialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof org.hibernate.dialect.TimesTenDialect)) {
+ if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof org.hibernate.dialect.TimesTenDialect)) {
assertTrue(
"query",
s.find("from Detail d, Master m where m = d.master and size(m.outgoing) = 0 and size(m.incoming) = 0").size()==2
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -23,14 +23,13 @@
import org.hibernate.dialect.InterbaseDialect;
import org.hibernate.dialect.MckoiDialect;
import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.Sybase11Dialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.dialect.SybaseAnywhereDialect;
import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -84,7 +83,7 @@
s.find("select count(*) from Simple s").size() == 1
);
- if ( getDialect() instanceof OracleDialect) {
+ if ( getDialect() instanceof Oracle9iDialect ) {
// Check Oracle Dialect mix of dialect functions - no args (no parenthesis and single arg functions
java.util.List rset = s.find("select s.name, sysdate(), trunc(s.pay), round(s.pay) from Simple s");
assertNotNull("Name string should have been returned",(((Object[])rset.get(0))[0]));
@@ -162,11 +161,11 @@
Map parameters = new HashMap();
parameters.put("name", simple.getName());
parameters.put("count", new Integer(simple.getCount()));
-
+
Query q = s.createQuery("from Simple s where s.name=:name and s.count=:count");
q.setProperties(((Map)parameters));
assertTrue( q.list().get(0)==simple );
-
+
List l = new ArrayList();
l.add("Simple 1");
l.add("Slimeball");
@@ -185,7 +184,6 @@
s.close();
}
public void testBroken() throws Exception {
- if (getDialect() instanceof Oracle9Dialect) return;
Session s = openSession();
Transaction t = s.beginTransaction();
Broken b = new Fixed();
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLLoaderTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLLoaderTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLLoaderTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -14,8 +14,6 @@
import org.hibernate.classic.Session;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -47,7 +45,6 @@
}
public void testTS() throws Exception {
- if (getDialect() instanceof Oracle9Dialect) return;
Session session = openSession();
Transaction txn = session.beginTransaction();
Simple sim = new Simple();
@@ -150,7 +147,6 @@
s.close();
if ( getDialect() instanceof MySQLDialect ) return;
- if ( getDialect() instanceof OracleDialect ) return; // todo : this fails on Oracle8 also
s = openSession();
@@ -341,11 +337,7 @@
session = openSession();
Query query;
- if ( getDialect() instanceof OracleDialect ) {
- // Oracle8 does not support X/Open extension functions :)
- query = session.createSQLQuery("select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA where upper(name) like upper('max')", "a", A.class);
- }
- else if( getDialect() instanceof TimesTenDialect) {
+ if( getDialect() instanceof TimesTenDialect) {
// TimesTen does not permit general expressions (like UPPER) in the second part of a LIKE expression,
// so we execute a similar test
query = session.createSQLQuery("select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA where {fn ucase(name)} like 'MAX'", "a", A.class);
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/rowid/RowIdTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/rowid/RowIdTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/rowid/RowIdTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -10,8 +10,8 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
@@ -37,7 +37,7 @@
}
public boolean appliesTo(Dialect dialect) {
- return dialect instanceof Oracle9Dialect;
+ return dialect instanceof Oracle9iDialect;
}
public boolean createSchema() {
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/check/OracleCheckStyleTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/check/OracleCheckStyleTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/check/OracleCheckStyleTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -3,7 +3,7 @@
import junit.framework.Test;
import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
@@ -21,7 +21,7 @@
}
public boolean appliesTo(Dialect dialect) {
- return dialect instanceof Oracle9Dialect;
+ return dialect instanceof Oracle9iDialect;
}
public static Test suite() {
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/oracle/OracleCustomSQLTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/oracle/OracleCustomSQLTest.java 2009-03-06 18:35:50 UTC (rev 16099)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/oracle/OracleCustomSQLTest.java 2009-03-06 18:42:49 UTC (rev 16100)
@@ -3,9 +3,8 @@
import junit.framework.Test;
-import org.hibernate.dialect.DataDirectOracle9Dialect;
import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.sql.hand.custom.CustomStoredProcTestSupport;
@@ -29,7 +28,7 @@
}
public boolean appliesTo(Dialect dialect) {
- return ( dialect instanceof Oracle9Dialect ) && !( dialect instanceof DataDirectOracle9Dialect );
+ return ( dialect instanceof Oracle9iDialect );
}
}
15 years, 9 months