Search Results

Search found 9989 results on 400 pages for 'grails controller'.

Page 18/400 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Compare associations between domain objects in Grails

    - by user303979
    I am not sure if I am going about this the best way, but I will try to explain what I am trying to do. I have the following domain classes class User { static hasMany = [goals: Goal] } So each User has a list of Goal objects. I want to be able to take an instance of User and return 5 Users with the highest number of matching Goal objects (with the instance) in their goals list. Can someone kindly explain how I might go about doing this?

    Read the article

  • Grails / GORM, Disable First-level Cache

    - by Stephen Swensen
    Suppose I have the following Domain class mapping to a legacy table, utilizing read-only second-level cache, and having a transient field: class DomainObject { static def transients = ['userId'] Long id Long userId static mapping = { cache usage: 'read-only' table 'SOME_TABLE' } } I have a problem, references to DomainObject are being shared due to first-level caching, and thus transient fields are writing over each other. For example, def r1 = DomainObject.get(1) r1.userId = 22 def r2 = DomainObject.get(1) r2.userId = 34 assert r1.userId == 34 That is, r1 and r2 are references to the same instance. This is undesirable, I would like to cache the table data without sharing references. Any ideas? [Edit] Understanding the situation better now, I believe my question boils down to the following: Is there anyway to disable first level cache for a specific domain class while still using second level cache?

    Read the article

  • Inheritance domain classes in Grails

    - by Tomáš
    Hi gurus how can I get Collection of specific Class? I use inheriance: On Planet live Human. Humans are dividing to Men and Women. class Planet{ String name static hasMany = [ humans : Human ] } class Human{ String name static belongsTo = [Planet] } class Man extends Human{ int countOfCar } class Woman extends Human{ int coutOfChildren } now a neet to get only Collection of Man or Collection of Woman: get all humans on planet is simple all = Planet.get(1).humans but what can I get only woman or men? womenLivedOnMars = Planet.get(1).getOnlyWoman menLivedOnJupiter = Planet.get(2).getOnlyMan Thanks for your help Tom

    Read the article

  • Grails/Hibernate max for string type

    - by bsreekanth
    Hello, In my table I have a serial number field, which is represneted by string.. It has a prefix and some numbers follow. Eg: ABC1234, ABC2345 etc. How to retrieve the largest value (max equivalent of int type) from this column. In my case it would be ABC2345. I probably could retrieve all the data,, sort it and get the same, but that would be slow. thanks in advance..

    Read the article

  • Working with the Grails g:timeZoneSelect tag?

    - by tinny
    I am wanting to use the g:timeZoneSelect tag within my application, problem is im finding the resulting html select to be quite overwhelming. Over 600 options are being displayed, IMHO this is to much to display to the user. Maybe someone could point me to an example of a much more manageable list of timezones? Maybe you have seen a site that does timezone selection well? Im sure over 600 option is "technically" correct, but this will just look like noise to the user. The display value of the timezone is to long. E.g. "CST, Central Standard Time (South Australia/New South Wales) 9.5:30.0" Just "CST, Central Standard Time" or "Australia/Broken_Hill" would be better Is there a way to address these issues via tag attributes of some sort (cant find any in the docs) or config that I am unaware of? Or, is my best bet to wrap an html select within a custom tag lib and "roll my own" solution (Id prefer not to). Thanks

    Read the article

  • grails and flash movie

    - by ziftech
    Is it possibe to insert into GSP simple flash movie? I tried this way: <object type="application/x-shockwave-flash" data="${resource(dir:'flash',file:'movie.swf')}" width="400" height="400"> <param name="movie" value="${resource(dir:'flash',file:'movie.swf')}" /> <param name="bgcolor" value="#ffffff" /> <param name="AllowScriptAccess" value="always" /> <param name="flashvars" value="feed=${resource(dir:'flash',file:'movie.xml')}" /> <p>This widget requires Flash Player 9 or better</p> </object> It seems that movie is loaded but .xml and pictures are not...

    Read the article

  • jasper grails parameters

    I have jasper report which accepts Integer parameter . I am using g:jasperreport tag to call the report . body of this tag has input html which gets passed to report. But's the report is not working. It is giving invalid format exception. Pl. help Thanks in advance. Abe

    Read the article

  • Rolling back a transaction in a Grails Service

    - by UltraVi01
    I have been updating all my services to be transactional by using Grail's ability to rollback when a RuntimeException is thrown in the service. I have, in most cases, doing this: def domain = new Domain(field: field) if (!domain.save()) { throw new RuntimeException() } Anyways, I wanted to verify that this indeed will rollback the transaction... it got me thinking as to whether at this point it's already been committed.. Also, if not, would setting flush:true change that? I am not very familiar with how Spring/Hibernate does all of this :)

    Read the article

  • Testing custom constraints in Grails App

    - by WaZ
    Hi there, I have the following as my unit test: void testCreateDealer() { mockForConstraintsTests(Dealer) def _dealer= new Dealer( dealerName:"ABC", Email:"[email protected]", HeadOffice:"", isBranch:false) assertFalse _dealer.validate() } But when I run the test I get the following error: No signature of method: static com.myCompany.Dealer.findByDealerNameIlike() is applicable for argument types: (java.lang.String) values: [ABC] I use some custom constraints in my domain class. How Can I test this? static constraints = { dealerName(blank:false, validator: { val, obj -> def similarDealer = Dealer.findByDealerNameIlike(val) return !similarDealer || (obj.id == similarDealer.id) } )

    Read the article

  • Documentation about difference between javacript src and javascript library in grails

    - by damian
    I know that if you write in a view: <g:javascript src="myscript.js" /> <g:javascript src="myscript.js" /> <g:javascript src="myscript.js" /> <!-- other try --> <g:javascript library="myscript" /> <g:javascript library="myscript" /> <g:javascript library="myscript" /> It will out output: <script type="text/javascript" src="/vip/js/myscript.js"></script> <script type="text/javascript" src="/vip/js/myscript.js"></script> <script type="text/javascript" src="/vip/js/myscript.js"></script> <!-- other try --> <script type="text/javascript" src="/vip/js/myscript.js"></script> Conclution: with library it will try to include only once. I have been try to find documentation about it without success. Do you have any pointer?

    Read the article

  • How to implement "select sum()" in Grails

    - by xain
    I have a relationship like this: class E { string name hasMany = [me:ME] } class M { float price } class ME { E e M m int quantity } And I'd hate to iterate to achieve this: "obtain the sum of the quantity in ME times the price of the corresponding M for a given E". Any hints on how to implement it using GORM/HQL ? Thanks in advance

    Read the article

  • Grails' GORM constraint question

    - by xain
    Hi, I have the following Domain Class: class Metric { String name float value static belongsTo = [Person,Corporation] static indexes = { name() } } How can I add a constraint so Person,Corporation and name are unique ? Thanks.

    Read the article

  • DynamicJasper(on Grails) Purposefully keep column or field blank(empty)

    - by petejoe
    Hi, I want to generate a pdf report, where a column(or cell/field) is left blank(empty) on purpose. This column actually does have a value but, I'm choosing not to display it. The column title still needs to be displayed. Example of where this could be useful: Blank(empty) column: A comments or notes column down one side of a report. Blank(empty) cell: A sudoku puzzle print-out. Much appreciated. DynamicJasper is Awesome! Thanks to the dj-team. Regards, Pete

    Read the article

  • Grails GORM rarely works in domain classes

    - by Vena
    I have many to many relationship between User and Organization. I want to delete user from all his organizations when the user is being deleted, so this is basically what I came up with: class User { ... def beforeDelete() { def user = User.get(id) Organization.all.each { it.removeFromMembers(user) it.save() } } } This surprisingly doesn't work because User.get(id) returns null even though the user with the given id is in the database, when I look at the log, no sql statement is even executed. So I tried to use load() method insted. ObjectNotFoundException is the result then. So I tried this as I was quite desperate: def user = User.find("from User as u where u.id = ?", [1L]) This, for some reason, works. But now, the line with it.removeFromMembers(user) throws NullPointerException. I tried to put this logic in my UserController and it works! Why is this? Why can't I do this in domain classes? This makes beforeDelete hook (and all the others too) pretty useless.

    Read the article

  • Groovy & Grails Concurrency ( quartz, executor )

    - by Pietro
    What I'm trying to do is to run multiple threads at some starting time. Those threads must stay alive for 90minutes after start. During the 90minutes they execute something after a random sleep time (ex: 5minutes to 15minutes). Here is a pseudo code on how I would implement it. The problem is that doing it in this way the threads run in an unexpected way. How can I implement correctly something like this? Class MyJob { static triggers = { cron name: 'first', cronExpression: "0 30 21 * * FRI" cron name: 'second', cronExpression: "0 30 19 * * FRI" cron name: 'third', cronExpression: "0 30 17 * * FRI" def myService def execute() { switch( between trigger name ) case 'first': model = Model.findByAttribute(...) ... myService.run( model, start_time ) break; ... } } class MyService { def run( model, start_time ) { def end_time = end_time.plusMinutes(90) model.fields.each( field -> Thread.start { executeSomeTasks( field, start_time, end_time ) } ) } def executeSomeTasks( field, start_time, end_time ) { while( start_time < end_time ) { ...do something ... sleep( Random.nextInt( 1000 ) ); } } }

    Read the article

  • Maintaining the position of columns in Grails/GORM

    - by firnnauriel
    Is there a way to fix the position of the columns in a domain? I have this domain: class SnbrActVector { int nid String term double weight static mapping = { version false id(generator: 'assigned') } static constraints = { nid(blank:false) term(blank:false) weight(blank:false) } } This is the schema of the table generated: CREATE TABLE `fractor_grailsDEV`.`snbr_act_vector` ( `id` bigint(20) NOT NULL, `weight` double NOT NULL, `term` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `nid` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci It seems that the order of the columns were reversed. Is there a way to make it like this? (order is nid, term, weight) CREATE TABLE `fractor_grailsDEV`.`snbr_act_vector` ( `id` bigint(20) NOT NULL, `nid` int(11) NOT NULL, `term` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `weight` double NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

    Read the article

  • Grails UnitTest

    - by Tomáš
    Hi (it is propably stupid question) how can acquire Domain class from database in test? class PollServiceTests extends GrailsUnitTestCase { Integer id = 1 void testSomething() { Teacher teacher1 = Teacher.get(id) assert teacher1 != null } } I always get null or No signature of method: cz.jak.Teacher.get() is applicable for argument types: (java.lang.Integer) values: [1] thanks a lot Tom

    Read the article

  • How to implement Voting for Grails Domain Classes?

    - by userWebMobile
    I have a Book class and need to implement a yes/no voting functionality. My domain classes look like this: class Book { String title static hasMany = [votes: Vote] } class User { String name static hasMany = [votes: Vote] } class Vote { boolean yesVote static belongsTo = [user: User, book: Book] } What is the best way to implement a voting for the book class. I need the following informations: What is the average yesVote for a book over all votes (either yes or no)? How to check if a specific user has done a vote? What is the best way to implement the computation of the average yesVote such that the performance does not drop?

    Read the article

  • Hibernate's version values in Grails app

    - by xain
    I'm looking at a database dump file, and I see many records in various tables with their version number set in values other than 0 (even 94 in one case). I understand it has to do with hibernate locking strategy, but my concern is that today is Sunday, and the site has almost no visitors so is: is this normal ? Or is there a known hibernate bug or even some programming malpractice producing this ?

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >