Giter VIP home page Giter VIP logo

spring-data-template's Introduction

Spring Data Template Framework

Spring Data FrameworkThe extension or use of template scaffolding, which is a secondary development tool. According to this template, you can easily extract the files in the template and develop your own Spring Dataframework.This case is intended for learning and communication and cannot be used for actual production.

中文版, Swith English version

Use spring-data-template

Briefly describe how to apply Spring data templates to develop your own Spring Dataframework.

Create project

First, you need to create a meaningful project name, which is SpringDatathe name of the current frame. For example, to create a cached SpringDataframe, just name it spring-data-cache. If you want to create a redis's SpringData, it is named spring-data-redis.

Create Packages

Creating suitable packagethe top pkg, for example, with a spring-data-cacheframe, for example, it packageshould be org.springframework.data.cache, and end is the name of the frame.

PackageAnd implementation class introduction

In general, the top packageHere are the main core of the package to achieve spring-data, which usually are:

  • annotations: annotations, Query、Repository、Entity、Configannotation classes for configuration

    • Query Query annotations, you can configure this annotation in the interface method of repo to complete the custom conditional query.
    • CountQuery Inherit Query to complete count query
    • Model Entity model annotation, after annotation, you can read the information in the entity annotation to facilitate the persistence operation
    • Setting Entity model annotations, such as the configuration path of the current entity
    • Field Entity model attribute annotation, you can map attributes
    • Score Entity attribute annotation, attribute additional configuration information
  • config: configuration type, based onSpringDatathe configuration base class, Entity scan class, etc.

    • AbstractTemplateConfiguration The template configuration base class, some common configuration information can be preferentially configured in it
    • TemplateEntityClassScannerScanning Repositoryused EntityClass, in AbstractTemplateConfiguration.getInitialEntitySetdependence of the type of process
    • TemplateNamespaceHandler Configuration injection of namespaces, you don't need
  • core : Core business is done repository to achieve the underlying business CRUD operations

    • converter: underlying interface entity and repository interaction time, object-type field converter

      • DateTimeConverter Date time and string conversion, there can also be conversion implementations of other classes
      • MappingTemplateConverter Map converter to complete the mapping between the underlying and the entity
      • TemplateConverter Map converter interface definition
    • mapping: mapping between entities and underlying interface objects, field types

      • TemplatePersistentEntity Persistent entity object interface, you can define additional information necessary for a number of persistent entities, to facilitate the realization of repositorythe use of time
      • TemplatePersistentProperty Persistent entity object attribute interface, additional necessary information to define persistent attributes
      • SimpleTemplateMappingContext Mapping context, providing methods for building persistent entities and attributes
      • SimpleTemplatePersistentEntity Persistent entity object interface implementation
      • SimpleTemplatePersistentProperty Persistent entity object attribute interface implementation
    • query : query string, annotation inquiry, CRUD operation conditions of the core implementation

    • MyTplTemplateTemplate class, CRUD operations is completed, provided to the repositoryunderlying implementation

    • TemplateOperations Template class interface, complete the definition of CRUD operations

  • enums : enum class configuration

  • repository: repository interface rules and main implementation

    • cdi: CDI implemented using dependency injection, without depending on spring the case of injection, the injection may be used

      • TemplateRepositoryBeanUse CdiRepositoryBean Creating Repositoryobject instances
      • TemplateRepositoryExtensionA portable CDI extensions, it is Repositoryregistered bean, provided CdiRepositoryBeanto achieve the required
    • config: based onSpringData the configuration class, open the current framework or some basic configuration

      • EnableTemplateRepositoriesCore configuration, whether open spring-data-templateframework and loaded configuration
      • TemplateRepositoriesRegistrarSet RepositoriesRegistrarregistration implementation
      • TemplateRepositoryConfigurationExtensionProvide RepositoryConfigurationconfiguration information to achieve
    • query: Based on SpringData the query implementation, basic needs SpringCommon some interfaces and classes to complete

      • simple : Provides a simple implementation of the repositoryinterface annotation SQL string query and PartTreequery
      • complex : Provides a complex implementation of repositoryinterface annotation SQL string queries and PartTreequeries
      • TemplateQueryMethodProvide repositorybasic information about the interface query method
      • SimpleTemplateQueryCreator``repositoryDynamically generate SQL query statements through interface query methods
      • TemplateEntityMetadataProvide repositorymetadata information for persistent entity objects
    • support: current repository core implementation

      • TemplateEntityInformationExpand EntityMetadatato add the ability to query entity instance information
      • MappingTemplateEntityInformationImplement EntityInformation to populate Entity related information. And you can take advantage of Converter/PersistentEntitydata conversion and the filling.
      • TemplateEntityInformationCreatorEntity information TemplateEntityInformationObject creator Interface
      • TemplateEntityInformationCreatorImplEntity information TemplateEntityInformationObject creator interface
      • TemplateRepositoryFactoryBy TemplateRepositoryFactoryCreating TemplateRepositoryinstances
      • TemplateRepositoryFactoryBeanCore class, create an TemplateRepositoryFactoryinstance
      • AbstractTemplateRepository Abstract implementation of repo , easy to expand
      • SimpleTemplateRepositorySimple implementation TemplateRepository, supporting entity and string generics, string type Id
      • NumberKeyedRepositorySimple implementation TemplateRepository, Numbertype Id
      • UUIDTemplateRepositorySimple implementation TemplateRepository, UUIDtype Id
    • TemplateRepositoryTop repositoryinterfaces, all interfaces inherit the completion CRUDof repothe operation

  • util : some common tools corerelated to other related businessespackage

summary

SpringDataAnd can SpringBoot、SpringCloud、SpringFrameworkseamlessly integrate, develop their own SpringDataframework for ease of use and expand the system. This framework is just a template to help you understand and learn the underlying interface knowledge of SpringData.

spring-data-template's People

Contributors

hooj0 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.