Jan 29, 2010 - The dynamic-update attribute tells Hibernate whether to include unmodified. Include unmodified properties in the Hibernate's SQL update statement. If set the dynamic-insert to true, which means exclude unmodified.
Functionally, there's no difference between Spring's JdbcTemplate and it's variant, NamedParameterJdbcTemplate except for: NamedParameterJdbcTemplate provides a better approach for assigning sql dynamic parameters instead of using multiple '?' In the statement. Followings are the key points to understand the use of NamedParameterJdbcTemplate:. It provides a way of specifying Named Parameters placeholders starting with ':' (colon).
For example:firstName is the named placeholder in this query: 'select. from PERSON where FIRSTNAME =:firstName'. Internally, it delegates all JDBC low level functionality to an instance of JdbcTemplate.
To bind the named placeholders to the real values into the sql query, we can use java.util.Map or we have a better option, that is to use an implementation of the interface, SqlParameterSource. Here are the commonly used implementations provided by Spring:. MapSqlParameterSource: It wraps java.util.Map and provides convenient method chaining for adding multiple param values. BeanPropertySqlParameterSource: It obtains parameter values from our domain/pojo/entity object, given that the object has proper getters and setters (Per JavaBean specifications). Also in our sql query placeholder names should be same as our object variable names.
It is the fastest way to bind values. We just have to pass our entity object to it's constructor.
Example Here we modified our last example to use NamedParameterJdbcTemplate and to see the clear difference between to two approaches. Note that we just had to make changes in JdbcTemplatePersonDao.