Hibernate SVN: r16531 - core/trunk/annotations.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-05-11 09:17:21 -0400 (Mon, 11 May 2009)
New Revision: 16531
Modified:
core/trunk/annotations/pom.xml
Log:
removed unnecessary depedencyManagement section and changed the postgresql definition. Using classifier did not work for me (using maven 2.1.0)
Modified: core/trunk/annotations/pom.xml
===================================================================
--- core/trunk/annotations/pom.xml 2009-05-11 12:28:36 UTC (rev 16530)
+++ core/trunk/annotations/pom.xml 2009-05-11 13:17:21 UTC (rev 16531)
@@ -52,78 +52,44 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
+ <version>${version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
+ <version>${version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.java-persistence</groupId>
<artifactId>jpa-api</artifactId>
+ <version>2.0.Beta1</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<scope>test</scope>
+ <version>2.2</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
+ <version>1.0.CR3-SNAPSHOT</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
+ <version>4.0.0.Beta2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-commons-annotations</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate.java-persistence</groupId>
- <artifactId>jpa-api</artifactId>
- <version>2.0.Beta1</version>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.4.GA</version>
- </dependency>
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- <version>2.2</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>4.0.0.Beta2-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- <version>1.0.CR3-SNAPSHOT</version>
- </dependency>
-
- </dependencies>
- </dependencyManagement>
-
<build>
<testResources>
<testResource>
@@ -168,7 +134,6 @@
</plugins>
</build>
-
<profiles>
<profile>
<id>doc</id>
@@ -312,8 +277,7 @@
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
- <version>8.2-504</version>
- <classifier>jdbc3</classifier>
+ <version>8.2-504.jdbc3</version>
</dependency>
</dependencies>
<properties>
15 years, 6 months
Hibernate SVN: r16530 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-05-11 08:28:36 -0400 (Mon, 11 May 2009)
New Revision: 16530
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java
Log:
make annotation complie again with java 5
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java 2009-05-11 12:19:43 UTC (rev 16529)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java 2009-05-11 12:28:36 UTC (rev 16530)
@@ -1,5 +1,6 @@
package org.hibernate.test.annotations.beanvalidation;
+import java.lang.annotation.Annotation;
import java.math.BigDecimal;
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull;
@@ -8,7 +9,6 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.annotations.reflection.XMLContext;
import org.hibernate.test.annotations.TestCase;
/**
@@ -18,32 +18,39 @@
public void testListeners() {
CupHolder ch = new CupHolder();
ch.setRadius( new BigDecimal( "12" ) );
- Session s = openSession( );
+ Session s = openSession();
Transaction tx = s.beginTransaction();
try {
s.persist( ch );
s.flush();
}
catch ( ConstraintViolationException e ) {
- fail("invalid object should not be validated");
+ fail( "invalid object should not be validated" );
}
try {
ch.setRadius( null );
s.flush();
}
catch ( ConstraintViolationException e ) {
- fail("invalid object should not be validated");
+ fail( "invalid object should not be validated" );
}
try {
s.delete( ch );
s.flush();
- fail("invalid object should not be persisted");
+ fail( "invalid object should not be persisted" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );
- assertEquals( NotNull.class,
- e.getConstraintViolations().iterator().next().getConstraintDescriptor().getAnnotation().annotationType()
- );
+ // TODO - seems this explicit case is necessary with JDK 5 (at least on Mac). With Java 6 there is no problem
+ Annotation annotation = (Annotation) e.getConstraintViolations()
+ .iterator()
+ .next()
+ .getConstraintDescriptor()
+ .getAnnotation();
+ assertEquals(
+ NotNull.class,
+ annotation.annotationType()
+ );
}
tx.rollback();
s.close();
@@ -52,12 +59,18 @@
@Override
protected void configure(Configuration cfg) {
super.configure( cfg );
- cfg.setProperty( "javax.persistence.validation.group.pre-persist",
- "" );
- cfg.setProperty( "javax.persistence.validation.group.pre-update",
- "" );
- cfg.setProperty( "javax.persistence.validation.group.pre-remove",
- Default.class.getName() + ", " + Strict.class.getName() );
+ cfg.setProperty(
+ "javax.persistence.validation.group.pre-persist",
+ ""
+ );
+ cfg.setProperty(
+ "javax.persistence.validation.group.pre-update",
+ ""
+ );
+ cfg.setProperty(
+ "javax.persistence.validation.group.pre-remove",
+ Default.class.getName() + ", " + Strict.class.getName()
+ );
}
protected Class<?>[] getMappings() {
15 years, 6 months
Hibernate SVN: r16529 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validation/constraints/custom and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-05-11 08:19:43 -0400 (Mon, 11 May 2009)
New Revision: 16529
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/SingleThreadCachedTraversableResolver.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/BoundariesConstraintValidator.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/CustomConstraintValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/Positive.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/PositiveConstraintValidator.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Child.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ChildFirst.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Parent.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ParentSecond.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ProperOrder.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/CachedTraversableResolverTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Cloth.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Jacket.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/SnifferTraversableResolver.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Suit.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/TraversableResolverTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Trousers.java
Log:
added license header and enabled keyword substitution
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/SingleThreadCachedTraversableResolver.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/SingleThreadCachedTraversableResolver.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/SingleThreadCachedTraversableResolver.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.resolver;
import java.lang.annotation.ElementType;
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/SingleThreadCachedTraversableResolver.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/BoundariesConstraintValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/BoundariesConstraintValidator.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/BoundariesConstraintValidator.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.constraints.custom;
import java.lang.annotation.Annotation;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/BoundariesConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/CustomConstraintValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/CustomConstraintValidatorTest.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/CustomConstraintValidatorTest.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.constraints.custom;
import java.util.Set;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/CustomConstraintValidatorTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/Positive.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/Positive.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/Positive.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.constraints.custom;
import java.lang.annotation.Target;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/Positive.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/PositiveConstraintValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/PositiveConstraintValidator.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/PositiveConstraintValidator.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.constraints.custom;
/**
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/custom/PositiveConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Child.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Child.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Child.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.graphnavigation;
import javax.validation.constraints.NotNull;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Child.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ChildFirst.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ChildFirst.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ChildFirst.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.graphnavigation;
/**
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ChildFirst.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Parent.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Parent.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Parent.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.graphnavigation;
import javax.validation.constraints.NotNull;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Parent.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ParentSecond.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ParentSecond.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ParentSecond.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.graphnavigation;
/**
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ParentSecond.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ProperOrder.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ProperOrder.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ProperOrder.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.graphnavigation;
import javax.validation.GroupSequence;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ProperOrder.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/CachedTraversableResolverTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/CachedTraversableResolverTest.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/CachedTraversableResolverTest.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.resolver;
import java.lang.annotation.ElementType;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/CachedTraversableResolverTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Cloth.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Cloth.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Cloth.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.resolver;
/**
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Cloth.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Jacket.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Jacket.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Jacket.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.resolver;
import javax.validation.constraints.Max;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Jacket.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/SnifferTraversableResolver.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/SnifferTraversableResolver.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/SnifferTraversableResolver.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.resolver;
import java.lang.annotation.ElementType;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/SnifferTraversableResolver.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Suit.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Suit.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Suit.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.resolver;
import javax.validation.constraints.Max;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Suit.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/TraversableResolverTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/TraversableResolverTest.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/TraversableResolverTest.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.resolver;
import javax.validation.Configuration;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/TraversableResolverTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Trousers.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Trousers.java 2009-05-11 12:18:22 UTC (rev 16528)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Trousers.java 2009-05-11 12:19:43 UTC (rev 16529)
@@ -1,3 +1,20 @@
+// $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.resolver;
import javax.validation.constraints.Min;
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/Trousers.java
___________________________________________________________________
Name: svn:keywords
+ Id
15 years, 6 months
Hibernate SVN: r16528 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validation/constraints and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-05-11 08:18:22 -0400 (Mon, 11 May 2009)
New Revision: 16528
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DateHolder.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/FutureValidatorTest.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForCalendar.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForDate.java
Log:
HV-158 Fixed the validators and added a test
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForCalendar.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForCalendar.java 2009-05-11 10:54:59 UTC (rev 16527)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForCalendar.java 2009-05-11 12:18:22 UTC (rev 16528)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -20,7 +20,7 @@
import java.util.Calendar;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Past;
+import javax.validation.constraints.Future;
/**
* Check that the <code>java.util.Calendar</code> passed to be validated is in
@@ -28,9 +28,9 @@
*
* @author Alaa Nassef
*/
-public class FutureValidatorForCalendar implements ConstraintValidator<Past, Calendar> {
+public class FutureValidatorForCalendar implements ConstraintValidator<Future, Calendar> {
- public void initialize(Past constraintAnnotation) {
+ public void initialize(Future constraintAnnotation) {
}
public boolean isValid(Calendar cal, ConstraintValidatorContext constraintValidatorContext) {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForDate.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForDate.java 2009-05-11 10:54:59 UTC (rev 16527)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForDate.java 2009-05-11 12:18:22 UTC (rev 16528)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -20,7 +20,7 @@
import java.util.Date;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Past;
+import javax.validation.constraints.Future;
/**
* Check that the <code>java.util.Date</code> passed to be validated is in the
@@ -28,9 +28,9 @@
*
* @author Alaa Nassef
*/
-public class FutureValidatorForDate implements ConstraintValidator<Past, Date> {
+public class FutureValidatorForDate implements ConstraintValidator<Future, Date> {
- public void initialize(Past constraintAnnotation) {
+ public void initialize(Future constraintAnnotation) {
}
public boolean isValid(Date date, ConstraintValidatorContext constraintValidatorContext) {
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DateHolder.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DateHolder.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DateHolder.java 2009-05-11 12:18:22 UTC (rev 16528)
@@ -0,0 +1,67 @@
+// $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.constraints;
+
+import java.util.Calendar;
+import java.util.Date;
+import javax.validation.constraints.Past;
+import javax.validation.constraints.Future;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class DateHolder {
+
+ @Past
+ private Calendar calendarWithPastDate;
+
+ @Future
+ private Calendar calendarWithFutureDate;
+
+ @Past
+ private Date past;
+
+ @Past
+ private Date future;
+
+ public DateHolder() {
+ calendarWithPastDate = Calendar.getInstance();
+ calendarWithPastDate.add( Calendar.YEAR, -1 );
+ past = calendarWithPastDate.getTime();
+
+ calendarWithFutureDate = Calendar.getInstance();
+ calendarWithFutureDate.add( Calendar.YEAR, 1 );
+ future = calendarWithFutureDate.getTime();
+ }
+
+ public Calendar getCalendarWithPastDate() {
+ return calendarWithPastDate;
+ }
+
+ public Calendar getCalendarWithFutureDate() {
+ return calendarWithFutureDate;
+ }
+
+ public Date getPast() {
+ return past;
+ }
+
+ public Date getFuture() {
+ return future;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DateHolder.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/FutureValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/FutureValidatorTest.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/FutureValidatorTest.java 2009-05-11 12:18:22 UTC (rev 16528)
@@ -0,0 +1,45 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.validatorcontext;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.constraints.DateHolder;
+import org.hibernate.validation.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class FutureValidatorTest {
+
+ /**
+ * HV-158
+ */
+ @Test
+ public void testFutureAndPast() {
+ Validator validator = TestUtil.getValidator();
+ DateHolder dateHolder = new DateHolder();
+ Set<ConstraintViolation<DateHolder>> constraintViolations = validator.validate( dateHolder );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/FutureValidatorTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
15 years, 6 months
Hibernate SVN: r16527 - validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-05-11 06:54:59 -0400 (Mon, 11 May 2009)
New Revision: 16527
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/TraversableResolverTest.java
Log:
Made compilation work with Java5 - not sure why added cast is needed though.
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/TraversableResolverTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/TraversableResolverTest.java 2009-05-08 15:48:28 UTC (rev 16526)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/resolver/TraversableResolverTest.java 2009-05-11 10:54:59 UTC (rev 16527)
@@ -1,12 +1,13 @@
package org.hibernate.validation.engine.resolver;
+import javax.validation.Configuration;
import javax.validation.Validation;
+import javax.validation.Validator;
import javax.validation.ValidatorFactory;
-import javax.validation.Validator;
import javax.validation.groups.Default;
+import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
-import static org.testng.Assert.*;
/**
* @author Emmanuel Bernard
@@ -15,16 +16,18 @@
@Test
public void testCorrectPathsAreRequested() {
Suit suit = new Suit();
- suit.setTrousers( new Trousers() );
- suit.setJacket( new Jacket() );
- suit.setSize( 3333 );
- suit.getTrousers().setLength( 32321 );
- suit.getJacket().setWidth( 432432 );
+ suit.setTrousers( new Trousers() );
+ suit.setJacket( new Jacket() );
+ suit.setSize( 3333 );
+ suit.getTrousers().setLength( 32321 );
+ suit.getJacket().setWidth( 432432 );
- SnifferTraversableResolver resolver = new SnifferTraversableResolver(suit);
- ValidatorFactory factory = Validation.byDefaultProvider()
- .configure().traversableResolver( resolver )
- .buildValidatorFactory();
+ SnifferTraversableResolver resolver = new SnifferTraversableResolver( suit );
+
+ // TODO - Investigate why this cast is needed with Java 5. In Java 6 there is no problem.
+ Configuration<?> config = (Configuration<?>) Validation.byDefaultProvider().configure().traversableResolver( resolver );
+
+ ValidatorFactory factory = config.buildValidatorFactory();
Validator v = factory.getValidator();
//Raises an IllegalStateException if something goes wrong
15 years, 6 months
Hibernate SVN: r16526 - core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/tuple.
by hibernate-commits@lists.jboss.org
Author: cbredesen
Date: 2009-05-08 11:48:28 -0400 (Fri, 08 May 2009)
New Revision: 16526
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/tuple/EntityModeToTuplizerMapping.java
Log:
JBPAPP-1922 / HHH-2645 - Synchronization bottleneck in EntityModeToTuplizerMapping
Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/tuple/EntityModeToTuplizerMapping.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/tuple/EntityModeToTuplizerMapping.java 2009-05-08 01:12:20 UTC (rev 16525)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/tuple/EntityModeToTuplizerMapping.java 2009-05-08 15:48:28 UTC (rev 16526)
@@ -1,72 +1,78 @@
-package org.hibernate.tuple;
-
-import org.apache.commons.collections.SequencedHashMap;
-
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-
-import java.util.Map;
-import java.util.Collections;
-import java.util.Iterator;
-import java.io.Serializable;
-
-/**
- * Centralizes handling of {@link EntityMode} to {@link Tuplizer} mappings.
- *
- * @author Steve Ebersole
- */
-public abstract class EntityModeToTuplizerMapping implements Serializable {
-
- // map of EntityMode -> Tuplizer
- private final Map tuplizers = Collections.synchronizedMap( new SequencedHashMap() );
-
- protected void addTuplizer(EntityMode entityMode, Tuplizer tuplizer) {
- tuplizers.put( entityMode, tuplizer );
- }
-
- /**
- * Given a supposed instance of an entity/component, guess its entity mode.
- *
- * @param object The supposed instance of the entity/component.
- * @return The guessed entity mode.
- */
- public EntityMode guessEntityMode(Object object) {
- Iterator itr = tuplizers.entrySet().iterator();
- while( itr.hasNext() ) {
- Map.Entry entry = ( Map.Entry ) itr.next();
- Tuplizer tuplizer = ( Tuplizer ) entry.getValue();
- if ( tuplizer.isInstance( object ) ) {
- return ( EntityMode ) entry.getKey();
- }
- }
- return null;
- }
-
- /**
- * Locate the contained tuplizer responsible for the given entity-mode. If
- * no such tuplizer is defined on this mapping, then return null.
- *
- * @param entityMode The entity-mode for which the caller wants a tuplizer.
- * @return The tuplizer, or null if not found.
- */
- public Tuplizer getTuplizerOrNull(EntityMode entityMode) {
- return ( Tuplizer ) tuplizers.get( entityMode );
- }
-
- /**
- * Locate the tuplizer contained within this mapping which is responsible
- * for the given entity-mode. If no such tuplizer is defined on this
- * mapping, then an exception is thrown.
- *
- * @param entityMode The entity-mode for which the caller wants a tuplizer.
- * @return The tuplizer.
- * @throws HibernateException Unable to locate the requested tuplizer.
- */
- public Tuplizer getTuplizer(EntityMode entityMode) {
- Tuplizer tuplizer = getTuplizerOrNull( entityMode );
- if ( tuplizer == null ) {
- throw new HibernateException( "No tuplizer found for entity-mode [" + entityMode + "]");
- }
- return tuplizer;
- }
-}
+package org.hibernate.tuple;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.util.FastHashMap;
+
+/**
+ * Centralizes handling of {@link EntityMode} to {@link Tuplizer} mappings.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class EntityModeToTuplizerMapping implements Serializable {
+
+ // map of EntityMode -> Tuplizer
+ private final Map tuplizers;
+
+ public EntityModeToTuplizerMapping() {
+ tuplizers = new FastHashMap();
+ }
+
+ public EntityModeToTuplizerMapping(Map tuplizers) {
+ this.tuplizers = tuplizers;
+ }
+
+ protected void addTuplizer(EntityMode entityMode, Tuplizer tuplizer) {
+ tuplizers.put( entityMode, tuplizer );
+ }
+
+ /**
+ * Given a supposed instance of an entity/component, guess its entity mode.
+ *
+ * @param object The supposed instance of the entity/component.
+ * @return The guessed entity mode.
+ */
+ public EntityMode guessEntityMode(Object object) {
+ Iterator itr = tuplizers.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry entry = ( Map.Entry ) itr.next();
+ Tuplizer tuplizer = ( Tuplizer ) entry.getValue();
+ if ( tuplizer.isInstance( object ) ) {
+ return ( EntityMode ) entry.getKey();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Locate the contained tuplizer responsible for the given entity-mode. If
+ * no such tuplizer is defined on this mapping, then return null.
+ *
+ * @param entityMode The entity-mode for which the caller wants a tuplizer.
+ * @return The tuplizer, or null if not found.
+ */
+ public Tuplizer getTuplizerOrNull(EntityMode entityMode) {
+ return ( Tuplizer ) tuplizers.get( entityMode );
+ }
+
+ /**
+ * Locate the tuplizer contained within this mapping which is responsible
+ * for the given entity-mode. If no such tuplizer is defined on this
+ * mapping, then an exception is thrown.
+ *
+ * @param entityMode The entity-mode for which the caller wants a tuplizer.
+ * @return The tuplizer.
+ * @throws HibernateException Unable to locate the requested tuplizer.
+ */
+ public Tuplizer getTuplizer(EntityMode entityMode) {
+ Tuplizer tuplizer = getTuplizerOrNull( entityMode );
+ if ( tuplizer == null ) {
+ throw new HibernateException( "No tuplizer found for entity-mode [" + entityMode + "]");
+ }
+ return tuplizer;
+ }
+}
15 years, 6 months
Hibernate SVN: r16525 - in core/trunk/cache-jbosscache2: src/test/java/org/hibernate/test/cache/jbc2/functional and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: pferraro
Date: 2009-05-07 21:12:20 -0400 (Thu, 07 May 2009)
New Revision: 16525
Modified:
core/trunk/cache-jbosscache2/pom.xml
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/MVCCConcurrentWriteTest.java
Log:
Upgraded JBoss Cache to 3.1.0.GA
Enable org.hibernate.test.cache.jbc2.functional.MVCCConcurrentWriteTest.testManyUsers() now that JBCACHE-1494 is fixed
Modified: core/trunk/cache-jbosscache2/pom.xml
===================================================================
--- core/trunk/cache-jbosscache2/pom.xml 2009-05-07 21:35:18 UTC (rev 16524)
+++ core/trunk/cache-jbosscache2/pom.xml 2009-05-08 01:12:20 UTC (rev 16525)
@@ -25,7 +25,7 @@
<dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
- <version>3.0.3.GA</version>
+ <version>3.1.0.GA</version>
</dependency>
<!-- test dependencies -->
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/MVCCConcurrentWriteTest.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/MVCCConcurrentWriteTest.java 2009-05-07 21:35:18 UTC (rev 16524)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/MVCCConcurrentWriteTest.java 2009-05-08 01:12:20 UTC (rev 16525)
@@ -202,7 +202,7 @@
*
* @throws Exception
*/
- public void testManyUsersFailureExpected() throws Exception {
+ public void testManyUsers() throws Exception {
//setup - create users
for (int i = 0; i < USER_COUNT; i++) {
15 years, 6 months
Hibernate SVN: r16524 - core/trunk/annotations/src/main/docbook/en/modules.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-05-07 17:35:18 -0400 (Thu, 07 May 2009)
New Revision: 16524
Modified:
core/trunk/annotations/src/main/docbook/en/modules/additionalmodules.xml
Log:
ANN-827 ANN-828 doc for Hibernate Validation
Modified: core/trunk/annotations/src/main/docbook/en/modules/additionalmodules.xml
===================================================================
--- core/trunk/annotations/src/main/docbook/en/modules/additionalmodules.xml 2009-05-07 21:34:21 UTC (rev 16523)
+++ core/trunk/annotations/src/main/docbook/en/modules/additionalmodules.xml 2009-05-07 21:35:18 UTC (rev 16524)
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
@@ -22,18 +22,242 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="additionalmodules">
<title>Additional modules</title>
<para>Hibernate Annotations mainly focus on persistence metadata. The
- project also have a nice integration with two Hibernate modules.</para>
+ project also have a nice integration with some external modules.</para>
<section>
- <title>Hibernate Validator</title>
+ <title>Bean Validation</title>
+ <para>Bean Validation standardizes how to define and declare domain model
+ level constraints. You can, for example, express that a property should
+ never be null, that the account balance should be strictly positive, etc.
+ These domain model constraints are declared in the bean itself by
+ annotating its properties. Bean Validation can then read them and check
+ for constraint violations. The validation mechanism can be executed in
+ different layers in your application without having to duplicate any of
+ these rules (presentation layer, data access layer). Following the DRY
+ principle, Bean Validation and its reference implementation Hibernate
+ Validator has been designed for that purpose.</para>
+
+ <para>The integration between Hibernate and Bean Validation works at two
+ levels. First, it is able to check in-memory instances of a class for
+ constraint violations. Second, it can apply the constraints to the
+ Hibernate metamodel and incorporate them into the generated database
+ schema.</para>
+
+ <para>Each constraint annotation is associated to a validator
+ implementation responsible for checking the constraint on the entity
+ instance. A validator can also (optionally) apply the constraint to the
+ Hibernate metamodel, allowing Hibernate to generate DDL that expresses the
+ constraint. With the appropriate event listener, you can execute the
+ checking operation on inserts, updates and deletes done by
+ Hibernate.</para>
+
+ <para>When checking instances at runtime, Hibernate Validator returns
+ information about constraint violations in a set of
+ <classname>ConstraintViolation</classname>s. Among other information, the
+ <classname>ConstraintViolation</classname> contains an error description
+ message that can embed the parameter values bundle with the annotation
+ (eg. size limit), and message strings that may be externalized to a
+ <classname>ResourceBundle</classname>.</para>
+
<section>
+ <title>Adding Bean Validation</title>
+
+ <para>To enable the Hibernate - Bean Validation integration, simply add
+ a Bean Validation provider (preferably Hibernate Validation 4) in your
+ classpath. </para>
+ </section>
+
+ <section>
+ <title>Configuration</title>
+
+ <para>By default, no configuration is necessary.</para>
+
+ <para>The <classname>Default</classname> group is validated on entity
+ insert and update and the database model is updated accordingly based on
+ the <classname>Default</classname> group as well.</para>
+
+ <para>You can customize the Bean Validation integration by setting the
+ validation mode. Use the
+ <literal>javax.persistence.validation.mode</literal> property and set it
+ up for example in your <filename>persistence.xml</filename> file.
+ Several options are possible:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><literal>auto</literal> (default): enable integration between
+ Bean Validation and Hibernate (callback and ddl generation) only if
+ Bean Validation is present in the classpath.</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>none</literal>: disable all integration between Bean
+ Validation and Hibernate</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>callback</literal>: only validate entities when they
+ are either inserted, updated or deleted. An exception is raised if
+ no Bean Validation provider is present in the classpath.</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>ddl</literal>: only apply constraints to the database
+ schema when generated by Hibernate. An exception is raised if no
+ Bean Validation provider is present in the classpath. This value is
+ not defined by the Java Persistence spec and is specific to
+ Hibernate.</para>
+ </listitem>
+ </itemizedlist>
+
+ <note>
+ <para>You can use both <literal>callback</literal> and
+ <literal>ddl</literal> together by setting the property to
+ <literal>callback, dll</literal></para>
+
+ <programlisting><persistence ...>
+ <persistence-unit ...>
+ ...
+ <properties>
+ <property name="javax.persistence.validation.mode"
+ value="callback, ddl"/>
+ </properties>
+ </persistence-unit>
+</persistence></programlisting>
+
+ <para>This is equivalent to <literal>auto</literal> except that if no
+ Bean Validation provider is present, an exception is raised.</para>
+ </note>
+
+ <para>If you want to validate different groups during insertion, update
+ and deletion, use:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><literal>javax.persistence.validation.group.pre-persist</literal>:
+ groups validated when an entity is about to be persisted (default to
+ <classname>Default</classname>)</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>javax.persistence.validation.group.pre-update</literal>:
+ groups validated when an entity is about to be updated (default to
+ <classname>Default</classname>)</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>javax.persistence.validation.group.pre-remove</literal>:
+ groups validated when an entity is about to be deleted (default to
+ no group)</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>org.hibernate.validator.group.ddl</literal>: groups
+ considered when applying constraints on the database schema (default
+ to <classname>Default</classname>)</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Each property accepts the fully qualified class names of the
+ groups validated separated by a comma (,)</para>
+
+ <example>
+ <title>Using custom groups for validation</title>
+
+ <programlisting><persistence ...>
+ <persistence-unit ...>
+ ...
+ <properties>
+ <property name="<literal>javax.persistence.validation.group.pre-update</literal>"
+ value="javax.validation.group.Default, com.acme.group.Strict"/>
+ <property name="<literal>javax.persistence.validation.group.pre-remove</literal>"
+ value="com.acme.group.OnDelete"/>
+ <property name="<literal>org.hibernate.validator.group.ddl</literal>"
+ value="com.acme.group.DDL"/>
+ </properties>
+ </persistence-unit>
+</persistence></programlisting>
+ </example>
+
+ <note>
+ <para>You can set these properties in
+ <filename>hibernate.cfg.xml</filename>,
+ <filename>hibernate.properties</filename> or programmatically.</para>
+ </note>
+ </section>
+
+ <section>
+ <title>Catching violations</title>
+
+ <para>If an entity is found to be invalid, the list of constraint
+ violations is propagated by the
+ <classname>ConstraintViolationException</classname> which exposes the
+ set of <classname>ConstraintViolation</classname>s.</para>
+
+ <para>This exception is wrapped into an
+ <classname>HibernateException</classname> or a
+ <classname>PersistenceException</classname>. Note that generally,
+ catchable violation are validated at a higher level (for example in Seam
+ / JSF 2 via the JSF - Bean Validation integration or in your business
+ layer by explicitly calling Bean Validation).</para>
+
+ <para>An application code will rarely be looking for a
+ <classname>ConstraintViolationException</classname> raised by Hibernate.
+ This exception should be treated as fatal and the persistence context
+ should be discarded (<classname>EntityManager</classname> or
+ <classname>Session</classname>).</para>
+ </section>
+
+ <section>
+ <title>Database schema</title>
+
+ <para>Hibernate uses Bean Validation constraints to generate an accurate
+ database schema:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><classname>@NotNull</classname> leads to a not null column
+ (unless it conflicts with components or table inheritance)</para>
+ </listitem>
+
+ <listitem>
+ <para><classname>@Size.max</classname> leads to a
+ <literal>varchar(max)</literal> definition for Strings</para>
+ </listitem>
+
+ <listitem>
+ <para><classname>@Min</classname>, <classname>@Max</classname> lead
+ to column checks (like <code>value <= max</code>) </para>
+ </listitem>
+
+ <listitem>
+ <para><classname>@Digits</classname> leads to the definition of
+ precision and scale (ever wondered which is which? It's easy now
+ with <classname>@Digits</classname> :) )</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>These constraints can be declared directly on the entity
+ properties or indirectly by using constraint composition.</para>
+ </section>
+ </section>
+
+ <section>
+ <title>Hibernate Validator 3</title>
+
+ <warning>
+ <para>We strongly encourage you to use Hibernate Validator 4 and the
+ Bean Validation integration. Consider Hibernate Validator 3 as
+ legacy.</para>
+ </warning>
+
+ <section>
<title>Description</title>
<para>Annotations are a very convenient and elegant way to specify
15 years, 6 months
Hibernate SVN: r16523 - in core/trunk: annotations/src/main/java/org/hibernate/cfg and 21 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-05-07 17:34:21 -0400 (Thu, 07 May 2009)
New Revision: 16523
Modified:
core/trunk/annotations/pom.xml
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/reflection/JPAOverridenAnnotationReader.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/array/Contest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/Screen.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/A.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/B.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/indexedCollection/Sale.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.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/cache-jbosscache2/pom.xml
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/PackagedEntityManagerTest.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/connection/PersistenceUnitInfoImpl.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/emops/cascade/CascadePersistTest.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java
core/trunk/envers/pom.xml
core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java
core/trunk/envers/src/main/java/org/jboss/envers/VersionsReaderFactory.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/flush/AbstractFlushTest.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/various/HsqlTest.java
Log:
HHH-3906 EJB-436 ANN-830 Move to JPA 2 API as a dependency
Modified: core/trunk/annotations/pom.xml
===================================================================
--- core/trunk/annotations/pom.xml 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/pom.xml 2009-05-07 21:34:21 UTC (rev 16523)
@@ -58,8 +58,8 @@
<artifactId>hibernate-commons-annotations</artifactId>
</dependency>
<dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
+ <groupId>org.hibernate.java-persistence</groupId>
+ <artifactId>jpa-api</artifactId>
</dependency>
<dependency>
<groupId>javassist</groupId>
@@ -96,9 +96,9 @@
<version>${version}</version>
</dependency>
<dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
+ <groupId>org.hibernate.java-persistence</groupId>
+ <artifactId>jpa-api</artifactId>
+ <version>2.0.Beta1</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -70,6 +70,7 @@
import javax.persistence.TableGenerator;
import javax.persistence.Transient;
import javax.persistence.Version;
+import javax.persistence.ElementCollection;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
@@ -1238,7 +1239,9 @@
}
else if ( joinColumns == null &&
( property.isAnnotationPresent( OneToMany.class )
- || property.isAnnotationPresent( CollectionOfElements.class ) ) ) {
+ || property.isAnnotationPresent( CollectionOfElements.class ) //legacy Hibernate
+ || property.isAnnotationPresent( ElementCollection.class )
+ ) ) {
OneToMany oneToMany = property.getAnnotation( OneToMany.class );
String mappedBy = oneToMany != null ?
oneToMany.mappedBy() :
@@ -1454,11 +1457,13 @@
}
else if ( property.isAnnotationPresent( OneToMany.class )
|| property.isAnnotationPresent( ManyToMany.class )
- || property.isAnnotationPresent( CollectionOfElements.class )
+ || property.isAnnotationPresent( CollectionOfElements.class ) //legacy Hibernate
+ || property.isAnnotationPresent( ElementCollection.class )
|| property.isAnnotationPresent( ManyToAny.class ) ) {
OneToMany oneToManyAnn = property.getAnnotation( OneToMany.class );
ManyToMany manyToManyAnn = property.getAnnotation( ManyToMany.class );
- CollectionOfElements collectionOfElementsAnn = property.getAnnotation( CollectionOfElements.class );
+ ElementCollection elementCollectionAnn = property.getAnnotation( ElementCollection.class );
+ CollectionOfElements collectionOfElementsAnn = property.getAnnotation( CollectionOfElements.class ); //legacy hibernate
org.hibernate.annotations.IndexColumn indexAnn = property.getAnnotation(
org.hibernate.annotations.IndexColumn.class
);
@@ -1585,7 +1590,9 @@
collectionBinder.setCascadeStrategy( getCascadeStrategy( oneToManyAnn.cascade(), hibernateCascade ) );
collectionBinder.setOneToMany( true );
}
- else if ( collectionOfElementsAnn != null ) {
+ else if ( elementCollectionAnn != null
+ || collectionOfElementsAnn != null //Hibernate legacy
+ ) {
for (Ejb3JoinColumn column : joinColumns) {
if ( column.isSecondary() ) {
throw new NotYetImplementedException( "Collections having FK in secondary table" );
@@ -1593,8 +1600,11 @@
}
collectionBinder.setFkJoinColumns( joinColumns );
mappedBy = "";
+ final Class<?> targetElement = elementCollectionAnn != null ?
+ elementCollectionAnn.targetClass() :
+ collectionOfElementsAnn.targetElement();
collectionBinder.setTargetEntity(
- mappings.getReflectionManager().toXClass( collectionOfElementsAnn.targetElement() )
+ mappings.getReflectionManager().toXClass( targetElement )
);
//collectionBinder.setCascadeStrategy( getCascadeStrategy( embeddedCollectionAnn.cascade(), hibernateCascade ) );
collectionBinder.setOneToMany( true );
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-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -38,6 +38,7 @@
import javax.persistence.ManyToMany;
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
+import javax.persistence.ElementCollection;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
@@ -449,7 +450,9 @@
tableBinder, mappings
);
if ( collectionType.isAnnotationPresent( Embeddable.class )
- || property.isAnnotationPresent( CollectionOfElements.class ) ) {
+ || property.isAnnotationPresent( CollectionOfElements.class ) //legacy hibernate
+ || property.isAnnotationPresent( ElementCollection.class ) //JPA 2
+ ) {
// do it right away, otherwise @ManyToon on composite element call addSecondPass
// and raise a ConcurrentModificationException
//sp.doSecondPass( CollectionHelper.EMPTY_MAP );
@@ -483,7 +486,8 @@
Fetch fetch = property.getAnnotation( Fetch.class );
OneToMany oneToMany = property.getAnnotation( OneToMany.class );
ManyToMany manyToMany = property.getAnnotation( ManyToMany.class );
- CollectionOfElements elements = property.getAnnotation( CollectionOfElements.class );
+ CollectionOfElements collectionOfElements = property.getAnnotation( CollectionOfElements.class ); //legacy hibernate
+ ElementCollection elementCollection = property.getAnnotation( ElementCollection.class ); //jpa 2
ManyToAny manyToAny = property.getAnnotation( ManyToAny.class );
FetchType fetchType;
if ( oneToMany != null ) {
@@ -492,9 +496,12 @@
else if ( manyToMany != null ) {
fetchType = manyToMany.fetch();
}
- else if ( elements != null ) {
- fetchType = elements.fetch();
+ else if ( elementCollection != null ) {
+ fetchType = elementCollection.fetch();
}
+ else if ( collectionOfElements != null ) {
+ fetchType = collectionOfElements.fetch();
+ }
else if ( manyToAny != null ) {
fetchType = FetchType.LAZY;
}
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverridenAnnotationReader.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverridenAnnotationReader.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverridenAnnotationReader.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -102,6 +102,7 @@
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
+import javax.persistence.ElementCollection;
import org.dom4j.Attribute;
import org.dom4j.Element;
@@ -563,7 +564,8 @@
defaultToJoinTable = defaultToJoinTable &&
( ( annotationClass == ManyToMany.class && StringHelper.isEmpty( ( (ManyToMany) annotation ).mappedBy() ) )
|| ( annotationClass == OneToMany.class && StringHelper.isEmpty( ( (OneToMany) annotation ).mappedBy() ) )
- || ( annotationClass == CollectionOfElements.class )
+ || ( annotationClass == CollectionOfElements.class ) //legacy Hibernate
+ || ( annotationClass == ElementCollection.class )
);
final Class<JoinTable> annotationType = JoinTable.class;
if ( defaultToJoinTable
@@ -699,7 +701,41 @@
annotation = getJavaAnnotation( Columns.class );
addIfNotNull( annotationList, annotation );
}
- else if ( isJavaAnnotationPresent( CollectionOfElements.class ) ) {
+ else if ( isJavaAnnotationPresent( ElementCollection.class ) ) { //JPA2
+ annotation = overridesDefaultsInJoinTable( getJavaAnnotation( ElementCollection.class ), defaults );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( JoinColumn.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( JoinColumns.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( PrimaryKeyJoinColumn.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( PrimaryKeyJoinColumns.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( MapKey.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( OrderBy.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( AttributeOverride.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( AttributeOverrides.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( AssociationOverride.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( AssociationOverrides.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( Lob.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( Enumerated.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( Temporal.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( Column.class );
+ addIfNotNull( annotationList, annotation );
+ annotation = getJavaAnnotation( Columns.class );
+ addIfNotNull( annotationList, annotation );
+ }
+ else if ( isJavaAnnotationPresent( CollectionOfElements.class ) ) { //legacy Hibernate
annotation = overridesDefaultsInJoinTable( getJavaAnnotation( CollectionOfElements.class ), defaults );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( JoinColumn.class );
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/array/Contest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/array/Contest.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/array/Contest.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -7,6 +7,7 @@
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
+import javax.persistence.ElementCollection;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.IndexColumn;
@@ -40,7 +41,7 @@
this.results = results;
}
- @CollectionOfElements
+ @ElementCollection
@IndexColumn(name = "pos", base=1)
public Month[] getHeldIn() {
return heldIn;
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/Screen.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/Screen.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/Screen.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -8,6 +8,7 @@
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.CascadeType;
+import javax.persistence.ElementCollection;
import javax.validation.constraints.NotNull;
import javax.validation.Valid;
@@ -54,7 +55,8 @@
this.powerSupply = powerSupply;
}
- @CollectionOfElements @Valid
+ @ElementCollection
+ @Valid
public Set<DisplayConnector> getConnectors() {
return connectors;
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -16,6 +16,7 @@
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
+import javax.persistence.ElementCollection;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.IndexColumn;
@@ -66,7 +67,7 @@
this.lastName = lastName;
}
- @CollectionOfElements
+ @CollectionOfElements //keep hibernate legacy for test purposes
public Set<String> getNickNames() {
return nickNames;
}
@@ -75,7 +76,7 @@
this.nickNames = nickName;
}
- @CollectionOfElements
+ @ElementCollection
@JoinTable(name = "ScorePerNickName", joinColumns = @JoinColumn(name = "BoyId"))
@Column(name = "score", nullable = false)
public Map<String, Integer> getScorePerNickName() {
@@ -86,7 +87,7 @@
this.scorePerNickName = scorePerNickName;
}
- @CollectionOfElements
+ @ElementCollection
@JoinTable(
name = "BoyFavoriteNumbers",
joinColumns = @JoinColumn(name = "BoyId")
@@ -101,7 +102,7 @@
this.favoriteNumbers = favoriteNumbers;
}
- @CollectionOfElements
+ @CollectionOfElements //TODO migration to ElementCollection "element.serial"??
@AttributeOverride(name = "element.serial", column = @Column(name = "serial_nbr"))
public Set<Toy> getFavoriteToys() {
return favoriteToys;
@@ -111,7 +112,7 @@
this.favoriteToys = favoriteToys;
}
- @CollectionOfElements
+ @ElementCollection
@Enumerated(EnumType.STRING)
public Set<Character> getCharacters() {
return characters;
@@ -121,7 +122,7 @@
this.characters = characters;
}
- @CollectionOfElements(fetch = FetchType.EAGER)
+ @ElementCollection(fetch = FetchType.EAGER)
//@Where(clause = "b_likes=false")
public Set<CountryAttitude> getCountryAttitudes() {
return countryAttitudes;
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-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -1,18 +1,18 @@
//$Id$
package org.hibernate.test.annotations.collectionelement;
+import java.io.Serializable;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
-import java.util.Locale;
-import java.io.Serializable;
import javax.persistence.Column;
+import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
-import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.Fetch;
-import org.hibernate.annotations.MapKey;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Filter;
+import org.hibernate.annotations.MapKey;
/**
* @author Emmanuel Bernard
@@ -32,7 +32,7 @@
private Map<String, String> variations =
new HashMap<String, String>( 1 );
- @CollectionOfElements
+ @ElementCollection
@MapKey( columns = @Column( name = "language_code" ) )
@Fetch( FetchMode.JOIN )
@Filter( name = "selectedLocale",
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -4,12 +4,11 @@
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
-
+import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
-import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.MapKey;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortType;
@@ -25,7 +24,7 @@
private Integer id;
@MapKey(type = @Type(type="integer") )
- @CollectionOfElements
+ @ElementCollection
@Sort(type = SortType.NATURAL)
@Type(type = "float")
private SortedMap<Integer, Float> values = new TreeMap<Integer, Float>();
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/A.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/A.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/A.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -6,6 +6,7 @@
*/
import java.util.List;
+import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@@ -13,7 +14,6 @@
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
-import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.IndexColumn;
@Entity
@@ -23,7 +23,7 @@
@GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "aSequence" )
@SequenceGenerator( name = "aSequence", sequenceName = "seq_A" )
private int id;
- @CollectionOfElements
+ @ElementCollection
@IndexColumn( name = "ndx" )
private List<B> listOfB;
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/B.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/B.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/B.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -3,10 +3,8 @@
import java.util.List;
import javax.persistence.Embeddable;
-import javax.persistence.Transient;
import javax.persistence.OneToMany;
-import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.IndexColumn;
@Embeddable
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/indexedCollection/Sale.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/indexedCollection/Sale.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/indexedCollection/Sale.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -23,7 +23,7 @@
public class Sale {
@Id @GeneratedValue private Integer id;
- @CollectionOfElements
+ @CollectionOfElements //TODO migrate to @ElementCollection, what about @CollectionId
@JoinTable(
name = "contact",
joinColumns = @JoinColumn(name = "n_key_person"))
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -6,9 +6,10 @@
* @author Edward Costello
* @author Paolo Perrotta
*/
+
import java.util.HashSet;
import java.util.Set;
-
+import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;
import javax.persistence.Entity;
@@ -16,8 +17,6 @@
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import org.hibernate.annotations.CollectionOfElements;
-
public class Classes {
@Embeddable
@@ -41,7 +40,7 @@
@GeneratedValue(strategy=GenerationType.AUTO)
Long id;
- @CollectionOfElements
+ @ElementCollection
Set<Edition<String>> editions = new HashSet<Edition<String>>();
}
}
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-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/indexcoll/Atmosphere.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -34,7 +34,7 @@
@JoinTable(name = "Gas_per_key")
public Map<GasKey, Gas> gasesPerKey = new HashMap<GasKey, Gas>();
- @CollectionOfElements
+ @CollectionOfElements //TODO migrate to @ElementCollection ; @MapKeyManyToMany ??
@Column(name="composition_rate")
@MapKeyManyToMany(joinColumns = @JoinColumn(name="gas_id"))
@JoinTable(name = "Composition", joinColumns = @JoinColumn(name = "atmosphere_id"))
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-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/target/Brand.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -1,15 +1,15 @@
//$Id$
package org.hibernate.test.annotations.target;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
+import javax.persistence.ElementCollection;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
import javax.persistence.ManyToMany;
import org.hibernate.annotations.MapKey;
-import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.MapKeyManyToMany;
/**
@@ -25,7 +25,7 @@
@MapKey(targetElement = SizeImpl.class)
private Map<Size, Luggage> luggagesBySize = new HashMap<Size, Luggage>();
- @CollectionOfElements(targetElement = SizeImpl.class)
+ @ElementCollection(targetClass = SizeImpl.class)
@MapKeyManyToMany(targetEntity = LuggageImpl.class)
private Map<Luggage, Size> sizePerLuggage = new HashMap<Luggage, Size>();
Modified: core/trunk/cache-jbosscache2/pom.xml
===================================================================
--- core/trunk/cache-jbosscache2/pom.xml 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/cache-jbosscache2/pom.xml 2009-05-07 21:34:21 UTC (rev 16523)
@@ -56,10 +56,9 @@
</dependency>
<dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- <scope>test</scope>
+ <groupId>org.hibernate.java-persistence</groupId>
+ <artifactId>jpa-api</artifactId>
+ <version>2.0.Beta1</version>
</dependency>
</dependencies>
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, the OpenSource EJB server Distributable under LGPL license. See terms of license at
* gnu.org.
@@ -10,6 +10,7 @@
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Map;
+import java.util.Set;
import javax.persistence.EntityNotFoundException;
import javax.persistence.EntityTransaction;
@@ -22,6 +23,10 @@
import javax.persistence.PersistenceException;
import javax.persistence.Query;
import javax.persistence.TransactionRequiredException;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.metamodel.Metamodel;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.QueryBuilder;
import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.transaction.Status;
import javax.transaction.Synchronization;
@@ -98,6 +103,10 @@
}
}
+ public Query createQuery(CriteriaQuery criteriaQuery) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Query createNamedQuery(String name) {
//adjustFlushMode();
org.hibernate.Query namedQuery;
@@ -204,6 +213,21 @@
}
}
+ public <T> T find(Class<T> tClass, Object o, Map<String, Object> stringObjectMap) {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public <T> T find(Class<T> tClass, Object o, LockModeType lockModeType) {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public <T> T find(Class<T> tClass, Object o, LockModeType lockModeType, Map<String, Object> stringObjectMap) {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
private void checkTransactionNeeded() {
if ( persistenceContextType == PersistenceContextType.TRANSACTION && ! isTransactionInProgress() ) {
//no need to mark as rollback, no tx in progress
@@ -277,6 +301,21 @@
}
}
+ public void refresh(Object o, Map<String, Object> stringObjectMap) {
+ //FIXME
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void refresh(Object o, LockModeType lockModeType) {
+ //FIXME
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void refresh(Object o, LockModeType lockModeType, Map<String, Object> stringObjectMap) {
+ //FIXME
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public boolean contains(Object entity) {
try {
if ( entity != null
@@ -295,6 +334,26 @@
}
}
+ public LockModeType getLockMode(Object o) {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setProperty(String s, Object o) {
+ //FIXME
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Map<String, Object> getProperties() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Set<String> getSupportedProperties() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public void flush() {
try {
if ( ! isTransactionInProgress() ) {
@@ -326,6 +385,21 @@
return tx;
}
+ public EntityManagerFactory getEntityManagerFactory() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public QueryBuilder getQueryBuilder() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Metamodel getMetamodel() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public void setFlushMode(FlushModeType flushModeType) {
this.flushModeType = flushModeType;
if ( flushModeType == FlushModeType.AUTO ) {
@@ -349,6 +423,10 @@
}
}
+ public void detach(Object entity) {
+ getSession().evict( entity );
+ }
+
public FlushModeType getFlushMode() {
FlushMode mode = getSession().getFlushMode();
if ( mode == FlushMode.AUTO ) {
@@ -387,6 +465,11 @@
}
}
+ public void lock(Object o, LockModeType lockModeType, Map<String, Object> stringObjectMap) {
+ //FIXME
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
private LockMode getLockMode(LockModeType lockMode) {
switch ( lockMode ) {
case READ:
@@ -431,6 +514,13 @@
joinTransaction( false );
}
+ public <T> T unwrap(Class<T> clazz) {
+ if (clazz.equals( Session.class ) ) return (T) getSession();
+ if (clazz.equals( SessionImplementor.class ) ) return (T) getSession();
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
private void joinTransaction(boolean ignoreNotJoining) {
//set the joined status
getSession().isOpen(); //for sync
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -2,8 +2,12 @@
package org.hibernate.ejb;
import java.util.Map;
+import java.util.Set;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContextType;
+import javax.persistence.Cache;
+import javax.persistence.metamodel.Metamodel;
+import javax.persistence.criteria.QueryBuilder;
import javax.persistence.spi.PersistenceUnitTransactionType;
import org.hibernate.SessionFactory;
@@ -42,10 +46,35 @@
);
}
+ public QueryBuilder getQueryBuilder() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Metamodel getMetamodel() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public void close() {
sessionFactory.close();
}
+ public Map<String, Object> getProperties() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Set<String> getSupportedProperties() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Cache getCache() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public boolean isOpen() {
return ! sessionFactory.isClosed();
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -2,9 +2,24 @@
package org.hibernate.ejb;
import java.util.Map;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceException;
import javax.persistence.spi.PersistenceUnitInfo;
+import javax.persistence.spi.LoadState;
+import org.hibernate.Hibernate;
+import org.hibernate.intercept.FieldInterceptionHelper;
+import org.hibernate.intercept.FieldInterceptor;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.proxy.HibernateProxy;
+import org.hibernate.proxy.LazyInitializer;
+
/**
* Hibernate EJB3 persistence provider implementation
*
@@ -132,7 +147,136 @@
return configured != null ? configured.buildEntityManagerFactory() : null;
}
+ public LoadState isLoadedWithoutReference(Object proxy, String property) {
+ Object entity;
+ boolean sureFromUs = false;
+ if ( proxy instanceof HibernateProxy ) {
+ LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
+ if ( li.isUninitialized() ) {
+ return LoadState.NOT_LOADED;
+ }
+ else {
+ entity = li.getImplementation();
+ }
+ sureFromUs = true;
+ }
+ else {
+ entity = proxy;
+ }
+
+ //we are instrumenting but we can't assume we are the only ones
+ if ( FieldInterceptionHelper.isInstrumented( entity ) ) {
+ FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity );
+ final boolean isInitialized = interceptor == null || interceptor.isInitialized( property );
+ LoadState state;
+ if (isInitialized && interceptor != null) {
+ state = LoadState.LOADED;
+ }
+ else if ( interceptor != null && (! isInitialized)) {
+ state = LoadState.NOT_LOADED;
+ }
+ else if ( sureFromUs ) { //interceptor == null
+ state = LoadState.LOADED;
+ }
+ else {
+ state = LoadState.UNKNOWN;
+ }
+
+ return state;
+ }
+ else {
+ //can't do sureFromUs ? LoadState.LOADED : LoadState.UNKNOWN;
+ //is that an association?
+ return LoadState.UNKNOWN;
+ }
+ }
+
+ public LoadState isLoadedWithReference(Object proxy, String property) {
+ //for sure we don't instrument and for sure it's not a lazy proxy
+ Object object = get(proxy, property);
+ return isLoaded( object );
+ }
+
+ private Object get(Object proxy, String property) {
+ final Class<?> clazz = proxy.getClass();
+ try {
+ try {
+ final Field field = clazz.getField( property );
+ setAccessibility( field );
+ return field.get( proxy );
+ }
+ catch ( NoSuchFieldException e ) {
+ final Method method = getMethod( clazz, property );
+ if (method != null) {
+ setAccessibility( method );
+ return method.invoke( proxy );
+ }
+ else {
+ throw new PersistenceException( "Unable to find field or method: "
+ + clazz + "#"
+ + property);
+ }
+ }
+ }
+ catch ( IllegalAccessException e ) {
+ throw new PersistenceException( "Unable to access field or method: "
+ + clazz + "#"
+ + property, e);
+ }
+ catch ( InvocationTargetException e ) {
+ throw new PersistenceException( "Unable to access field or method: "
+ + clazz + "#"
+ + property, e);
+ }
+ }
+
/**
+ * Returns the method with the specified name or <code>null</code> if it does not exist.
+ *
+ * @param clazz The class to check.
+ * @param methodName The method name.
+ *
+ * @return Returns the method with the specified name or <code>null</code> if it does not exist.
+ */
+ public static Method getMethod(Class<?> clazz, String methodName) {
+ try {
+ char string[] = methodName.toCharArray();
+ string[0] = Character.toUpperCase( string[0] );
+ methodName = new String( string );
+ try {
+ return clazz.getMethod( "get" + methodName );
+ }
+ catch ( NoSuchMethodException e ) {
+ return clazz.getMethod( "is" + methodName );
+ }
+ }
+ catch ( NoSuchMethodException e ) {
+ return null;
+ }
+ }
+
+ public static void setAccessibility(Member member) {
+ if ( !Modifier.isPublic( member.getModifiers() ) ) {
+ //Sun's ease of use, sigh...
+ ( ( AccessibleObject ) member ).setAccessible( true );
+ }
+ }
+
+ public LoadState isLoaded(Object o) {
+ if ( o instanceof HibernateProxy ) {
+ final boolean isInitialized = !( ( HibernateProxy ) o ).getHibernateLazyInitializer().isUninitialized();
+ return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
+ }
+ else if ( o instanceof PersistentCollection ) {
+ final boolean isInitialized = ( ( PersistentCollection ) o ).wasInitialized();
+ return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
+ }
+ else {
+ return LoadState.UNKNOWN;
+ }
+ }
+
+ /**
* create a factory from a canonical version
* @deprecated
*/
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -7,6 +7,7 @@
import java.util.List;
import java.util.HashSet;
import java.util.Set;
+import java.util.Map;
import javax.persistence.FlushModeType;
import javax.persistence.NoResultException;
import javax.persistence.NonUniqueResultException;
@@ -14,6 +15,7 @@
import javax.persistence.TemporalType;
import static javax.persistence.TemporalType.*;
import javax.persistence.TransactionRequiredException;
+import javax.persistence.LockModeType;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
@@ -32,6 +34,7 @@
private HibernateEntityManagerImplementor em;
private Boolean isPositional = null;
private int maxResults = -1;
+ private int firstResult;
public QueryImpl(org.hibernate.Query query, AbstractEntityManagerImpl em) {
this.query = query;
@@ -143,6 +146,10 @@
return this;
}
+ public int getMaxResults() {
+ return maxResults == -1 ? Integer.MAX_VALUE : maxResults; //stupid spec MAX_VALUE??
+ }
+
public Query setFirstResult(int firstResult) {
if ( firstResult < 0 ) {
throw new IllegalArgumentException(
@@ -152,9 +159,14 @@
);
}
query.setFirstResult( firstResult );
+ this.firstResult = firstResult;
return this;
}
+ public int getFirstResult() {
+ return firstResult;
+ }
+
public Query setHint(String hintName, Object value) {
try {
if ( "org.hibernate.timeout".equals( hintName ) ) {
@@ -192,6 +204,16 @@
return this;
}
+ public Map<String, Object> getHints() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Set<String> getSupportedHints() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Query setParameter(String name, Object value) {
try {
if ( value instanceof Collection ) {
@@ -351,6 +373,16 @@
}
}
+ public Map<String, Object> getNamedParameters() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List getPositionalParameters() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Query setFlushMode(FlushModeType flushMode) {
if ( flushMode == FlushModeType.AUTO ) {
query.setFlushMode( FlushMode.AUTO );
@@ -360,4 +392,24 @@
}
return this;
}
+
+ public FlushModeType getFlushMode() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Query setLockMode(LockModeType lockModeType) {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public LockModeType getLockMode() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public <T> T unwrap(Class<T> tClass) {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/PackagedEntityManagerTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -219,7 +219,7 @@
public void testListeners() throws Exception {
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "manager1", new HashMap() );
EntityManager em = emf.createEntityManager();
- EventListeners eventListeners = ( (SessionImplementor) em.getDelegate() ).getListeners();
+ EventListeners eventListeners = em.unwrap(SessionImplementor.class).getListeners();
assertEquals(
"Explicit pre-insert event through hibernate.ejb.event.pre-insert does not work",
eventListeners.getPreInsertEventListeners().length,
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/connection/PersistenceUnitInfoImpl.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/connection/PersistenceUnitInfoImpl.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/connection/PersistenceUnitInfoImpl.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -8,6 +8,8 @@
import javax.persistence.spi.ClassTransformer;
import javax.persistence.spi.PersistenceUnitInfo;
import javax.persistence.spi.PersistenceUnitTransactionType;
+import javax.persistence.Caching;
+import javax.persistence.ValidationMode;
import javax.sql.DataSource;
import org.hibernate.cfg.Environment;
@@ -71,6 +73,10 @@
return properties;
}
+ public String PersistenceXMLSchemaVersion() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public ClassLoader getClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
@@ -87,6 +93,16 @@
return true;
}
+ public Caching getCaching() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public ValidationMode getValidationMode() {
+ //FIXME
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public void addTransformer(ClassTransformer transformer) {
}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/emops/cascade/CascadePersistTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/emops/cascade/CascadePersistTest.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/emops/cascade/CascadePersistTest.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -72,7 +72,7 @@
c2.setB2( anotherB2 );
}
}
- Statistics statistics = ( (Session) em.getDelegate() ).getSessionFactory().getStatistics();
+ Statistics statistics = em.unwrap(Session.class).getSessionFactory().getStatistics();
statistics.setStatisticsEnabled( true );
statistics.clear();
em.persist( c2 );
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -271,7 +271,7 @@
em.flush();
em.clear();
book.setName( "kitty kid2"); //non updated version
- ( (Session) em.getDelegate() ).update( book );
+ em.unwrap( Session.class ).update( book );
try {
em.getTransaction().commit();
fail( "Commit should be rollbacked" );
Modified: core/trunk/envers/pom.xml
===================================================================
--- core/trunk/envers/pom.xml 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/envers/pom.xml 2009-05-07 21:34:21 UTC (rev 16523)
@@ -70,8 +70,9 @@
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
+ <groupId>org.hibernate.java-persistence</groupId>
+ <artifactId>jpa-api</artifactId>
+ <version>2.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -24,14 +24,14 @@
package org.hibernate.envers;
import javax.persistence.EntityManager;
+import javax.persistence.PersistenceException;
+import org.hibernate.Session;
+import org.hibernate.engine.SessionImplementor;
import org.hibernate.envers.event.AuditEventListener;
import org.hibernate.envers.exception.AuditException;
import org.hibernate.envers.reader.AuditReaderImpl;
import static org.hibernate.envers.tools.ArraysTools.arrayIncludesInstanceOf;
-
-import org.hibernate.Session;
-import org.hibernate.engine.SessionImplementor;
import org.hibernate.event.EventListeners;
import org.hibernate.event.PostInsertEventListener;
@@ -81,17 +81,11 @@
* listeners aren't installed.
*/
public static AuditReader get(EntityManager entityManager) throws AuditException {
- if (entityManager.getDelegate() instanceof Session) {
- return get((Session) entityManager.getDelegate());
- }
-
- if (entityManager.getDelegate() instanceof EntityManager) {
- entityManager = (EntityManager) entityManager.getDelegate();
- if (entityManager.getDelegate() instanceof Session) {
- return get((Session) entityManager.getDelegate());
- }
- }
-
- throw new AuditException("Hibernate EntityManager not present!");
+ try {
+ return get( entityManager.unwrap(Session.class) );
+ }
+ catch ( PersistenceException e ) {
+ throw new AuditException("Hibernate EntityManager not present!");
+ }
}
}
Modified: core/trunk/envers/src/main/java/org/jboss/envers/VersionsReaderFactory.java
===================================================================
--- core/trunk/envers/src/main/java/org/jboss/envers/VersionsReaderFactory.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/envers/src/main/java/org/jboss/envers/VersionsReaderFactory.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -25,6 +25,7 @@
package org.jboss.envers;
import javax.persistence.EntityManager;
+import javax.persistence.PersistenceException;
import org.hibernate.envers.event.AuditEventListener;
import org.hibernate.envers.reader.AuditReaderImpl;
@@ -81,16 +82,11 @@
* listeners aren't installed.
*/
public static VersionsReader get(EntityManager entityManager) throws VersionsException {
- if (entityManager.getDelegate() instanceof Session) {
- return get((Session) entityManager.getDelegate());
- }
-
- if (entityManager.getDelegate() instanceof EntityManager) {
- if (entityManager.getDelegate() instanceof Session) {
- return get((Session) entityManager.getDelegate());
- }
- }
-
- throw new VersionsException("Hibernate EntityManager not present!");
+ try {
+ return get( entityManager.unwrap(Session.class) );
+ }
+ catch ( PersistenceException e ) {
+ throw new VersionsException("Hibernate EntityManager not present!");
+ }
}
}
\ No newline at end of file
Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/flush/AbstractFlushTest.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/flush/AbstractFlushTest.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/flush/AbstractFlushTest.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -25,6 +25,7 @@
import java.io.IOException;
import javax.persistence.EntityManager;
+import javax.persistence.PersistenceException;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrTestEntity;
@@ -45,18 +46,12 @@
}
private static Session getSession(EntityManager em) {
- Object delegate = em.getDelegate();
- if (delegate instanceof Session) {
- return (Session) delegate;
- } else if (delegate instanceof EntityManager) {
- Object delegate2 = ((EntityManager) delegate).getDelegate();
-
- if (delegate2 instanceof Session) {
- return (Session) delegate2;
- }
- }
-
- throw new RuntimeException("Invalid entity manager");
+ try {
+ return em.unwrap( Session.class );
+ }
+ catch ( PersistenceException e ) {
+ throw new RuntimeException("Invalid entity manager", e);
+ }
}
@BeforeClass(dependsOnMethods = "init")
Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/various/HsqlTest.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/various/HsqlTest.java 2009-05-07 20:33:16 UTC (rev 16522)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/various/HsqlTest.java 2009-05-07 21:34:21 UTC (rev 16523)
@@ -100,7 +100,7 @@
entityManager.getTransaction().begin();
- Session sesion = (Session) entityManager.getDelegate();
+ Session sesion = entityManager.unwrap(Session.class);
System.out.println(sesion.createQuery(
"select e from org.hibernate.envers.demo.Person_versions e " +
"where " +
15 years, 6 months
Hibernate SVN: r16522 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-05-07 16:33:16 -0400 (Thu, 07 May 2009)
New Revision: 16522
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
Log:
fix bug with isGetter not retrieved when getMethod is used
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-05-07 18:38:51 UTC (rev 16521)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java 2009-05-07 20:33:16 UTC (rev 16522)
@@ -393,21 +393,7 @@
* false</code> otherwise.
*/
public static boolean containsMethod(Class<?> clazz, String methodName) {
- try {
- char string[] = methodName.toCharArray();
- string[0] = Character.toUpperCase( string[0] );
- methodName = new String( string );
- try {
- clazz.getMethod( "get" + methodName );
- }
- catch ( NoSuchMethodException e ) {
- clazz.getMethod( "is" + methodName );
- }
- return true;
- }
- catch ( NoSuchMethodException e ) {
- return false;
- }
+ return getMethod( clazz, methodName ) != null;
}
/**
@@ -420,7 +406,15 @@
*/
public static Method getMethod(Class<?> clazz, String methodName) {
try {
- return clazz.getMethod( "get" + methodName.substring( 0, 1 ).toUpperCase() + methodName.substring( 1 ) );
+ char string[] = methodName.toCharArray();
+ string[0] = Character.toUpperCase( string[0] );
+ methodName = new String( string );
+ try {
+ return clazz.getMethod( "get" + methodName );
+ }
+ catch ( NoSuchMethodException e ) {
+ return clazz.getMethod( "is" + methodName );
+ }
}
catch ( NoSuchMethodException e ) {
return null;
15 years, 6 months