Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Eclipselink generating sequence twice which is unexcepted(Eclipselink generating sequence twice which is unexcepted)
Eclipselink generating sequence twice which is unexcepted [message #1861518] Tue, 17 October 2023 07:24 Go to next message
Sanjana C is currently offline Sanjana CFriend
Messages: 31
Registered: December 2022
Member
Hi Team,

I am using eclipselink 2.7.6 with weblogic 12c.

When i run a insert operation which follows generating sequence, i see eclipselink generats sequence twice.

[EL Fine]: sql: 2023-10-17 08:59:21.434--ClientSession(1507239121)--Connection(1104718965)--Thread(Thread[main,5,main])--SELECT BAS_SEQ.NEXTVAL FROM DUAL
[EL Fine]: sql: 2023-10-17 08:59:21.455--ClientSession(1507239121)--Connection(1104718965)--Thread(Thread[main,5,main])--SELECT SAM_SEQ.NEXTVAL FROM DUAL
[EL Fine]: sql: 2023-10-17 08:59:21.472--ClientSession(1507239121)--Connection(1104718965)--Thread(Thread[main,5,main])--SELECT MIG_SEQ.NEXTVAL FROM DUAL
[EL Fine]: sql: 2023-10-17 08:59:21.489--ClientSession(1507239121)--Connection(1104718965)--Thread(Thread[main,5,main])--SELECT MIG_SEQ.NEXTVAL FROM DUAL
[EL Fine]: sql: 2023-10-17 08:59:21.512--ClientSession(1507239121)--Connection(1104718965)--Thread(Thread[main,5,main])--SELECT SYSDATE FROM DUAL

In above log , MIG_SEQ is generated twice. So record is inserted with id 1 and later when i search for record , it just takes latest sequence i.e 2 and throws error saying no record available.

Below is persistence.xml

<properties>

<property name="eclipselink.logging.level" value="ALL" />
<property name="eclipselink.logging.level.sql" value="ALL"/>
<property name="eclipselink.logging.parameters" value="true" />
<property name="eclipselink.logging.logger" value="DefaultLogger"/>
<property name="eclipselink.jdbc.bind-paramaters" value="true" />
<property name="eclipselink.target-database" value="Oracle" />
<property name="eclipselink.persistence-context.flush-mode" value="commit" />
<property name="eclipselink.persistence-context.reference-mode" value="WEAK" />
<property name="eclipselink.weaving" value="static" />

<property name="eclipselink.jdbc.exclusive-connection.mode" value="Always" />
<property name="eclipselink.sessions-xml" value="sessions.xml" />
<property name="eclipselink.session-name" value="default" />

</properties>

sessions.xml

<session xsi:type="server-session">
<name></name>
<logging xsi:type="server-log"></logging>
<primary-project xsi:type="xml"></primary-project>
<additional-project xsi:type="xml"></additional-project>
<login xsi:type="database-login">
<platform-class>org.eclipse.persistence.platform.database.oracle.Oracle10Platform</platform-class>
<!-- usage of external connect information - uses the spring toplink transaction manager -->
<external-connection-pooling>true</external-connection-pooling>
<external-transaction-controller>true</external-transaction-controller>
<sequencing>
<default-sequence xsi:type="native-sequence">
<name>Native</name>
<preallocation-size>1</preallocation-size>
</default-sequence>
</sequencing>
</login>
<connection-policy>
<exclusive-connection>true</exclusive-connection>
<lazy>false</lazy>
</connection-policy>
</session>

I tried disabling the weaving but still can see the duplicate sequence generated . I see there was a bug in 2.5 eclipselink version but iam using 2.7.6

Please let me know if any one faced or resolved this issue.

Thanks,
Sanjana

Re: Eclipselink generating sequence twice which is unexcepted [message #1861559 is a reply to message #1861518] Wed, 18 October 2023 17:49 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 54
Registered: December 2021
Member
Not quite sure of the issue, or the cause as the problem doesn't seem clear to me. EclipseLink should be selecting from the sequence generator to obtain sequences based on the preallocation size, so is thinking it needs two inserts. Can you elaborate more on what is actually being inserted, and why you'd be looking for a row using the second sequence value if it wasn't actually used for the insert? The value used should have been put into the entity when it was assigned.

If you are able to reproduce the issue in a test case, you might try putting a break point in the buildSelectQueryForSequenceObject from the base OraclePlatform class to determine what might be triggering the call.
Re: Eclipselink generating sequence twice which is unexcepted [message #1861592 is a reply to message #1861559] Fri, 20 October 2023 12:30 Go to previous messageGo to next message
Sanjana C is currently offline Sanjana CFriend
Messages: 31
Registered: December 2022
Member
Hi Chris,

I hope eclipselink creates sequence by default when there is an insert query(when we configure sequence in orm.xml). But in code we have a call to UOW.assignSequenceNumber() after insert statement which may be creating the problem.

Instead i tried using UOW.getNextSequenceNumberValue() and now it just gets the correct sequence.

Thanks,
Sanjana

Re: Eclipselink generating sequence twice which is unexcepted [message #1861623 is a reply to message #1861592] Mon, 23 October 2023 20:11 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 54
Registered: December 2021
Member
Ah - you should either let EclipseLInk assign sequence numbers and so leave it blank (and so have EL assign it after the persist call or after flush/commit), or assign them yourself (via UOW.assignSequenceNumber() or any sequence strategy). If you configure the entity to have EclipseLink assign them, I believe JPA code has it assign them even if there is a value in there already - I don't remember that functionality all that well or seen it in the more recent versions.

Best Regards,
Chris
Previous Topic:Eclipselink with spring giving error while loading descriptor xml
Next Topic:Eclipselink gives exception when running TestSuite
Goto Forum:
  


Current Time: Mon Apr 29 13:15:17 GMT 2024

Powered by FUDForum. Page generated in 0.02729 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top