Metadata.create() vs. dataManager.create()?

What is the difference between working with data via metadata.x (metadata.create() for instance) and via dataManager? Many examples say metadata is the way, but others use dataManager (for example @mario excellent guide @ https://www.cuba-platform.com/guides/intro-working-with-data-in-cuba ).

Hi,

According to javadocs of the DataManager method:

    /**
     * Creates a new entity instance in memory. This is a shortcut to {@code Metadata.create()}.
     * @param entityClass   entity class
     */
    <T> T create(Class<T> entityClass);

It’s just a shortcut.

1 Like

Aha. Thanks. :slight_smile:

@AlexBudarov i had recently problem with outOfMemory heap space. Is it possible that if i create entity datamanager.create and wont use it ater function it will leak? Shoul i somehow delete entity from memory if not used?

No, dataManager.create() doesn’t have risk of creating any memory leaks.

1 Like