<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.br.lp2.dao;

import com.br.lp2.model.javabeans.Imagem;
import com.br.lp2.singletonconnection.SingletonConnection;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.rowset.serial.SerialBlob;

/**
 *
 * @author 41514262
 */
public class ImagemDAO implements GenericDAO<Imagem> {

    Connection connection = SingletonConnection.getInstance().getConnection();

    @Override
    public boolean insert(Imagem imagem) {
        boolean result = false;

        String sql = "INSERT INTO imagem (id_produto,conteudo)VALUES(?,?)";
        try {
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setLong(1, imagem.getId_produto());
            ps.setBlob(2, new SerialBlob(imagem.getConteudo()));

            int resp = ps.executeUpdate();
            if (resp != 0) {
                result = true;
            }
            ps.close();<commit_msg>ImagemDAO inset com SELECT MAX LENGHT<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.br.lp2.dao;

import com.br.lp2.model.javabeans.Imagem;
import com.br.lp2.singletonconnection.SingletonConnection;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.rowset.serial.SerialBlob;

/**
 *
 * @author 41514262
 */
public class ImagemDAO implements GenericDAO<Imagem> {

    Connection connection = SingletonConnection.getInstance().getConnection();

    @Override
    public boolean insert(Imagem imagem) {
        boolean result = false;

        String sql = "INSERT INTO imagem (id_produto,conteudo)VALUES((SELECT MAX(LENGTH(id_produto))FROM PRODUTO),?)";
        try {
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setBlob(1, new SerialBlob(imagem.getConteudo()));

            int resp = ps.executeUpdate();
            if (resp != 0) {
                result = true;
            }
            ps.close();
{'fraction_non_alphanumeric': 0.10635881907645722, 'fraction_numerical': 0.010219530658591975, 'mean_word_length': 3.2491961414790995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4881255', 'n_tokens_mistral': 786, 'n_tokens_neox': 759, 'n_words': 194}