aaberg / sql2o

sql2o is a small library, which makes it easy to convert the result of your sql-statements into objects. No resultset hacking required. Kind of like an orm, but without the sql-generation capabilities. Supports named parameters.
http://sql2o.org
MIT License
1.15k stars 229 forks source link

Bind vs addParameter #320

Open The-Funk opened 5 years ago

The-Funk commented 5 years ago

I can't seem to use .bind(myObj) to update the myObjs table. All of my POJOs data members have the same exact names as their corresponding SQL Server database fields. The POJO I'm using has private data members and public get/set functions.

If I set each parameter individually with .addParameter() this works fine. Can .bind() not access private data members via public getter functions?

None of my function or field names start with "is". All of the "get" function names start with the word get followed by the name of the database field/POJO-private-data-member exactly as they are typed. For instance a DB field called Active corresponds to a private data member called Active which is accessible via a public method called getActive().

Is there a way to troubleshoot bind?

ICHx commented 4 years ago

I think I have the problem that, my POJO does not work with bind properly. I have setters and getters matching the POJO field names, and the :fields, and when the attributes are set to private, it just gives sql null values.