Hi all.
I'm just looking for some general advice. My situation is that I've been asked to re-implement an existing persistence layer using Hibernate. It's all going pretty well so far (Hibernate guys: you are amazing, it is an excellent product), but I have the following grey area to deal with:
The data objects I have inherited already conform to basic Bean standards, so all good there, but they contain int IDs that link to each other's database records, rather than references. So for example the Apple class has a getParentAppleId() method which corresponds to the primary key in the APPLE table, rather than a getParentApple() method which returns an instance. My dilemma is whether I (1) keep things this way and try to handle all relationships using joins and similar techniques or (2) re-implement the data objects also so that they all have variables which point to instances of the objects to which they are related, rather than ID's to database entities.
I have tried (1) to some extent already and I'm having a few problems. For instance, is it possible to set up associations in your mapping file if you only have an ID of the other object's database entry, not a reference to it?
Thanks in advance for any help you are able to give.
Paul
|