public static void main(String[] args) throws IOException { EntityManager manager = JpaUtil.getEntityManager(); Veiculo veiculo = manager.find(Veiculo.class, 1L); if (veiculo.getFoto() != null) { BufferedImage image = ImageIO.read(new ByteArrayInputStream(veiculo.getFoto())); JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(image))); } else { System.out.println("Veículo não posui foto."); } manager.close(); JpaUtil.close(); }