Does JPA only refer to RDBMS
JPA is all about data persistence; is data persistence only limited to RDBMS ? if not what are all the different persistence mechanisms (like Excel,File System,XML, NON RDMS etc ..) we can achieve with JPA specifications开发者_Python百科 ?
JPA is designed for RDBMS, and looking at the API and metadata you can see that this is the case. It is possible to apply JPA to other datastores, but approximations have to be made for some concepts, particularly when querying. On the other hand the JDO API was designed for all datastores, and such approximations don't have to be made.
DataNucleus was the first implementation to provide JPA across a range of other datastores (Excel, ODBMS, ODF, LDAP, BigTable, HBase, MongoDB, etc), and has provided these for the last 2+ years. It also provides JDO access for the same datastores.
JPA is all about data persistence; is data persistence only limited to RDBMS ?
Yes.
JPA is a framework that provides an object / relational mapping. Relational is the "R" in RDBMS.
A project (Hibernate OGM) started recently to allow Hibernate to interface with NoSQL-type databases. The goal of the project is "to provide a common interface for NoSQL datastores using JPA constructs". (That is not the same as implementing JPA for NoSQL.) The article linked below describes the project as "nascent"; i.e. only recently started, don't hold your breath waiting.
References:
- Java Persistence API - Wikipedia.
- Hibernate Object Mapping for NoSQL Data Stores
JPA only defines standard mappings for relational data. But many JPA providers support non-relational data as well. Normally it is the runtime side of the API that is supported, mapping is normally done through non-standard meta-data.
Also there are many JDBC providers that support the JDBC API and SQL to non-relational data and data sources, which will work with any JPA provider. This is typically the best solution for accessing non-relational data.
There is no standard to mapping to non-relational data, as non-relational data encompasses a broad range of data formats, and are by definition non-standard. The Java Connector Architecture (JCA) standard is Java's standard for accessing non-relational data. However most non-relational adapters provide JDBC drivers instead of JCA drivers as JDBC usage is more widespread.
See, http://en.wikibooks.org/wiki/Java_Persistence/Databases#EIS.2C_and_Non-relational_Data_Sources
EclipseLink has support for several persistence services including:
- JPA
- EIS (Enterprise Information Systems) non-relational data sources through JCA connectors
- JAXB (mapping XML data)
- DBWS (database web-services)
- SDO (Service Data Objects)
The Java Persistence API deals with the way relational data is mapped to Java objects ("persistent entities"), the way that these objects are stored in a relational database so that they can be accessed at a later time, and the continued existence of an entity's state even after the application that uses it ends. In addition to simplifying the entity persistence model, the Java Persistence API standardizes object-relational mapping.
The qoutes are taken fro here: http://www.oracle.com/technetwork/articles/javaee/jpa-137156.html
Shortly, yes. The JPA is about mapping of java objects to relational DB.
Is there a way to "abuse" the API and create implementation that maps objects to other targets like NOSQL? I believe it is possible but not very simple. How for example will you implement support of relational annotations like @OneToMany
?
精彩评论