Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into wip/6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 committed Mar 15, 2021
2 parents 5dfbaf5 + b6ba93c commit d28b719
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 38 deletions.
2 changes: 1 addition & 1 deletion databases/oracle/matrix.gradle
Expand Up @@ -4,4 +4,4 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
jdbcDependency 'com.oracle.database.jdbc:ojdbc8:19.8.0.0'
jdbcDependency 'com.oracle.database.jdbc:ojdbc8:21.1.0.0'
2 changes: 1 addition & 1 deletion databases/pgsql/matrix.gradle
Expand Up @@ -4,4 +4,4 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
jdbcDependency 'org.postgresql:postgresql:42.2.2'
jdbcDependency 'org.postgresql:postgresql:42.2.19'
1 change: 1 addition & 0 deletions docker_db.sh
Expand Up @@ -153,6 +153,7 @@ alter system checkpoint;
alter database drop logfile group 1;
alter database drop logfile group 2;
alter database drop logfile group 3;
alter system set open_cursors=1000 sid='*' scope=both;
EOF\""
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libraries.gradle
Expand Up @@ -131,7 +131,7 @@ ext {
mariadb: 'org.mariadb.jdbc:mariadb-java-client:2.2.3',
cockroachdb: 'org.postgresql:postgresql:42.2.8',

oracle: 'com.oracle.database.jdbc:ojdbc8:19.8.0.0',
oracle: 'com.oracle.database.jdbc:ojdbc8:21.1.0.0',
mssql: 'com.microsoft.sqlserver:mssql-jdbc:7.2.1.jre8',
db2: 'com.ibm.db2:jcc:11.5.4.0',
hana: 'com.sap.cloud.db.jdbc:ngdbc:2.4.59',
Expand Down
Expand Up @@ -6,9 +6,11 @@
*/
package org.hibernate.engine.internal;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
Expand All @@ -28,6 +30,7 @@
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.type.AssociationType;
import org.hibernate.type.CollectionType;
import org.hibernate.type.ComponentType;
import org.hibernate.type.CompositeType;
import org.hibernate.type.EntityType;
import org.hibernate.type.ForeignKeyDirection;
Expand Down Expand Up @@ -89,7 +92,6 @@ public static void cascade(
final String[] propertyNames = persister.getPropertyNames();
final CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles();
final boolean hasUninitializedLazyProperties = persister.hasUninitializedLazyProperties( parent );
final int componentPathStackDepth = 0;
for ( int i = 0; i < types.length; i++) {
final CascadeStyle style = cascadeStyles[ i ];
final String propertyName = propertyNames[ i ];
Expand Down Expand Up @@ -152,7 +154,7 @@ else if ( action.performOnLazyProperty() && type.isEntityType() ) {
action,
cascadePoint,
eventSource,
componentPathStackDepth,
null,
parent,
child,
type,
Expand All @@ -177,7 +179,7 @@ else if ( action.performOnLazyProperty() && type.isEntityType() ) {
cascadeLogicalOneToOneOrphanRemoval(
action,
eventSource,
componentPathStackDepth,
null,
parent,
persister.getPropertyValue( parent, i ),
type,
Expand All @@ -202,7 +204,7 @@ private static void cascadeProperty(
final CascadingAction action,
final CascadePoint cascadePoint,
final EventSource eventSource,
final int componentPathStackDepth,
List<String> componentPath,
final Object parent,
final Object child,
final Type type,
Expand All @@ -219,7 +221,7 @@ private static void cascadeProperty(
action,
cascadePoint,
eventSource,
componentPathStackDepth,
componentPath,
parent,
child,
type,
Expand All @@ -230,23 +232,28 @@ private static void cascadeProperty(
}
}
else if ( type.isComponentType() ) {
if ( componentPath == null ) {
componentPath = new ArrayList<>();
}
componentPath.add( propertyName );
cascadeComponent(
action,
cascadePoint,
eventSource,
componentPathStackDepth,
componentPath,
parent,
child,
(CompositeType) type,
anything
);
componentPath.remove( componentPath.size() - 1 );
}
}

cascadeLogicalOneToOneOrphanRemoval(
action,
eventSource,
componentPathStackDepth,
componentPath,
parent,
child,
type,
Expand All @@ -258,7 +265,7 @@ else if ( type.isComponentType() ) {
private static void cascadeLogicalOneToOneOrphanRemoval(
final CascadingAction action,
final EventSource eventSource,
final int componentPathStackDepth,
final List<String> componentPath,
final Object parent,
final Object child,
final Type type,
Expand All @@ -277,26 +284,26 @@ private static void cascadeLogicalOneToOneOrphanRemoval(
final EntityEntry entry = persistenceContext.getEntry( parent );
if ( entry != null && entry.getStatus() != Status.SAVING ) {
Object loadedValue;
if ( componentPathStackDepth == 0 ) {
if ( componentPath == null ) {
// association defined on entity
loadedValue = entry.getLoadedValue( propertyName );
}
else {
// association defined on component
// todo : this is currently unsupported because of the fact that
// we do not know the loaded state of this value properly
// and doing so would be very difficult given how components and
// entities are loaded (and how 'loaded state' is put into the
// EntityEntry). Solutions here are to either:
// 1) properly account for components as a 2-phase load construct
// 2) just assume the association was just now orphaned and
// issue the orphan delete. This would require a special
// set of SQL statements though since we do not know the
// orphaned value, something a delete with a subquery to
// match the owner.
// final EntityType entityType = (EntityType) type;
// final String getPropertyPath = composePropertyPath( entityType.getPropertyName() );
loadedValue = null;
// Since the loadedState in the EntityEntry is a flat domain type array
// We first have to extract the component object and then ask the component type
// recursively to give us the value of the sub-property of that object
loadedValue = entry.getLoadedValue( componentPath.get( 0 ) );
ComponentType componentType = (ComponentType) entry.getPersister().getPropertyType( componentPath.get( 0 ) );
if ( componentPath.size() != 1 ) {
for ( int i = 1; i < componentPath.size(); i++ ) {
final int subPropertyIndex = componentType.getPropertyIndex( componentPath.get( i ) );
loadedValue = componentType.getPropertyValue( loadedValue, subPropertyIndex );
componentType = (ComponentType) componentType.getSubtypes()[subPropertyIndex];
}
}

loadedValue = componentType.getPropertyValue( loadedValue, componentType.getPropertyIndex( propertyName ) );
}

// orphaned if the association was nulled (child == null) or receives a new value while the
Expand Down Expand Up @@ -367,7 +374,7 @@ private static void cascadeComponent(
final CascadingAction action,
final CascadePoint cascadePoint,
final EventSource eventSource,
final int componentPathStackDepth,
final List<String> componentPath,
final Object parent,
final Object child,
final CompositeType componentType,
Expand All @@ -379,7 +386,7 @@ private static void cascadeComponent(
for ( int i = 0; i < types.length; i++ ) {
final CascadeStyle componentPropertyStyle = componentType.getCascadeStyle( i );
final String subPropertyName = propertyNames[i];
if ( componentPropertyStyle.doCascade( action ) ) {
if ( componentPropertyStyle.doCascade( action ) || componentPropertyStyle.hasOrphanDelete() && action.deleteOrphans() ) {
if (children == null) {
// Get children on demand.
children = componentType.getPropertyValues( child, eventSource );
Expand All @@ -388,7 +395,7 @@ private static void cascadeComponent(
action,
cascadePoint,
eventSource,
componentPathStackDepth + 1,
componentPath,
parent,
children[i],
types[i],
Expand All @@ -405,7 +412,7 @@ private static void cascadeAssociation(
final CascadingAction action,
final CascadePoint cascadePoint,
final EventSource eventSource,
final int componentPathStackDepth,
final List<String> componentPath,
final Object parent,
final Object child,
final Type type,
Expand All @@ -420,7 +427,7 @@ else if ( type.isCollectionType() ) {
action,
cascadePoint,
eventSource,
componentPathStackDepth,
componentPath,
parent,
child,
style,
Expand All @@ -437,7 +444,7 @@ private static void cascadeCollection(
final CascadingAction action,
final CascadePoint cascadePoint,
final EventSource eventSource,
final int componentPathStackDepth,
final List<String> componentPath,
final Object parent,
final Object child,
final CascadeStyle style,
Expand All @@ -457,7 +464,7 @@ private static void cascadeCollection(
action,
elementsCascadePoint,
eventSource,
componentPathStackDepth,
componentPath,
parent,
child,
type,
Expand Down Expand Up @@ -504,7 +511,7 @@ private static void cascadeCollectionElements(
final CascadingAction action,
final CascadePoint cascadePoint,
final EventSource eventSource,
final int componentPathStackDepth,
final List<String> componentPath,
final Object parent,
final Object child,
final CollectionType collectionType,
Expand All @@ -526,7 +533,7 @@ private static void cascadeCollectionElements(
action,
cascadePoint,
eventSource,
componentPathStackDepth,
componentPath,
parent,
itr.next(),
elemType,
Expand Down
Expand Up @@ -80,7 +80,6 @@ protected void prepareTest() {
}

@Test
@FailureExpected( jiraKey = "HHH-12076")
public void testClassExpressionInOnClause() {
doInHibernate( this::sessionFactory, session -> {
List<SettlementTask> results = session.createQuery(
Expand Down

0 comments on commit d28b719

Please sign in to comment.