Javapersistencewithhibernate Second Edition notes-fourth chapter-mapping persistent classes-001 distinguishing entities and value types

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.