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

io.crnk.jpa.JpaRepositoryFactory Maven / Gradle / Ivy

package io.crnk.jpa;

import java.io.Serializable;

/**
 * Used to create document and relationship repositories for the provided
 * classes. By default {@link DefaultJpaRepositoryFactory}} is used.
 */
public interface JpaRepositoryFactory {

	/**
	 * Creates a document document that maps an entity to a JSON API endpoint. The provided document class not necessarily has to be
	 * an entity class. The JpaModule is checked whether there is a mapping available.
	 *
	 * @param     document type
	 * @param     identifier type
	 * @param module managing the document
	 * @param config for this document
	 * @return created document
	 */
	 JpaEntityRepository createEntityRepository(JpaModule module,
																				 JpaRepositoryConfig config);

	/**
	 * Creates a relationship document that maps an entity relationship to a JSON API endpoint. The provided document classes do not necessarily have to be
	 * an entity class. The JpaModule is checked whether there is a mapping available.
	 *
	 * @param                  source document type
	 * @param                  source identifier type
	 * @param                  target document type
	 * @param                  target identifier type
	 * @param module              managing the document
	 * @param sourceResourceClass representing the source of the relation (entity or mapped dto)
	 * @param config              for this document
	 * @return created document
	 */
	 JpaRelationshipRepository createRelationshipRepository(
			JpaModule module, Class sourceResourceClass, JpaRepositoryConfig config);

}