merge master

This commit is contained in:
Strong Liu 2013-05-20 15:56:10 -07:00
parent a3184e16cb
commit 9a02c9e52d
12 changed files with 106 additions and 9 deletions

View File

@ -1385,6 +1385,7 @@ public class Binder {
return metadata.getTypeResolver().getTypeFactory().manyToOne(
referencedEntityBinding.getEntity().getName(),
uniqueKeyAttributeName == null,
uniqueKeyAttributeName,
attributeSource.getFetchTiming() != FetchTiming.IMMEDIATE,
attributeSource.isUnWrapProxy(),
@ -1492,6 +1493,7 @@ public class Binder {
return metadata.getTypeResolver().getTypeFactory().oneToOne(
referencedEntityBinding.getEntity().getName(),
attributeSource.getForeignKeyDirection(),
uniqueKeyAttributeName == null,
uniqueKeyAttributeName,
attributeSource.getFetchTiming() != FetchTiming.IMMEDIATE,
attributeSource.isUnWrapProxy(),
@ -1504,6 +1506,7 @@ public class Binder {
return metadata.getTypeResolver().getTypeFactory().specialOneToOne(
referencedEntityBinding.getEntity().getName(),
attributeSource.getForeignKeyDirection(),
uniqueKeyAttributeName == null,
uniqueKeyAttributeName,
attributeSource.getFetchTiming() != FetchTiming.IMMEDIATE,
attributeSource.isUnWrapProxy(),
@ -2048,6 +2051,7 @@ public class Binder {
Type resolvedElementType = metadata.getTypeResolver().getTypeFactory().manyToOne(
referencedEntityBinding.getEntity().getName(),
true,
null,
false,
false,

View File

@ -107,12 +107,25 @@ public abstract class EntityType extends AbstractType implements AssociationType
String uniqueKeyPropertyName,
boolean eager,
boolean unwrapProxy) {
this(scope, entityName, referenceToPrimaryKey, uniqueKeyPropertyName, eager, unwrapProxy, null);
}
protected EntityType(
TypeFactory.TypeScope scope,
String entityName,
boolean referenceToPrimaryKey,
String uniqueKeyPropertyName,
boolean eager,
boolean unwrapProxy,
Class returnedClass) {
this.scope = scope;
this.associatedEntityName = entityName;
this.uniqueKeyPropertyName = uniqueKeyPropertyName;
this.eager = eager;
this.unwrapProxy = unwrapProxy;
this.referenceToPrimaryKey = referenceToPrimaryKey;
this.returnedClass = returnedClass;
}

View File

@ -95,10 +95,25 @@ public class ManyToOneType extends EntityType {
boolean unwrapProxy,
boolean ignoreNotFound,
boolean isLogicalOneToOne) {
super( scope, referencedEntityName, referenceToPrimaryKey, uniqueKeyPropertyName, !lazy, unwrapProxy );
this( scope, referencedEntityName, referenceToPrimaryKey, uniqueKeyPropertyName, lazy, unwrapProxy, ignoreNotFound, isLogicalOneToOne, null);
}
public ManyToOneType(
TypeFactory.TypeScope scope,
String referencedEntityName,
boolean referenceToPrimaryKey,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
boolean ignoreNotFound,
boolean isLogicalOneToOne,
Class returnedClass) {
super( scope, referencedEntityName, referenceToPrimaryKey, uniqueKeyPropertyName, !lazy, unwrapProxy, returnedClass );
this.ignoreNotFound = ignoreNotFound;
this.isLogicalOneToOne = isLogicalOneToOne;
}
protected boolean isNullable() {
return ignoreNotFound;
}

View File

@ -81,6 +81,23 @@ public class OneToOneType extends EntityType {
this.entityName = entityName;
}
public OneToOneType(
TypeFactory.TypeScope scope,
String referencedEntityName,
ForeignKeyDirection foreignKeyType,
boolean referenceToPrimaryKey,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
String entityName,
String propertyName,
Class returnedClass) {
super( scope, referencedEntityName, referenceToPrimaryKey, uniqueKeyPropertyName, !lazy, unwrapProxy, returnedClass );
this.foreignKeyType = foreignKeyType;
this.propertyName = propertyName;
this.entityName = entityName;
}
public String getPropertyName() {
return propertyName;

View File

@ -86,6 +86,7 @@ public class SpecialOneToOneType extends OneToOneType {
TypeFactory.TypeScope scope,
String referencedEntityName,
ForeignKeyDirection foreignKeyType,
boolean referenceToPrimaryKey,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
@ -96,6 +97,7 @@ public class SpecialOneToOneType extends OneToOneType {
scope,
referencedEntityName,
foreignKeyType,
referenceToPrimaryKey,
uniqueKeyPropertyName,
lazy,
unwrapProxy,
@ -104,7 +106,8 @@ public class SpecialOneToOneType extends OneToOneType {
returnedClass
);
}
public int getColumnSpan(Mapping mapping) throws MappingException {
return super.getIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
}

View File

@ -237,6 +237,20 @@ public final class TypeFactory implements Serializable {
return new OneToOneType( typeScope, persistentClass, foreignKeyType, referenceToPrimaryKey,
uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName );
}
public EntityType oneToOne(
String persistentClass,
ForeignKeyDirection foreignKeyType,
boolean referenceToPrimaryKey,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
String entityName,
String propertyName,
Class returnedClass) {
return new OneToOneType( typeScope, persistentClass, foreignKeyType, referenceToPrimaryKey,
uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName, returnedClass );
}
/**
* @deprecated Use {@link #specialOneToOne(String, ForeignKeyDirection, String, boolean, boolean, String, String, boolean)} instead.
@ -267,6 +281,20 @@ public final class TypeFactory implements Serializable {
uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName );
}
public EntityType specialOneToOne(
String persistentClass,
ForeignKeyDirection foreignKeyType,
boolean referenceToPrimaryKey,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
String entityName,
String propertyName,
Class returnedClass) {
return new SpecialOneToOneType( typeScope, persistentClass, foreignKeyType, referenceToPrimaryKey,
uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName, returnedClass );
}
// many-to-one type builders ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -294,7 +322,6 @@ public final class TypeFactory implements Serializable {
isLogicalOneToOne );
}
public EntityType manyToOne(
String persistentClass,
boolean referenceToPrimaryKey,
@ -303,6 +330,18 @@ public final class TypeFactory implements Serializable {
boolean unwrapProxy,
boolean ignoreNotFound,
boolean isLogicalOneToOne) {
return manyToOne( persistentClass, referenceToPrimaryKey, uniqueKeyPropertyName, lazy, unwrapProxy, ignoreNotFound, isLogicalOneToOne, null );
}
public EntityType manyToOne(
String persistentClass,
boolean referenceToPrimaryKey,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
boolean ignoreNotFound,
boolean isLogicalOneToOne,
Class returnedClass) {
return new ManyToOneType(
typeScope,
persistentClass,
@ -311,7 +350,8 @@ public final class TypeFactory implements Serializable {
lazy,
unwrapProxy,
ignoreNotFound,
isLogicalOneToOne
isLogicalOneToOne,
returnedClass
);
}

View File

@ -63,6 +63,7 @@ import org.hibernate.loader.spi.NoOpLoadPlanAdvisor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.test.component.cascading.toone.PersonalInfo;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.junit4.ExtraAssertions;
@ -131,6 +132,7 @@ public class EncapsulatedCompositeAttributeResultSetProcessorTest extends BaseCo
}
@Test
@FailureExpectedWithNewMetamodel
public void testNestedCompositeElementCollectionProcessing() throws Exception {
// create some test data
Session session = openSession();

View File

@ -55,6 +55,7 @@ import org.hibernate.loader.spi.LoadQueryAliasResolutionContext;
import org.hibernate.loader.spi.NamedParameterContext;
import org.hibernate.loader.spi.NoOpLoadPlanAdvisor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.junit4.ExtraAssertions;
import org.hibernate.type.Type;
@ -128,6 +129,7 @@ public class EncapsulatedCompositeIdResultSetProcessorTest extends BaseCoreFunct
}
@Test
@FailureExpectedWithNewMetamodel
public void testCompositeIdWithKeyManyToOne() throws Exception {
final String cardId = "ace-of-spades";

View File

@ -56,6 +56,7 @@ import org.hibernate.loader.spi.LoadQueryAliasResolutionContext;
import org.hibernate.loader.spi.NamedParameterContext;
import org.hibernate.loader.spi.NoOpLoadPlanAdvisor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.junit4.ExtraAssertions;
@ -75,6 +76,7 @@ public class EntityWithNonLazyOneToManyListResultSetProcessorTest extends BaseCo
}
@Test
@FailureExpectedWithNewMetamodel
public void testEntityWithList() throws Exception {
final EntityPersister entityPersister = sessionFactory().getEntityPersister( Poster.class.getName() );

View File

@ -380,7 +380,7 @@ public class OuterJoinCriteriaTest extends BaseCoreFunctionalTestCase {
s.getTransaction().commit();
s.close();
}
@Override
protected void prepareTest() {
Session s = openSession();
s.getTransaction().begin();
@ -409,7 +409,7 @@ public class OuterJoinCriteriaTest extends BaseCoreFunctionalTestCase {
s.getTransaction().commit();
s.close();
}
@Override
protected void cleanupTest() {
Session s = openSession();
s.getTransaction().begin();

View File

@ -26,6 +26,7 @@ package org.hibernate.jpa.test.graphs.named.basic;
import javax.persistence.EntityGraph;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.junit.Test;
@ -41,6 +42,7 @@ public class BasicNamedEntityGraphTest extends BaseEntityManagerFunctionalTestCa
}
@Test
@FailureExpectedWithNewMetamodel
public void testIt() {
EntityGraph graph = getOrCreateEntityManager().getEntityGraph( "Person" );
assertNotNull( graph );

View File

@ -81,7 +81,6 @@ import static org.junit.Assert.fail;
@SuppressWarnings("unchecked")
public class PackagedEntityManagerTest extends PackagingTestCase {
@Test
@FailureExpectedWithNewMetamodel
public void testDefaultPar() throws Exception {
File testPackage = buildDefaultPar();
addPackageToClasspath( testPackage );
@ -117,7 +116,6 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testDefaultParForPersistence_1_0() throws Exception {
File testPackage = buildDefaultPar_1_0();
addPackageToClasspath( testPackage );
@ -193,7 +191,6 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testExplodedPar() throws Exception {
File testPackage = buildExplodedPar();
addPackageToClasspath( testPackage );