Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[#3023] DefaultRecordMapper does not map nested UDTs onto nested POJOs

  • Loading branch information...
commit 5564c0dfb7a93869d32247b930147263a94ffad3 1 parent 9aae9b0
Lukas Eder lukaseder authored
34 jOOQ-test/src/org/jooq/test/OracleTest.java
View
@@ -1433,6 +1433,40 @@
xxxxxxxxxxxxxxxxx xxxx xxx xxxx xxx xxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx xxxxxx xxxxxxx xxxxxxx xx xxxxxxx xxxxxxxxxxxxxxxxxxxxxxx
x
+
+ xxxxxx xxxxx xxxxxx x
+ xxxxxx xxxxxx xxxxxxx
+ xxxxxx xxxxxx xxx
+ x
+
+ xxxxxx xxxxx xxxxxxx x
+ xxxxxx xxxxxx xxxxxxx
+ xxxxxx xxxxxx xxxxx
+ xxxxxx xxxxxx xxxxxxxx
+ x
+
+ xxxxxx xxxxx xxxxxx x
+ xxxxxx xxxxxx xxxxxxxxxx
+ xxxxxx xxxxxx xxxxxxxxx
+ xxxxxx xxxxxxx xxxxxxxx
+ x
+
+ xxxxx
+ xxxxxx xxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxx x
+ xxxxxxxxxxxxx xxxxxx x xxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxx
+
+ xxxxxx xxxxxx x xxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxx
+ x
x
xx [/pro] */
37 jOOQ-test/src/org/jooq/test/PostgresTest.java
View
@@ -42,6 +42,7 @@
package org.jooq.test;
import static java.util.Arrays.asList;
+import static junit.framework.Assert.assertEquals;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.name;
import static org.jooq.impl.DSL.select;
@@ -75,7 +76,6 @@
import static org.jooq.util.postgres.PostgresDSL.arrayToString;
import static org.jooq.util.postgres.PostgresDSL.only;
import static org.jooq.util.postgres.PostgresDSL.stringToArray;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.math.BigDecimal;
@@ -1148,4 +1148,39 @@ public void testPostgresTableRename() throws Exception {
create().execute(drop, b2);
}
}
+
+
+ static class Street {
+ public String street;
+ public String no;
+ }
+
+ static class Address {
+ public Street street;
+ public String city;
+ public String country;
+ }
+
+ static class Author {
+ public String firstName;
+ public String lastName;
+ public Address address;
+ }
+
+ @Test
+ public void testPostgresUDTRecordMapping() throws Exception {
+ TAuthorRecord record = create()
+ .selectFrom(T_AUTHOR)
+ .where(T_AUTHOR.ID.eq(1))
+ .fetchOne();
+
+ Author author = record.into(Author.class);
+ assertEquals("George", author.firstName);
+ assertEquals("Orwell", author.lastName);
+ assertEquals("Hampstead", author.address.city);
+ assertEquals("England", author.address.country);
+ assertEquals("Parliament Hill", author.address.street.street);
+ assertEquals("77", author.address.street.no);
+ System.out.println(author);
+ }
}
10 jOOQ/src/main/java/org/jooq/tools/Convert.java
View
@@ -69,6 +69,7 @@
import org.jooq.Converter;
import org.jooq.EnumType;
import org.jooq.Field;
+import org.jooq.Record;
import org.jooq.SQLDialect;
import org.jooq.exception.DataTypeException;
import org.jooq.types.UByte;
@@ -742,6 +743,15 @@ else if ((fromClass == String.class) && toClass == UUID.class) {
return null;
}
}
+
+ // [#3023] Record types can be converted using the supplied Configuration's
+ // RecordMapperProvider
+ else if (Record.class.isAssignableFrom(fromClass)) {
+ Record record = (Record) from;
+ return record.into(toClass);
+ }
+
+ // TODO [#2520] When RecordUnmappers are supported, they should also be considered here
}
throw fail(from, toClass);
Please sign in to comment.
Something went wrong with that request. Please try again.