All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.droidlogix.dbflare.datahandler.IEntityRepository Maven / Gradle / Ivy

The newest version!
package com.droidlogix.dbflare.datahandler;

import com.droidlogix.dbflare.datahandler.models.IMetadataResult;
import com.droidlogix.dbflare.datahandler.models.IResultInfo;
import com.droidlogix.dbflare.datahandler.models.IResultParser;

import java.lang.reflect.Type;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * @author John Pili
 * @since 2016-10-13
 */
public interface IEntityRepository
{
	enum QUERY_STRING_TYPE
	{
		JPQL_QUERY, NATIVE_QUERY, NAMED_QUERY, NAMED_STORED_PROCEDURE, STORED_PROCEDURE
	};

	enum QUERY_RESULT_TYPE
	{
		SINGLE, MULTIPLE
	};

	/**
	 * This method handles the SQL insert. It will insert array of the same entities
	 * It uses transaction to rollback commits in an event of SQL exceptions
	 * @param entities
	 * @param 
	 * @return
	 * @throws Exception
	 */
	 long create(List entities) throws Exception;

	 void update(T entity, String findQuery, Map parameters) throws Exception;

	 long update(List entities, String fieldName) throws Exception;

	/**
	 * This method handles the delete. It will return an array of deleted entities.
	 * @param findQuery
	 * @param parameters
	 * @param 
	 * @return
	 * @throws Exception
	 */
	 List delete(String findQuery, Map parameters) throws Exception;

	/**
	 * This method handles the delete. It will return an array of deleted entities.
	 * @param findQuery
	 * @param parameters
	 * @param typeOf
	 * @param 
	 * @return
	 * @throws Exception
	 */
	 List delete(String findQuery, Map parameters, Type typeOf) throws Exception;

	/**
	 * This method is used to extra columns information. This helps in generating mapping and automated
	 * code generation for native SQL queries
	 * @param nativeSqlQuery
	 * @return
	 * @throws SQLException
	 */
	List extractMetadata(String nativeSqlQuery) throws SQLException;

	/**
	 * This method will handle single result query
	 * @param queryString
	 * @param parameters
	 * @param queryStringType
	 * @param resultInfo
	 * @return
	 * @throws Exception
	 */
	Object getSingle(String queryString, Map parameters, QUERY_STRING_TYPE queryStringType, IResultInfo resultInfo) throws Exception;

	/**
	 * This method handles getList based on QUERY_STRING_TYPE without pagination info and container
	 * it returns and empty array if no result or when an exception occurs
	 * @param queryString
	 * @param parameters
	 * @param queryStringType
	 * @param 
	 * @return
	 */
	 List getList(String queryString, Map parameters, QUERY_STRING_TYPE queryStringType, IResultInfo resultInfo) throws Exception;

	/**
	 * This method handles getList based on QUERY_STRING_TYPE with pagination info and container
	 * it returns and empty array if no result or when an exception occurs
	 * @param queryString
	 * @param parameters
	 * @param queryStringType
	 * @param pagingParameter
	 * @param 
	 * @return
	 */
	 List getList(String queryString, Map parameters, QUERY_STRING_TYPE queryStringType, IResultInfo resultInfo, IPagingParameter pagingParameter) throws Exception;

	/**
	 * This method handles native query with custom result parser to Map
	 * @param queryString
	 * @param parameters
	 * @param resultParser
	 * @return
	 * @throws Exception
	 */
	List> nativeQuery(String queryString, Map parameters, IResultParser resultParser) throws Exception;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy