A MySQL connector wrapper that supports mapping to Kotlin classes.

Last update: Jun 3, 2022

Racoon

Racoon is a wrapper for the MySQL connector. It makes communicating with the database easier by providing a bunch of functionalities:

  • Mapping query results to classes.
  • Query parameter support (prepared statements)
    • Custom types support
    • Indexed parameter support
    • Named parameter support
    • Basic types support
    • Smart cast query result to match the class field type

Racoon is developed with freedom of use in mind from the beginning. This property of Racoon can be seen in the mapping operations that allow the use of reified generic types and runtime types.

Installation

To build the library, run the following command:

$ ./gradlew clean build -x test

To publish the library to the local Maven repository, run the following command:

$ ./gradlew publishToMavenLocal

Roadmap

  • Basics:
    • Table column name mapping (ANNOTATIONS?) (ADDED MAPPING FUNCTIONALITY, BUT APPLIES TO ALL)
    • Get query info (number of rows, number of columns, column names, column types, ecc...)?
  • Insert query support
    • Custom ID annotation
    • Update the ID field upon insertion
    • Detect ID field by name or annotation
  • Update query support
  • Basic cache support?
  • Custom cache support?
  • Pooling:
    • Possibility to disable pooling without limiting the number of connections (TO BE TESTED)
    • Remove expired connections in the pool even if are being used
    • Possibility to set the minimum number of connections in the pool???

GitHub

https://github.com/vendro-zoo/racoon
Comments
  • 1. Fixed ambiguous null LazyId

    The LazyId does not have an empty method anymore, and the get method cannot return a null value. If a property of a Table can be null, make the LazyId itself nullable.

    A small fix of the update method is also included.

    Reviewed by a-vezzoli-02 at 2022-06-04 14:52
  • 2. LazyId should be splitted into null and non-null variants

    Is your feature request related to a problem? Please describe. Always have to check if the value of a LazyId is null or not makes the code "heavy". Also there are cases where a LazyId cannot have a null value (for example when a foreign key has a NON NULL)

    Describe the solution you'd like Splitting the LazyId class into different classes:

    • a generic one (the current LazyId)
    • a null one
    • a non-null one

    Note that LazyId would then become a sealed class and the variants would be subclasses.

    Describe alternatives you've considered Probably also splitting the non-null variant into:

    • a non-null lazy one
    • a non-null defined one

    could be useful

    Additional context No.

    Reviewed by a-vezzoli-02 at 2022-06-03 21:59
  • 3. Enhanced the ParameterCaster interface

    The ParameterCaster interface can now be used to achieve more complex behaviours. A prefix and a postfix can be optionally be defined such that when executing auto-generated queries (for example when using the insert or find methods), the resulting query is customized with these two new properties

    Reviewed by a-vezzoli-02 at 2022-06-02 20:36
  • 4. Fix for idleTimeout parameter of ConnectionSettings

    If a connection is idle for more than the specified time in the idleTimeout settings, the connection will be closed and when a new one is requested, a new one is created instead of the same one being used.

    The old behavior of the idleTimeout is replaced by the new property socketTimeout.

    Reviewed by a-vezzoli-02 at 2022-06-02 14:03
  • 5. Fix for idleTimeout parameter of ConnectionSettings

    If a connection is idle for more that the specified time in the idleTimeout settings, the connection will be closed and when a new one is requested, a new one is created instead of the same one being used.

    The old beaviour of the idleTimeout is replaced by the new property socketTimeout.

    Reviewed by a-vezzoli-02 at 2022-06-02 14:01
  • 6. Unsigned types not supported as query parameters

    Describe the bug A class using the Table interface doesn't work as expected if one of the properties is an unsigned one. This happens only when a value is set using parameter binding.

    In particular, this exception is thrown when executing a query with an UInt being used as a parameter:

    java.sql.SQLException: Cannot convert class kotlin.UInt to SQL type requested due to com.mysql.cj.exceptions.WrongArgumentException - Invalid argument value: java.io.NotSerializableException
    

    To Reproduce Steps to reproduce the behavior:

    1. Create a class that implements the Table interface
    2. Create a property with an unsigned Kotlin type
    3. Execute a query that sets the previously defined property as a parameter of the prepared statement
    4. See the exception above

    Expected behavior Unsigned types should be supported??

    Screenshots No.

    Version

    • MySQL: Any
    • Racoon: 0.1.2b and earlier (and probably newer)

    Additional context This can't probably be fixed. Unsigned types are not supported by Java, and so not supported by the MySQL connector. A possible fix would be to cast an unsigned type to its corresponding signed one, but it would be more confusing than declaring the field signed in the first place. Another possible fix would be to cast the unsigned type to String and let MySQL handle the conversion after, but this seems a cheap trick that could prevent Racoon from working with other DBMS in the future.

    Reviewed by a-vezzoli-02 at 2022-06-03 21:20
  • 7. Remove setValue and getValue functions from LazyId

    Describe the bug LazyId should not be used with a delegation. Using it this way makes the code more error-prone and inefficient. For example, suppose only the id needs to be retrieved from the object when using the delegation pattern. In that case, a whole new query and mapping must be done, while when using the LazyId, the id can be collected directly.

    Expected behavior No.

    Screenshots No.

    Version

    • MySQL: Any
    • Racoon: Latest branch

    Additional context No.

    Reviewed by a-vezzoli-02 at 2022-05-31 18:28
  • 8. ConnectionString.idleTimeout not working as intended

    Describe the bug The idleTimeout property of the ConnectionSettings does not change the actual idle time of the connection.

    To Reproduce Steps to reproduce the behavior:

    1. Use a ConnectionSetting instance with a short idleTimeout;
    2. Request a connection from RacoonDen and release it;
    3. Wait for the defined `idleTimeout.

    Expected behavior The ping test while requesting the next connection, should be negative, but its positive (it depends on the configuration of the Database itself)

    Screenshots No.

    Version

    • MySQL: Any
    • Racoon: Latest branch

    Additional context A series of queries should be used instead of the idleTimeout URL parameter: https://dba.stackexchange.com/a/174640

    Reviewed by a-vezzoli-02 at 2022-05-31 18:04
  • 9. Enum type support

    Is your feature request related to a problem? Please describe. No.

    Describe the solution you'd like An enum should be used as the type of a property in the primary constructor. The enum should implement an interface which defines the correlation between the in-code enum constant and the in-database enum constant.

    Describe alternatives you've considered Maybe leave the opportunity to use enums without a specific interface implementation, such that less runtime-errors occurs.

    Additional context No.

    Reviewed by a-vezzoli-02 at 2022-05-31 09:51
lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)

Description ORMAN is an minimalistic and lightweight ORM framework for Java which can handle your common database usage without writing SQL and strugg

Dec 16, 2021
Object-relational mapping for Android

RushOrm Object-relational mapping for Android RushOrm replaces the need for SQL by mapping java classes to SQL tables. What is the aim? The aim is to

Jan 7, 2022
A lightweight wrapper around SQLiteOpenHelper which introduces reactive stream semantics to SQL operations.

SQL Brite A lightweight wrapper around SupportSQLiteOpenHelper and ContentResolver which introduces reactive stream semantics to queries. Deprecated T

Jun 17, 2022
A wrapper around Android's SQLiteDatabase with restoring capability

Restorable SQLiteDatabase RestorableSQLiteDatabase is a wrapper to replicate android's SQLiteDatabase class with restoring capability. This wrapper ma

Jan 20, 2022
Kotlin-Exposed-SQL - Example of using Exposed with Kotlin for the consumption of relational SQL Databases
Kotlin-Exposed-SQL - Example of using Exposed with Kotlin for the consumption of relational SQL Databases

Kotlin Exposed SQL Sencillo ejemplo sobre el uso y abuso de Exposed ORM de Jetbr

Jun 14, 2022
requery - modern SQL based query & persistence for Java / Kotlin / Android
requery - modern SQL based query & persistence for Java / Kotlin / Android

A light but powerful object mapping and SQL generator for Java/Kotlin/Android with RxJava and Java 8 support. Easily map to or create databases, perfo

Jun 15, 2022
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.

Thanks to JetBrains for support Kripton Persistence Library project! Kripton Persistence Library Kripton is a java library, for Android platform, that

Feb 25, 2022
Upsert DSL extension for Exposed, Kotlin SQL framework

Exposed Upsert Upsert DSL extension for Exposed, Kotlin SQL framework. Project bases on various solutions provided by community in the official "Expos

Jun 20, 2022
Samples demonstrating the usage of Realm-Kotlin SDK
Samples demonstrating the usage of Realm-Kotlin SDK

Realm-Kotlin Samples This repository contains a set of projects to help you learn about using Realm-Kotlin SDK Each sample demonstrates different use

Jun 20, 2022
Collection of Kotlin APIs/tools to make using Realm Mobile database easier

Compass Kotlin API and tools to make working with Realm easier Components Compass is designed to make working with Realm easier through collection of

May 30, 2022
Upsert DSL extension for Exposed, Kotlin SQL framework

Exposed Upsert Upsert DSL extension for Exposed, Kotlin SQL framework. Project bases on various solutions provided by community in the official "Expos

Apr 11, 2022
sql-delight example, a plugin by Square which is pure kotlin and it is useful in kmm

Sql-Delight-Example01 Developed by Mahdi Razzaghi Ghaleh first example of sql-delight What is SqlDelight? Kotlin Multiplatform is one of the most inte

Jan 24, 2022
RecordMe - Record your voice application with kotlin
RecordMe - Record your voice application with kotlin

RecordMe A simple voice recording app. Made Using : Kotlin, Navigation Component

Apr 28, 2022
Starter code for Android Kotlin Fundamentals Codelab 6.1 Room

TrackMySleepQuality - Starter Code Starter code for Android Kotlin Fundamentals Codelab 6.1 Room Introduction TrackMySleepQuality is an app for record

Jan 15, 2022
BookSearchApp - Book Search App With Kotlin
BookSearchApp - Book Search App With Kotlin

BookSearchApp IT Book Search App Search IT books with keyword and view informati

Feb 7, 2022
Memory objects for Kotlin/JVM and Java

Memoria Why should an object care about where to store their bytes? Examples Basics RAM can used as a memory storage: val ram: BytesMemory = RamMemory

Jun 4, 2022
JAKO: Just Another Kotlin Orm (PostgreSQL)
JAKO: Just Another Kotlin Orm (PostgreSQL)

JAKO: Just Another Kotlin Orm (PostgreSQL) JAKO is a simple, minimal, no-dependency library to build and execute postgresql statements using a fluent

May 27, 2022
Intellij Idea, Android Studio plugin for generating Kotlin data classes from JSON. Helps to avoid writing boilerplate code for model classes. Supports annotations for Gson, Moshi, Jackson.
Intellij Idea, Android Studio plugin for generating Kotlin data classes from JSON. Helps to avoid writing boilerplate code for model classes. Supports annotations for Gson, Moshi, Jackson.

JSONToKotlinClass Intellij Idea, Android Studio plugin. Plugin generates Kotlin data classes from JSON text. It can find inner classes in nested JSON.

Apr 22, 2022
Kafka Connect connector for CØSMOS based blockchains.
Kafka Connect connector for CØSMOS based blockchains.

CØSMOS Kafka Connector Kafka Connect connector for CØSMOS based blockchains. Purpose The Kafka Connect CØSMOS Source connector is a Kafka connector us

Jun 11, 2022
lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)

Description ORMAN is an minimalistic and lightweight ORM framework for Java which can handle your common database usage without writing SQL and strugg

Dec 16, 2021