<commit_before>package dao.jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import conexao.ConnectionFactory;
import dao.dao.MaterialDAO;
import model.Material;

public class JDBCMaterialDAO implements MaterialDAO {
	
	private Connection connection;

	public JDBCMaterialDAO() {
		connection = ConnectionFactory.getConnection();
	}

	@Override
	public void inserir(Material material) {
		try {
			String SQL = "INSERT INTO material values (?, ?, ?, ?)";
			PreparedStatement ps = connection.prepareStatement(SQL);

			ps.setInt(1, material.getId());
			ps.setString(2, material.getNome());
			ps.setDouble(3, material.getPeso());
			ps.setLong(4, material.getTelefone());
			ps.executeUpdate();

			SQL = "UPDATE vendedor_fornecedor SET id_fornecedor = ? where id = ?";
			PreparedStatement ps2 = connection.prepareStatement(SQL);
			fornecedor.getVendedores().forEach(vendedorFornecedor -> {

				try {
					ps2.setInt(1, fornecedor.getId());
					ps2.setInt(2, vendedorFornecedor.getId());
					ps2.executeUpdate();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			});

		} catch (SQLException ex) {
			Logger.getLogger(JDBCClienteDAO.class.getName()).log(Level.SEVERE, null, ex);
		}
	}

	@Override
	public void remover(int id) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Material> listar() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Material buscar(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void editar(Material material) {
		// TODO Auto-generated method stub
		
	}

}<commit_msg>Atualizando JDBCMaterialDAO gerenciado pelo Hibernate<commit_after>package dao.jdbc;


import java.util.List;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import dao.dao.MaterialDAO;
import model.Material;

public class JDBCMaterialDAO implements MaterialDAO {
	
	private SessionFactory factory;

	public JDBCMaterialDAO() {
		
		factory = HibernateStarter.getSessionFactory();
	}

	@Override
	public void inserir(Material material) {
		Session session = factory.getCurrentSession();
		session.beginTransaction();
		session.save(material);
		session.getTransaction().commit();
	}

	@Override
	public void remover(int id) {
		Session session = factory.getCurrentSession();
		session.beginTransaction();
		Material material = new Material();
		material.setId(id);
		session.delete(material);
		session.getTransaction().commit();		
	}

	@Override
	public List<Material> listar() {
		Session session = factory.getCurrentSession();
		session.beginTransaction();
		@SuppressWarnings("unchecked")
		List<Material> materiais = session.createQuery("from Material").getResultList();
		session.getTransaction().commit();
		return materiais;
	}

	@Override
	public Material buscar(int id) {
		Session session = factory.getCurrentSession();
		session.beginTransaction();
		Material material = new Material();
		material.setId(id);
		material = session.get(Material.class, material.getId());
		session.getTransaction().commit();
		return material;
	}

	@Override
	public void editar(Material material) {
		Session session = factory.getCurrentSession();
		session.beginTransaction();
		session.update(material);
		session.getTransaction().commit();
		
	}

}
{'fraction_non_alphanumeric': 0.11916497535517541, 'fraction_numerical': 0.0028993911278631487, 'mean_word_length': 4.52, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1863314', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1049, 'n_words': 228}