Details
-
Type:
Bug
-
Status:
In Progress
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.0.1, 2.0.3, 2.0.4
-
Fix Version/s: None
-
Component/s: Persistence
-
Environment:Windows 7,
jdk1.6.0_19,
Grails 2.0.4 (faced since 2.0.1),
spring-security plugin's family,
STS 64-bit 2.9.2
-
Testcase included:yes
Description
We have such domain classes relationships (see project's domain classes sources and an integration test attached):
class TrackPost {
static hasMany = [
tags : Tag, // many-to-many
comments: Comment // one-to-many
]
}
class Tag {
static belongsTo = [TrackPost]
static hasMany = [
postedTracks: TrackPost
]
}
class Comment {
static belongsTo = [track: TrackPost]
}
In /conf/BootStrap.groovy I'm populating DB configured in /conf/DataSource.groovy (having dbCreate = 'create' for 'dev' environment).
PROBLEM
TrackPost.tags association is being populated and saved only for NEWLY created TrackPost instance. When I'm trying to add tags to EXISTENT TrackPost instance - there is an DB/Hibernate exception thrown:
com.mysql.jdbc.JDBC4PreparedStatement@3ae0e5b7: select this_.id as id18_0_, this_.version as version18_0_, this_.creator_id as creator3_18_0_, this_.date_created as date4_18_0_, this_.last_updated as last5_18_0_, this_.message as message18_0_, this_.title as title18_0_, this_.track_id as track8_18_0_ from track_post this_ where this_.id=** NOT SPECIFIED ** | Error 2012-06-26 19:10:47,733 [pool-7-thread-1] ERROR util.JDBCExceptionReporter - No value specified for parameter 1
The full console trace is at the BootStrap.groovy's bottom.
That's for many-to-many association. The worst thing is, there is the same problem for one-to-many association for TrackPost.comments. There is CommentIntegrationTests.groovy included which demonstrates the problem (again full trace is in the file):
| org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select this_.id as id5_0_, this_.version as version5_0_, this_.creator_id as creator3_5_0_, this_.date_created as date4_5_0_, this_.last_updated as last5_5_0_, this_.message as message5_0_, this_.title as title5_0_, this_.track_id as track8_5_0_ from track_post this_ where this_.id=?]; SQL state [90012]; error code [90012]; Параметр "#1" не установлен Parameter "#1" is not set; SQL statement: select this_.id as id5_0_, this_.version as version5_0_, this_.creator_id as creator3_5_0_, this_.date_created as date4_5_0_, this_.last_updated as last5_5_0_, this_.message as message5_0_, this_.title as title5_0_, this_.track_id as track8_5_0_ from track_post this_ where this_.id=? [90012-164]; nested exception is org.h2.jdbc.JdbcSQLException: Параметр "#1" не установлен
I faced this problem first time in Grails 2.0.1, then it's been there in every version except 2.0.2 which I didn't use.
The code included comprises the plugins we use, cause I couldn't re-create the problem as 'simplified' version without plugins. Are there chances the problem is being introduced by some plugin ?
Anyways, this functionality is critical for us, that's why I'm following Graeme's advice (contacted him directly some time ago) and reporting the problem here.
Look forward for your help guys !
same error encountered.