mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
Fixup review comments
This commit is contained in:
parent
9392b94ee7
commit
47416b9e24
@ -19,6 +19,7 @@
|
|||||||
import org.hibernate.dialect.PostgreSQLDialect;
|
import org.hibernate.dialect.PostgreSQLDialect;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.loader.NonUniqueDiscoveredSqlAliasException;
|
import org.hibernate.loader.NonUniqueDiscoveredSqlAliasException;
|
||||||
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.transform.Transformers;
|
import org.hibernate.transform.Transformers;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.userguide.model.AddressType;
|
import org.hibernate.userguide.model.AddressType;
|
||||||
@ -41,6 +42,7 @@
|
|||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -762,6 +764,10 @@ public void test_sql_jpa_composite_key_entity_associations_named_query_example()
|
|||||||
}
|
}
|
||||||
//end::sql-jpa-composite-key-entity-associations_named-query-example[]
|
//end::sql-jpa-composite-key-entity-associations_named-query-example[]
|
||||||
assertEquals(1, tuples.size());
|
assertEquals(1, tuples.size());
|
||||||
|
SpaceShip spaceShip = (SpaceShip) tuples.get( 0 )[0];
|
||||||
|
assertNotNull( spaceShip.getCaptain() );
|
||||||
|
assertTrue( spaceShip.getCaptain() instanceof HibernateProxy );
|
||||||
|
assertTrue( ( (HibernateProxy) spaceShip.getCaptain() ).getHibernateLazyInitializer().isUninitialized() );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ public List<Fetch> visitFetches(FetchParent fetchParent) {
|
|||||||
final Map.Entry<String, NavigablePath> oldEntry = relativePathStack.getCurrent();
|
final Map.Entry<String, NavigablePath> oldEntry = relativePathStack.getCurrent();
|
||||||
final String key = oldEntry.getKey();
|
final String key = oldEntry.getKey();
|
||||||
currentEntry = new AbstractMap.SimpleEntry<>(
|
currentEntry = new AbstractMap.SimpleEntry<>(
|
||||||
getRelativePath( !key.isEmpty() ? key : "", fetchable, fetchableContainer ),
|
getRelativePath( key, fetchable, fetchableContainer ),
|
||||||
oldEntry.getValue().append( fetchableName )
|
oldEntry.getValue().append( fetchableName )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -351,6 +351,18 @@ public List<Fetch> visitFetches(FetchParent fetchParent) {
|
|||||||
FetchBuilder explicitFetchBuilder = fetchBuilderResolverStack
|
FetchBuilder explicitFetchBuilder = fetchBuilderResolverStack
|
||||||
.getCurrent()
|
.getCurrent()
|
||||||
.apply( fullPath );
|
.apply( fullPath );
|
||||||
|
DynamicFetchBuilderLegacy fetchBuilderLegacy;
|
||||||
|
if ( explicitFetchBuilder == null ) {
|
||||||
|
fetchBuilderLegacy = legacyFetchResolver.resolve(
|
||||||
|
fromClauseAccess.findTableGroup( fetchParent.getNavigablePath() )
|
||||||
|
.getPrimaryTableReference()
|
||||||
|
.getIdentificationVariable(),
|
||||||
|
fetchableName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fetchBuilderLegacy = null;
|
||||||
|
}
|
||||||
if ( fetchable instanceof Association && fetchable.getMappedFetchOptions().getTiming() == FetchTiming.DELAYED ) {
|
if ( fetchable instanceof Association && fetchable.getMappedFetchOptions().getTiming() == FetchTiming.DELAYED ) {
|
||||||
final Association association = (Association) fetchable;
|
final Association association = (Association) fetchable;
|
||||||
final ForeignKeyDescriptor foreignKeyDescriptor = association.getForeignKeyDescriptor();
|
final ForeignKeyDescriptor foreignKeyDescriptor = association.getForeignKeyDescriptor();
|
||||||
@ -358,7 +370,8 @@ public List<Fetch> visitFetches(FetchParent fetchParent) {
|
|||||||
final String partName = attributeName( foreignKeyDescriptor.getSide( association.getSideNature().inverse() )
|
final String partName = attributeName( foreignKeyDescriptor.getSide( association.getSideNature().inverse() )
|
||||||
.getModelPart());
|
.getModelPart());
|
||||||
|
|
||||||
if ( explicitFetchBuilder == null && partName != null ) {
|
// If there are no fetch builders for this association, we only want to fetch the FK
|
||||||
|
if ( explicitFetchBuilder == null && fetchBuilderLegacy == null && partName != null ) {
|
||||||
currentEntry = new AbstractMap.SimpleEntry<>(
|
currentEntry = new AbstractMap.SimpleEntry<>(
|
||||||
currentEntry.getKey() + "." + partName,
|
currentEntry.getKey() + "." + partName,
|
||||||
currentEntry.getValue().append( partName )
|
currentEntry.getValue().append( partName )
|
||||||
@ -366,6 +379,14 @@ public List<Fetch> visitFetches(FetchParent fetchParent) {
|
|||||||
explicitFetchBuilder = fetchBuilderResolverStack
|
explicitFetchBuilder = fetchBuilderResolverStack
|
||||||
.getCurrent()
|
.getCurrent()
|
||||||
.apply( currentEntry.getKey() );
|
.apply( currentEntry.getKey() );
|
||||||
|
if ( explicitFetchBuilder == null ) {
|
||||||
|
fetchBuilderLegacy = legacyFetchResolver.resolve(
|
||||||
|
fromClauseAccess.findTableGroup( fetchParent.getNavigablePath() )
|
||||||
|
.getPrimaryTableReference()
|
||||||
|
.getIdentificationVariable(),
|
||||||
|
fetchableName
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
relativePathStack.push( currentEntry );
|
relativePathStack.push( currentEntry );
|
||||||
@ -377,12 +398,6 @@ public List<Fetch> visitFetches(FetchParent fetchParent) {
|
|||||||
fetchBuilder = explicitFetchBuilder;
|
fetchBuilder = explicitFetchBuilder;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final DynamicFetchBuilderLegacy fetchBuilderLegacy = legacyFetchResolver.resolve(
|
|
||||||
fromClauseAccess.findTableGroup( fetchParent.getNavigablePath() )
|
|
||||||
.getPrimaryTableReference()
|
|
||||||
.getIdentificationVariable(),
|
|
||||||
fetchableName
|
|
||||||
);
|
|
||||||
if ( fetchBuilderLegacy == null ) {
|
if ( fetchBuilderLegacy == null ) {
|
||||||
fetchBuilder = Builders.implicitFetchBuilder( fetchPath, fetchable, this );
|
fetchBuilder = Builders.implicitFetchBuilder( fetchPath, fetchable, this );
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
@ -60,7 +61,7 @@ public void initData() {
|
|||||||
em.persist( entity );
|
em.persist( entity );
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
|
|
||||||
timestampEnd = Instant.now();
|
timestampEnd = Instant.now().plus( 1L, ChronoUnit.SECONDS );
|
||||||
}
|
}
|
||||||
catch( InterruptedException x ) {
|
catch( InterruptedException x ) {
|
||||||
fail( "Unexpected interrupted exception" );
|
fail( "Unexpected interrupted exception" );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user