dao

What is good practice for java agile integration testing DAO -> database?

What is current good practice for agile integration testing of DAOs against a real database schema in the Java landscape? (By 'agile' I mean what is the most streamlined, automated & simple solution to this problem). I hope to achieve automation of tests that prove the data access layer integrates seamlessly with real running instances...

How to manipulate Data Transfer Object if sql join 2 tables?

I have a query in Data Access Object DAOComments that joins users table and comments table and then store the result into Data Transfer Object DTOComments: private static final String SQL_FIND_WITH_USERNAME = "SELECT u.username, comments.* FROM users u JOIN comments ON u.id = comments.id ORDER BY created_date DESC LIMIT 10;"; However...

Problem using nested avg(..) aggregate function in hibernate hql

I am using HQL to get data through DAO class but it throws as error stated below : ERROR org.hibernate.hql.PARSER - <AST>:0:0: unexpected AST node: query Below is my Hql Query : select new com.shaikh.dto.UserResult ( user.userSurName, avg((select avg(v1.age) from com.shaikh.dto.UserResult v1 where v1.joinDate between to_date(:dayF...

Java EE Architecture - Are DAO's still recommended when using an ORM like JPA 2?

If I'm using an ORM like JPA2 - where I have my entities that are mapped to my database, should I still be using a DAO? It seems like a lot more overhead. For example, I would need to maintain three extra packages: One that specifies my domain objects (which pretty much map my Entity objects): public class Employee { private Stri...

spring mvc dao and service bean mapping

I am new to Spring and hibernate. I am trying to learn the best practices and design methodoligies in j2ee apps. I have a managed to create a basic spring mvc web app. now lookin for that - how should i map my service beans to dao beans or should just use dao beans only. - Is there any need to make DAO classes singleton - If i use s...

Which database patterns (ORM, DAO, Active Record, etc.) to use for small/medium projects?

I writing real estate web site with basic function for choosing and ordering realty. It is small/simple project, but I want to write it in way, so in future I, or other developers, can turn it into medium business app without rewriting it from scratch. So what kind of patterns could you advice me to use for dealing with database? For...

DAO and Manger pattern clarification

Hi! I'm new persistence and the DAO pattern. After seeing some code snippets, I wonder what the use of manager classes is (they seem to duplicate the functionality of DAO's)? I've tried searching for some tutorials but couldn't find any. Could you, please, give me some links/hints? ...

JPA and DAO - what's the standard approach?

I'm developing my first app with JPA/Hibernate and Spring. My first attempt at a DAO class looks like this: @Repository(value = "userDao") public class UserDaoJpa implements UserDao { @PersistenceContext private EntityManager em; public User getUser(Long id) { return em.find(User.class, id); } public List g...

DAO and Service layers (JPA/Hibernate + Spring)

I'm designing a new app based on JPA/Hibernate, Spring and Wicket. The distinction between the DAO and Service layers isn't that clear to me though. According to Wikipedia, DAO is an object that provides an abstract interface to some type of database or persistence mechanism, providing some specific operations without exposing...

Where should "@Transactional" be place Service Layer or DAO

Firstly it is possible that I am asking something that has been asked and answered before but I could not get a search result back . Okay generally (or always so far:) ) We define transactional annotations on service layer typical spring hibernate crud is usually Controller->Manager->Dao->Orm . I now have a situation where I need to ch...

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 methods was proposed, but I'm not very sure how to implement this using JPA. Could you please g...

VB.Net: DAO Object won't create DBEngine

I'm using a dynamically created Access database as a temporary storage for a file being inputed. I know that everything works, as on my dev machine I can get this code to run. But on another system (Win 7) it's not working. I'm being stopped at this line... DAOEngine = New DAO.DBEngine When it gets here, it just throws an error... ...

Understanding DAOs place in an MVC Java Web App

I'm using the (slightly dated) links below as a guide to learning and understanding proper use of DAOs in my web apps. http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jspservlet.html Generally speaking, is it correct to initialize a DAO in the INIT() method of a Se...

Is there a way to increase the ammount of open dao recordsets at vb?

I've opened a dao recordset at a VB application. The problem is that I received an '3037' runtime error, this error says that I can't open any more tables or queries. So, I have to close some, but this doesn't seem to work... Is there any way to increase the number of opened recordsets? I use the next code to sort a FlexGrid table when ...

Is it OK to have singleton DAO objects?

Consider the following classes' structure: BaseDAO with methods to crest PreparedStatement and get connection from pool AccountDAO extends BaseDAO to work with Account table via JDBC. This class is singleton AccountService witch calls methods of AccountDAO like this: AccountDAO.getInstance().login(name, password). AccountDAO is a Spr...

DAO (data access object) best practices - examples I see use a DAO and a Services object both, what is the best practice here?

I'm creating a data access object to retrieve information from Google App Engine for a web app built on the Spring framework (first time for all). I see a number of examples that use a Controller/webapp -> Service -> DAO -> JDO/Google-app-engine pattern. In this pattern the DAO layer is the only one that knows about JDO, thus this laye...

DAO and Service Layer with hibernate

Hi all, im in trouble with implemenetation of a service layer, i think i did not understand this concept very well. In a DAO implementation i can write all CRUD logic for a specific technology and entity (for example hibernate and User table), and in a service layer we use a DAO for all data operation for the entity in DAO (like getUser...

DAO vs ORM(hibernate) pattern

Hi all, i read in some articles DAO is not mandatory with hibernate and its implementation is by "it depends", in other words, we can choose between ORM vs DAO pattern. Ok, let's assume that i don't want use a DAO pattern, so im using only session CRUD and query operation provided by hibernate(my ORM). Especially for the "search" and "...