Save or update in Groovy

Usually in Java, I execute a SELECT statement and check the size of the ResultSet. If it is zero, I throw INSERT and otherwise UPDATE.

Since Groovy provides syntactic sugar on top of JDBC, I wonder if it makes this process easier? Is there an easier way to save or update a record?

Note: I know that Hibernate offers this, but I would prefer to stick only to the Groovy API.

+6
source share
1 answer

There is a lightweight ORM called GStorm here , which I had on my list of things to research, which has basically no dependencies, but does not process the related domain objects

And the library for uses Grails GORM here (which explicitly derives GORM from Grails, so it has quite a few dependencies, including Hibernate)

Other than this (and maybe some other examples that I missed), I don't know anything about what you are doing. I think you will have to write your own (you can switch between INSERT or UPDATE depending on whether you pass the primary key - if the primary keys are automatically generated by the database)

+5
source

Source: https://habr.com/ru/post/951611/


All Articles