java - JPA update Query issue -


suppose have 2 entities

@entity(name = "user") @inheritance(strategy = inheritancetype.joined) public class user{   @id  @generatedvalue(strategy = generationtype.auto)  private long id;   private string name; } 

another inherited class

@entity public class extendeduser extends user{    private string bio; } 

now when try run jpa update query

@modifying @query("update extendeduser  set bio=?2 id=?1") void updateoverflowtext(long id,string bio); 

i exception, cannot run query, due ambiguous column "id"

caused by: com.mysql.jdbc.exceptions.jdbc4.mysqlintegrityconstraintviolationexception: column 'id' in clause ambiguous  @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method)  @ sun.reflect.nativeconstructoraccessorimpl.newinstance(unknown source)  @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(unknown source)  @ java.lang.reflect.constructor.newinstance(unknown source)  @ com.mysql.jdbc.util.handlenewinstance(util.java:411)  @ com.mysql.jdbc.util.getinstance(util.java:386)  @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:1040)  @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:4074)  @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:4006)  @ com.mysql.jdbc.mysqlio.sendcommand(mysqlio.java:2468)  @ com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio.java:2629)  @ com.mysql.jdbc.connectionimpl.execsql(connectionimpl.java:2719)  @ com.mysql.jdbc.preparedstatement.executeinternal(preparedstatement.java:2155)  @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:2450)  @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:2371)  @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:2355)  @ org.hibernate.hql.ast.exec.multitableupdateexecutor.execute(multitableupdateexecutor.java:142)  ... 103 more 

try this

update user usr set usr.bio=?2 usr.id=?1


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -