Possible to avoid code changes during schema changes when using Jdbctemplate?

When using spring's JdbcTemplate, I am using the row mapper to map results coming back.

The benefit with this is that there are less places where I have to change my code if I change my mysql schema etc.

Are there any other tips on how to minimize changes in code when adding/removing columns in mysql?

Answers


If you are retrieving columns by name (SELECT col1, col2, col3) you will be immune to adding and rearranging of columns. Never use SELECT *.

However if you are removing columns, you have no choice. In fact, how was this suppose to work? Previously you fetched e.g. price column and used it in your business layer. Now the column does not exist - how to handle this?

But adding columns is safe, unless new columns are non-nullable. In this case you will have a problem when adding new records, since VALUES statement won't include new columns. Optional columns are fine.


Need Your Help

Simple query issue, where clause

php mysql

I am trying to get a query work!

How do I get the resolution of the main monitor in Mac OS X in C++?

c++ osx graphics resolution

I have a graphical app that needs to test the resolution of the display it is starting up on in Mac OS X to ensure it is not larger than the resolution. This is done before the window itself is

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.