http://www.intelligrape.com/blog/2010/09/07/how-to-map-database-table-without-id-with-grails-domain/
How to Map database table without id with grails domain
Recently I got a query regarding mapping a database table
which do not have any id and version. For example the table have two
varchar fields username and password nothing more than that.
Although it was something strange for me that table doesn’t have the id
field. The good thing is that the username is a primary key in the table
and this is not auto incremented user want to create it by his own
method.
The good thing about grails is, in most of the cases you get your answer in the docs http://grails.org/doc/latest/
. So in this case we just need to change the id field in grails domain like this
class
Test {
String
username
String
password
static
mapping =
{
id name: 'username'
version false
id generator: 'assigned'
}
static
constraints =
{
username(
nullable: true
)
}
}
and we are done
.
Hope it helps
## Uday Pratap Singh ##
uday@intelligrape.com
http://www.IntelliGrape.com/
http://in.linkedin.com/in/meudaypratap
分享到:
相关推荐
"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, Tropicana, and Taco Bell are all using Grails. Are you ready to get started ...
Getting Started with Grails
Ajax Development With Grails Dojo www.grails-exchange.com © Sven Haiges, Yahoo! Inc. GRAILS & DOJO 3 Goals You know how to get started! You know how AJAX is supported by Grails Tags, Libraries...
We’ll see how Grails allows us to use powerful frameworks like Spring and Hibernate without even knowing it. Using this hands-on, pragmatic approach, we’ll explore topics such as AJAX in Grails, ...
详细介绍grails框架的奥秘,英文版你值得拥有
非常好的grails教材, 建议grails程序员参考
getting started with grails chinese Grails入门指南书籍和源码----下载不扣分,回帖加1分,欢迎下载,童叟无欺 getting started with grails chinese Grails入门指南书籍和源码----下载不扣分,回帖加1分,欢迎...
Grails Grails Grails Grails Grails
How to use Acegi on Grails using Grails Domain class Beans to support Acegi on Grails Grails Acegi Plugin Setting up Acegi Plugin Secure your Ajax Secure your Service
The definitive guide to grails 2 英文版 书和随书代码, 学习grails必备
Grails权威指南Grails权威指南Grails权威指南Grails权威指南Grails权威指南Grails权威指南
Getting-Started-with-Grails-Chinese,一本不错的grails入门书籍,希望对有志于grails的朋友们有用。
Apress.Beginning.Groovy.and.Grails.From.Novice.to.Professional.Jun.2008 grails_programming Grails1.1中文文档-----2009.3.25 Grails入门指南(第二版) Groovy经典入门 Programming Groovy 2 合集,超实惠哦
Grails Persistence with GORM and GSQL
Agile Development with Groovy and Grails.pdf
Grails1.1中文文档
grails-2.1.zip.001