grails-2.0

Using assigned ID for domain object in Grails 2.0

邮差的信 提交于 2019-12-25 08:48:09
问题 We are using Grails with a legacy database and we need to control how ID's get assigned to domain objects. We have tried: id column: "sco_id", generator:'assigned' but we get the exception: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 we have also tried to create a custom ID generator: public class ScoIdGenerator implements IdentifierGenerator { public Serializable generate(SessionImplementor session, Object object) { /*Generate ID here*/ return

Error in Declaration of service within Grails service

偶尔善良 提交于 2019-12-25 02:44:28
问题 I have concerns about the use of Services within other Services. Some work, but others don't. The problem is that I can't figure out what's wrong. When you add a service that generates the error always occurs the same problem, then I withdraw the reference to service problematic and the system returns to normal. I wonder if the same is effecting any circular reference creating instability. class UserService { def terceirizadoService def unidadeService def grailsApplication def

Uploading photos using Grails Services

 ̄綄美尐妖づ 提交于 2019-12-25 02:27:08
问题 I would like to ask, What would be the most suitable scope for my upload photo service in Grails ? I created this PhotoService in my Grails 2.3.4 web app, all it does is to get the request.getFile("myfile") and perform the necessary steps to save it on the hard drive whenever a user wants to upload an image. To illustrate what it looks like, I give a skeleton of these classes. PhotoPageController { def photoService def upload(){ ... photoService.upload(request.getFile("myfile")) ... } }

How to limit the size of association in grails?

醉酒当歌 提交于 2019-12-25 01:45:40
问题 I have a grails domain class as below : class Order { String orderId = 'OD' + System.nanoTime().toString() Date orderedDate String itemName List bids; static hasMany = [ bids: Bid ;likedUsers: User,] static belongsTo =[owner:User] } class Bid { Integer amount User bidedUser static belongsTo = [Order] } class User { String username String password String emailId List orders static hasMany = [orders:Order] } What I am trying to do is , to query for an order with bits with maxResult of 10 as

Spock @Unroll annotation

放肆的年华 提交于 2019-12-24 03:50:42
问题 During a recent code review, the question came up regarding whether the @Unroll annotation belongs at the class level or the method level. The class in question requires @Unroll on most of its methods but not all of them. Does declaring @Unroll incur any performance penalties if declared at the class level and not all methods of the class require it? 回答1: The @Unroll annotation is intended to be used on the method level. But it can also be used on the class level as indicated in the Unroll

Grails 2 app wont deploy on JBOSS: BeanCreationException

半城伤御伤魂 提交于 2019-12-24 01:51:02
问题 After having upgraded one of my apps from Grails 1.3.7 to 2.1.0 and installed a couple of additional plugins the app will no longer deploy on JBOSS AS 5.1, which is used for production. The error I am getting from the JBOSS server log is the following: 13:39:10,263 ERROR [[/]] Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean

Does the multiple datasource feature of Grails 2.0 support relations?

六月ゝ 毕业季﹏ 提交于 2019-12-24 00:19:37
问题 I'm trying to support some legacy tables and I was able to create a domain that uses a separate datasource of those legacy tables. However, when I try to use that domain from the separate datasource in a hasMany , it fails. Is it possible to relate hasMany to a domain on a different datasource? 回答1: Unfortunately you can not have GORM automatically manage the association across multiple datasources. However, that said you can quite easily write the code that will accomplish what you are

GORM Relations without dependent delete

爱⌒轻易说出口 提交于 2019-12-23 13:06:13
问题 I have two domain classes User and Node. The following conditions should hold. a User can have zero or one node a Node can have one to n User (it is always initialized with a User instance) if you delete a Node the User will not be deleted if you delete a User the reference in the Node will be deleted I tried: class User { Node node } class Node { // constructor Node(User user) { addToUsers(user) save() } hasMany = [users: User] } The former does not work. It does not work because when you

Grails - Error creating and mapping a view

点点圈 提交于 2019-12-23 12:25:05
问题 I have created a view with the name signIn.gsp . I put it into the URLMapping.groovy with: class UrlMappings { static mappings = { "/$controller/$action?/$id?(.${format})?"{ constraints { // apply constraints here } } "/"(view:"/index") "signIn"(view:'/signIn') "500"(view:'/error') } } I also added it to the spring security part in the Config.groovy : // Added by the Spring Security Core plugin: grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.testApplication

Grails (iOS specific): Returning video (mp4) file gives Broken Pipe exception (getOutputStream() has already been called for this response)

怎甘沉沦 提交于 2019-12-23 05:32:17
问题 I'm trying to return an mp4 file from my Grails controller so that it can be played in the browser. The following is the simplest version of what I have: def file = new File(<path to mp4 file>) response.outputStream << file.newInputStream() The strange thing is that this works when hitting it from a desktop (Chrome on my MacBook), works on an Android phone, but does not work on an iPad Air. The one header that's different in the iOS request is for "range" of "0-1", but it looks like that