heavyai/heavyai-jdbc

PreparedStatement addBatch insert NULL into POINT column

ediril opened this issue · 3 comments

I have a table with several columns one of which is a defined as FrameCenter GEOMETRY(POINT, 4326) so it's nullable. For some rows, I'd like to insert a NULL into this column. I'm using addBatch and executeBatch methods. I tried calling setNull with all combinations of java.sql.Types. I also tried setString with empty string as value, but didn't work. I don't get an error when I call executeBatch but my row does not get inserted into the table either.

I also tried INSERT with named columns leaving out the column I'd like to insert a NULL but that didn't work either. executeBatch knows the full list of columns and gave me this error: executeBatch failed: Exception: TException - service has thrown: TOmniSciException(error_msg=Wrong number of columns to load into Table (4 vs 7))

So how do I insert a NULL to a Geometry Point column?

Btw, setNull with VARCHAR using execute (instead of addBatch and executeBatch) works if that helps. But I need it to work with addBatch and executeBatch.

Thank you!

One easy way to reproduce this problem is to modify OmniSciGeomTest.tst2_geometry and replace the first ps.setString line with ps.setNull(1, Types.VARCHAR);. The test will still pass, but you'll notice the resultset from statement.executeQuery(sql_select_geom) is empty since the row never got created.