Originally posted by Anh Vu:
I have a column named BrandTypeID (primary key) . That column doesn't increase automatically , so I must get id to insert new row . Ok , It's just the example , I also get BrandName and something on that table .
BrandType has no meaning in the real world .
OK, so the id has only meaning in the database model.
Ideally, your domain classes - Brand and Type - shouldn't know anything about the database. (
You should be able to switch to a different persistence mechanism - XML, OODB, flat files... - without touching your domain classes.)
Incrementing the primary key sounds more like the responsibility of the persistence layer, for example a DAO.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus