Alovoa / alovoa

Free and open-source dating platform that respects your privacy
https://alovoa.com
GNU Affero General Public License v3.0
483 stars 100 forks source link

[FEATURE] Move SQL-Queries To Stored Functions #399

Open ip6li opened 5 months ago

ip6li commented 5 months ago

Is your feature request related to a problem? Please describe. UserHideRepository, UserInterestRepository, and UserRepository contains MariaDB/MySQL specific SQL queries. This makes is difficult to adapt Alovoa to other database platforms, e.g. PostgreSql. Problem may be solved by moving that queries into stored functions, so Alovoa code @Query needs a simple select call, only. An init interface and its implementations for each supported database platform is needed to set up stored functions if a new Alovoa installation is started for the first time.

Describe the solution you'd like

  1. Classes mentioned above should be adapted for use of stored functions.
  2. In a first step an initSql interface should be defined and an implementation of that interface should set up required stored functions for MariaDB/MySQL.
  3. For each class it should be possible to use different databases, especially for classes regarding binary blobs.

According to application.properties the right implementation is selected for used database.

Describe alternatives you've considered Unfortunately @Query cannot parametrized at runtime, so that is not an option to select a @Query based on application.properties.

Additional context This feature may be also useful if Alovoa is considered to be used on high volume installations, because it opens the possibility to use distributed databases and even some types of NoSQL databases like Apache Cassandra. This would be useful for e.g. big binary blobs like images or videos.

If you need help to implement this, please let me know.

Nonononoki commented 5 months ago

I don't see any issue here, @Query uses JPQL and translates to native SQL for any database supported by Hibernate, which includes PostgreSQL.