Created
February 19, 2022 13:51
-
-
Save jasondlee/479dd752fa129a8b4ab3aefaf090c69f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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