package entity;
public class Car {
private int cid;
private String cname;
private String cbrand;
private double cprice;
private double csellprice;
private int ccount ;
private int cstate;
public Car() {
super();
}
public Car(String cname, String cbrand, double cprice, double csellprice, int ccount, int cstate) {
super();
this.cname = cname;
this.cbrand = cbrand;
this.cprice = cprice;
this.csellprice = csellprice;
this.ccount = ccount;
this.cstate = cstate;
}
public Car(int cid, String cname, String cbrand, double cprice, double csellprice, int ccount, int cstate) {
super();
this.cid = cid;
this.cname = cname;
this.cbrand = cbrand;
this.cprice = cprice;
this.csellprice = csellprice;
this.ccount = ccount;
this.cstate = cstate;
}
public int getCid() {
return cid;
}
public void setCid(int cid) {
this.cid = cid;
}
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}
public String getCbrand() {
return cbrand;
}
public void setCbrand(String cbrand) {
this.cbrand = cbrand;
}
public double getCprice() {
return cprice;
}
public void setCprice(double cprice) {
this.cprice = cprice;
}
public double getCsellprice() {
return csellprice;
}
public void setCsellprice(double csellprice) {
this.csellprice = csellprice;
}
public int getCcount() {
return ccount;
}
public void setCcount(int ccount) {
this.ccount = ccount;
}
public int getCstate() {
return cstate;
}
public void setCstate(int cstate) {
this.cstate = cstate;
}
@Override
public String toString() {
return "Car [cid=" + cid + ", cname=" + cname + ", cbrand=" + cbrand + ", cprice=" + cprice + ", csellprice="
+ csellprice + ", ccount=" + ccount + ", cstate=" + cstate + "]";
}
}
```我的实体类2需要查将Car表作为属性连接查询【注意看我的Car car 属性名小写】
package entity;
public class shopCar {
/**
* 购物车表包含购物车的id 用户的id 商品车的id 添加购物车商品的数量
*/
private int sid;
private int uid;
private int cid;
private int count;
private Car car;
public shopCar(int sid, int uid, int cid, int count, Car car) {
super();
this.sid = sid;
this.uid = uid;
this.cid = cid;
this.count = count;
this.car = car;
}
public shopCar() {
super();
}
public shopCar(int uid, int cid, int count) {
super();
this.uid = uid;
this.cid = cid;
this.count = count;
}
public shopCar(int sid, int uid, int cid, int count) {
super();
this.sid = sid;
this.uid = uid;
this.cid = cid;
this.count = count;
}
public Car getCar() {
return car;
}
public void setCar(Car car) {
this.car = car;
}
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public int getCid() {
return cid;
}
public void setCid(int cid) {
this.cid = cid;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
@Override
public String toString() {
return "shopCar [sid=" + sid + ", uid=" + uid + ", cid=" + cid + ", count=" + count + ", car=" + car + "]";
}
}
【我的映射文件注意看:属性名Car】
<!-- 查询购物车表 -->
<resultMap type="entity.shopCar" id="map1">
<result property="sid" column="sid"/>
<result property="count" column="count"/>
<association property="*Car*" javaType="entity.Car">
<result property="cbrand" column="cbrand"/>
<result property="cprice" column="cprice"/>
</association>
</resultMap>
<select id="selectShopDateAll" resultMap="map1">
select s.sid,s.count,c.cbrand,c.cprice from shopcar s
inner join car c on s.cid=c.cid
where uid=#{uid}
</select>
才会出现这样的错误
报错之There is no getter for property named ‘Car‘ in ‘class entity.shopCar‘
最新推荐文章于 2024-03-11 11:24:08 发布