Questions tagged [genericdao]

48 questions
47
votes
5 answers

Single DAO & generic CRUD methods (JPA/Hibernate + Spring)

Following my previous question, DAO and Service layers (JPA/Hibernate + Spring), I decided to use just a single DAO for my data layer (at least at the beginning) in an application using JPA/Hibernate, Spring and Wicket. The use of generic CRUD…
John Manak
  • 12,620
  • 27
  • 73
  • 114
28
votes
2 answers

How do I implement a DAO manager using JDBC and connection pools?

My problem is as follows. I need a class that works as a single point to a database connection in a web system, so to avoid having one user with two open connections. I need it to be as optimal as possible and it should manage every transaction in…
Carlos Vergara
  • 3,464
  • 4
  • 27
  • 53
13
votes
1 answer

How to retrieve common values (IpAddress, TenantId) in GenericDao?

We are using the Play! framework for HTTP sessions. tenantId and ipAddress are columns that are common across multiple tables. When the user is logged in, we are storing the tenantId in HttpContextSession Whenever we require the ip address of the…
Kathiresa
  • 391
  • 2
  • 3
  • 15
9
votes
2 answers

Abstract DAO pattern and Spring's "Proxy cannot be cast to ..." problem!

I know this is very often asked , but I cannot find a working solution : This is my AbstractDAO : public interface AbstractDao { public T get(Serializable id); //other CRUD operations } And this is my JPA's implementation: public abstract…
smallufo
  • 10,110
  • 19
  • 64
  • 101
8
votes
5 answers

Spring MVC: Generic DAO and Service classes

I am writting web in Spring MVC. I wrote all DAOs using Generic DAO. Now I would like to rewrite my Service classes. How can I write "Generic Service"? There are my DAOs: /* ################################# DAO ################################…
martin
  • 1,463
  • 5
  • 25
  • 57
7
votes
1 answer

Injecting generic Beans with CDI/Weld

I just come from my tiny nice JavaSE/Guice world and am currently discovering the path of "carried by the container"-EE6. After having some trouble with Glassfish3.1, I just switched to JBoss and am now facing a problem that shouldnt be one. As…
dwegener
  • 482
  • 5
  • 14
7
votes
7 answers

generic DAO in java

I am trying to develop generic DAO in java. I have tried the following. Is this a good way to implement generic DAO? I don't want to use hibernate. I am trying to make it as generic as possible so that I don't have to repeat the same code over and…
akshay
  • 101
  • 1
  • 2
  • 4
7
votes
1 answer

Generic DAO pattern implementation Design

I am working on a GWT+Hibernate project. It consists of various module out of which I will name two - Company and Login. For each module, I have created an RPC service so that the project doesn't end up with one God-like service that does…
Jayesh Bhoot
  • 1,347
  • 1
  • 18
  • 33
5
votes
4 answers

What is the best practice for service-dao pattern?

let's think about a simple User insert operation. My Spring related classes to do this job are UserController, UserService, UserServiceImpl, UserDAO, UserDAOImpl. At controller side i call userService.insert(new User()) and in userService.insert()…
user1153321
  • 317
  • 5
  • 17
2
votes
1 answer

Spring data repository and DAO Java Generics

Reading about using Java Generics in DAO layer, I have a doubt applying this in spring data repositories. I mean, with spring data repositories, you have something like this: public interface OrderRepository extends…
user3254515
  • 1,255
  • 2
  • 17
  • 23
2
votes
0 answers

Any alternatives to Google's Generic DAO?

For some time, I was using Google's Generic DAO paired with Hibernate. But now Google's Generic DAO no longer developed & I decided to find an alternative. Advise an alternative, pls! Except Spring.
Alexiuscrow
  • 717
  • 13
  • 29
2
votes
2 answers

Pros and Cons of DAO dependent on DAOFactory

Recently I came across code where DAO has an instance of DAOFactory. And DAOFactory has Connection. DAO uses Connection of DAOFactory for its operations. Basically DAO was dependent on DAOFactory. This is the code: DAOFactory.java: public…
srh
  • 1,427
  • 3
  • 22
  • 45
2
votes
2 answers

getCurrentSession() vs openSession()

I'm trying to use generic-dao (http://code.google.com/p/hibernate-generic-dao/ ). However, in my HibernateBaseDAO the getSession() method is implemented as sessionFactory.getCurrentSession(). This leads to an error for any entity update…
obh
  • 311
  • 4
  • 8
2
votes
3 answers

Spring Generic Dao class name

I have configured a custom generic service DAO for my spring / hibernate project - the idea being that I can reuse it easily from my controllers. It essentially looks like this: public class DefaultService { private Class e; public String…
Toby
  • 1,561
  • 2
  • 17
  • 30
2
votes
1 answer

Trying to use EhCache using Spring and a custom GenericDao interface that extends the Hibernate's JpaRepository

Background Here is my working (simplified) GenericDao interface, which is implemented by any DomainDao: GenericDao.java @NoRepositoryBean public interface GenericDao, K extends Serializable> extends JpaRepository { …
sp00m
  • 44,266
  • 23
  • 127
  • 230
1
2 3 4