com.kenshoo.pl.entity.internal.fetch.AliasedKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of persistence-layer Show documentation
Show all versions of persistence-layer Show documentation
A Java persistence layer based on JOOQ for high performance and business flow support.
package com.kenshoo.pl.entity.internal.fetch;
import com.kenshoo.jooq.TempTableResource;
import com.kenshoo.pl.data.ImpersonatorTable;
import com.kenshoo.pl.entity.EntityField;
import com.kenshoo.pl.entity.EntityType;
import com.kenshoo.pl.entity.UniqueKey;
import org.jooq.Record;
import org.jooq.TableField;
import org.jooq.lambda.Seq;
import java.util.List;
import java.util.stream.Collectors;
import static org.jooq.lambda.Seq.seq;
public class AliasedKey > {
private static final String PREFIX = "key_field_";
private final List> fields;
public AliasedKey(UniqueKey key) {
this.fields = Seq.of(key.getFields())
.map(field -> {
TableField tableField = field.getDbAdapter().getFirstTableField();
return new Field(field, tableField.as(PREFIX + tableField.getName()));
}).collect(Collectors.toList());
}
// foreign key
public AliasedKey(UniqueKey key, TempTableResource otherTable) {
this.fields = Seq.of(key.getFields())
.map(field -> {
TableField tableField = otherTable.getTable().getField(field.getDbAdapter().getFirstTableField());
return new Field(field, tableField.as(PREFIX + tableField.getName()));
}).collect(Collectors.toList());
}
public List> fields() {
return this.fields;
}
public List extends EntityField> unAliasedFields() {
return seq(this.fields).map(Field::unAliased).toList();
}
public List extends org.jooq.Field>> aliasedFields() {
return seq(this.fields).map(Field::aliased).toList();
}
public class Field> {
private final EntityField original;
private final org.jooq.Field> aliased;
public Field(EntityField original, org.jooq.Field> aliased) {
this.original = original;
this.aliased = aliased;
}
public org.jooq.Field> aliased(){
return aliased;
}
public EntityField unAliased(){
return original;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy