NutzCN Logo
问答 自关联的pojo如何设计
发布于 244天前 作者 cxc3214 282 次浏览 复制 上一个帖子 下一个帖子
标签:

我有个menu表是一个树形菜单

public class Menu{
    private int id;
    private Menu parentMenu; 
    @Many(field="parentMenu",target=Menu.class)
    private List<Menu> subMenu;
}

启动后 报错了

Caused by: org.nutz.dao.DaoException: host class=simple.system.simpleweb.module.menu.model.Menu, props=subMenus @Many(field="parentMenu",key="")) expect prop=parentMenu found at target class=simple.system.simpleweb.module.menu.model.Menu
	at org.nutz.dao.impl.entity.field.ManyLinkField.<init>(ManyLinkField.java:41) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.dao.impl.entity.AnnotationEntityMaker.make(AnnotationEntityMaker.java:294) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.dao.impl.EntityHolder.getEntity(EntityHolder.java:72) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.dao.impl.entity.field.AbstractLinkField.getLinkedEntity(AbstractLinkField.java:72) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.dao.impl.entity.field.ManyLinkField.<init>(ManyLinkField.java:26) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.dao.impl.entity.AnnotationEntityMaker.make(AnnotationEntityMaker.java:294) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.dao.impl.EntityHolder.getEntity(EntityHolder.java:72) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.dao.impl.NutDao.getEntity(NutDao.java:689) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.dao.util.Daos$3.compare(Daos.java:533) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.dao.util.Daos$3.compare(Daos.java:531) ~[nutz-1.r.67.jar:1.r.67]
	at java.util.TimSort.countRunAndMakeAscending(Unknown Source) ~[na:1.8.0_77]
	at java.util.TimSort.sort(Unknown Source) ~[na:1.8.0_77]
	at java.util.Arrays.sort(Unknown Source) ~[na:1.8.0_77]
	at java.util.ArrayList.sort(Unknown Source) ~[na:1.8.0_77]
	at java.util.Collections.sort(Unknown Source) ~[na:1.8.0_77]
	at org.nutz.dao.util.Daos.createTables(Daos.java:531) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.dao.util.Daos.createTablesInPackage(Daos.java:463) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.plugin.spring.boot.listener.NutzDataBaseIniter$1.invoke(NutzDataBaseIniter.java:39) ~[nutz-plugins-spring-boot-starter-1.r.67.jar:na]
	at org.nutz.plugin.spring.boot.listener.NutzDataBaseIniter$1.invoke(NutzDataBaseIniter.java:35) ~[nutz-plugins-spring-boot-starter-1.r.67.jar:na]
	at org.nutz.lang.Lang.each(Lang.java:1598) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.lang.Lang.each(Lang.java:1563) ~[nutz-1.r.67.jar:1.r.67]
	at org.nutz.plugin.spring.boot.listener.NutzDataBaseIniter.create(NutzDataBaseIniter.java:35) ~[nutz-plugins-spring-boot-starter-1.r.67.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_77]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_77]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_77]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:363) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:307) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	... 18 common frames omitted
6 回复

field和key都是关联属性名,不是管理对象,仔细看文档,nutz不支持隐藏关联字段的

像这种自关联的对象 是不是这样写?

public class Menu{
    private int id;
    private int parentId; 
    @Many(field="parentId")
    private List<Menu> subMenu;
}

能不能发个论坛安卓app 的下载地址,这个二维码扫出来下载不了 提示“没有被小米商店收录”

额,被下架了?

目前是下载不了
给个其他链接下载吧

得试试还能不能编译...

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