3

I'm new to JPA, and i understands that JPA is an interface that Hibernate and eclipse link are implementing.. can i implement it myself? or use JPA without Hibernate or eclipse link ?

all the tutorials and examples I've seen regards one of the implementations, but as for this answer: What is a JPA implementation?

If you want your application to be portable, use only JPA.

how can I use only JPA ? do someone know for such a tutorial to write my own PersistenceProvider(i thinks that's what i need to do..)

Thank you.

Community
  • 1
  • 1
jezrael
  • 331
  • 3
  • 11
  • 2
    I think you misunderstand. You should use only JPA _in your code_. i.e. your code should be independent of Hibernate and EclipseLink. You then "plug" your chosen implementation into the application at runtime. – Boris the Spider Jan 02 '14 at 13:50
  • I don't think it's that easy to write your own JPA implementation... – Lucas Jan 02 '14 at 13:51
  • I guess that is it, but how can i do this? all the documentation I've seen on JPA regards to Hibernate and EclipseLink. is implementing PersistenceProvide will help me? if not what will ? – jezrael Jan 02 '14 at 13:54
  • 1
    Just thinking about having to (yet again) solve the problem of tracing changes to managed entities gives me cold chills. Please: use an existing ORM package. If you don't want to take my word for it, check out how huge the source code of OpenJPA is and then ask yourself the question: do I really believe I am so good that I can do it with less code than that? – Gimby Jan 02 '14 at 14:01
  • @user2515512 Sorry, but you are wrong... – Adam Dyga Jan 02 '14 at 14:01

2 Answers2

1

You should not build your own JPA implementation, but use the JPA API and rely on an implementation such as Hibernate or EclipseLink. As long as you'll use classes/interfaces in the javax.persistence namespace (or package if you prefer), you'll be strictly using JPA.

Xavier Coulon
  • 1,580
  • 10
  • 15
0

The only reason to implement JPA is that you are the provider-manufacturer of an enterprise-level ORM such as Hibernate or iBatis.

JPA is a standard wrapper for the existing ORM products, it is an option available to you to use it as a wrapper for your ORM. It can't be used (as far as I know) appart from an ORM.

That in the case that your decision is to use an ORM for your database access. You must consider every option: does JDBC stand-alone suit you for your job? Would an object abstraction layer bring anything to your application? Is there any legacy condition that you must consider (for example, tons of code in PL/SQL that hide the tables from you) that would make you discard an ORM?

Jorge_B
  • 9,712
  • 2
  • 17
  • 22