Skip to content

Instantly share code, notes, and snippets.

@gbadner
Created May 19, 2011 21:34
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/981804 to your computer and use it in GitHub Desktop.
Save gbadner/981804 to your computer and use it in GitHub Desktop.
Clarification of Attribute/Value Bindings
In the new metamodel code, it appears that both "Attribute" and "Value" bindings are modelled using AttributeBinding. The places I've seen references to "Value" bindings (EntityIdentifier, Discriminator) don't necessarily have a domain representation.
I'm working on @IdClass, and this an example where the IdClass itself does not have a representation in the domain model.
I'd like to make some improvements.
NOTE: This uses POJO terminology; this applies to other entity modes as well.
EntityBinding knows about 3 different kinds of bindings:
1) "Value" bindings: metadata that has no domain representation,
has no domain reprentation; has a relational representation
(e.g., discriminator)
2) "Attribute" bindings: metadata about persistent fields in
the entity class;
both domain and relational representations
3) "Composite" bindings: aggregated "Value" and/or "Attribute" bindings;
aggregation (container) has no domain representation;
aggregation (container) has a relational representation
(e.g., composite key, unique key)
4) "Component Attribute" bindings: same as "Composite" bindings, except the
aggregation (container) has a domain representation (domain.Component);
aggregation (container) may have a relational representation
Is this accurate/complete?
If so, I'd like to propose only adding true "Attribute" bindings (including those contained in to attributeBindingMap).
I'd also like to tweak the class hierarchy to clarify the meaning of these different types of values.
public interface ValueBinding {
public EntityBinding getEntityBinding();
public HibernateTypeDescriptor getHibernateTypeDescriptor();
public boolean hasFormula();
public boolean isSimpleValue();
public Value getValue();
public Iterable<SimpleValue> getValues();
public boolean isAlternateUniqueKey();
public boolean isNullable();
// Not sure these belong here...
public boolean[] getColumnUpdateability();
public boolean[] getColumnInsertability();
@Deprecated
public TableSpecification getTable();
public void validate();
}
public interface AttributeBinding extends ValueBinding {
public ValueBinding getValueBinding();
public Attribute getAttribute();
public HibernateTypeDescriptor getHibernateTypeDescriptor();
public Map<String, MetaAttribute> getMetaAttributes();
public Iterable<SimpleValue> getValues();
public String getPropertyAccessorName();
public boolean hasFormula();
public boolean isLazy();
// these should be moved into a KeyValueBinding of some sort, but
// that's a separate discussion.
public void addEntityReferencingAttributeBinding(EntityReferencingAttributeBinding attributeBinding);
public Set<EntityReferencingAttributeBinding> getEntityReferencingAttributeBindings();
}
public interface CompositeValueBinding extends ValueBinding {
private String getRole();
private boolean isKey();
// TODO: flesh out if this appears to be a good approach
}
public interface ComponentAttributeBinding extends AttributeBinding {
// TODO: flesh out if this appears to be a good approach
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment