Skip to content

Instantly share code, notes, and snippets.

View abdelghanyMh's full-sized avatar
🕵️
On the hunt for a new gig!

Mahammedi Abdelghani abdelghanyMh

🕵️
On the hunt for a new gig!
View GitHub Profile

Understanding Your Spring Boot Hibernate Spatial Solution

I'm glad the solution worked! Let's break down what happened and why it worked, which will help you understand the entire Spring Boot + Hibernate Spatial + GeoJSON + PostGIS stack better.

The Problem

You were experiencing an issue where your Point geometry field (cityCoordinates) wasn't being serialized correctly to JSON. Instead of getting a proper GeoJSON Point representation, you were getting a deeply nested structure with repeated "envelope" objects:

"cityCoordinates": {

Description:

A summary table of HTTP methods (POST, PUT, PATCH) and their roles in CRUD operations, tailored for the Cash Card API. The table clarifies which methods are implemented (bold rows) and their behavior, including URI definitions, response codes, and response bodies. Non-bold rows indicate features not supported by the Cash Card API.

HTTP Method Operation Definition of Resource URI What Does It Do? Response Status Code Response Body
POST Create Server generates and returns the URI Creates a sub-resource under the request URI (e.g., /cashcards/101) 201 CREATED The created resource
PUT Create Client supplies the URI Creates a resource at the exact request URI (e.g., /invoices/1234-567) 201 CREATED The created resource
PUT Update Client supplies the URI Replaces the **

Resources and Sub-Resources

Let’s clarify the distinction between POST and PUT in the context of resources and sub-resources, using the Cash Card and Invoice APIs as examples:


Key Idea: Resources vs. Sub-Resources

  • A resource is any entity your API manages (e.g., a Cash Card or Invoice).
  • A sub-resource is a child entity nested under a parent resource (e.g., a specific Cash Card under the /cashcards collection).

Surrogate and Natural Keys

Key Concepts:

  1. Natural Key: An identifier provided by the client (e.g., an invoice number like 1234-567).
  2. Surrogate Key: An identifier generated by the server (e.g., a database auto-incremented ID like 101).
  3. HTTP Verbs:
    • POST: Used when the server determines the resource’s URI (uses surrogate keys).
    • PUT: Used when the client determines the resource’s URI (uses natural keys).
@abdelghanyMh
abdelghanyMh / tips.md
Created November 1, 2024 22:08
jetbrains JavaScript Best Practices 2024
:root {
--transition: 0.3s ease-in-out all
--text-font-stack: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif
--shadow-1: 0px 0px 0px 3px var(--colors-blue-50);
--border-radius: 4px;
--ring-color: rgba(66, 153, 225, 0.6);
--colors-transparent: transparent;
--colors-current: currentColor;
--colors-black: #000000;
--colors-white: #ffffff;
@abdelghanyMh
abdelghanyMh / algeria_map_2019_present.svg
Last active July 11, 2022 14:59
Blank administrative map of Algeria ( 2019-Present)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abdelghanyMh
abdelghanyMh / index.html
Created June 22, 2022 22:43
magnetic button vanilla js
<div class='container' onmousemove='MagneticBtn(event)'>
<button class='btn'>hello</button>
</div>
@abdelghanyMh
abdelghanyMh / dark_light.py
Created July 20, 2021 15:38
switch between dark mode and light mode in Linux mint cinnamon
#!/usr/bin/python3
import sys
from gi.repository import Gio
import time
# for light theme ./dark_light.py light
# for dark theme ./dark_light.py dark
# if no theme has been specified scripte will stop
if len(sys.argv) == 1: