Entity types and values ​​in sleep mode

What is the difference between an entity and value types at the object level. I understand that the object will have an identifier, but there will be no value, but why do we need different ways of matching the types of objects with goals?

Is hibernate able to apply any optimization to a value type?

+4
source share
2 answers

An entity already defines the table in which it is stored. Therefore, when you have a list of objects B in entity A, there is no need to define a target table for Bs: B already defines it. Value types do not have a linked table, so the mapping of List<String> in entity A should determine which table will be used to store this list.

In addition, value types are, by definition, always wholly owned by their containing entity. After deleting an object, you also delete all lines associated with this object. This does not apply to objects: when you delete a course object, you do not delete all of your students.

These are just two examples showing that various matching properties must be defined.

+10
source

An entity type object has its own identification, where, since a value type object does not have a database identifier, it belongs to the entity. Value type objects are identified through their own objects.

0
source

Source: https://habr.com/ru/post/1380014/


All Articles