Perhaps I'm missing something (my experience with hibernate has not been extensive) but is the support for value semantics quite shallow in Hibernate?
There is support for simple nested values (using dependent objects) and some support for collections of values (but only only to one level).
I'm working with an existing domain model where there is only a single entity but a number of associated value objects.
For example,
Code:
public class EntityClass {
private String id;
private String description;
private List<ValueA> as;
// ... getters & setters, etc.
}
public class ValueA {
private String name;
private List<ValueB> bs;
// ... getters & setters, etc.
}
public class ValueB {
private int amount;
private int size;
// ... getters & setters, etc.
}
(Note that only EntityClass has an ID.)
I don't think it is possible to persist this domain model unaltered using Hibernate? Nested collections of dependent objects are not supported. Adding IDs to either of the value classes fundamentally changes the (value) semantics of the domain model and introduces complexity elsewhere (entity life-cycle management).
I'm looking at using "inverse='true'" type collection properties and writing some wrapper Java clases to support this domain model but I'm wondering whether I'm overlooking something?
Any comments, general or specific, would be appreciated.