mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1405 - ENH: Add SqlQuery.findSingleAttribute() ... for returning single scalar values via SqlQuery
This commit is contained in:
@@ -5,11 +5,14 @@ import io.ebean.Ebean;
|
||||
import io.ebean.SqlQuery;
|
||||
import io.ebean.SqlRow;
|
||||
import org.tests.model.basic.TUuidEntity;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class TestSqlRowUUID extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
@@ -26,9 +29,17 @@ public class TestSqlRowUUID extends BaseTestCase {
|
||||
|
||||
UUID id = sqlRow.getUUID("id");
|
||||
|
||||
Assert.assertNotNull(id);
|
||||
assertNotNull(id);
|
||||
|
||||
Boolean b = sqlRow.getBoolean("name");
|
||||
Assert.assertFalse(b);
|
||||
assertFalse(b);
|
||||
|
||||
|
||||
SqlQuery q2 = Ebean.createSqlQuery("select id from tuuid_entity where id = :id");
|
||||
q2.setParameter("id", e.getId());
|
||||
UUID value = q2.findSingleAttribute(UUID.class);
|
||||
|
||||
assertThat(value).isEqualTo(e.getId());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user