0

I'm not even sure this is really a M2M relationship, but I'll describe it and hopefully someone can help with the mapping:

@Entity
public class EntityOne {
    @Id
    private Long id;

    // other properties
}

I need to map this as a parent/child relationships with some additional data that goes along with each row. For example:

parent_entity_one_id | child_entity_one_id | some_boolean_property 100 | 200 | false 100 | 201 | false 100 | 202 | true 101 | 300 | false 102 | 301 | false 103 | 302 | true

I've tried with some @ManyToMany mappings but that only seems appropriate when the relationship is between 2 entities; like User & Role for example. But I'd like for parent_entity_one_id and child_entity_one_id to be a composite key is possible.

Gregg
  • 34,973
  • 19
  • 109
  • 214
  • I saw that answer and I believe it is different. Again, as I mentioned, the typical M2M references 2 tables. This is referencing a parent/child relationship with the single entity. – Gregg Feb 21 '17 at 23:01
  • It is unclear what you are asking. Post the entities with the relationships you hope to achieve. – Alan Hay Feb 22 '17 at 10:43
  • @AlanHay I'm not sure I can be more clear in that I actually did show the entity that I'm working with in addition to the structure that I hope to achieve with the mappings I'm having an issue with. That said, I've solved the problem and will post an answer soon. – Gregg Feb 22 '17 at 14:10
  • Well, as it turns out, I can't post an answer because folks think this is a duplicate even though it isn't. – Gregg Feb 22 '17 at 14:11

0 Answers0