Hibernate - why use many-to-one to represent a one-to-one?

后端 未结 5 976
再見小時候
再見小時候 2020-11-28 06:40

I\'ve seen people use many-to-one mappings to represent one-to-one relationships. I\'ve also read this in a book by Gavin King and on articles.

For example, if a cu

5条回答
  •  抹茶落季
    2020-11-28 07:16

    It's even in official Hibernate docs: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/associations.html#assoc-bidirectional-121.

    It's not totally unreasonable. The many-to-one end says: I am mapped via one of my columns to an ID of the -one end. You would use the exact same database schema for many-to-one.

提交回复
热议问题