Replies: 3 comments 2 replies
-
Off the top of my head, the easiest way would be to version your entity and check that the version is 1 (I think. that order is a bit fuzzy and i don't have that code in front of me right now.) Any other value would indicate that it's an update and not the initial insert. |
Beta Was this translation helpful? Give feedback.
-
I was actually referring to using Morphia's built-in versioning to manage those values for you. It will always be a |
Beta Was this translation helpful? Give feedback.
-
I got it. Thank you very much for your response. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to add automatic filling functionality to the entity class. Here's how you can use it:
The following is the main code implementing the EntityInterceptor interface:
As mentioned above, I encountered an issue where
isInsert
always returns false. During my debugging process, I discovered that Morphia always assigns values to properties annotated with@Id
beforeprePersist
, which makes it impossible for me to determine whether the current operation is an insert or update based on the id's nullability. Additionally, I haven't found any method that can provide the current operation type, which makes it difficult for me to extend the framework.Could you please let me know if there is a solution to this problem? Thank you very much for your assistance!
Beta Was this translation helpful? Give feedback.
All reactions