What is the difference in dirty detection methods isDirty() & hasChanged() for GORM with MongoDB - grails

For dirty checking in Gorm for MongoDB, the doc says to use hasChanged() method which works fine. But the GORM entity also supports the traditional method isDirty() method.
What are the main differences between both methods? If any, which one to prefer?
Tried to search the repository and found the isDirty() & hasChanged() implementation but not sure which one to use with MongoDB.
Past references-
Is isDirty() method not supported in grails mongodb
Can't run Grails app with mongodb plugin version 3.0.3

Related

Do Grails Domain Methods Create Mysql Triggers?

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.

Integrating Elasticsearch with Activerecord

In Java when using Hibernate Search for instance you bind JPA insertion, removal and update events to the search engine so that it automatically insert, updates and removes elements from the search engine index at the same time inserting, updating or removing it from the database. Is the same possible in Ruby and when using active record? Or do you manually have to register observers?
There are at least three notable gems allowing you to integrate Elasticsearch with ActiveRecord, some (like elasticsearch-rails, flex, retire) shipping with callback hooks for ActiveRecord that will automatically add, update or destroy an elasticsearch record on the appropriate actions.
elasticsearch-rails: The new default
flex: Really great wiki
stretcher: Runner-up, new option
All of them are actively maintained and developed. A still widely used but no longer maintained gem is retire.
retire: Widely used, but no longer supported
The Tire Rubygem comes with a robust ActiveModel/ActiveRecord integration.
The best option to quickly start is to generate an example Rails application:
rails new searchapp -m https://raw.github.com/karmi/tire/master/examples/rails-application-template.rb
Also, the Railscasts episode gives a quick overview of the integration. Tire README and integration test suite have all the information.

Grails bottom-up development

I'm considering Grails for my next project, but I will be given a complete database before I start writing the application around it. I have read that Grails is a domain-centric environment, supporting top-down development, so that does not fit my development mode.
Hence my question: is it possible to write a Grails app around an existing DB structure? What would be the best approach? Can Grails be used without a full ORM, but with a pattern like ActiveRecord? Or are there tools to generate Grails classes from an existing DB schema?
are there tools to generate Grails classes from an existing DB schema?
Grails Reverse Engineering Plugin
Yes Grails can be used without an ORM.
We have written non-GORM domain classes that fetch their data from RESTful APIs without ever going to a permanent storage. So Grails is in no way forcing you to use GORM.
Depending on your legacy DB schema you can either just add params to your GORM classes to fit that schema or you can just write your own data accessors for your database.
Giving further tips / ideas without further information regarding your project and database schema is impossible, so I'll leave it at that :)

Does grails support sharding?

Does grails support sharding?
I want a multi-tenancy database solution and I looking at grails currently.
Take a look at: http://www.grails.org/plugin/sharding
Grails ORM is built on Hibernate, so my guess is that it'll be capable of (or limited to) whatever Hibernate can do. Hibernate Shards is the extension that supports sharding. I haven't used it myself, but you might want to try plugging that in and see what happens.

How to ad users using A shiro Plugin

I am using Shiro plugin for my grails application security, My application already has a user .Using the shiro plugin, we get a shiro user, now how do i integrate the shiro user with the normal user of my application,show i go ahead and use relationships or is it that the user class ahould be only a shiro user class now ??
The Grails Shiro Plugin auto-generates the ShiroUser class as a starting point that you can use directly, or, if you don't want to use it, an example that helps you configure your own data model to work similarly. It is totally ok to use your own classes instead.
And in my opinion, it is a good thing to use your own classes: there are less classes to maintain and you have Shiro work with your existing data model rather than forcing you to use new classes and/or interfaces. The Grails plugin creates these things as a convenience to reduce the time it takes for you to get up and running, but you don't need to use them if you don't want to.
Using the ShiroUser class (and even further, using the Nimble plugin, which is built on top of Shiro) is all about convenience - how much do you prefer to use something that already exists (with the caveat that it may not meet all of your needs) vs how quickly do you want to get up and running.
Cheers,
Les
Apache Shiro PMC Chair & Katasoft Inc. Founder:
Application Security Products & Professional Apache Shiro Support and Training:
http://www.katasoft.com
Check out the nimble plugin which does exactly this and more:
http://www.grails.org/plugin/nimble

Resources