|
I have a integration test for one of my Domain objects that works in 1.3.7 but in 2.0 it fails because it doesn't produce the correct SQL (so maybe more of an Hibernate 3.6 problem?). I actually tried running 2.0 with the Hibernate 1.3.7 plugin but I get errors regarding the session factory.
Anyway, got a one-to-one between AgentIdMap to Agent (legacy DB schema): class AgentIdMap { int clientId int id String agentLabel static hasOne = [agent: Agent] static mapping = { table 'idmap' version false id column: 'vacdid', generator: 'assigned' agent column: 'vacdid' clientId column: 'clientid' agentLabel column: 'agentlabel' } class Agent { int id Date onlineDate Date offlineDate String ssn String firstName String lastName String email String phoneNumber String login String password String displayName String updatedUser Date dateUpdated static hasMany = [agentSkills: AgentSkill] static belongsTo = [agentIdMap: AgentIdMap] static mapping = { table 'agent' version false id column: 'agentkey', generator: 'assigned' agentIdMap column: 'agentid' onlineDate column: 'onlinedate' offlineDate column: 'offlinedate' firstName column: 'firstname' lastName column: 'lastname' phoneNumber column: 'homephone' displayName column: 'displayname' updatedUser column: 'updateduser' dateUpdated column: 'dateupdated' agentSkills lazy: true } Relevant test code: int vacdId = Integer.MAX_VALUE / 2 def agent = new Agent(onlineDate: onlineTime, offlineDate: offlineTime, ssn: '0', firstName: 'Grails', lastName: 'User', email: '[hidden email]', phoneNumber: '4025551212', login: 'theLabelAndLogin', password: 'password', displayName: 'Grails User', updatedUser: 'vacduser', dateUpdated: onlineTime) agent.id = vacdId def agentIdMap = new AgentIdMap(agentLabel: "theLabelAndLogin", clientId: 68) agentIdMap.id = vacdId agentIdMap.agent = agent agent.agentIdMap = agentIdMap //Set the back-reference in the agent object agentIdMap.save(failOnError: true, flush: true) <--Error is thrown when I try to save here Error is: Caused by: java.sql.SQLException: Too many or too few host variables given. Because the SQL it generates puts "null" for the vacdid: 09:16:34|12|1|statement|select this_.vacdid as vacdid15_0_, this_.agentlabel as agentlabel15_0_, this_.clientid as clientid15_0_ from idmap this_ where this_.vacdid=?|select this_.vacdid as vacdid15_0_, this_.agentlabel as agentlabel15_0_, this_.clientid as clientid15_0_ from idmap this_ where this_.vacdid=null However, when running the project as a 1.3.7 project it produces the correct SQL (with a non-null bind parameter): 09:44:33|3|1|statement|select agentidmap_.vacdid, agentidmap_.agentlabel as agentlabel5_, agentidmap_.clientid as clientid5_ from idmap agentidmap_ where agentidmap_.vacdid=?|select agentidmap_.vacdid, agentidmap_.agentlabel as agentlabel5_, agentidmap_.clientid as clientid5_ from idmap agentidmap_ where agentidmap_.vacdid=1073741823 Can anyone offer insight? Bug in Grails 2.0 or Hibernate 3.6? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
