use of com.haulmont.cuba.core.entity.Config in project cuba by cuba-platform.
the class ConfigStorage method setDbProperty.
@Override
public void setDbProperty(String name, String value) {
Preconditions.checkNotNullArgument(name, "name is null");
Transaction tx = persistence.getTransaction();
try {
EntityManager em = persistence.getEntityManager();
Config instance = getConfigInstance(name);
if (value != null) {
if (instance == null) {
Metadata metadata = AppBeans.get(Metadata.NAME);
instance = metadata.create(Config.class);
instance.setName(name.trim());
instance.setValue(value.trim());
em.persist(instance);
} else {
instance.setValue(value);
}
} else {
if (instance != null)
em.remove(instance);
}
tx.commit();
} finally {
tx.end();
}
clearCache();
}
use of com.haulmont.cuba.core.entity.Config in project cuba by cuba-platform.
the class ConfigProviderTest method cleanup.
private void cleanup() {
Transaction tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
Query query = em.createQuery("select c from sys$Config c where c.name like ?1");
query.setParameter(1, "cuba.test.%");
List<Config> list = query.getResultList();
for (Config config : list) {
em.remove(config);
}
tx.commit();
} finally {
tx.end();
}
}
Aggregations