package org.minimalj.transaction;

import java.sql.Connection;

import org.minimalj.backend.Persistence;

public abstract class PersistenceTransaction<ENTITY, RETURN> implements Transaction<RETURN> {
	private static final long serialVersionUID = 1L;

	@Override
	public final RETURN execute() {
		RETURN result;
		boolean commit = false;
		Persistence persistence = Persistence.getCurrent();
		try {
			persistence.startTransaction(Connection.TRANSACTION_SERIALIZABLE);
			result = execute(persistence);
			commit = true;
		} finally {
			persistence.endTransaction(commit);
		}
		return result;
	}

//	public List<String> getRoles() {
//		List<String> neededRoles = new ArrayList<>();
//		PersistenceRole[] roles = getEntityClazz().getAnnotationsByType(PersistenceRole.class);
//		checkPermissions(subject, roles);
//
//		roles = getEntityClazz().getPackage().getAnnotationsByType(PersistenceRole.class);
//		checkPermissions(subject, roles);
//	}
//
//	Das Problem ist, dass mehrere And von Ors Verknüpfungen entstehen.
//	
//	private void getRoles(List<String> neededRoles, PersistenceRole[] roles) {
//		for (PersistenceRole role : roles) {
//			if (role.type().isAssignableFrom(this.getClass())) {
//				neededRoles.add(role.)
//			}
//		}
//	}
//	
	
	protected abstract RETURN execute(Persistence persistence);
	
}

@@ -597,664 +597,8 @@
 %09%7D%0A%0A
-//%09public List%3CString%3E getRoles() %7B%0A//%09%09List%3CString%3E neededRoles = new ArrayList%3C%3E();%0A//%09%09PersistenceRole%5B%5D roles = getEntityClazz().getAnnotationsByType(PersistenceRole.class);%0A//%09%09checkPermissions(subject, roles);%0A//%0A//%09%09roles = getEntityClazz().getPackage().getAnnotationsByType(PersistenceRole.class);%0A//%09%09checkPermissions(subject, roles);%0A//%09%7D%0A//%0A//%09Das Problem ist, dass mehrere And von Ors Verkn%C3%BCpfungen entstehen.%0A//%09%0A//%09private void getRoles(List%3CString%3E neededRoles, PersistenceRole%5B%5D roles) %7B%0A//%09%09for (PersistenceRole role : roles) %7B%0A//%09%09%09if (role.type().isAssignableFrom(this.getClass())) %7B%0A//%09%09%09%09neededRoles.add(role.)%0A//%09%09%09%7D%0A//%09%09%7D%0A//%09%7D%0A//%09%0A%09%0A
 %09pro

remove dead comment