• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 126
  • Last Modified:

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.
0
Software Programmer
Asked:
Software Programmer
  • 5
  • 3
2 Solutions
 
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
 
Software ProgrammerAuthor Commented:
How does many writes the BasicDAO implementation ?
0
 
girionisCommented:
I don't understand your question.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now