Search code examples
apache-zest

Is it possible to use Qi4j with SQL databases?


I'm interested in Qi4j but I don't know how well it fits with SQL databases.

I would like to know what does Qi4j provide to support SQL databases ?

Thanks !


Solution

  • Qi4j SQL support is, like everything Qi4j, an opt-in collection of libraries and extensions.

    First, you can use Qi4j in applications that already use something else to handle persistence (JDBC, JPA or any other technology). The Qi4j core is small and you are free to use, or not, librairies and extensions present in the SDK.

    If you don't want to use Qi4j persistence support (ie. Entities and Query API) you still can leverage the SQL Library that allows you to manage DataSources (connection pools) as Qi4j Services. As stated in the documentation, the SQL Library give you CircuitBreaker Library and Qi4j I/O API integration for free. Moreover you can choose to either import an existing DataSource (useful if you deploy your application in a container and you want that container to manage the DataSource), or use any of the following connection pools implementations: Apache DBCP, C3P0 or BoneCP. See http://qi4j.org/latest/library-sql.html

    Qi4j persistence relies on Entities stored in an EntityStore. The SDK provides many EntityStore implementations including one based on SQL databases. There's support for the following databases: PostgreSQL, MySQL, MariaDB, SQLite (embedded), H2 (embedded or server), and Apache Derby (aka. Oracle JavaDB, both in embedded and server modes). See http://qi4j.org/latest/extension-es-sql.html

    Qi4j Query API relies on Index/Query services. Again, the SDK provides several implementations including one based on SQL databases. At the time of writing it supports only PostgreSQL as a backend but work is being done to support as many SQL databases as the SQL EntityStore. See http://qi4j.org/latest/extension-indexing-sql.html

    Finally, an application sample demonstrates how to use all the SQL support provided by the Qi4j SDK for you to get started from. See http://qi4j.org/latest/sample-sql-support.html

    /Paul