Skip to content

contraint violation cause of JdbcOperationsSessionRepository.JdbcSession#setAttribute #1110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mfra opened this issue Jul 2, 2018 · 5 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@mfra
Copy link

mfra commented Jul 2, 2018

Removing and readding a attribute within a single requests causes a DB's contraint violation.

This is caused by the session's attribute delta calculation in
org.springframework.session.jdbc.JdbcOperationsSessionRepository.JdbcSession#setAttribute

Removing the attribute stores "attributeName:REMOVED" while adding later changes the information to "attributeName:ADDED". The DELETE statement then is not executed and an INSERT of that attribute is triggered on the end of the requestcycle. This leads to a constraint violation defined by
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME)

@mfra mfra changed the title org.springframework.session.jdbc.JdbcOperationsSessionRepository.JdbcSession#setAttribute contraint violation cause of JdbcOperationsSessionRepository.JdbcSession#setAttribute Jul 2, 2018
@vpavic vpavic self-assigned this Jul 2, 2018
@vpavic
Copy link
Contributor

vpavic commented Jul 2, 2018

Thanks for the report @mfra. Can you clarify which version of Spring Session are you using?

@vpavic vpavic added the status: waiting-for-feedback We need additional information before we can continue label Jul 2, 2018
@mfra
Copy link
Author

mfra commented Jul 2, 2018

I am using currently:

  <groupId>org.springframework.session</groupId>
  <artifactId>spring-session-jdbc</artifactId>
  <version>2.0.3.RELEASE</version>

@vpavic vpavic removed the status: waiting-for-feedback We need additional information before we can continue label Jul 2, 2018
@vpavic
Copy link
Contributor

vpavic commented Jul 2, 2018

Thanks for the quick follow up. Please upgrade to 2.0.4.RELEASE - this issue was reported and addressed in #1070.

@vpavic
Copy link
Contributor

vpavic commented Jul 2, 2018

Duplicate of #1070

@vpavic vpavic marked this as a duplicate of #1070 Jul 2, 2018
@vpavic vpavic closed this as completed Jul 2, 2018
@vpavic vpavic added the status: duplicate A duplicate of another issue label Jul 2, 2018
@mfra
Copy link
Author

mfra commented Jul 2, 2018

ah, thnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants