{"id":25229946,"url":"https://github.com/sproket/persism","last_synced_at":"2025-04-05T17:02:53.413Z","repository":{"id":41425953,"uuid":"333581202","full_name":"sproket/Persism","owner":"sproket","description":"A zero ceremony ORM for Java","archived":false,"fork":false,"pushed_at":"2025-03-29T11:18:50.000Z","size":127129,"stargazers_count":140,"open_issues_count":10,"forks_count":5,"subscribers_count":5,"default_branch":"persism2","last_synced_at":"2025-04-05T17:01:53.904Z","etag":null,"topics":["database","java","mysql","orm-framework","postgresql","sql"],"latest_commit_sha":null,"homepage":"https://sproket.github.io/Persism/","language":"TSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sproket.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","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":"2021-01-27T22:48:18.000Z","updated_at":"2025-03-29T11:18:54.000Z","dependencies_parsed_at":"2025-03-29T12:32:00.166Z","dependency_job_id":null,"html_url":"https://github.com/sproket/Persism","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sproket%2FPersism","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sproket%2FPersism/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sproket%2FPersism/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sproket%2FPersism/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sproket","download_url":"https://codeload.github.com/sproket/Persism/tar.gz/refs/heads/persism2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369954,"owners_count":20927928,"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":["database","java","mysql","orm-framework","postgresql","sql"],"created_at":"2025-02-11T11:37:51.947Z","updated_at":"2025-04-05T17:02:53.390Z","avatar_url":"https://github.com/sproket.png","language":"TSQL","readme":"![](logo1.png) [Release notes 2.2.0](release-notes.md) -- [Getting Started Guide](https://sproket.github.io/Persism/manual2.html)\n\n[Table joins are now supported!](https://sproket.github.io/Persism/join.html)\n\n# Welcome\n\nPersism is a light weight, auto discovery, autoconfiguration, and convention\nover configuration ORM (Object Relational Mapping) library for Java 17 or later.\n\nFor Java 8 or later see the 1.x branch https://github.com/sproket/Persism/tree/persism1\n\n```xml \n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.sproket\u003c/groupId\u003e\n    \u003cartifactId\u003epersism\u003c/artifactId\u003e\n    \u003cversion\u003e2.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n```Java \nimport static net.sf.persism.Parameters.*;\nimport static net.sf.persism.SQL.*;\n\nConnection con = DriverManager.getConnection(url, username, password);\n\n// Instantiate a Persism session object with the connection\nSession session = new Session(con);\n\nList\u003cCustomer\u003e list = session.query(Customer.class, sql(\"select * from Customers where CUST_NAME = ?\"), params(\"Fred\"));\n// or\nList\u003cCustomer\u003e list = session.query(Customer.class, proc(\"sp_FindCustomers(?)\"), params(\"Fred\"));\n\nCustomer customer;\ncustomer = session.fetch(Customer.class, sql(\"select * from Customers where CUST_NAME = ?\"), params(\"Fred\"));\n// or   \ncustomer = session.fetch(Customer.class, proc(\"sp_FindCustomer(?)\"), params(\"Fred\"));\nif (customer != null) {\n    // etc...\n}\n\n// You don't need the SELECT parts for Views or Tables\nList\u003cCustomer\u003e list = session.query(Customer.class, where(\"CUST_NAME = ?\"), params(\"Fred\"));\n\n// You can reference the property names instead of the column names - just use :propertyName \nList\u003cCustomer\u003e list = session.query(Customer.class, where(\":name = ?\"), params(\"Fred\"));\n\n// Order by is also supported with where() method\nList\u003cCustomer\u003e list = session.query(Customer.class, where(\":name = ? ORDER BY :lastUpdated\"), params(\"Fred\"));\n\n// Named parameters are also supported - just use @name\nSQL sql = where(\"(:firstname = @name OR :company = @name) and :lastname = @last\");\ncustomer = session.fetch(Customer.class, sql, params(Map.of(\"name\", \"Fred\", \"last\", \"Flintstone\")));\n\n// fetch an existing instance\nCustomer customer = new Customer();\ncustomer.setCustomerId(123);\nif (session.fetch(customer)) {\n    // customer found and initialized\n} \n\n// Supports basic types\nString result = session.fetch(String.class, sql(\"select Name from Customers where ID = ?\"), params(10));\n\n// Fetch a count as an int - Enums are supported \nint count = session.fetch(int.class, sql(\"select count(*) from Customers where Region = ?\"), params(Region.West));\n\n// Insert - get autoinc\nCustomer customer = new Customer();\ncustomer.setCustomerName(\"Fred\");\ncustomer.setAddress(\"123 Sesame Street\");\n\nsession.insert(customer); \n\n// Inserted and new autoinc value assigned \nassert customer.getCustomerId() \u003e 0\n\n// Update\ncustomer.setCustomerName(\"Barney\");\nsesion.update(customer); // Update Customer   \n\n// Delete\nsession.delete(customer);\n\n// Handles transactions\nsession.withTransaction(() -\u003e {\n    Contact contact = getContactFromSomewhere();\n    contact.setIdentity(randomUUID);\n    session.insert(contact);\n    \n    contact.setContactName(\"Wilma Flintstone\");\n    \n    session.update(contact);\n    session.fetch(contact);\n});\n```\n \n\n## Simple\n\nThe API for Persism is small. Mostly you just need a Connection and a Persism Session object, and you're good to go.\nYour POJOs can have optional annotations for table and column names and can optionally implement a Persistable interface\nfor where you need to track changes to properties for UPDATE statements.\n\n## Auto-Discovery\nCreate a table, write a JavaBean, run a query. Persism uses simple mapping rules to\nfind your table and column names and only requires an annotation where\nsomething is outside convention. \n\n## Convention over configuration\nPersism requires no special configuration. Drop the JAR into your project and go.\n\nPersism has annotations though they are only needed where something is outside the conventions. In most cases\nyou probably don't even need them.\n\nPersism can usually detect the table and column mappings for you including primary/generated keys and columns\nwith defaults.\n\n## Supports most common databases\nDerby, Firebird, H2, HSQLDB, Informix, MSAccess, MSSQL, MySQL/MariaDB, Oracle (12+), PostgreSQL, SQLite.\n\n## Smart\nPersism will do the correct thing by default. Persism understands that your class is called Customer and your table\nis called CUSTOMERS. It understands that your table column is CUSTOMER_ID and your property is customerId.\n\nPersism understands when your class is called Category and your table is called CATEGORIES.\nNo problem. No need to annotate for that. Persism uses annotations as a fall back – annotate only when\nsomething is outside the conventions.\n\n## Tiny\nPersism is about 100k and has zero dependencies however it will\nutilize logging based on whatever is available at runtime - SLF4J, LOG4J2, LOG4J or JUL.\n\n[Have a look here for the getting started guide, code coverage and Javadoc](https://sproket.github.io/Persism/)\n\n## Compile\n\nTo run tests for in memory databases H2, HSQLDB, Derby and SQLite\n\n    mvn clean test\n\nTo run basic tests + testContainers based tests (postgresql, mysql, mariadb, firebird). Need docker installed.\n\n    mvn clean test -P include-test-containers-db\n\nTo run tests for every supported database. Needs Oracle up and running\n\n    mvn clean test -P all-db\n\nTo generate surefire reports with every database but Oracle  (in target/site/surefire-report.html)\n\n    mvn clean test surefire-report:report -P include-test-containers-db\n\nThanks!\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsproket%2Fpersism","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsproket%2Fpersism","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsproket%2Fpersism/lists"}