<commit_before>package com.github.aureliano.edocs.domain.dao;

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 com.github.aureliano.edocs.common.exception.EDocsException;
import com.github.aureliano.edocs.common.persistence.DataPagination;
import com.github.aureliano.edocs.domain.entity.Attachment;
import com.github.aureliano.edocs.domain.entity.Document;
import com.github.aureliano.edocs.domain.helper.DataTypeHelper;

public class AttachmentDao extends AbstractDao<Attachment> {

	private static final Logger logger = Logger.getLogger(AttachmentDao.class.getName());
	
	public AttachmentDao() {}
	
	@Override
	public Attachment save(Attachment entity) {
		return super.saveEntity(entity);
	}

	@Override
	public void delete(Attachment entity) {
		this.delete(entity.getId());
	}

	@Override
	public void delete(Integer id) {
		String sql = "delete from attachments where id = ?";
		super.delete(sql, id);
	}

	@Override
	public Attachment find(Integer id) {
		String sql = "select * from attachments where id = ?";
		return super.findEntity(sql, id);
	}

	@Override
	public List<Attachment> search(DataPagination<Attachment> dataPagination) {
		StringBuilder sql = new StringBuilder("select * from attachments where");
		Attachment entity = dataPagination.getEntity();
		
		if (entity.getId() != null) {
			sql.append(" id = " + entity.getId());
			return this.search(sql.toString());
		}
		
		if (entity.getDocument() != null) {
			sql.append(" document_fk = " + entity.getDocument().getId());
		}
		
		return this.search(sql.toString());
	}

	@Override
	public List<Attachment> search(String query) {
		return super.searchEntities(query);
	}<commit_msg>Add pagination params to query.<commit_after>package com.github.aureliano.edocs.domain.dao;

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 com.github.aureliano.edocs.common.exception.EDocsException;
import com.github.aureliano.edocs.common.persistence.DataPagination;
import com.github.aureliano.edocs.domain.entity.Attachment;
import com.github.aureliano.edocs.domain.entity.Document;
import com.github.aureliano.edocs.domain.helper.DataTypeHelper;

public class AttachmentDao extends AbstractDao<Attachment> {

	private static final Logger logger = Logger.getLogger(AttachmentDao.class.getName());
	
	public AttachmentDao() {}
	
	@Override
	public Attachment save(Attachment entity) {
		return super.saveEntity(entity);
	}

	@Override
	public void delete(Attachment entity) {
		this.delete(entity.getId());
	}

	@Override
	public void delete(Integer id) {
		String sql = "delete from attachments where id = ?";
		super.delete(sql, id);
	}

	@Override
	public Attachment find(Integer id) {
		String sql = "select * from attachments where id = ?";
		return super.findEntity(sql, id);
	}

	@Override
	public List<Attachment> search(DataPagination<Attachment> dataPagination) {
		StringBuilder sql = new StringBuilder("select * from attachments where");
		Attachment entity = dataPagination.getEntity();
		
		if (entity.getId() != null) {
			sql.append(" id = " + entity.getId());
			return this.search(sql.toString());
		}
		
		if (entity.getDocument() != null) {
			sql.append(" document_fk = " + entity.getDocument().getId());
		}

		super.setPaginationParams(dataPagination, sql);
		return this.search(sql.toString());
	}

	@Override
	public List<Attachment> search(String query) {
		return super.searchEntities(query);
	}
{'fraction_non_alphanumeric': 0.123052122514777, 'fraction_numerical': 0.0, 'mean_word_length': 4.995169082125604, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1377291', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1159, 'n_words': 244}