views:

72

answers:

4

I'm a .NET Developer trying my hand at Java. My current project has a UI layer, Business logic layer, and a Data Access layer. I'm currently working on the DAL.

I'm not connecting to an external database yet; I had hoped to have my DAL classes utilize in-memory dataTables until the DB is in place.

In .NET it's very easy to make in-memory dataTables, select from them, add to them, and remove from them. But, in Java, I've been unable to find something that does the same thing.

I was considering replacing the 'dataTables' with a collection of strongly typed objects; but that would require adding references to Business layer inside of the DAL (and I thought that was a no-no).

Can someone help a confused developer out? If this whole approach is flawed, what would you do? If I missed the equivalent of a dataTable in Java - what is it?

+1  A: 

You could use a memory database like described in this answer.

A comparison of different memory databases is shown in this SO question.

tangens
+1  A: 

Here's an article on running an in-memory Derby database.

If I knew what database and what persistence library you're using, I might be able to give a more precise answer.

Mike Baranczak
+1  A: 

I was considering replacing the 'dataTables' with a collection of strongly typed objects; but that would require adding references to Business layer inside of the DAL (and I thought that was a no-no).

Who makes up these rules?

If your data access layer is responsible for CRUD operations for model objects, it seems to me that it has to have references to them. There's no way around that.

The persistence tier need not know about the service or view layers.

The only completely uncoupled class is one that talks to no one and offers nothing. It's useless.

Don't be so hung up on "rules". You're trying to layer your application. You're putting all things about persistence into a layer of classes.

I don't think in-memory database has any effect on the way you design the persistence tier. You should be able to swap in a relational database or flat file or any other mechanism, but the interface shouldn't change. That's an implementation detail.

duffymo
A: 

OR/Ms were available much earlier in Java than in .NET. DataSets are flawed in that they force you to program procedurally. Try to interact with objects and map those to the DB later.

flq