[JAVA] Notes for reading the Hibernate ORM 5.3.9.Final User Guide

Content of this article

This article does not explain ** the contents of the Official Hibernate Documentation **. This is a memo ** for reading a document, assuming that people who are starting to read it, have read it but forgot where it was written when they tried to check it. Please note that it is difficult to distinguish between the JPA specifications and Hibernate's original extension as a whole.

2.Domain Model

2.3 Basic Types

2.3.1. Hibernate-provided BasicTypes https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#basic-provided A list of Hibernate and Java, JDBC, and Hibernate internal map keys used for mapping. Be careful not to make the table column type unexpected. Check out Java's new time type support.

2.3.5. Explicit BasicTypes https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#basic-type-annotation Annotation of instruction to resolve to a specific DB side type. The Java type is String, but if it is a different type on the DB, it seems better to specify it positively.

2.3.15. Mapping Date/Time Values https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#basic-datetime About the value of the time system

To avoid dependencies on the java.sql package, it’s common to use the java.util or java.time Date/Time classes instead.

Don't use the java.sql type as it will be managed.

2.3.16. JPA 2.1 AttributeConverters https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#basic-jpa-convert What to do if you need to convert the data when moving the data on the object to the DB column. In this area, it is difficult to decide which layer to implement the function.

2.3.18. Generated properties https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#mapping-generated Annotation to capture the value generated on the database side. When using a strict DB timestamp or an auto-generated primary key in an entity. It can be used for reading back when the calculation result is written, but is it practical?

2.4. Embeddable types https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#embeddables When using the built-in type. It may be convenient when making a fixed combination of columns in a table. Coordinates and day of the week set.

2.5. Entity types https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#entity Hibernate mountain range. Since there is a difference between the API specifications specified in JPA and the functions implemented in Hibernate, care must be taken when considering portability.

2.5.7. Implementing equals() and hashCode() https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#mapping-model-pojo-equalshashcode Important in connection with the next section. In the first place, the identity of objects is difficult to handle.

2.6. Identifiers How to identify an entity. There seems to be a lot of things to think about, including the Java object specifications.

2.6.2. Composite identifiers https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#identifiers-composite From here, a few sections, about the handling of * compound key-like things *.

2.6.9. Using IDENTITY columns https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#identifiers-generators-identity When using the key generated by the DB side.

2.7. Associations About the relationship between entities. Around the setting of so-called relationships.

2.7.2. @OneToMany https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#associations-one-to-many About one-to-many, which is important for most relationships. Due to the structural difference between Java objects and DBs, unidirectional associations may not be used very often. Bidirectional @ OneToMany is a must read.

2.7.4. @ManyToMany https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#associations-many-to-many Feel free to use only @ManyToMany and it will be a big deal.

2.8. Collections How to manage collections. See section 2.4 from time to time as built-in types are also involved.

2.8.3. Collections of entities https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#collections-entity A description of what to do when expressing entity relationships in Java objects. The following sections are very important and are recommended to be read through.

2.9. Natural Ids https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#naturalid About identifiers that come from outside the system included in the model, such as natural IDs, JAN codes and ISBN codes. Be careful when considering porting as it seems to be a unique function of Hibernate.

  1. Bootstrap https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#bootstrap How to start Hibernate, option settings, etc. For coding without relying on Spring Boot etc. and for checking the contents of settings.

  2. Schema generation https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#schema-generation About automatic generation of schema and table. When it is not generated in the way you want.

  3. Persistence Context https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#pc About the persistence context. If it is not saved or loaded, something is wrong with this process.

Will be added at any time below ...

Recommended Posts

Notes for reading the Hibernate ORM 5.3.9.Final User Guide
Java Programming Style Guide for the Java 11 Era