I am new to Hazelcast Jet and I am using Spring JdbcTemplate
to execute my query, which uses named parameters in the query, but I am not sure how to use it with Hazelcast Jet.
E.g. Hazelcast works in following way:
Pipeline p = Pipeline.create();
p.readFrom(Sources.jdbc(
() -> DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql"),
(con, parallelism, index) -> {
PreparedStatement stmt = con.prepareStatement(
"SELECT * FROM person WHERE MOD(id, ?) = ?)");
stmt.setInt(1, parallelism);
stmt.setInt(2, index);
return stmt.executeQuery();
},
resultSet -> new Person(resultSet.getInt(1), resultSet.getString(2))
)).writeTo(Sinks.logger());
But instead of ?
I want to use named query like SELECT * FROM person WHERE MOD(id, :id) = :id)
. Does Hazelcast support named query or Spring JdbcTemplate
?
Also in Sources
, can we pass ResultSet
directly as a source? There are many sources but I didn't find any for "ResultSet".
E.g.
p.readFrom(Sources.resultSet(<Resultset Object>) //something like this
Please help me out on this, if possible.
I assume that by "Named JDBC Query" you meant "Named parameters".
It's is not a standard feature of JDBC API, it's a convenience provided by the Spring Framework. Hazelcast Jet does not support it. We are currently looking at how to provide better integration between Hazelcast Jet and Spring and this is one of the things on our radar.