Alters the complex field example to leverage a traditional JPA OneToMany associated collection. The relates to a new table in the database, rather than serializing to JSON.
-
Show table based complex field support in the JpaProduct extension
-
Demonstrate custom mapping to/from projection
-
Demonstrate special
@ProjectionPostConvert
support for setting bi-directional references -
Show supporting admin customization
-
Builds On : 00200-productExtensionComplexFieldJson
-
Create spring boot autoconfiguration class
ProductExtensionComplexFieldTableBased
, which will be referenced from META-INF/spring.factories -
Create
MyAutoCoProduct
repository domain class extending Broadleaf’sJpaProduct
-
Create
Upgrade
repository domain class, which will serve as a OneToMany collection member -
Create
Characteristics
repository domain class, which will serve as a OneToOne relationship-
Use @MapsId on the OneToOne reference back to the parent entity
-
Use a non-generated @Id field with the same column as the @JoinColumn from the OneToOne backreference
-
It is important for the id to not be generated in order for sandboxing transitions to function appropriately
-
-
Add new OneToMany JPA collection field to
MyAutoCoProduct
-
Create
MyAutoCoProductProjection
class extending Broadleaf’sProduct
-
Implement
getBusinessDomainType(..)
in the domain class -
Implement
toMe(..)
andfromMe(..)
in the domain class-
Call the super implementation of the method override first
-
Use
MappingUtils.setupExtensions(..)
to setup the extension mapping with the converter
-
-
Annotate method in
Upgrade
with@ProjectionPostConvert
to handle bi-direction reference back toMyAutoCoProduct
-
Annotate method in
Characteristics
with@ProjectionPostConvert
to handle bi-direction reference back toMyAutoCoProduct
-
Add
JpaEntityScan
annotation to autoconfiguration class above for new extended entity class -
Add
AutoConfigureBefore(..)
annotation to autoconfiguration class above to make sure the entity reference is scanned before JPA processing