/** * INTERNAL: * Indicates whether several sequencing values should be acquired at a time * and be kept by TopLink. This in only possible in case sequencing numbers should * be acquired before insert (shouldAcquireValueAfterInsert()==false). * In default implementation, it is true for table sequencing and native * sequencing on Oracle platform, false for native sequencing on other platforms. */ public boolean shouldUsePreallocation() { return !shouldAcquireValueAfterInsert(); }
/** * INTERNAL: * Indicates whether the existing pk value should always be overridden by the sequence. */ public boolean shouldAlwaysOverrideExistingValue(String seqName) { return this.shouldAlwaysOverrideExistingValue || shouldAcquireValueAfterInsert(); }
/** * INTERNAL: * Indicates whether several sequencing values should be acquired at a time * and be kept by TopLink. This in only possible in case sequencing numbers should * be acquired before insert (shouldAcquireValueAfterInsert()==false). * In default implementation, it is true for table sequencing and native * sequencing on Oracle platform, false for native sequencing on other platforms. */ public boolean shouldUsePreallocation() { return !shouldAcquireValueAfterInsert(); }
/** * INTERNAL: * Indicates whether several sequencing values should be acquired at a time * and be kept by TopLink. This in only possible in case sequencing numbers should * be acquired before insert (shouldAcquireValueAfterInsert()==false). * In default implementation, it is true for table sequencing and native * sequencing on Oracle platform, false for native sequencing on other platforms. */ public boolean shouldUsePreallocation() { return !shouldAcquireValueAfterInsert(); }
/** * INTERNAL: * Indicates whether the existing pk value should always be overridden by the sequence. */ public boolean shouldAlwaysOverrideExistingValue(String seqName) { return this.shouldAlwaysOverrideExistingValue || shouldAcquireValueAfterInsert(); }
/** * INTERNAL: * Indicates whether sequencing value should be acquired after INSERT. * Note that preallocation could be used only in case sequencing values * should be acquired before insert (this method returns false). * In default implementation, it is true for table sequencing and native * sequencing on Oracle platform, false for native sequencing on other platforms. */ public boolean shouldAcquireValueAfterInsert() { return getDefaultSequence().shouldAcquireValueAfterInsert(); }
/** * INTERNAL: * Indicates whether sequencing value should be acquired after INSERT. * Note that preallocation could be used only in case sequencing values * should be acquired before insert (this method returns false). * In default implementation, it is true for table sequencing and native * sequencing on Oracle platform, false for native sequencing on other platforms. */ public boolean shouldAcquireValueAfterInsert() { return getDefaultSequence().shouldAcquireValueAfterInsert(); }
/** * INTERNAL: * Indicates whether sequencing value should be acquired after INSERT. * Note that preallocation could be used only in case sequencing values * should be acquired before insert (this method returns false). * In default implementation, it is true for table sequencing and native * sequencing on Oracle platform, false for native sequencing on other platforms. */ public boolean shouldAcquireValueAfterInsert() { return getDefaultSequence().shouldAcquireValueAfterInsert(); }
/** * INTERNAL: * Indicates whether pk or some of its components * set after insert into the database. * Shouldn't be called before ClassDescriptor has been initialized. */ public boolean isPrimaryKeySetAfterInsert(AbstractSession session) { return (usesSequenceNumbers() && getSequence().shouldAcquireValueAfterInsert()) || (hasReturningPolicy() && getReturningPolicy().isUsedToSetPrimaryKey()); }
/** * INTERNAL: * Indicates whether pk or some of its components * set after insert into the database. * Shouldn't be called before ClassDescriptor has been initialized. */ public boolean isPrimaryKeySetAfterInsert(AbstractSession session) { return (usesSequenceNumbers() && getSequence().shouldAcquireValueAfterInsert()) || (hasReturningPolicy() && getReturningPolicy().isUsedToSetPrimaryKey()); }
/** * INTERNAL: * Indicates whether pk or some of its components * set after insert into the database. * Shouldn't be called before ClassDescriptor has been initialized. */ public boolean isPrimaryKeySetAfterInsert(AbstractSession session) { return (usesSequenceNumbers() && getSequence().shouldAcquireValueAfterInsert()) || (hasReturningPolicy() && getReturningPolicy().isUsedToSetPrimaryKey()); }
public boolean shouldPrintFieldIdentityClause(AbstractSession session, String qualifiedFieldName) { if (!supportsIdentity()) { return false; } if ((session.getSequencing() == null) || (session.getSequencing().whenShouldAcquireValueForAll() == Sequencing.BEFORE_INSERT)) { return false; } boolean shouldAcquireSequenceValueAfterInsert = false; DatabaseField field = new DatabaseField(qualifiedFieldName, getStartDelimiter(), getEndDelimiter()); Iterator descriptors = session.getDescriptors().values().iterator(); while (descriptors.hasNext()) { ClassDescriptor descriptor = (ClassDescriptor)descriptors.next(); if (!descriptor.usesSequenceNumbers()) { continue; } if (descriptor.getSequenceNumberField().equals(field)) { String seqName = descriptor.getSequenceNumberName(); Sequence sequence = getSequence(seqName); shouldAcquireSequenceValueAfterInsert = sequence.shouldAcquireValueAfterInsert(); break; } } return shouldAcquireSequenceValueAfterInsert; }
/** * INTERNAL * Remove a potential sequence number field and invoke the ReturningPolicy trimModifyRowsForInsert method */ public void trimFieldsForInsert(AbstractSession session, AbstractRecord databaseRow) { ClassDescriptor descriptor = this.descriptor; if (descriptor.usesSequenceNumbers() && descriptor.getSequence().shouldAcquireValueAfterInsert()) { databaseRow.remove(descriptor.getSequenceNumberField()); } if (descriptor.hasReturningPolicy()) { descriptor.getReturningPolicy().trimModifyRowForInsert(databaseRow); } }
/** * INTERNAL * Remove a potential sequence number field and invoke the ReturningPolicy trimModifyRowsForInsert method */ public void trimFieldsForInsert(AbstractSession session, AbstractRecord databaseRow) { ClassDescriptor descriptor = this.descriptor; if (descriptor.usesSequenceNumbers() && descriptor.getSequence().shouldAcquireValueAfterInsert()) { databaseRow.remove(descriptor.getSequenceNumberField()); } if (descriptor.hasReturningPolicy()) { descriptor.getReturningPolicy().trimModifyRowForInsert(databaseRow); } }
protected SequenceDefinition buildSequenceDefinition(Sequence sequence) { if (sequence.shouldAcquireValueAfterInsert()) { return null; } if (sequence instanceof TableSequence || (sequence instanceof DefaultSequence && ((DefaultSequence)sequence).getDefaultSequence() instanceof TableSequence)) { return new TableSequenceDefinition(sequence); } else if (sequence instanceof UnaryTableSequence || (sequence instanceof DefaultSequence && ((DefaultSequence)sequence).getDefaultSequence() instanceof UnaryTableSequence)) { return new UnaryTableSequenceDefinition(sequence); } else if (sequence instanceof NativeSequence || (sequence instanceof DefaultSequence && ((DefaultSequence)sequence).getDefaultSequence() instanceof NativeSequence)) { return new SequenceObjectDefinition(sequence); } else { return null; } }
/** * INTERNAL * Remove a potential sequence number field and invoke the ReturningPolicy trimModifyRowsForInsert method */ public void trimFieldsForInsert(AbstractSession session, AbstractRecord databaseRow) { ClassDescriptor descriptor = this.descriptor; if (descriptor.usesSequenceNumbers() && descriptor.getSequence().shouldAcquireValueAfterInsert()) { databaseRow.remove(descriptor.getSequenceNumberField()); } if (descriptor.hasReturningPolicy()) { descriptor.getReturningPolicy().trimModifyRowForInsert(databaseRow); } }
/** * INTERNAL: * Assign sequence number to the object. */ public Object assignSequenceNumber(Object object, ClassDescriptor descriptor) throws DatabaseException { Object value = null; // This is done outside of a transaction to ensure optimal concurrency and deadlock avoidance in the sequence table. if (descriptor.usesSequenceNumbers() && !descriptor.getSequence().shouldAcquireValueAfterInsert()) { startOperationProfile(SessionProfiler.AssignSequence); ObjectBuilder builder = descriptor.getObjectBuilder(); try { value = builder.assignSequenceNumber(object, this); } catch (RuntimeException exception) { handleException(exception); } finally { endOperationProfile(SessionProfiler.AssignSequence); } } return value; }
/** * INTERNAL: * Assign sequence number to the object. */ public Object assignSequenceNumber(Object object, ClassDescriptor descriptor) throws DatabaseException { Object value = null; // This is done outside of a transaction to ensure optimal concurrency and deadlock avoidance in the sequence table. if (descriptor.usesSequenceNumbers() && !descriptor.getSequence().shouldAcquireValueAfterInsert()) { startOperationProfile(SessionProfiler.AssignSequence); ObjectBuilder builder = descriptor.getObjectBuilder(); try { value = builder.assignSequenceNumber(object, this); } catch (RuntimeException exception) { handleException(exception); } finally { endOperationProfile(SessionProfiler.AssignSequence); } } return value; }
/** * INTERNAL: * Assign sequence number to the object. */ public Object assignSequenceNumber(Object object, ClassDescriptor descriptor) throws DatabaseException { Object value = null; // This is done outside of a transaction to ensure optimal concurrency and deadlock avoidance in the sequence table. if (descriptor.usesSequenceNumbers() && !descriptor.getSequence().shouldAcquireValueAfterInsert()) { startOperationProfile(SessionProfiler.AssignSequence); ObjectBuilder builder = descriptor.getObjectBuilder(); try { value = builder.assignSequenceNumber(object, this); } catch (RuntimeException exception) { handleException(exception); } finally { endOperationProfile(SessionProfiler.AssignSequence); } } return value; }
protected SequenceDefinition buildSequenceDefinition(Sequence sequence) { if (sequence.shouldAcquireValueAfterInsert()) { return null; } if (sequence instanceof TableSequence || (sequence instanceof DefaultSequence && ((DefaultSequence)sequence).getDefaultSequence() instanceof TableSequence)) { return new TableSequenceDefinition(sequence, createDatabaseSchemas); } else if (sequence instanceof UnaryTableSequence || (sequence instanceof DefaultSequence && ((DefaultSequence)sequence).getDefaultSequence() instanceof UnaryTableSequence)) { return new UnaryTableSequenceDefinition(sequence, createDatabaseSchemas); } else if (sequence instanceof NativeSequence || (sequence instanceof DefaultSequence && ((DefaultSequence)sequence).getDefaultSequence() instanceof NativeSequence)) { NativeSequence nativeSequence = null; if (sequence instanceof NativeSequence) { nativeSequence = (NativeSequence)sequence; } else { nativeSequence = (NativeSequence)((DefaultSequence)sequence).getDefaultSequence(); } if (nativeSequence.hasDelegateSequence()) { return buildSequenceDefinition(((NativeSequence)sequence).getDelegateSequence()); } return new SequenceObjectDefinition(sequence); } else { return null; } }