Skip to content
This repository has been archived by the owner on Jan 17, 2019. It is now read-only.

Case sensitive mapping of id key in row unmapper lead to update error. #16

Open
iazarny opened this issue Nov 16, 2014 · 1 comment
Open

Comments

@iazarny
Copy link

iazarny commented Nov 16, 2014

Case sensitive mapping of id key

Case sensitive mapping of id key in row unmapper lead to update and probably delete errors.
Because value of primary key to run update or delete queries assigned incorrectly.

Example

public Map<String, Object> mapColumns(final Person person) {
        Map<String, Object> mapping = new LinkedHashMap<String, Object>();
        mapping.put("ID", person.getId());
        mapping.put("NAME", person.getName());
       return mapping;
}

Provided below unmapper will be used to generate following sql sentence

UPDATE person set ID=?, NAME=? where Id =?

To get value of primary key used Id field from map, which has null value, so real sentence

UPDATE person set ID=10, NAME="Jonh Dou" where Id = null

will never update record.

@nurkiewicz
Copy link
Owner

Which database engine are you using? Not sure if it's related, but some databases are case-sensitive while others aren't (most notably MySQL). Also TableDescription declares names of ID columns. Where does Id come from in your example? In your database it's ID, right?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants