You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In StandardSqlMaker getPojoInfo:
private static ConcurrentHashMap<Class<?>, StandardPojoInfo> map = new ConcurrentHashMap<>();
public StandardPojoInfo getPojoInfo(Class<?> rowClass) {
StandardPojoInfo pi = map.get(rowClass);
if (pi == null) {
pi = new StandardPojoInfo(rowClass);
map.put(rowClass, pi);
makeInsertSql(pi);
makeUpsertSql(pi);
makeUpdateSql(pi);
makeSelectColumns(pi);
}
return pi;
}
There is some case that sql is not generated before using,
when doing many inserts in many threads at the first time.
When B thread get a StandardPojoInfo just after A thread finished the row of "map.put(rowClass, pi);"
B will get a StandardPojoInfo with null sql and then cause a exception.
It seem to need a lock for it. :)
The text was updated successfully, but these errors were encountered:
gamtruliar
changed the title
Thread-safe problem while inserting
Thread-safe problem while inserting(java.sql.SQLException: SQL String cannot be NULL )
Nov 10, 2022
Yup, I can see how this can happen. I just added a "synchronized" keyword to the method and pushed it to master. Version bumped to 1.0.6. Can you test it to see if it fixes the problem?
java.sql.SQLException: SQL String cannot be NULL
In StandardSqlMaker getPojoInfo:
private static ConcurrentHashMap<Class<?>, StandardPojoInfo> map = new ConcurrentHashMap<>();
There is some case that sql is not generated before using,
when doing many inserts in many threads at the first time.
When B thread get a StandardPojoInfo just after A thread finished the row of "map.put(rowClass, pi);"
B will get a StandardPojoInfo with null sql and then cause a exception.
It seem to need a lock for it. :)
The text was updated successfully, but these errors were encountered: