org.babyfish.jimmer.sql.ast.table.AssociationTable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql Show documentation
Show all versions of jimmer-sql Show documentation
A revolutionary ORM framework for both java and kotlin
The newest version!
package org.babyfish.jimmer.sql.ast.table;
import org.babyfish.jimmer.meta.ImmutableType;
import org.babyfish.jimmer.sql.ImmutableProps;
import org.babyfish.jimmer.sql.JoinType;
import org.babyfish.jimmer.sql.association.Association;
import org.babyfish.jimmer.sql.association.meta.AssociationType;
import org.babyfish.jimmer.sql.ast.Expression;
import org.babyfish.jimmer.sql.ast.impl.table.AssociationTableProxyImpl;
import java.util.function.Function;
public interface AssociationTable<
SE,
ST extends Table,
TE,
TT extends Table
> extends TableEx> {
@SuppressWarnings("unchecked")
default ST source() {
return (ST)join("source");
}
default Expression sourceId() {
return getAssociatedId("source");
}
@SuppressWarnings("unchecked")
default ST source(ImmutableType treatedAs) {
return (ST)join("source", JoinType.INNER, treatedAs);
}
default Expression targetId() {
return getAssociatedId("target");
}
@SuppressWarnings("unchecked")
default TT target() {
return (TT)join("target");
}
@SuppressWarnings("unchecked")
default ST target(ImmutableType treatedAs) {
return (ST)join("target", JoinType.INNER, treatedAs);
}
static <
SE,
ST extends Table,
TE,
TT extends Table
> AssociationTable of(Class sourceTableType, Function targetTableGetter) {
return AssociationTableProxyImpl.table(
AssociationType.of(
ImmutableProps.join(sourceTableType, targetTableGetter)
)
);
}
}