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

@OnetoMamy @JoinColumn don't populate when @Id is manually assigned [DATAJPA-511] #908

Closed
spring-projects-issues opened this issue Apr 9, 2014 · 7 comments
Assignees
Labels
in: core status: declined type: bug

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Apr 9, 2014

Gökhan Öner opened DATAJPA-511 and commented

Hi,

I'm trying to save a unidirectional OneToMay relationed entitiy.

What I discover is, if I use supply manual id, it's not populating the @JoinColumn using Repository.save . But When I inject EntitiyManagerFactory and persist it manually, it works.

Also, if I define a @GeneratedValue for @Id, then Repository.save also works as expected.

I^ve attached the hibernate config, Entitiy Classes and my service that run the save operation. (updateIstekResponse Method)


Affects: 1.4.4 (Babbage SR3)

Attachments:

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Apr 9, 2014

Gökhan Öner commented

Note:

As a workaround, I ad a custom save method to implementing repository, which just call entitiyManager.persist, and it also works. Only thing that I can think is that because I'm supplying the id, maybe spring is calling merge instead of persist??

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Apr 9, 2014

Gökhan Öner commented

Note:

As a second workaround, I implement the Persistable in my entity and return true on isNew() method, so I now that i'll never update, just insert

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Apr 9, 2014

Oliver Drotbohm commented

If you manually assign IDs you either have to implement Persistable or provide a custom EntityInformation instance on the JpaRepositoryFactory level as we have no way to distinguish between new entities and ones to be updated

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Apr 9, 2014

Gökhan Öner commented

Thanks for the info.
After some readings, I also found that and implemented the Persistable

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Apr 9, 2014

Gökhan Öner commented

Point taken and Persistable implemented, issue resolved

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Apr 9, 2014

Oliver Drotbohm commented

Awesome, glad it works for you! :)

@spring-projects-issues
Copy link
Author

spring-projects-issues commented May 22, 2019

Jens Schauder commented

Batch closing resolved issue without a fix version and a resolution indicating that there is nothing to release (Won't fix, Invalid ...)

@spring-projects-issues spring-projects-issues added type: bug status: declined in: core labels Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: declined type: bug
Projects
None yet
Development

No branches or pull requests

2 participants