|
Hello, I'm new to grails. I'm using DB2 express-C database and an the simpliest example from Grails in Action book. I get always the same Runtime Exception when I try to insert values from a form using scaffolding:
Error 500:
org.springframework.orm.hibernate3.HibernateSystemException: The database
returned no natively generated identity value; nested exception is
org.hibernate.HibernateException: The database returned no natively generated
identity value Servlet: grails URI: /hubbub/grails/profile/save.dispatch Exception Message: The database returned no natively generated identity value Caused by: org.springframework.orm.hibernate3.HibernateSystemException: The database returned no natively generated identity value; nested exception is org.hibernate.HibernateException: The database returned no natively generated identity value Class: script1253120408390 I don't have any idea why I get this runtime error. I know that is DB2 specific because when using with hsqldb works fine. Any one could help me??
Thanks in advance.
|
|
This post was updated on .
Hello Salvador,
I'm also new to Grails, and having the same issue. I wish I could just tell you to naviagate to "Hosting Grails to Your Legacy DB" ( http://jasonrudolph.com/blog/2006/06/20/hoisting-grails-to-your-legacy-db/ ), because Mr. Rudolph addresses this issue exactly. Unfortunately, it seems to be dated, and the code can't look like that anymore. I tried to copy this approach and this is how far I have gotten.
Modify DataSource.groovy:
dataSource {
Modify Employee.groovy:
class Employee {
Finally, add this to create.gsp (in the view/employee directory. I placed it just before the section for firstName)
<tr class="prop">
Now it all works up to the point where Mr. Rudolph states "Success", and I get the same failure that you see ("The database returned no natively generated identity value"). I hope someone else posts the last little point I missed, so I can get it to work.
Regards,
Thomas
|
|
Hello Salvador,
I think I just found the "missing link" for getting this to work. The tutorial will work if you add one line to EmployeeController.groovy. It should look like:
If you explicitly assign the id from the params copy of the same variable just before you save, it seems to all be better. I also added the port number for MySQL to the datasource url lines. They now look like. url = "jdbc:mysql://localhost:3306/grailstutorial"Regards, Thomas
|
| Powered by Nabble | Edit this page |
