NutzCN Logo
问答 一对多查询 多对象没有值
发布于 3042天前 作者 Hamming 1743 次浏览 复制 上一个帖子 下一个帖子
标签:

good对象代码如下

package nuoshang.bluejay.bean;
import java.io.Serializable;
import org.nutz.dao.entity.annotation.*;
import java.util.Date;
import java.util.List;

/**
 * 通过 DBCodeCreateTool 代码自动生成
 * @author 黄川
 * @time 2016-08-24 09:52:56
 */
@Table("t_goods")
public class Goods implements Serializable{
    private static final long serialVersionUID = 1L;
    /********** attribute ***********/
    /**
     * 商品状态-删除
     */
    public static final String STATE_RM = "0";

    /**
     * 商品状态-上架
     */
    public static final String STATE_ON = "1";

    /**
     * 商品状态-下架
     */
    public static final String STATE_OFF = "2";

    /**
     * 默认图片文件名
     */
    public static final String IMG_DFT = "goods_default.png";
    
    /****商品id ****/
    @Id
    @Column("good_id")
    private int good_id;
    /****商品名称 ****/

    @Name
    @Column("name")
    private String name;
    /****商品状态 ****/
    @Column("state")
    private String state;

    /****库存 ****/
    @Column("good_sku")
    private int good_sku;

    @Column("good_tenant_id")
    private int good_tenant_id;
    /****店铺ID ****/
    @Column("good_store_id")
    private int good_store_id;
    /****商品类别 ****/
    @Column("good_cate_id")
    private int good_cate_id;
    /****原价 ****/
    @Column("original_price")
    private java.math.BigDecimal original_price;
    /****优惠价 ****/
    @Column("prefere_price")
    private java.math.BigDecimal prefere_price;
    /****商品描述 ****/
    @Column("g_describe")
    private String g_describe;
    /****商品图片 ****/
    @Column("picture")
    private String picture;
    /****商品标签 ****/
    @Column("label")
    private String label;
    /****店铺名称 ****/
    @Column("good_store_name")
    private String good_store_name;
    /****首页商品标题 ****/
    @Column("good_title")
    private String good_title;
    /****添加时间 ****/
    @Column("create_time")
    private Date create_time;
    /****更新时间 ****/
    @Column("update_time")
    private Date update_time;

    @Many(target = Sku.class, field = "sku_goods_id")
    private List<Sku> Sku;

    public Goods() {}
    public Goods(int good_id, String name, String state, int good_sku, int good_tenant_id, int good_store_id, int good_cate_id, java.math.BigDecimal original_price, java.math.BigDecimal prefere_price, String g_describe, String picture, String label, String good_store_name, String good_title, Date create_time, Date update_time) {
        this.good_id = good_id;
        this.name = name;
        this.state = state;
        this.good_sku = good_sku;
        this.good_tenant_id = good_tenant_id;
        this.good_store_id = good_store_id;
        this.good_cate_id = good_cate_id;
        this.original_price = original_price;
        this.prefere_price = prefere_price;
        this.g_describe = g_describe;
        this.picture = picture;
        this.label = label;
        this.good_store_name = good_store_name;
        this.good_title = good_title;
        this.create_time = create_time;
        this.update_time = update_time;
    }
    /********** get/set ***********/
    public int getGood_id() {
        return good_id;
    }
    public void setGood_id(int good_id) {
        this.good_id = good_id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
    public int getGood_sku() {
        return good_sku;
    }
    public void setGood_sku(int good_sku) {
        this.good_sku = good_sku;
    }
    public int getGood_tenant_id() {
        return good_tenant_id;
    }
    public void setGood_tenant_id(int good_tenant_id) {
        this.good_tenant_id = good_tenant_id;
    }
    public int getGood_store_id() {
        return good_store_id;
    }
    public void setGood_store_id(int good_store_id) {
        this.good_store_id = good_store_id;
    }
    public int getGood_cate_id() {
        return good_cate_id;
    }
    public void setGood_cate_id(int good_cate_id) {
        this.good_cate_id = good_cate_id;
    }
    public java.math.BigDecimal getOriginal_price() {
        return original_price;
    }
    public void setOriginal_price(java.math.BigDecimal original_price) {
        this.original_price = original_price;
    }
    public java.math.BigDecimal getPrefere_price() {
        return prefere_price;
    }
    public void setPrefere_price(java.math.BigDecimal prefere_price) {
        this.prefere_price = prefere_price;
    }
    public String getG_describe() {
        return g_describe;
    }
    public void setG_describe(String g_describe) {
        this.g_describe = g_describe;
    }
    public String getPicture() {
        return picture;
    }
    public void setPicture(String picture) {
        this.picture = picture;
    }
    public String getLabel() {
        return label;
    }
    public void setLabel(String label) {
        this.label = label;
    }
    public String getGood_store_name() {
        return good_store_name;
    }
    public void setGood_store_name(String good_store_name) {
        this.good_store_name = good_store_name;
    }
    public String getGood_title() {
        return good_title;
    }
    public void setGood_title(String good_title) {
        this.good_title = good_title;
    }
    public Date getCreate_time() {
        return create_time;
    }
    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }
    public Date getUpdate_time() {
        return update_time;
    }
    public void setUpdate_time(Date update_time) {
        this.update_time = update_time;
    }

    public List<Sku> getSku() {
        return Sku;
    }

    public void setSku(List<Sku> sku) {
        Sku = sku;
    }
}

sku 对象

package nuoshang.bluejay.bean;
import java.io.Serializable;
import org.nutz.dao.entity.annotation.*;
import java.util.Date;
/**
 * 通过 DBCodeCreateTool 代码自动生成
 * @time 2016-08-23 11:29:08
 */
@Table("t_sku")
public class Sku implements Serializable{
    private static final long serialVersionUID = 1L;
    /********** attribute ***********/
    /**
     * 商品状态-删除
     */
    public static final String STATE_RM = "0";

    /**
     * 商品状态-上架
     */
    public static final String STATE_ON = "1";

    /**
     * 商品状态-下架
     */
    public static final String STATE_OFF = "2";

    /**
     * 默认图片文件名
     */
    public static final String IMG_DFT = "sku_default.png";

    @Id
    @Column("sku_id")
    private int sku_id;
    
    @Column("sku_goods_id")
    private int sku_goods_id;
    
    @Column("img")
    private String img;
    
    @Column("colour")
    private String colour;
    
    @Column("size")
    private String size;

    @Column("remark")
    private String remark;
    /****创建时间 ****/
    @Column("ctime")
    private Date ctime;
    /****更新时间 ****/
    @Column("utime")
    private Date utime;
    /****状态 ****/
    @Column("state")
    private String state;

    public Sku() {}
    public Sku(int sku_id, int sku_goods_id, String img, String colour, String size, String remark, Date ctime, Date utime, String state) {
        this.sku_id = sku_id;
        this.sku_goods_id = sku_goods_id;
        this.img = img;
        this.colour = colour;
        this.size = size;
        this.remark = remark;
        this.ctime = ctime;
        this.utime = utime;
        this.state = state;
    }
    /********** get/set ***********/
    public int getSku_id() {
        return sku_id;
    }
    public void setSku_id(int sku_id) {
        this.sku_id = sku_id;
    }
    public int getSku_goods_id() {
        return sku_goods_id;
    }
    public void setSku_goods_id(int sku_goods_id) {
        this.sku_goods_id = sku_goods_id;
    }
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    public String getColour() {
        return colour;
    }
    public void setColour(String colour) {
        this.colour = colour;
    }
    public String getSize() {
        return size;
    }
    public void setSize(String size) {
        this.size = size;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Date getCtime() {
        return ctime;
    }

    public void setCtime(Date ctime) {
        this.ctime = ctime;
    }

    public Date getUtime() {
        return utime;
    }

    public void setUtime(Date utime) {
        this.utime = utime;
    }

    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
}

为什么 查不到sku的值呢

goodsList = dao.fetchLinks(dao.query(Goods.class,null) , "sku");
1 回复
private List<Sku> Sku;

goodsList = dao.fetchLinks(dao.query(Goods.class,null) , "sku");

// Sku != sku

属性不要大写字母开头

添加回复
请先登陆
回到顶部