[#3023] DefaultRecordMapper does not map nested UDTs onto nested POJOs
This commit is contained in:
parent
9aae9b02c7
commit
5564c0dfb7
@ -1433,6 +1433,40 @@ xxxxxx xxxxx xxxxxxxxxx xxxxxxx xxxxxxxxxxxxxxxxx
|
||||
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] */
|
||||
@ -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.arrayPrepend;
|
||||
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 class PostgresTest extends jOOQAbstractTest<
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,6 +69,7 @@ import java.util.regex.Pattern;
|
||||
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 @@ public final class Convert {
|
||||
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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user