Reputation: 4500
I'm new to JPA, so forgive this question if this is pretty standard functionality, but can you use JPA without having a database and basically use it as a cache to store objects across your application? If so, is that standard practice?
Upvotes: 2
Views: 329
Reputation: 340733
JPA is just an API implemented by few major players like Hibernate, EclipseLink and OpenJPA (so called persistence providers). All these libraries implement object-relational mapping and are focused towards database.
I don't really get your motivation but you can:
use in-memory database like H2 and any persistence provider
use de-facto standard caching solutions like EhCache or JCache API abstraction
implement your own persistence provider implementing JPA. The scariest and worst solution.
Upvotes: 1
Reputation: 47974
You could use JPA with an in memory database so it would effectively just be a cache, yes. Using it 'without a database' at all would take huge amounts of work to build a custom JPA provider that works against whatever your storage is. If it's truly a full JPA implementation that simply leaves off the 'Persistent' part, you'd spend months if not years alone just reinventing the wheel to implement the query language against your non-RDBMS cache and so forth.
I haven't worked everywhere, but personally would certainly not file such a setup under 'standard practices.' :)
Upvotes: 3