Hibernate SVN: r16601 - beanvalidation/trunk/validation-tck/src/main/resources.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-05-19 09:45:23 -0400 (Tue, 19 May 2009)
New Revision: 16601
Modified:
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Completed assertions for chapter 2
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-05-19 13:44:49 UTC (rev 16600)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-05-19 13:45:23 UTC (rev 16601)
@@ -61,24 +61,184 @@
group is considered declared. </text>
</assertion>
</section>
-
+
<section id="2.2" title="Applying multiple constraints of the same type">
- <assertion id="">
- <text></text>
+ <assertion id="a">
+ <text>The bean validation provider treats regular annotations (annotations not annotated
+ by @Constraint) whose value element has a return type of an array of constraint
+ annotations in a special way. Each element in the value array are processed by the
+ Bean Validation implementation as regular constraint annotations.</text>
</assertion>
- <assertion id="">
- <text/>
+ <assertion id="b">
+ <text>The annotation must have retention RUNTIME and can be applied on a type, field,
+ property or an other annotation</text>
</assertion>
- </section>
+ </section>
+ <section id="2.3" title="Constraint composition">
+ <assertion id="a">
+ <text>Each constraint annotation hosted on a constraint an- notation is applied to the
+ target element and this recursively</text>
+ </assertion>
+ <assertion id="b">
+ <text>Note that the main annotation and its constraint valid- ation implementation is
+ also applied</text>
+ </assertion>
+ <assertion id="c">
+ <text>By default, each failing constraint generates an error report</text>
+ </assertion>
+ <assertion id="d">
+ <text>Groups from the main constraint annotation are inherited by the composing
+ annotations</text>
+ </assertion>
+ <assertion id="e">
+ <text>Any groups definition on a composing an- notation is ignored</text>
+ </assertion>
+ <assertion id="f">
+ <text>The property type a composed constraint is placed on must be compatible with all
+ constraints (composing and com- posed)</text>
+ </assertion>
+ <assertion id="g">
+ <text> If a composed constraint is marked as @ReportAsSingleViolation, and if any of its
+ composing constraint reports one or more violations, all reports from composing
+ constraints are ignored and the error report corresponding to the composed
+ constraint is generated</text>
+ </assertion>
+ <assertion id="h">
+ <text>Composing annotations can define the value of message and custom attributes
+ (excluding groups) but these are fixed in the composed constraint definition</text>
+ </assertion>
+ <assertion id="i">
+ <text>It is possible to override attributes and messages defined on a composing
+ annotation. An attribute from the main annotation is used to override one or more
+ attributes of the composing annotations. Such an attribute is annotated with the
+ @OverridesAttribute annotation or its multivalued equivalent
+ @OverridesAttribute.List</text>
+ </assertion>
+ <assertion id="j">
+ <text> The types of the overridden and overriding attributes must be identical</text>
+ </assertion>
+ <assertion id="k">
+ <text>A composing constraint can itself be a composed constraint. In this case,
+ attribute values are overridden re- cursively according to the described
+ rules</text>
+ </assertion>
+ <assertion id="l">
+ <text>If a constraint is used more than once as a composing constraint, the multi value
+ constraints model as described in Section 2.2 is used</text>
+ </assertion>
+ <assertion id="m">
+ <text>To select the appropriate composing constraint targeted, OverridesAttrib-
+ ute.constraintIndex is used. It represents the constraint index in the value
+ array</text>
+ </assertion>
+ <assertion id="n">
+ <text>If index is undefined, the single constraint declaration is targeted</text>
+ </assertion>
+ <assertion id="o">
+ <text>If the composition is invalid (infinite composition, wrong attribute overriding, a
+ single attribute mapped to more than one source attribute etc), a
+ ConstraintDefinitionException is raised either at validation time or when the
+ metadata is requested</text>
+ </assertion>
+ </section>
+ <section id="2.4" title="Constraint validation implementation">
+ <assertion id="a">
+ <text>A constraint validation implementation performs the validation of a given
+ constraint annotation for a given type</text>
+ </assertion>
+ <assertion id="b">
+ <text>The implementation classes are specified by the validatedBy element of the
+ @Contraint annotation that decorates the constraint definition</text>
+ </assertion>
+ <assertion id="c">
+ <text>The constraint validation implementation implements the ConstraintValidator
+ interface</text>
+ </assertion>
+ <assertion id="d">
+ <text>T must resolve in a non parameterized type or generic parameters of T must be
+ unbounded wildcard types</text>
+ </assertion>
+ <assertion id="e">
+ <text>The initialize method is called by the Bean validation provider prior to any use
+ of the constraint implementation.</text>
+ </assertion>
+ <assertion id="f">
+ <text>The isValid method is evaluated by the Bean Validation provider each time a given
+ value is validated</text>
+ </assertion>
+ <assertion id="g">
+ <text>It returns false if the value is not valid, true otherwise</text>
+ </assertion>
+ <assertion id="h">
+ <text>isValid implementations must be thread-safe</text>
+ </assertion>
+ <assertion id="i">
+ <text>If the property is of an unanticipated type, an UnexpectedTypeException is
+ raised</text>
+ </assertion>
+ <assertion id="j">
+ <text>If an exception occurs either in the initialize or isValid method, the runtime
+ exception is wrapped into a Valid- ationException by the Bean Validation engine
+ </text>
+ </assertion>
+ <assertion id="k">
+ <text>The constraint validation implementation is not allowed to change the state of the
+ value passed to isValid. </text>
+ </assertion>
+ <assertion id="l">
+ <text>By default, each invalid constraint leads to the generation of one error object
+ represented by a ConstraintViolation object. This object is build from the default
+ error message as defined by the constraint de- claration and the context in which
+ the constraint declaration is placed on (bean, property, attribute)</text>
+ </assertion>
+ <assertion id="m">
+ <text>The ConstraintValidatorContext methods let the constraint implementation disable
+ the default error object gen- eration and create one or more custom ones</text>
+ </assertion>
+ <assertion id="n">
+ <text>The non-interpolated message passed as a parameter is used to build the
+ ConstraintViolation object (the message interpolation operation is applied to
+ it)</text>
+ </assertion>
+ <assertion id="o">
+ <text>By default, the propertyPath exposed on the ConstraintViolation represents the
+ path to the bean or property hosting the constraint</text>
+ </assertion>
+ <assertion id="q">
+ <text>The leaf of the propertyPath can be adjusted by use of ConstraintValidatorCon-
+ text.addError(String, String). In this case, propertyPath is the concatenation of
+ the default propertyPath value . (dot) if propertyPath is not an empty string (ie
+ not representing the root object) and the property string passed to the addError
+ method </text>
+ </assertion>
+ </section>
+ <section id="2.5" title="The ConstraintValidatorFactory">
+ <assertion id="a">
+ <text>Constraint validation implementation instances are created by a
+ ConstraintValidatorFactory</text>
+ </assertion>
+ <assertion id="b">
+ <text>The default ConstraintValidatorFactory provided by the Bean Validation provider
+ implementation uses the pub- lic constraint no-arg constructor</text>
+ </assertion>
+ <assertion id="c">
+ <text>ConstraintValidatorFactory should not cache instances as the state of each
+ instance can be altered in the ini- tialize method</text>
+ </assertion>
+ <assertion id="d">
+ <text>If an exception occurs in the factory while retrieving the ConstraintValidator
+ instance, the runtime exception is wrapped in a ValidationException</text>
+ </assertion>
+ <assertion id="e">
+ <text>If the instance returned by the factory is null, a ValidationException is
+ raised</text>
+ </assertion>
+ </section>
-
-
<!--
<assertion id="">
<text></text>
</assertion>
-->
-
-
-
+
</specification>
14 years, 11 months
Hibernate SVN: r16600 - beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-05-19 09:44:49 -0400 (Tue, 19 May 2009)
New Revision: 16600
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java
Log:
javadoc fixes
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java 2009-05-19 13:26:30 UTC (rev 16599)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java 2009-05-19 13:44:49 UTC (rev 16600)
@@ -1,3 +1,20 @@
+// $Id: Past.java 16368 2009-04-21 09:51:00Z epbernard $
+/*
+* 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 javax.validation.constraints;
import java.lang.annotation.Target;
@@ -24,22 +41,22 @@
@Constraint(validatedBy = {})
public @interface Pattern {
/**
- * regular expression to match
+ * @return The regular expression to match.
*/
String regexp();
/**
- * Flags considered when resolving the regular expression
+ * @return Array of <code>Flag</code> enumeration instances considered when resolving the regular expression.
*/
Flag[] flags() default {};
/**
- * error message template
+ * @return The error message template.
*/
String message() default "{constraint.pattern}";
/**
- * groups the constraint belongs to
+ * @return The groups the constraint belongs to.
*/
Class<?>[] groups() default { };
14 years, 11 months
Hibernate SVN: r16599 - in entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test: inheritance and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: jcosta(a)redhat.com
Date: 2009-05-19 09:26:30 -0400 (Tue, 19 May 2009)
New Revision: 16599
Modified:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/emops/Race.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/lock/Lock.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/ops/Workload.java
Log:
EJB-405 JBPAPP-1077 - Backported: Added explicit names for some columns and entities which uses reserved keywords in its names
Modified: entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/emops/Race.java
===================================================================
--- entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/emops/Race.java 2009-05-19 13:25:47 UTC (rev 16598)
+++ entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/emops/Race.java 2009-05-19 13:26:30 UTC (rev 16599)
@@ -18,7 +18,7 @@
@Entity
public class Race {
@Id @GeneratedValue public Integer id;
- @IndexColumn( name="index" ) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ @IndexColumn( name="index_" ) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
public List<Competitor> competitors = new ArrayList<Competitor>();
public String name;
Modified: entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java
===================================================================
--- entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java 2009-05-19 13:25:47 UTC (rev 16598)
+++ entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java 2009-05-19 13:26:30 UTC (rev 16599)
@@ -1,6 +1,7 @@
//$Id: $
package org.hibernate.ejb.test.inheritance;
+import javax.persistence.Column;
import javax.persistence.Entity;
/**
@@ -8,6 +9,7 @@
*/
@Entity
public class Strawberry extends Fruit {
+ @Column(name="size_")
private Long size;
public Long getSize() {
Modified: entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/lock/Lock.java
===================================================================
--- entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/lock/Lock.java 2009-05-19 13:25:47 UTC (rev 16598)
+++ entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/lock/Lock.java 2009-05-19 13:26:30 UTC (rev 16599)
@@ -9,7 +9,7 @@
/**
* @author Emmanuel Bernard
*/
-@Entity
+@Entity(name="Lock_")
public class Lock {
private Integer id;
private Integer version;
Modified: entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/ops/Workload.java
===================================================================
--- entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/ops/Workload.java 2009-05-19 13:25:47 UTC (rev 16598)
+++ entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/ops/Workload.java 2009-05-19 13:26:30 UTC (rev 16599)
@@ -1,6 +1,7 @@
//$Id$
package org.hibernate.ejb.test.ops;
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@@ -14,5 +15,6 @@
@GeneratedValue
public Integer id;
public String name;
+ @Column(name="load_")
public Integer load;
}
14 years, 11 months
Hibernate SVN: r16598 - entitymanager/branches/v3_4_0_GA_CP/src/java/org/hibernate/ejb.
by hibernate-commits@lists.jboss.org
Author: jcosta(a)redhat.com
Date: 2009-05-19 09:25:47 -0400 (Tue, 19 May 2009)
New Revision: 16598
Modified:
entitymanager/branches/v3_4_0_GA_CP/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
Log:
JBPAPP-1998 - Backported: Added additional try/catch in AbstractEntityManagerImpl.wrapStaleStateException
Modified: entitymanager/branches/v3_4_0_GA_CP/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
--- entitymanager/branches/v3_4_0_GA_CP/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-05-19 13:11:42 UTC (rev 16597)
+++ entitymanager/branches/v3_4_0_GA_CP/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-05-19 13:25:47 UTC (rev 16598)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, the OpenSource EJB server Distributable under LGPL license. See terms of license at
* gnu.org.
@@ -621,12 +621,16 @@
StaleObjectStateException sose = (StaleObjectStateException) e;
Serializable identifier = sose.getIdentifier();
if (identifier != null) {
- Object entity = getRawSession().load( sose.getEntityName(), identifier );
- if ( entity instanceof Serializable ) {
- //avoid some user errors regarding boundary crossing
- pe = new OptimisticLockException( null, e, entity );
- }
- else {
+ try {
+ Object entity = getRawSession().load( sose.getEntityName(), identifier );
+ if ( entity instanceof Serializable ) {
+ //avoid some user errors regarding boundary crossing
+ pe = new OptimisticLockException( null, e, entity );
+ }
+ else {
+ pe = new OptimisticLockException( e );
+ }
+ } catch (EntityNotFoundException enfe) {
pe = new OptimisticLockException( e );
}
}
14 years, 11 months
Hibernate SVN: r16597 - entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb.
by hibernate-commits@lists.jboss.org
Author: jcosta(a)redhat.com
Date: 2009-05-19 09:11:42 -0400 (Tue, 19 May 2009)
New Revision: 16597
Modified:
entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
Log:
JBPAPP-1998 - Backported: Added additional try/catch in AbstractEntityManagerImpl.wrapStaleStateException
Modified: entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
--- entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-05-19 11:50:10 UTC (rev 16596)
+++ entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-05-19 13:11:42 UTC (rev 16597)
@@ -644,12 +644,16 @@
StaleObjectStateException sose = (StaleObjectStateException) e;
Serializable identifier = sose.getIdentifier();
if (identifier != null) {
- Object entity = getRawSession().load( sose.getEntityName(), identifier );
- if ( entity instanceof Serializable ) {
- //avoid some user errors regarding boundary crossing
- pe = new OptimisticLockException( null, e, entity );
- }
- else {
+ try {
+ Object entity = getRawSession().load( sose.getEntityName(), identifier );
+ if ( entity instanceof Serializable ) {
+ //avoid some user errors regarding boundary crossing
+ pe = new OptimisticLockException( null, e, entity );
+ }
+ else {
+ pe = new OptimisticLockException( e );
+ }
+ } catch (EntityNotFoundException enfe) {
pe = new OptimisticLockException( e );
}
}
14 years, 11 months
Hibernate SVN: r16596 - in branches/Branch_3_2/HibernateExt/tools: src/java/org/hibernate/tool and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2009-05-19 07:50:10 -0400 (Tue, 19 May 2009)
New Revision: 16596
Added:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/AbstractTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Order.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/TypeParamsTest.java
Modified:
branches/Branch_3_2/HibernateExt/tools/build.xml
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/property.hbm.ftl
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Car.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/CarPart.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java
Log:
JBIDE-3914 ( Cfg2HbmTool.needsTable() method returns true for Subclass object),
JBIDE-4050 (Abstract attribute is never exported in persistent class.),
JBIDE-4052 (getFetchMode calles NullPointerException when was not set)
JBIDE-4198 ( Parametrized type should be exported with it's parameters )
Modified: branches/Branch_3_2/HibernateExt/tools/build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/build.xml 2009-05-19 10:29:18 UTC (rev 16595)
+++ branches/Branch_3_2/HibernateExt/tools/build.xml 2009-05-19 11:50:10 UTC (rev 16596)
@@ -7,7 +7,7 @@
<!-- Name of project and version, used to create filenames -->
<property name="Name" value="Hibernate Tools"/>
<property name="name" value="hibernate-tools"/>
- <property name="version" value="3.2.4.GA"/>
+ <property name="version" value="3.2.5.GA"/>
<property name="javadoc.packagenames" value="org.hibernate.tool"/>
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java 2009-05-19 10:29:18 UTC (rev 16595)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java 2009-05-19 11:50:10 UTC (rev 16596)
@@ -5,7 +5,7 @@
final public class Version {
- public static final String VERSION = "3.2.4.GA";
+ public static final String VERSION = "3.2.5.Beta";
private static final Version instance = new Version();
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2009-05-19 10:29:18 UTC (rev 16595)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2009-05-19 11:50:10 UTC (rev 16596)
@@ -17,12 +17,10 @@
import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
import org.hibernate.mapping.Any;
-import org.hibernate.mapping.Backref;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Formula;
-import org.hibernate.mapping.IndexBackref;
import org.hibernate.mapping.JoinedSubclass;
import org.hibernate.mapping.ManyToOne;
import org.hibernate.mapping.OneToMany;
@@ -312,7 +310,7 @@
}
public String getFetchMode(Property property) {
FetchMode fetchMode = property.getValue().getFetchMode();
- return fetchMode.toString().toLowerCase();
+ return (fetchMode== null) ? null : fetchMode.toString().toLowerCase();
}
@@ -382,6 +380,11 @@
return !(cfg.getImports().isEmpty());
}
+ public boolean needsDiscriminatorElement(PersistentClass clazz) {
+ return clazz instanceof RootClass
+ && (clazz.getDiscriminator() != null);
+ }
+
public boolean needsDiscriminator(PersistentClass clazz) {
return clazz instanceof Subclass
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl 2009-05-19 10:29:18 UTC (rev 16595)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl 2009-05-19 11:50:10 UTC (rev 16596)
@@ -38,7 +38,7 @@
<#elseif !clazz.isLazy()>
lazy="false"
</#if>
-<#if clazz.abstract?exists && clazz.abstract>
+<#if clazz.isAbstract()?exists && clazz.isAbstract()>
abstract="true"
</#if>
<#if c2h.isClassLevelOptimisticLockMode(clazz)>
@@ -102,6 +102,15 @@
</key>
</#if>
+<#if c2h.needsDiscriminatorElement(clazz)>
+ <discriminator type="${clazz.discriminator.typeName}">
+ <#foreach column in clazz.discriminator.columnIterator>
+ <#include "column.hbm.ftl">
+ </#foreach>
+ </discriminator>
+</#if>
+
+
<#-- version has to be done explicitly since Annotation's does not list version first -->
<#if pojo.hasVersionProperty()>
<#assign property=clazz.getVersion()/>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/property.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/property.hbm.ftl 2009-05-19 10:29:18 UTC (rev 16595)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/property.hbm.ftl 2009-05-19 11:50:10 UTC (rev 16596)
@@ -1,6 +1,8 @@
<property
name="${property.name}"
- type="${property.value.typeName}"
+<#if !property.value.typeParameters?exists>
+ type="${property.value.typeName}"
+</#if>
<#if !property.updateable>
update="false"
</#if>
@@ -28,5 +30,12 @@
<#foreach column in property.columnIterator>
<#include "column.hbm.ftl">
</#foreach>
+ <#if property.value.typeParameters?exists>
+ <type name="${property.value.typeName}">
+ <#foreach entry in property.value.typeParameters.entrySet()>
+ <param name="${entry.key}">${entry.value}</param>
+ </#foreach>
+ </type>
+ </#if>
</property>
Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/AbstractTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/AbstractTest.java (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/AbstractTest.java 2009-05-19 11:50:10 UTC (rev 16596)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.mapping.Backref;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class AbstractTest extends NonReflectiveTestCase {
+
+ private String mappingFile = "Car.hbm.xml";
+
+ private Exporter hbmexporter;
+
+ /**
+ * @param name
+ */
+ public AbstractTest(String name) {
+ super(name, "cfg2hbmoutput");
+ }
+
+ protected String[] getMappings() {
+ return new String[] {
+ mappingFile
+ };
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
+ hbmexporter.start();
+ }
+
+ public void testAllFilesExistence() {
+ assertFileAndExists(new File(getOutputDir().getAbsolutePath(), getBaseForMappings() + "Car.hbm.xml") );
+ assertFileAndExists(new File(getOutputDir().getAbsolutePath(), getBaseForMappings() + "CarPart.hbm.xml") );
+ }
+
+ public void testAbstractPresent() {
+ File outputXml = new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/CarPart.hbm.xml");
+ assertFileAndExists(outputXml);
+
+ SAXReader xmlReader = this.getSAXReader();
+
+ Document document;
+ try {
+ document = xmlReader.read(outputXml);
+ XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class");
+ List list = xpath.selectNodes(document);
+ assertEquals("Expected to get one class element", 1, list.size());
+ Element node = (Element) list.get(0);
+ assertNotNull("Abstract attrinute was not exported.", node.attribute( "abstract" ));
+ assertEquals(node.attribute( "abstract" ).getText(),"true");
+ } catch (DocumentException e) {
+ fail("Can't parse file " + outputXml.getAbsolutePath());
+ }
+ }
+
+ public void testReadable() {
+ Configuration cfg = new Configuration();
+
+ cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Car.hbm.xml"));
+ cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "CarPart.hbm.xml"));
+
+ cfg.buildMappings();
+ }
+
+ protected String getBaseForMappings() {
+ return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
+ }
+
+ public static Test suite() {
+ return new TestSuite(AbstractTest.class);
+ }
+
+}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml 2009-05-19 10:29:18 UTC (rev 16595)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml 2009-05-19 11:50:10 UTC (rev 16596)
@@ -18,6 +18,9 @@
<id name="id" type="long">
<generator class="assigned"/>
</id>
+ <discriminator type="string">
+ <column name="HIER_TYPE" length="5" not-null="true" />
+ </discriminator>
<property name="legs" type="int"/>
</class>
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Car.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Car.hbm.xml 2009-05-19 10:29:18 UTC (rev 16595)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Car.hbm.xml 2009-05-19 11:50:10 UTC (rev 16596)
@@ -16,7 +16,7 @@
</set>
</class>
- <class name="CarPart" node="carPart">
+ <class name="CarPart" node="carPart" abstract="true">
<id name="id" node="@id" type="long">
<generator class="increment"/>
</id>
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/CarPart.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/CarPart.java 2009-05-19 10:29:18 UTC (rev 16595)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/CarPart.java 2009-05-19 11:50:10 UTC (rev 16596)
@@ -1,35 +1,35 @@
-package org.hibernate.tool.hbm2x.hbm2hbmxml;
-
-/**
- * @author Paco Hern�ndez
- */
-public class CarPart implements java.io.Serializable {
-
- private long id;
- private String partName;
-
- /**
- * @return Returns the id.
- */
- public long getId() {
- return id;
- }
- /**
- * @param id The id to set.
- */
- public void setId(long id) {
- this.id = id;
- }
- /**
- * @return Returns the typeName.
- */
- public String getPartName() {
- return partName;
- }
- /**
- * @param typeName The typeName to set.
- */
- public void setPartName(String typeName) {
- this.partName = typeName;
- }
-}
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+/**
+ * @author Paco Hern�ndez
+ */
+public abstract class CarPart implements java.io.Serializable {
+
+ private long id;
+ private String partName;
+
+ /**
+ * @return Returns the id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the typeName.
+ */
+ public String getPartName() {
+ return partName;
+ }
+ /**
+ * @param typeName The typeName to set.
+ */
+ public void setPartName(String typeName) {
+ this.partName = typeName;
+ }
+}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java 2009-05-19 10:29:18 UTC (rev 16595)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java 2009-05-19 11:50:10 UTC (rev 16596)
@@ -20,6 +20,8 @@
suite.addTest(SetElementTest.suite());
suite.addTest(BackrefTest.suite());
suite.addTest(Cfg2HbmToolTest.suite());
+ suite.addTest(AbstractTest.suite());
+ suite.addTest(TypeParamsTest.suite());
//$JUnit-END$
return suite;
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java 2009-05-19 10:29:18 UTC (rev 16595)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java 2009-05-19 11:50:10 UTC (rev 16596)
@@ -16,6 +16,7 @@
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
import org.dom4j.XPath;
import org.dom4j.io.SAXReader;
import org.hibernate.cfg.Configuration;
@@ -82,9 +83,24 @@
} catch (DocumentException e) {
fail("Can't parse file " + outputXml.getAbsolutePath());
}
- }
+ }
+
+ public void testDiscriminator() throws DocumentException {
+ File outputXml = new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Animal.hbm.xml");
+ assertFileAndExists(outputXml);
+ SAXReader xmlReader = this.getSAXReader();
+ Document document = xmlReader.read(outputXml);
+ XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/discriminator");
+ List list = xpath.selectNodes(document);
+ assertEquals("Expected to get one discriminator element", 1, list.size());
+
+ Element node = (Element) list.get(0);
+ assertEquals(node.attribute( "type" ).getText(), "string");
+
+ }
+
protected String getBaseForMappings() {
return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
}
Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Order.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Order.hbm.xml (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Order.hbm.xml 2009-05-19 11:50:10 UTC (rev 16596)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Generated 17.04.2009 10:41:19 by Hibernate Tools 3.2.4.GA -->
+<hibernate-mapping>
+ <class name="org.hibernate.tool.hbm2x.hbm2hbmxml.Order" table="ORDERS">
+ <id name="orderId" type="long">
+ <column name="ORDERID"/>
+ <generator class="native"/>
+ </id>
+ <property generated="never" lazy="false" name="status">
+ <column name="STATUS"/>
+ <type name="org.hibernate.type.EnumType">
+ <param name="catalog"/>
+ <param name="column">STATUS</param>
+ <param name="table">ORDERS</param>
+ <param name="schema"/>
+ <param name="enumClass">org.hibernate.tool.hbm2x.hbm2hbmxml.Order$Status</param>
+ </type>
+ </property>
+ <property name="name" type="string"/>
+ </class>
+</hibernate-mapping>
Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/TypeParamsTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/TypeParamsTest.java (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/TypeParamsTest.java 2009-05-19 11:50:10 UTC (rev 16596)
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class TypeParamsTest extends NonReflectiveTestCase {
+
+ private String mappingFile = "Order.hbm.xml";
+
+ private Exporter hbmexporter;
+
+ /**
+ * @param name
+ */
+ public TypeParamsTest(String name) {
+ super(name, "cfg2hbmoutput");
+ }
+
+
+ protected String[] getMappings() {
+ return new String[] {
+ mappingFile
+ };
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
+ hbmexporter.start();
+ }
+
+ public void testAllFilesExistence() {
+ assertFileAndExists(new File(getOutputDir().getAbsolutePath(), getBaseForMappings() + mappingFile) );
+ }
+
+ public void testReadable() {
+ Configuration cfg = new Configuration();
+ cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Order.hbm.xml"));
+ cfg.buildMappings();
+ }
+
+ public void testTypeParamsElements() throws DocumentException {
+ File outputXml = new File(getOutputDir(), getBaseForMappings() + mappingFile);
+ assertFileAndExists(outputXml);
+
+ SAXReader xmlReader = getSAXReader();
+
+ Document document = xmlReader.read(outputXml);
+
+ XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/property");
+ List list = xpath.selectNodes(document);
+ assertEquals("Expected to get one property element", 2, list.size());
+ Element statusElement = (Element) list.get(0);
+ Element nameElement = (Element) list.get(1);
+ if(!statusElement.attribute( "name" ).getText().equals("status")) {
+ Element temp = nameElement;
+ nameElement = statusElement;
+ statusElement = temp;
+ }
+ assertEquals(statusElement.attribute( "name" ).getText(),"status");
+
+ list = statusElement.elements("type");
+ assertEquals("Expected to get one type element", 1, list.size());
+
+ list = ((Element) list.get(0)).elements("param");
+ assertEquals("Expected to get 5 params elements", list.size(), 5);
+
+ Map params = new HashMap();
+ for (int i = 0; i < list.size(); i++) {
+ Element param = (Element) list.get(i);
+ params.put(param.attribute( "name" ).getText(), param.getText());
+ }
+
+ Set set = params.entrySet();
+ assertEquals("Expected to get 5 different params elements", set.size(), 5);
+
+ assertTrue("Can't find 'catalog' param",
+ set.contains(new TestEntry("catalog", "")));
+
+ assertTrue("Can't find 'column' param",
+ set.contains(new TestEntry("column", "STATUS")));
+
+ assertTrue("Can't find 'table' param",
+ set.contains(new TestEntry("table", "ORDERS")));
+
+ assertTrue("Can't find 'schema' param",
+ set.contains(new TestEntry("schema", "")));
+
+ assertTrue("Can't find 'enumClass' param",
+ set.contains(new TestEntry("enumClass", "org.hibernate.tool.hbm2x.hbm2hbmxml.Order$Status")));
+
+ assertTrue("property name should not have any type element",nameElement.elements("type").isEmpty());
+ assertEquals(nameElement.attribute("type").getText(), "string");
+ }
+
+ protected String getBaseForMappings() {
+ return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
+ }
+
+ public static Test suite() {
+ return new TestSuite(TypeParamsTest.class);
+ }
+
+}
+
+class TestEntry implements Entry{
+
+ private Object key;
+
+ private Object value;
+
+ public TestEntry(Object key, Object value){
+ this.key = key;
+ this.value = value;
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Object setValue(Object value) {
+ return this.value = value;
+ }
+
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((key == null) ? 0 : key.hashCode());
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
+ return result;
+ }
+
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!(obj instanceof Entry)){
+ return false;
+ }
+
+ Entry other = (Entry) obj;
+ if (key == null) {
+ if (other.getKey() != null)
+ return false;
+ } else if (!key.equals(other.getKey()))
+ return false;
+ if (value == null) {
+ if (other.getValue() != null)
+ return false;
+ } else if (!value.equals(other.getValue()))
+ return false;
+ return true;
+ }
+
+
+
+}
14 years, 11 months
Hibernate SVN: r16595 - in validator/trunk/hibernate-validator: src/main/java/org/hibernate/validation/engine/xml and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-05-19 06:29:18 -0400 (Tue, 19 May 2009)
New Revision: 16595
Modified:
validator/trunk/hibernate-validator/pom.xml
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/xml/ValidationXmlParser.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/xml/XmlMappingParser.java
validator/trunk/hibernate-validator/src/main/xjb/binding-customization.xjb
validator/trunk/hibernate-validator/src/test/resources/META-INF/validation.xml
Log:
HV-162 Added CollapsedStringAdapter to binding-customization
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2009-05-19 09:55:46 UTC (rev 16594)
+++ validator/trunk/hibernate-validator/pom.xml 2009-05-19 10:29:18 UTC (rev 16595)
@@ -103,6 +103,7 @@
<configuration>
<packageName>org.hibernate.validation.xml</packageName>
<outputDirectory>${basedir}/target/generated-sources</outputDirectory>
+ <extension>true</extension>
</configuration>
</plugin>
<plugin>
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/xml/ValidationXmlParser.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/xml/ValidationXmlParser.java 2009-05-19 09:55:46 UTC (rev 16594)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/xml/ValidationXmlParser.java 2009-05-19 10:29:18 UTC (rev 16595)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -115,12 +115,12 @@
}
private void setMappingStreamsFromXml(ValidationConfigType config, ValidationBootstrapParameters xmlParameters) {
- for ( String mappingFileName : config.getConstraintMapping() ) {
+ for ( JAXBElement<String> mappingFileName : config.getConstraintMapping() ) {
if ( log.isDebugEnabled() ) {
log.debug(
"Trying to open input stream for {}.", mappingFileName
);
- InputStream in = getInputStreamForPath( mappingFileName );
+ InputStream in = getInputStreamForPath( mappingFileName.getValue() );
if ( in == null ) {
throw new ValidationException( "Unable to open input stream for mapping file " + mappingFileName + "." );
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/xml/XmlMappingParser.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/xml/XmlMappingParser.java 2009-05-19 09:55:46 UTC (rev 16594)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/xml/XmlMappingParser.java 2009-05-19 10:29:18 UTC (rev 16595)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -162,11 +162,11 @@
if ( validatedByType.isIncludeExistingValidators() != null && validatedByType.isIncludeExistingValidators() ) {
constraintValidatorClasses.addAll( findConstraintValidatorClasses( annotationClass ) );
}
- for ( String validatorClassName : validatedByType.getValue() ) {
+ for ( JAXBElement<String> validatorClassName : validatedByType.getValue() ) {
Class<? extends ConstraintValidator<?, ?>> validatorClass;
try {
validatorClass = ( Class<? extends ConstraintValidator<?, ?>> ) ReflectionHelper.classForName(
- validatorClassName,
+ validatorClassName.getValue(),
this.getClass()
);
}
@@ -318,8 +318,8 @@
private List<Class<?>> createGroupSequence(GroupSequenceType groupSequenceType, String defaultPackage) {
List<Class<?>> groupSequence = new ArrayList<Class<?>>();
- for ( String groupName : groupSequenceType.getValue() ) {
- Class<?> group = getClass( groupName, defaultPackage );
+ for ( JAXBElement<String> groupName : groupSequenceType.getValue() ) {
+ Class<?> group = getClass( groupName.getValue(), defaultPackage );
groupSequence.add( group );
}
return groupSequence;
@@ -537,8 +537,8 @@
}
List<Class<?>> groupList = new ArrayList<Class<?>>();
- for ( String groupClass : groupsType.getValue() ) {
- groupList.add( getClass( groupClass, defaultPackage ) );
+ for ( JAXBElement<String> groupClass : groupsType.getValue() ) {
+ groupList.add( getClass( groupClass.getValue(), defaultPackage ) );
}
return groupList.toArray( new Class[groupList.size()] );
}
Modified: validator/trunk/hibernate-validator/src/main/xjb/binding-customization.xjb
===================================================================
--- validator/trunk/hibernate-validator/src/main/xjb/binding-customization.xjb 2009-05-19 09:55:46 UTC (rev 16594)
+++ validator/trunk/hibernate-validator/src/main/xjb/binding-customization.xjb 2009-05-19 10:29:18 UTC (rev 16595)
@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jxb:bindings version="1.0"
- xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
+<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
<jxb:bindings schemaLocation="../xsd/validation-mapping-1.0.xsd" node="/xs:schema">
+ <jxb:globalBindings>
+ <xjc:javaType name="java.lang.String" xmlType="xs:string"
+ adapter="javax.xml.bind.annotation.adapters.CollapsedStringAdapter"/>
+ </jxb:globalBindings>
+
<jxb:bindings node="//xs:complexType[8]/xs:sequence[1]/xs:element[1]">
<jxb:property name="classType"/>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
-
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/test/resources/META-INF/validation.xml
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/META-INF/validation.xml 2009-05-19 09:55:46 UTC (rev 16594)
+++ validator/trunk/hibernate-validator/src/test/resources/META-INF/validation.xml 2009-05-19 10:29:18 UTC (rev 16595)
@@ -2,9 +2,12 @@
<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <default-provider>org.hibernate.validation.engine.HibernateValidatorConfiguration</default-provider>
- <message-interpolator>org.hibernate.validation.engine.ResourceBundleMessageInterpolator</message-interpolator>
+ <default-provider>org.hibernate.validation.engine.HibernateValidatorConfiguration
+ </default-provider>
+ <message-interpolator>
+ org.hibernate.validation.engine.ResourceBundleMessageInterpolator
+ </message-interpolator>
<constraint-mapping>/META-INF/validation/order-constraints.xml</constraint-mapping>
- <constraint-mapping>META-INF/validation/user-constraints.xml</constraint-mapping>
+ <constraint-mapping> META-INF/validation/user-constraints.xml </constraint-mapping>
<property name="org.hibernate.validator.test">foobar</property>
</validation-config>
\ No newline at end of file
14 years, 11 months
Hibernate SVN: r16594 - in core/trunk/entitymanager/src: test/java/org/hibernate/ejb/test/emops and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-05-19 05:55:46 -0400 (Tue, 19 May 2009)
New Revision: 16594
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/emops/RemoveTest.java
Log:
JBPAPP-1998 Added additional try/catch in AbstractEntityManagerImpl.wrapStaleStateException
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-18 22:38:23 UTC (rev 16593)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-05-19 09:55:46 UTC (rev 16594)
@@ -11,7 +11,7 @@
import java.io.Serializable;
import java.util.Map;
import java.util.Set;
-
+import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityNotFoundException;
import javax.persistence.EntityTransaction;
import javax.persistence.FlushModeType;
@@ -23,16 +23,18 @@
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.metamodel.Metamodel;
import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.transaction.Status;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.hibernate.AssertionFailure;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
@@ -58,8 +60,6 @@
import org.hibernate.transaction.TransactionFactory;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.JTAHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* @author <a href="mailto:gavin@hibernate.org">Gavin King</a>
@@ -84,9 +84,11 @@
protected void postInit() {
//register in Sync if needed
- if ( PersistenceUnitTransactionType.JTA.equals( transactionType ) ) joinTransaction( true );
+ if ( PersistenceUnitTransactionType.JTA.equals( transactionType ) ) {
+ joinTransaction( true );
+ }
Object flushMode = properties.get( "org.hibernate.flushMode" );
- if (flushMode != null) {
+ if ( flushMode != null ) {
getSession().setFlushMode( ConfigurationHelper.getFlushMode( flushMode ) );
}
this.properties = null;
@@ -97,7 +99,7 @@
try {
return new QueryImpl( getSession().createQuery( ejbqlString ), this );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
return null;
}
@@ -113,13 +115,13 @@
try {
namedQuery = getSession().getNamedQuery( name );
}
- catch (MappingException e) {
- throw new IllegalArgumentException("Named query not found: " + name);
+ catch ( MappingException e ) {
+ throw new IllegalArgumentException( "Named query not found: " + name );
}
try {
return new QueryImpl( namedQuery, this );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
return null;
}
@@ -131,7 +133,7 @@
SQLQuery q = getSession().createSQLQuery( sqlString );
return new QueryImpl( q, this );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
return null;
}
@@ -144,7 +146,7 @@
q.addEntity( "alias1", resultClass.getName(), LockMode.READ );
return new QueryImpl( q, this );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
return null;
}
@@ -157,7 +159,7 @@
q.setResultSetMapping( resultSetMapping );
return new QueryImpl( q, this );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
return null;
}
@@ -167,18 +169,18 @@
public <T> T getReference(Class<T> entityClass, Object primaryKey) {
//adjustFlushMode();
try {
- return (T) getSession().load( entityClass, (Serializable) primaryKey );
+ return ( T ) getSession().load( entityClass, ( Serializable ) primaryKey );
}
- catch (MappingException e) {
+ catch ( MappingException e ) {
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (TypeMismatchException e ) {
+ catch ( TypeMismatchException e ) {
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (ClassCastException e) {
+ catch ( ClassCastException e ) {
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
return null;
}
@@ -188,26 +190,26 @@
public <A> A find(Class<A> entityClass, Object primaryKey) {
//adjustFlushMode();
try {
- return (A) getSession().get( entityClass, (Serializable) primaryKey );
+ return ( A ) getSession().get( entityClass, ( Serializable ) primaryKey );
}
- catch (ObjectDeletedException e) {
+ catch ( ObjectDeletedException e ) {
//the spec is silent about people doing remove() find() on the same PC
return null;
}
- catch (ObjectNotFoundException e) {
+ catch ( ObjectNotFoundException e ) {
//should not happen on the entity itself with get
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (MappingException e) {
+ catch ( MappingException e ) {
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (TypeMismatchException e ) {
+ catch ( TypeMismatchException e ) {
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (ClassCastException e) {
+ catch ( ClassCastException e ) {
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
return null;
}
@@ -229,7 +231,7 @@
}
private void checkTransactionNeeded() {
- if ( persistenceContextType == PersistenceContextType.TRANSACTION && ! isTransactionInProgress() ) {
+ if ( persistenceContextType == PersistenceContextType.TRANSACTION && !isTransactionInProgress() ) {
//no need to mark as rollback, no tx in progress
throw new TransactionRequiredException(
"no transaction is in progress for a TRANSACTION type persistence context"
@@ -243,10 +245,10 @@
try {
getSession().persist( entity );
}
- catch (MappingException e) {
+ catch ( MappingException e ) {
throw new IllegalArgumentException( e.getMessage() );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
}
}
@@ -256,15 +258,15 @@
checkTransactionNeeded();
//adjustFlushMode();
try {
- return (A) getSession().merge( entity );
+ return ( A ) getSession().merge( entity );
}
- catch (ObjectDeletedException sse) {
+ catch ( ObjectDeletedException sse ) {
throw new IllegalArgumentException( sse );
}
- catch (MappingException e) {
+ catch ( MappingException e ) {
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
return null;
}
@@ -276,10 +278,10 @@
try {
getSession().delete( entity );
}
- catch (MappingException e) {
+ catch ( MappingException e ) {
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
}
}
@@ -288,15 +290,15 @@
checkTransactionNeeded();
//adjustFlushMode();
try {
- if ( ! getSession().contains( entity ) ) {
+ if ( !getSession().contains( entity ) ) {
throw new IllegalArgumentException( "Entity not managed" );
}
getSession().refresh( entity );
}
- catch (MappingException e) {
+ catch ( MappingException e ) {
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
}
}
@@ -319,16 +321,16 @@
public boolean contains(Object entity) {
try {
if ( entity != null
- && ! ( entity instanceof HibernateProxy )
+ && !( entity instanceof HibernateProxy )
&& getSession().getSessionFactory().getClassMetadata( entity.getClass() ) == null ) {
throw new IllegalArgumentException( "Not an entity:" + entity.getClass() );
}
return getSession().contains( entity );
}
- catch (MappingException e) {
+ catch ( MappingException e ) {
throw new IllegalArgumentException( e.getMessage(), e );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
return false;
}
@@ -356,19 +358,20 @@
public void flush() {
try {
- if ( ! isTransactionInProgress() ) {
+ if ( !isTransactionInProgress() ) {
throw new TransactionRequiredException( "no transaction is in progress" );
}
//adjustFlushMode();
getSession().flush();
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
}
}
/**
* return a Session
+ *
* @throws IllegalStateException if the entity manager is closed
*/
public abstract Session getSession();
@@ -418,7 +421,7 @@
try {
getSession().clear();
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
}
}
@@ -453,14 +456,16 @@
public void lock(Object entity, LockModeType lockMode) {
try {
- if ( ! isTransactionInProgress() ) {
+ if ( !isTransactionInProgress() ) {
throw new TransactionRequiredException( "no transaction is in progress" );
}
//adjustFlushMode();
- if ( !contains( entity ) ) throw new IllegalArgumentException( "entity not in the persistence context" );
+ if ( !contains( entity ) ) {
+ throw new IllegalArgumentException( "entity not in the persistence context" );
+ }
getSession().lock( entity, getLockMode( lockMode ) );
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
}
}
@@ -482,11 +487,11 @@
}
public boolean isTransactionInProgress() {
- return ( (SessionImplementor) getRawSession() ).isTransactionInProgress();
+ return ( ( SessionImplementor ) getRawSession() ).isTransactionInProgress();
}
protected void markAsRollback() {
- log.debug( "mark transaction for rollback");
+ log.debug( "mark transaction for rollback" );
if ( tx.isActive() ) {
tx.setRollbackOnly();
}
@@ -494,7 +499,7 @@
//no explicit use of the tx. boudaries methods
if ( PersistenceUnitTransactionType.JTA == transactionType ) {
TransactionManager transactionManager =
- ( (SessionFactoryImplementor) getRawSession().getSessionFactory() ).getTransactionManager();
+ ( ( SessionFactoryImplementor ) getRawSession().getSessionFactory() ).getTransactionManager();
if ( transactionManager == null ) {
throw new PersistenceException(
"Using a JTA persistence context wo setting hibernate.transaction.manager_lookup_class"
@@ -503,7 +508,7 @@
try {
transactionManager.setRollbackOnly();
}
- catch (SystemException e) {
+ catch ( SystemException e ) {
throw new PersistenceException( "Unable to set the JTA transaction as RollbackOnly", e );
}
}
@@ -515,8 +520,12 @@
}
public <T> T unwrap(Class<T> clazz) {
- if (clazz.equals( Session.class ) ) return (T) getSession();
- if (clazz.equals( SessionImplementor.class ) ) return (T) getSession();
+ 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.
}
@@ -531,7 +540,7 @@
final Transaction transaction = session.getTransaction();
if ( transaction != null && transaction instanceof JoinableCMTTransaction ) {
//can't handle it if not a joinnable transaction
- final JoinableCMTTransaction joinableCMTTransaction = (JoinableCMTTransaction) transaction;
+ final JoinableCMTTransaction joinableCMTTransaction = ( JoinableCMTTransaction ) transaction;
if ( joinableCMTTransaction.getStatus() == JoinableCMTTransaction.JoinStatus.JOINED ) {
log.debug( "Transaction already joined" );
@@ -550,8 +559,7 @@
);
}
}
- else
- if ( joinableCMTTransaction.getStatus() == JoinableCMTTransaction.JoinStatus.MARKED_FOR_JOINED ) {
+ else if ( joinableCMTTransaction.getStatus() == JoinableCMTTransaction.JoinStatus.MARKED_FOR_JOINED ) {
throw new AssertionFailure( "Transaction MARKED_FOR_JOINED after isOpen() call" );
}
//flush before completion and
@@ -563,18 +571,21 @@
boolean flush = false;
TransactionFactory.Context ctx = null;
try {
- ctx = (TransactionFactory.Context) session;
- JoinableCMTTransaction joinable = (JoinableCMTTransaction) session.getTransaction();
+ ctx = ( TransactionFactory.Context ) session;
+ JoinableCMTTransaction joinable = ( JoinableCMTTransaction ) session.getTransaction();
javax.transaction.Transaction transaction = joinable.getTransaction();
- if ( transaction == null )
- log.warn( "Transaction not available on beforeCompletionPhase: assuming valid" );
+ if ( transaction == null ) {
+ log.warn(
+ "Transaction not available on beforeCompletionPhase: assuming valid"
+ );
+ }
flush = !ctx.isFlushModeNever() &&
//ctx.isFlushBeforeCompletionEnabled() &&
//TODO probably make it ! isFlushBeforecompletion()
( transaction == null || !JTAHelper.isRollback( transaction.getStatus() ) );
- //transaction == null workaround a JBoss TMBug
+ //transaction == null workaround a JBoss TMBug
}
- catch (SystemException se) {
+ catch ( SystemException se ) {
log.error( "could not determine transaction status", se );
//throwPersistenceException will mark the transaction as rollbacked
throwPersistenceException(
@@ -584,7 +595,7 @@
)
);
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
}
@@ -597,10 +608,10 @@
log.trace( "skipping managed flushing" );
}
}
- catch (RuntimeException re) {
+ catch ( RuntimeException re ) {
//throwPersistenceException will mark the transaction as rollbacked
if ( re instanceof HibernateException ) {
- throwPersistenceException( (HibernateException) re );
+ throwPersistenceException( ( HibernateException ) re );
}
else {
throwPersistenceException( new PersistenceException( re ) );
@@ -618,11 +629,11 @@
}
if ( session.isOpen() ) {
//only reset if the session is opened since you can't get the Transaction otherwise
- JoinableCMTTransaction joinable = (JoinableCMTTransaction) session.getTransaction();
+ JoinableCMTTransaction joinable = ( JoinableCMTTransaction ) session.getTransaction();
joinable.resetStatus();
}
}
- catch (HibernateException e) {
+ catch ( HibernateException e ) {
throwPersistenceException( e );
}
}
@@ -633,12 +644,14 @@
log.warn( "Cannot join transaction: do not override {}", Environment.TRANSACTION_STRATEGY );
}
}
- catch (HibernateException he) {
+ catch ( HibernateException he ) {
throwPersistenceException( he );
}
}
else {
- if ( !ignoreNotJoining ) log.warn( "Calling joinTransaction() on a non JTA EntityManager" );
+ if ( !ignoreNotJoining ) {
+ log.warn( "Calling joinTransaction() on a non JTA EntityManager" );
+ }
}
}
@@ -661,13 +674,13 @@
}
public void throwPersistenceException(PersistenceException e) {
- if ( ! ( e instanceof NoResultException || e instanceof NonUniqueResultException ) ) {
+ if ( !( e instanceof NoResultException || e instanceof NonUniqueResultException ) ) {
try {
markAsRollback();
}
- catch (Exception ne) {
+ catch ( Exception ne ) {
//we do not want the subsequent exception to swallow the original one
- log.error( "Unable to mark for rollback on PersistenceException: ", ne);
+ log.error( "Unable to mark for rollback on PersistenceException: ", ne );
}
}
throw e;
@@ -675,7 +688,7 @@
public void throwPersistenceException(HibernateException e) {
if ( e instanceof StaleStateException ) {
- PersistenceException pe = wrapStaleStateException( (StaleStateException) e );
+ PersistenceException pe = wrapStaleStateException( ( StaleStateException ) e );
throwPersistenceException( pe );
}
else if ( e instanceof ObjectNotFoundException ) {
@@ -694,9 +707,9 @@
try {
markAsRollback();
}
- catch (Exception ne) {
+ catch ( Exception ne ) {
//we do not want the subsequent exception to swallow the original one
- log.error( "Unable to mark for rollback on TransientObjectException: ", ne);
+ log.error( "Unable to mark for rollback on TransientObjectException: ", ne );
}
throw new IllegalStateException( e ); //Spec 3.2.3 Synchronization rules
}
@@ -708,15 +721,20 @@
public PersistenceException wrapStaleStateException(StaleStateException e) {
PersistenceException pe;
if ( e instanceof StaleObjectStateException ) {
- StaleObjectStateException sose = (StaleObjectStateException) e;
+ StaleObjectStateException sose = ( StaleObjectStateException ) e;
Serializable identifier = sose.getIdentifier();
- if (identifier != null) {
- Object entity = getRawSession().load( sose.getEntityName(), identifier );
- if ( entity instanceof Serializable ) {
- //avoid some user errors regarding boundary crossing
- pe = new OptimisticLockException( null, e, entity );
+ if ( identifier != null ) {
+ try {
+ Object entity = getRawSession().load( sose.getEntityName(), identifier );
+ if ( entity instanceof Serializable ) {
+ //avoid some user errors regarding boundary crossing
+ pe = new OptimisticLockException( null, e, entity );
+ }
+ else {
+ pe = new OptimisticLockException( e );
+ }
}
- else {
+ catch ( EntityNotFoundException enfe ) {
pe = new OptimisticLockException( e );
}
}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/emops/RemoveTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/emops/RemoveTest.java 2009-05-18 22:38:23 UTC (rev 16593)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/emops/RemoveTest.java 2009-05-19 09:55:46 UTC (rev 16594)
@@ -7,6 +7,7 @@
import org.slf4j.LoggerFactory;
import javax.persistence.EntityManager;
+import javax.persistence.OptimisticLockException;
import java.util.Map;
/**
@@ -75,8 +76,7 @@
fail("should have an optimistic lock exception");
}
- //catch( OptimisticLockException e ) {
- catch( Exception e ) {
+ catch( OptimisticLockException e ) {
log.debug("success");
}
finally {
14 years, 11 months
Hibernate SVN: r16593 - core/trunk/testsuite/src/test/java/org/hibernate/test/component/basic.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2009-05-18 18:38:23 -0400 (Mon, 18 May 2009)
New Revision: 16593
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/component/basic/ComponentTest.java
Log:
HHH-3510 : Add FailureExpected test for HQL SQLFunction replacement not occur
ing when HQL text has no parenthesis
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/component/basic/ComponentTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/component/basic/ComponentTest.java 2009-05-18 21:28:34 UTC (rev 16592)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/component/basic/ComponentTest.java 2009-05-18 22:38:23 UTC (rev 16593)
@@ -16,6 +16,7 @@
import org.hibernate.criterion.Property;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.Component;
@@ -157,12 +158,38 @@
s.createQuery( "from Employee e where e.person = :p and 1 = 1 and 2=2" ).setParameter( "p", emp.getPerson() ).list();
s.createQuery( "from Employee e where :p = e.person" ).setParameter( "p", emp.getPerson() ).list();
- s.createQuery( "from Employee e where e.person = ('steve', current_timestamp)" ).list();
+ // The following fails on Sybase due to HHH-3510. When HHH-3510
+ // is fixed, the check for SybaseASE15Dialect should be removed.
+ if ( ! ( getDialect() instanceof SybaseASE15Dialect ) ) {
+ s.createQuery( "from Employee e where e.person = ('steve', current_timestamp)" ).list();
+ }
s.delete( emp );
t.commit();
s.close();
}
+
+ // Sybase should translate "current_timestamp" in HQL to "getdate()";
+ // This fails currently due to HHH-3510. The following test should be
+ // deleted and testComponentQueries() should be updated (as noted
+ // in that test case) when HHH-3510 is fixed.
+ public void testComponentQueryMethodNoParensFailureExpected() {
+ if ( ! ( getDialect() instanceof SybaseASE15Dialect ) ) {
+ fail( "Dialect does not apply to test that is expected to fail; force failure" );
+ }
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ Employee emp = new Employee();
+ emp.setHireDate( new Date() );
+ emp.setPerson( new Person() );
+ emp.getPerson().setName( "steve" );
+ emp.getPerson().setDob( new Date() );
+ s.save( emp );
+ s.createQuery( "from Employee e where e.person = ('steve', current_timestamp)" ).list();
+ s.delete( emp );
+ t.commit();
+ s.close();
+ }
public void testComponentFormulaQuery() {
Session s = openSession();
14 years, 11 months
Hibernate SVN: r16592 - core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/component/basic.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2009-05-18 17:28:34 -0400 (Mon, 18 May 2009)
New Revision: 16592
Modified:
core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/component/basic/ComponentTest.java
Log:
HHH-3510 : Add FailureExpected test for HQL SQLFunction replacement not occur
ing when HQL text has no parenthesis
Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/component/basic/ComponentTest.java
===================================================================
--- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/component/basic/ComponentTest.java 2009-05-18 20:47:10 UTC (rev 16591)
+++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/component/basic/ComponentTest.java 2009-05-18 21:28:34 UTC (rev 16592)
@@ -16,6 +16,7 @@
import org.hibernate.criterion.Property;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.Component;
@@ -157,12 +158,38 @@
s.createQuery( "from Employee e where e.person = :p and 1 = 1 and 2=2" ).setParameter( "p", emp.getPerson() ).list();
s.createQuery( "from Employee e where :p = e.person" ).setParameter( "p", emp.getPerson() ).list();
- s.createQuery( "from Employee e where e.person = ('steve', current_timestamp)" ).list();
+ // The following fails on Sybase due to HHH-3510. When HHH-3510
+ // is fixed, the check for SybaseASE15Dialect should be removed.
+ if ( ! ( getDialect() instanceof SybaseASE15Dialect ) ) {
+ s.createQuery( "from Employee e where e.person = ('steve', current_timestamp)" ).list();
+ }
s.delete( emp );
t.commit();
s.close();
}
+
+ // Sybase should translate "current_timestamp" in HQL to "getdate()";
+ // This fails currently due to HHH-3510. The following test should be
+ // deleted and testComponentQueries() should be updated (as noted
+ // in that test case) when HHH-3510 is fixed.
+ public void testComponentQueryMethodNoParensFailureExpected() {
+ if ( ! ( getDialect() instanceof SybaseASE15Dialect ) ) {
+ fail( "Dialect does not apply to test that is expected to fail; force failure" );
+ }
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ Employee emp = new Employee();
+ emp.setHireDate( new Date() );
+ emp.setPerson( new Person() );
+ emp.getPerson().setName( "steve" );
+ emp.getPerson().setDob( new Date() );
+ s.save( emp );
+ s.createQuery( "from Employee e where e.person = ('steve', current_timestamp)" ).list();
+ s.delete( emp );
+ t.commit();
+ s.close();
+ }
public void testComponentFormulaQuery() {
Session s = openSession();
14 years, 11 months