Reputation: 480
I want to remove direct Hibernate references from my Java EE 7 server application so that I will not have a compile-time dependency on hibernate-core in the future. As a replacement, I want to use the plain JPA API.
So far, I figured out that org.hibernate.annotations.Cascade
and org.hibernate.annotations.CascadeType
can be mostly transferred to the cascade-parameter of JPA's @ManyToOne
or @OneToMany
.
Also, org.hibernate.annotations.Type
seems to be replaceable by a suitable JPA @Converter
.
However, there are more usages of Hibernate in my code where I am struggling more:
org.hibernate.annotations.Immutable
org.hibernate.annotations.OptimisticLock
org.hibernate.annotations.DiscriminatorOptions
org.hibernate.annotations.Fetch
org.hibernate.EmptyInterceptor
Could you give me any hints if and how those can be migrated to JPA? Alternatively, links to a Hibernate → JPA migration guide/tutorial would be very appreciated.
Upvotes: 0
Views: 417
Reputation: 16462
You can't replace these unless you want to rewrite your application. You shouldn't try to avoid these annotations IMO as that would just leave you with a bad performing application that is probably still not portable. Hibernate is the de-facto JPA implementation, so I doubt you want to move away from it.
Upvotes: 1