logo
down
shadow

grails GORM or statement


grails GORM or statement

By : user2950500
Date : November 17 2020, 11:55 AM
wish help you to fix your issue Grails doesn't know you want to use the same search parameter for both tests, it expects to see one argument for the NameIlike and a second argument for the DescriptionILike:
code :
Item.findAllByNameIlikeOrDescriptionIlike(search, search)


Share : facebook icon twitter icon
Technical reasons not to set grails.gorm.autoFlush and grails.gorm.failOnError to true in Config.groovy?

Technical reasons not to set grails.gorm.autoFlush and grails.gorm.failOnError to true in Config.groovy?


By : user2632855
Date : March 29 2020, 07:55 AM
it fixes the issue GORM is a wrapper around Hibernate (at least that's one of the implementations - there are now also various NoSQL implementations like Redis). By setting autoFlush to true you're denying Hibernate the opportunity to optimise the calls it makes to the database. For example, you may cause it to insert then later update, when a single insert might have been sufficient. There's nothing inherently bad about that, it's just not necessary and is less efficient. Hibernate is clever enough to know when it needs to write to the database and can optimise - you've abstracted away that problem.
Setting failOnError would cause save to throw an exception whenever you try to save a domain object that doesn't validate. When building an application which involves creating objects from user input it's pretty normal for objects not to validate - missing inputs, wrong formats, etc. Exception handling should be saved for exceptions and errors - it shouldn't be used for normal flow of an application. save() returns the object when the object was successfully saved or null otherwise, which gives you a more convenient way to handle validation as part of the application flow, rather than putting try-catch blocks all over the place.
Grails - How to cache service method with grails.gorm.DetachedCriteria as parameter?

Grails - How to cache service method with grails.gorm.DetachedCriteria as parameter?


By : Chris
Date : March 29 2020, 07:55 AM
I wish this help you Focus of this question should be towards the parameter of function, DetachedCriteria. There is no way, (as far as i know) that a DetachedCriteria be used as a key.
Luckily for me, i had another object 'UserCriteria'(this is a custom object, that i created) which was used to create DetachedCriteria. so i updated the method so that it would accept my 'UserCriteria' object as parameter. Shown below
code :
@Cacheable(value='userTotalCountCache', key='#userCriteria.toString()')
public int count(UserCriteria userCriteria) throws Exception {
    DetachedCriteria detachedCriteria = getDetachedCriteria(userCriteria);
    return detachedCriteria.count();
}
Grails + GORM: What is the default equals() implementation in GORM?

Grails + GORM: What is the default equals() implementation in GORM?


By : jcchin
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further First, you need to understand that GORM/Grails doesn't do anything special when it comes to equals(). Unless you implement your own equals() on your domain class it will default to the Java/Groovy implementation. Which by default means the variables must point to the same instance.
Now, what gets slightly confusing is Hibernate. Hibernate uses an identity map (the first-level cache); when you fetch the same domain instance from GORM, Hibernate will actually return the same instance from the cache the second time. Thus making the two variables point to the same instance and appear as equal.
code :
def something = Something.get(1)
def somethingElse = Something.get(1)
assert (something == somethingElse) // true
something.name = 'I changed this'
assert (something == somethingElse) // still true
something.id = 123 // no idea why you would EVER do this
assert (something == somethingElse) // still true
assert (something.id == somethingElse.id) // true, since it's the same instance!
assert (something.name == somethingElse.name) // true, since it's the same 
Problems with grails.gorm.TestCriteriaBuilder when upgrading from Grails 2.4.4 to Grails 2.5.0

Problems with grails.gorm.TestCriteriaBuilder when upgrading from Grails 2.4.4 to Grails 2.5.0


By : user3853070
Date : March 29 2020, 07:55 AM
it helps some times I ran into the same exception when executing unit test after upgrading my application from 2.4.3 to 2.4.5. I manually added the package in the BuildConfig with test scope:
code :
runtime 'org.grails:grails-datastore-gorm:3.1.4.RELEASE'
Grails 3 + IntelliJ: Running integration tests yields "No GORM implementations configured. Ensure GORM has been ini

Grails 3 + IntelliJ: Running integration tests yields "No GORM implementations configured. Ensure GORM has been ini


By : Alex Black
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I found a "fix", sort of.
I edited the @IntegrationTest annotation on my test class from:
code :
@Integration
@Integration(applicationClass = Application.class)
CompilerConfiguration configuration = new CompilerConfiguration()
configuration.setTolerance(1)

println new File("src/integration-test/groovy/my/package/Mytest.groovy").isFile()
// true

def source = new SourceUnit(
    new File("src/integration-test/groovy/my/package/MyTest.groovy"),
    configuration,
    null,
    new ErrorCollector(configuration))

println source
// org.codehaus.groovy.control.SourceUnit@19bbb216
println source.source
// org.codehaus.groovy.control.io.FileReaderSource@6cfac0bd
println source.source.URI
// file:/path/to/my/app/src/integration-test/groovy/my/package/MyTest.groovy
println MainClassFinder.searchMainClass(source.source.URI)
// null
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org