dao

DAO pattern - where do transactions fit in?

So I've got this generic DAO thing going on and at face value it appears to be ok. It's basically modeled after the CaveatEmptor sample application from the Hibernate guys. On top of that I have a business layer...the guts of the application. It's completely unaware of any specific DAO implementation. Everything up to this point se...

hibernate DAO design

do i have to open and close session and transcation in each function (make object ,delete object ,findbyID) can u give me a DAO implenetation for findall (lazy initialization ). ...

Hibernate DAO

Can anyone suggest me a DAO implementation for a web application? What will be the problem if I create a transaction for fundamental operation (e.g. findByID(), findALL(), creatObject(), deleteObject(), etc.)? Please suggest me a DAO implementation that supports lazy operations. ...

What does 'native' mean in the context of two related technologies?

The scenario in question relates to the much-maligned Microsoft Jet database engine. The assertion was that the Data Access Objects (DAO) data access technology is 'native' to Jet, the implication being that creating an object via the DAO model is 'superior' to doing the same via SQL code executed from within in the Microsoft Access user...

Should web app domain objects containing collections have "add" and "remove" item methods?

Let's say I have a Person class that has a collection of Dog objects. The relationship is bidirectional. public class Person { private List<Dog> dogs; // getter and setter for dogs } public class Dog { private Person person; // getter and setter for person } Ok now if I was just working with these objects, I would have metho...

Should multiple service layer objects share a DAO?

I have a Contact class that contains a PortalAccount object. When I want to create a "Portal Account" for a contact, an account is created remotely on a portal application using soap/axis and then the contact's portalAccount is populated and the contact is saved (local database holds information about the remote account, like user id an...

DAO vs ADO in HTA over wireless

I've written a small (8-10 laptops) point-of-sale system running over a wireless network, as an HTA that reads from/writes to an Access MDB located on a network share. I need to use ADO - GetString and the user roster are not available with DAO. I also need to use DAO - the MDB cannot be compacted with ADO. I know that: 1) If the databa...

Awkward DAO string manipulation issue.

I'm working with a legacy vb6 product and I've come across a problem whereby I need to get the filename part of a full path from a database table through DAO. I've got no access to VBA functions here so I'm looking specifically for MS Access SQL. I have no way of dropping some extra code after the query. I CAN'T change/refactor the solu...

Are methods that update multiple entities not typically part of a DAO?

I've seen a million examples of DAOs, and for the most part they all implement your basic CRUD operations for single entities, with maybe a few methods that return lists (e.g. List getCustomers()). However, I've never seen an example in which there is a method that updates, deletes, or creates multiple entities, like: void update(List)....

JDBC DAO - any good reference implementation?

Can anyone point me to a well written DAO using JDBC, that covers all the exceptions a DAO should handle. I looked at some samples at java.sun.com, their blue prints but there is a lot of theory and less code. Looking through Spring DAO source code will be enlightening but that's way too complicated for me. ...

Best way to test for duplicate keys in a database

This is more of a correctness question. Say I have a table with a primary key column in my database. In my DAO code I have a function called insertRow(string key) that will return true if the key doesn't exist in the table and insert a new row with the key. Otherwise, if a row already exists with that key it returns false. Is it better/...

Why extremely occasionally will one of bof/eof be true for a new non-empty recordset

set recordsetname = databasename.openrecordset(SQLString) if recordsetname.bof <> true and recordsetname.eof <> true then 'do something end if 2 questions : the above test can evaluate to false incorrectly but only extremely rarely (I've had one lurking in my code and it failed today, I believe for the first time in 5 ye...

How to put records from a query into DAOs?

I have written a gateway to get a result set from my database. How do i store every row in a separate dao so that i can manipulate every record further? Or can i access the result set directly to get the records? This is my Gateway (btw, should i write the conditional logic within the cfquery into a seperate cfc that extends this one?) ...

Is my DAO strategy ok?

I'm using Hibernate. The question is at the bottom. The current strategy It's simple. First of all, I have a basic Dao<T>. public class Dao<T> { private Class<T> persistentClass; private Session session; public Dao(Class<T> persistentClass) { this.persistenClass = persistentClass; this.session = Hibernate...

proper DAO way to do a 'save if not in the db'?

Here's what I have, which has problems: public User addUser(final String name, final String uid) { final List<User> result = findByProperty("uid", uid); if (!result.isEmpty()) return (result.get(0)); final User user = new User(name, uid); saveOrUpdate(user); return (user); } where findByProperty is usin...

Is there a way to change the JPA fetch type on a method?

Is there a way to change the JPA fetch type on a single method without editing the entity object? I have a shared ORM layer consisting of JPA entity classes. This ORM layer is accessed by two DAO layers. One DAO needs lazy fetching, as it is for my web application, the other needs eager fetching, as I need it to be threadsafe. Here is ...

How to cache information in a DAO in a threadsafe manner

I often need to implement DAO's for some reference data that doesn't change very often. I sometimes cache this in collection field on the DAO - so that it is only loaded once and explicitly updated when required. However this brings in many concurrency issues - what if another thread attempts to access the data while it is loading or b...

ORM and DAO in PHP

I am a PHP developer and I am familiar with ORM (Doctrine and Propel), but I seldom heard about DAO. What are the differences and relationship between ORM and DAO from PHP development perspective? If I use Symfony to develop very large and complex projects, will that be better if I use DAO? (ORM is somehow heavy I think, but I know lit...

Legacy MS Access application needs to support multiple users

I'm currently on a 4-person team tasked with the development and maintenance of a legacy MS Access application. The application is quite large, with hundreds of forms, reports, queries, and tables. Currently we have the front end split into about 7 mde components, each of which is essentially an application in its own right, joined by ...

Spring @Transactional Annotation Best Practice

We are currently discussing the Best Practice for placing the @Transactional annotations in our code. Do you place the @Transactional in the DAO classes and/or their methods or is it better to annotate the Service classed which are calling using the DAO objects? Or does it make sense to annotate both "layers"? ...