org.springframework.web.util.NestedServletException:请求处理失败;嵌套的异常是org.hibernate.ObjectNotFoundException:不存在具有给定标识符的行:[com.websystique.springmvc.model.AssetMakeMaster#0]

我有两个实体如下:
1. AssetMaster
2. AssetMakeMaster

上面的实体与表映射。我想对以上两个实体使用左联接,并从AssetMaster获取所有数据。内部查询对于上述实体工作正常,但我也想获取不匹配的值。我已经尝试过但还没有解决方案。请任何人为我的问题提供解决方案。

我已经在mysql中尝试了以下查询,它给了我适当的结果,但是我想从休眠实体中获取结果。请给我以下查询的解决方案:


  SELECT * FROM fscassets.asset_master左联接
  fscassets.asset_make_master b on a.make = b.id;

/*  * To change this license header, choose License Headers in Project
Properties.  * To change this template file, choose Tools | Templates
* and open the template in the editor.  */ package > >
/**  *  * @author Amol  */
@Entity @Table(name = "asset_master")
public class AssetMaster implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

@Column(name = "make", nullable = false)
private int make;

@Column(name = "serialno", nullable = false)
private String serialno;

@Column(name = "specs", nullable = false)
private String specs;

@Column(name = "model", nullable = false)
private String model;

@Column(name = "quantity", nullable = false)
private int quantity;

@Column(name = "purchasedate", nullable = false)
private String purchasedate;

@Column(name = "created_on", nullable = false)
private String createdOnDate;

@Column(name = "remark", nullable = false)
private String remark;

@Column(name = "ipaddress", nullable = false)
private String ipAddress;


@ManyToOne(cascade = CascadeType.ALL)
@Fetch(FetchMode.SELECT)
@JoinColumn(name = "make", updatable = false, insertable = false)
private AssetMakeMaster assetMakeMasterdata;

public AssetMakeMaster getAssetMakeMasterdata() {
    return assetMakeMasterdata;
}

public void setAssetMakeMasterdata(AssetMakeMaster assetMakeMasterdata) {
    this.assetMakeMasterdata = assetMakeMasterdata;
}



public Integer getId() {
    return id;
}

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


public String getCreatedOnDate() {
    return createdOnDate;
}

public void setCreatedOnDate(String createdOnDate) {
    this.createdOnDate = createdOnDate;
}

public String getIpAddress() {
    return ipAddress;
}

public void setIpAddress(String ipAddress) {
    this.ipAddress = ipAddress;
}


public int getMake() {
    return make;
}

public void setMake(int make) {
    this.make = make;
}

public String getSerialno() {
    return serialno;
}

public void setSerialno(String serialno) {
    this.serialno = serialno;
}

public String getSpecs() {
    return specs;
}

public void setSpecs(String specs) {
    this.specs = specs;
}

public String getModel() {
    return model;
}

public void setModel(String model) {
    this.model = model;
}

public int getQuantity() {
    return quantity;
}

public void setQuantity(int quantity) {
    this.quantity = quantity;
}

public String getPurchasedate() {
    return purchasedate;
}

public void setPurchasedate(String purchasedate) {
    this.purchasedate = purchasedate;
}


public String getRemark() {
    return remark;
}

public void setRemark(String remark) {
    this.remark = remark;
}

  
  }

/*  * To change this license header, choose License Headers in Project
Properties.  * To change this template file, choose Tools | Templates
* and open the template in the editor.  */ package > >
/**  *  * @author Amol  */

  
  @实体
     @Table(name =“ asset_make_master”)
     公共类AssetMakeMaster实现Serializable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

@NotEmpty
@Column(name = "asset_make_name", unique = true, nullable = false)
private String assetmakename;

@Column(name = "assetgroup", nullable = false)
private int groupid;

@Column(name = "created_on", nullable = false)
private String createdOnDate;

@Column(name = "ipaddress", nullable = false)
private String ipAddress;


@ManyToMany(cascade = CascadeType.ALL, mappedBy = "assetMakeMasterdata")
private List<AssetMaster> assetMakeMasters = new ArrayList<AssetMaster>();

public List<AssetMaster> getAssetMakeMasters() {
    return assetMakeMasters;
}

public void setAssetMakeMasters(List<AssetMaster> assetMakeMasters) {
    this.assetMakeMasters = assetMakeMasters;
}
public Integer getId() {
    return id;
}

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

public String getAssetmakename() {
    return assetmakename;
}

public void setAssetmakename(String assetmakename) {
    this.assetmakename = assetmakename;
}

public int getGroupid() {
    return groupid;
}

public void setGroupid(int groupid) {
    this.groupid = groupid;
}

public String getCreatedOnDate() {
    return createdOnDate;
}

public void setCreatedOnDate(String createdOnDate) {
    this.createdOnDate = createdOnDate;
}

public String getIpAddress() {
    return ipAddress;
}

public void setIpAddress(String ipAddress) {
    this.ipAddress = ipAddress;
}

 }

最佳答案

您不能在HQL查询中使用(*)。如果还需要不匹配的值,则分别选择该列,您将获得值。

10-07 22:11