[ https://issues.apache.org/jira/browse/JDO-735?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14545765#comment-14545765 ]
Craig L Russell edited comment on JDO-735 at 5/15/15 8:57 PM: -------------------------------------------------------------- The specification is silent on the subject of PM.close() when a transaction is active. I think we need to add this behavior in light of auto-close. I'd think that if a transaction is active, close should roll back the transaction and complete normally. Consider this use-case: // this will either update the objects or throw an optimistic exception try (PersistenceManger pm = pmf.getPersistenceManager()) { pm.currentTransaction().begin(); // optimistic // do some updates to some objects pm.currentTransaction().commit(); } What we want to allow the user to do is to avoid all the work to figure out how to clean up the persistence manager in case of an error. was (Author: clr): The specification is silent on the subject of PM.close() when a transaction is active. I think we need to add this behavior in light of auto-close. I'd think that if a transaction is active, close should roll back the transaction and complete normally. Consider this use-case: // this will either update the objects or throw an optimistic exception try (PersistenceManger pm = pmf.getPersistenceManager()) { pm.currentTransaction().begin(); // optimistic // do some updates to some objects pm.currentTransaction().commit(); } What we want to allow the user to do is to avoid all the work to figure out how to clean up the persistence manager in case of an error. > Make PersistenceManager and Query support AutoCloseable (JDK1.7+) > ----------------------------------------------------------------- > > Key: JDO-735 > URL: https://issues.apache.org/jira/browse/JDO-735 > Project: JDO > Issue Type: New Feature > Components: api, specification, tck > Reporter: Andy Jefferson > Fix For: JDO 3.2 > > > So then it can be used with JDK1.7+ try-with-resources, as per > http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html -- This message was sent by Atlassian JIRA (v6.3.4#6332)