| Ko

Spring Data JPA vs JPA

JPA is the standard API. Spring Data JPA is a code-generation layer on top of it: you declare an interface, it generates the implementation, and that implementation calls the EntityManager underneath. Writing the same operation both ways makes the boundary clear. JPA The center of JPA is the persistence context and the EntityManager that manages it. The persistence context is a logical space that holds entities and provides the first-level cache, dirty checking, lazy loading, and write-behind. In plain JPA, you hold the EntityManager and open and close the transaction yourself. ...

June 7, 2024 · 5 min · 853 words · In-Jun

Spring interceptors

What sets an interceptor apart from a filter is position. An interceptor runs inside the DispatcherServlet, after handler mapping has decided which controller handles the request. So an interceptor already knows which handler is about to run. It intercepts that execution at three points (before the controller, after the controller, after view rendering), and at the first point it can block the request entirely. The three hooks HandlerInterceptor provides three methods, each intercepting a different moment. ...

June 4, 2024 · 4 min · 831 words · In-Jun

Servlet filters

A filter is the first thing to touch a request. There’s no DispatcherServlet, no controller, no Spring bean yet, because a filter runs at the servlet container (Tomcat and friends) level. That position defines what a filter is for, and it explains why CORS handling and security token validation live in filters rather than interceptors. Servlet A Java server-side component that processes client HTTP requests and generates responses. It’s a core technology of the Java EE (now Jakarta EE) standard and the foundation of most Java web frameworks. ...

June 4, 2024 · 5 min · 916 words · In-Jun
[email protected]