{"id":21346929,"url":"https://github.com/queer/async-postgres-jsonb-orm","last_synced_at":"2026-02-28T18:01:48.469Z","repository":{"id":94882109,"uuid":"128881908","full_name":"queer/async-postgres-jsonb-orm","owner":"queer","description":"A simple, a/sync JSONB ORM for Postgres, written in Java. ","archived":false,"fork":false,"pushed_at":"2019-03-23T15:08:28.000Z","size":26,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-22T11:14:15.788Z","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/queer.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-10T06:05:51.000Z","updated_at":"2021-02-15T16:51:13.000Z","dependencies_parsed_at":"2023-03-23T15:06:07.607Z","dependency_job_id":null,"html_url":"https://github.com/queer/async-postgres-jsonb-orm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/queer/async-postgres-jsonb-orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queer%2Fasync-postgres-jsonb-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queer%2Fasync-postgres-jsonb-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queer%2Fasync-postgres-jsonb-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queer%2Fasync-postgres-jsonb-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/queer","download_url":"https://codeload.github.com/queer/async-postgres-jsonb-orm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queer%2Fasync-postgres-jsonb-orm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29946463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T17:57:52.716Z","status":"ssl_error","status_checked_at":"2026-02-28T17:57:31.974Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-22T02:12:03.172Z","updated_at":"2026-02-28T18:01:48.448Z","avatar_url":"https://github.com/queer.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A/Sync Postgres JSONB ORM\n\nA super-simple ORM for Postgres / JSONB, using HikariCP underneath. Supports both sync / async usage. \n\nNote: I make no guarantees about it being perfectly thread-safe or anything. Use at your own risk.\n\nThis library will automatically create tables and indexes for you based off of the values of the entity class annotations. \nThis may have performance implications, so it's probably a good idea to do initial class mapping once at the start of your \napplication to get that out of the way. \n\n## Building\n\nJust run `mvn clean package`.\n\nTo run the tests, set the following environment variables:\n```\nPOSTGRES_URL=\"jdbc:postgresql://localhost/test\"\nPOSTGRES_USERNAME=\"test\"\nPOSTGRES_PASSWORD=\"abc123\"\n```\nand then run `mvn test`.\n\n## Usage\n\nGet it on JitPack: https://jitpack.io/#queer/async-postgres-jsonb-orm\n\nExample code:\n```Java\n// A class you could save / load\n@Table(\"data_table\") // Save/load with a table named `data_table`\n@Index({\"name\", \"something\"}) // Index on the JSONB fields `name` and `something`\npublic class Data {\n    // This field will be the primary key, and will be stored in the DB as a column named \"id\"  \n    @PrimaryKey(\"id\")\n    private String primaryKey;\n    \n    private String name;\n    private String something;\n    private long someNumber;\n    \n    public Data(String primaryKey, String name, String something, String someNumber) {\n        this.primaryKey = primaryKey;\n        this.name = name;\n        this.something = something;\n        this.someNumber = someNumber;\n    }\n}\n\npublic class Example {\n    // Make a data store\n    public void makeStore() {\n        // Pass a JDBC URL / username / password\n        PgStore store = new PgStore(\"jdbc:postgresql://localhost/test\", \"test\", \"abc123\");\n        // Or pass your own HikariConfig instance\n        final HikariConfig config = new HikariConfig();\n        config.setJdbcUrl(\"jdbc:postgresql://localhost:test\");\n        config.setUsername(\"test\");\n        config.setPassword(\"abc123\");\n        PgStore store = new PgStore(config);\n        // Or configure it from the environment, by setting the following env vars:\n        // - POSTGRES_URL=\"jdbc:postgresql://localhost/test\"\n        // - POSTGRES_USERNAME=\"test\"\n        // - POSTGRES_PASSWORD=\"abc123\"\n        PgStore store = PgStore.fromEnv();\n    }\n    \n    // Save and load some data\n    public void saveLoad() {\n        PgStore store = PgStore.fromEnv();\n        Data data = new Data(\"spooky id\", \"some name\", \"potato\", 1234L);\n        // Save the data synchronously\n        store.mapSync(Data.class).save(data);\n        // Load the data synchronously\n        Optional\u003cData\u003e result = store.mapSync(Data.class).load(\"spooky id\");\n        if(result.isPresent()) {\n            // Yay we have it\n        } else {\n            // We don't have it and that's lame\n        }\n    }\n    \n    // Save and load some data but async this time\n    public void saveLoadAsync() {\n        PgStore store = PgStore.fromEnv();\n        Data data = new Data(\"spooky id\", \"some name\", \"potato\", 1234L);\n        // Save the data asynchronously\n        Future\u003cVoid\u003e saveFuture = store.mapAsync(Data.class).save(data);\n        saveFuture.get(); // Wait for it to finish\n        // Load the data asynchronously\n        Future\u003cOptional\u003cData\u003e\u003e loadFuture = store.mapAsync(Data.class).load(\"spooky id\");\n        Optional\u003cData\u003e result = loadFuture.get(); // Wait for it to finish\n        if(result.isPresent()) {\n            // Yay we have it\n        } else {\n            // We don't have it and that's lame\n        }\n    }\n}\n```\n\n## Things to remember\n\n- You can choose index type with `@BtreeIndex` vs `@GIndex`. The latter is GIN indexing.\n\n- The `AsyncPgMapper` uses `Executors.newCachedThreadPool()` by default. In the future, there might be a way to set an \n  alternative.\n\n- Data is mapped to/from JSON using Jackson. Make sure your entity classes work correctly with Jackson.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueer%2Fasync-postgres-jsonb-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqueer%2Fasync-postgres-jsonb-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueer%2Fasync-postgres-jsonb-orm/lists"}