【问题标题】:Grails oracle database cannot add newGrails oracle 数据库无法添加新的
【发布时间】:2015-07-30 17:08:09
【问题描述】:

我正在开发 grails 2.4.5。 我将我的项目连接到 oracle 11g。 在数据源中,我添加:

dataSource {
            pooled = true
            dialect = org.hibernate.dialect.Oracle10gDialect
            driverClassName = 'oracle.jdbc.OracleDriver'
            username = 'grails'   // YOUR USERNAME AND PASS
            password = 'grails'
            url = 'jdbc:oracle:thin:localhost:1521:orcl'
            dbCreate = 'update'
        }

然后它连接,当我创建新域时,数据库中的新表会创建。 但是,当我添加新内容时:

new Book(name:'The Strain').save(flush:true)

然后出现错误:

2015-07-29 17:10:30,036 [Thread-10] ERROR plugins.AbstractGrailsPluginManager  - Plugin [controllers:2.4.5] could not reload changes to file [C:\Users\Thuc Tran\IdeaProjects\EmailTutorial\grails-app\controllers\emailtutorial\PlaceController.groovy]: Cannot invoke method getPropertyValue() on null object
Message: Cannot invoke method getPropertyValue() on null object
   Line | Method
->> 120 | configureScaffoldingController in ScaffoldingGrailsPlugin
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
^   105 | doCall                         in ScaffoldingGrailsPlugin$_closure3

我们将不胜感激任何解决方案。谢谢。

【问题讨论】:

  • 要检查两件事。有关一些想法,请参阅之前的Stackoverflow answer 并尝试添加适当的代码。如果这不起作用,请检查此JIRA entry 是否存在可能的错误。

标签: grails groovy oracle11g


【解决方案1】:

我解决了这个问题。我为需要它的人发布解决方案。 在 oracle 上,在我的情况下创建序列 eg: BOOK_SEQ。确保在 oracle 上,当您添加新记录时,id 将自动递增。 然后在域类上,static mapping引用,添加:

static mapping = {
        id generator:'sequence', params:[sequence:'BOOKS_SEQ']
}

就是这样。

如果答案不清楚,我随时回答。

谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-16
    • 2017-11-16
    • 1970-01-01
    相关资源
    最近更新 更多