Skip to content

Commit 0693392

Browse files
Update README.md
1 parent 7246c71 commit 0693392

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -2711,4 +2711,13 @@ Calling `fetchWithBooksByGenre()` works fine only that the following warning is
27112711

27122712
**Key points:**\
27132713
- strive for smallest data types (e.g., for `EnumType.ORDINAL` set `@Column(columnDefinition = "SMALLINT")`)
2714-
2714+
2715+
----------------------------------------------------------------------------------------------------------------------
2716+
2717+
192. **[How To Map Java `enum` To Database Via `AttributeConverter`](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootEnumAttributeConverter)**
2718+
2719+
**Description:** This application maps a Java `enum` via `AttributeConverter`. In other words, it maps the `enum` values `HORROR`, `ANTHOLOGY` and `HISTORY` to the integers `1`, `2` and `3` and viceversa. This allows us to set the column type as `SMALLINT` which is less space-consuming than `VARCHAR(9)` needed in this case.
2720+
2721+
**Key points:**\
2722+
- define a custom `AttributeConverter`\
2723+
- annotate with `@Converter` the corresponding entity field

0 commit comments

Comments
 (0)