在groovy中使用更新查询时出现意外的令牌错误(unexpected token error while using update query in groovy)
我正在尝试使用简单的更新查询使用查询结果更新表。
这是查询。
def restore(def id, def contentId) { String hql = "" def q = revisionService.getRevisionById(id) hql = """UPDATE Content SET parentId = ${q.parent_id} ,user_id = ${q.user_id} ,inheritFromParent = ${q.inherit_from_parent} ,forceSSL = ${q.forcessl} ,title = ${q.title} ,fileName = ${q.file_name} ,fileNamePath = ${q.file_name_path} ,fileNameLookup = ${q.file_name_lookup} ,body = ${q.body} ,summary = ${q.summary} ,template = ${q.template} ,layout = ${q.layout} ,contentType = ${q.content_type} ,isNavItem = ${q.is_nav_item} ,navDepth = ${q.nav_depth} ,navOrder = ${q.nav_order} ,metaTitle = ${q.meta_title} ,metaKeywords = ${q.meta_keywords} ,metaDescription = ${q.meta_description} ,isActive = ${q.is_active} ,col1 = ${q.col1} ,col2 = ${q.col2} ,col3 = ${q.col3} ,col4 = ${q.col4} ,col5 = ${q.col5} ,col6 = ${q.col6} ,col7 = ${q.col7} ,col8 = ${q.col8} ,col9 = ${q.col9} WHERE id = ${contentId}""" try { Content.executeUpdate(hql) } catch(Exception e) { println e } }
当我执行此查询时获得一个异常说org.springframework.orm.hibernate4.HibernateQueryException:意外令牌:关于第7行,第50列附近。
这是我终端的堆栈跟踪。
line 7:50: unexpected token: about Message: unexpected token: about Line | Method ->> 353 | $tt__restore in org.regionscms.ContentService$$EOqIswWO - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 48 | restore in org.regionscms.ContentController | 198 | doFilter . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 53 | doFilter . . in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter | 49 | doFilter in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter | 82 | doFilter . . in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread org.springframework.orm.hibernate4.HibernateQueryException: unexpected token: about near line 7, column 50 [UPDATE org.regionscms.Content SET parentId = 1 ,user_id = 1 ,inheritFromParent = true ,forceSSL = false ,title = about us ,fileName = about-us ,fileNamePath = home/about-us ,fileNameLookup = 72635069142711694 ,body = tests ,summary = tests ,template = index.gsp ,layout = Main ,contentType = Page ,isNavItem = true ,navDepth = 1 ,navOrder = 2 ,metaTitle = null ,metaKeywords = null ,metaDescription = null ,isActive = true ,col1 = 1045719790170831251 ,col2 = 72635069142711694 ,col3 = 0 ,col4 = 0 ,col5 = 0 ,col6 = 0 ,col7 = 0 ,col8 = 0 ,col9 = 0 WHERE id = 2]; nested exception is org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: about near line 7, column 50 [UPDATE org.regionscms.Content SET parentId = 1 ,user_id = 1 ,inheritFromParent = true ,forceSSL = false ,title = about us ,fileName = about-us ,fileNamePath = home/about-us ,fileNameLookup = 72635069142711694 ,body = tests ,summary = tests ,template = index.gsp ,layout = Main ,contentType = Page ,isNavItem = true ,navDepth = 1 ,navOrder = 2 ,metaTitle = null ,metaKeywords = null ,metaDescription = null ,isActive = true ,col1 = 1045719790170831251 ,col2 = 72635069142711694 ,col3 = 0 ,col4 = 0 ,col5 = 0 ,col6 = 0 ,col7 = 0 ,col8 = 0 ,col9 = 0 WHERE id = 2]
I am trying to update the table with the query result using simple update query.
here is the query.
def restore(def id, def contentId) { String hql = "" def q = revisionService.getRevisionById(id) hql = """UPDATE Content SET parentId = ${q.parent_id} ,user_id = ${q.user_id} ,inheritFromParent = ${q.inherit_from_parent} ,forceSSL = ${q.forcessl} ,title = ${q.title} ,fileName = ${q.file_name} ,fileNamePath = ${q.file_name_path} ,fileNameLookup = ${q.file_name_lookup} ,body = ${q.body} ,summary = ${q.summary} ,template = ${q.template} ,layout = ${q.layout} ,contentType = ${q.content_type} ,isNavItem = ${q.is_nav_item} ,navDepth = ${q.nav_depth} ,navOrder = ${q.nav_order} ,metaTitle = ${q.meta_title} ,metaKeywords = ${q.meta_keywords} ,metaDescription = ${q.meta_description} ,isActive = ${q.is_active} ,col1 = ${q.col1} ,col2 = ${q.col2} ,col3 = ${q.col3} ,col4 = ${q.col4} ,col5 = ${q.col5} ,col6 = ${q.col6} ,col7 = ${q.col7} ,col8 = ${q.col8} ,col9 = ${q.col9} WHERE id = ${contentId}""" try { Content.executeUpdate(hql) } catch(Exception e) { println e } }
when i execute this query getting an exception saying org.springframework.orm.hibernate4.HibernateQueryException: unexpected token: about near line 7, column 50.
here is stacktrace from my terminal.
line 7:50: unexpected token: about Message: unexpected token: about Line | Method ->> 353 | $tt__restore in org.regionscms.ContentService$$EOqIswWO - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 48 | restore in org.regionscms.ContentController | 198 | doFilter . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 53 | doFilter . . in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter | 49 | doFilter in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter | 82 | doFilter . . in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread org.springframework.orm.hibernate4.HibernateQueryException: unexpected token: about near line 7, column 50 [UPDATE org.regionscms.Content SET parentId = 1 ,user_id = 1 ,inheritFromParent = true ,forceSSL = false ,title = about us ,fileName = about-us ,fileNamePath = home/about-us ,fileNameLookup = 72635069142711694 ,body = tests ,summary = tests ,template = index.gsp ,layout = Main ,contentType = Page ,isNavItem = true ,navDepth = 1 ,navOrder = 2 ,metaTitle = null ,metaKeywords = null ,metaDescription = null ,isActive = true ,col1 = 1045719790170831251 ,col2 = 72635069142711694 ,col3 = 0 ,col4 = 0 ,col5 = 0 ,col6 = 0 ,col7 = 0 ,col8 = 0 ,col9 = 0 WHERE id = 2]; nested exception is org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: about near line 7, column 50 [UPDATE org.regionscms.Content SET parentId = 1 ,user_id = 1 ,inheritFromParent = true ,forceSSL = false ,title = about us ,fileName = about-us ,fileNamePath = home/about-us ,fileNameLookup = 72635069142711694 ,body = tests ,summary = tests ,template = index.gsp ,layout = Main ,contentType = Page ,isNavItem = true ,navDepth = 1 ,navOrder = 2 ,metaTitle = null ,metaKeywords = null ,metaDescription = null ,isActive = true ,col1 = 1045719790170831251 ,col2 = 72635069142711694 ,col3 = 0 ,col4 = 0 ,col5 = 0 ,col6 = 0 ,col7 = 0 ,col8 = 0 ,col9 = 0 WHERE id = 2]
原文:https://stackoverflow.com/questions/25932403
最满意答案
我实际上喜欢我的JavaScript文件被验证,但我绝对不想验证和处理与第三方库的微不足道的警告。
这就是为什么我认为一起关闭验证是太激烈了。 幸运的是,使用Eclipse,您可以从验证中选择性地删除一些JavaScript源代码。
- 右键单击您的项目。
- 导航到:属性→JavaScript→包含路径
- 选择源选项卡。 (它看起来与Java Build Path Source选项卡相同)
- 展开JavaScript源文件夹。
- 突出显示
Excluded
图案。- 按编辑按钮。
- 按
Exclusion patterns
框旁边的添加按钮。- 您可以键入Ant风格的通配符模式,也可以单击“
Browse
按钮以按名称提及JavaScript源。有关JavaScript源代码包含/排除的信息保存到
.settings/.jsdtscope
文件中。 不要忘记将其添加到您的SCM。以下是从验证中删除jQuery文件的配置外观:
I actually like MY JavaScript files to be validated, but I definitely don't want to validate and deal with trivial warnings with third party libraries.
That's why I think that turning off validation all together is too drastic. Fortunately with Eclipse, you can selectively remove some JavaScript sources from validation.
- Right-click your project.
- Navigate to: Properties → JavaScript → Include Path
- Select Source tab. (It looks identical to Java Build Path Source tab.)
- Expand JavaScript source folder.
- Highlight
Excluded
pattern.- Press the Edit button.
- Press the Add button next to
Exclusion patterns
box.- You may either type Ant-style wildcard pattern, or click
Browse
button to mention the JavaScript source by name.The information about JavaScript source inclusion/exclusion is saved into
.settings/.jsdtscope
file. Do not forget to add it to your SCM.Here is how configuration looks with jQuery files removed from validation:
相关问答
更多-
android 3d游戏开发 所需要的软件[2023-10-23]
eclipse -
安卓应用程序开发使用哪个开发工具最好?[2022-11-21]
eclipse -
安卓手机编程现在用什么软件?并求下载地址。[2022-05-06]
eclipse -
Eclipse:禁用Javascript验证。(Eclipse: Javascript validation disabled. but still generating errors?)[2024-03-09]
右键点击你的项目 选择属性 - > JavaScript - >包含 选择源选项卡(它看起来类似于Java构建路径源选项卡) 展开源文件夹 突出显示排除的图案 单击编辑按钮 点击排除模式框旁边的添加按钮。 单击浏览按钮,并按名称选择JavaScript源。 Right click your project Select Properties -> JavaScript -> Include Select Source tab (It looks similar to the Java Build Path ... -
JSDT使用具体的语法分析器来生成语法错误。 你不能禁用它。 只能配置语义错误或警告。 但是,您可以禁用JSDT的整个验证。 下面的解决方案将抑制在我们保存java脚本文件的一些更改时生成的错误和警告。 (自动构建,构建) 打开项目的“属性”对话框。 选择建筑商项目。 取消选中“JavaScript Validator”。 然后按OK按钮。 从“ 问题视图”中删除当前错误和警告 编辑时,此解决方案无法消除编辑器中的错误或警告注释。 只有在编辑时,它们才会暂时显示在编辑器上。 After a lot of r ...
-
好吧,可能我已经设法做你需要的东西),这有点棘手。 所以我的步骤: 下载Eclipse PDT(确保它适用于您,因为我使用Eclipse for Java EE) 创建项目TestJS(这是JavaScript项目) 创建了两个文件test.js和htmlparser.js(最后一个从John Resig的网站复制) 他们都打了个“破”的脚本,所以Eclipse告诉我,他们两个都有错误 转到项目属性> JavaScript>包含路径>源 ,有“ 排除 ”突出显示并按“编辑”按钮,这里您可以添加要排除的内容( ...
-
如何从我的eclipse项目中删除javascript验证?(How do I remove javascript validation from my eclipse project?)[2023-04-24]
我实际上喜欢我的JavaScript文件被验证,但我绝对不想验证和处理与第三方库的微不足道的警告。 这就是为什么我认为一起关闭验证是太激烈了。 幸运的是,使用Eclipse,您可以从验证中选择性地删除一些JavaScript源代码。 右键单击您的项目。 导航到:属性→JavaScript→包含路径 选择源选项卡。 (它看起来与Java Build Path Source选项卡相同) 展开JavaScript源文件夹。 突出显示Excluded图案。 按编辑按钮。 按Exclusion patterns框旁边 ... -
如何从eclipse中的Maven项目中删除未使用的依赖项?(How to remove unused depedencies from maven project in eclipse?)[2022-06-30]
首先从源代码中删除未使用的导入。 在Eclipse中是Source - > Organize Imports。 然后,您可以通过运行mvn dependency:analyze-only来使用Maven依赖关系分析器mvn dependency:analyze-only 。 它将生成一个报告,标识未使用的依赖关系。 First remove unused imports from your source code. In Eclipse it is Source -> Organize Imports. T ... -
你必须从项目文件夹根目录中的.classpath和.project文件中删除特定于android的东西,即
com.android.ide.eclipse.adt.ApkBuilder -
这是我的工作,似乎工作正常。 我正在使用Eclipse Juno SR2(面向Web开发人员的Java EE)和Maven 3.0.5。 (我不是Eclipse或Maven的专家,所以我确信有更优雅的方式来做这件事。请让我知道!) 根据Maven惯例,我们希望有一个如下所示的项目结构: - src +-- main +-- java +-- js +-- webapp +-- WEB-INF +-- test +-- java +-- js 然后我们希望使用以 ...