grails-2.0

Grails: Raw SQL query in the current transaction

左心房为你撑大大i 提交于 2019-12-03 17:22:38
I am trying to execute a raw sql query using something similar to def dataSource; Sql sql = new Sql(dataSource); But, it seems that this runs in a separate transaction of its own. It therefore misses all the (uncommitted) changes done before it in the service method. What is the best way to run a raw sql query in the current transaction? The above code would create a new connection, hence a new transaction. You can use the current Hibernate session(injecting sessionFactory) to execute a raw sql in the current transaction as below. def session = sessionFactory.getCurrentSession() def results =

Intelligent folder structure for grails 2.3.4 in combination with angular js

强颜欢笑 提交于 2019-12-03 14:12:36
What would be an intelligent folder structure for grails 2.3.4 in combination with angularjs without using the grails angularjs plugin? Currently I have packed everything into the webapp folder. There are many ways to organize your directories, however, the way we are using, which I'm gonna call it Grailsy way and to some extent is consistent with Grails directory structure is as follow: web-app css js | lib | ng-app | controllers - abcController.js | directives - directives.js | filters - filters.js | services - dataServices.js | views - someHtml.html | app.js the lib has all the angular

Is performance of Grails 2.0 really that awfully low?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 12:27:48
问题 I'm somewhat newbie for WEB development based on JVM stack, but future project will require specifically some JVM-based WEB engine. So I started looking on some ground to make things quickly and turned to try Grails. Things looked good from the book, but beeing impressed by really long startup time (grails run-app) I decided to test how this works under load. Here it is: test app: follow few instruction here to make it from ground (takes 2 mins assuming you already have Grails and Tomcat

dateCreated, lastUpdated fields in Grails 2.0

落花浮王杯 提交于 2019-12-03 12:17:14
I've got an application that was using Grails 1.3.7 which I've just migrated to Grails 2.0. The application makes use of the automatic dateCreated and lastUpdated fields to manage the timestamps associated with creation and modification of the objects. After upgrading, I get the following error: | Running Grails application | Error 2012-01-29 22:36:53,504 [Thread-8] ERROR util.JDBCExceptionReporter - ERROR: null value in column "date_created" violates not-null constraint | Error 2012-01-29 22:36:53,510 [Thread-8] ERROR events.PatchedDefaultFlushEventListener - Could not synchronize database

Grails and Subdomains

有些话、适合烂在心里 提交于 2019-12-03 11:04:29
问题 Does Grails know anything about sub-domains (i.e. subdomain.domain.com) ? I don't see it discussed in the manual. Is this purely an app server/web server issue? Can be tied into grails controllers, either statically or dynamically? 回答1: It does not matter which host is accessed for a java web application. Supposing you have multiple clients separated on one host, e.g. customer1.yourhost.com, customer2.yourhost.com, etc. and all clients will have same functionalities. In the simplest case I

Grails 2.3.4 - Error executing script Clean: _GrailsClasspath_groovy$_run_closure1

£可爱£侵袭症+ 提交于 2019-12-03 10:52:24
问题 I am using eclipse kepler and after shutting down my computer and turning it on again I am getting this error message: grails run-app --stacktrace |Loading Grails 2.3.4 |Configuring classpath . |Environment set to development .Error | Error executing script RunApp: _GrailsClasspath_groovy$_run_closure1 (NOTE: Stac k trace has been filtered. Use --verbose to see entire trace.) java.lang.NoClassDefFoundError: _GrailsClasspath_groovy$_run_closure1 at _GrailsClasspath_groovy.run(_GrailsClasspath

how to use session in grails

只谈情不闲聊 提交于 2019-12-03 09:41:04
问题 I am new to grails. And I have to work with session. I have seen the session documentation. But no idea where to put the code in my controller. I have a page for student creation names createStudent. Now I want that this page only be access able when the user will be in session. Now how can I do it. Should I have to set the user in a variable at the time of login. Can anyone please help me on this ? def index() { def user = session["user"] if (user){ redirect(controller: 'admistratorAction',

Fastest way to read/write Images from a File into a BufferedImage?

て烟熏妆下的殇ゞ 提交于 2019-12-03 06:59:07
What is the fastest way to read Images from a File into a BufferedImage in Java/Grails? What is the fastest way to write Images from a BufferedImage into a File in Java/Grails? my variant (read): byte [] imageByteArray = new File(basePath+imageSource).readBytes() InputStream inStream = new ByteArrayInputStream(imageByteArray) BufferedImage bufferedImage = ImageIO.read(inStream) my variant (write): BufferedImage bufferedImage = // some image def fullPath = // image page + file name byte [] currentImage try{ ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write( bufferedImage,

In Grails, how do I display validation error messages next to the fields?

ぃ、小莉子 提交于 2019-12-03 05:12:31
The Grails 2.0.4 documentation for validation shows you how to display error messages at the top of the page and how to add a css class to an element if a field is invalid, but it doesn't tell you how to display the error message next to the fields themselves, something like this: ----------------------- Name: | | You must enter a name! ----------------------- How do you retrieve the specific error message for an invalid field and then display it next to the field it's for? Actually, the documentation does show how to do this, it just isn't overly clear that this is what they mean: <g

Is performance of Grails 2.0 really that awfully low?

浪子不回头ぞ 提交于 2019-12-03 02:02:14
I'm somewhat newbie for WEB development based on JVM stack, but future project will require specifically some JVM-based WEB engine. So I started looking on some ground to make things quickly and turned to try Grails. Things looked good from the book, but beeing impressed by really long startup time (grails run-app) I decided to test how this works under load. Here it is: test app: follow few instruction here to make it from ground (takes 2 mins assuming you already have Grails and Tomcat installed): _http://grails.org/Quick+Start test case (with Apache benchmark - comes with Apache httpd -