NutzCN Logo
问答 如何新增一条address类数据的时候,也能插入一条关联数据到address_user这个表
发布于 2089天前 作者 qq_753729fe 1871 次浏览 复制 上一个帖子 下一个帖子
标签:
public class Address {

    private static final long serialVersionUID = -965829144356813385L;

    @Id
    private Long id;    // 逻辑id

    @Column
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String areaName;  // 地址名称

    @Column
    @ColDefine(type = ColType.FLOAT)
    private float longitude;  // 经度

    @Column
    @ColDefine(type = ColType.FLOAT)
    private float latitude;  // 纬度

    @Column
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String phone;    // 手机号

    @Column
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String adcode;   // 行政区划代码

    @Column
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String name;  // 姓名


    @ManyMany(target = Role.class, relation = "address_user", from = "addressid", to = "userid")
    private List<User> users;

这个address_user表
@ManyMany(target = Role.class, relation = "address_user", from = "addressid", to = "userid")

4 回复

下面这样插入还是不行,麻烦帮忙看下

 public void insert(final Address address) {


        Trans.exec(new Atom(){
            public void run() {
                dao().insertWith(address, "users");
            }
        });
    }

users有没有值?有才会操作

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