错误预分配序列号。序列表信息不完整

时间:2017-08-09 11:49:20

标签: oracle11g eclipselink jpa-2.0

EclipseLink 2.6.3,JPA 2.0,IBM Websphere 8.5.5.8和JTA启用

我目前突然面临这种奇怪的错误并间歇性地发生

  

异常[EclipseLink-4011](Eclipse持久性服务 -   2.6.3.v20160428-59c81c5):org.eclipse.persistence.exceptions.DatabaseException异常   说明:错误预分配序列号。序列表   信息不完整。

实体中的序列生成器如下所示

    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="AlrtSeq")
    @SequenceGenerator(name="AlrtSeq",sequenceName="ALR_SEQ1",allocationSize=1)
    @Column(name="ALERT_NO")
    private Integer Number;

我已经调试了Eclipselink源代码,并且在此方法中引发了错误

StandardSequence.java

public Vector getGeneratedVector(Accessor accessor, AbstractSession writeSession, String seqName, int size) {
    if (shouldUsePreallocation()) {
        Number value = updateAndSelectSequence(accessor, writeSession, seqName, size);
        if (value == null) {
            throw DatabaseException.errorPreallocatingSequenceNumbers();
        }
        return createVector(value, seqName, size);
    } else {
        return null;
    }
}

如何从dual中选择seq.nextVal可以为null?因为这是 updateAndSelectSequence()方法内部发生的事情。

我还在我的SessionCustomizer类中启用了((AbstractSession)会话).setIsConcurrent(true); 来提高性能。这个属性是否必须对此做些什么?

异常堆栈跟踪

Caused by: Exception [EclipseLink-4011] (Eclipse Persistence Services - 2.6.3.v20160428-59c81c5): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Error preallocating sequence numbers.  The sequence table information is not complete.
    at org.eclipse.persistence.exceptions.DatabaseException.errorPreallocatingSequenceNumbers(DatabaseException.java:150)
    at org.eclipse.persistence.sequencing.StandardSequence.getGeneratedVector(StandardSequence.java:73)
    at org.eclipse.persistence.sequencing.Sequence.getGeneratedVector(Sequence.java:257)
    at org.eclipse.persistence.internal.sequencing.SequencingManager$Preallocation_NoTransaction_State.getNextValue(SequencingManager.java:683)
    at org.eclipse.persistence.internal.sequencing.SequencingManager.getNextValue(SequencingManager.java:1107)
    at org.eclipse.persistence.internal.sequencing.ClientSessionSequencing.getNextValue(ClientSessionSequencing.java:70)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:362)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:321)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.assignSequenceNumber(UnitOfWorkImpl.java:486)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist(UnitOfWorkImpl.java:4288)
    at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist(RepeatableWriteUnitOfWork.java:521)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.discoverAndPersistUnregisteredNewObjects(UnitOfWorkImpl.java:4187)
    at org.eclipse.persistence.mappings.CollectionMapping.cascadeDiscoverAndPersistUnregisteredNewObjects(CollectionMapping.java:483)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.cascadeDiscoverAndPersistUnregisteredNewObjects(ObjectBuilder.java:2515)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.discoverAndPersistUnregisteredNewObjects(UnitOfWorkImpl.java:4205)
    at org.eclipse.persistence.mappings.ObjectReferenceMapping.cascadeDiscoverAndPersistUnregisteredNewObjects(ObjectReferenceMapping.java:951)
    at org.eclipse.persistence.mappings.ObjectReferenceMapping.cascadeDiscoverAndPersistUnregisteredNewObjects(ObjectReferenceMapping.java:929)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.cascadeDiscoverAndPersistUnregisteredNewObjects(ObjectBuilder.java:2515)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.discoverAndPersistUnregisteredNewObjects(UnitOfWorkImpl.java:4205)
    at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.discoverUnregisteredNewObjects(RepeatableWriteUnitOfWork.java:308)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:723)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1516)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.issueSQLbeforeCompletion(UnitOfWorkImpl.java:3168)
    at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.issueSQLbeforeCompletion(RepeatableWriteUnitOfWork.java:355)
    at org.eclipse.persistence.transaction.AbstractSynchronizationListener.beforeCompletion(AbstractSynchronizationListener.java:158)

1 个答案:

答案 0 :(得分:0)

  • 确保数据库中存在序列值。
  • 重写持久化单元的名称(相同或新名称),然后清理并构建项目。