Hibernate SVN: r17181 - core/trunk/core/src/main/java/org/hibernate/impl.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-07-21 09:45:51 -0400 (Tue, 21 Jul 2009)
New Revision: 17181
Modified:
core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
Log:
Make CacheImpl serializable
Modified: core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2009-07-21 13:41:01 UTC (rev 17180)
+++ core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2009-07-21 13:45:51 UTC (rev 17181)
@@ -958,7 +958,7 @@
private final Cache cacheAccess = new CacheImpl();
- private class CacheImpl implements Cache {
+ private class CacheImpl implements Cache, Serializable {
public boolean containsEntity(Class entityClass, Serializable identifier) {
return containsEntity( entityClass.getName(), identifier );
}
15 years, 4 months
Hibernate SVN: r17180 - core/trunk/parent.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-07-21 09:41:01 -0400 (Tue, 21 Jul 2009)
New Revision: 17180
Modified:
core/trunk/parent/pom.xml
Log:
HHH-3997 - Configure the maven javadoc plugin
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2009-07-21 12:38:15 UTC (rev 17179)
+++ core/trunk/parent/pom.xml 2009-07-21 13:41:01 UTC (rev 17180)
@@ -36,11 +36,13 @@
<name>Hibernate Core Parent POM</name>
<description>The base POM for all Hibernate Core modules.</description>
<url>http://hibernate.org</url>
+ <inceptionYear>2002</inceptionYear>
<organization>
<name>Hibernate.org</name>
<url>http://hibernate.org</url>
</organization>
+
<developers>
</developers>
@@ -175,7 +177,40 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.4</version>
+ <version>2.5</version>
+ <configuration>
+ <links>
+ <link>http://java.sun.com/j2se/1.4.2/docs/api/</link>
+ <link>http://java.sun.com/j2ee/1.4/docs/api/</link>
+ </links>
+ <packagesheader>Hibernate Packages</packagesheader>
+ <doctitle>Hibernate Core ${project.version}</doctitle>
+ <windowtitle>Hibernate Core ${project.version}</windowtitle>
+ <bottom><![CDATA[Copyright © ${inceptionYear}-{currentYear} <a href="http://redhat.com">Red Hat Middleware, LLC.</a> All Rights Reserved]]></bottom>
+ <excludePackageNames>orh.hibernate.tutorial*</excludePackageNames>
+ <groups>
+ <group>
+ <title>Core API</title>
+ <packages>
+ org.hibernate:org.hibernate.classic:org.hibernate.criterion:org.hibernate.mapping:org.hibernate.metadata:org.hibernate.cfg:org.hibernate.stat
+ </packages>
+ </group>
+ <group>
+ <title>Extension SPI/API</title>
+ <packages>
+ org.hibernate.id*:org.hibernate.connection:org.hibernate.transaction:org.hibernate.type:org.hibernate.dialect*:org.hibernate.cache*:org.hibernate.event*:org.hibernate.property:org.hibernate.loader*:org.hibernate.persister*:org.hibernate.proxy:org.hibernate.tuple:org.hibernate.transform:org.hibernate.collection:org.hibernate.jdbc:org.hibernate.usertype
+ </packages>
+ </group>
+ <group>
+ <title>JBoss Cache Integration</title>
+ <packages>org.hibernate.cache.jbc2*</packages>
+ </group>
+ <group>
+ <title>Miscellaneous API</title>
+ <packages>org.hibernate.tool.hbm2ddl:org.hibernate.jmx:org.hibernate.tool.instrument*</packages>
+ </group>
+ </groups>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -215,18 +250,9 @@
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.4.3</version>
</plugin>
+<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <links>
- <link>http://java.sun.com/j2se/1.4.2/docs/api/</link>
- <link>http://java.sun.com/j2ee/1.4/docs/api/</link>
- </links>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.1</version>
</plugin>
@@ -235,7 +261,7 @@
<artifactId>maven-pmd-plugin</artifactId>
<version>2.2</version>
<configuration>
- <linkXref>true</linkXref>
+ <linkXRef>true</linkXRef>
<minimumTokens>100</minimumTokens>
<targetJdk>1.4</targetJdk>
</configuration>
@@ -258,11 +284,11 @@
</configuration>
</plugin>
<plugin>
- <!-- Note: aggregate-able, may cause problems if we aggregate jxr and not this because of the xref links -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>javancss-maven-plugin</artifactId>
<version>2.0-beta-2</version>
</plugin>
+-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
15 years, 4 months
Hibernate SVN: r17179 - in validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation: metadata and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-21 08:38:15 -0400 (Tue, 21 Jul 2009)
New Revision: 17179
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorFactoryImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorContextImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/PropertyDescriptorImpl.java
Log:
javadoc cleanup
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorFactoryImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorFactoryImpl.java 2009-07-21 12:24:39 UTC (rev 17178)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorFactoryImpl.java 2009-07-21 12:38:15 UTC (rev 17179)
@@ -28,10 +28,7 @@
* @author Hardy Ferentschik
*/
public class ConstraintValidatorFactoryImpl implements ConstraintValidatorFactory {
-
- /**
- * {@inheritDoc}
- */
+
public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T> key) {
try {
return key.newInstance();
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorContextImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorContextImpl.java 2009-07-21 12:24:39 UTC (rev 17178)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorContextImpl.java 2009-07-21 12:38:15 UTC (rev 17179)
@@ -36,9 +36,6 @@
traversableResolver( factoryTraversableResolver );
}
- /**
- * {@inheritDoc}
- */
public ValidatorContext messageInterpolator(MessageInterpolator messageInterpolator) {
if ( messageInterpolator == null ) {
this.messageInterpolator = factoryMessageInterpolator;
@@ -49,9 +46,6 @@
return this;
}
- /**
- * {@inheritDoc}
- */
public ValidatorContext traversableResolver(TraversableResolver traversableResolver) {
if ( traversableResolver == null ) {
this.traversableResolver = factoryTraversableResolver;
@@ -62,9 +56,6 @@
return this;
}
- /**
- * {@inheritDoc}
- */
public Validator getValidator() {
return new ValidatorImpl(
constraintValidatorFactory,
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/PropertyDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/PropertyDescriptorImpl.java 2009-07-21 12:24:39 UTC (rev 17178)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/PropertyDescriptorImpl.java 2009-07-21 12:38:15 UTC (rev 17179)
@@ -36,16 +36,10 @@
this.property = property;
}
- /**
- * {@inheritDoc}
- */
public boolean isCascaded() {
return cascaded;
}
- /**
- * {@inheritDoc}
- */
public String getPropertyName() {
return property;
}
15 years, 4 months
Hibernate SVN: r17178 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/traversableresolver and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-21 08:24:39 -0400 (Tue, 21 Jul 2009)
New Revision: 17178
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Person.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Suit.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Trousers.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
TraversableResolver tck tests
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-07-21 10:53:12 UTC (rev 17177)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-07-21 12:24:39 UTC (rev 17178)
@@ -21,18 +21,14 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.lang.annotation.ElementType;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
import java.util.Set;
-import javax.validation.Configuration;
import javax.validation.ConstraintViolation;
import javax.validation.MessageInterpolator;
-import javax.validation.Path;
-import javax.validation.TraversableResolver;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
@@ -127,35 +123,6 @@
);
}
- @Test
- @SpecAssertion(section = "3.5.2", id = "b")
- public void testCustomTraversableResolverViaConfiguration() {
-
- // get a new factory using a custom configuration
- Configuration<?> configuration = Validation.byDefaultProvider().configure();
- configuration.traversableResolver( new DummyTraversableResolver() );
- ValidatorFactory factory = configuration.buildValidatorFactory();
- Validator validator = factory.getValidator();
-
- assertCustomTrversableResolverUsed( validator );
- }
-
- @Test
- @SpecAssertion(section = "3.5.2", id = "b")
- public void testCustomTraversableResolverViaValidatorContext() {
- ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
- DummyTraversableResolver DummyTraversableResolver = new DummyTraversableResolver();
- Validator validator = factory.usingContext().traversableResolver( DummyTraversableResolver ).getValidator();
-
- assertCustomTrversableResolverUsed( validator );
- }
-
- private void assertCustomTrversableResolverUsed(Validator validator) {
- Person person = new Person();
- Set<ConstraintViolation<Person>> constraintViolations = validator.validate( person );
- assertCorrectNumberOfViolations( constraintViolations, 0 );
- }
-
private List<ValidationProvider> readBeanValidationServiceFile() {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
if ( classloader == null ) {
@@ -238,15 +205,4 @@
throw new UnsupportedOperationException( "No specific locale is possible" );
}
}
-
- private static class DummyTraversableResolver implements TraversableResolver {
-
- public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
- return false;
- }
-
- public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
- return false;
- }
- }
}
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Person.java (from rev 17143, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/Person.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Person.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Person.java 2009-07-21 12:24:39 UTC (rev 17178)
@@ -0,0 +1,60 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jsr303.tck.tests.traversableresolver;
+
+import javax.validation.constraints.Digits;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Person {
+ @NotNull
+ private String firstName;
+
+ @NotNull
+ private String lastName;
+
+ @Digits(integer = 10, fraction = 0)
+ private long personalNumber;
+
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public long getPersonalNumber() {
+ return personalNumber;
+ }
+
+ public void setPersonalNumber(long personalNumber) {
+ this.personalNumber = personalNumber;
+ }
+}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Suit.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Suit.java 2009-07-21 10:53:12 UTC (rev 17177)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Suit.java 2009-07-21 12:24:39 UTC (rev 17178)
@@ -17,21 +17,24 @@
*/
package org.hibernate.jsr303.tck.tests.traversableresolver;
+import javax.validation.GroupSequence;
+import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
-import javax.validation.Valid;
-import javax.validation.GroupSequence;
import javax.validation.groups.Default;
/**
* @author Emmanuel Bernard
*/
-@GroupSequence( {Suit.class, Cloth.class })
+@GroupSequence({ Suit.class, Cloth.class })
public class Suit {
- @Max(value=50, groups = { Default.class, Cloth.class})
+ @Max(value = 50, groups = { Default.class, Cloth.class })
@Min(1)
private Integer size;
- @Valid private Trousers trousers;
+
+ @Valid
+ private Trousers trousers;
+
private Jacket jacket;
public Trousers getTrousers() {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.java 2009-07-21 10:53:12 UTC (rev 17177)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.java 2009-07-21 12:24:39 UTC (rev 17178)
@@ -17,22 +17,29 @@
*/
package org.hibernate.jsr303.tck.tests.traversableresolver;
+import java.lang.annotation.ElementType;
+import java.util.Set;
import javax.validation.Configuration;
+import javax.validation.ConstraintViolation;
+import javax.validation.Path;
+import javax.validation.TraversableResolver;
import javax.validation.Validation;
+import javax.validation.ValidationException;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
-import javax.validation.ValidationException;
import javax.validation.groups.Default;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.test.audit.annotations.SpecAssertion;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
/**
* @author Emmanuel Bernard
@@ -42,7 +49,11 @@
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
public class TraversableResolverTest extends AbstractTest {
@Test
- public void testCorrectPathsAreRequested() {
+ @SpecAssertions({
+ @SpecAssertion(section = "3.5.2", id = "a"),
+ @SpecAssertion(section = "3.5.2", id = "b")
+ })
+ public void testCorrectNumberOfCallsToIsReachableAndIsCascadable() {
Suit suit = new Suit();
suit.setTrousers( new Trousers() );
suit.setJacket( new Jacket() );
@@ -67,8 +78,24 @@
assertEquals( resolver.getCascadePaths().size(), 2 );
}
+ @Test
+ @SpecAssertion(section = "3.5.2", id = "d")
+ public void testCustomTraversableResolverViaConfiguration() {
+
+ // get a new factory using a custom configuration
+ Configuration<?> configuration = Validation.byDefaultProvider().configure();
+ configuration.traversableResolver( new DummyTraversableResolver() );
+ ValidatorFactory factory = configuration.buildValidatorFactory();
+ Validator validator = factory.getValidator();
+
+ Person person = new Person();
+ Set<ConstraintViolation<Person>> constraintViolations = validator.validate( person );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+ }
+
+
@Test(expectedExceptions = ValidationException.class)
- @SpecAssertion(section = "3.5.2", id = "c")
+ @SpecAssertion(section = "3.5.2", id = "e")
public void testResolverExceptionsGetWrappedInValidationException() {
ExceptionThrowingTraversableResolver resolver = new ExceptionThrowingTraversableResolver();
Configuration<?> config = ( Configuration<?> ) Validation.byDefaultProvider()
@@ -80,4 +107,15 @@
v.validate( new Suit() );
}
+
+ private static class DummyTraversableResolver implements TraversableResolver {
+
+ public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
+ return false;
+ }
+
+ public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
+ return false;
+ }
+ }
}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Trousers.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Trousers.java 2009-07-21 10:53:12 UTC (rev 17177)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Trousers.java 2009-07-21 12:24:39 UTC (rev 17178)
@@ -17,16 +17,16 @@
*/
package org.hibernate.jsr303.tck.tests.traversableresolver;
+import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
-import javax.validation.constraints.Max;
import javax.validation.groups.Default;
/**
* @author Emmanuel Bernard
*/
public class Trousers {
- @Min(value=70, groups = {Default.class, Cloth.class})
- @Max(value=220)
+ @Min(value = 70, groups = { Default.class, Cloth.class })
+ @Max(value = 220)
private Integer length;
public Integer getLength() {
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-21 10:53:12 UTC (rev 17177)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-21 12:24:39 UTC (rev 17178)
@@ -452,28 +452,34 @@
</section>
<section id="3.5.2" title="Traversable property">
<assertion id="a">
+ <text>isReachable is called for every property about to be accessed either for validation or for cascading</text>
+ </assertion>
+ <assertion id="b">
+ <text>isCascadable is called for every property about to be cascaded (ie. marked as @Valid)</text>
+ </assertion>
+ <assertion id="c">
<text>isCascadable for a given property is only called if isReachable returns true. In
other words, isReachable is always called before isCascadable for a given
property</text>
- </assertion>
- <assertion id="b">
+ </assertion>
+ <assertion id="d">
<text>The Bean Validation provider must not access the state of a property, nor validate
its constraints if the property is not traversable. A property is traversable if
TraversableResolver returns true for this property</text>
</assertion>
- <assertion id="c">
+ <assertion id="e">
<text>If an exception occurs when the TraversableResolver is called, the exception is
wrapped into a ValidationException</text>
</assertion>
- <assertion id="d">
+ <assertion id="f" testable="false">
<text>If Java Persistence is available in the runtime environment, a property is
considered reachable if Java Persistence considers the property as loaded</text>
</assertion>
- <assertion id="d">
+ <assertion id="g" testable="false">
<text>If Java Persistence is not available in the runtime environment, all properties
are considered reachable</text>
</assertion>
- <assertion id="e">
+ <assertion id="h" testable="false">
<text>If Java Persistence is not available in the runtime environment, all properties are considered cascadable</text>
</assertion>
</section>
15 years, 4 months
Hibernate SVN: r17177 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-21 06:53:12 -0400 (Tue, 21 Jul 2009)
New Revision: 17177
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
Log:
HV-187 added approproate try/catch clauses
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-07-21 10:52:39 UTC (rev 17176)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-07-21 10:53:12 UTC (rev 17177)
@@ -429,7 +429,7 @@
private <T> void validateCascadedConstraint(GlobalExecutionContext<T> context, Iterator<?> iter, boolean isIndexable, Class<?> currentGroup, PathImpl currentPath) {
Object value;
Integer index;
- Object mapKey = null;
+ Object mapKey;
int i = 0;
while ( iter.hasNext() ) {
value = iter.next();
@@ -737,36 +737,60 @@
return new SingleThreadCachedTraversableResolver( traversableResolver );
}
- @SuppressWarnings("SimplifiableIfStatement")
private boolean isValidationRequired(GlobalExecutionContext globalContext, LocalExecutionContext localContext, MetaConstraint metaConstraint) {
if ( !metaConstraint.getGroupList().contains( localContext.getCurrentGroup() ) ) {
return false;
}
- return globalContext.getTraversableResolver().isReachable(
- localContext.getCurrentBean(),
- localContext.getPropertyPath().getLeafNode(),
- globalContext.getRootBeanClass(),
- localContext.getPropertyPath().getPathWithoutLeafNode(),
- metaConstraint.getElementType()
- );
+ boolean isReachable;
+
+ try {
+ isReachable = globalContext.getTraversableResolver().isReachable(
+ localContext.getCurrentBean(),
+ localContext.getPropertyPath().getLeafNode(),
+ globalContext.getRootBeanClass(),
+ localContext.getPropertyPath().getPathWithoutLeafNode(),
+ metaConstraint.getElementType()
+ );
+ }
+ catch ( RuntimeException e ) {
+ throw new ValidationException( "Call to TraversableResolver.isReachable() threw an exception", e );
+ }
+
+ return isReachable;
}
private boolean isCascadeRequired(GlobalExecutionContext globalContext, LocalExecutionContext localContext, Member member) {
final ElementType type = member instanceof Field ? ElementType.FIELD : ElementType.METHOD;
- return globalContext.getTraversableResolver().isReachable(
- localContext.getCurrentBean(),
- localContext.getPropertyPath().getLeafNode(),
- globalContext.getRootBeanClass(),
- localContext.getPropertyPath().getPathWithoutLeafNode(),
- type
- )
- && globalContext.getTraversableResolver().isCascadable(
- localContext.getCurrentBean(),
- localContext.getPropertyPath().getLeafNode(),
- globalContext.getRootBeanClass(),
- localContext.getPropertyPath().getPathWithoutLeafNode(),
- type
- );
+ boolean isReachable;
+ boolean isCascadable;
+
+ try {
+ isReachable = globalContext.getTraversableResolver().isReachable(
+ localContext.getCurrentBean(),
+ localContext.getPropertyPath().getLeafNode(),
+ globalContext.getRootBeanClass(),
+ localContext.getPropertyPath().getPathWithoutLeafNode(),
+ type
+ );
+ }
+ catch ( RuntimeException e ) {
+ throw new ValidationException( "Call to TraversableResolver.isReachable() threw an exception", e );
+ }
+
+ try {
+ isCascadable = globalContext.getTraversableResolver().isCascadable(
+ localContext.getCurrentBean(),
+ localContext.getPropertyPath().getLeafNode(),
+ globalContext.getRootBeanClass(),
+ localContext.getPropertyPath().getPathWithoutLeafNode(),
+ type
+ );
+ }
+ catch ( RuntimeException e ) {
+ throw new ValidationException( "Call to TraversableResolver.isCascadable() threw an exception", e );
+ }
+
+ return isReachable && isCascadable;
}
}
15 years, 4 months
Hibernate SVN: r17176 - validator/trunk/hibernate-validator.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-21 06:52:39 -0400 (Tue, 21 Jul 2009)
New Revision: 17176
Modified:
validator/trunk/hibernate-validator/pom.xml
Log:
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2009-07-21 10:52:34 UTC (rev 17175)
+++ validator/trunk/hibernate-validator/pom.xml 2009-07-21 10:52:39 UTC (rev 17176)
@@ -47,7 +47,7 @@
Optional dependencies
-->
<dependency>
- <!-- This is a temporary dependency. Do not use this dependecy in production. -->
+ <!-- This is a temporary dependency. Do not use this dependecy in production.-->
<groupId>org.hibernate.java-persistence</groupId>
<artifactId>jpa-api</artifactId>
<version>2.0.Beta-SNAPSHOT</version>
15 years, 4 months
Hibernate SVN: r17175 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/constraints and 7 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-21 06:52:34 -0400 (Tue, 21 Jul 2009)
New Revision: 17175
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/ExceptionThrowingTraversableResolver.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/messageinterpolation/
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages.properties
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages_de.properties
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/customconstraint/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/messageinterpolation/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/validation/messageinterpolation/
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Cloth.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Jacket.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/SnifferTraversableResolver.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Suit.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Trousers.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
restructured package structure and added tests for TraversableResolver
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint (from rev 17143, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/customconstraint)
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation (from rev 17143, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/messageinterpolation)
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/messageinterpolation/MessageInterpolationTest.java 2009-07-17 21:41:19 UTC (rev 17143)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java 2009-07-21 10:52:34 UTC (rev 17175)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.messageinterpolation;
+package org.hibernate.jsr303.tck.tests.messageinterpolation;
import java.util.Locale;
import javax.validation.MessageInterpolator;
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver (from rev 17143, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver)
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Cloth.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/Cloth.java 2009-07-17 21:41:19 UTC (rev 17143)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Cloth.java 2009-07-21 10:52:34 UTC (rev 17175)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.traversableresolver;
+package org.hibernate.jsr303.tck.tests.traversableresolver;
/**
* @author Emmanuel Bernard
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/ExceptionThrowingTraversableResolver.java (from rev 17143, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/SnifferTraversableResolver.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/ExceptionThrowingTraversableResolver.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/ExceptionThrowingTraversableResolver.java 2009-07-21 10:52:34 UTC (rev 17175)
@@ -0,0 +1,36 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jsr303.tck.tests.traversableresolver;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Path;
+import javax.validation.TraversableResolver;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class ExceptionThrowingTraversableResolver implements TraversableResolver {
+
+ public boolean isReachable(Object o, Path.Node node, Class<?> aClass, Path path, ElementType elementType) {
+ throw new RuntimeException( "isReachable failed" );
+ }
+
+ public boolean isCascadable(Object o, Path.Node node, Class<?> aClass, Path path, ElementType elementType) {
+ throw new RuntimeException( "isCascadable failed" );
+ }
+}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Jacket.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/Jacket.java 2009-07-17 21:41:19 UTC (rev 17143)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Jacket.java 2009-07-21 10:52:34 UTC (rev 17175)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.traversableresolver;
+package org.hibernate.jsr303.tck.tests.traversableresolver;
import javax.validation.constraints.Max;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/SnifferTraversableResolver.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/SnifferTraversableResolver.java 2009-07-17 21:41:19 UTC (rev 17143)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/SnifferTraversableResolver.java 2009-07-21 10:52:34 UTC (rev 17175)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.traversableresolver;
+package org.hibernate.jsr303.tck.tests.traversableresolver;
import java.lang.annotation.ElementType;
import java.util.HashSet;
@@ -89,6 +89,9 @@
);
}
+ /**
+ * Wrapper class for keeping track of the paramters for a single call to {@link SnifferTraversableResolver#isReachable} and {@link SnifferTraversableResolver#isCascadable}.
+ */
private static final class Call {
private Object traversableObject;
private String traversableProperty;
@@ -105,7 +108,6 @@
}
@Override
- @SuppressWarnings("SimplifiableIfStatement")
public boolean equals(Object o) {
if ( this == o ) {
return true;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Suit.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/Suit.java 2009-07-17 21:41:19 UTC (rev 17143)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Suit.java 2009-07-21 10:52:34 UTC (rev 17175)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.traversableresolver;
+package org.hibernate.jsr303.tck.tests.traversableresolver;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/TraversableResolverTest.java 2009-07-17 21:41:19 UTC (rev 17143)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.java 2009-07-21 10:52:34 UTC (rev 17175)
@@ -15,18 +15,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.traversableresolver;
+package org.hibernate.jsr303.tck.tests.traversableresolver;
import javax.validation.Configuration;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
+import javax.validation.ValidationException;
import javax.validation.groups.Default;
import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.test.audit.annotations.SpecAssertion;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
@@ -34,9 +36,10 @@
/**
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
public class TraversableResolverTest extends AbstractTest {
@Test
public void testCorrectPathsAreRequested() {
@@ -63,4 +66,18 @@
assertEquals( resolver.getReachPaths().size(), 5 );
assertEquals( resolver.getCascadePaths().size(), 2 );
}
+
+ @Test(expectedExceptions = ValidationException.class)
+ @SpecAssertion(section = "3.5.2", id = "c")
+ public void testResolverExceptionsGetWrappedInValidationException() {
+ ExceptionThrowingTraversableResolver resolver = new ExceptionThrowingTraversableResolver();
+ Configuration<?> config = ( Configuration<?> ) Validation.byDefaultProvider()
+ .configure()
+ .traversableResolver( resolver );
+
+ ValidatorFactory factory = config.buildValidatorFactory();
+ Validator v = factory.getValidator();
+
+ v.validate( new Suit() );
+ }
}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Trousers.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/Trousers.java 2009-07-17 21:41:19 UTC (rev 17143)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/Trousers.java 2009-07-21 10:52:34 UTC (rev 17175)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.traversableresolver;
+package org.hibernate.jsr303.tck.tests.traversableresolver;
import javax.validation.constraints.Min;
import javax.validation.constraints.Max;
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages.properties (from rev 17143, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/validation/messageinterpolation/ValidationMessages.properties)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages.properties (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages.properties 2009-07-21 10:52:34 UTC (rev 17175)
@@ -0,0 +1,4 @@
+javax.validation.constraints.NotNull.message=may not be null
+foo=replacement worked
+replace.in.user.bundle1={replace.in.user.bundle2}
+replace.in.user.bundle2=recursion worked
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages_de.properties (from rev 17143, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/validation/messageinterpolation/ValidationMessages_de.properties)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages_de.properties (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages_de.properties 2009-07-21 10:52:34 UTC (rev 17175)
@@ -0,0 +1 @@
+javax.validation.constraints.NotNull.message=kann nicht null sein
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-21 09:46:56 UTC (rev 17174)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-21 10:52:34 UTC (rev 17175)
@@ -466,15 +466,15 @@
wrapped into a ValidationException</text>
</assertion>
<assertion id="d">
- <text>if Java Persistence is available in the runtime environment, a property is
+ <text>If Java Persistence is available in the runtime environment, a property is
considered reachable if Java Persistence considers the property as loaded</text>
</assertion>
<assertion id="d">
- <text>if Java Persistence is not available in the runtime environment, all properties
+ <text>If Java Persistence is not available in the runtime environment, all properties
are considered reachable</text>
</assertion>
<assertion id="e">
- <text>all properties are considered cascadable</text>
+ <text>If Java Persistence is not available in the runtime environment, all properties are considered cascadable</text>
</assertion>
</section>
<section id="3.5.3" title="ConstraintValidator resolution algorithm">
15 years, 4 months
Hibernate SVN: r17174 - beanvalidation/trunk/validation-tck.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-21 05:46:56 -0400 (Tue, 21 Jul 2009)
New Revision: 17174
Modified:
beanvalidation/trunk/validation-tck/pom.xml
Log:
changed the way the tck-audit tool was configured. Now uses ant task to generate the coverage report. This prevents the complication failure with UserType and DummyPayload
Modified: beanvalidation/trunk/validation-tck/pom.xml
===================================================================
--- beanvalidation/trunk/validation-tck/pom.xml 2009-07-21 02:07:50 UTC (rev 17173)
+++ beanvalidation/trunk/validation-tck/pom.xml 2009-07-21 09:46:56 UTC (rev 17174)
@@ -1,5 +1,7 @@
<?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/maven-v4_0_0.xsd">
+<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hibernate.jsr303.tck</groupId>
<artifactId>jsr303-tck</artifactId>
@@ -208,7 +210,7 @@
<ciManagement>
<system>Hudson</system>
- <url />
+ <url/>
</ciManagement>
<issueManagement>
@@ -265,11 +267,44 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>process_annotations</id>
+ <phase>process-test-resources</phase>
+ <configuration>
+ <tasks>
+ <javac srcdir="src/main/java" destdir="/target/classes"
+ failonerror="false" excludes="test/**">
+ <compilerarg value="-proc:only"/>
+ <compilerarg value="-AauditXml=${basedir}/src/main/resources/tck-audit.xml"/>
+ <classpath>
+ <path refid="maven.test.classpath"/>
+ </classpath>
+ </javac>
+ </tasks>
+ <sourceRoot>generate</sourceRoot>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
- <compilerArgument>-AauditXml=${basedir}/src/main/resources/tck-audit.xml</compilerArgument>
+ <compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
15 years, 4 months
Hibernate SVN: r17173 - in core/trunk/annotations/src: main/java/org/hibernate/cfg/annotations and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-07-20 22:07:50 -0400 (Mon, 20 Jul 2009)
New Revision: 17173
Added:
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CustomizableColumns.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapKeyColumnDelegator.java
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/any/PropertyMap.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/indexcoll/Atmosphere.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/Brand.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/OwnerImpl.java
Log:
ANN-856 implement @MapKeyColumn
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2009-07-21 01:25:22 UTC (rev 17172)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2009-07-21 02:07:50 UTC (rev 17173)
@@ -73,6 +73,7 @@
import javax.persistence.ElementCollection;
import javax.persistence.CollectionTable;
import javax.persistence.UniqueConstraint;
+import javax.persistence.MapKeyColumn;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
@@ -132,6 +133,8 @@
import org.hibernate.cfg.annotations.QueryBinder;
import org.hibernate.cfg.annotations.SimpleValueBinder;
import org.hibernate.cfg.annotations.TableBinder;
+import org.hibernate.cfg.annotations.MapKeyColumnDelegator;
+import org.hibernate.cfg.annotations.CustomizableColumns;
import org.hibernate.engine.FilterDefinition;
import org.hibernate.engine.Versioning;
import org.hibernate.id.MultipleHiLoPerTableGenerator;
@@ -1538,14 +1541,20 @@
);
}
- org.hibernate.annotations.MapKey hibMapKeyAnn = property.getAnnotation(
- org.hibernate.annotations.MapKey.class
- );
+ Column[] keyColumns = null;
+ //JPA 2 has priority
+ if ( property.isAnnotationPresent( MapKeyColumn.class ) ) {
+ keyColumns = new Column[] { new MapKeyColumnDelegator( property.getAnnotation( MapKeyColumn.class ) ) };
+ }
+ else if ( property.isAnnotationPresent( org.hibernate.annotations.MapKey.class ) ) {
+ keyColumns = property.getAnnotation( org.hibernate.annotations.MapKey.class ).columns();
+ }
+ //nullify empty array
+ keyColumns = keyColumns != null && keyColumns.length > 0 ? keyColumns : null;
+
PropertyData mapKeyVirtualProperty = new WrappedInferredData( inferredData, "mapkey" );
Ejb3Column[] mapColumns = Ejb3Column.buildColumnFromAnnotation(
- hibMapKeyAnn != null && hibMapKeyAnn.columns().length > 0 ?
- hibMapKeyAnn.columns() :
- null,
+ keyColumns,
null,
Nullability.FORCED_NOT_NULL,
propertyHolder,
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2009-07-21 01:25:22 UTC (rev 17172)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2009-07-21 02:07:50 UTC (rev 17173)
@@ -39,6 +39,7 @@
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
import javax.persistence.ElementCollection;
+import javax.persistence.MapKeyColumn;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
@@ -337,9 +338,11 @@
collection.setRole( StringHelper.qualify( propertyHolder.getPath(), propertyName ) );
collection.setNodeName( propertyName );
- if ( property.isAnnotationPresent( org.hibernate.annotations.MapKey.class ) && mapKeyPropertyName != null ) {
+ if ( (property.isAnnotationPresent( org.hibernate.annotations.MapKey.class )
+ || property.isAnnotationPresent( MapKeyColumn.class ) )
+ && mapKeyPropertyName != null ) {
throw new AnnotationException(
- "Cannot mix @javax.persistence.MapKey and @org.hibernate.annotations.MapKey "
+ "Cannot mix @javax.persistence.MapKey and @MapKeyColumn or @org.hibernate.annotations.MapKey "
+ "on the same collection: " + StringHelper.qualify(
propertyHolder.getPath(), propertyName
)
Added: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CustomizableColumns.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CustomizableColumns.java (rev 0)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CustomizableColumns.java 2009-07-21 02:07:50 UTC (rev 17173)
@@ -0,0 +1,27 @@
+package org.hibernate.cfg.annotations;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import javax.persistence.Column;
+
+import org.hibernate.annotations.Columns;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@SuppressWarnings({ "ClassExplicitlyAnnotation" })
+public class CustomizableColumns implements Columns {
+ private final Column[] columns;
+
+ public CustomizableColumns(Column[] columns) {
+ this.columns = columns;
+ }
+
+ public Column[] columns() {
+ return columns;
+ }
+
+ public Class<? extends Annotation> annotationType() {
+ return Columns.class;
+ }
+}
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java 2009-07-21 01:25:22 UTC (rev 17172)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java 2009-07-21 02:07:50 UTC (rev 17173)
@@ -138,13 +138,14 @@
Class target = void.class;
/*
* target has priority over reflection for the map key type
+ * JPA 2 has priority
*/
- if ( property.isAnnotationPresent( org.hibernate.annotations.MapKey.class ) ) {
+ if ( property.isAnnotationPresent( MapKeyClass.class ) ) {
+ target = property.getAnnotation( MapKeyClass.class ).value();
+ }
+ else if ( property.isAnnotationPresent( org.hibernate.annotations.MapKey.class ) ) {
target = property.getAnnotation( org.hibernate.annotations.MapKey.class ).targetElement();
}
- else if ( property.isAnnotationPresent( MapKeyClass.class ) ) {
- target = property.getAnnotation( MapKeyClass.class ).value();
- }
else if ( property.isAnnotationPresent( MapKeyManyToMany.class ) ) {
target = property.getAnnotation( MapKeyManyToMany.class ).targetEntity();
}
Added: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapKeyColumnDelegator.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapKeyColumnDelegator.java (rev 0)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapKeyColumnDelegator.java 2009-07-21 02:07:50 UTC (rev 17173)
@@ -0,0 +1,61 @@
+package org.hibernate.cfg.annotations;
+
+import java.lang.annotation.Annotation;
+import javax.persistence.Column;
+import javax.persistence.MapKeyColumn;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@SuppressWarnings({ "ClassExplicitlyAnnotation" })
+public class MapKeyColumnDelegator implements Column {
+ private final MapKeyColumn column;
+
+ public MapKeyColumnDelegator(MapKeyColumn column) {
+ this.column = column;
+ }
+
+ public String name() {
+ return column.name();
+ }
+
+ public boolean unique() {
+ return column.unique();
+ }
+
+ public boolean nullable() {
+ return column.nullable();
+ }
+
+ public boolean insertable() {
+ return column.insertable();
+ }
+
+ public boolean updatable() {
+ return column.updatable();
+ }
+
+ public String columnDefinition() {
+ return column.columnDefinition();
+ }
+
+ public String table() {
+ return column.table();
+ }
+
+ public int length() {
+ return column.length();
+ }
+
+ public int precision() {
+ return column.precision();
+ }
+
+ public int scale() {
+ return column.scale();
+ }
+
+ public Class<? extends Annotation> annotationType() {
+ return Column.class;
+ }
+}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/any/PropertyMap.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/any/PropertyMap.java 2009-07-21 01:25:22 UTC (rev 17172)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/any/PropertyMap.java 2009-07-21 02:07:50 UTC (rev 17173)
@@ -61,7 +61,7 @@
name = "map_properties",
joinColumns = @JoinColumn( name = "map_id" ),
inverseJoinColumns = @JoinColumn( name = "property_id" ) )
- @MapKey( columns = { @Column( name = "map_key" ) } )
+ @MapKey( columns = { @Column( name = "map_key" ) } ) //keep for legacy test
public Map<String, Property> getProperties() {
return properties;
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java 2009-07-21 01:25:22 UTC (rev 17172)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java 2009-07-21 02:07:50 UTC (rev 17173)
@@ -8,6 +8,7 @@
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
+import javax.persistence.MapKeyColumn;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
@@ -33,7 +34,7 @@
new HashMap<String, String>( 1 );
@ElementCollection
- @MapKey( columns = @Column( name = "language_code" ) )
+ @MapKeyColumn(name = "language_code" )
@Fetch( FetchMode.JOIN )
@Filter( name = "selectedLocale",
condition = " language_code = :param " )
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/indexcoll/Atmosphere.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/indexcoll/Atmosphere.java 2009-07-21 01:25:22 UTC (rev 17172)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/indexcoll/Atmosphere.java 2009-07-21 02:07:50 UTC (rev 17173)
@@ -11,6 +11,7 @@
import javax.persistence.Column;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
+import javax.persistence.MapKeyColumn;
import org.hibernate.annotations.MapKey;
import org.hibernate.annotations.CollectionOfElements;
@@ -26,7 +27,7 @@
public Integer id;
@ManyToMany(cascade = CascadeType.ALL)
- @MapKey(columns = {@Column(name="gas_name")})
+ @MapKeyColumn(name="gas_name")
public Map<String, Gas> gases = new HashMap<String, Gas>();
@ManyToMany(cascade = CascadeType.ALL)
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/Brand.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/Brand.java 2009-07-21 01:25:22 UTC (rev 17172)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/Brand.java 2009-07-21 02:07:50 UTC (rev 17173)
@@ -8,6 +8,7 @@
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
+import javax.persistence.MapKeyClass;
import org.hibernate.annotations.MapKey;
import org.hibernate.annotations.MapKeyManyToMany;
@@ -22,7 +23,7 @@
private Long id;
@ManyToMany(targetEntity = LuggageImpl.class)
- @MapKey(targetElement = SizeImpl.class)
+ @MapKeyClass(SizeImpl.class)
private Map<Size, Luggage> luggagesBySize = new HashMap<Size, Luggage>();
@ElementCollection(targetClass = SizeImpl.class)
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/OwnerImpl.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/OwnerImpl.java 2009-07-21 01:25:22 UTC (rev 17172)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/OwnerImpl.java 2009-07-21 02:07:50 UTC (rev 17173)
@@ -1,11 +1,7 @@
//$Id$
package org.hibernate.test.annotations.target;
-import java.util.Map;
-import java.util.HashMap;
import javax.persistence.Embeddable;
-import org.hibernate.annotations.MapKey;
-import javax.persistence.ManyToMany;
/**
* @author Emmanuel Bernard
15 years, 4 months
Hibernate SVN: r17172 - in core/trunk/annotations/src: test/java/org/hibernate/test/annotations/target and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-07-20 21:25:22 -0400 (Mon, 20 Jul 2009)
New Revision: 17172
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/Brand.java
Log:
ANN-855 implement @MapKeyClass
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java 2009-07-20 23:24:38 UTC (rev 17171)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java 2009-07-21 01:25:22 UTC (rev 17172)
@@ -29,6 +29,7 @@
import java.util.Random;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
+import javax.persistence.MapKeyClass;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
@@ -141,6 +142,9 @@
if ( property.isAnnotationPresent( org.hibernate.annotations.MapKey.class ) ) {
target = property.getAnnotation( org.hibernate.annotations.MapKey.class ).targetElement();
}
+ else if ( property.isAnnotationPresent( MapKeyClass.class ) ) {
+ target = property.getAnnotation( MapKeyClass.class ).value();
+ }
else if ( property.isAnnotationPresent( MapKeyManyToMany.class ) ) {
target = property.getAnnotation( MapKeyManyToMany.class ).targetEntity();
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/Brand.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/Brand.java 2009-07-20 23:24:38 UTC (rev 17171)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/Brand.java 2009-07-21 01:25:22 UTC (rev 17172)
@@ -27,6 +27,7 @@
@ElementCollection(targetClass = SizeImpl.class)
@MapKeyManyToMany(targetEntity = LuggageImpl.class)
+ //TODO @MapKeyClass(LuggageImpl.class)
private Map<Luggage, Size> sizePerLuggage = new HashMap<Luggage, Size>();
15 years, 4 months