From 76c329f91912dabe109509a783931f41c5252894 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 9 Dec 2021 12:54:20 -0600 Subject: [PATCH] More work on ``@AttributeBinderType` --- .../chapters/domain/customizing.adoc | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/documentation/src/main/asciidoc/userguide/chapters/domain/customizing.adoc b/documentation/src/main/asciidoc/userguide/chapters/domain/customizing.adoc index bfd2ba4d64..fd55cba316 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/domain/customizing.adoc +++ b/documentation/src/main/asciidoc/userguide/chapters/domain/customizing.adoc @@ -5,7 +5,13 @@ :attributeBinderTestDir: {coreProjectDir}/src/test/java/org/hibernate/orm/test/mapping/attributebinder :extrasdir: extras -`AttributeBinder` is the best thing since sliced bread. Here's why... +For cases where Hibernate does not provide a built-in way to configure the domain +model mapping based on requirements, it provides a very broad and flexible +way to adjust the mapping model through its "boot-time model" (defined in +the `org.hibernate.mapping` package) using its `@AttributeBinderType` meta +annotation and corresponding `AttributeBinder` contract. + +An example: [[domain-customizing-example]] .AttributeBinder example @@ -16,4 +22,14 @@ include::{attributeBinderTestDir}/YesNo.java[tag=attribute-binder-example, inden include::{attributeBinderTestDir}/YesNoBinder.java[tag=attribute-binder-example, indent=0] ---- -==== \ No newline at end of file +==== + +The important thing to take away here is that both `@YesNo` and `YesNoBinder` are custom, user-written +code. Hibernate has no inherent understanding of what a `@YesNo` does or is. It only understands that +it has the `@AttributeBinderType` meta-annotation and knows how to apply that through the corresponding +`YesNoBinder`. + +Notice also that `@AttributeBinderType` provides a type-safe way to perform configuration because +the `AttributeBinder` (`YesNoBinder`) is handed the custom annotation (`@YesNo`) to grab its configured +attributes. `@YesNo` does not provide any attributes, but it easily could. Whatever `YesNoBinder` +supports. \ No newline at end of file