mirror of
https://github.com/google/nomulus.git
synced 2025-07-09 04:33:28 +02:00
Add JPA annotations to RegistrarContact (#432)
This commit is contained in:
parent
8b9139bc4c
commit
d6f49f5c08
8 changed files with 142 additions and 16 deletions
|
@ -49,17 +49,33 @@ public class EnumSetUserTypeTest {
|
|||
assertThat(persisted.data).isEqualTo(enums);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNativeQuery_succeeds() {
|
||||
Set<TestEnum> enums = ImmutableSet.of(TestEnum.BAR, TestEnum.FOO);
|
||||
TestEntity obj = new TestEntity("foo", enums);
|
||||
|
||||
jpaTm().transact(() -> jpaTm().getEntityManager().persist(obj));
|
||||
|
||||
assertThat(
|
||||
ImmutableSet.of(
|
||||
getSingleResultFromNativeQuery(
|
||||
"SELECT data[1] FROM \"TestEntity\" WHERE name = 'foo'"),
|
||||
getSingleResultFromNativeQuery(
|
||||
"SELECT data[2] FROM \"TestEntity\" WHERE name = 'foo'")))
|
||||
.containsExactly("BAR", "FOO");
|
||||
}
|
||||
|
||||
private static Object getSingleResultFromNativeQuery(String sql) {
|
||||
return jpaTm()
|
||||
.transact(() -> jpaTm().getEntityManager().createNativeQuery(sql).getSingleResult());
|
||||
}
|
||||
|
||||
enum TestEnum {
|
||||
FOO,
|
||||
BAR,
|
||||
BAZ;
|
||||
|
||||
public static class TestEnumType extends EnumSetUserType<TestEnum> {
|
||||
@Override
|
||||
protected TestEnum convertToElem(String value) {
|
||||
return TestEnum.valueOf(value);
|
||||
}
|
||||
}
|
||||
public static class TestEnumType extends EnumSetUserType<TestEnum> {}
|
||||
}
|
||||
|
||||
@Entity(name = "TestEntity")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue