{"id":19044767,"url":"https://github.com/yugabyte/spring-data-yugabytedb","last_synced_at":"2025-06-11T16:06:36.294Z","repository":{"id":48120384,"uuid":"189627463","full_name":"yugabyte/spring-data-yugabytedb","owner":"yugabyte","description":"Spring Data Module for YugabyteDB.","archived":false,"fork":false,"pushed_at":"2021-08-30T11:10:46.000Z","size":638,"stargazers_count":18,"open_issues_count":2,"forks_count":6,"subscribers_count":81,"default_branch":"sdyb-main","last_synced_at":"2025-04-23T23:38:55.446Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yugabyte.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-31T16:41:50.000Z","updated_at":"2024-06-29T16:01:40.000Z","dependencies_parsed_at":"2022-07-25T23:02:53.874Z","dependency_job_id":null,"html_url":"https://github.com/yugabyte/spring-data-yugabytedb","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/yugabyte/spring-data-yugabytedb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugabyte%2Fspring-data-yugabytedb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugabyte%2Fspring-data-yugabytedb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugabyte%2Fspring-data-yugabytedb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugabyte%2Fspring-data-yugabytedb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yugabyte","download_url":"https://codeload.github.com/yugabyte/spring-data-yugabytedb/tar.gz/refs/heads/sdyb-main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugabyte%2Fspring-data-yugabytedb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259293110,"owners_count":22835540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T22:47:24.683Z","updated_at":"2025-06-11T16:06:36.273Z","avatar_url":"https://github.com/yugabyte.png","language":"Java","funding_links":[],"categories":["\u003ca name=\"Java\"\u003e\u003c/a\u003eJava"],"sub_categories":[],"readme":"= Spring Data YugabyteDB\n\nSpring Data YugabyteDB brings the power of Distributed SQL to Spring developers by using the familar Spring Data paradigms, Spring Data YugabyteDB supports Spring template and Spring repositories for accessing the data from YugabyteDB. Spring Data YuabyteDB is based on the [Spring Data JDBC](https://github.com/spring-projects/spring-data-jdbc) project which is extended to support YugabyteDB distributed SQL features.\n\nYugabyteDB is a high-performance, cloud-native distributed SQL database that aims to support all PostgreSQL features. It is best to fit for cloud-native OLTP (i.e. real-time, business-critical) applications that need absolute data correctness and require at least one of the following: scalability, high tolerance to failures, or globally-distributed deployments.\n\n== Features\n\nIn addition to providing most PostgreSQL features supported by Spring Data JDBC, this project aims to enable the following:\n\n* CRUD operations for YugabyteDB\n* `@EnableYsqlRepositories` annotation to enable `YsqlRepository`\n* Yugabyte Distributed SQL transaction manager\n* Support for Follower Reads\n* Eliminate Load Balancer from SQL (cluster-awareness)\n* Develop Geo-Distributed Apps (topology-awareness)\n* Row Level Geo-partitioning support (partition-awareness)\n\n=== Getting Started\n\nA quick start example of getting started with Spring Data YugabyteDB in JAVA:\n\n[source, java]\n----\npublic interface ShoppingCartRepository extends YsqlRepository\u003cShoppingCart, String\u003e {\n\n  ShoppingCart findById(String id);\n\n  List\u003cShoppingCart\u003e findByUserId(String userId);\n\n}\n\n@Service\npublic class CartService {\n\n  private final ShoppingCartRepository repository;\n\n  public CartService(CartService repository) {\n    this.repository = repository;\n  }\n\n  public void doWork() {\n\n    repository.deleteAll();\n\n    ShoppingCart myShoppingCart = new ShoppingCart();\n    myShoppingCart.set(\"cart1\")\n    myShoppingCart.setUserId(\"u1001\");\n    myShoppingCart.setProductId(\"asin1001\");\n    myShoppingCart.setQuantity(1);\n    \n    repository.save(myShoppingCart);\n\n    ShoppingCart savedCart = repository.findById(\"cart1\");\n    List\u003cShoppingCart\u003e productsInCart = repository.findByUserId(\"u1001\");\n  }\n}\n\n@Configuration\n@EnableYsqlRepositories\npublic class YsqlConfig extends AbstractYugabyteJdbcConfiguration {\n\n\t@Bean\n\tDataSource dataSource() {\n\t\t\n\t  String hostName = \"127.0.0.1\";\n\t  String port = \"5433\";\n\n\t  Properties poolProperties = new Properties();\n\t  poolProperties.setProperty(\"dataSourceClassName\", \"com.yugabyte.ysql.YBClusterAwareDataSource\");\n\t  poolProperties.setProperty(\"dataSource.serverName\", hostName);\n\t  poolProperties.setProperty(\"dataSource.portNumber\", port);\n\t  poolProperties.setProperty(\"dataSource.user\", \"yugabyte\");\n\t  poolProperties.setProperty(\"dataSource.password\", \"\");\n\t  poolProperties.setProperty(\"dataSource.loadBalance\", \"true\");\n\t  poolProperties.setProperty(\"dataSource.additionalEndpoints\",\n\t\t    \"127.0.0.2:5433,127.0.0.3:5433\");\n\n\t  HikariConfig hikariConfig = new HikariConfig(poolProperties);\n\t  DataSource ybClusterAwareDataSource = new HikariDataSource(hikariConfig);\n\t  return ybClusterAwareDataSource;\n\t}\n\n  @Bean\n  JdbcTemplate jdbcTemplate(@Autowired DataSource dataSource) {\n\n    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);\n    return jdbcTemplate;\n  }\n  \n  @Bean\n  NamedParameterJdbcOperations namedParameterJdbcOperations(DataSource dataSource) { \n    return new NamedParameterJdbcTemplate(dataSource);\n  }\n\n\t@Bean\n\tTransactionManager transactionManager(DataSource dataSource) {                     \n\t  return new YugabyteTransactionManager(dataSource);\n\t}\n\n}\n----\n\n=== Maven configuration\n\nAdd the Maven dependency:\n\n[source,xml]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.yugabyte\u003c/groupId\u003e\n  \u003cartifactId\u003espring-data-yugabytedb-ysql\u003c/artifactId\u003e\n  \u003cversion\u003e2.3.0\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.yugabyte\u003c/groupId\u003e\n  \u003cartifactId\u003ejdbc-yugabytedb\u003c/artifactId\u003e\n  \u003cversion\u003e42.2.7-yb-5.beta.5\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\nSee also the https://github.com/yugabyte/spring-data-yugabytedb-example[spring-data-yugabytedb-example] app.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugabyte%2Fspring-data-yugabytedb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyugabyte%2Fspring-data-yugabytedb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugabyte%2Fspring-data-yugabytedb/lists"}