HV-361 Formatting and adding/updating copyrights

This commit is contained in:
Hardy Ferentschik 2010-11-10 17:41:20 +01:00
parent fd0a463f0e
commit d24a06ee8d
21 changed files with 551 additions and 64 deletions

View File

@ -139,7 +139,7 @@ class TypeSafeActivator {
for ( PropertyDescriptor propertyDesc : descriptor.getConstrainedProperties() ) {
Property property = findPropertyByName( persistentClass, prefix + propertyDesc.getPropertyName() );
boolean hasNotNull = false;
boolean hasNotNull;
if ( property != null ) {
hasNotNull = applyConstraints( propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull );
if ( property.isComposite() && propertyDesc.isCascaded() ) {

View File

@ -1,14 +1,38 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import javax.persistence.Entity;
import javax.persistence.Transient;
import javax.persistence.Id;
import javax.validation.constraints.Size;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Min;
import javax.validation.constraints.Max;
import javax.validation.constraints.Pattern;
import javax.persistence.Transient;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
@Entity
public class Address {
@ -24,7 +48,8 @@ public class Address {
private String country;
private long id;
private boolean internalValid = true;
@Min(-2) @Max(value=50)
@Min(-2)
@Max(value = 50)
public int floor;
public String getCountry() {
@ -99,5 +124,4 @@ public class Address {
public void setId(long id) {
this.id = id;
}
}

View File

@ -1,3 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
@ -14,12 +38,12 @@ public class BeanValidationAutoTest extends TestCase {
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();
fail("invalid object should not be persisted");
fail( "invalid object should not be persisted" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );

View File

@ -1,13 +1,37 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
import javax.validation.ConstraintViolationException;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.mapping.Column;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.test.annotations.TestCase;
/**
@ -17,23 +41,23 @@ public class BeanValidationDisabledTest extends TestCase {
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" );
}
tx.rollback();
s.close();
}
public void testDDLDisabled() {
PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
assertTrue("DDL constraints are applied", countryColumn.isNullable() );
PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
assertTrue( "DDL constraints are applied", countryColumn.isNullable() );
}
@Override

View File

@ -1,3 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.lang.annotation.Annotation;
@ -42,7 +66,7 @@ public class BeanValidationGroupsTest extends TestCase {
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );
// 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()
Annotation annotation = (Annotation) e.getConstraintViolations()
.iterator()
.next()
.getConstraintDescriptor()

View File

@ -1,3 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
@ -19,12 +43,12 @@ public class BeanValidationProvidedFactoryTest extends TestCase {
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();
fail("invalid object should not be persisted");
fail( "invalid object should not be persisted" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );
@ -56,6 +80,6 @@ public class BeanValidationProvidedFactoryTest extends TestCase {
final javax.validation.Configuration<?> configuration = Validation.byDefaultProvider().configure();
configuration.messageInterpolator( messageInterpolator );
ValidatorFactory vf = configuration.buildValidatorFactory();
cfg.getProperties().put( "javax.persistence.validation.factory", vf);
cfg.getProperties().put( "javax.persistence.validation.factory", vf );
}
}

View File

@ -1,8 +1,32 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
/**
* @author Emmanuel Bernard
@ -23,7 +47,7 @@ public class Button {
this.name = name;
}
@Max( 10 )
@Max(10)
public Integer getSize() {
return size;
}

View File

@ -1,8 +1,32 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
/**
@ -13,7 +37,8 @@ public class Color {
private Integer id;
private String name;
@Id @GeneratedValue
@Id
@GeneratedValue
public Integer getId() {
return id;
}

View File

@ -1,3 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
@ -25,7 +49,7 @@ public class CupHolder {
this.id = id;
}
@Max( value = 10, message = "Radius way out")
@Max(value = 10, message = "Radius way out")
@NotNull(groups = Strict.class)
public BigDecimal getRadius() {
return radius;

View File

@ -1,7 +1,31 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.test.annotations.TestCase;
@ -37,7 +61,7 @@ public class DDLTest extends TestCase {
PersistentClass classMapping = getCfg().getClassMapping( Tv.class.getName() );
Column modelColumn = (Column) classMapping.getProperty( "model" ).getColumnIterator().next();
assertEquals( modelColumn.getLength(), 5 );
}
}
public void testApplyOnManyToOne() throws Exception {
PersistentClass classMapping = getCfg().getClassMapping( TvOwner.class.getName() );
@ -48,18 +72,22 @@ public class DDLTest extends TestCase {
public void testSingleTableAvoidNotNull() throws Exception {
PersistentClass classMapping = getCfg().getClassMapping( Rock.class.getName() );
Column serialColumn = (Column) classMapping.getProperty( "bit" ).getColumnIterator().next();
assertTrue( "Notnull should not be applised on single tables", serialColumn.isNullable() );
assertTrue( "Notnull should not be applied on single tables", serialColumn.isNullable() );
}
public void testNotNullOnlyAppliedIfEmbeddedIsNotNullItself() throws Exception {
PersistentClass classMapping = getCfg().getClassMapping( Tv.class.getName() );
Property property = classMapping.getProperty( "tuner.frequency" );
Column serialColumn = (Column) property.getColumnIterator().next();
assertEquals( "Validator annotations are applied on tunner as it is @NotNull", false, serialColumn.isNullable() );
assertEquals(
"Validator annotations are applied on tuner as it is @NotNull", false, serialColumn.isNullable()
);
property = classMapping.getProperty( "recorder.time" );
serialColumn = (Column) property.getColumnIterator().next();
assertEquals( "Validator annotations are applied on tunner as it is @NotNull", true, serialColumn.isNullable() );
assertEquals(
"Validator annotations are applied on tuner as it is @NotNull", true, serialColumn.isNullable()
);
}
protected Class<?>[] getAnnotatedClasses() {

View File

@ -1,13 +1,37 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
import javax.validation.ConstraintViolationException;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.mapping.Column;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.test.annotations.TestCase;
/**
@ -17,7 +41,7 @@ public class DDLWithoutCallbackTest extends TestCase {
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 );
@ -27,7 +51,7 @@ public class DDLWithoutCallbackTest extends TestCase {
}
}
catch ( ConstraintViolationException e ) {
fail("invalid object should not be validated");
fail( "invalid object should not be validated" );
}
catch ( org.hibernate.exception.ConstraintViolationException e ) {
if ( getDialect().supportsColumnCheck() ) {
@ -40,11 +64,11 @@ public class DDLWithoutCallbackTest extends TestCase {
tx.rollback();
s.close();
}
public void testDDLEnabled() {
PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
assertFalse("DDL constraints are not applied", countryColumn.isNullable() );
PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
assertFalse( "DDL constraints are not applied", countryColumn.isNullable() );
}
@Override

View File

@ -1,8 +1,32 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
/**

View File

@ -1,8 +1,31 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import javax.persistence.Embeddable;
import javax.persistence.OneToOne;
import javax.persistence.CascadeType;
import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;
import javax.validation.Valid;
import javax.validation.constraints.Min;

View File

@ -1,3 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
@ -46,7 +70,7 @@ public class HibernateTraversableResolverTest extends TestCase {
try {
s.persist( screen );
s.flush();
fail( "@NotNull on empedded property is not evaluated" );
fail( "@NotNull on embedded property is not evaluated" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );

View File

@ -1,3 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import javax.persistence.Entity;

View File

@ -1,10 +1,34 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
@ -17,7 +41,8 @@ public class PowerSupply {
private BigDecimal power;
private String position;
@Id @GeneratedValue
@Id
@GeneratedValue
public Integer getId() {
return id;
}
@ -26,7 +51,8 @@ public class PowerSupply {
this.id = id;
}
@Min(100) @Max(250)
@Min(100)
@Max(250)
public BigDecimal getPower() {
return power;
}
@ -35,7 +61,7 @@ public class PowerSupply {
this.power = power;
}
@Column(name="fld_pos")
@Column(name = "fld_pos")
public String getPosition() {
return position;
}

View File

@ -1,3 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import javax.persistence.Entity;

View File

@ -1,16 +1,40 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.util.Set;
import java.util.HashSet;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.ManyToMany;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.ElementCollection;
import javax.validation.constraints.NotNull;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
/**
* @author Emmanuel Bernard
@ -23,7 +47,8 @@ public class Screen {
private Set<DisplayConnector> connectors = new HashSet<DisplayConnector>();
private Set<Color> displayColors = new HashSet<Color>();
@Id @GeneratedValue
@Id
@GeneratedValue
public Integer getId() {
return id;
}
@ -32,7 +57,6 @@ public class Screen {
this.id = id;
}
//@NotNull
@Valid
public Button getStopButton() {
return stopButton;
@ -42,7 +66,8 @@ public class Screen {
this.stopButton = stopButton;
}
@ManyToOne(cascade = CascadeType.PERSIST) @Valid
@ManyToOne(cascade = CascadeType.PERSIST)
@Valid
@NotNull
public PowerSupply getPowerSupply() {
return powerSupply;

View File

@ -1,3 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
/**

View File

@ -1,3 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
@ -25,7 +49,7 @@ public class Tv {
@Size(max = 2)
public String serial;
@Length(max=5)
@Length(max = 5)
public String model;
public int size;

View File

@ -1,8 +1,32 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;
@ -14,7 +38,7 @@ public class TvOwner {
@Id
@GeneratedValue
public Integer id;
@ManyToOne
@NotNull
public Tv tv;