package jpastart.reserve.application;
import java.util.Optional;
import javax.persistence.EntityManager;
import jpastart.jpa.EMF;
import jpastart.reserve.model.User;
public class UserService {
public UserService() {
// // TODO Auto-generated constructor stub
}
public Optional<User> getUser(String email){
EntityManager em = EMF.createEntityManager();
try{
return Optional.ofNullable(em.find(User.class, email));
}finally{
em.close();
}
}
}
Even if there is a code that returns in the middle of the above code, will the final part be executed?
java c++ c#
Yes.
Even if the return statement is executed in the try block, the final block is executed.
930 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
578 Who developed the "avformat-59.dll" that comes with FFmpeg?
635 Uncaught (inpromise) Error on Electron: An object could not be cloned
624 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.