Unable to import class Persistence in a new bean

I can not import the class “Transaction” and “Persistence” in a Bean. I have an error message at compilation.
After checking, the files are in the right places. I don’t understand !

Code :

package com.company.performancecenter.core;

import org.springframework.stereotype.Component;
import com.company.performancecenter.entity.Departement;
import com.haulmont.cuba.Persistence;
import com.haulmont.cuba.core.Transaction;
import javax.inject.Inject;
import java.util.UUID;

public class NomCompletDepartement {
    public static final String NAME = "PerformanceCenter_NomCompletDepartement";

    private Persistence persistence;
    public void miseAJourNomCompletDepartement(UUID entityId, String nomComplet){
        try (Transaction tx = persistence.getTransaction()){
            Departement departement = persistence.getEntityManager().find(Departement.class, entityId);
            if (departement != null){

log.txt(2.1 KB)


As far as I can see, your bean located in a global module. And Persistence and Transaction classes are not available there. Move the bean to core model. See the difference:




Thank you very much Alexander !
The problem is solved !

However, I don’t understand why the Bean I created just with a right click on “Middleware -> Beans -> new -> Bean” ended up at this location.

It was a bug of Studio 8.1, fixed in 8.2.