Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 0.2.1
-
Fix Version/s: 0.3
-
Component/s: Scaffolding
-
Labels:None
-
Environment:Windows XP
Description
I created a Device and DeviceVendor class, with a GORM 1:m relationship. I also created some test objects in the ApplicationBootStrap.groovy file:
DeviceVendor vendorA = new DeviceVendor(name:"Nokia")
vendorA.addDevice(new Device(model:"6680"))
.addDevice(new Device(model:"n70"))
.save()
new DeviceVendor(name:"Sony Ericsson").save()
new DeviceVendor(name:"Benq").save()
new DeviceVendor(name:"Alcatel").save()
The controllers currently use scaffolding.
Grails starts up without errors, but when I try to change the DeviceVendor of a Device (via the scaffold-generated code), I get this exception:
[groovy] Handler execution resulted in exception - forwarding to resolved error view
[groovy] org.springframework.orm.hibernate3.HibernateSystemException: identifier of an instance of DeviceVendor was altered from 7 to 10; nested exception is org.hiber
ate.HibernateException: identifier of an instance of DeviceVendor was altered from 7 to 10
[groovy] org.hibernate.HibernateException: identifier of an instance of DeviceVendor was altered from 7 to 10
[groovy] at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:51)
[groovy] at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java :150)
[groovy] at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:106)
[groovy] at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities (AbstractFlushingEventListener.java:195)
[groovy] at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
[groovy] at org.hibernate.event.def.DefaultFlushEventListener.onFlush (DefaultFlushEventListener.java:26)
[groovy] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
[groovy] at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java :394)
[groovy] at org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor.postHandle(OpenSessionInViewInterceptor.java:180)
[groovy] at org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:723)
[groovy] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:658)
[groovy] at org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:392)
[groovy] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:357)
[groovy] at javax.servlet.http.HttpServlet.service(HttpServlet.java:616)
[groovy] at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
[groovy] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
[groovy] at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter (WebApplicationHandler.java:830)
[groovy] at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119)
That's right. I am changing the foreign key reference... that's the goal. But somehow Hibernate does not like it...
Issue Links
- duplicates
-
GRAILS-225
Update of references causes HibernateException: "identifier ... was altered"
-
This looks like a dupe of
GRAILS-225.