楼主: jieforest

SpringSource发布 Grails 1.2 最终版

[复制链接]
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
11#
 楼主| 发表于 2009-12-24 22:47 | 只看该作者
Named Query Support

GORM now supports defining named queries in a domain class. For example, given a domain class like this:

class Publication {
   String title
   Date datePublished

   static namedQueries = {
       recentPublications {
           def now = new Date()
           gt 'datePublished', now - 365
       }

       publicationsWithBookInTitle {
           like 'title', '%Book%'
       }
   }

}

You can do:

// get all recent publications
def recentPubs = Publication.recentPublications.list()

// get up to 10 recent publications, skip the first 5…
def recentPubs = Publication.recentPublications.list(max: 10, offset: 5)

// get the number of recent publications…
def numberOfRecentPubs = Publication.recentPublications.count()

// get a recent publication with a specific id…
def pub = Publication.recentPublications.get(42)

// dynamic finders are supported
def pubs = Publication.recentPublications.findAllByTitle('Some Title')

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
12#
 楼主| 发表于 2009-12-24 22:47 | 只看该作者
Support for SQL restriction in criteria builder

The criteria builder now supports arbitrary SQL expressions:

def c = Person.createCriteria()

def peopleWithShortFirstNames = c.list {
    sqlRestriction "char_length( first_name ) <= 4"
}

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
13#
 楼主| 发表于 2009-12-24 22:48 | 只看该作者
Support for hasOne mapping

GORM now supports hasOne mapping where the foreign key is stored in the child instead of the parent association. For example:

class Person {
        String name
        static hasOne = [address: Address]
}
class Address {
        String street
        String postCode
}

In the above case a foreign key column called person_id will be created in the address table rather than the default where an address_id is created in the person table.

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
14#
 楼主| 发表于 2009-12-24 22:48 | 只看该作者
Strict Validation Errors

There is a new failOnError argument available on the save() method that will throw an exception if a validation error occurs:

try {
     book.save(failOnError:true)
}catch(ValidationException e) {
   // handle
}

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
15#
 楼主| 发表于 2009-12-24 22:48 | 只看该作者
Improved support for annotated entities

You can now use annotated entities instead of the GORM syntax inside domains located in @grails-app/domain@. These entities can use Grails constraints and events just like normal GORM entities for those who prefer annotations over GORM syntax:

import javax.persistence.*

@Entity
@Table(name = "animal")
class Animal {

  @Id @GeneratedValue
  int id
  String name
  @ManyToOne
  @JoinColumn
  Owner owner


  static constraints = {
        name blank:false
  }
}

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
16#
 楼主| 发表于 2009-12-24 22:48 | 只看该作者
Precompilation of Groovy Server Pages in WAR deployment

GSPs are now pre-compiled when producing a WAR file meaning less permgen space is used at deployment time for Grails applications.

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
17#
 楼主| 发表于 2009-12-24 22:48 | 只看该作者
Improved handling of i18n class and property names

You can now put entries in your i18n messages.properties file for all class and property names in your application. For example:

book.label = Libro
book.title.label = Título del libro

These are then picked up by Grails' default error messages and scaffolded views.

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
18#
 楼主| 发表于 2009-12-24 22:49 | 只看该作者
Tomcat & Multiple Embedded Containers Supported

Grails now supports multiple embedded containers with Tomcat being the default. Grails will by default install the Tomcat plugin into your application. You can easily switch containers by switching plugins:

grails uninstall-plugin tomcat
grails install-plugin jetty

The Tomcat plugin comes with built in remote deployment commands:

grails tomcat deploy
grails tomcat undeploy

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
19#
 楼主| 发表于 2009-12-24 22:49 | 只看该作者
Web Flow as a plugin

Grails' support for Spring Web Flow has been extracted into a plugin. To install simply type:

grails install-plugin webflow

If you are migrating from older versions of Grails and use Web Flow you will need to run the above command. If you don't wish to use Web Flow in your application you can uninstall it:

grails uninstall-plugin webflow

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
20#
 楼主| 发表于 2009-12-24 22:49 | 只看该作者
New Web Flow Events

Grails' Web Flow DSL now supports more of the common Web Flow events such as onEntry@, @onRender and so on:

def searchFlow = {
            onStart {
                println "started"
            }
            onEnd {
                println "ended"
            }

            displaySearchForm {
                onRender {
                    println "rendering"
                }
                onEntry {
                   println  "entered"
                }
                onExit {
                    println "exited"
                }

                on("submit") {
                    [results: Book.findAllByTitle(params.title)]
                }.to "displayResults"

            }
            displayResults()
}

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表