Introduction to the hibernate collection Interface

Source: Internet
Author: User
Tags in domain

 Introduction to the hibernate collection Interface

In Java Domain Models, set attributes are always the same

Private <inteface> ATTR = new <implementaction> (); // initialize the object as early as possible to avoid uninitialized sets.

...

// Getter and setter

<Set>

Semantics: unordered, repeat is not allowed, and the sequence of elements is not saved.

Ing interface: Java. util. set or Java. util. sortedset

Implementation class: Java. util. hashset or Java. util. treeset

Note: set corresponds to hashset; sortedset corresponds to treeset. sortedset can be used to set a comparator or for natural sorting in memory.

<List>

Semantics: ordered and repeatable storage locations with additional indexes

Ing interface: Java. util. lits

Implementation class: Java. util. arraylist

<Big>

Semantics: unordered, repeatable, and element order not saved

Ing interface: Java. util. Collection

Implementation class: any class that can be used to implement the collection interface. java. util. arraylist is generally used (although list has an index, if it is big, the index will not be saved)

<Idbig>

Unlike big, it provides an additional primary key to distinguish distinct elements.

<Map>

Semantics: stores key/value pairs. The key cannot be repeated without saving the element sequence.

Ing interface: Java. util. map or Java. util. sortedmap

Implementation class: Java. util. hashmap or Java. util. treemap

Note: Map corresponds to hashmap; sortedmap corresponds to treemap. sortedmap can be used to set the comparator or to use the natural sequence in the memory.

<Primitive-array> <array>

Rarely used in Domain Models

About JPA

JPA does not list all of these options. The available standard set attributes are set, list, collection, and map.

About Expansion

If you cannot find the collection interface or implementation you need in the previous collection, you can extend the persistentcollection. Generally, you can extend one of the existing persistentset, persistentbag, and persistentlist classes.

 

 

 

 

 

 

 

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.