Skip to content

Entity new detection doesn't consider Persistable.isNew() [DATAMONGO-1590] #2502

Closed
@spring-projects-issues

Description

@spring-projects-issues

Matan Shukry opened DATAMONGO-1590 and commented

Lookign at SimpleMongoRepository, MongoRepositoryFactory, MappingMongoEntityInformation in spring, it seems MappingMongoEntityInformation will always be used for type information about a class.

If that is the case, an entity that implements org.springframework.data.domain.Persistable isn't taken into account.

In my specific use case, where I would like to generate sequential ids (I'm using an extra query for the database using an extra collection so it'd be unique), the id isn't empty when I'm saving it, and as a result SimpleMongoRepository will always try to 'update' rather than insert a new record.

I didn't follow the entire flow, but from a quick glance, it seems the insert is the better option, when the entity isn't created.

p.s.
I'm also looking for a way to create a custom id generator. I'll open a different ticket for it (feature request), but I'm guessing it's related. Not sure if it matters


Issue Links:

  • DATACMNS-976 AbstractEntityInformation should consider Persistable.isNew()

Referenced from: pull request #436

Backported to: 1.10 GA (Ingalls), 1.9.7 (Hopper SR7)

Metadata

Metadata

Assignees

Labels

in: mappingMapping and conversion infrastructuretype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions