History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILS-2775
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Graeme Rocher
Reporter: Daniel.Sun
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Grails

The gsp generated through scaffold are not correct when the id generator is 'assigned'

Created: 03/Apr/08 07:29 AM   Updated: 29/Sep/08 04:52 PM
Component/s: Scaffolding
Affects Version/s: 1.0.2
Fix Version/s: 1.0.4

Time Tracking:
Not Specified


 Description  « Hide
The gsp generated through scaffold are not correct when the id generator is 'assigned'

the gsp such as create.gsp does not contain the field related to id.

for example,

class Book {
   id generator:'assigned', column:'isdn'
}

I think the create.gsp should contains some field such as 'isdn' to let users to fill in.
If no such field offered, hibernate will complain no id assigned manually.

The elegant solution I think for customized id is:

class Book {
   String isdnOfBook
   id generator:'assigned', column:'isdn', property:'isdnOfBook'
}

If the parameter named 'property' is present in the 'id dynamic method',
the id property will not auto created by Grails, and Grails will see the isdnOfBook as id.

Cheers,
Daniel.Sun



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Daniel.Sun - 03/Apr/08 07:31 AM
the code
id generator:'assigned', column:'isdn', property:'isdnOfBook'

should be placed in the mapping closure as the following:

class Book {
   String isdnOfBook
   static mapping = {
      table 'BOOK'
      id generator:'assigned', column:'isdn', property:'isdnOfBook'
   }
}

Andres - 29/Sep/08 04:52 PM
yeahh this is kind of painful specially if you are trying to build an app fast.
I like your solution.