spring-data-gremlin

所属分类:数据库系统
开发工具:Java
文件大小:19534KB
下载次数:0
上传日期:2021-10-14 07:43:43
上 传 者sh-1993
说明:  我们正在反对Spring Data Gremlin。——提供通用的面向注释的编程表单基础...
(We are in the process of deprecating Spring Data Gremlin. -- Provide generic annotation oriented programming form based on gremlin for graph database)

文件列表:
.travis.yml (811, 2021-10-14)
CODE_OF_CONDUCT.md (333, 2021-10-14)
CONTRIBUTING.md (1528, 2021-10-14)
DESIGN.md (5072, 2021-10-14)
LICENSE (1324, 2021-10-14)
PULL_REQUEST_TEMPLATE.md (321, 2021-10-14)
config (0, 2021-10-14)
config\checkstyle.xml (11538, 2021-10-14)
config\findbugs-exclude.xml (454, 2021-10-14)
config\gremlin-server-ci.properties (117, 2021-10-14)
config\gremlin-server-ci.yaml (874, 2021-10-14)
examples (0, 2021-10-14)
examples\LICENSE (1063, 2021-10-14)
examples\example (0, 2021-10-14)
examples\example\pom.xml (1016, 2021-10-14)
examples\example\src (0, 2021-10-14)
examples\example\src\main (0, 2021-10-14)
examples\example\src\main\java (0, 2021-10-14)
examples\example\src\main\java\example (0, 2021-10-14)
examples\example\src\main\java\example\springdata (0, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin (0, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\Application.java (3101, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\config (0, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\config\GremlinProperties.java (883, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\config\UserRepositoryConfiguration.java (1966, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\domain (0, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\domain\Network.java (659, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\domain\Person.java (1021, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\domain\Relation.java (1206, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\repository (0, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\repository\NetworkRepository.java (937, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\repository\PersonRepository.java (1031, 2021-10-14)
examples\example\src\main\java\example\springdata\gremlin\repository\RelationRepository.java (940, 2021-10-14)
examples\example\src\main\resources (0, 2021-10-14)
... ...

[![MIT License](http://img.shields.io/badge/license-MIT-green.svg) ](https://github.com/Microsoft/spring-data-gremlin/blob/master/LICENSE) [![Build Status](https://travis-ci.org/Microsoft/spring-data-gremlin.svg?branch=master)](https://travis-ci.org/Microsoft/spring-data-gremlin) [![codecov](https://codecov.io/gh/Microsoft/spring-data-gremlin/branch/master/graph/badge.svg)](https://codecov.io/gh/Microsoft/spring-data-gremlin) :exclamation::exclamation::exclamation: We have **deprecated** Spring Data Gremlin. We recommend that you use the TinkerPop driver to [query Cosmos DB with Gremlin API](https://docs.microsoft.com/en-us/azure/cosmos-db/create-graph-gremlin-console) or use [azure-spring-boot-starter-cosmos](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/spring/azure-spring-boot-starter-cosmos) to query Cosmos DB with Spring Data SQL API. If you would like us to continue supporting Spring Data Gremlin, please tell us how you are using Spring Data Gremlin for Cosmos DB and how important it is to you, by voting on this [issue](https://github.com/Azure/azure-sdk-for-java/issues/24773) with the thumbs up emoji. # Spring Data Gremlin **Spring Data Gremlin** provides initial Spring Data support for those databases using Gremlin query language. With annotation oriented programming model, it simplified the mapping to the database entity. It also provides supports for basic and custom query. This project works with *any Gremlin-compatible* data store, and also with [Azure Cosmos DB](https://docs.microsoft.com/en-us/azure/cosmos-db/introduction). Cosmos is a globally-distributed database service that allows developers to work with data using a variety of standard APIs, such as Graph, MongoDB, and SQL. Spring Data Gremlin provides a delightful experience to interact with Azure Cosmos DB Graph API. ## Spring Data Version Support Version mapping between spring boot and spring-data-gremlin: | Spring boot version | spring-data-gremlin version | |:-----------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | ![version](https://img.shields.io/badge/version-2.3.x-blue) | [![Maven Central](https://img.shields.io/maven-central/v/com.microsoft.spring.data.gremlin/spring-data-gremlin/2.3.svg)](https://search.maven.org/search?q=g:com.microsoft.spring.data.gremlin%20AND%20a:spring-data-gremlin%20AND%20v:2.3.*) | | ![version](https://img.shields.io/badge/version-2.2.x-blue) | [![Maven Central](https://img.shields.io/maven-central/v/com.microsoft.spring.data.gremlin/spring-data-gremlin/2.2.svg)](https://search.maven.org/search?q=g:com.microsoft.spring.data.gremlin%20AND%20a:spring-data-gremlin%20AND%20v:2.2.*) | | ![version](https://img.shields.io/badge/version-2.1.x-blue) | [![Maven Central](https://img.shields.io/maven-central/v/com.microsoft.spring.data.gremlin/spring-data-gremlin/2.1.svg)](https://search.maven.org/search?q=g:com.microsoft.spring.data.gremlin%20AND%20a:spring-data-gremlin%20AND%20v:2.1.*) | | ![version](https://img.shields.io/badge/version-2.0.x-blue) | [![Maven Central](https://img.shields.io/maven-central/v/com.microsoft.spring.data.gremlin/spring-data-gremlin/2.0.svg)](https://search.maven.org/search?q=g:com.microsoft.spring.data.gremlin%20AND%20a:spring-data-gremlin%20AND%20v:2.0.*) | ## TOC * [Welcome to Contribute](#welcome-to-contribute) * [Sample Code](#sample-code) * [Spring data version support](#spring-data-version-support) * [Feature List](#feature-list) * [Quick Start](#quick-start) * [Filing Issues](#filing-issues) * [Code of Conduct](#code-of-conduct) ## Welcome To Contribute Contribution is welcome. Please follow [this instruction](./CONTRIBUTING.md) to contribute code. ## Sample Code Please refer to [sample project here](./examples/example/). ## Spring data version support This repository only supports Spring Data 2.x. ## Feature List - Spring Data CRUDRepository basic CRUD functionality - save - findAll - findById - deleteAll - deleteById - Spring Data [@Id](https://github.com/spring-projects/spring-data-commons/blob/db62390de90c93a78743c97cc2cc9ccd9***994a5/src/main/java/org/springframework/data/annotation/Id.java) annotation. There're 2 ways to map a field in domain class to `id` field of a database entity. - annotate a field in domain class with `@Id` - set name of this field to `id` - Default annotaion - ```@Vertex``` maps an ```Object``` to a ```Vertex``` - ```@VertexSet``` maps a set of ```Vertex``` - ```@Edge``` maps an ```Object``` to an ```Edge``` - ```@EdgeSet``` maps to a set of ```Edge``` - ```@EdgeFrom``` maps to the head ```Vertex``` of an ```Edge``` - ```@EdgeTo``` maps to the tail ```Vertex``` of an ```Edge``` - ```@Graph``` maps to an ```Object``` to a ```Graph``` - Supports advanced operations - ``` T findVertexById(Object id, Class domainClass);``` - ``` T findEdgeById(Object id, Class domainClass);``` - ``` boolean isEmptyGraph(T object)``` - ```long vertexCount()``` - ```long edgeCount()``` - Supports [Spring Data custom query](https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.query-methods.details) find operation, e.g., `findByAFieldAndBField` - Supports any class type in domain class including collection and nested type. ## Quick Start ### Add the dependency `spring-data-gremlin` is published on Maven Central Repository. If you are using Maven, add the following dependency. ```xml com.microsoft.spring.data.gremlin spring-data-gremlin 2.1.7 ``` ### Setup Configuration Setup ```application.yml``` file.(Use Azure Cosmos DB Graph as an example.) ``` gremlin: endpoint: url-of-endpoint port: 443 username: /dbs/your-db-name/colls/your-collection-name password: your-password telemetryAllowed: true # set false to disable telemetry ``` ### Define an entity Define a simple Vertex entity with ```@Vertex```. ``` @Vertex public class Person { @Id private String id; private String name; private String age; ... } ``` Define a simple Edge entity with ```@Edge```. ``` @Edge public class Relation { @Id private String id; private String name; @EdgeFrom private Person personFrom; @EdgeTo private Person personTo; ... } ``` Define a simple Graph entity with ```@Graph```. ``` @Graph public class Network { @Id private String id; public Network() { this.edges = new ArrayList(); this.vertexes = new ArrayList(); } @EdgeSet private List edges; @VertexSet private List vertexes; ... } ``` ### Create repositories Extends DocumentDbRepository interface, which provides Spring Data repository support. ``` import GremlinRepository; import org.springframework.stereotype.Repository; @Repository public interface PersonRepository extends GremlinRepository { List findByName(String name); } ``` `findByName` method is custom query method, it will find the person with the ```name``` property. ### Create an Application class Here create an application class with all the components ``` @SpringBootApplication public class SampleApplication implements CommandLineRunner { @Autowired private PersonRepository repository; public static void main(String[] args) { SpringApplication.run(SampleApplication.class, args); } public void run(String... var1) throws Exception { private final Person testUser = new Person("PERSON_ID", "PERSON_NAME", "PERSON_AGE"); repository.deleteAll(); repository.save(testUser); ... } } ``` Autowired UserRepository interface, then can do save, delete and find operations. Spring Data Azure Cosmos DB uses the DocumentTemplate to execute the queries behind *find*, *save* methods. You can use the template yourself for more complex queries. ## Filing Issues If you encounter any bug, please file an issue [here](https://github.com/Microsoft/spring-data-gremlin/issues/new?template=custom.md). To suggest a new feature or changes that could be made, file an issue the same way you would for a bug. ## Code of Conduct This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. ## Data/Telemetry This project collects usage data and sends it to Microsoft to help improve our products and services. Read our [privacy](https://privacy.microsoft.com/en-us/privacystatement) statement to learn more.
近期下载者

相关文件


收藏者