GORM - 在 .get() 函数中获取 sql 异常
你好,我正在使用 GORM,并且我在数据库中有一个用户表。我还有一个更新用户配置文件的更新方法。当我尝试更新联系人时,第一次尝试可以,但在第二次或有时第三次尝试后,
ERROR org.hibernate.transaction.JDBCTransaction - Could not toggle autocommit
java.sql.SQLException: Error during query: Unexpected Exception: java.lang.ArrayIndexOutOfBoundsException message given: 3
当我尝试执行此操作时,我会遇到异常:
User updateUser(User tempUser){
def id=tempUser.id
User user = User.get(id)//this line throws exception
hi i am using GORM and i have an user table in database. also I have an update method that updates a users profile. when i am trying to update a contact its ok with first try, but after second or sometimes third try, iam getting
ERROR org.hibernate.transaction.JDBCTransaction - Could not toggle autocommit
java.sql.SQLException: Error during query: Unexpected Exception: java.lang.ArrayIndexOutOfBoundsException message given: 3
exception when i am trying to do this:
User updateUser(User tempUser){
def id=tempUser.id
User user = User.get(id)//this line throws exception
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,信息不够。
你为什么要这样做?这段代码在 Domain 类中吗?
您可以在控制器中更新用户实例经典方式:
您也可以尝试向用户实例添加方法(在用户域类中),如下所示:
然后在控制器中调用它:
我没有测试上面的代码片段,所以小心点。关于您的代码,如果您提供更多代码,那就太好了:User 类的一部分,更多的 updateUser 方法。
问候。
First of all, there is not enough information.
Why are you doing it like this? Is this code in a Domain class?
You can update User instance classic way in your controller:
Also you can try to add method to user instance (in User domain class), smth like this:
and then invoke it in your controller:
I didn't test code snippets above, so be carefull. And about your code, it would be nice, if you gave some more code: parts of User class, more of updateUser method.
Regards.