{"id":15091337,"url":"https://github.com/deepakbhalla/springboot-postgres-jsonb-jpa","last_synced_at":"2026-03-04T16:31:24.661Z","repository":{"id":201966710,"uuid":"704453985","full_name":"deepakbhalla/springboot-postgres-jsonb-jpa","owner":"deepakbhalla","description":"Spring boot application to demonstrate the JSONB data type to be used in Postgre SQL database using Springboot JPA.","archived":false,"fork":false,"pushed_at":"2023-10-26T18:28:14.000Z","size":1343,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T07:14:29.553Z","etag":null,"topics":["account-management","crud-application","jpa","json","jsonb","lombok","openapi","openapi-specification","openapi3","performance","postgresql","restapi","spring-boot","spring-data-jpa","springboot","springboot-web","swagger"],"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/deepakbhalla.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":"2023-10-13T09:40:28.000Z","updated_at":"2025-01-13T23:12:28.000Z","dependencies_parsed_at":"2024-09-19T18:40:47.173Z","dependency_job_id":null,"html_url":"https://github.com/deepakbhalla/springboot-postgres-jsonb-jpa","commit_stats":null,"previous_names":["deepakbhalla/springboot-postgres-jsonb-jpa"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/deepakbhalla/springboot-postgres-jsonb-jpa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepakbhalla%2Fspringboot-postgres-jsonb-jpa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepakbhalla%2Fspringboot-postgres-jsonb-jpa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepakbhalla%2Fspringboot-postgres-jsonb-jpa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepakbhalla%2Fspringboot-postgres-jsonb-jpa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepakbhalla","download_url":"https://codeload.github.com/deepakbhalla/springboot-postgres-jsonb-jpa/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepakbhalla%2Fspringboot-postgres-jsonb-jpa/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30086451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T15:40:14.053Z","status":"ssl_error","status_checked_at":"2026-03-04T15:40:13.655Z","response_time":59,"last_error":"SSL_read: 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":["account-management","crud-application","jpa","json","jsonb","lombok","openapi","openapi-specification","openapi3","performance","postgresql","restapi","spring-boot","spring-data-jpa","springboot","springboot-web","swagger"],"created_at":"2024-09-25T10:40:28.758Z","updated_at":"2026-03-04T16:31:24.609Z","avatar_url":"https://github.com/deepakbhalla.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# springboot-postgres-jsonb-jpa\nApplication to demonstrate the JSONB data type used in PostgreSQL database using Springboot JPA implementation.\n\n### JSON Data Types\n\nJSON data types are for storing JSON (JavaScript Object Notation) data. Such data can also be stored as text, but the \nJSON data types have the advantage of enforcing that each stored value is valid according to the JSON rules. There are \nalso assorted JSON-specific functions and operators available for data stored in these data types.\n\nPostgreSQL offers two types for storing JSON data: \n\n- JSON \n- JSONB. \n\nTo implement efficient query mechanisms for these \ndata types, PostgreSQL also provides the jsonpath data type.\n\nThe json and jsonb data types accept almost identical sets of values as input. The major practical difference is one \nof efficiency. The json data type stores an exact copy of the input text, which processing functions must reparse on \neach execution; while jsonb data is stored in a decomposed binary format that makes it slightly slower to input due to \nadded conversion overhead, but significantly faster to process, since no reparsing is needed. jsonb also supports \nindexing, which can be a significant advantage.\n\nBecause the json type stores an exact copy of the input text, it will preserve semantically-insignificant white space \nbetween tokens, as well as the order of keys within JSON objects. Also, if a JSON object within the value contains the \nsame key more than once, all the key/value pairs are kept. (The processing functions consider the last value as the \noperative one.) By contrast, jsonb does not preserve white space, does not preserve the order of object keys, and does \nnot keep duplicate object keys. If duplicate keys are specified in the input, only the last value is kept.\n\nIn general, most applications should prefer to store JSON data as jsonb, unless there are quite specialized needs, such \nas legacy assumptions about ordering of object keys.\n\nJSONB is a \"better\" version of JSON.\n\nLet's look at an example:\n\n- JSON\n\n![img.png](screenshots/19_json_data_type_example.png)\n\n- JSONB\n\n![img.png](screenshots/20_jsonb_data_type_example.png)\n\nIn summary,\n\n1. JSON stores white space, and that is why we can see spaces when key \"a\" is stored, while JSONB does not.\n2. JSON stores all the values of a key. This is the reason you can see multiple values (2 and 1) against the key \"a\", while JSONB only \"stores\" the last value.\n3. JSON maintains the order in which elements are inserted, while JSONB maintains the \"sorted\" order.\n4. JSONB objects are stored as a decompressed binary as opposed to \"raw data\" in JSON, where no reparsing of data is required during retrieval.\n5. JSONB also supports indexing, which can be a significant advantage.\n\n### JSON Functions and Operators\n\nThis section describes:\n\n- functions and operators for processing and creating JSON data\n- the SQL/JSON path language\n\nTo provide native support for JSON data types within the SQL environment, PostgreSQL implements the SQL/JSON data model. \nThis model comprises sequences of items. Each item can hold SQL scalar values, with an additional SQL/JSON null value, \nand composite data structures that use JSON arrays and objects. The model is a formalization of the implied data model \nin the JSON specification.\n\nSQL/JSON allows you to handle JSON data alongside regular SQL data, with transaction support, including:\n\n- Uploading JSON data into the database and storing it in regular SQL columns as character or binary strings.\n- Generating JSON objects and arrays from relational data.\n- Querying JSON data using SQL/JSON query functions and SQL/JSON path language expressions.\n\n### OpenAPI Specification\n\nhttp://localhost:9091/my-application/swagger-ui/index.html\n\n![img.png](screenshots/21_openapi_swagger_specifications.png)\n\n### Disable OpenAPI Swagger for Production Environment\n\nWe can disable OpenAPI swagger for any environment based upon profiles. We can supply a VM argument \n'-Dspring.profiles.active=\u003cenvironment name\u003e' to the application configurations.\nUsing spring profile annotation @Profile(\"prod\"), we can control the display of swagger.\n\n- VM Argument\n\n![img.png](screenshots/22_vm_argument_spring_active_profile.png)\n\nIf the value of spring profile is 'prod', then swagger won't be available. Please refer the below screenshot:\n\n![img.png](screenshots/23_swagger_not_available.png)\n\nReferences:\n\n- https://www.postgresql.org/docs/current/datatype-json.html\n- https://www.postgresql.org/docs/current/functions-json.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepakbhalla%2Fspringboot-postgres-jsonb-jpa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepakbhalla%2Fspringboot-postgres-jsonb-jpa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepakbhalla%2Fspringboot-postgres-jsonb-jpa/lists"}