Introduce `VirtualIdEmbeddable` and `IdClassEmbeddable`

Added new form of `SqlExpressionResolver#createColumnReferenceKey`

Still need to
  - integrate EmbeddableInstantiator work
  - integrate embedded forms.  `VirtualIdEmbeddable` does not really need it as it can use the id-mapping itself as the embedded form.  But `IdClassEmbedded` should really be integrated
  - integrate `VirtualKeyEmbeddable` and `VirtualKeyEmbedded` for use as inverse composite fks
  - share `#finishInit` handling for `EmbeddableMappingType`, `VirtualIdEmbeddable` and `IdClassEmbeddable`
This commit is contained in:
Steve Ebersole 2021-11-21 08:20:37 -06:00
parent 86e8b2751c
commit 546a635be9
1 changed files with 12 additions and 0 deletions

View File

@ -8,11 +8,14 @@ package org.hibernate.sql.ast.spi;
import java.util.function.Function;
import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.spi.TypeConfiguration;
import static java.util.Locale.ROOT;
/**
* Resolution of a SqlSelection reference for a given SqlSelectable. Some
* SqlSelectable are required to be qualified (e.g. a Column) - this is indicated
@ -54,6 +57,15 @@ public interface SqlExpressionResolver {
return qualifier + columnExpression;
}
/**
* Convenience form for creating a key from TableReference and SelectableMapping
*/
static String createColumnReferenceKey(TableReference tableReference, SelectableMapping selectable) {
assert selectable.getContainingTableExpression().equals( tableReference.getTableExpression() )
: String.format( ROOT, "Expecting tables to match between TableReference (%s) and SelectableMapping (%s)", tableReference.getTableExpression(), selectable.getContainingTableExpression() );
return createColumnReferenceKey( tableReference, selectable.getSelectionExpression() );
}
/**
* Given a qualifier + a qualifiable SqlExpressable, resolve the
* (Sql)Expression reference.