BaseDAO class for JdbcTemplate for native SQL queries - save/update/delete

How to create a BaseDAO class for jdbcTemplate which handles the save, update and delete in generic way so that we can use the same in any entity.

for example, in sales we may have the id column as salesId, in product we have the id column as id, in inventory table we will have the id column as invId.

Assume we need to have one generic method for save which gets something like parameter names and values and inserts it

Example as

https://stackoverflow.com/questions/23830961/jdbctemplate-utilities-for-insert-statement

However the above example doesn't clearly says the or gives the implementation of the BaseObjectMapper and seems pretty big

Need a proper way to define the save, update and delete.
Software ProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

girionisCommented:
If you have different row ids for each table I don't think you can write a generic DAO. The mapping will be different each time.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Software ProgrammerAuthor Commented:
How does many writes the BasicDAO implementation ?
0
girionisCommented:
I don't understand your question.
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Software ProgrammerAuthor Commented:
Basic DAO class like http://javadox.com/com.google.code.morphia/morphia/0.99/com/google/code/morphia/dao/BasicDAO.html which has all default methods for query. Looking for a generic Basic DAO since we are using jdbcTemplate in our application
0
girionisCommented:
You need something like a CRUD bean.
0
Software ProgrammerAuthor Commented:
Yes, you are right. Can you help me with a code snippet?
0
girionisCommented:
Take a look at the link I posted.
0
girionisCommented:
The best answer should be accepted as answer, since what the asker asks cannot be done.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.