Created
September 7, 2013 10:45
-
-
Save MarioAriasC/6474576 to your computer and use it in GitHub Desktop.
RowMapper with KotlinPrimavera
This file contains 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
package org.kotlinprimavera.samples.petclinic.repository.jdbc | |
import org.springframework.jdbc.core.RowMapper | |
import java.sql.ResultSet | |
import org.kotlinprimavera.jdbc.core.build | |
import org.joda.time.DateTime | |
/** | |
* Created by IntelliJ IDEA. | |
* @author Mario Arias | |
* Date: 30/08/13 | |
* Time: 22:54 | |
*/ | |
public class JdbcPetRowMapper : RowMapper<JdbcPet> { | |
public override fun mapRow(rs: ResultSet?, rowNum: Int): JdbcPet? { | |
return rs!!.build { | |
val pet = JdbcPet() | |
pet.id = int["id"] | |
pet.name = string["name"] | |
pet.birthDate = DateTime(date["birth_date"]) | |
pet.typeId = int["type_id"] | |
pet.ownerId = int["owner_id"] | |
pet | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment