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

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

There is a newer version: 2.6.20180522184741
Show newest version
package io.crnk.jpa;

import io.crnk.core.engine.information.resource.ResourceField;
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 resourceField       representing the source field of the relation (entity or mapped dto)
	 * @param config              for this document
	 * @return created document
	 */
	 JpaRelationshipRepository createRelationshipRepository(
			JpaModule module, ResourceField resourceField, JpaRepositoryConfig config);

}