Skip to content

Commit

Permalink
Introduce VirtualIdEmbeddable and IdClassEmbeddable
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
sebersole committed Dec 1, 2021
1 parent 86e8b27 commit 546a635
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

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
Expand Down Expand Up @@ -54,6 +57,15 @@ static String createColumnReferenceKey(TableReference tableReference, String col
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.
Expand Down

0 comments on commit 546a635

Please sign in to comment.