Announcement Announcement Module
Collapse
No announcement yet.
Pre- and PostPersist in a Roo Aspect? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pre- and PostPersist in a Roo Aspect?

    Hi

    I'm finding myself putting the following snippet in most of my entities:

    Code:
    @PrePersist
    protected void onCreate() {
        dateCreated = new Date();
    }
    
    @PreUpdate
    protected void onUpdate() {
        lastUpdated = new Date();
    }
    It feels like this is something that belongs in Roo_Entity.aj and might be a neat option for entity creation. Any believers? Where would I RTFM if I wanted to attempt to do this (add this option to the entity command) myself?

    -Steve

  • #2
    Hi Steve,

    This is interesting. Your way to include such data into your domain model is certainly an option. I am not sure if this should be included in the default Roo JPA add-on though as not everyone wants such auditing data directly inside the domain model. So it may make more sense to create your own little add-on which introduces this functionality from a separate aspect (similar to *_Roo_Entity.aj, etc). To get started I would encourage you to check out the roo sources and take a look at the toString add-on which is fairly simple so you understand the inner workings of how an add-on works.

    Ben has recently worked at making add-on development much easier and has presented a conference talk on this as well. So I will leave it to him to comment here. There will be a add-on development guide in the documentation soon which should help you further. Finally, feel free to ask questions here should you need help.

    Cheers,
    Stefan

    Comment


    • #3
      This is a great example of a new add-on, like @RooAudit. It would use an ITD to add these members to entities that don't already include them. As Stefan mentioned, I gave a conference talk on the topic of add-on development and you'd probably find that a good starting point for today (just email me directly and I'll send you the slides; I will publish them publicly soon, but not until I've finished my present round of conference talks next week). I've also got a lot of chapters planned for the reference guide on Roo internals and add-on development, so that will also help. Realistically this will take a little more time to write, though, as we're first focusing on standard usage of Roo (as opposed to extension of Roo). The source code for add-ons like the entity add-on are excellent learning tools in the meantime, though - especially when coupled with my Roo internals conference presentation material.

      Comment


      • #4
        thanks

        Hi Ben

        Thanks for the reply! I took a look at the source code and I'm not sure I'm quite ready to make my own ITD magic just yet, but I'm excited to see some docs when they're ready. I'll check out the cloud source add on as well for more reference.

        Best
        Steve

        Comment


        • #5
          Are any activity on @RooAudit addon?
          It can help me great but I can't find nothing about development of this addon.
          Also founded https://jira.springframework.org/browse/ROO-673 and the scaffolding issue is not a problem for me this time.

          Comment

          Working...
          X