Hibernate combat - understanding object/relational persistence notes

A distributed system can no longer maintain consistency, availability, and fault tolerance against partition failures at the same time.

An application's business logic interacts with an application-specific object-oriented model. At runtime, the application manipulates instances of these classes.

Business logic is not executed in the database; it is implemented in Java and executed in the application layer. This enables business logic to use object-oriented concepts such as inheritance and polymorphism.

Two data representation applications must address: the object-oriented domain model and the persistence relational model.

Granularity refers to the relative size of the type you are working with.

SQL databases only expose two levels of granularity: relational types created by you and built-in data types.

A foreign key constraint will refer to exactly one target table, and defining a foreign key that refers to multiple tables is not straightforward. You must write a procedural constraint to enforce such integrity rules.

Java has two different concepts of identity:

  • instance id (memory location, "==")
  • Instance equality is determined by the implementation of the equals method (value equality)

The identity of the database is represented as a comparison of the primary key value.

Unable to find a good natural key, use surrogate keys - keys that are not presented to the user of the application and whose sole purpose is to identify data inside the application.

In object persistence solutions, relationship mapping and entity association management are core concepts.

To implement a many-to-many association in a SQL database, you must introduce a linked table, which does not appear anywhere in the domain model.

Improve the performance of data access code - minimize requests to the database. (The most obvious way: reduce the number of SQL queries.)

Retrieving an initial instance requires figuring out which part of the network you plan to visit before you start navigating the network of objects. If you retrieve too much data, you waste application layer memory.

Lazy Loading: Retrieve data only when needed.

Object/relational mapping is the automatic and transparent persistence of objects in a Java application to tables in an SQL database using metadata that describes the mapping between application classes and the SQL database schema. ORMs work by transforming data from one identity to another (a reversible operation).

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324605424&siteId=291194637