| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| I have a java class that has two methods private void populatePreceedingVarVerHashMap(int varVerId, Session session,Map map) { String sql = "from DbProcess d where d.varVer.id=? and d.schma='eV12'"; Object[] params = new Object[1]; params[0] = new Integer(varVerId); DbProcess dbProcess = (DbProcess) hUtil.executeQueryReturnUniqueResult(session, sql, params); if(dbProcess != null){ int val = dbProcess.getVal(); map.put(new Integer(varVerId),new Integer(val)); populatePreceedingVarVerHashMap(val,session,map); } } private void clearExistingVarVerChgLog(int varVerId,Session session){ String sql = "delete from VarVerChgLog v where v.varVer.id=?"; Query q = session.createQuery(sql); q.setInteger(0,varVerId); q.executeUpdate(); } While the query in the second method ' String sql = "delete from VarVerChgLog v where v.varVer.id=?";' is recoginzed by IntelliJ as a hibernate query and i can see the mappings for the VarVerChgLog while typing in the query, the same is not true for the query String sql = "from DbProcess d where d.varVer.id=? and d.schma='eV12'"; Can anybody give me an idea why this is. I can use the HQL console to execute the query and i have made sure the resource mapping exists in the hibernate.cfg.xml file. Also Intellij does not like the '?' mark in the query delete from VarVerChgLog v where v.varVer.id=? It shows a red line underneath it and a red mark also shows up in the gutter giving a false impression that an error exists in code. Is there a way to fix this Any help will be appreciate. The autocomplete on the queries will be a much appreciated feature when I have tons of them to write right now. |
|
#2
| |||
| |||
| This is known problem which should be solved in last IDEA 7 EAP build. ranjana14 wrote: > I have a java class that has two methods > > private void populatePreceedingVarVerHashMap(int varVerId, Session session,Map map) { > String sql = "from DbProcess d where d.varVer.id=? and d.schma='eV12'"; > Object[] params = new Object[1]; > params[0] = new Integer(varVerId); > DbProcess dbProcess = (DbProcess) hUtil.executeQueryReturnUniqueResult(session, sql, params); > if(dbProcess != null){ > int val = dbProcess.getVal(); > map.put(new Integer(varVerId),new Integer(val)); > populatePreceedingVarVerHashMap(val,session,map); > } > } > > private void clearExistingVarVerChgLog(int varVerId,Session session){ > String sql = "delete from VarVerChgLog v where v.varVer.id=?"; > Query q = session.createQuery(sql); > q.setInteger(0,varVerId); > q.executeUpdate(); > } > > While the query in the second method ' > String sql = "delete from VarVerChgLog v where v.varVer.id=?";' > is recoginzed by IntelliJ as a hibernate query and i can see the mappings for the VarVerChgLog while typing in the query, the same is not true for the query > String sql = "from DbProcess d where d.varVer.id=? and d.schma='eV12'"; > > Can anybody give me an idea why this is. I can use the HQL console to execute the query and i have made sure the resource mapping exists in the hibernate.cfg.xml file. > > Also Intellij does not like the '?' mark in the query > delete from VarVerChgLog v where v.varVer.id=? > It shows a red line underneath it and a red mark also shows up in the gutter giving a false impression that an error exists in code. Is there a way to fix this > > Any help will be appreciate. The autocomplete on the queries will be a much appreciated feature when I have tons of them to write right now. -- Best regards, Maxim Mossienko IntelliJ Labs / JetBrains Inc. http://www.intellij.com "Develop with pleasure!" |
|
#3
| |||
| |||
| I have figured out the answer to my own question: The method call hUtil.executeQueryReturnUniqueResult - is actually a wrapper for the session.createQuery(sql) with the some additonal checks If I remove this method call and put session.createQuery(sql) in its place the sql statement from DbProcess d where d.varVer.id=? and d.schma='eV12' starts to act as if it is a recognizable hibernate query Its a workaround but that should do for now |
|
#4
| |||
| |||
| I am new to this forum - can you tell me how to get this build. I just upgraded IntelliJ 5.0 with IntelliJ7.0.2 two days ago |
|
#5
| |||
| |||
| Hello, ranjana14! The second method has a direct "hibernate.session" method invocation which is captured and thererfore the "String sql" is recognised as the hql constant. Unfortunately the first method has not. The '?' mark error should be fixed in 7.0.3. Regards, Gregory Shrago ranjana14 wrote: > I have a java class that has two methods > > private void populatePreceedingVarVerHashMap(int varVerId, Session session,Map map) { > String sql = "from DbProcess d where d.varVer.id=? and d.schma='eV12'"; > Object[] params = new Object[1]; > params[0] = new Integer(varVerId); > DbProcess dbProcess = (DbProcess) hUtil.executeQueryReturnUniqueResult(session, sql, params); > if(dbProcess != null){ > int val = dbProcess.getVal(); > map.put(new Integer(varVerId),new Integer(val)); > populatePreceedingVarVerHashMap(val,session,map); > } > } > > private void clearExistingVarVerChgLog(int varVerId,Session session){ > String sql = "delete from VarVerChgLog v where v.varVer.id=?"; > Query q = session.createQuery(sql); > q.setInteger(0,varVerId); > q.executeUpdate(); > } > > While the query in the second method ' > String sql = "delete from VarVerChgLog v where v.varVer.id=?";' > is recoginzed by IntelliJ as a hibernate query and i can see the mappings for the VarVerChgLog while typing in the query, the same is not true for the query > String sql = "from DbProcess d where d.varVer.id=? and d.schma='eV12'"; > > Can anybody give me an idea why this is. I can use the HQL console to execute the query and i have made sure the resource mapping exists in the hibernate.cfg.xml file. > > Also Intellij does not like the '?' mark in the query > delete from VarVerChgLog v where v.varVer.id=? > It shows a red line underneath it and a red mark also shows up in the gutter giving a false impression that an error exists in code. Is there a way to fix this > > Any help will be appreciate. The autocomplete on the queries will be a much appreciated feature when I have tons of them to write right now. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.