Reputation: 153
I am using MongoDB with spring-data and was wondering if this is possible. I'm looking to make my application work with MySQL at the moment and at some point in future I am planning to switch it to MongoDB. I was wondering that if I use HQL with MySQL at the moment and the switch the database to MongoDB at a later stage, will it work? If not what can I do to minimize the changes required at the later stage?
Thanks!
Upvotes: 2
Views: 1433
Reputation: 154070
HQL is Hibernate specific only. JPQL is a the standard JPA query language, but it doesn't support all HQL features.
Spring Data doesn't use HQL, but JPQL. You can define a Common Repository interface that can be implemented by both a MongoDB repository and a JPA one.
But querying Mongo is so much different than SQL, so you might only reuse same base CRUD operations and the standard Spring Data query translation from method names.
Upvotes: 2