The simplest use case for this would be to support the singleton pattern, where only one object should be created of a specific entity.
But it could prove useful also for other use cases for example by preventing developers from creating sessions or other system objects in a microflow.
@Jord and only before-commit is not failsafe. You need to do more. I created a pattern for it a while ago, but that is far too many clicks-and-drags when you create it. Would love to see Andrej’s idea implemented.
@Jord yes that is possible but a before create event handler would only offer run-time protections while the feature that I am suggesting would prevent such error at design time.
Though i haven’t used it so far, the singleton pattern could be easily guarded by an before-create event handler, right? Just check if there is already an object in the database and if so, throw an error.
Singleton pattern is one of the things, which I use almost in every project (eg. for something like an app configuration or App status) and usually realized via DS-Microflow. But this is not failsafe.
In Java you can set the constructor_ of a class to private, to prevent creation from outside of the class. Would be nice to have a similar solution in mendix.