similarity and difference between jpa and hibernate

前端 未结 4 2139
北恋
北恋 2020-12-05 19:28

what is similarity and difference between jpa and hibernate.

4条回答
  •  佛祖请我去吃肉
    2020-12-05 19:46

    Here's a list of some difference between subjects (excerpts from Hibernate documentation)

    1. Entity. Hibernate goes beyond the JPA specification and provide additional configurations. Some of them are hosted on @org.hibernate.annotations.Entity

      • dynamicInsert / dynamicUpdate (defaults to false)
      • selectBeforeUpdate (defaults to false)
      • polymorphisms
      • persister
      • optimisticLock (version, all, dirty, none)
    2. id as a property using a component type

      • While not supported in JPA, Hibernate lets you place your association directly in the embedded id component (instead of having to use the @MapsId annotation)
    3. Multiple id properties without identifier type

      • Another, arguably more natural, approach is to place @Id on multiple properties of your entity. This approach is only supported by Hibernate (not JPA compliant) but does not require an extra embeddable component.
    4. Multiple id properties with with a dedicated identifier type

      • While not JPA standard, Hibernate let's you declare the vanilla associated property in the @IdClass
    5. Identifier generator

      • Package level definition is not supported by the JPA specification. However, you can use the @GenericGenerator at the package level
    6. Annotations

      • Hibernate Annotations supports something that is not explicitly supported by the JPA specification. You can annotate a embedded object with the @MappedSuperclass annotation to make the superclass properties persistent (see @MappedSuperclass for more informations).
    7. Discriminator

      • @org.hibernate.annotations.DiscriminatorOptions allows to optionally specify Hibernate specific discriminator options which are not standardized in JPA. The available options are force and insert
    8. Transaction

      • Hibernate provides more flush modes than the one described in the JPA specification. In particularFlushMode.MANUAL for long running conversation. Please refer to the Hibernate core reference documentation for more informations.
    9. Static metamodel

      • Important. As of today the JPA 2 metamodel does not provide any facility for accessing relational information pertaining to the physical model. It is expected this will be addressed in a future release of the specification.

提交回复
热议问题