I'm trying to use Spring Roo to generate entities with a @OneToMany
unidirectional relationship. Here's what I've tried:
entity --class ~.family.Child
field string --fieldName name
controller scaffold ~.web.ChildController
entity --class ~.family.Father
field string --fieldName name
field set --fieldName children --element ~.family.Child --cardinality ONE_TO_MANY
controller scaffold ~.web.FatherController
perform package
This produces the expected entities and database tables (including a link table.) The Father
entity is generated with the following annotation, which conforms to the JPA spec:
@OneToMany(cascade = CascadeType.ALL)
private Set<family开发者_运维问答.Child> message = new java.util.HashSet<family.Child>();
But when I go to the Roo-generated admin page, and click Create Father
, I find the following message:
Create Father
Name: (field to enter name)
Children: This relationship is managed from the Father side.
This looks like a bug in Roo. Has anyone found a work-around? Or do I have an error in here?
OK, here's a workaround: In the fathers/create.jspx
file, Roo generates the following line:
<field:simple field="children" id="c:family.Father.children" messageCode="entity.reference.not.managed"
messageCodeAttribute="Child" z="dMKrUOiCeYNub4vNayuiWJ99s1k="/>
This should be replaced by:
<field:select field="children" id="c:family.Father.children" itemValue="id"
items="${children}" multiple="true" path="/children"/>
And it should work.
Yes, that is a bug, probably!
I had the same command. It worked with an older version of Roo, but I tried an old backup script. It is no more working.
精彩评论