MorphiaOrg / MorphiaOrg/morphia

@PrePersist method not invoked sometimes

Open
#2,136 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Waiting for Response
Dominant language
Java
Stars
1.7k
Forks
449
Avg merge
7m
Merged PRs (30d)
10

Description

We use @PrePersist to initialize few fields during Save of an entity.
This feature seems to be working fine most of the times. But in rare cases, this PrePersist module code is never invoked. Also we dont have the fields initialized. This leads to many processing bugs due to missing field.

  • Server Version: 4.2.x
  • Driver Version: 4.4.0
  • Morphia Version:Using Morphia 2.2.8. [ Same issue happened in 2.2.3 as well]

@evanchooly , please suggest why this would happen. No Errors on console as well. Is there a way to track why this is skipped?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the rare save case involving @PrePersist and compare behavior across Morphia 2.2.3 and 2.2.8. The issue names no source file or test; done means determining why the callback is skipped and documenting or fixing the behavior with coverage for the failing case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.