Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0-RC2, 2.0-RC3, 2.0.1
-
Fix Version/s: 2.2-RC3
-
Component/s: Persistence
-
Labels:
-
Environment:Java 6.0.29, Win 7
Description
Trying to achieve the following:
I have:
class Entry {
String value
static mapping = {
id generator:'assigned'
}
...
}
Now I'd like to do the following:
Entry entry = Entry.findOrSaveWhere(id:key, value:value);
But this raises:
org.springframework.orm.hibernate3.HibernateSystemException: ids for this class must be manually assigned before calling save()
This is probably due to the fact that "id generator:'assigned'" for
the Entry class but it is a bit strange that the id cannot be specified in the
constructor (not sure if this holds in general). Please improve this.
If it worked, it would really improve readability and potentially even
avoid an additional save() which is required when doing:
Entry entry = Entry.findOrCreateWhere(id:key, value:value) entry.id = key entry.save()
Issue Links
- is related to
-
GRAILS-1984
id initialization on constructor when generator is assigned
-
Activity
Graeme Rocher
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 2.0.1 [ 13005 ] | |
| Fix Version/s | 2.1 [ 12801 ] |
Burt Beckwith
made changes -
| Summary | Allow the specification of ids in the constructor | Allow the specification of ids in findOrSaveWhere |
| Description |
Trying to achieve the following:
I have: class Entry{ String value; static mapping = { id generator:'assigned' } ... } Now I'd like to do the following: Entry entry = Entry.findOrSaveWhere(id:key, value:value); But this raises: org.springframework.orm.hibernate3.HibernateSystemException: ids for this class must be manually assigned before calling save() This is probably due to the fact that "id generator:'assigned'" for the Entry class but it is a bit strange that the id cannot be specified in the constructor (not sure if this holds in general). Please improve this. If it worked, it would really improve readability and potentially even avoid an additional save() which is required when doing: Entry entry = Entry.findOrCreateWhere(id:key, value:value); entry.id = key; entry.save(); |
Trying to achieve the following:
I have: {code} class Entry { String value static mapping = { id generator:'assigned' } ... } {code} Now I'd like to do the following: {code} Entry entry = Entry.findOrSaveWhere(id:key, value:value); {code} But this raises: {code} org.springframework.orm.hibernate3.HibernateSystemException: ids for this class must be manually assigned before calling save() {code} This is probably due to the fact that "id generator:'assigned'" for the Entry class but it is a bit strange that the id cannot be specified in the constructor (not sure if this holds in general). Please improve this. If it worked, it would really improve readability and potentially even avoid an additional save() which is required when doing: {code} Entry entry = Entry.findOrCreateWhere(id:key, value:value) entry.id = key entry.save() {code} |
Jeff Brown
made changes -
| Assignee | Jeff Brown [ brownj ] |
Jeff Brown
made changes -
| Attachment | grails8422.zip [ 17121 ] |
Fat Zopilot
made changes -
| Attachment | grails8422.zip [ 17139 ] |
Fat Zopilot
made changes -
| Status | Open [ 1 ] | Edit [ 10000 ] |
| Affects Version/s | 2.0-RC3 [ 13019 ] | |
| Environment | Java 6.0.29, Win 7 |
Burt Beckwith
made changes -
| Workflow | Grails2 [ 70912 ] | jira [ 71587 ] |
| Status | Edit [ 10000 ] | Open [ 1 ] |
Burt Beckwith
made changes -
| Workflow | jira [ 71587 ] | Grails2 [ 80344 ] |
Peter Ledbrook
made changes -
| Last Reviewed | 01/Jan/10 |
Peter Ledbrook
made changes -
| Workflow | Grails2 [ 80344 ] | jira [ 88271 ] |
Peter Ledbrook
made changes -
| Workflow | jira [ 88271 ] | Grails2 [ 96483 ] |
Graeme Rocher
made changes -
| Fix Version/s | 2.0.2 [ 13064 ] | |
| Fix Version/s | 2.0.1 [ 13005 ] |
Fat Zopilot
made changes -
| Status | Open [ 1 ] | Edit [ 10000 ] |
| Issue Type | Improvement [ 4 ] | Bug [ 1 ] |
| Affects Version/s | 2.0.1 [ 13005 ] |
Raviteja
made changes -
| Status | Edit [ 10000 ] | Open [ 1 ] |
Jeff Brown
made changes -
| Issue Type | Bug [ 1 ] | Improvement [ 4 ] |
Graeme Rocher
made changes -
| Fix Version/s | 2.0.3 [ 13094 ] | |
| Fix Version/s | 2.0.2 [ 13064 ] |
Graeme Rocher
made changes -
| Fix Version/s | 2.0.4 [ 13099 ] | |
| Fix Version/s | 2.0.3 [ 13094 ] |
Graeme Rocher
made changes -
| Fix Version/s | 2.1 [ 13117 ] | |
| Fix Version/s | 2.1-RC1 [ 12801 ] |
Graeme Rocher
made changes -
| Fix Version/s | 2.1 [ 13125 ] | |
| Fix Version/s | 2.1-RC2 [ 13117 ] |
Jeff Brown
made changes -
| Fix Version/s | 2.2 [ 13093 ] | |
| Fix Version/s | 2.0.4 [ 13099 ] |
Graeme Rocher
made changes -
| Fix Version/s | 2.1 [ 13125 ] |
Graeme Rocher
made changes -
| Fix Version/s | 2.3 [ 13311 ] | |
| Fix Version/s | 2.2-RC1 [ 13093 ] |
Jeff Brown
made changes -
| Link |
This issue is related to |
Jeff Brown
made changes -
| Status | Open [ 1 ] | Closed [ 6 ] |
| Fix Version/s | 2.2 [ 13324 ] | |
| Fix Version/s | 2.3 [ 13311 ] | |
| Resolution | Fixed [ 1 ] |
Fat,
Can you take a look at the attached project and let me know if this works for you. This is an RC3 app but I see the same behavior in RC2.
Note that BootStrap is invoking findOrSaveWhere twice.
Let me know if this works for you.
Thanks for the help.