Skip to content
Advertisement

Tag: dao

DAO design pattern: where should the database access be implemented?

I am building a Java application that uses a database and I’m using a DAO design pattern: in my code, all objects classes have an associated DAO class that implements an interface with get, save and update methods. For instance, for a User object, I will have the following class (ConnectionDB implements the connection to the database): Here is the

Creating new instance of concrete implementation in interface – is this an antipattern?

Let’s say I have the interface AuthorDao with two different implementation classes for example MyAuthorDaoImpl1 and MyAuthorDaoImpl2. In my interface AuthorDao I have some basic crud methods and one extra method which is static for getting a new instance of MyAuthorDaoImpl1. It looks like this: Questions Is this static method getInstance() is not an anti-pattern? Because in my opinion we

Understanding Dao-pattern, can it be used for retrieving data from cache?

I read about DAO-pattern in the official documentation and it’s not quite clear if it can be used for retrieving data from cache? Formally speaking, DAO is an additional abstraction layer between clients and mechanism the data is being retrieved from somewhere. So, if data resides in cache, I suppose we might as well call the DAO something like But

passing value to a jsp page from a java class using DAO

I wanted to pass the value retrieved on a java class to a page.I am using DAO classes. I have retrieved the values from the database and stored them on String variables.Now I want to set them to the text boxes in my view.jsp page.I am new to this area,can anyone help me out?? View.jsp is as and My Activity

Where is the best place to begin transaction using Hibernate in a tired web application with Struts 2?

I got this Java web application which uses Struts 2 and Hibernate. In the most upper layer comprises of the Struts 2 action classes. Then there are my business logic classes which are responsible for the logic of the application. Finally there is a DAO layer (called Database Bridge) which is responsible for communicating with the database. Currently I open

Advertisement