HHH-7739 Correct "appliesTo" value handeling on @Table/@Index processing

This commit is contained in:
brmeyer 2012-10-30 15:24:31 -04:00
parent 1a5bdd9adb
commit 70221d8ac2
4 changed files with 28 additions and 24 deletions

View File

@ -93,7 +93,7 @@ public class TableProcessor {
"indexes",
AnnotationInstance[].class
) ) {
bindIndexAnnotation( table, indexAnnotation );
bindIndexAnnotation( table, tableAnnotation, indexAnnotation );
}
String comment = JandexHelper.getValue( tableAnnotation, "comment", String.class );
if ( StringHelper.isNotEmpty( comment ) ) {
@ -101,8 +101,8 @@ public class TableProcessor {
}
}
private static void bindIndexAnnotation(Table table, AnnotationInstance indexAnnotation) {
String indexName = JandexHelper.getValue( indexAnnotation, "appliesTo", String.class );
private static void bindIndexAnnotation(Table table, AnnotationInstance tableAnnotation, AnnotationInstance indexAnnotation) {
String indexName = JandexHelper.getValue( tableAnnotation, "appliesTo", String.class );
String[] columnNames = JandexHelper.getValue( indexAnnotation, "columnNames", String[].class );
if ( columnNames == null ) {
LOG.noColumnsSpecifiedForIndex( indexName, table.toLoggableString() );

View File

@ -1,6 +1,7 @@
//$Id$
package org.hibernate.test.annotations.entity;
import java.util.Set;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@ -8,15 +9,20 @@ import javax.persistence.Id;
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 @@ import org.hibernate.annotations.Where;
*/
@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({

View File

@ -23,18 +23,16 @@
*/
package org.hibernate.test.annotations.entity;
import org.junit.Test;
import org.hibernate.mapping.RootClass;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.test.util.SchemaUtil;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class NewCustomEntityMappingAnnotationsTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
@ -48,14 +46,14 @@ public class NewCustomEntityMappingAnnotationsTest extends BaseCoreFunctionalTes
@Test
public void testSameMappingValues() {
// TODO: These need to use the new metamodel, but the information
EntityBinding forest = SchemaUtil.getEntityBinding( Forest.class, metadata() );
EntityBinding forest2 = SchemaUtil.getEntityBinding( Forest2.class, metadata() );
assertEquals( forest.isDynamicInsert(), forest2.isDynamicInsert() );
assertEquals( forest.isDynamicUpdate(), forest2.isDynamicUpdate() );
assertEquals( forest.isSelectBeforeUpdate(), forest2.isSelectBeforeUpdate() );
// TODO: This needs to use the new metamodel, but the information
// is not available in EntityBinding.
RootClass forest = (RootClass) configuration().getClassMapping( Forest.class.getName() );
RootClass forest2 = (RootClass) configuration().getClassMapping( Forest2.class.getName() );
assertEquals( forest.useDynamicInsert(), forest2.useDynamicInsert() );
assertEquals( forest.useDynamicUpdate(), forest2.useDynamicUpdate() );
assertEquals( forest.hasSelectBeforeUpdate(), forest2.hasSelectBeforeUpdate() );
assertEquals( forest.getOptimisticLockMode(), forest2.getOptimisticLockMode() );
assertEquals( forest.isExplicitPolymorphism(), forest2.isExplicitPolymorphism() );
// assertEquals( forest.getOptimisticLockMode(), forest2.getOptimisticLockMode() );
assertEquals( forest.isPolymorphic(), forest2.isPolymorphic() );
}
}

View File

@ -60,7 +60,7 @@ public abstract class SchemaUtil {
}
}
private static EntityBinding getEntityBinding(
public static EntityBinding getEntityBinding(
Class<?> entityClass, Metadata metadata ) {
return metadata.getEntityBinding( entityClass.getName() );
}