Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityManager(Factory) should implement AutoCloseable #77

Closed
lukasj opened this issue Apr 13, 2014 · 14 comments · Fixed by #312
Closed

EntityManager(Factory) should implement AutoCloseable #77

lukasj opened this issue Apr 13, 2014 · 14 comments · Fixed by #312

Comments

@lukasj
Copy link
Contributor

lukasj commented Apr 13, 2014

EntityManager and EntityManagerFactory have #close() methods but do not implement AutoCloseable. Implementing AutoCloseable would allow them to be used in Java 7 try-with-resource statement.

@lukasj
Copy link
Contributor Author

lukasj commented Apr 13, 2014

@glassfishrobot Commented
Reported by braghest

@lukasj
Copy link
Contributor Author

lukasj commented May 21, 2015

@glassfishrobot Commented
flutter said:
This would mean to drop Java 6 support, right?

@lukasj
Copy link
Contributor Author

lukasj commented May 22, 2015

@glassfishrobot Commented
braghest said:
That would mean dropping Java 7 support but then again Java EE 7 requires Java SE 7.

@lukasj
Copy link
Contributor Author

lukasj commented May 28, 2015

@glassfishrobot Commented
neilstockton said:
It would mean dropping Java 1.6, yes. But then Java 1.6 and Java 1.7 are BOTH end of life now.
By the time the next version of JPA happens (who knows when that is), Java 1.8+ should be the baseline, hence no reason why this issue can't be included.
+1

@lukasj
Copy link
Contributor Author

lukasj commented Aug 31, 2016

@glassfishrobot Commented
jemiller1 said:
Come on guys. It's 2016 and Java 8 has been out for over a year. Is this ever going to get implemented? It looks really obvious to me that this needs to happen. I don't know what to say about the whole Java standards process other than it's extremely slow. Coming from a .NET environment. It is a huge step backwards working with Java. I'm amazed that things as simple as this don't just work. And has already been pointed out Java 6 and 7 are already EOL.

@lukasj
Copy link
Contributor Author

lukasj commented Dec 2, 2016

@glassfishrobot Commented
s.grinovero said:
For the record, we had this in Hibernate since a while, and initially implemented java.io.Closeable which just requires java 1.5. java.io.Closeable extends AutoCloseable since Java 7, so people on Java >=7 could use the try-with-resources pattern already.

@lukasj
Copy link
Contributor Author

lukasj commented May 5, 2017

@glassfishrobot Commented
This issue was imported from java.net JIRA JPA_SPEC-77

@lukasj
Copy link
Contributor Author

lukasj commented Jun 22, 2018

@KrishnaST Commented
2018 and counting.

@lukasj
Copy link
Contributor Author

lukasj commented Aug 31, 2018

tofflos added a commit to tofflos/jpa-api that referenced this issue Aug 31, 2018
tofflos added a commit to tofflos/jpa-api that referenced this issue Aug 31, 2018
Signed-off-by: Erik Östlund <erik.ostlund@gmail.com>
@MalteMagnussen
Copy link

I've been working a lot with EntityManager in school now, and it kinda bugs me that this isn't implemented.
It isn't a big deal though, I just add a finally { em.close } to all my stuff, but it would be lovely if we could use try-with-resources.
Please get this implemented.

@nerdglitchtiff
Copy link

It would be great if we could use the try-with-resource statement with the EntityManager Factory Interface. It's the only thing that makes sense.

@gavinking
Copy link
Contributor

+1

2 similar comments
@joeltoby
Copy link

+1

@DSEyers
Copy link

DSEyers commented Dec 10, 2020

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants