grails

grails criteria :How to select all columns in mysql and at the same time format the date then use like

青春壹個敷衍的年華 提交于 2020-01-07 07:22:12
问题 I'm currently creating a search functionality for my page. The data will be coming from DB. In the HTML, the date is displayed in this format dd/mm/yyyy . What I want to do is, in the select query, I want to select the all columns and the date should be displayed using that format and I have a a couple of like conditions that will be used to check if there is a match. How will I select all column, format date and at the same time check for all matches using one single statement in criteria?

Grails named queries: find parents of child A and child B

落爺英雄遲暮 提交于 2020-01-07 06:42:12
问题 I have this: class Parent { String name static hasMany = [children: Child] } class Child { String name } And I want to find all the parents that have a child named "Tom" and another one named "Sam". id | parentName --------------- 1 | Peter 2 | Joe 3 | Ann id | childName --------------- 1 | Tom 2 | Sam idParent | idChild --------------- 1 | 1 2 | 2 3 | 1 3 | 2 In the example, it will be Ann. I've tried this: static namedQueries = { findParents{nameList -> children{ nameList.each{childName->

Grails form creation for many-to-one belongsTo

若如初见. 提交于 2020-01-07 06:38:30
问题 I am a beginner in grails and I have a basic question. I want to display a list of instances of a parent class in the child class form creation. My Domain class are as follows. The Parent class is the Company. class Company { String name static constraints = { name(blank:false) } String toString(){name} } My Child Class is the Location of the company. class Location { String name String address static belongsTo= {companyLocation:Company} static constraints = { name(blank: false) address blank

Grails changing datasource at runtime

回眸只為那壹抹淺笑 提交于 2020-01-07 06:14:23
问题 I was asked to implement a logic for having separate domains for a separate user (assuming he will have his own database) means all the domains will be mapped to different database at runtime. Sounds silly i know How can i change the datasouce(persistence configuration file) after logIn of user while datasource are supposed to load at startup time of application. Is it possible somehow? NOTE: I want to change datasource of some domain to another datasource at runtime one at a time. 回答1: You

Why is Grails hasMany List size wrong?

寵の児 提交于 2020-01-07 05:04:10
问题 I have a domain object Parent that has a hasMany relationship implemented as a List. I am getting an incorrect size of List returned and I don't know why: class Parent { List children static hasMany = [children : Child, otherHasMany : SomeOtherChildClass] static mapping = { children lazy: false } } def parent = Parent.get(someId) // parent is returned as a result of a query def numChildren = parent.children.size() I am getting a lot of null values interspersed amongst the correct Children

Grails 2.2.1 app cannot resolve dependencies

随声附和 提交于 2020-01-07 04:50:50
问题 I am running into problems setting up an existing grails (2.2.1) project on a new mbp. I get dependency resolution errors whenever I try to run any grails command. It seems that it cannot resolve any grails plugins that are marked with the compile phase like below. compile ":cache:1.0.0" I've taken a look at the org.grails.plugins repository to make sure the plugins exist, and they all appear to be there. I cannot for the life of me figure out why it cannot resolve these plugins. A coworker

Resource not found on grails application with cache plugins

戏子无情 提交于 2020-01-07 03:42:07
问题 I have installed cache-header (1.0.4) and cached-resources (1.0) in our grails application and once in a while we receive messages like the one below. Do you have any clue on why do we get those messages and how can we fix it? Regards 2013-09-24 04:21:34,561 [catalina-exec-2] ERROR resource.ResourceMeta - CENTRALLEAD - Resource not found: /LNEjLROINsk9TKAzkAwtTxIXru6CyGZP4s5w1mybXkD.js 2013-09-24 04:21:30,030 [catalina-exec-5] ERROR resource.ResourceMeta - CENTRALLEAD - Resource not found:

Grails : Edit (form: multipart) file (from client) and send it back to the client

强颜欢笑 提交于 2020-01-07 03:08:07
问题 This is what I need to do. 1) Accept an xlsx/xls file from client. 2) Backend will receive it in the form of multipart file 3) The file will be processed and if the format of the data is invalid, that same file will be updated and the error message will be written in the side of the input of the client. 4) this modified file will be sent back to the user. So far this is what i've done. def generateErrorReport(ServletResponse response, Map messageCollections, MultipartFile file, String ext){

Grails query - can't access join table

妖精的绣舞 提交于 2020-01-07 03:01:15
问题 I want to make a list of all the SAMPLE_PARAMETERS that belong to a SAMPLE_TYPE. I have two classes: A Sample_type and a Sample_parameter. There is also a join table which grails automagically made that lists all the ids of the type/parameters called Sample_Type_Sample_Parameters. I am trying to make a list of all the parameters that belong to a certain type, but cannot figure out how to access the join table. Can I use withCriteria? if so, how would one go about doing so? In pseudo-code: For

Groovy @CompileStatic and Grails

放肆的年华 提交于 2020-01-07 02:36:15
问题 Looking at article on DZone about improved performance with Groovy2 when compiling with @CompileStatic annotation, I wonder to what extent can I take advantage of it? I'm guessing annotate controllers, domain objects and services? Does Grails take advantage of it by default when app gets compiled? Link to article. 回答1: Current Grails version (2.1) run groovy 1.8.x In Grails web you can see the roadmap, where Groovy 2.x integration is featured http://grails.org/Roadmap 回答2: As of December 20th