Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JPA更新查询问题_Java_Jpa - Fatal编程技术网

Java JPA更新查询问题

Java JPA更新查询问题,java,jpa,Java,Jpa,假设我们有两个实体 @Entity(name = "user") @Inheritance(strategy = InheritanceType.JOINED) public class User{ @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; } 另一个继承类 @Entity public class ExtendedUser extends Us

假设我们有两个实体

@Entity(name = "user")
@Inheritance(strategy = InheritanceType.JOINED)
public class User{

 @Id
 @GeneratedValue(strategy = GenerationType.AUTO)
 private Long id;

 private String name;
}
另一个继承类

@Entity
public class ExtendedUser extends User{
   private String bio;
}
现在,当我尝试运行JPA更新查询时

@Modifying
@Query("update ExtendedUser  set bio=?2 where id=?1")
void updateOverflowText(Long id,String bio);
我遇到异常,无法运行查询,因为“id”列不明确

试试这个

更新用户usr set usr.bio=?2,其中usr.id=?1

试试这个:

@Modifying 
@Query( nativeQuery = true, value = "update user set bio=?2 where id=?1")
int updateOverflowText( Long id, String bio );    `

尝试更新ExtendeDeduser usr set usr.bio=?2,其中usr.id=?1。但是它不起作用,如果你在后端用值执行相同的update语句以查看它是否正常工作,这可能会对你有所帮助。我不知道,以“try”开头的答案让我觉得作者不确定提议的更改将产生什么样的效果。无论如何,如果你能解释为什么你的解决方案能解决问题,我会更有信心。-话虽如此,欢迎来到stack overflow,并感谢分享您的知识:)介意一点吗?
@Modifying 
@Query( nativeQuery = true, value = "update user set bio=?2 where id=?1")
int updateOverflowText( Long id, String bio );    `