(发布问题后列和变量名称更改)当我运行代码时,我正在使用 jpa 自定义方法中的 entityManager.createNativeQuery(somequery) 编写连接查询,但出现以下错误:
com.ibm.db2.jcc.am.SqlException:[jcc][10150][10300][4.12.56] 无效>参数:未知列名 exc_seq_nbr。错误代码=-4460,SQLSTATE=null
我正在使用 IBM DB2 服务器和 spring boot
exceptionTenderPK(实体类中的对象)未正确映射,这就是为什么获取无效列有人可以告诉我如何映射 exceptionTenderPK 对象类
注意:在这种情况下我不能使用@OneToMany,因为表是不相关的
@Entity
@Table(name = "Table_name")
@Data
public class MainPojoclass {
@EmbeddedId
@JsonProperty(value = "mainPojoclassPK")
private MainPojoclassPK mainPojoclassPK;
@Column(name = "amt")
@JsonProperty(value = "amt")
private BigDecimal amt;
@Column(name = "tndid")
@JsonProperty(value = "tndid")
private String tndid;
@Column(name = "cde")
@JsonProperty(value = "cde")
private String cde;
@Column(name = "ind")
@JsonProperty(value = "ind")
private String ind;
@Column(name = "user")
@JsonProperty(value = "user")
private String user;
@Column(name = "updatedtime")
@JsonProperty(value = "updatedtime")
private Date updatedtime;
@Column(name = "src")
@JsonProperty(value = "src")
private String src;
@Column(name = "stat")
@JsonProperty(value = "stat")
private String stat;
}
@Transactional
public interface JoinQueryRepository extends JpaRepository<MainPojoclass, Long>, JoinQueryRepositoryCustom{
}
public interface JoinQueryRepositoryCustom {
List<MainPojoclass> getGRDetails(MainPojoclass et,Date reportDate);
}
public class JoinQueryRepositoryImpl implements JoinQueryRepositoryCustom {
@PersistenceContext
EntityManager entityManager;
@SuppressWarnings("all")
@Override
public List<MainPojoclass> getGRDetails(MainPojoclass et,Date rdate) {
String queryStr = "select et.Salss_DTE from table et"
+ " join dte etr on et.Salss_DTE = etr.Salss_DTE where et.nbr =? ";
List<MainPojoclass> datalist = null;
Query query = entityManager.
createNativeQuery(queryStr,"mapping")
.setParameter(1, 222);
datalist = query.getResultList();
return datalist;
}
}