Skip to content

Instantly share code, notes, and snippets.

@jasondlee
Created February 19, 2022 13:51
Show Gist options
  • Save jasondlee/479dd752fa129a8b4ab3aefaf090c69f to your computer and use it in GitHub Desktop.
Save jasondlee/479dd752fa129a8b4ab3aefaf090c69f to your computer and use it in GitHub Desktop.
Java:
public static Field<List<LocationModel>> location(Condition cond) {
return multiset(
select(LOCATIONS.ID,
LOCATIONS.CHURCH_ID,
LOCATIONS.NAME)
.from(LOCATIONS)
.where(cond)
).as("location").convertFrom(r -> r.map(mapping(LocationModel::new)));
}
Kotlin:
fun location(cond: Condition?): Field<List<LocationModel>> {
return multiset(
select(
Locations.LOCATIONS.ID,
Locations.LOCATIONS.CHURCH_ID,
Locations.LOCATIONS.NAME
)
.from(Locations.LOCATIONS)
.where(cond)
).`as`("location").convertFrom { r: Result<Record3<Long, Long, String>> ->
r.map(
Records.mapping { id: Long?, churchId: Long?, name: String? ->
LocationModel(
id,
churchId,
name
)
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment