|
21 | 21 | import lombok.Data;
|
22 | 22 | import lombok.EqualsAndHashCode;
|
23 | 23 |
|
| 24 | +import java.util.AbstractMap; |
24 | 25 | import java.util.ArrayList;
|
25 | 26 | import java.util.Arrays;
|
| 27 | +import java.util.Collections; |
26 | 28 | import java.util.HashMap;
|
27 | 29 | import java.util.HashSet;
|
28 | 30 | import java.util.List;
|
|
41 | 43 | import org.springframework.context.annotation.Configuration;
|
42 | 44 | import org.springframework.context.annotation.Import;
|
43 | 45 | import org.springframework.data.annotation.Id;
|
| 46 | +import org.springframework.data.annotation.ReadOnlyProperty; |
44 | 47 | import org.springframework.data.jdbc.core.convert.DataAccessStrategy;
|
45 | 48 | import org.springframework.data.jdbc.testing.DatabaseProfileValueSource;
|
| 49 | +import org.springframework.data.jdbc.testing.HsqlDbOnly; |
46 | 50 | import org.springframework.data.jdbc.testing.TestConfiguration;
|
47 | 51 | import org.springframework.data.relational.core.conversion.RelationalConverter;
|
48 | 52 | import org.springframework.data.relational.core.mapping.Column;
|
@@ -597,6 +601,20 @@ public void shouldDeleteChainOfMapsWithoutIds() {
|
597 | 601 | });
|
598 | 602 | }
|
599 | 603 |
|
| 604 | + @Test // DATAJDBC-431 |
| 605 | + @HsqlDbOnly |
| 606 | + public void readOnlyGetsLoadedButNotWritten() { |
| 607 | + |
| 608 | + WithReadOnly entity = new WithReadOnly(); |
| 609 | + entity.name = "Alfred"; |
| 610 | + entity.readOnly = "not used"; |
| 611 | + |
| 612 | + template.save(entity); |
| 613 | + |
| 614 | + assertThat( |
| 615 | + jdbcTemplate.queryForObject("SELECT read_only FROM with_read_only", Collections.emptyMap(), String.class)).isEqualTo("from-db"); |
| 616 | + } |
| 617 | + |
600 | 618 | private static NoIdMapChain4 createNoIdMapTree() {
|
601 | 619 |
|
602 | 620 | NoIdMapChain4 chain4 = new NoIdMapChain4();
|
@@ -855,6 +873,13 @@ static class NoIdMapChain4 {
|
855 | 873 | Map<String, NoIdMapChain3> chain3 = new HashMap<>();
|
856 | 874 | }
|
857 | 875 |
|
| 876 | + static class WithReadOnly { |
| 877 | + @Id Long id; |
| 878 | + String name; |
| 879 | + @ReadOnlyProperty |
| 880 | + String readOnly; |
| 881 | + } |
| 882 | + |
858 | 883 | @Configuration
|
859 | 884 | @Import(TestConfiguration.class)
|
860 | 885 | static class Config {
|
|
0 commit comments