[hibernate-issues] [Hibernate-JIRA] Created: (HHH-7242) referenced attributes (property-ref) need to be resolved into relational Value references

Steve Ebersole (JIRA) noreply at atlassian.com
Wed Apr 11 12:43:50 EDT 2012


referenced attributes (property-ref) need to be resolved into relational Value references
-----------------------------------------------------------------------------------------

                 Key: HHH-7242
                 URL: https://hibernate.onjira.com/browse/HHH-7242
             Project: Hibernate ORM
          Issue Type: Task
          Components: metamodel
            Reporter: Steve Ebersole
            Assignee: Hardy Ferentschik
             Fix For: 5.0.0


hbm and annotations both have this same concept, but each does it very differently.  Ultimately both need to affect the {{ForeignKey}} target columns.  After discussion on IRC (http://transcripts.jboss.org/channel/irc.freenode.org/%23hibernate-dev/2012/%23hibernate-dev.2012-04-11.log.html) the proposed solution is essentially:

1) Change {{org.hibernate.metamodel.spi.source.ToOneAttributeSource#getReferencedEntityAttributeName}} to instead be:
{code:title=ToOneAttributeSource.java|borderStyle=solid}
public interface ToOneAttributeSource ... {
    public String getReferencedEntityName();

    public JoinColumnResolutionSource getJoinColumnResolutionSource();

    public String getForeignKeyName();
}
{code}
Specifically note that {{getReferencedEntityAttributeName}} becomes {{getJoinColumnResolutionSource}}

2) Define the JoinColumnResolutionSource abstraction:
{code:title=JoinColumnResolutionSource.java|borderStyle=solid}
public interface JoinColumnResolutionSource {
    public static interface JoinColumnResolutionContext {
        public List<org.hibernate.metamodel.spi.relational.Value> resolveRelationalValuesForAttribute(String attributeName);

        public Column resolveColumn(String logicalTableName, String logicalColumnName);
        public DerivedValue resolveFormula(String logicalTableName, String formula);
    }

    public List<org.hibernate.metamodel.spi.relational.Value> getJoinColumns(JoinColumnResolutionContext context);
}
{code}
As well as the hbm and annotation variants...
{code:borderStyle=solid}
public class HbmJoinColumnResolutionSource implements JoinColumnResolutionSource {
    @Override
    public List<org.hibernate.metamodel.spi.relational.Value> getJoinColumns(JoinColumnResolutionContext context) {
        return context.resolveRelationalValuesForAttribute( referencedPropertyName );
    }
}

public class AnnotationsJoinColumnResolutionSource implements JoinColumnResolutionSource {
    @Override
    public List<org.hibernate.metamodel.spi.relational.Value> getJoinColumns(JoinColumnResolutionContext context) {
        List<org.hibernate.metamodel.spi.relational.Value> values = ...;
        for ( attributesWithJoinColumns ... ) {
            values.add( context.resolveColumn( joinTableName, joinColumnName ) );
        }
        return values;
    }
}
{code}


3) Update Binder to use this new API.  Currently this is limited to just {{org.hibernate.metamodel.internal.Binder#bindManyToOneAttribute}}

4) Update binding classes to no longer expect to be passed the referenced attribute.  Identify what, if any, problems that introduces in consumers of the binding classes.

5) Identify all other places where {{JoinColumnResolutionSource}} could be used.  Secondary table.  Collection keys.  Others?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list