user3058865
user3058865

Reputation: 480

Migrate Hibernate 5.2 to JPA 2.1

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:

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

Answers (1)

Christian Beikov
Christian Beikov

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

Related Questions