Persistence interface wrong import

I am using Studio plugin 7, I am trying to insert a row into database programmatically, I have tried the following code:

@Inject
private Metadata metadata;
@Inject
private Persistence persistence;
try (Transaction tx = persistence.createTransaction()) {
    Customer customer = metadata.create(Customer.class);
    customer.setName("John Smith");
    persistence.getEntityManager().persist(customer);
    tx.commit();
}

intellij cannot find the interface com.haulmont.cuba.core.Persistence to import it, intellij imports a wrong package javax.persistence.Persistence.
Anyone has any idea for why that package is not included in the project, and how to include it?
Than you

Hi,

Where does the code live (in which module)? The persistence bean is only availablr in the core module. Otherwise you can use services or dataManager instead.

Bye
Mario

Hi, Mario. you are right.

Thank you for your reply.