HHH-8969 removed deprecated annotations

This commit is contained in:
Brett Meyer 2014-02-14 11:20:55 -05:00
parent b5553a2485
commit ff12d5cdf1
79 changed files with 275 additions and 1157 deletions

View File

@ -1,51 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Property Access type. Prefer the standard {@link javax.persistence.Access} annotation; however,
* {@code @Access} is limited to field/property access definitions.
*
* @author Emmanuel Bernard
*
* @deprecated Use {@link AttributeAccessor} instead; renamed to avoid confusion with the JPA
* {@link javax.persistence.AccessType} enum.
*/
@Target({ TYPE, METHOD, FIELD })
@Retention(RUNTIME)
@Deprecated
public @interface AccessType {
/**
* The access strategy name.
*/
String value();
}

View File

@ -59,24 +59,10 @@ public enum CascadeType {
* Corresponds to the Hibernate native REPLICATE action.
*/
REPLICATE,
/**
* Hibernate originally handled orphan removal as a specialized cascade.
*
* @deprecated use @OneToOne(orphanRemoval=true) or @OneToMany(orphanRemoval=true)
*/
@Deprecated
DELETE_ORPHAN,
/**
* Corresponds to the Hibernate native LOCK action.
*/
LOCK,
/**
* JPA originally planned on calling DETACH EVICT.
*
* @deprecated use javax.persistence.CascadeType.DETACH
*/
@Deprecated
EVICT,
/**
* Corresponds to {@link javax.persistence.CascadeType#REFRESH}.
*/

View File

@ -1,86 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Extends {@link javax.persistence.Entity} with Hibernate features.
*
* @author Emmanuel Bernard
*
* @deprecated See individual attributes for intended replacements. To be removed in 4.1
*/
@Target(TYPE)
@Retention(RUNTIME)
@Deprecated
public @interface Entity {
/**
* Is this entity mutable (read only) or not.
*
* @deprecated use {@link org.hibernate.annotations.Immutable}
*/
@Deprecated
boolean mutable() default true;
/**
* Needed column only in SQL on insert.
* @deprecated use {@link DynamicInsert} instead
*/
@Deprecated
boolean dynamicInsert() default false;
/**
* Needed column only in SQL on update.
* @deprecated Use {@link DynamicUpdate} instead
*/
@Deprecated
boolean dynamicUpdate() default false;
/**
* Do a select to retrieve the entity before any potential update.
* @deprecated Use {@link SelectBeforeUpdate} instead
*/
@Deprecated
boolean selectBeforeUpdate() default false;
/**
* polymorphism strategy for this entity.
* @deprecated use {@link Polymorphism} instead
*/
@Deprecated
PolymorphismType polymorphism() default PolymorphismType.IMPLICIT;
/**
* optimistic locking strategy.
* @deprecated use {@link OptimisticLocking} instead.
*/
@Deprecated
OptimisticLockType optimisticLock() default OptimisticLockType.VERSION;
/**
* persister of this entity, default is hibernate internal one.
* @deprecated use {@link Persister} instead
*/
@Deprecated
String persister() default "";
}

View File

@ -41,13 +41,6 @@ public enum FlushModeType {
* Corresponds to {@link org.hibernate.FlushMode#COMMIT}.
*/
COMMIT,
/**
* Corresponds to {@link org.hibernate.FlushMode#NEVER}.
*
* @deprecated use MANUAL, will be removed in a subsequent release
*/
@Deprecated
NEVER,
/**
* Corresponds to {@link org.hibernate.FlushMode#MANUAL}.
*/

View File

@ -1,54 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Define the foreign key name.
*
* @deprecated Prefer the JPA 2.1 introduced {@link javax.persistence.ForeignKey} instead.
*/
@Target({FIELD, METHOD, TYPE})
@Retention(RUNTIME)
@Deprecated
public @interface ForeignKey {
/**
* Name of the foreign key. Used in OneToMany, ManyToOne, and OneToOne
* relationships. Used for the owning side in ManyToMany relationships
*/
String name();
/**
* Used for the non-owning side of a ManyToMany relationship. Ignored
* in other relationships
*/
String inverseName() default "";
}

View File

@ -1,52 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Define a DB index.
*
* @author Emmanuel Bernard
*
* @deprecated Using {@link javax.persistence.Index} instead.
*/
@Target({FIELD, METHOD})
@Retention(RUNTIME)
@Deprecated
public @interface Index {
/**
* The index name.
*/
String name();
/**
* The column(s) that are indexed.
*/
String[] columnNames() default {};
}

View File

@ -1,64 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Describe an index column of a List.
*
* @author Matthew Inger
*
* @deprecated Prefer the standard JPA {@link javax.persistence.OrderColumn} annotation and the Hibernate specific
* {@link ListIndexBase} (for replacing {@link #base()}).
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
@Deprecated
public @interface IndexColumn {
/**
* The column name.
*/
String name();
/**
* The starting index value. Zero (0) by default, since Lists indexes start at zero (0).
*/
int base() default 0;
/**
* Is the column nullable?
*/
boolean nullable() default true;
/**
* An explicit column definition.
*/
String columnDefinition() default "";
}

View File

@ -1,57 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Collection sort (in-memory sorting). Different that ordering, which is applied during the SQL select.
*
* @author Emmanuel Bernard
*
* @see OrderBy
*
* @deprecated Use {@link SortComparator} or {@link SortNatural} instead depending on need.
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
@Deprecated
public @interface Sort {
/**
* The type of sorting to use. The default is to not use sorting.
*/
SortType type() default SortType.UNSORTED;
/**
* Specifies the comparator to use. Only valid when {@link #type} specifies {@link SortType#COMPARATOR}.
*
* TODO find a way to use Class<Comparator> -> see HHH-8164
*/
Class comparator() default void.class;
}

View File

@ -1,47 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
/**
* Possible collection sorting strategies.
*
* @author Emmanuel Bernard
*
* @deprecated Since {@link Sort} is deprecated.
*/
@Deprecated
public enum SortType {
/**
* The collection is unsorted.
*/
UNSORTED,
/**
* The collection is sorted using its natural sorting.
*/
NATURAL,
/**
* The collection is sorted using a supplied comparator.
*/
COMPARATOR
}

View File

@ -23,11 +23,14 @@
*/
package org.hibernate.annotations;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import javax.persistence.ForeignKey;
import javax.persistence.Index;
/**
* Complementary information to a table either primary or secondary.

View File

@ -23,15 +23,15 @@
*/
package org.hibernate.annotations;
import java.lang.annotation.Retention;
import org.hibernate.EntityMode;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import org.hibernate.EntityMode;
/**
* Define a tuplizer for an entity or a component.
*
@ -45,13 +45,6 @@
*/
Class impl();
/**
* either pojo, dynamic-map or dom4j.
* @deprecated should use #entityModeType instead
*/
@Deprecated
String entityMode() default "pojo";
/**
* The entity mode.
*/

View File

@ -87,7 +87,6 @@
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.EntityMode;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
import org.hibernate.annotations.BatchSize;
@ -107,11 +106,9 @@
import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.FilterDefs;
import org.hibernate.annotations.Filters;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.GenericGenerators;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.annotations.ListIndexBase;
@ -128,7 +125,6 @@
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Parent;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortComparator;
import org.hibernate.annotations.SortNatural;
import org.hibernate.annotations.Source;
@ -607,11 +603,8 @@ public static void bindClass(
PersistentClass persistentClass = makePersistentClass( inheritanceState, superEntity );
Entity entityAnn = clazzToProcess.getAnnotation( Entity.class );
org.hibernate.annotations.Entity hibEntityAnn = clazzToProcess.getAnnotation(
org.hibernate.annotations.Entity.class
);
EntityBinder entityBinder = new EntityBinder(
entityAnn, hibEntityAnn, clazzToProcess, persistentClass, mappings
entityAnn, clazzToProcess, persistentClass, mappings
);
entityBinder.setInheritanceState( inheritanceState );
@ -713,10 +706,6 @@ else if ( clazzToProcess.isAnnotationPresent( Table.class ) ) {
final JoinedSubclass jsc = ( JoinedSubclass ) persistentClass;
SimpleValue key = new DependantValue( mappings, jsc.getTable(), jsc.getIdentifier() );
jsc.setKey( key );
ForeignKey fk = clazzToProcess.getAnnotation( ForeignKey.class );
if ( fk != null && !BinderHelper.isEmptyAnnotationValue( fk.name() ) ) {
key.setForeignKeyName( fk.name() );
}
if ( onDeleteAnn != null ) {
key.setCascadeDeleteEnabled( OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ) );
}
@ -1359,10 +1348,6 @@ private static boolean isEntityClassType(XClass clazzToProcess, AnnotatedClassTy
|| AnnotatedClassType.NONE.equals( classType ) //to be ignored
|| AnnotatedClassType.EMBEDDABLE.equals( classType ) //allow embeddable element declaration
) {
if ( AnnotatedClassType.NONE.equals( classType )
&& clazzToProcess.isAnnotationPresent( org.hibernate.annotations.Entity.class ) ) {
LOG.missingEntityAnnotation( clazzToProcess.getName() );
}
return false;
}
@ -1892,29 +1877,15 @@ else if ( property.isAnnotationPresent( OneToMany.class )
ManyToMany manyToManyAnn = property.getAnnotation( ManyToMany.class );
ElementCollection elementCollectionAnn = property.getAnnotation( ElementCollection.class );
final IndexColumn indexColumn;
if ( property.isAnnotationPresent( OrderColumn.class ) ) {
indexColumn = IndexColumn.buildColumnFromAnnotation(
property.getAnnotation( OrderColumn.class ),
propertyHolder,
inferredData,
entityBinder.getSecondaryTables(),
mappings
);
if ( property.isAnnotationPresent( ListIndexBase.class ) ) {
indexColumn.setBase( ( property.getAnnotation( ListIndexBase.class ) ).value() );
}
}
else {
//if @IndexColumn is not there, the generated IndexColumn is an implicit column and not used.
//so we can leave the legacy processing as the default
indexColumn = IndexColumn.buildColumnFromAnnotation(
property.getAnnotation( org.hibernate.annotations.IndexColumn.class ),
propertyHolder,
inferredData,
mappings
);
final IndexColumn indexColumn = IndexColumn.buildColumnFromAnnotation(
property.getAnnotation( OrderColumn.class ),
propertyHolder,
inferredData,
entityBinder.getSecondaryTables(),
mappings
);
if ( property.isAnnotationPresent( ListIndexBase.class ) ) {
indexColumn.setBase( ( property.getAnnotation( ListIndexBase.class ) ).value() );
}
CollectionBinder collectionBinder = CollectionBinder.getCollectionBinder(
propertyHolder.getEntityName(),
@ -1932,7 +1903,6 @@ else if ( property.isAnnotationPresent( OneToMany.class )
collectionBinder.setJpaOrderBy( property.getAnnotation( javax.persistence.OrderBy.class ) );
collectionBinder.setSqlOrderBy( property.getAnnotation( OrderBy.class ) );
collectionBinder.setSort( property.getAnnotation( Sort.class ) );
collectionBinder.setNaturalSort( property.getAnnotation( SortNatural.class ) );
collectionBinder.setComparatorSort( property.getAnnotation( SortComparator.class ) );
@ -2274,24 +2244,6 @@ else if ( !isId || !entityBinder.isIgnoreIdAnnotations() ) {
}
}
}
//init index
//process indexes after everything: in second pass, many to one has to be done before indexes
Index index = property.getAnnotation( Index.class );
if ( index != null ) {
if ( joinColumns != null ) {
for ( Ejb3Column column : joinColumns ) {
column.addIndex( index, inSecondPass );
}
}
else {
if ( columns != null ) {
for ( Ejb3Column column : columns ) {
column.addIndex( index, inSecondPass );
}
}
}
}
// Natural ID columns must reside in one single UniqueKey within the Table.
// For now, simply ensure consistent naming.
@ -2795,16 +2747,12 @@ private static void setupComponentTuplizer(XProperty property, Component compone
}
if ( property.isAnnotationPresent( Tuplizers.class ) ) {
for ( Tuplizer tuplizer : property.getAnnotation( Tuplizers.class ).value() ) {
EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
//todo tuplizer.entityModeType
component.addTuplizer( mode, tuplizer.impl().getName() );
component.addTuplizer( tuplizer.entityModeType(), tuplizer.impl().getName() );
}
}
if ( property.isAnnotationPresent( Tuplizer.class ) ) {
Tuplizer tuplizer = property.getAnnotation( Tuplizer.class );
EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
//todo tuplizer.entityModeType
component.addTuplizer( mode, tuplizer.impl().getName() );
component.addTuplizer( tuplizer.entityModeType(), tuplizer.impl().getName() );
}
}
@ -2881,10 +2829,6 @@ private static void bindManyToOne(
if ( joinColumn != null && joinColumn.foreignKey() != null ) {
fkName = joinColumn.foreignKey().name();
}
if ( StringHelper.isEmpty( fkName ) ) {
ForeignKey fk = property.getAnnotation( ForeignKey.class );
fkName = fk != null ? fk.name() : "";
}
if ( !StringHelper.isEmpty( fkName ) ) {
value.setForeignKeyName( fkName );
}
@ -3164,7 +3108,6 @@ private static String getCascadeStrategy(
}
if ( orphanRemoval ) {
hibernateCascadeSet.add( CascadeType.DELETE_ORPHAN );
hibernateCascadeSet.add( CascadeType.REMOVE );
}
if ( forcePersist ) {
@ -3195,16 +3138,12 @@ private static String getCascadeStrategy(
case REPLICATE:
cascade.append( "," ).append( "replicate" );
break;
case EVICT:
case DETACH:
cascade.append( "," ).append( "evict" );
break;
case DELETE:
cascade.append( "," ).append( "delete" );
break;
case DELETE_ORPHAN:
cascade.append( "," ).append( "delete-orphan" );
break;
case REMOVE:
cascade.append( "," ).append( "delete" );
break;

View File

@ -30,7 +30,6 @@
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.ColumnTransformer;
import org.hibernate.annotations.ColumnTransformers;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.annotations.Nullability;
import org.hibernate.internal.CoreMessageLogger;
@ -40,7 +39,6 @@
import org.hibernate.mapping.Join;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.jboss.logging.Logger;
/**
@ -647,12 +645,6 @@ public static void checkPropertyConsistency(Ejb3Column[] columns, String propert
}
public void addIndex(Index index, boolean inSecondPass) {
if ( index == null ) return;
String indexName = index.name();
addIndex( indexName, inSecondPass );
}
void addIndex(String indexName, boolean inSecondPass) {
IndexOrUniqueKeySecondPass secondPass = new IndexOrUniqueKeySecondPass( indexName, this, mappings, false );
if ( inSecondPass ) {

View File

@ -23,6 +23,7 @@
*/
package org.hibernate.cfg;
import java.util.Map;
import javax.persistence.OrderColumn;
import org.hibernate.mapping.Join;
@ -119,39 +120,4 @@ public static IndexColumn buildColumnFromAnnotation(
}
return column;
}
/**
* Legacy {@link IndexColumn @IndexColumn} processing.
*
* @param ann The IndexColumn annotation instance
* @param propertyHolder Information about the property
* @param inferredData Yeah, right. Uh...
* @param mappings The mappings being built.
*
* @return The index column
*/
public static IndexColumn buildColumnFromAnnotation(
org.hibernate.annotations.IndexColumn ann,
PropertyHolder propertyHolder,
PropertyData inferredData,
Mappings mappings) {
final IndexColumn column;
if ( ann != null ) {
final String sqlType = BinderHelper.isEmptyAnnotationValue( ann.columnDefinition() ) ? null : ann.columnDefinition();
final String name = BinderHelper.isEmptyAnnotationValue( ann.name() ) ? inferredData.getPropertyName() : ann.name();
//TODO move it to a getter based system and remove the constructor
column = new IndexColumn(
false, sqlType, 0, 0, 0, name, ann.nullable(),
false, true, true, null, null, propertyHolder, mappings
);
column.setBase( ann.base() );
}
else {
column = new IndexColumn(
true, null, 0, 0, 0, null, true,
false, true, true, null, null, propertyHolder, mappings
);
}
return column;
}
}

View File

@ -28,7 +28,6 @@
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.cfg.annotations.PropertyBinder;
import org.hibernate.internal.util.StringHelper;
@ -255,9 +254,6 @@ else if ( otherSideProperty.getValue() instanceof ManyToOne ) {
);
}
}
ForeignKey fk = inferredData.getProperty().getAnnotation( ForeignKey.class );
String fkName = fk != null ? fk.name() : "";
if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) value.setForeignKeyName( fkName );
}
/**

View File

@ -31,6 +31,7 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.persistence.Access;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
@ -39,7 +40,6 @@
import javax.persistence.Transient;
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.annotations.ManyToAny;
import org.hibernate.annotations.Target;
import org.hibernate.annotations.Type;
@ -47,7 +47,6 @@
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.jboss.logging.Logger;
/**
@ -207,35 +206,13 @@ private TreeMap<String, XProperty> initProperties(AccessType access) {
}
private AccessType determineClassDefinedAccessStrategy() {
AccessType classDefinedAccessType;
AccessType hibernateDefinedAccessType = AccessType.DEFAULT;
AccessType jpaDefinedAccessType = AccessType.DEFAULT;
org.hibernate.annotations.AccessType accessType = xClass.getAnnotation( org.hibernate.annotations.AccessType.class );
if ( accessType != null ) {
hibernateDefinedAccessType = AccessType.getAccessStrategy( accessType.value() );
}
AccessType classDefinedAccessType = null;
Access access = xClass.getAnnotation( Access.class );
if ( access != null ) {
jpaDefinedAccessType = AccessType.getAccessStrategy( access.value() );
}
if ( hibernateDefinedAccessType != AccessType.DEFAULT
&& jpaDefinedAccessType != AccessType.DEFAULT
&& hibernateDefinedAccessType != jpaDefinedAccessType ) {
throw new MappingException(
"@AccessType and @Access specified with contradicting values. Use of @Access only is recommended. "
);
}
if ( hibernateDefinedAccessType != AccessType.DEFAULT ) {
classDefinedAccessType = hibernateDefinedAccessType;
}
else {
classDefinedAccessType = jpaDefinedAccessType;
classDefinedAccessType = AccessType.getAccessStrategy( access.value() );
}
return classDefinedAccessType;
}

View File

@ -66,35 +66,14 @@ public PropertyInferredData(XClass declaringClass, XProperty property, String pr
public AccessType getDefaultAccess() throws MappingException {
AccessType accessType = defaultAccess;
AccessType hibernateAccessType = AccessType.DEFAULT;
AccessType jpaAccessType = AccessType.DEFAULT;
org.hibernate.annotations.AccessType accessTypeAnnotation = property.getAnnotation( org.hibernate.annotations.AccessType.class );
if ( accessTypeAnnotation != null ) {
hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() );
}
Access access = property.getAnnotation( Access.class );
if ( access != null ) {
jpaAccessType = AccessType.getAccessStrategy( access.value() );
}
if ( hibernateAccessType != AccessType.DEFAULT
&& jpaAccessType != AccessType.DEFAULT
&& hibernateAccessType != jpaAccessType ) {
StringBuilder builder = new StringBuilder();
builder.append( property.toString() );
builder.append(
" defines @AccessType and @Access with contradicting values. Use of @Access only is recommended."
);
throw new MappingException( builder.toString() );
}
if ( hibernateAccessType != AccessType.DEFAULT ) {
accessType = hibernateAccessType;
}
else if ( jpaAccessType != AccessType.DEFAULT ) {
if ( jpaAccessType != AccessType.DEFAULT ) {
accessType = jpaAccessType;
}
return accessType;

View File

@ -23,11 +23,15 @@
*/
package org.hibernate.cfg.annotations;
import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.ElementCollection;
@ -53,7 +57,6 @@
import org.hibernate.annotations.FilterJoinTable;
import org.hibernate.annotations.FilterJoinTables;
import org.hibernate.annotations.Filters;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@ -67,10 +70,8 @@
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.SQLInsert;
import org.hibernate.annotations.SQLUpdate;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortComparator;
import org.hibernate.annotations.SortNatural;
import org.hibernate.annotations.SortType;
import org.hibernate.annotations.Where;
import org.hibernate.annotations.WhereJoinTable;
import org.hibernate.annotations.common.AssertionFailure;
@ -92,7 +93,6 @@
import org.hibernate.cfg.PropertyHolderBuilder;
import org.hibernate.cfg.PropertyInferredData;
import org.hibernate.cfg.PropertyPreloadedData;
import org.hibernate.cfg.RecoverableException;
import org.hibernate.cfg.SecondPass;
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
import org.hibernate.internal.CoreMessageLogger;
@ -112,12 +112,8 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.TypeDef;
import org.jboss.logging.Logger;
import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
/**
* Base class for binding different types of collections to Hibernate configuration objects.
*
@ -165,7 +161,6 @@ public abstract class CollectionBinder {
private boolean isSortedCollection;
private javax.persistence.OrderBy jpaOrderBy;
private OrderBy sqlOrderBy;
private Sort deprecatedSort;
private SortNatural naturalSort;
private SortComparator comparatorSort;
@ -234,10 +229,6 @@ public void setSqlOrderBy(OrderBy sqlOrderBy) {
this.sqlOrderBy = sqlOrderBy;
}
public void setSort(Sort deprecatedSort) {
this.deprecatedSort = deprecatedSort;
}
public void setNaturalSort(SortNatural naturalSort) {
this.naturalSort = naturalSort;
}
@ -553,21 +544,7 @@ private void applySortingAndOrdering(Collection collection) {
Class<? extends Comparator> comparatorClass = null;
if ( jpaOrderBy == null && sqlOrderBy == null ) {
if ( deprecatedSort != null ) {
LOG.debug( "Encountered deprecated @Sort annotation; use @SortNatural or @SortComparator instead." );
if ( naturalSort != null || comparatorSort != null ) {
throw buildIllegalSortCombination();
}
hadExplicitSort = deprecatedSort.type() != SortType.UNSORTED;
if ( deprecatedSort.type() == SortType.NATURAL ) {
isSorted = true;
}
else if ( deprecatedSort.type() == SortType.COMPARATOR ) {
isSorted = true;
comparatorClass = deprecatedSort.comparator();
}
}
else if ( naturalSort != null ) {
if ( naturalSort != null ) {
if ( comparatorSort != null ) {
throw buildIllegalSortCombination();
}
@ -630,7 +607,6 @@ private AnnotationException buildIllegalSortCombination() {
String.format(
"Illegal combination of annotations on %s. Only one of @%s, @%s and @%s can be used",
safeCollectionRole(),
Sort.class.getName(),
SortNatural.class.getName(),
SortComparator.class.getName()
)
@ -1091,9 +1067,6 @@ private static SimpleValue buildCollectionKey(
key.setUpdateable( joinColumns.length == 0 || joinColumns[0].isUpdatable() );
key.setCascadeDeleteEnabled( cascadeDeleteEnabled );
collValue.setKey( key );
ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null;
String fkName = fk != null ? fk.name() : "";
if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) key.setForeignKeyName( fkName );
return key;
}
@ -1245,11 +1218,6 @@ else if ( anyAnn != null ) {
buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() )
);
}
final ForeignKey fk = property.getAnnotation( ForeignKey.class );
String fkName = fk != null ? fk.inverseName() : "";
if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) {
element.setForeignKeyName( fkName );
}
}
else if ( anyAnn != null ) {
//@ManyToAny

View File

@ -23,10 +23,14 @@
*/
package org.hibernate.cfg.annotations;
import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.persistence.Access;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
@ -39,22 +43,17 @@
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.EntityMode;
import org.hibernate.MappingException;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Filter;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Loader;
import org.hibernate.annotations.NaturalIdCache;
import org.hibernate.annotations.OptimisticLockType;
import org.hibernate.annotations.OptimisticLocking;
import org.hibernate.annotations.Persister;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.RowId;
@ -62,7 +61,6 @@
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.SQLInsert;
import org.hibernate.annotations.SQLUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;
import org.hibernate.annotations.Subselect;
import org.hibernate.annotations.Synchronize;
import org.hibernate.annotations.Tables;
@ -86,7 +84,6 @@
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.DependantValue;
import org.hibernate.mapping.Join;
@ -96,12 +93,8 @@
import org.hibernate.mapping.Table;
import org.hibernate.mapping.TableOwner;
import org.hibernate.mapping.Value;
import org.jboss.logging.Logger;
import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
/**
* Stateful holder and processor for binding Entity information
@ -154,7 +147,6 @@ public EntityBinder() {
public EntityBinder(
Entity ejb3Ann,
org.hibernate.annotations.Entity hibAnn,
XClass annotatedClass,
PersistentClass persistentClass,
Mappings mappings) {
@ -162,52 +154,6 @@ public EntityBinder(
this.persistentClass = persistentClass;
this.annotatedClass = annotatedClass;
bindEjb3Annotation( ejb3Ann );
bindHibernateAnnotation( hibAnn );
}
@SuppressWarnings("SimplifiableConditionalExpression")
private void bindHibernateAnnotation(org.hibernate.annotations.Entity hibAnn) {
{
final DynamicInsert dynamicInsertAnn = annotatedClass.getAnnotation( DynamicInsert.class );
this.dynamicInsert = dynamicInsertAnn == null
? ( hibAnn == null ? false : hibAnn.dynamicInsert() )
: dynamicInsertAnn.value();
}
{
final DynamicUpdate dynamicUpdateAnn = annotatedClass.getAnnotation( DynamicUpdate.class );
this.dynamicUpdate = dynamicUpdateAnn == null
? ( hibAnn == null ? false : hibAnn.dynamicUpdate() )
: dynamicUpdateAnn.value();
}
{
final SelectBeforeUpdate selectBeforeUpdateAnn = annotatedClass.getAnnotation( SelectBeforeUpdate.class );
this.selectBeforeUpdate = selectBeforeUpdateAnn == null
? ( hibAnn == null ? false : hibAnn.selectBeforeUpdate() )
: selectBeforeUpdateAnn.value();
}
{
final OptimisticLocking optimisticLockingAnn = annotatedClass.getAnnotation( OptimisticLocking.class );
this.optimisticLockType = optimisticLockingAnn == null
? ( hibAnn == null ? OptimisticLockType.VERSION : hibAnn.optimisticLock() )
: optimisticLockingAnn.type();
}
{
final Polymorphism polymorphismAnn = annotatedClass.getAnnotation( Polymorphism.class );
this.polymorphismType = polymorphismAnn == null
? ( hibAnn == null ? PolymorphismType.IMPLICIT : hibAnn.polymorphism() )
: polymorphismAnn.type();
}
if ( hibAnn != null ) {
// used later in bind for logging
explicitHibernateEntityAnnotation = true;
//persister handled in bind
}
}
private void bindEjb3Annotation(Entity ejb3Ann) {
@ -260,13 +206,6 @@ public void bindEntity() {
if ( annotatedClass.isAnnotationPresent( Immutable.class ) ) {
mutable = false;
}
else {
org.hibernate.annotations.Entity entityAnn =
annotatedClass.getAnnotation( org.hibernate.annotations.Entity.class );
if ( entityAnn != null ) {
mutable = entityAnn.mutable();
}
}
rootClass.setMutable( mutable );
rootClass.setExplicitPolymorphism( isExplicitPolymorphism( polymorphismType ) );
if ( StringHelper.isNotEmpty( where ) ) rootClass.setWhere( where );
@ -301,17 +240,6 @@ public void bindEntity() {
if ( persisterAnn != null ) {
persister = persisterAnn.impl();
}
else {
org.hibernate.annotations.Entity entityAnn = annotatedClass.getAnnotation( org.hibernate.annotations.Entity.class );
if ( entityAnn != null && !BinderHelper.isEmptyAnnotationValue( entityAnn.persister() ) ) {
try {
persister = ReflectHelper.classForName( entityAnn.persister() );
}
catch (ClassNotFoundException cnfe) {
throw new AnnotationException( "Could not find persister class: " + persister );
}
}
}
if ( persister != null ) {
persistentClass.setEntityPersisterClass( persister );
}
@ -367,16 +295,12 @@ public void bindEntity() {
//tuplizers
if ( annotatedClass.isAnnotationPresent( Tuplizers.class ) ) {
for (Tuplizer tuplizer : annotatedClass.getAnnotation( Tuplizers.class ).value()) {
EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
//todo tuplizer.entityModeType
persistentClass.addTuplizer( mode, tuplizer.impl().getName() );
persistentClass.addTuplizer( tuplizer.entityModeType(), tuplizer.impl().getName() );
}
}
if ( annotatedClass.isAnnotationPresent( Tuplizer.class ) ) {
Tuplizer tuplizer = annotatedClass.getAnnotation( Tuplizer.class );
EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
//todo tuplizer.entityModeType
persistentClass.addTuplizer( mode, tuplizer.impl().getName() );
persistentClass.addTuplizer( tuplizer.entityModeType(), tuplizer.impl().getName() );
}
for ( Filter filter : filters ) {
@ -998,30 +922,9 @@ public AccessType getPropertyAccessor(XAnnotatedElement element) {
public AccessType getExplicitAccessType(XAnnotatedElement element) {
AccessType accessType = null;
AccessType hibernateAccessType = null;
AccessType jpaAccessType = null;
org.hibernate.annotations.AccessType accessTypeAnnotation = element.getAnnotation( org.hibernate.annotations.AccessType.class );
if ( accessTypeAnnotation != null ) {
hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() );
}
Access access = element.getAnnotation( Access.class );
if ( access != null ) {
jpaAccessType = AccessType.getAccessStrategy( access.value() );
}
if ( hibernateAccessType != null && jpaAccessType != null && hibernateAccessType != jpaAccessType ) {
throw new MappingException(
"Found @Access and @AccessType with conflicting values on a property in class " + annotatedClass.toString()
);
}
if ( hibernateAccessType != null ) {
accessType = hibernateAccessType;
}
else if ( jpaAccessType != null ) {
accessType = jpaAccessType;
accessType = AccessType.getAccessStrategy( access.value() );
}
return accessType;

View File

@ -28,7 +28,6 @@
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.annotations.OrderBy;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.CollectionSecondPass;
@ -46,7 +45,6 @@
import org.hibernate.mapping.OneToMany;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
import org.jboss.logging.Logger;
/**
@ -74,12 +72,6 @@ public void setSqlOrderBy(OrderBy orderByAnn) {
LOG.orderByAnnotationIndexedCollection();
}
@Override
public void setSort(Sort sortAnn) {
if ( sortAnn != null )
LOG.sortAnnotationIndexedCollection();
}
@Override
public SecondPass getSecondPass(
final Ejb3JoinColumn[] fkJoinColumns,

View File

@ -24,6 +24,7 @@
package org.hibernate.cfg.annotations;
import java.util.HashMap;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.NamedQueries;
@ -50,7 +51,6 @@
import org.hibernate.engine.spi.NamedSQLQueryDefinition;
import org.hibernate.engine.spi.NamedSQLQueryDefinitionBuilder;
import org.hibernate.internal.CoreMessageLogger;
import org.jboss.logging.Logger;
/**
@ -279,9 +279,6 @@ private static FlushMode getFlushMode(FlushModeType flushModeType) {
case COMMIT:
flushMode = FlushMode.COMMIT;
break;
case NEVER:
flushMode = FlushMode.MANUAL;
break;
case MANUAL:
flushMode = FlushMode.MANUAL;
break;

View File

@ -26,14 +26,14 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.persistence.Index;
import javax.persistence.UniqueConstraint;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.Index;
import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.IndexOrUniqueKeySecondPass;
import org.hibernate.cfg.JPAIndexHolder;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.NamingStrategy;
@ -53,7 +53,6 @@
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.jboss.logging.Logger;
/**
@ -107,7 +106,7 @@ public void setUniqueConstraints(UniqueConstraint[] uniqueConstraints) {
this.uniqueConstraints = TableBinder.buildUniqueConstraintHolders( uniqueConstraints );
}
public void setJpaIndex(javax.persistence.Index[] jpaIndex){
public void setJpaIndex(Index[] jpaIndex){
this.jpaIndexHolders = buildJpaIndexHolder( jpaIndex );
}
@ -536,21 +535,12 @@ public static void createUniqueConstraint(Value value) {
}
public static void addIndexes(Table hibTable, Index[] indexes, Mappings mappings) {
for (Index index : indexes) {
//no need to handle inSecondPass here since it is only called from EntityBinder
mappings.addSecondPass(
new IndexOrUniqueKeySecondPass( hibTable, index.name(), index.columnNames(), mappings )
);
}
}
public static void addIndexes(Table hibTable, javax.persistence.Index[] indexes, Mappings mappings) {
mappings.addJpaIndexHolders( hibTable, buildJpaIndexHolder( indexes ) );
}
public static List<JPAIndexHolder> buildJpaIndexHolder(javax.persistence.Index[] indexes){
public static List<JPAIndexHolder> buildJpaIndexHolder(Index[] indexes){
List<JPAIndexHolder> holders = new ArrayList<JPAIndexHolder>( indexes.length );
for(javax.persistence.Index index : indexes){
for(Index index : indexes){
holders.add( new JPAIndexHolder( index ) );
}
return holders;

View File

@ -26,17 +26,15 @@
import java.util.Collections;
import java.util.List;
import org.jboss.jandex.AnnotationInstance;
import org.hibernate.metamodel.internal.Binder;
import org.hibernate.metamodel.internal.source.annotations.attribute.Column;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
import org.hibernate.metamodel.spi.source.BasicPluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.jboss.jandex.AnnotationInstance;
/**
* @author Strong Liu <stliu@hibernate.org>
@ -66,14 +64,8 @@ public BasicPluralAttributeIndexSourceImpl(
private static List<RelationalValueSource> createRelationalValueSources(PluralAssociationAttribute attribute) {
AnnotationInstance columnAnnotation = JandexHelper.getSingleAnnotation(
attribute.annotations(),
HibernateDotNames.INDEX_COLUMN
JPADotNames.ORDER_COLUMN
);
if ( columnAnnotation == null ) {
columnAnnotation = JandexHelper.getSingleAnnotation(
attribute.annotations(),
JPADotNames.ORDER_COLUMN
);
}
if ( columnAnnotation == null ) {
columnAnnotation = JandexHelper.getSingleAnnotation(
attribute.annotations(),

View File

@ -33,7 +33,6 @@
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.source.AttributeSource;
@ -73,10 +72,9 @@ public IndexedPluralAttributeSourceImpl(
}
if ( attribute.getPluralAttributeNature() == PluralAttributeSource.Nature.ARRAY
&& !attribute.annotations().containsKey( JPADotNames.ORDER_COLUMN )
&& !attribute.annotations().containsKey( HibernateDotNames.INDEX_COLUMN ) ) {
&& !attribute.annotations().containsKey( JPADotNames.ORDER_COLUMN ) ) {
throw new AnnotationException( "The array attribute '" + attribute.getRole()
+ "' must be annotated with @OrderColumn or @IndexColumn!" );
+ "' must be annotated with @OrderColumn!" );
}
if ( attribute.isSequentiallyIndexed() ) {

View File

@ -26,15 +26,13 @@
import java.util.Collections;
import java.util.Map;
import org.jboss.jandex.AnnotationInstance;
import org.hibernate.metamodel.internal.Binder;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.source.HibernateTypeSource;
import org.hibernate.metamodel.spi.source.SequentialPluralAttributeIndexSource;
import org.jboss.jandex.AnnotationInstance;
/**
* @author Gail Badner
@ -67,14 +65,8 @@ public SequentialPluralAttributeIndexSourceImpl(
super( indexedPluralAttributeSource, attribute, defaultNamingStrategy );
AnnotationInstance columnAnnotation = JandexHelper.getSingleAnnotation(
attribute.annotations(),
HibernateDotNames.INDEX_COLUMN
JPADotNames.ORDER_COLUMN
);
if ( columnAnnotation == null ) {
columnAnnotation = JandexHelper.getSingleAnnotation(
attribute.annotations(),
JPADotNames.ORDER_COLUMN
);
}
this.base = columnAnnotation.value( "base" ) != null ? columnAnnotation.value( "base" )
.asInt() : 0;
}

View File

@ -32,14 +32,12 @@
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.internal.Binder;
import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.Column;
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.SingularAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.entity.EntityBindingContext;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
@ -112,23 +110,15 @@ else if ( associationAttribute.getJoinColumnValues() == null ||
private String resolveForeignKeyName(SingularAssociationAttribute associationAttribute) {
String fkName = null;
final AnnotationInstance fkAnnotation = JandexHelper.getSingleAnnotation( associationAttribute().annotations(),
HibernateDotNames.FOREIGN_KEY );
fkName = fkAnnotation != null ? JandexHelper.getValue( fkAnnotation, "name", String.class, cls ) : null;
if (StringHelper.isEmpty( fkName) ) {
final AnnotationInstance joinColumnAnnotation = JandexHelper.getSingleAnnotation(
associationAttribute().annotations(), JPADotNames.JOIN_COLUMN );
if (joinColumnAnnotation != null) {
final AnnotationInstance jpaFkAnnotation = JandexHelper.getValue(
joinColumnAnnotation, "foreignKey", AnnotationInstance.class, cls );
fkName = jpaFkAnnotation != null ? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls )
: null;
}
final AnnotationInstance joinColumnAnnotation = JandexHelper.getSingleAnnotation(
associationAttribute().annotations(), JPADotNames.JOIN_COLUMN );
if (joinColumnAnnotation != null) {
final AnnotationInstance jpaFkAnnotation = JandexHelper.getValue(
joinColumnAnnotation, "foreignKey", AnnotationInstance.class, cls );
fkName = jpaFkAnnotation != null ? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls )
: null;
}
// TODO: join tables?
return fkName;
}

View File

@ -23,14 +23,12 @@
*/
package org.hibernate.metamodel.internal.source.annotations.attribute;
import org.hibernate.AssertionFailure;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.DotName;
import org.hibernate.AssertionFailure;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
/**
* Container for the properties defined by {@link javax.persistence.Column} or {@link javax.persistence.JoinColumn}.
*
@ -64,7 +62,6 @@ protected void applyCheck(AnnotationInstance columnAnnotation) {
if ( !( JPADotNames.COLUMN.equals( name )
|| JPADotNames.JOIN_COLUMN.equals( name )
|| JPADotNames.ORDER_COLUMN.equals( name )
|| HibernateDotNames.INDEX_COLUMN.equals( name )
|| JPADotNames.PRIMARY_KEY_JOIN_COLUMN.equals( name )
|| JPADotNames.MAP_KEY_COLUMN.equals( name )
) ) {

View File

@ -37,7 +37,6 @@
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.SortType;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.internal.source.annotations.attribute.type.AttributeTypeResolver;
@ -216,35 +215,26 @@ private PluralAssociationAttribute(
final ClassLoaderService cls = context.getServiceRegistry().getService( ClassLoaderService.class );
// TODO: This is UGLY -- pull into a util and find a better pattern?
AnnotationInstance foreignKey = JandexHelper.getSingleAnnotation(
annotations(), HibernateDotNames.FOREIGN_KEY );
AnnotationInstance joinTable = JandexHelper.getSingleAnnotation(
annotations(), JPADotNames.JOIN_TABLE );
AnnotationInstance collectionTable = JandexHelper.getSingleAnnotation(
annotations(), JPADotNames.COLLECTION_TABLE );
if (foreignKey != null) {
explicitForeignKeyName = JandexHelper.getValue( foreignKey, "name", String.class, cls );
String temp = JandexHelper.getValue( foreignKey, "inverseName", String.class, cls );
inverseForeignKeyName = StringHelper.isNotEmpty( temp ) ? temp : null;
}
if (joinTable != null && StringHelper.isEmpty( explicitForeignKeyName )) {
final AnnotationInstance jpaFkAnnotation = JandexHelper.getValue(
if (joinTable != null) {
AnnotationInstance jpaFkAnnotation = JandexHelper.getValue(
joinTable, "foreignKey", AnnotationInstance.class, cls );
explicitForeignKeyName = jpaFkAnnotation != null
? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls ) : null;
jpaFkAnnotation = JandexHelper.getValue(
joinTable, "inverseForeignKey", AnnotationInstance.class, cls );
inverseForeignKeyName = jpaFkAnnotation != null
? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls ) : null;
}
if (collectionTable != null && StringHelper.isEmpty( explicitForeignKeyName )) {
if (collectionTable != null) {
final AnnotationInstance jpaFkAnnotation = JandexHelper.getValue(
collectionTable, "foreignKey", AnnotationInstance.class, cls );
explicitForeignKeyName = jpaFkAnnotation != null
? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls ) : null;
}
if (joinTable != null && StringHelper.isEmpty( inverseForeignKeyName )) {
final AnnotationInstance jpaFkAnnotation = JandexHelper.getValue(
joinTable, "inverseForeignKey", AnnotationInstance.class, cls );
inverseForeignKeyName = jpaFkAnnotation != null
? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls ) : null;
}
this.mutable = JandexHelper.getSingleAnnotation( annotations(), HibernateDotNames.IMMUTABLE ) == null;
@ -269,7 +259,6 @@ HibernateDotNames.SQL_DELETE_ALL, annotations()
annotations,
HibernateDotNames.COLLECTION_ID
) != null;
final AnnotationInstance sortAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.SORT );
final AnnotationInstance sortNaturalAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.SORT_NATURAL );
final AnnotationInstance sortComparatorAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.SORT_COMPARATOR );
@ -281,33 +270,6 @@ else if ( sortComparatorAnnotation != null ) {
this.sorted = true;
this.comparatorName = JandexHelper.getValue( sortComparatorAnnotation, "value", String.class, cls );
}
else if ( sortAnnotation != null ) {
final SortType sortType = JandexHelper.getEnumValue( sortAnnotation, "type", SortType.class,
getContext().getServiceRegistry().getService( ClassLoaderService.class ) );
switch ( sortType ){
case NATURAL:
this.sorted = true;
this.comparatorName = "natural";
break;
case COMPARATOR:
String comparatorName = JandexHelper.getValue( sortAnnotation, "comparator", String.class,
getContext().getServiceRegistry().getService( ClassLoaderService.class ) );
if ( StringHelper.isEmpty( comparatorName ) ) {
throw new MappingException(
"Comparator class must be provided when using SortType.COMPARATOR on property: " + getRole(),
getContext().getOrigin()
);
}
this.sorted = true;
this.comparatorName = comparatorName;
break;
default:
this.sorted = false;
this.comparatorName = null;
break;
}
}
else {
this.sorted = false;
this.comparatorName = null;
@ -315,14 +277,7 @@ else if ( sortAnnotation != null ) {
AnnotationInstance orderColumnAnnotation = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ORDER_COLUMN );
AnnotationInstance indexColumnAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.INDEX_COLUMN );
if ( orderColumnAnnotation != null && indexColumnAnnotation != null ) {
throw new MappingException(
"@OrderColumn and @IndexColumn can't be used together on property: " + getRole(),
getContext().getOrigin()
);
}
this.isSequentiallyIndexed = orderColumnAnnotation != null || indexColumnAnnotation != null;
this.isSequentiallyIndexed = orderColumnAnnotation != null;
this.pluralAttributeNature = resolvePluralAttributeNature();
AnnotationInstance batchAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.BATCH_SIZE );
@ -357,7 +312,7 @@ private void checkSortedTypeIsSortable() {
|| SortedSet.class.isAssignableFrom( getAttributeType() ) ) {
if ( !isSorted() ) {
throw new MappingException(
"A sorted collection has to define @Sort: " + getRole(),
"A sorted collection has to define @SortNatural or @SortComparator: " + getRole(),
getContext().getOrigin()
);
}

View File

@ -322,11 +322,6 @@ private AccessType determineClassAccessType(AccessType defaultAccessType) {
if ( accessAnnotation != null ) {
accessType = JandexHelper.getEnumValue( accessAnnotation, "value", AccessType.class,
localBindingContext.getServiceRegistry().getService( ClassLoaderService.class ) );
} else {
accessAnnotation = JandexHelper.getSingleAnnotation( classInfo, HibernateDotNames.ACCESS_TYPE, ClassInfo.class );
if ( accessAnnotation != null ) {
accessType = AccessType.valueOf( accessAnnotation.value().asString().toUpperCase() );
}
}
return accessType;
@ -380,14 +375,8 @@ private Set<String> createExplicitlyConfiguredAccessProperties() {
Set<String> explicitAccessPropertyNames = new HashSet<String>();
List<AnnotationInstance> accessAnnotations = classInfo.annotations().get( JPADotNames.ACCESS );
List<AnnotationInstance> hibernateAccessAnnotations = classInfo.annotations().get( HibernateDotNames.ACCESS_TYPE );
if ( accessAnnotations == null ) {
accessAnnotations = hibernateAccessAnnotations;
if ( accessAnnotations == null ) {
return explicitAccessPropertyNames;
}
} else if ( hibernateAccessAnnotations != null ) {
accessAnnotations.addAll( hibernateAccessAnnotations );
return explicitAccessPropertyNames;
}
// iterate over all @Access annotations defined on the current class

View File

@ -144,24 +144,10 @@ public EntityClass(
processProxyGeneration();
processDiscriminatorValue();
AnnotationInstance foreignKey = JandexHelper.getSingleAnnotation(
classInfo,
HibernateDotNames.FOREIGN_KEY,
ClassInfo.class
);
this.joinedSubclassPrimaryKeyJoinColumnSources = determinePrimaryKeyJoinColumns();
if ( foreignKey != null ) {
ensureJoinedSubEntity();
explicitForeignKeyName = JandexHelper.getValue( foreignKey, "name", String.class,
getLocalBindingContext().getServiceRegistry().getService( ClassLoaderService.class ) );
String temp = JandexHelper.getValue( foreignKey, "inverseName", String.class,
getLocalBindingContext().getServiceRegistry().getService( ClassLoaderService.class ) );
inverseForeignKeyName = StringHelper.isNotEmpty( temp ) ? temp : null;
}
else {
explicitForeignKeyName = null;
inverseForeignKeyName = null;
}
// TODO: bind JPA @ForeignKey?
explicitForeignKeyName = null;
inverseForeignKeyName = null;
this.onDeleteAction = determineOnDeleteAction();
}

View File

@ -171,9 +171,6 @@ public static FlushMode getFlushMode(FlushModeType flushModeType) {
case COMMIT:
flushMode = FlushMode.COMMIT;
break;
case NEVER:
flushMode = FlushMode.MANUAL;
break;
case MANUAL:
flushMode = FlushMode.MANUAL;
break;

View File

@ -25,6 +25,7 @@
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.GenerationType;
@ -127,9 +128,6 @@ public static CascadeStyle cascadeTypeToCascadeStyle(
case LOCK: {
return CascadeStyles.LOCK;
}
case DELETE_ORPHAN: {
return CascadeStyles.DELETE_ORPHAN;
}
default: {
throw new AssertionFailure( "Unknown cascade type: " + cascadeType );
}

View File

@ -23,9 +23,6 @@
*/
package org.hibernate.metamodel.internal.source.annotations.util;
import org.jboss.jandex.DotName;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.Any;
import org.hibernate.annotations.AnyMetaDef;
import org.hibernate.annotations.AnyMetaDefs;
@ -50,14 +47,11 @@
import org.hibernate.annotations.FilterJoinTable;
import org.hibernate.annotations.FilterJoinTables;
import org.hibernate.annotations.Filters;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.GenericGenerators;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.IndexColumn;
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.hibernate.annotations.JoinFormula;
@ -90,7 +84,6 @@
import org.hibernate.annotations.SQLInsert;
import org.hibernate.annotations.SQLUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortComparator;
import org.hibernate.annotations.SortNatural;
import org.hibernate.annotations.Source;
@ -108,6 +101,7 @@
import org.hibernate.annotations.TypeDefs;
import org.hibernate.annotations.Where;
import org.hibernate.annotations.WhereJoinTable;
import org.jboss.jandex.DotName;
/**
* Defines the dot names for the Hibernate specific mapping annotations.
@ -115,7 +109,6 @@
* @author Hardy Ferentschik
*/
public interface HibernateDotNames {
DotName ACCESS_TYPE = DotName.createSimple( AccessType.class.getName() );
DotName ANY = DotName.createSimple( Any.class.getName() );
DotName ANY_META_DEF = DotName.createSimple( AnyMetaDef.class.getName() );
DotName ANY_META_DEFS = DotName.createSimple( AnyMetaDefs.class.getName() );
@ -141,14 +134,11 @@ public interface HibernateDotNames {
DotName FILTER_DEFS = DotName.createSimple( FilterDefs.class.getName() );
DotName FILTER_JOIN_TABLE = DotName.createSimple( FilterJoinTable.class.getName() );
DotName FILTER_JOIN_TABLES = DotName.createSimple( FilterJoinTables.class.getName() );
DotName FOREIGN_KEY = DotName.createSimple( ForeignKey.class.getName() );
DotName FORMULA = DotName.createSimple( Formula.class.getName() );
DotName GENERATED = DotName.createSimple( Generated.class.getName() );
DotName GENERIC_GENERATOR = DotName.createSimple( GenericGenerator.class.getName() );
DotName GENERIC_GENERATORS = DotName.createSimple( GenericGenerators.class.getName() );
DotName IMMUTABLE = DotName.createSimple( Immutable.class.getName() );
DotName INDEX = DotName.createSimple( Index.class.getName() );
DotName INDEX_COLUMN = DotName.createSimple( IndexColumn.class.getName() );
DotName JOIN_COLUMN_OR_FORMULA = DotName.createSimple( JoinColumnOrFormula.class.getName() );
DotName JOIN_COLUMNS_OR_FORMULAS = DotName.createSimple( JoinColumnsOrFormulas.class.getName() );
DotName JOIN_FORMULA = DotName.createSimple( JoinFormula.class.getName() );
@ -177,7 +167,6 @@ public interface HibernateDotNames {
DotName PROXY = DotName.createSimple( Proxy.class.getName() );
DotName ROW_ID = DotName.createSimple( RowId.class.getName() );
DotName SELECT_BEFORE_UPDATE = DotName.createSimple( SelectBeforeUpdate.class.getName() );
DotName SORT = DotName.createSimple( Sort.class.getName() );
DotName SORT_COMPARATOR = DotName.createSimple( SortComparator.class.getName());
DotName SORT_NATURAL = DotName.createSimple( SortNatural.class.getName() );
DotName SOURCE = DotName.createSimple( Source.class.getName() );

View File

@ -23,9 +23,15 @@
*/
package org.hibernate.metamodel.internal.source.annotations.util;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.persistence.AttributeOverride;
import javax.persistence.Basic;
import javax.persistence.Column;
@ -33,27 +39,19 @@
import javax.persistence.LockModeType;
import javax.persistence.NamedQuery;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.NamedNativeQuery;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* Tests for the helper class {@link JandexHelper}.
@ -179,23 +177,6 @@ class Foo {
assertEquals( "Wrong lock mode", LockModeType.OPTIMISTIC, lockMode );
}
@Test
public void testRetrieveStringArray() {
class Foo {
@org.hibernate.annotations.Index(name = "index", columnNames = { "a", "b", "c" })
private String foo;
}
IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class );
Collection<AnnotationInstance> annotationInstances = index.getAnnotations( HibernateDotNames.INDEX );
assertTrue( annotationInstances.size() == 1 );
AnnotationInstance annotationInstance = annotationInstances.iterator().next();
String[] columnNames = JandexHelper.getValue( annotationInstance, "columnNames", String[].class,
classLoaderService );
Assert.assertTrue( columnNames.length == 3 );
}
@Test(expected = AssertionFailure.class)
public void testRetrieveClassParameterAsClass() {
@NamedNativeQuery(name = "foo", query = "bar", resultClass = Foo.class)

View File

@ -7,13 +7,14 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OrderColumn;
import org.hibernate.annotations.IndexColumn;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
/**
@ -70,7 +71,7 @@ public void setTheSet(Set<ReferencedEntity> theSet) {
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "theListOwner", nullable = false)
@IndexColumn( name = "list_index")
@OrderColumn( name = "list_index")
public List<ReferencedEntity> getTheList() {
return theList;
}

View File

@ -1,8 +1,11 @@
//$Id$
package org.hibernate.test.annotations;
import static org.hibernate.annotations.CascadeType.ALL;
import java.io.Serializable;
import java.util.Collection;
import java.util.SortedSet;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@ -13,10 +16,7 @@
import javax.persistence.OneToOne;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortType;
import static org.hibernate.annotations.CascadeType.ALL;
import org.hibernate.annotations.SortComparator;
/**
@ -55,7 +55,7 @@ public void setName(String string) {
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "CUST_ID")
@Sort(type = SortType.COMPARATOR, comparator = TicketComparator.class)
@SortComparator(TicketComparator.class)
public SortedSet<Ticket> getTickets() {
return tickets;
}

View File

@ -3,13 +3,13 @@
import javax.persistence.Entity;
import javax.persistence.Transient;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.AttributeAccessor;
/**
* @author Emmanuel Bernard
*/
@Entity
@AccessType("property")
@AttributeAccessor("property")
public class Bed extends Furniture {
String quality;

View File

@ -5,13 +5,13 @@
import javax.persistence.Id;
import javax.persistence.Transient;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.AttributeAccessor;
/**
* @author Emmanuel Bernard
*/
@Entity
@AccessType("field")
@AttributeAccessor("field")
public class Furniture extends Woody {
@Id
@GeneratedValue
@ -36,7 +36,7 @@ public void setId(Integer id) {
this.id = id;
}
@AccessType("property")
@AttributeAccessor("property")
public long weight;
public long getWeight() {

View File

@ -5,7 +5,7 @@
import javax.persistence.Id;
import javax.persistence.Transient;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.AttributeAccessor;
/**
* This is the opposite of the Furniture test, as this tries to override the class AccessType("property") with
@ -15,7 +15,7 @@
* @since 2007-05-31
*/
@Entity
@AccessType( "property" )
@AttributeAccessor( "property" )
public class Gardenshed
extends
Woody {
@ -43,7 +43,7 @@ public void setId(Integer id) {
}
// These 2 functions should not return in Hibernate, but the value should come from the field "floors"
@AccessType( "field" )
@AttributeAccessor( "field" )
public long getFloors() {
return this.floors + 2;
}

View File

@ -2,13 +2,13 @@
package org.hibernate.test.annotations.access;
import javax.persistence.MappedSuperclass;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.AttributeAccessor;
/**
* @author Emmanuel Bernard
*/
@MappedSuperclass
@AccessType("property")
@AttributeAccessor("property")
public class Woody extends Thingy {
private String color;
private String name;

View File

@ -24,6 +24,7 @@
*/
package org.hibernate.test.annotations.access.jpa;
import java.util.List;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.CascadeType;
@ -32,6 +33,8 @@
import javax.persistence.Id;
import javax.persistence.OneToMany;
import org.hibernate.annotations.AttributeAccessor;
/**
* @author Hardy Ferentschik
@ -48,7 +51,7 @@ public class Course3 {
@Id
@GeneratedValue
@org.hibernate.annotations.AccessType("field")
@AttributeAccessor("field")
public long getId() {
return id;
}

View File

@ -17,11 +17,11 @@
*/
package org.hibernate.test.annotations.access.xml;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.Entity;
/**
* @author Hardy Ferentschik
*/

View File

@ -1,15 +1,17 @@
//$Id$
package org.hibernate.test.annotations.backquotes;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import org.hibernate.annotations.Index;
import javax.persistence.Table;
@Entity
@Table(indexes = @Index(name="`titleindex`", columnList = "title"))
public class Bug
{
@Id
@ -17,7 +19,6 @@ public class Bug
private int id;
@Column(name="`title`")
@Index(name="`titleindex`")
private String title;
@ManyToMany

View File

@ -27,18 +27,17 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;
import org.hibernate.annotations.ForeignKey;
@Entity
@Table(name = "CODED_PAIR_SET_HOLDER")
class CodedPairSetHolder implements Serializable {
@ -54,8 +53,8 @@ class CodedPairSetHolder implements Serializable {
private String code;
@ElementCollection
@CollectionTable(name = "CODED_PAIR_HOLDER_PAIR_SET", joinColumns = @JoinColumn(name = "CODED_PAIR_HOLDER_ID"))
@ForeignKey(name = "FK_PAIR_SET")
@CollectionTable(name = "CODED_PAIR_HOLDER_PAIR_SET", joinColumns = @JoinColumn(name = "CODED_PAIR_HOLDER_ID"),
foreignKey = @ForeignKey(name = "FK_PAIR_SET"))
private final Set<PersonPair> pairs = new HashSet<PersonPair>(0);
CodedPairSetHolder() {

View File

@ -24,27 +24,27 @@
package org.hibernate.test.annotations.cascade;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.ForeignKey;
@Embeddable
class PersonPair implements Serializable {
private static final long serialVersionUID = 4543565503074112720L;
@ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@JoinColumn(name = "LEFT_PERSON_ID", nullable = false, updatable = false)
@ForeignKey(name = "FK_LEFT_PERSON")
@JoinColumn(name = "LEFT_PERSON_ID", nullable = false, updatable = false,
foreignKey = @ForeignKey(name = "FK_LEFT_PERSON"))
private Person left;
@ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@JoinColumn(name = "RIGHT_PERSON_ID", nullable = false, updatable = false)
@ForeignKey(name = "FK_RIGHT_PERSON")
@JoinColumn(name = "RIGHT_PERSON_ID", nullable = false, updatable = false,
foreignKey = @ForeignKey(name = "FK_RIGHT_PERSON"))
private Person right;
PersonPair() {

View File

@ -3,6 +3,7 @@
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@ -10,8 +11,7 @@
import javax.persistence.MapKeyColumn;
import org.hibernate.annotations.MapKeyType;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortType;
import org.hibernate.annotations.SortNatural;
import org.hibernate.annotations.Type;
/**
@ -25,7 +25,7 @@ public class Matrix {
@MapKeyType( @Type(type="integer") )
@ElementCollection
@Sort(type = SortType.NATURAL)
@SortNatural
@Type(type = "float")
@MapKeyColumn(nullable = false)
private SortedMap<Integer, Float> mvalues = new TreeMap<Integer, Float>();

View File

@ -1,10 +1,11 @@
//$Id$
package org.hibernate.test.annotations.embedded;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.AttributeAccessor;
/**
* Non realistic embedded dependent object
@ -12,7 +13,7 @@
* @author Emmanuel Bernard
*/
@Embeddable
@AccessType("property")
@AttributeAccessor("property")
public class Country implements Serializable {
private String iso2;
private String name;

View File

@ -1,9 +1,10 @@
//$Id$
package org.hibernate.test.annotations.embedded;
import java.io.Serializable;
import javax.persistence.Embeddable;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.AttributeAccessor;
/**
* Regional article pk
@ -11,7 +12,7 @@
* @author Emmanuel Bernard
*/
@Embeddable
@AccessType("field")
@AttributeAccessor("field")
public class RegionalArticlePk implements Serializable {
/**
* country iso2 code

View File

@ -25,7 +25,7 @@
import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.AttributeAccessor;
/**
* TODO : javadoc
@ -33,7 +33,7 @@
* @author Steve Ebersole
*/
@Embeddable
@AccessType("property")
@AttributeAccessor("property")
public class Address {
private String line1;
private String line2;

View File

@ -22,11 +22,10 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.embedded.one2many;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.Entity;
/**
* TODO : javadoc
*

View File

@ -24,7 +24,7 @@
package org.hibernate.test.annotations.embedded.one2many;
import javax.persistence.Embeddable;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.AttributeAccessor;
/**
* TODO : javadoc
@ -32,7 +32,7 @@
* @author Steve Ebersole
*/
@Embeddable
@AccessType("property")
@AttributeAccessor("property")
public class Name {
private String first;
private String last;

View File

@ -24,11 +24,12 @@
package org.hibernate.test.annotations.embedded.one2many;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Embeddable;
import javax.persistence.OneToMany;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.AttributeAccessor;
/**
* TODO : javadoc
@ -36,7 +37,7 @@
* @author Steve Ebersole
*/
@Embeddable
@AccessType("property")
@AttributeAccessor("property")
public class PersonName extends Name {
private Set<Alias> aliases = new HashSet<Alias>();

View File

@ -1,22 +1,28 @@
//$Id$
package org.hibernate.test.annotations.entity;
import java.util.Set;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Lob;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.Filters;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.OptimisticLock;
import org.hibernate.annotations.OptimisticLockType;
import org.hibernate.annotations.OptimisticLocking;
import org.hibernate.annotations.ParamDef;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;
import org.hibernate.annotations.SelectBeforeUpdate;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;
@ -27,11 +33,11 @@
*/
@Entity
@BatchSize(size = 5)
@org.hibernate.annotations.Entity(
selectBeforeUpdate = true,
dynamicInsert = true, dynamicUpdate = true,
optimisticLock = OptimisticLockType.ALL,
polymorphism = PolymorphismType.EXPLICIT)
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@OptimisticLocking(type = OptimisticLockType.ALL)
@Polymorphism(type = PolymorphismType.EXPLICIT)
@Where(clause = "1=1")
@FilterDef(name = "minLength", parameters = {@ParamDef(name = "minLength", type = "integer")})
@Filters({
@ -39,7 +45,7 @@
@Filter(name = "minLength", condition = ":minLength <= length")
})
@org.hibernate.annotations.Table(appliesTo = "Forest",
indexes = {@Index(name = "idx", columnNames = {"name", "length"})})
indexes = {@Index(name = "idx", columnList = "name, length")})
public class Forest {
private Integer id;
private String name;

View File

@ -23,17 +23,12 @@
*/
package org.hibernate.test.annotations.entity;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import static org.junit.Assert.assertEquals;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* @author Steve Ebersole
*/
@ -49,7 +44,6 @@ protected String[] getAnnotatedPackages() {
}
@Test
@FailureExpectedWithNewMetamodel
public void testSameMappingValues() {
EntityBinding forest = metadata().getEntityBinding( Forest.class.getName() );
EntityBinding forest2 = metadata().getEntityBinding( Forest2.class.getName() );

View File

@ -5,13 +5,14 @@
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Immutable;
/**
* @author Emmanuel Bernard
*/
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
@Entity
@org.hibernate.annotations.Entity(mutable = false)
@Immutable
public class ZipCode {
@Id
public String code;

View File

@ -2,14 +2,14 @@
package org.hibernate.test.annotations.indexcoll;
import java.util.SortedMap;
import java.util.TreeMap;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.MapKey;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortType;
import org.hibernate.annotations.SortNatural;
/**
* @author Emmanuel Bernard
@ -17,7 +17,7 @@
@Entity
public class Training {
@Id @GeneratedValue private Long id;
@Sort(type= SortType.NATURAL)
@SortNatural
@MapKey(name="name") @ManyToMany SortedMap<String, Trainee> trainees = new TreeMap<String, Trainee>();
public Long getId() {

View File

@ -3,13 +3,10 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import org.hibernate.annotations.ForeignKey;
/**
* @author Emmanuel Bernard
*/
@Entity
@ForeignKey(name = "FK_DOCU_FILE")
public class Document extends File {
@Column(nullable = false, name="xsize")
private int size;

View File

@ -1,17 +1,18 @@
//$Id$
package org.hibernate.test.annotations.join;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.SecondaryTable;
import javax.persistence.SecondaryTables;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.SQLInsert;
import org.hibernate.annotations.Table;
import org.hibernate.annotations.Tables;
@ -25,11 +26,12 @@
@SecondaryTable(name = "Cat2", uniqueConstraints = {@UniqueConstraint(columnNames = {"storyPart2"})})
})
@Tables( {
@Table(appliesTo = "Cat", indexes = @Index(name = "secondname",
columnNames = "secondName"), comment = "My cat table" ),
@Table(comment = "My cat table", appliesTo = "Cat", indexes = {
@Index(name = "secondname", columnList = "secondName"),
@Index(name = "nameindex", columnList = "name"),
@Index(name = "story1index", columnList = "`Cat nbr1`")}),
@Table(appliesTo = "Cat2", foreignKey = @ForeignKey(name="FK_CAT2_CAT"), fetch = FetchMode.SELECT,
sqlInsert=@SQLInsert(sql="insert into Cat2(storyPart2, id) values(upper(?), ?)") )
} )
sqlInsert=@SQLInsert(sql="insert into Cat2(storyPart2, id) values(upper(?), ?)"))})
public class Cat implements Serializable {
private Integer id;
@ -44,7 +46,6 @@ public Integer getId() {
return id;
}
@Index(name = "nameindex")
public String getName() {
return name;
}
@ -77,7 +78,6 @@ public void setSecondName(String secondName) {
// }
@Column(table = "`Cat nbr1`")
@Index(name = "story1index")
public String getStoryPart1() {
return storyPart1;
}

View File

@ -2,15 +2,15 @@
package org.hibernate.test.annotations.manytomany;
import java.io.Serializable;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import org.hibernate.annotations.ForeignKey;
/**
* Woman knowing several mens
*
@ -33,19 +33,16 @@ public void setCats(Set<Cat> cats) {
}
@ManyToMany(cascade = {CascadeType.ALL})
@JoinTable(
name = "Man_Woman",
@JoinTable(name = "Man_Woman",
joinColumns = {
@JoinColumn(name = "womanLastName", referencedColumnName = "lastName"),
@JoinColumn(name = "womanFirstName", referencedColumnName = "firstName")
},
@JoinColumn(name = "womanLastName", referencedColumnName = "lastName"),
@JoinColumn(name = "womanFirstName", referencedColumnName = "firstName") },
inverseJoinColumns = {
@JoinColumn(name = "manIsElder", referencedColumnName = "elder"),
@JoinColumn(name = "manLastName", referencedColumnName = "lastName"),
@JoinColumn(name = "manFirstName", referencedColumnName = "firstName")
}
)
@ForeignKey(name = "WM_W_FK", inverseName = "WM_M_FK")
@JoinColumn(name = "manIsElder", referencedColumnName = "elder"),
@JoinColumn(name = "manLastName", referencedColumnName = "lastName"),
@JoinColumn(name = "manFirstName", referencedColumnName = "firstName") },
foreignKey = @ForeignKey(name = "WM_W_FK"),
inverseForeignKey = @ForeignKey(name = "WM_M_FK"))
public Set<Man> getMens() {
return mens;
}

View File

@ -2,12 +2,12 @@
package org.hibernate.test.annotations.manytoone;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.ForeignKey;
/**
* Many to one sample using default mapping values
*
@ -30,7 +30,7 @@ public void setId(Integer id) {
}
@ManyToOne(fetch = FetchType.EAGER)
@ForeignKey(name="BODY_COLOR_FK")
@JoinColumn(foreignKey = @ForeignKey(name="BODY_COLOR_FK"))
public Color getBodyColor() {
return bodyColor;
}

View File

@ -1,7 +1,9 @@
//$Id$
package org.hibernate.test.annotations.manytoone;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
@ -9,8 +11,6 @@
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import org.hibernate.annotations.ForeignKey;
/**
* @author Emmanuel Bernard
*/
@ -24,10 +24,9 @@ public class ForestType {
@OneToOne
@JoinTable(name="BiggestRepPerForestType",
joinColumns = @JoinColumn(name="forest_type"),
inverseJoinColumns = @JoinColumn(name="forest")
)
@ForeignKey(name="A_TYP_FK",
inverseName = "A_FOR_FK" //inverse fail cause it involves a Join
inverseJoinColumns = @JoinColumn(name="forest"),
foreignKey = @ForeignKey(name="A_TYP_FK"),
inverseForeignKey = @ForeignKey(name="A_FOR_FK") //inverse fail cause it involves a Join
)
public BiggestForest getBiggestRepresentative() {
return biggestRepresentative;

View File

@ -2,15 +2,15 @@
package org.hibernate.test.annotations.onetomany;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Immutable;
/**
@ -52,8 +52,7 @@ public void setStreets(List<Street> streets) {
}
@OneToMany
@JoinColumn(name = "mainstreetcity_id")
@ForeignKey(name = "CITYSTR_FK")
@JoinColumn(name = "mainstreetcity_id", foreignKey = @ForeignKey(name = "CITYSTR_FK"))
@OrderBy
@Immutable
public List<Street> getMainStreets() {

View File

@ -1,15 +1,15 @@
//$Id$
package org.hibernate.test.annotations.onetomany;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import org.hibernate.annotations.ForeignKey;
/**
* Unidirectional one to many sample
*
@ -54,9 +54,10 @@ public void setTrainedTigers(Set<Tiger> trainedTigers) {
name = "TrainedMonkeys",
//columns are optional, here we explicit them
joinColumns = @JoinColumn(name = "trainer_id"),
inverseJoinColumns = @JoinColumn(name = "monkey_id")
inverseJoinColumns = @JoinColumn(name = "monkey_id"),
foreignKey = @ForeignKey(name = "TM_TRA_FK"),
inverseForeignKey = @ForeignKey(name = "TM_MON_FK")
)
@ForeignKey(name = "TM_TRA_FK", inverseName = "TM_MON_FK")
public Set<Monkey> getTrainedMonkeys() {
return trainedMonkeys;
}

View File

@ -2,6 +2,7 @@
package org.hibernate.test.annotations.onetomany;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@ -24,9 +25,8 @@ public class Troop {
private String name;
private Set<Soldier> soldiers;
@OneToMany(mappedBy = "troop", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
@OneToMany(mappedBy = "troop", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY, orphanRemoval = true)
@OrderBy(clause = "name desc")
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@OnDelete(action = OnDeleteAction.CASCADE)
public Set<Soldier> getSoldiers() {
return soldiers;

View File

@ -1,15 +1,18 @@
package org.hibernate.test.annotations.persister;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.Persister;
/**
* @author Shawn Clowater
*/
@Entity
@org.hibernate.annotations.Entity( persister = "org.hibernate.persister.entity.SingleTableEntityPersister" )
@Persister(impl = org.hibernate.persister.entity.SingleTableEntityPersister.class)
public class Card implements Serializable {
@Id
public Integer id;

View File

@ -1,6 +1,7 @@
package org.hibernate.test.annotations.persister;
import java.io.Serializable;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@ -12,7 +13,6 @@
* @author Shawn Clowater
*/
@Entity
@org.hibernate.annotations.Entity( persister = "org.hibernate.persister.entity.SingleTableEntityPersister" )
@Persister( impl = org.hibernate.test.annotations.persister.EntityPersister.class )
public class Deck implements Serializable {
@Id

View File

@ -23,15 +23,14 @@
*/
package org.hibernate.test.annotations.persister;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
import org.hibernate.persister.entity.SingleTableEntityPersister;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
import org.hibernate.persister.entity.SingleTableEntityPersister;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
/**
* @author Shawn Clowater
*/
@ -46,7 +45,6 @@ public void testEntityEntityPersisterAndPersisterSpecified() throws Exception {
}
@Test
@FailureExpectedWithNewMetamodel
public void testEntityEntityPersisterSpecified() throws Exception {
//tests the persister specified with an @Entity.persister()
Class<? extends org.hibernate.persister.entity.EntityPersister> clazz =

View File

@ -8,6 +8,7 @@
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;
/**
@ -15,7 +16,7 @@
*/
@Entity
@Inheritance(strategy= InheritanceType.TABLE_PER_CLASS)
@org.hibernate.annotations.Entity(polymorphism = PolymorphismType.EXPLICIT)
@Polymorphism(type = PolymorphismType.EXPLICIT)
public class Car extends Automobile {
@Id

View File

@ -27,7 +27,6 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
@ -39,7 +38,6 @@
public class PolymorphismTest extends BaseCoreFunctionalTestCase {
@Test
@FailureExpectedWithNewMetamodel
public void testPolymorphism() throws Exception {
Car car = new Car();
car.setModel( "SUV" );

View File

@ -3,6 +3,7 @@
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;
/**
@ -10,6 +11,6 @@
*/
@Entity
@Table(name = "sport_car")
@org.hibernate.annotations.Entity(polymorphism = PolymorphismType.EXPLICIT) //raise a warn
@Polymorphism(type = PolymorphismType.EXPLICIT) //raise a warn
public class SportCar extends Car {
}

View File

@ -5,18 +5,16 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.Index;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Emmanuel Bernard
*/
@Entity
@FailureExpectedWithNewMetamodel
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"start.country", "start.city"})})
@Table(uniqueConstraints = @UniqueConstraint(columnNames = {"start.country", "start.city"}),
indexes = @Index(name="storm_name_idx", columnList = "stormName"))
public class Storm {
private Integer id;
private Location start;
@ -51,7 +49,6 @@ public void setEnd(Location end) {
this.end = end;
}
@Index(name="storm_name_idx")
@Column(unique = true)
public String getStormName() {
return stormName;

View File

@ -3,16 +3,17 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import org.hibernate.annotations.Index;
import javax.persistence.Table;
/**
* @author Emmanuel Bernard
*/
@Entity(name = "xpmComponent")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(indexes = @Index(name = "manufacturerPartNumber", columnList = "manufacturerPartNumber"))
public abstract class Component {
private String manufacturerPartNumber;
private Long manufacturerId;
@ -31,7 +32,6 @@ public Long getId() {
}
@Column(nullable = false)
@Index(name = "manufacturerPartNumber")
public String getManufacturerPartNumber() {
return manufacturerPartNumber;
}

View File

@ -4,22 +4,23 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.Version;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.OptimisticLock;
/**
* @author Emmanuel Bernard
*/
@Entity
@Table(indexes = @Index(name = "cond_name", columnList = "cond_name"))
public class Conductor {
@Id
@GeneratedValue
private Integer id;
@Column(name = "cond_name")
@Index(name = "cond_name")
@OptimisticLock(excluded = true)
private String name;

View File

@ -1,22 +1,23 @@
//$Id$
package org.hibernate.test.annotations.various;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.Index;
import javax.persistence.Table;
/**
* @author Emmanuel Bernard
*/
@Entity
@Table(indexes = {
@Index(name = "weigth_idx", columnList = "weight"),
@Index(name = "agreement_idx", columnList = "agreement_id")})
public class Truck extends Vehicule {
@Index(name = "weigth_idx")
private int weight;
@ManyToOne
@JoinColumn(name = "agreement_id")
@Index(name = "agreement_idx")
private ProfessionalAgreement agreement;
public int getWeight() {

View File

@ -4,25 +4,26 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Table;
/**
* @author Emmanuel Bernard
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@org.hibernate.annotations.Table(appliesTo = "Vehicule",
indexes = {
@Index(name = "improbableindex", columnNames = {"registration", "Conductor_fk"}),
@Index(name = "secondone", columnNames = {"Conductor_fk"})
}
)
@Table(appliesTo = "Vehicule", indexes = {
@Index(name = "improbableindex", columnList = "registration, Conductor_fk"),
@Index(name = "secondone", columnList = "Conductor_fk"),
@Index(name = "thirdone", columnList = "Conductor_fk"),
@Index(name = "year_idx", columnList = "year"),
@Index(name = "forthone", columnList = "previousConductor")})
public class Vehicule {
@Id
@GeneratedValue(generator = "gen")
@ -32,12 +33,9 @@ public class Vehicule {
private String registrationNumber;
@ManyToOne(optional = false)
@JoinColumn(name = "Conductor_fk")
@Index(name = "thirdone")
private Conductor currentConductor;
@Index(name = "year_idx")
private Integer year;
@ManyToOne(optional = true)
@Index(name = "forthone")
private Conductor previousConductor;
public String getId() {

View File

@ -56,18 +56,16 @@ public class ConstraintTest extends BaseCoreFunctionalTestCase {
private static final String EXPLICIT_UK_NAME = "EXPLICIT_UK_NAME";
private static final String EXPLICIT_COLUMN_NAME_NATIVE = "EXPLICIT_COLUMN_NAME_NATIVE";
private static final String EXPLICIT_FK_NAME_NATIVE = "EXPLICIT_FK_NAME_NATIVE";
private static final String EXPLICIT_COLUMN_NAME_JPA_O2O = "EXPLICIT_COLUMN_NAME_JPA_O2O";
private static final String EXPLICIT_FK_NAME_JPA_O2O = "EXPLICIT_FK_NAME_JPA_O2O";
private static final String EXPLICIT_COLUMN_NAME_JPA_M2O = "EXPLICIT_COLUMN_NAME_JPA_M2O";
private static final String EXPLICIT_FK_NAME_JPA_M2O = "EXPLICIT_FK_NAME_JPA_M2O";
private static final String EXPLICIT_JOINTABLE_NAME_JPA_M2M = "EXPLICIT_JOINTABLE_NAME_JPA_M2M";
private static final String EXPLICIT_COLUMN_NAME_JPA_M2M = "EXPLICIT_COLUMN_NAME_JPA_M2M";
private static final String EXPLICIT_FK_NAME_JPA_M2M = "EXPLICIT_FK_NAME_JPA_M2M";
private static final String EXPLICIT_COLLECTIONTABLE_NAME_JPA_ELEMENT = "EXPLICIT_COLLECTIONTABLE_NAME_JPA_ELEMENT";
private static final String EXPLICIT_COLUMN_NAME_JPA_ELEMENT = "EXPLICIT_COLUMN_NAME_JPA_ELEMENT";
private static final String EXPLICIT_FK_NAME_JPA_ELEMENT = "EXPLICIT_FK_NAME_JPA_ELEMENT";
private static final String EXPLICIT_COLUMN_NAME_O2O = "EXPLICIT_COLUMN_NAME_O2O";
private static final String EXPLICIT_FK_NAME_O2O = "EXPLICIT_FK_NAME_O2O";
private static final String EXPLICIT_COLUMN_NAME_M2O = "EXPLICIT_COLUMN_NAME_M2O";
private static final String EXPLICIT_FK_NAME_M2O = "EXPLICIT_FK_NAME_M2O";
private static final String EXPLICIT_JOINTABLE_NAME_M2M = "EXPLICIT_JOINTABLE_NAME_M2M";
private static final String EXPLICIT_COLUMN_NAME_M2M = "EXPLICIT_COLUMN_NAME_M2M";
private static final String EXPLICIT_FK_NAME_M2M = "EXPLICIT_FK_NAME_M2M";
private static final String EXPLICIT_COLLECTIONTABLE_NAME_ELEMENT = "EXPLICIT_COLLECTIONTABLE_NAME_ELEMENT";
private static final String EXPLICIT_COLUMN_NAME_ELEMENT = "EXPLICIT_COLUMN_NAME_ELEMENT";
private static final String EXPLICIT_FK_NAME_ELEMENT = "EXPLICIT_FK_NAME_ELEMENT";
private static final String INDEX_1 = "INDEX_1";
private static final String INDEX_2 = "INDEX_2";
private static final String INDEX_3 = "INDEX_3";
@ -121,13 +119,12 @@ public void testConstraintNames() {
assertTrue( SchemaUtil.hasUniqueKey( table1, EXPLICIT_UK_NAME, "explicit" ) );
TableSpecification table2 = SchemaUtil.getTable( DataPoint2.class, metadata() );
TableSpecification joinTable = SchemaUtil.getTable( EXPLICIT_JOINTABLE_NAME_JPA_M2M, metadata() );
TableSpecification collectionTable = SchemaUtil.getTable( EXPLICIT_COLLECTIONTABLE_NAME_JPA_ELEMENT, metadata() );
assertTrue( SchemaUtil.hasForeignKey( table2, EXPLICIT_FK_NAME_NATIVE, EXPLICIT_COLUMN_NAME_NATIVE ) );
assertTrue( SchemaUtil.hasForeignKey( table2, EXPLICIT_FK_NAME_JPA_O2O, EXPLICIT_COLUMN_NAME_JPA_O2O ) );
assertTrue( SchemaUtil.hasForeignKey( table2, EXPLICIT_FK_NAME_JPA_M2O, EXPLICIT_COLUMN_NAME_JPA_M2O ) );
assertTrue( SchemaUtil.hasForeignKey( joinTable, EXPLICIT_FK_NAME_JPA_M2M, EXPLICIT_COLUMN_NAME_JPA_M2M ) );
assertTrue( SchemaUtil.hasForeignKey( collectionTable, EXPLICIT_FK_NAME_JPA_ELEMENT, EXPLICIT_COLUMN_NAME_JPA_ELEMENT ) );
TableSpecification joinTable = SchemaUtil.getTable( EXPLICIT_JOINTABLE_NAME_M2M, metadata() );
TableSpecification collectionTable = SchemaUtil.getTable( EXPLICIT_COLLECTIONTABLE_NAME_ELEMENT, metadata() );
assertTrue( SchemaUtil.hasForeignKey( table2, EXPLICIT_FK_NAME_O2O, EXPLICIT_COLUMN_NAME_O2O ) );
assertTrue( SchemaUtil.hasForeignKey( table2, EXPLICIT_FK_NAME_M2O, EXPLICIT_COLUMN_NAME_M2O ) );
assertTrue( SchemaUtil.hasForeignKey( joinTable, EXPLICIT_FK_NAME_M2M, EXPLICIT_COLUMN_NAME_M2M ) );
assertTrue( SchemaUtil.hasForeignKey( collectionTable, EXPLICIT_FK_NAME_ELEMENT, EXPLICIT_COLUMN_NAME_ELEMENT ) );
testConstraintLength( table1 );
testConstraintLength( table2 );
@ -184,31 +181,26 @@ private static class DataPoint2 {
public DataPoint dp;
@OneToOne
@org.hibernate.annotations.ForeignKey(name = EXPLICIT_FK_NAME_NATIVE)
@JoinColumn(name = EXPLICIT_COLUMN_NAME_NATIVE)
public DataPoint explicit_native;
@OneToOne
@JoinColumn(name = EXPLICIT_COLUMN_NAME_JPA_O2O,
foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_JPA_O2O))
public DataPoint explicit_jpa_o2o;
@JoinColumn(name = EXPLICIT_COLUMN_NAME_O2O,
foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_O2O))
public DataPoint explicit_o2o;
@ManyToOne
@JoinColumn(name = EXPLICIT_COLUMN_NAME_JPA_M2O,
foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_JPA_M2O))
public DataPoint explicit_jpa_m2o;
@JoinColumn(name = EXPLICIT_COLUMN_NAME_M2O,
foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_M2O))
public DataPoint explicit_m2o;
@ManyToMany
@JoinTable(name = EXPLICIT_JOINTABLE_NAME_JPA_M2M,
joinColumns = @JoinColumn(name = EXPLICIT_COLUMN_NAME_JPA_M2M),
foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_JPA_M2M))
public Set<DataPoint> explicit_jpa_m2m;
@JoinTable(name = EXPLICIT_JOINTABLE_NAME_M2M,
joinColumns = @JoinColumn(name = EXPLICIT_COLUMN_NAME_M2M),
foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_M2M))
public Set<DataPoint> explicit_m2m;
@ElementCollection
@CollectionTable(name = EXPLICIT_COLLECTIONTABLE_NAME_JPA_ELEMENT,
joinColumns = @JoinColumn(name = EXPLICIT_COLUMN_NAME_JPA_ELEMENT),
foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_JPA_ELEMENT))
public Set<String> explicit_jpa_element;
@CollectionTable(name = EXPLICIT_COLLECTIONTABLE_NAME_ELEMENT,
joinColumns = @JoinColumn(name = EXPLICIT_COLUMN_NAME_ELEMENT),
foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_ELEMENT))
public Set<String> explicit_element;
}
public static enum SimpleEnum {

View File

@ -25,6 +25,7 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@ -43,8 +44,8 @@ public class MultipleCollectionRefEntity1 implements org.hibernate.test.event.co
private String text;
@ManyToOne
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false)
@org.hibernate.annotations.ForeignKey(name = "FK_RE1_MCE")
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false,
foreignKey = @ForeignKey(name = "FK_RE1_MCE"))
private MultipleCollectionEntity multipleCollectionEntity;
@Column(name = "MCE_ID", insertable = false, updatable = false)

View File

@ -25,6 +25,7 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@ -43,8 +44,8 @@ public class MultipleCollectionRefEntity2 implements org.hibernate.test.event.co
private String text;
@ManyToOne
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false)
@org.hibernate.annotations.ForeignKey(name = "FK_RE2_MCE")
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false,
foreignKey = @ForeignKey(name = "FK_RE2_MCE"))
private MultipleCollectionEntity multipleCollectionEntity;
@Column(name = "MCE_ID", insertable = false, updatable = false)

View File

@ -23,20 +23,19 @@
*/
package org.hibernate.test.propertyref;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OrderColumn;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.annotations.IndexColumn;
import org.hibernate.annotations.ListIndexBase;
/**