Announcement Announcement Module
Collapse
No announcement yet.
Entity constraints validation using SpringData mongo repository Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Entity constraints validation using SpringData mongo repository

    Hi,

    I am using SpringData for mongoDb and have defined marker repository interfaces for my entities. All repositories extend a custom parent repository. I need to perform validation on my entities before saving them.

    Since repository implementations are proxied at runtime I don't have a handle to write validate method in each repository. How do I ensure validation is invoked on each entity prior to save?

    I have other requirements too where few child repositories may choose to override behavior of some methods.

    - Auto generating GUID for all entities that are being saved. Logic to generate the id resides with the repository.



    Thanks,
    Sid
    Last edited by ssharma; Mar 26th, 2012, 08:01 AM. Reason: More info

  • #2
    As the repository infrastructure uses MongoTemplate have a look at the events [0] we support and implement a custom event listener.

    [0] http://static.springsource.org/sprin...e-summary.html

    Comment


    • #3
      Thanks Oliver. I will flirt with BeforeSaveEvent<E>.

      -Sid

      Comment

      Working...
      X