本文整理汇总了Java中org.jooq.Record2类的典型用法代码示例。如果您正苦于以下问题:Java Record2类的具体用法?Java Record2怎么用?Java Record2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Record2类属于org.jooq包,在下文中一共展示了Record2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBasicJooqSample
import org.jooq.Record2; //导入依赖的package包/类
@Test
public void testBasicJooqSample() {
CompanyDao companyDao = new CompanyDao(configuration());
companyDao.findAll().stream().map(String::valueOf).forEach(log::info);
Result<Record2<String, String>> results = dslContext()
.select(COMPANY.ORGANISATIONNAME, USERPROFILE.EMAIL)
.from(COMPANY)
.join(USERPROFILE)
.on(COMPANY.ID.eq(USERPROFILE.COMPANY_ID))
.join(REGULARUSER)
.on(REGULARUSER.ID.eq(USERPROFILE.ID))
.fetch();
// Loop and process results
}
示例2: findAllUsers
import org.jooq.Record2; //导入依赖的package包/类
public List<User> findAllUsers() {
Result<Record2<String, String>> records = dsl.select(USER.USER_NAME, USER_ROLE.ROLE)
.from(USER)
.leftOuterJoin(USER_ROLE)
.on(USER.USER_NAME.eq(USER_ROLE.USER_NAME))
.fetch();
Map<String, List<Record2<String, String>>> byUserName = records.stream()
.collect(groupingBy(r -> r.getValue(USER.USER_NAME)));
return byUserName.entrySet().stream()
.map( entry -> ImmutableUser.builder()
.userName(entry.getKey())
.roles(entry.getValue()
.stream()
.map(record -> record.getValue(USER_ROLE.ROLE))
.filter(roleName -> roleName != null)
.map(roleName -> Role.valueOf(roleName))
.collect(Collectors.toList()))
.build())
.collect(toList());
}
示例3: findStoragePoolHostsByDriver
import org.jooq.Record2; //导入依赖的package包/类
@Override
public Map<Long, Long> findStoragePoolHostsByDriver(long clusterId, Long storageDriverId) {
final Map<Long, Long> result = new HashMap<>();
create().select(HOST.ID, STORAGE_POOL.ID)
.from(HOST)
.leftOuterJoin(STORAGE_POOL_HOST_MAP)
.on(STORAGE_POOL_HOST_MAP.HOST_ID.eq(HOST.ID))
.leftOuterJoin(STORAGE_POOL)
.on(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID.eq(STORAGE_POOL.ID)
.and(STORAGE_POOL.STORAGE_DRIVER_ID.eq(storageDriverId)))
.where(STORAGE_POOL.REMOVED.isNull()
.and(STORAGE_POOL_HOST_MAP.REMOVED.isNull())
.and(HOST.CLUSTER_ID.eq(clusterId))
.and(HOST.REMOVED.isNull()))
.fetchInto((RecordHandler<Record2<Long, Long>>) record -> {
Long hostId = record.getValue(HOST.ID);
Long storagePoolId = record.getValue(STORAGE_POOL.ID);
if (!result.containsKey(hostId) || storagePoolId != null) {
result.put(hostId, storagePoolId);
}
});
return result;
}
示例4: findHostsForPools
import org.jooq.Record2; //导入依赖的package包/类
@Override
public Map<Long, List<Object>> findHostsForPools(List<Long> ids, final IdFormatter idFormatter) {
final Map<Long, List<Object>> result = new HashMap<>();
create().select(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID, STORAGE_POOL_HOST_MAP.HOST_ID)
.from(STORAGE_POOL_HOST_MAP)
.where(STORAGE_POOL_HOST_MAP.REMOVED.isNull()
.and(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID.in(ids)))
.fetchInto(new RecordHandler<Record2<Long, Long>>() {
@Override
public void next(Record2<Long, Long> record) {
Long hostId = record.getValue(STORAGE_POOL_HOST_MAP.HOST_ID);
Long storagePoolId = record.getValue(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID);
List<Object> pools = result.get(storagePoolId);
if (pools == null) {
pools = new ArrayList<>();
result.put(storagePoolId, pools);
}
pools.add(idFormatter.formatId(HostConstants.TYPE, hostId));
}
});
return result;
}
示例5: findVolumesForPools
import org.jooq.Record2; //导入依赖的package包/类
@Override
public Map<Long, List<Object>> findVolumesForPools(List<Long> ids, final IdFormatter idFormatter) {
final Map<Long, List<Object>> result = new HashMap<>();
create().select(VOLUME.STORAGE_POOL_ID, VOLUME.ID)
.from(VOLUME)
.join(STORAGE_POOL)
.on(STORAGE_POOL.ID.eq(VOLUME.STORAGE_POOL_ID))
.where(STORAGE_POOL.KIND.ne("docker")
.and(VOLUME.STORAGE_POOL_ID.in(ids)))
.fetchInto(new RecordHandler<Record2<Long, Long>>() {
@Override
public void next(Record2<Long, Long> record) {
Long volumeId = record.getValue(VOLUME.ID);
Long storagePoolId = record.getValue(VOLUME.STORAGE_POOL_ID);
List<Object> pools = result.get(storagePoolId);
if (pools == null) {
pools = new ArrayList<>();
result.put(storagePoolId, pools);
}
pools.add(idFormatter.formatId(VolumeConstants.TYPE, volumeId));
}
});
return result;
}
示例6: getInstancesPerHost
import org.jooq.Record2; //导入依赖的package包/类
@Override
public Map<Long, List<Object>> getInstancesPerHost(List<Long> hosts, final IdFormatter idFormatter) {
final Map<Long, List<Object>> result = new HashMap<>();
create().select(INSTANCE.ID, INSTANCE.HOST_ID)
.from(INSTANCE)
.where(INSTANCE.HOST_ID.in(hosts)
.and(INSTANCE.REMOVED.isNull()))
.fetchInto((RecordHandler<Record2<Long, Long>>) record -> {
Long hostId = record.getValue(INSTANCE.HOST_ID);
Long instanceId = record.getValue(INSTANCE.ID);
List<Object> list = result.get(hostId);
if (list == null) {
list = new ArrayList<>();
result.put(hostId, list);
}
list.add(idFormatter.formatId(InstanceConstants.TYPE, instanceId));
});
return result;
}
示例7: getServicesForStack
import org.jooq.Record2; //导入依赖的package包/类
@Override
public Map<Long, List<Object>> getServicesForStack(List<Long> ids, final IdFormatter idFormatter) {
final Map<Long, List<Object>> result = new HashMap<>();
create().select(SERVICE.ID, SERVICE.STACK_ID)
.from(SERVICE)
.where(SERVICE.STACK_ID.in(ids)
.and(SERVICE.REMOVED.isNull()))
.fetchInto((RecordHandler<Record2<Long, Long>>) record -> {
Long id = record.getValue(SERVICE.ID);
Long stackId = record.getValue(SERVICE.STACK_ID);
List<Object> list = result.get(stackId);
if (list == null) {
list = new ArrayList<>();
result.put(stackId, list);
}
list.add(idFormatter.formatId(ServiceConstants.KIND_SERVICE, id));
});
return result;
}
示例8: iteratorHosts
import org.jooq.Record2; //导入依赖的package包/类
protected Iterator<AllocationCandidate> iteratorHosts(List<Long> volumes, QueryOptions options, boolean hosts,
AllocationCandidateCallback callback) {
final Cursor<Record2<Long,Long>> cursor = create()
.select(HOST.ID, STORAGE_POOL.ID)
.from(HOST)
.leftOuterJoin(STORAGE_POOL_HOST_MAP)
.on(STORAGE_POOL_HOST_MAP.HOST_ID.eq(HOST.ID)
.and(STORAGE_POOL_HOST_MAP.REMOVED.isNull()))
.join(STORAGE_POOL)
.on(STORAGE_POOL.ID.eq(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID))
.leftOuterJoin(AGENT)
.on(AGENT.ID.eq(HOST.AGENT_ID))
.where(
AGENT.ID.isNull().or(AGENT.STATE.eq(CommonStatesConstants.ACTIVE))
.and(HOST.STATE.eq(CommonStatesConstants.ACTIVE))
.and(STORAGE_POOL.STATE.eq(CommonStatesConstants.ACTIVE))
.and(getQueryOptionCondition(options)))
.orderBy(SPREAD.get() ? HOST.COMPUTE_FREE.desc() : HOST.COMPUTE_FREE.asc())
.fetchLazy();
return new AllocationCandidateIterator(objectManager, cursor, volumes, hosts, callback);
}
示例9: getLastestActiveApiKeys
import org.jooq.Record2; //导入依赖的package包/类
@Override
public String[] getLastestActiveApiKeys(Agent agent) {
Record2<String, String> result = create()
.select(CREDENTIAL.PUBLIC_VALUE, CREDENTIAL.SECRET_VALUE)
.from(CREDENTIAL)
.join(ACCOUNT)
.on(ACCOUNT.ID.eq(CREDENTIAL.ACCOUNT_ID))
.join(AGENT)
.on(AGENT.ACCOUNT_ID.eq(ACCOUNT.ID))
.where(
AGENT.ID.eq(agent.getId())
.and(CREDENTIAL.KIND.eq(CredentialConstants.KIND_AGENT_API_KEY))
.and(CREDENTIAL.STATE.eq(CommonStatesConstants.ACTIVE)))
.orderBy(CREDENTIAL.CREATED.desc())
.fetchAny();
return result == null ? null : new String[] { result.value1(), result.value2() };
}
示例10: iteratorHosts
import org.jooq.Record2; //导入依赖的package包/类
protected Iterator<AllocationCandidate> iteratorHosts(List<Long> volumes, QueryOptions options, boolean hosts) {
final Cursor<Record2<Long,Long>> cursor = create()
.select(HOST.ID, STORAGE_POOL.ID)
.from(HOST)
.leftOuterJoin(STORAGE_POOL_HOST_MAP)
.on(STORAGE_POOL_HOST_MAP.HOST_ID.eq(HOST.ID)
.and(STORAGE_POOL_HOST_MAP.REMOVED.isNull()))
.join(STORAGE_POOL)
.on(STORAGE_POOL.ID.eq(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID))
.leftOuterJoin(AGENT)
.on(AGENT.ID.eq(HOST.AGENT_ID))
.where(
AGENT.ID.isNull().or(AGENT.STATE.eq(CommonStatesConstants.ACTIVE))
.and(HOST.STATE.eq(CommonStatesConstants.ACTIVE))
.and(STORAGE_POOL.STATE.eq(CommonStatesConstants.ACTIVE))
.and(getQueryOptionCondition(options)))
.orderBy(SPREAD.get() ? HOST.COMPUTE_FREE.asc() : HOST.COMPUTE_FREE.desc())
.fetchLazy();
return new AllocationCandidateIterator(objectManager, cursor, volumes, hosts);
}
示例11: getLastestActiveApiKeys
import org.jooq.Record2; //导入依赖的package包/类
@Override
public String[] getLastestActiveApiKeys(Agent agent) {
Record2<String, String> result = create()
.select(CREDENTIAL.PUBLIC_VALUE, CREDENTIAL.SECRET_VALUE)
.from(CREDENTIAL)
.join(ACCOUNT)
.on(ACCOUNT.ID.eq(CREDENTIAL.ACCOUNT_ID))
.join(AGENT)
.on(AGENT.ACCOUNT_ID.eq(ACCOUNT.ID))
.where(
AGENT.ID.eq(agent.getId())
.and(CREDENTIAL.STATE.eq(CommonStatesConstants.ACTIVE)))
.orderBy(CREDENTIAL.CREATED.desc())
.fetchAny();
return result == null ? null : new String[] { result.value1(), result.value2() };
}
示例12: getDBVersion
import org.jooq.Record2; //导入依赖的package包/类
@Override
public DbVersion getDBVersion() {
Record2<String, DateTime> record = ctx.select(SCHEMA_VERSION.VERSION, SCHEMA_VERSION.INSTALLED_ON)
.from(SCHEMA_VERSION)
.where(SCHEMA_VERSION.INSTALLED_RANK.eq(
select(max(SCHEMA_VERSION.INSTALLED_RANK)).from(SCHEMA_VERSION)))
.fetchOne();
String ts = DateTimeUtils.humanize(record.value2());
return DbVersion.builder()
.version(record.value1())
.updateTimestamp(ts)
.build();
}
示例13: getTop
import org.jooq.Record2; //导入依赖的package包/类
public static List<Clause<Optional<GameProfile>, Integer>> getTop(ScoreType scoreType, int count) {
try (Connection con = SQLHandle.getConnection()) {
DSLContext create = DSL.using(con);
Result<Record2<String, Integer>> results = create.select(PLAYERS.UUID, HIGH_SCORES.VALUE).from(HIGH_SCORES).join(PLAYERS).on(PLAYERS.ID.equal(HIGH_SCORES.PLAYER_ID)).where(
HIGH_SCORES.SCORE_TYPE_ID.equal(scoreType.getId())
).orderBy(scoreType.getOrder() == ScoreType.Order.ASC ? HIGH_SCORES.VALUE.asc() : HIGH_SCORES.VALUE.desc()).limit(count).fetch();
return results.stream().map(
record -> new Clause<>(getProfile(record.getValue(PLAYERS.UUID)), record.getValue(HIGH_SCORES.VALUE))
).collect(Collectors.toList());
} catch (SQLException e) {
e.printStackTrace();
}
return Lists.newArrayList();
}
示例14: testService
import org.jooq.Record2; //导入依赖的package包/类
@Test
public void testService() {
assertNotNull(authorService);
authorService.save(1, "testFirstaName", "testLastName");
Record2<String, String> record2 = authorService.get();
assertEquals("testFirstaName", record2.value1());
assertEquals("testLastName", record2.value2());
}
示例15: getInstanceIdToInstanceName
import org.jooq.Record2; //导入依赖的package包/类
@Override
public Map<Long, String> getInstanceIdToInstanceName(long accountId) {
final Map<Long, String> toReturn = new HashMap<>();
create().select(INSTANCE.ID, INSTANCE.NAME)
.from(INSTANCE)
.where(INSTANCE.ACCOUNT_ID.eq(accountId))
.and(INSTANCE.REMOVED.isNull())
.fetchInto(new RecordHandler<Record2<Long, String>>() {
@Override
public void next(Record2<Long, String> record) {
toReturn.put(record.getValue(INSTANCE.ID), record.getValue(INSTANCE.NAME));
}
});
return toReturn;
}