we have an object which clearly does not have an entity on it's own, it's has few properties ,and a collections of chid objects, as well as methods to handle the child objects.
we have several entity objects which have many-to-one associtions which this type of object (a few with one-to-many even) but stilll it is not entity. so how do i model this in hibernate? do i still need to give equels/hash impementaion? placing it in it's own hbm file will force me to get it an identifer, but it's not ... an entitiy
Well, Hibernate is an ORM tool, helping you map Objects in a Relational database to an object model. But it seems this aggregate object isn't relational. So, I don't think Hibernate will be able to map it, because there's nothing to map it to.
Figure out what the primary key is. Even if it's a composite key, made up of several fields, there must be some type of natural key. With a composite key, you can use Hibernate to map the object to the database.
The 'object' does get persisted at some point, doesn't it?
posted 11 years ago
there is no primary key for this thing, a good example for this type of info would an adress objects what with addtional child objects representing other relavent info.
this address objects would be part factory, person and other different entities.
Without any way to uniquely identify the object, there is no way to persist it. And that only makes sense, because if you couldn't identify something and you persisted it, you could never retrieve it, because there is no unique identifier that could ever be used to obtain it.
So, it would appear that in this scenario, Hibernate won't be able to persist or manage your data or object. If you can figure out some way to uniquely identify it, then you're set. Otherwise, I guess it's just a generated runtime object.
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
Devious Experiments for a Truly Passive Greenhouse!