21
21
import com .hedera .mirror .common .domain .transaction .Transaction ;
22
22
import com .hedera .mirror .common .domain .transaction .TransactionType ;
23
23
import com .hedera .mirror .importer .ImporterProperties ;
24
+ import com .hedera .mirror .importer .config .Owner ;
24
25
import com .hedera .mirror .importer .parser .record .entity .EntityProperties ;
25
26
import com .hedera .mirror .importer .parser .record .transactionhandler .AbstractNodeTransactionHandler ;
26
27
import com .hederahashgraph .api .proto .java .TransactionRecord ;
39
40
import org .springframework .core .env .Environment ;
40
41
import org .springframework .core .env .Profiles ;
41
42
import org .springframework .jdbc .core .DataClassRowMapper ;
43
+ import org .springframework .jdbc .core .JdbcTemplate ;
42
44
import org .springframework .jdbc .core .ParameterizedPreparedStatementSetter ;
43
- import org .springframework .jdbc .core .namedparam .NamedParameterJdbcTemplate ;
44
45
45
46
@ Named
46
47
public class FixNodeTransactionsMigration extends ConfigurableJavaMigration {
@@ -56,7 +57,7 @@ public class FixNodeTransactionsMigration extends ConfigurableJavaMigration {
56
57
"""
57
58
select consensus_timestamp, transaction_bytes, transaction_record_bytes
58
59
from transaction
59
- where consensus_timestamp >= :startTimestamp and type in (54, 55, 56)
60
+ where consensus_timestamp >= ? and type in (54, 55, 56)
60
61
order by consensus_timestamp asc;
61
62
""" ;
62
63
@@ -66,7 +67,7 @@ public class FixNodeTransactionsMigration extends ConfigurableJavaMigration {
66
67
values (?, ?, ?, ?, ?::int8range);
67
68
""" ;
68
69
69
- private final NamedParameterJdbcTemplate jdbcTemplate ;
70
+ private final JdbcTemplate jdbcTemplate ;
70
71
private final ObjectProvider <AbstractNodeTransactionHandler > nodeTransactionHandlers ;
71
72
private final EntityProperties entityProperties ;
72
73
private final Map <TransactionType , AbstractNodeTransactionHandler > nodeTransactionHandlerMap =
@@ -79,7 +80,7 @@ public class FixNodeTransactionsMigration extends ConfigurableJavaMigration {
79
80
ObjectProvider <AbstractNodeTransactionHandler > nodeTransactionHandlers ,
80
81
ImporterProperties importerProperties ,
81
82
EntityProperties entityProperties ,
82
- NamedParameterJdbcTemplate jdbcTemplate ) {
83
+ @ Owner JdbcTemplate jdbcTemplate ) {
83
84
super (importerProperties .getMigration ());
84
85
this .v2 = environment .acceptsProfiles (Profiles .of ("v2" ));
85
86
this .nodeTransactionHandlers = nodeTransactionHandlers ;
@@ -122,14 +123,16 @@ protected void doMigrate() throws IOException {
122
123
ps .setString (5 , PostgreSQLGuavaRangeType .INSTANCE .asString (node .getTimestampRange ()));
123
124
};
124
125
125
- jdbcTemplate .getJdbcTemplate ().execute (DROP_DATA_SQL );
126
- jdbcTemplate
127
- .getJdbcTemplate ()
128
- .batchUpdate (INSERT_SQL .formatted ("node" ), nodeState .values (), nodeState .size (), statementSetter );
129
- jdbcTemplate
130
- .getJdbcTemplate ()
131
- .batchUpdate (
132
- INSERT_SQL .formatted ("node_history" ), historicalNodes , historicalNodes .size (), statementSetter );
126
+ jdbcTemplate .execute (DROP_DATA_SQL );
127
+ jdbcTemplate .batchUpdate (INSERT_SQL .formatted ("node" ), nodeState .values (), nodeState .size (), statementSetter );
128
+ jdbcTemplate .batchUpdate (
129
+ INSERT_SQL .formatted ("node_history" ), historicalNodes , historicalNodes .size (), statementSetter );
130
+
131
+ log .info (
132
+ "Successfully processed {} node transactions producing {} rows and {} history rows" ,
133
+ nodeRecordItems .size (),
134
+ nodeState .size (),
135
+ historicalNodes .size ());
133
136
}
134
137
135
138
private Node recordItemToNode (RecordItem recordItem ) {
@@ -165,10 +168,7 @@ public String getDescription() {
165
168
166
169
private List <RecordItem > getRecordItems () {
167
170
return jdbcTemplate
168
- .query (
169
- NODE_TRANSACTIONS_SQL ,
170
- Map .of ("startTimestamp" , LOWER_TIMESTAMP ),
171
- new DataClassRowMapper <>(Transaction .class ))
171
+ .query (NODE_TRANSACTIONS_SQL , new DataClassRowMapper <>(Transaction .class ), LOWER_TIMESTAMP )
172
172
.stream ()
173
173
.map (this ::toRecordItem )
174
174
.toList ();
0 commit comments