{"id":18909364,"url":"https://github.com/geysermc/databaseutils","last_synced_at":"2026-03-06T23:30:19.681Z","repository":{"id":221873648,"uuid":"755596782","full_name":"GeyserMC/DatabaseUtils","owner":"GeyserMC","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-11T18:49:03.000Z","size":173,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-14T06:47:31.195Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GeyserMC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"geysermc","open_collective":"geysermc"}},"created_at":"2024-02-10T17:36:05.000Z","updated_at":"2024-02-14T08:18:32.000Z","dependencies_parsed_at":"2024-04-13T17:23:56.488Z","dependency_job_id":"d250dfe5-471a-4977-a40e-abe28919f257","html_url":"https://github.com/GeyserMC/DatabaseUtils","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"426216426477911f5c8ec13f9a1592a9e06bd434"},"previous_names":["geysermc/databaseutils"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeyserMC%2FDatabaseUtils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeyserMC%2FDatabaseUtils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeyserMC%2FDatabaseUtils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeyserMC%2FDatabaseUtils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeyserMC","download_url":"https://codeload.github.com/GeyserMC/DatabaseUtils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239896869,"owners_count":19715106,"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-08T09:32:57.611Z","updated_at":"2026-03-06T23:30:19.588Z","avatar_url":"https://github.com/GeyserMC.png","language":"Java","funding_links":["https://github.com/sponsors/geysermc","https://opencollective.com/geysermc"],"categories":[],"sub_categories":[],"readme":"DatabaseUtils is a library that allows you to write Repository interfaces that support both SQL and No-SQL (MongoDB) databases.\nThe implementation of the interface is automatically generated while compiling.\n\nThis readme will be expanded in the future with for example code examples,\ncurrently examples can be found in the tests of the AP module and the tests of the core module. \n\n# What's left to do?\n- make 'simple' actions like `insert` more flexible\n  - support adding every variable of the entity as parameter\n- add `upsert` which either inserts the entity if it's not present or updates the already existing entity\n- adding migrations\n- add null and non-null support\n- and plenty more\n\n# Supported types\nEvery database type is responsible for providing support for at least:\n- Boolean\n- Byte\n- Short\n- Char\n- Integer\n- Long\n- Float\n- Double\n- String\n- Byte[]\n\nUsing TypeCodecRegistry the supported types can be expanded (each of them will be stored as a byte[]).\nThe following types are added out of the box:\n- UUID\n\n# SQL\n\nThis project tries to support the following SQL dialects:\n\n- H2\n- (Microsoft) SQL Server\n- MariaDB\n- MySQL\n- Oracle Database\n- PostgreSQL\n- SQLite\n\nHowever not everything is the same across dialects.\n\n### Missing functionality for specific dialects\n\n#### TestEntity deleteByAAndB(String, String)\nThis currently doesn't work on MySQL (not MariaDB) and H2.\nThis is caused by the lack of support for 'REPLACING' or a variant of it.\nWe have to fetch a record first and then delete it (inside a transaction).\nThe current codebase is not flexible enough to do these wildly different behaviours per dialect, \nbut will be supported in the future.\n\n#### any deleteFirst() and any deleteTop*()\nAnything with a limit projection in delete currently doesn't work for Oracle Database, PostgreSQL, SQLite and SQL Server.\nFor SQL Server it's TOP instead of LIMIT.\nFor SQLite this is a flag that can be enabled during compile, but it's disabled by default.\nFor Oracle and Postgres delete with a limit doesn't exist.\nWe have to fetch a record first and then delete it (inside a transaction).\nThe current codebase is not flexible enough to do these wildly different behaviours per dialect,\nbut will be supported in the future.\n\n#### any delete*OrderBy*()\nAnything with an order by in delete currently doesn't work for Oracle Database, SQL Server, H2 and SQLite.\nFor SQLite this is a flag that can be enabled during compile, but it's disabled by default.\nFor the others this functionality doesn't exist.\nWe have to fetch a record first and then delete it (inside a transaction).\nThe current codebase is not flexible enough to do these wildly different behaviours per dialect,\nbut will be supported in the future.\n\n### Different data types across dialects\nNot every data type has the same name / is available on each dialect.\nThese are the base type conversions:\n\n| Java Type | SQL type         | Reason / remarks                                                |\n|-----------|------------------|-----------------------------------------------------------------|\n| Boolean   | boolean          | More platforms support boolean than tinyint / bit               |\n| Byte      | tinyint          | SQL Server's tinyint is unsigned and PostgresSQL has no tinyint |\n| Short     | smallint         | -                                                               |\n| Char      | int              | Unlike short, char is unsigned                                  |\n| Integer   | int              | -                                                               |\n| Long      | bigint           | -                                                               |\n| Float     | real             | MySQL and MariaDB map this as a double precision type           |\n| Double    | double precision | -                                                               |\n| String    | varchar          | All dialects support varchar, but it's deprecated on OracleDB   |\n| Byte[]    | varbinary        | Most dialects support varbinary                                 |\n\nAnd these are the exceptions:\n\n| Java Type | Dialect    | SQL Type          |\n|-----------|------------|-------------------|\n| Boolean   | SQLite     | int               |\n| Boolean   | SQL Server | bit               |\n| Byte      | PostgreSQL | smallint          |\n| Byte      | SQL Server | smallint          |\n| Char      | MariaDB    | smallint unsigned |\n| Char      | MySQL      | smallint unsigned |\n| Char      | OracleDB   | number(5)         |\n| Double    | SQL Server | float             |\n| String    | OracleDB   | varchar2          |\n| Byte[]    | OracleDB   | raw               |\n| Byte[]    | PostgreSQL | bytea             |\n| Byte[]    | SQLite     | blob              |\n\n# Query syntax\nAssuming we have the following entity called TestEntity:\n\n| Name | Type   | Is Key? | \n|------|--------|---------|\n| a    | int    | Yes     |\n| b    | String | Yes     |\n| c    | String | No      |\n| d    | UUID   | No      |\n\n## delete\n\n#### int/boolean delete(TestEntity) - delete single entity\nIf you delete a single entity, it'll look at the \n\n### TestEntity deleteByAAndB(a, b) - delete by key\nIf you delete by the key then you know for certain that there can at most be only one match.\n\n### List\u003cTestEntity\u003e deleteByB(b) - delete by a non-unique column\nIf you delete by a non-unique column everything matching that column is deleted.\nNote that for the returning collection that not every database type has a defined order. \n\n### TestEntity deleteFirstByB(b) - delete by a non-unique column\nIf you delete by a non-unique column you have to specify first if your return type is a single row.\nOnly use this if any match is fine, because not every database type has a defined order.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeysermc%2Fdatabaseutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeysermc%2Fdatabaseutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeysermc%2Fdatabaseutils/lists"}