Giter Site home page Giter Site logo

Introducing Business Logic about elide HOT 1 CLOSED

jackmatt2 avatar jackmatt2 commented on May 7, 2024
Introducing Business Logic

from elide.

Comments (1)

DennisMcWherter avatar DennisMcWherter commented on May 7, 2024

We have good news and bad news. The bad news, is that we didn't go into sufficient detail on this in the docs and that's why you couldn't find it! 👎

The good news: we do support this! 👍 If you look in the lifecycle events section of the docs, you'll notice that we briefly touch upon @OnCommit and @OnUpdate annotations. We actually support this for all operations, in fact. That is, there is an equivalent @OnCreate and @OnDelete. We do not support an @OnRead since you already have control of the getter method for that :)

Likewise, where supported you can use standard JPA callbacks. The reason we built these additional annotations to augment these is that Elide annotations can monitor on a per-column basis.

I will look into updating the docs today to make this clearer. Thank you for calling this out!

In regards to your example

I would expect an implementation for this would look similar to the following:

// ... annotations
@Entity
public class User {
  // ... user fields
  // Assuming this isn't a persisted field:
  private boolean isCreated = false;

  @OnCreate
  public void onCreateUser() {
    // This is executed upon object creation before commit.
    isCreated = true;
  }

  @OnCommit
  public void onCommitUser() {
    if (isCreated) {
      // send email
    }
  }
}

Please verify that this addresses your question and we can close the issue!

from elide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.