Reputation: 2599
I am currently working on an application that uses hibernate as its ORM; however, there is currently no database set up on my machine and I was wanting to start running some tests without one. I figure since hibernate is object/code based that there must be a way to simulate the DB functionality.
If there isn't a way to do it through hibernate, how can this be achieved in the general case (simulation of database)? Obviously, it wont need to handle large amounts of data, just testing functionality.
Upvotes: 5
Views: 2390
Reputation: 21858
I'm using H2. One of its major advantages is the use of dialects that simulate the behaviour of the more common DBs. For example - I'm using PostgreSQL
and I define the dialect for Hibernate
to be PostgreSQL
. I'm using it for my integration tests - in each test I create the data that fits my scenario for this test, which is then erased pretty easily. No need to rollback transactions or anything.
Upvotes: 0
Reputation: 5055
I assume you have hidden all the ORM calls behind a clean interface.
If you did, you could simply write another implementation of that interface backed by a Map
that caches your objects.
You could then utilize this in your test environment.
But I have to agree with @duffymo, you should just go through the 'first pain' and set up a proper working enviroment.
Upvotes: 0
Reputation: 308813
Hibernate is an object-relational mapping tool (ORM). You can't use it without objects and a relational database. Excluding either one makes no sense.
There are plenty of open source, free relational databases to choose from:
You're only limited by your ability to download and install one.
Upvotes: 2
Reputation: 24885
Just use an embedded DB like Derby
Maybe you could also try to use an ODBC-JDBC bridge and connect to an Excel or Access file, on Windows.
Upvotes: 7