Announcement Announcement Module
Collapse
No announcement yet.
Roo hint on relationships Order/LineOrder confusing - since ManyToMany created Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo hint on relationships Order/LineOrder confusing - since ManyToMany created

    Brand new to using Roo. Starting my app I needed a oneToMany, ManyToOne relationship - similar to how I'd think a "Order" and "LineItem" behavior would work. When in the roo console and you do 'hint relationships' you get:

    Code:
    You create persistent relationships via 'field set' and 'field reference'.
    
    For example, consider the typical Order <-> LineItem case:
    
       ENTITY: Order            ENTITY: LineItem
       Set<LineItem> items      Order order
    
    To setup this relationship in Roo, you would use:
    
    field set --fieldName items --class Order --type LineItem --mappedBy order
    field reference --fieldName order --class LineItem --type Order --notNull
    Yet, if I follow that you end up with a ManyToMany relationship in Order for "items" which is not typically correct. Buried in the JPA docs I saw an example where --cardinality is mentioned, but it wasn't obvious in the docs. I had to add --cardinality ONE_TO_MANY to get the relationship I was expecting (maybe that shouldn't be mentioned in the hint?) Shouldn't the default be OneToMany and ManyToOne anyway? And then if you need ManyToMany you'd add the cardinality?

    That hint is very confusing in my opinion since it's not even how Orders/LineItems typically work ( multiple orders don't typically share the same linesItems do they?)
Working...
X