Code Monkey home page Code Monkey logo

Comments (9)

jswiesner avatar jswiesner commented on May 18, 2024 1

I started working on this issue and I'm realizing that even Hibernate is overkill what what is needed here - the DAO class is only doing the most basic CRUD operations. I'm thinking this implementation can just simply use JDBC. To use the generic SQL DAO plugin you would need to specify some basic properties like URL, user name and password of the database, and then the JDBC driver class name (i.e. "com.mysql.jdbc.Driver"). Lastly, you'd need to include the jarfile with the JDBC driver in it in your classpath when running Para server. What do you think about this?

from para.

jswiesner avatar jswiesner commented on May 18, 2024 1

We'll definitely need a connection pooling mechanism on top of JDBC. I propose we try HikariCP. I've never used it before, but it looks solid.

from para.

jswiesner avatar jswiesner commented on May 18, 2024

Have done any work on this yet? I’m thinking Hibernate may be a better choice over JOOQ. From what I’ve read about JOOQ, its features start to shine when you do complex interaction with your data. But a SQL DAO in Para is only ever going to do key-value reading so this DAO implementation does need advanced reading capabilities. What are your thoughts on this?

from para.

albogdano avatar albogdano commented on May 18, 2024

I have not. I don't have a preference for JOOQ. The only goal is to make this universal so that we don't have to rewrite H2DAO all over again for every DB engine. Is this possible with Hibernate? If it's used we don't need to include any specific database drivers, right?

from para.

jswiesner avatar jswiesner commented on May 18, 2024

Yes Hibernate supports a wide range of SQL databases, including H2. You do need a SQL database driver that implements java.sql.driver, but JDBC should work for this. Are you thinking the genetic SQL DAO would replace the H2 DAO in Para? Or is this a intended to be an external plugin? Also, I agree with your point about the SQL schema being simply an ID primary key column and a second column being the JSON object. The object column could be a text type or it also could be a BLOB, I’m not sure which would be better. In theory you could map the ParaObject fields to columns, but I don’t see any value in doing this since we only need the DAO to perform lookups by ID.

from para.

albogdano avatar albogdano commented on May 18, 2024

I think this should definitely be an external plugin - para-dao-sql is a possible choice for a name. The H2DAO can be used a starting point. ID + JSON works well but BLOB is also an option. The only reason why I chose JSON for H2 is because you can see the data, in case you want to do some debugging. Modern DBs also have compression, so this shouldn't be an issue.

from para.

jswiesner avatar jswiesner commented on May 18, 2024

I finished an initial implementation of this plugin if you're interested to check it out so far (repo here). I used H2DAO as the foundation for this implementation. Connection pooling managed by HikariCPI. I used the in-memory H2 database for integration testing and setup multiple tests so they run with various compatibility modes (H2, MySQL, Oracle, PostreSQL, and SQL Server). I haven't done a careful review of the SqlUtils code yet and mostly just reused the code from H2Utils. I also need to enhance the testing a bit more, it's pretty light at the moment. HikariCP offers quite a few useful settings, so we may want to think about exposing some of these. I also need to work on the documentation a bit more.

After doing a review I'll likely have a more comprehensive list of questions/points to discuss regarding some of the implementation details. Any feedback you have in the mean time would be much appreciated.

from para.

albogdano avatar albogdano commented on May 18, 2024

Awesome! The code looks very good. HikariCP is a great choice for connection pooling. You're right about Hibernate being overkill. I just kinda forgot that JDBC existed and started thinking in other directions. 🙂

from para.

jswiesner avatar jswiesner commented on May 18, 2024

Initial implementation complete, project added to Erudika organization repo!
https://github.com/Erudika/para-dao-sql
This closes #18.

from para.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.