Skip to content
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

annotated @Version Entity can't set @ContentId、@MimeType、@OriginalFileName automatically #79

Closed
lmtoo opened this issue Oct 11, 2019 · 1 comment

Comments

@lmtoo
Copy link

lmtoo commented Oct 11, 2019

hi,I have a bug to report.
ContentEntityRestController's handleMultipart first find domainObj from JpaRepository,
and then set @ContentID@MimeType@originalFilename value to the domainObj,
and then check domainObj whether annotated @Version,if so find domainObj from JpaRepository again , but the domainObj changed ,don't have these value anymore , it seems persistence context changed.

@paulcwarren
Copy link
Owner

paulcwarren commented Oct 17, 2019

Hi lmtoo,

Thanks for raising this issue.

I agree this code looks a little weird.

If I recall this is because ContentStore.setContent should return the entity but doesn't. This is a problem when @Version is applied to the entity. Hibernate will update it during save/persist and return the updated entity with the updated version field that setContent drops on the floor. If we dont re-fetch the entity then the subsequent save fails. I believe this works though because the re-fetch just grabs the (updated) entity out of its cache, rather than going back to the database. But, I could be wrong.

Is this failing for you? i.e. you are seeing the contentid, mime-type and original filename fields revert? Also what Spring Boot stack are you on? 2.1, or 2.2?

paulcwarren pushed a commit that referenced this issue Oct 23, 2019
paulcwarren pushed a commit that referenced this issue Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants