In Cuba I had a service that would create a new instance, save it through an entitymanager and then set properties on it.
T entity = metadata.create(targetType);
persistence.getEntityManager().persist(entity);
// a whole bunch of other layers
entity.setNotNullProperty(value);
This used to work but when converting to a datamanger approach a database ConstraintViolationException on the not null property is thrown.
I assume this is because with the entityManager the flush happens at transaction commit (or when needed) vs instantly when using the datamanager.
Is this intended behavior? When should I expect the datamanager strategy to flush?
ps. The reason I switched from entitymanager to datamanager is that my entities are in fact using the multitenancy plugin. Cuba Entitymanager (no longer?) supports multitenancy because it is implemented through entity listener events.
edit: I compared the code in com.haulmont.cuba.core.sys.EntityManagerImpl and my suspicion on events is correct, the cuba entitymanager used to send events. This means that the cuba entitymanager is NOT backwards compatible. Is this a bug?