liveBook · Manning

Spring Data JDBC Column annotation

As explained in Java Persistence with Spring Data and Hibernate epub

The Spring Data JDBC Column annotation maps a domain property to a relational database column.

Spring Data JDBC’s @Column annotation maps a domain property to a named relational database column. Use org.springframework.data.relational.core.mapping.Column, not the JPA-specific javax.persistence.Column. section 15.1

Explicit column mapping

@Table("USERS") public class User { @Id @Column("ID") private Long id; @Column("USERNAME") private String username; @Column("REGISTRATION_DATE") private LocalDate registrationDate; } These properties map to the ID, USERNAME, and REGISTRATION_DATE columns in the USERS table.

When explicit column annotations are omitted, Spring Data JDBC converts camel-case field names to snake-case table-column names. Explicit mappings make the correspondence visible and handle names that do not follow that convention. section 15.1

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Demonstrates explicit mappings and camel-case conversion, but does not detail conversion internals or lifecycle behavior.
Examples
Uses a User entity mapped to USERS columns ID, USERNAME, and REGISTRATION_DATE.
What it assumes
Assumes basic Java classes and relational schemas while distinguishing Spring Data JDBC annotations from JPA annotations.
What you can do after
Apply it by annotating Spring Data JDBC properties with their corresponding database column names.
How it connects
Connects column mapping with Spring Data JDBC entities, @Table, @Id, repositories, and relational database schemas.

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.