Do Grails Domain Methods Create Mysql Triggers? - grails

I can't seem to find this information anywhere. If I add domain methods to a grails domain class, are they set up as mysql triggers or do they just run in the project? Especially "default" triggers that have overlap like beforeUpdate or beforeInsert. There's no documentation on exactly how these methods are being set up.

No they do not. GORM does not create any triggers.

Related

Grails named queries as scroll results

I know that I can do Alert.Criteria().scroll() but I cannot seem to do it with named queries. Can it be done?
Right now, and it looks like this won't change, it is not possible to use scroll() with named queries. You can look at the Grails source code of the NamedQueryProxy (which is the actual instance you get back when calling a named query) at GitHub using this path:
grails-data-mapping/grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/query/NamedQueriesBuilder.groovy
According to the Grails team, the named query feature has largely been replaced by where queries. There's some other problems with named queries (like when adding additional criteria at invocation, the query automatically executes .list() ). I opened two issues with the Grails team and it seems they will not be evolving the feature set and stability of named queries in favor of using where queries instead.

Grails ConcurrentModificationException in custom eventlistener

I have a Grails (2.4.3) application which uses a PersistenceListener to listen on GORM events.
The PersistenceListener works fine. In the PreUpdate event, it calls a service (injected) which does a findAll on a related object. Here, I am just gathering values to update a 3rd party system. The service doesn't change any object value at all including the event.entityObject.
It gets a ConcurrentModificationException after the PreUpdate is run and the instance.save is invoked on the controller.
If I remove/comment the findAll of the related object, the exception goes away.
I suspect this is to do with Hibernate. Related questions all talk about iterators and using their remove methods. Here I am not removing any values, just trying to get the related objects.
Are you on JDK 8 where even sort is also considered as a modification operation different from JDK 7 ?
This may not be an answer; but I had to write it as an answer since I don't have permission to comment. Please remove this if its not relevant.

How does Grails handle Database triggers?

I have an existing oracle database with triggers when a record is created. The documentation indicate to register evenlisteners for update and create. Do anybody know best practice.
What happens after or before the record is created when you use triggers is totally dependent of the db that you're using. As #aldrin says, it will help consistency if there's another application handling the same database.
I suggest you to use the events if there're plans to support more than one database vendor because you avoid the work to translate triggers between them.
If you are asking if Oracle triggers can be replicated in grails - the answer is that the event binding can be replicated (see http://grails.org/doc/latest/guide/GORM.html#eventsAutoTimestamping). as far as, what you are doing in PL/SQL for the trigger logic, that might not translate as easily.

How can I create a dynamic domain class in Grails

How can I create a dynamic domain class in Grails.
Let's say I want to create a new domain class whose class name and properties is known in the run-time. How to create it and persist it in Grails?
Many thanks,
There's a plugin for that: http://www.grails.org/plugin/dynamic-domain-class
the plugin seems to be abandoned, and in the google group of the project the deveoper say that there is some important issue and he said we can't using it in production, and there is no evolution since 2011, I hope that the founder of the idea Burt Beckwith can help us to continue this plugin, because it is really an interesting thing, there is too much possiblity behind the scene.
I'm working to get this to work on grails 2.4.4, I'm very close at getting it to work, only need to make a new instance of sessionfactory to work :)

Modifying a domain class after objects have already been persisted with that class

This question is similar to the question here.
Let us assume that I have made a Grails application and then, sometime down the road, I need to add a field to a domain class. What would be the best way to add that field and have all the objects already persisted to the database be updated too? Is there anyway to do this in Grails (currently using 1.3.7, but upgrading to 2.0 when it is stable) without manually accessing the database?
Use this plugin: http://grails.org/plugin/database-migration

Resources