Why doesn't jpa perform a lookup according to my sql statement?

because I want to query the linked list, I add a field in the main table a that needs to be checked out by the linked table. After setting up the set get, the linked list is checked out, but the trouble comes

first of all, when inserting table a, that field is troublesome, but luckily I solved

then, there is a single query, when it is used for modification, I find that no matter what, I put the field of my linked list into it. I don"t need that field of the linked list under my requirement. I checked hebnet"s annotations and didn"t find any annotations that could fulfill my needs, so I thought of another way, which is to execute the original sql statement and write out the fields I want, so that I don"t find the one that doesn"t exist, right?

all right, as shown in the picture, what"s going on? I obviously did not look up that field, but it appeared in sql, and then reported an error. I asked you how to solve it.

how can I succeed when I have a field in my bean that does not exist in this table, and then I want to find the original contents of this table?

is there any way to solve the problem with sql without rewriting a bean, ha, and without the annotations of Onemany?

Thank you

copy my bean,catname field, which is the field of my linked list, which I don"t need when querying a single record.

@ Entity
@ Table (name = "news")

public class News {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)

private Integer id;

private String xname;

private String xcontent;

/ / @ CreatedDate
/ / private Date addtime;

private String image;

private Integer click;
private String descript;
private String keyword;

private Integer catid;

@Column(insertable = false)
@Transient
private String catname;

public String getCatname() {
    return catname;
}

public void setCatname(String catname) {
    this.catname = catname;
}

private Integer type;

public Integer getType() {
    return type;
}

public void setType(Integer type) {
    this.type = type;
}

public Integer getId() {
    return id;
}

public void setId(Integer id) {
    this.id = id;
}

public String getXname() {
    return xname;
}

public void setXname(String xname) {
    this.xname = xname;
}

public String getXcontent() {
    return xcontent;
}

public void setXcontent(String xcontent) {
    this.xcontent = xcontent;
}

/ / public Date getAddtime () {
/ / return addtime;
/ /}
/ /
/ / public void setAddtime (Date addtime) {
/ / this.addtime = addtime;
/ /}

public String getImage() {
    return image;
}

public void setImage(String image) {
    this.image = image;
}

public Integer getClick() {
    return click;
}

public void setClick(Integer click) {
    this.click = click;
}

public String getDescript() {
    return descript;
}

public void setDescript(String descript) {
    this.descript = descript;
}

public String getKeyword() {
    return keyword;
}

public void setKeyword(String keyword) {
    this.keyword = keyword;
}

public Integer getCatid() {
    return catid;
}

public void setCatid(Integer catid) {
    this.catid = catid;
}

Jul.08,2022

@Transient

add a comment to the fields that do not need database mapping

Menu