I have a class User. A user can be a friend with many other users. The relationship is mutual. If A is a friend of B then B is a friend of A. Also I want every relation to store additional data - for example the date when two users became friends. So this is a many-to-many relationship on the same table with additional columns. I know that a middle class Friendship should be created(containing two user ids and column for the date). But I am coming short at mapping this with Hibernate. The thing that stops me is that the mapping is to the same table. I can solve it, if the many-to-many relationship was between two different tables.
相关问题
- How does the JPA handle partial, non-disjoint inhe
- Tell hibernate hbm2ddl not create individual table
- Should there be an EntityManager per thread in Spr
- Hibernate and multiThread Logic
- Why does Hibernate perform a JNDI lookup?
相关文章
- 用哪个ORM好点,博客园用的什么
- Hibernate Tutorial - Where to put Mapping File?
- Hibernate doesn't generate cascade
- Setup and Tear Down of Complex Database State With
- Is this the right way of using ThenFetch() to load
- Does aiohttp have ORM?
- How to map an abstract collection with jpa?
- Two foreign keys as primary key
I had the same problem. You can try something like this:
I'm not sure this will fit your case, but give it a try.
You have said
It is not a good idea. It is a nightmare to maintain.
Try this one instead
regards,