Skip to content

Instantly share code, notes, and snippets.

@gbadner
Created May 16, 2011 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbadner/974835 to your computer and use it in GitHub Desktop.
Save gbadner/974835 to your computer and use it in GitHub Desktop.
Entity/Attribute Binding
HHH-6227 will provide a way to update Entity/Attribute objects in EntityBinding/AttributeBinding objects
EntityBinding entityBinding =
new EntityBinding( name )
.initialize( new HbmEntityBindingState( getHibernateMappingBinder(), ... )
.initialize( new HbmEntityRelationalState( getHibernateMappingBinder(), ... );
entityBinding.setEntity( new Entity( name ) ) can be called immediately or later
SimpleAttributeBinding attributeBinding =
entityBinding.makeSimpleAttributeBinding( name )
.initialize( new HbmSimpleAttributeBindingState( getHibernateMappingBinder(), ... )
.initialize( new HbmSimpleAttributeRelationalState( getHibernateMappingBinder(), ... )
attributeBinding.setAttribute( entity.getOrCreateSingularAttribute( name ) ) can be called immediately or later
// CompositeAttributeBinding groups singular attributes for:
// creating primary/surrogate keys, or grouped to be used for element collections.
//
// CompositeAttributeBinding does not have an associated Embeddable class
// CompositeAttributeBinding has no domain representation
// Attributes contained by CompositeAttributeBinding are defined directly on the EntityBinding
// (not completely sure this will always work)
CompositeAttributeBinding compositeAttributeBinding = entityBinding.makeCompositeAttributeBinding();
for ( Object attributeInfo : attributeInfoList ) {
if ( attributeInfo is simple prop ) {
compositeAttributeBinding.makeSimpleAttributeBindingState( )
.initialize( new HbmSimpleAttributeBindingState( getHibernateMappingBinder(), ... )
.initialize( new HbmSimpleAttributeRelationalState( getHibernateMappingBinder(), ... )
}
if ( keyPropertyOrKeyManyToOne is <key-many-to-one> ) {
....
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment