25
25
26
26
import org .springframework .core .convert .ConversionService ;
27
27
import org .springframework .data .convert .EntityInstantiators ;
28
- import org .springframework .data .jdbc .core .mapping .JdbcMappingContext ;
29
- import org .springframework .data .jdbc .core .mapping .JdbcPersistentEntity ;
30
- import org .springframework .data .jdbc .core .mapping .JdbcPersistentProperty ;
31
28
import org .springframework .data .mapping .MappingException ;
32
29
import org .springframework .data .mapping .PersistentProperty ;
33
30
import org .springframework .data .mapping .PersistentPropertyAccessor ;
34
31
import org .springframework .data .mapping .PreferredConstructor .Parameter ;
35
32
import org .springframework .data .mapping .context .MappingContext ;
36
33
import org .springframework .data .mapping .model .ConvertingPropertyAccessor ;
37
34
import org .springframework .data .mapping .model .ParameterValueProvider ;
35
+ import org .springframework .data .relational .core .mapping .RelationalMappingContext ;
36
+ import org .springframework .data .relational .core .mapping .RelationalPersistentEntity ;
37
+ import org .springframework .data .relational .core .mapping .RelationalPersistentProperty ;
38
38
import org .springframework .util .ClassUtils ;
39
39
40
40
/**
45
45
*/
46
46
public class EntityRowMapper <T > implements BiFunction <Row , RowMetadata , T > {
47
47
48
- private final JdbcPersistentEntity <T > entity ;
48
+ private final RelationalPersistentEntity <T > entity ;
49
49
private final EntityInstantiators entityInstantiators ;
50
50
private final ConversionService conversions ;
51
- private final MappingContext <JdbcPersistentEntity <?>, JdbcPersistentProperty > context ;
51
+ private final MappingContext <RelationalPersistentEntity <?>, RelationalPersistentProperty > context ;
52
52
53
- public EntityRowMapper (JdbcPersistentEntity <T > entity , EntityInstantiators entityInstantiators ,
54
- JdbcMappingContext context ) {
53
+ public EntityRowMapper (RelationalPersistentEntity <T > entity , EntityInstantiators entityInstantiators ,
54
+ RelationalMappingContext context ) {
55
55
56
56
this .entity = entity ;
57
57
this .entityInstantiators = entityInstantiators ;
@@ -67,7 +67,7 @@ public T apply(Row row, RowMetadata metadata) {
67
67
ConvertingPropertyAccessor propertyAccessor = new ConvertingPropertyAccessor (entity .getPropertyAccessor (result ),
68
68
conversions );
69
69
70
- for (JdbcPersistentProperty property : entity ) {
70
+ for (RelationalPersistentProperty property : entity ) {
71
71
72
72
if (entity .isConstructorArgument (property )) {
73
73
continue ;
@@ -90,11 +90,12 @@ public T apply(Row row, RowMetadata metadata) {
90
90
* Read a single value or a complete Entity from the {@link ResultSet} passed as an argument.
91
91
*
92
92
* @param row the {@link Row} to extract the value from. Must not be {@literal null}.
93
- * @param property the {@link JdbcPersistentProperty} for which the value is intended. Must not be {@literal null}.
93
+ * @param property the {@link RelationalPersistentProperty} for which the value is intended. Must not be
94
+ * {@literal null}.
94
95
* @param prefix to be used for all column names accessed by this method. Must not be {@literal null}.
95
96
* @return the value read from the {@link ResultSet}. May be {@literal null}.
96
97
*/
97
- private Object readFrom (Row row , JdbcPersistentProperty property , String prefix ) {
98
+ private Object readFrom (Row row , RelationalPersistentProperty property , String prefix ) {
98
99
99
100
try {
100
101
@@ -109,7 +110,7 @@ private Object readFrom(Row row, JdbcPersistentProperty property, String prefix)
109
110
}
110
111
}
111
112
112
- private static Class <?> getType (JdbcPersistentProperty property ) {
113
+ private static Class <?> getType (RelationalPersistentProperty property ) {
113
114
return ClassUtils .resolvePrimitiveIfNecessary (property .getActualType ());
114
115
}
115
116
@@ -118,7 +119,7 @@ private <S> S readEntityFrom(Row row, PersistentProperty<?> property) {
118
119
String prefix = property .getName () + "_" ;
119
120
120
121
@ SuppressWarnings ("unchecked" )
121
- JdbcPersistentEntity <S > entity = (JdbcPersistentEntity <S >) context
122
+ RelationalPersistentEntity <S > entity = (RelationalPersistentEntity <S >) context
122
123
.getRequiredPersistentEntity (property .getActualType ());
123
124
124
125
if (readFrom (row , entity .getRequiredIdProperty (), prefix ) == null ) {
@@ -130,7 +131,7 @@ private <S> S readEntityFrom(Row row, PersistentProperty<?> property) {
130
131
PersistentPropertyAccessor accessor = entity .getPropertyAccessor (instance );
131
132
ConvertingPropertyAccessor propertyAccessor = new ConvertingPropertyAccessor (accessor , conversions );
132
133
133
- for (JdbcPersistentProperty p : entity ) {
134
+ for (RelationalPersistentProperty p : entity ) {
134
135
if (!entity .isConstructorArgument (property )) {
135
136
propertyAccessor .setProperty (p , readFrom (row , p , prefix ));
136
137
}
@@ -139,17 +140,17 @@ private <S> S readEntityFrom(Row row, PersistentProperty<?> property) {
139
140
return instance ;
140
141
}
141
142
142
- private <S > S createInstance (Row row , String prefix , JdbcPersistentEntity <S > entity ) {
143
+ private <S > S createInstance (Row row , String prefix , RelationalPersistentEntity <S > entity ) {
143
144
144
145
return entityInstantiators .getInstantiatorFor (entity ).createInstance (entity ,
145
146
new RowParameterValueProvider (row , entity , conversions , prefix ));
146
147
}
147
148
148
149
@ RequiredArgsConstructor
149
- private static class RowParameterValueProvider implements ParameterValueProvider <JdbcPersistentProperty > {
150
+ private static class RowParameterValueProvider implements ParameterValueProvider <RelationalPersistentProperty > {
150
151
151
152
private final @ NonNull Row resultSet ;
152
- private final @ NonNull JdbcPersistentEntity <?> entity ;
153
+ private final @ NonNull RelationalPersistentEntity <?> entity ;
153
154
private final @ NonNull ConversionService conversionService ;
154
155
private final @ NonNull String prefix ;
155
156
@@ -158,7 +159,7 @@ private static class RowParameterValueProvider implements ParameterValueProvider
158
159
* @see org.springframework.data.mapping.model.ParameterValueProvider#getParameterValue(org.springframework.data.mapping.PreferredConstructor.Parameter)
159
160
*/
160
161
@ Override
161
- public <T > T getParameterValue (Parameter <T , JdbcPersistentProperty > parameter ) {
162
+ public <T > T getParameterValue (Parameter <T , RelationalPersistentProperty > parameter ) {
162
163
163
164
String column = prefix + entity .getRequiredPersistentProperty (parameter .getName ()).getColumnName ();
164
165
0 commit comments