First, Introduction
1. This citation is incorrect, but cannot be cascaded when deleted
This is the way to cite
2.theBid class could be a problem. In object-oriented modeling, this is marked as a composition (the association between Item and Bid with the Diamo nd). Thus, an Item was the owner of its Bid instances and holds a collection of references. At first, this seems reasonable, because bids in an auction system is useless when the item they
were made for is gone. If a future extension of the domain model requires a user#bids Collec tion, containing all bids made by a particular User? Right now, the association between bid and User are unidirectional; a BID has a bidder reference. What if this is bidirectional?
In this case, you had to deal with possible GKFX references to Bid instances, so The Bid class needs to is an entity. It had a dependent life cycle, but it must had it own identity to support (the future) shared references.
3. When writing entity classes and Value objects, note the following 3 points:
(1) shared references-avoid shared references to value type instances Write your POJO classes.
(2) Life Cycle Dependencies-if A User was deleted, its Address dependency have to be deleted as well.
(3) identity-entity Classes need an identifier property in almost all cases. Value type classes (and of course JDK classes such as String and Integer) don ' t has an identifier prop Erty, because instances is identified through the owning entity.
Javapersistencewithhibernate Second Edition notes-fourth chapter-mapping persistent classes-001 distinguishing entities and value types