Revision 93186f1a
ref #9204 probably uncritical updates to AbstractPersistentCollection
eu.etaxonomy.taxeditor.cdmlib/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java | ||
---|---|---|
339 | 339 |
throwLazyInitializationException( "SessionFactory UUID not known to create temporary Session for loading" ); |
340 | 340 |
} |
341 | 341 |
|
342 |
SessionFactoryImplementor sf = (SessionFactoryImplementor) |
|
342 |
final SessionFactoryImplementor sf = (SessionFactoryImplementor)
|
|
343 | 343 |
SessionFactoryRegistry.INSTANCE.getSessionFactory( sessionFactoryUuid ); |
344 | 344 |
return (SessionImplementor) sf.openSession(); |
345 | 345 |
} |
... | ... | |
695 | 695 |
return directlyAccessible; |
696 | 696 |
} |
697 | 697 |
|
698 |
/** |
|
699 |
* Disassociate this collection from the given session. |
|
700 |
* |
|
701 |
* @return true if this was currently associated with the given session |
|
702 |
*/ |
|
703 | 698 |
@Override |
704 | 699 |
public final boolean unsetSession(SessionImplementor currentSession) { |
705 | 700 |
prepareForPossibleSpecialSpecjInitialization(); |
... | ... | |
727 | 722 |
} |
728 | 723 |
} |
729 | 724 |
|
730 |
|
|
731 |
/** |
|
732 |
* Associate the collection with the given session. |
|
733 |
* |
|
734 |
* @return false if the collection was already associated with the session |
|
735 |
* |
|
736 |
* @throws HibernateException if the collection was already associated |
|
737 |
* with another open session |
|
738 |
*/ |
|
739 | 725 |
@Override |
740 |
public final boolean setCurrentSession(SessionImplementor session) throws HibernateException {
|
|
726 |
public final boolean setCurrentSession(SessionImplementor session) throws HibernateException {
|
|
741 | 727 |
if ( session == this.session ) { |
742 | 728 |
return false; |
743 | 729 |
} |
... | ... | |
770 | 756 |
* Do we need to completely recreate this collection when it changes? |
771 | 757 |
*/ |
772 | 758 |
@Override |
773 |
public boolean needsRecreate(CollectionPersister persister) { |
|
759 |
public boolean needsRecreate(CollectionPersister persister) { |
|
760 |
// Workaround for situations like HHH-7072. If the collection element is a component that consists entirely |
|
761 |
// of nullable properties, we currently have to forcefully recreate the entire collection. See the use |
|
762 |
// of hasNotNullableColumns in the AbstractCollectionPersister constructor for more info. In order to delete |
|
763 |
// row-by-row, that would require SQL like "WHERE ( COL = ? OR ( COL is null AND ? is null ) )", rather than |
|
764 |
// the current "WHERE COL = ?" (fails for null for most DBs). Note that |
|
765 |
// the param would have to be bound twice. Until we eventually add "parameter bind points" concepts to the |
|
766 |
// AST in ORM 5+, handling this type of condition is either extremely difficult or impossible. Forcing |
|
767 |
// recreation isn't ideal, but not really any other option in ORM 4. |
|
768 |
// Selecting a type used in where part of update statement |
|
769 |
// (must match condidion in org.hibernate.persister.collection.BasicCollectionPersister.doUpdateRows). |
|
770 |
// See HHH-9474 |
|
771 |
Type whereType; |
|
772 |
if ( persister.hasIndex() ) { |
|
773 |
whereType = persister.getIndexType(); |
|
774 |
} |
|
775 |
else { |
|
776 |
whereType = persister.getElementType(); |
|
777 |
} |
|
778 |
if ( whereType instanceof CompositeType ) { |
|
779 |
CompositeType componentIndexType = (CompositeType) whereType; |
|
780 |
return !componentIndexType.hasNotNullProperty(); |
|
781 |
} |
|
774 | 782 |
return false; |
775 | 783 |
} |
776 | 784 |
|
... | ... | |
1257 | 1265 |
|
1258 | 1266 |
final EntityPersister entityPersister = session.getFactory().getEntityPersister( entityName ); |
1259 | 1267 |
final Type idType = entityPersister.getIdentifierType(); |
1268 |
final boolean useIdDirect = mayUseIdDirect( idType ); |
|
1260 | 1269 |
|
1261 | 1270 |
// create the collection holding the Orphans |
1262 | 1271 |
final Collection res = new ArrayList(); |
... | ... | |
1276 | 1285 |
current, |
1277 | 1286 |
session |
1278 | 1287 |
); |
1279 |
currentIds.add( new TypedValue( idType, currentId, entityPersister.getEntityMode() ) );
|
|
1288 |
currentIds.add( useIdDirect ? currentId : new TypedValue( idType, currentId ) );
|
|
1280 | 1289 |
} |
1281 | 1290 |
} |
1282 | 1291 |
} |
... | ... | |
1284 | 1293 |
// iterate over the *old* list |
1285 | 1294 |
for ( Object old : oldElements ) { |
1286 | 1295 |
if ( !currentSaving.contains( old ) ) { |
1287 |
Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, old, session ); |
|
1288 |
if ( !currentIds.contains( new TypedValue( idType, oldId, entityPersister.getEntityMode() ) ) ) {
|
|
1296 |
final Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, old, session );
|
|
1297 |
if ( !currentIds.contains( useIdDirect ? oldId : new TypedValue( idType, oldId ) ) ) {
|
|
1289 | 1298 |
res.add( old ); |
1290 | 1299 |
} |
1291 | 1300 |
} |
Also available in: Unified diff