<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hamza Salih-Eddine</title>
    <description>The latest articles on DEV Community by Hamza Salih-Eddine (@xhozey).</description>
    <link>https://dev.to/xhozey</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1770891%2F6e5e9f15-46bc-4bd3-93c1-d1b48513ba25.png</url>
      <title>DEV Community: Hamza Salih-Eddine</title>
      <link>https://dev.to/xhozey</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xhozey"/>
    <language>en</language>
    <item>
      <title>Understanding Common Spring Boot, Spring Security, and JPA Annotations</title>
      <dc:creator>Hamza Salih-Eddine</dc:creator>
      <pubDate>Sat, 13 Dec 2025 15:27:29 +0000</pubDate>
      <link>https://dev.to/xhozey/understanding-common-spring-boot-spring-security-and-jpa-annotations-5h0c</link>
      <guid>https://dev.to/xhozey/understanding-common-spring-boot-spring-security-and-jpa-annotations-5h0c</guid>
      <description>&lt;p&gt;Recently, I started developing a full-stack web application using Spring Boot for the backend and Angular for the frontend. You can check out the project on my &lt;a href="https://github.com/xHozey/01Blog" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt; to see it in action.&lt;/p&gt;

&lt;p&gt;While building the app, I realized how much Spring Boot and its ecosystem simplify development with annotations. Since there are so many annotations, I won’t cover all of them. Instead, I’ll focus on the commonly used ones, explaining their purpose and why they’re useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spring Boot Core Annotations
&lt;/h2&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@SpringBootApplication&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Marks the main class of a Spring Boot application. It combines @Configuration, @EnableAutoConfiguration, and @ComponentScan to simplify setup.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Configuration&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Marks a class as a source of Spring bean definitions. Methods annotated with Bean inside it define beans managed by the Spring context.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Bean&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Declares a bean method whose return value is managed by Spring. Commonly used for third-party library classes since you cannot annotate external classes with @Component.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Component&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Marks a class as a Spring-managed component that can be automatically detected via classpath scanning.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Service&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;A specialized @Component for service-layer classes. It indicates that the class contains business logic. While it does not enforce a singleton by itself, Spring by default manages beans as singletons, ensuring a single instance per application context.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@RestController&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Combines @Controller and @ResponseBody to automatically serialize/deserialize JSON request and response bodies. Used for building REST APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spring Security Annotation
&lt;/h2&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@EnableWebSecurity&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Enables Spring Security in the application and allows customizing authentication and authorization rules. Typically used in a configuration class that defines a SecurityFilterChain bean.&lt;/p&gt;

&lt;h2&gt;
  
  
  JPA / Hibernate Annotations
&lt;/h2&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Entity&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Marks a class as a database entity. Hibernate detects it at bootstrap and maps it to a database table.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Table(name = "comment")&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Specifies the database table name for the entity. If omitted, the table name defaults to the entity class name.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Id&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Marks the primary key field of the entity.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@GeneratedValue&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Configures automatic generation of primary key values using strategies like IDENTITY or SEQUENCE.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@CreationTimestamp&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Automatically sets the timestamp when the entity is first persisted.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@ManyToOne&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Defines a many-to-one relationship between entities.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@OneToMany&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Defines a one-to-many relationship. Typically paired with mappedBy to indicate the owning side.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@ManyToMany&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Defines a many-to-many relationship between entities, often with a join table.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@JoinColumn&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Specifies the foreign key column used in a relationship.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Transactional&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Applied to service methods or classes to ensure database transactions roll back automatically if an error occurs during execution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Useful Annotations
&lt;/h2&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Column&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Customize column name, type, and constraints.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Transient&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Marks fields that should not be persisted to the database.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Enumerated&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Maps enums to database columns (e.g., as STRING or ORDINAL).&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;@Embedded&lt;/code&gt; / &lt;code&gt;@Embeddable&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;Used for reusable embedded objects within an entity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Annotations are one of the features that make Spring Boot, Spring Security, and JPA so powerful and developer-friendly. They help reduce boilerplate code, improve readability, and make your application easier to maintain.&lt;/p&gt;

&lt;p&gt;I hope this guide gave you a clear understanding of the commonly used annotations and when to apply them in your projects.&lt;/p&gt;

&lt;p&gt;Thanks for taking the time to read this blog! If you found it helpful, feel free to share your thoughts and questions in the comments.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>java</category>
      <category>springboot</category>
      <category>fullstack</category>
    </item>
  </channel>
</rss>
