Figure it out that it's related to the bulk operation in [1], as Andrey
suggested before, in the /jdbc bulk operations/ section, but due to my lack
of experience, I still have to learn a lot . What I have to do is to add
some codes in the /writeAll()/ method in /TransactionStore.java/.
Here's my additional code for /writeAll()/ method to overcome my problem:
@Override
public void writeAll(Collection<Cache.Entry<? extends Long, ? extends
Store>> arg0) throws CacheWriterException {
System.out.println("let me in!");
try(Connection conn = dataSource.getConnection()) {
try (PreparedStatement st = conn.prepareStatement(
"update TRANSACTION set amount = ? where
idNumber = ?")) {
for (Entry<? extends Long, ? extends Store> entry :
arg0) {
Store val = entry.getValue();
System.out.println("writing: " +
val.getIdNumber() + " with " +
val.getAmount() );
st.setLong(2, val.getIdNumber());
st.setLong(1, val.getAmount());
st.addBatch();
}
st.executeBatch();
}
}
catch (SQLException e) {
throw new CacheWriterException("Failed to write object", e);
}
}
Thanks for all the helps. I really appreciate it.
-- Ricky
[1]
https://apacheignite.readme.io/docs/persistent-store#write-behind-caching
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/How-to-do-write-behind-caching-tp12138p12280.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.