charlesbos73 said:
I'm about to start a small web project that's going to need a small database
comprising about half a dozen master data tables and two or three
transactional tables. The size of the project doesn't warrant a full blown
persistance framework like iBatis or Hibernate, and I really can't be arsed
to roll my own. So what would people recommend?
If the solution to your problem is really better expressed
using a relational DB *and* if you really need to use Java
then you have to deal with the "Object-Relational impedance
mismatch". In that case you'd be better to reuse one of
the tested and proven ORM out there, as others pointed out.
[ SNIP ]
Why don't we look at what that "object-relational impedance mismatch"
really means? Wikipedia has a pretty decent starter discussion:
http://en.wikipedia.org/wiki/Object-Relational_impedance_mismatch
1) Encapsulation - I don't really buy into the idea that there's a
problem here. I think of JPA entity classes as data objects. They are
unsophisticated classes that lack behaviour. Getters and setters are
pretty much the only API they need (apart from named queries, say, which
are still getters of a sort).
When you look at OODB code that works with data objects it looks very
similar to JPA code. Maybe the OODB has no entity classes, but so what?
Do you expect your data model to be changing frequently? If it is I
respectfully suggest that you've got bigger problems.
2) Data type differences - ultimately your data type in the OOP language
has to be stored as something concrete somewhere on the disk or in RAM.
Please don't tell me that in an OODB you don't have to think about this.
As for the reference issue, JPA handles that...I don't have to worry
about it.
3) Structural and integrity differences - _I_ haven't had serious
difficulties with anything that's talked about in this subsection. So I
can't comment on it.
4) Manipulative differences - hmmm, what do I want to do with data
objects? Get values, set values, retrieve lists of objects with given
criteria? Haven't had any problems doing this so far, with JPA. And the
code for doing so looks very similar to OODB code.
5) Transactional differences - the blurb here I don't really buy into.
Setting a primitive field on an object is just that, setting a primitive
field on an object. It's not a transaction to me unless I say it is.
In the final analysis, JPA is ably handling all these issues. Just like
an OODB is. Considering that the OODB code I've seen that manipulates
data objects looks very similar to JPA code, I'm left asking, what is
the advantage of an OODB to me?
As for representation and storage of data, well, the relational model
has worked very well for me so far. I haven't run across a situation yet
where it didn't work very well or fairly well.
I'm probably very lucky to work in a domain where OO
shines... Most developers here are so used to do
ORM plumbing in their dayjob that their mind became
hardwired to answer "use a SQL RDB".
Mindboggling.
I've used some of these OODBs. Right up to the point where I realized
that this emperor's new clothes didn't exist, and that I was gaining
precisely nothing over using an ORM with an RDBMS.
AHS