Hibernate 面接の質問と回答
Question: What does it mean to be inverse?Answer: It informs hibernate to ignore that end of the relationship. If the one-to-many was marked as inverse, hibernate would create a child->parent relationship (child.getParent). If the one-to-many was marked as non-inverse then a child->parent relationship would be created.In Hibernate, only the “relationship owner” should maintain the relationship, and the “inverse” keyword is created to defines which side is the owner to maintain the relationship. However the “inverse” keyword itself is not verbose enough, I would suggest change the keyword to “relationship_owner“. In short, inverse=”true” means this is the relationship owner, and inverse=”false” (default) means it’s not. Suppose Stock is parent and StockDailyRecords is Child object. Inverse keyword is applied in one to many relationship. Here’s the question, if save or update operation perform in “Stock” object, should it update the “stockDailyRecords” relationship? 1. inverse=”true” If inverse=”true” in the set variable, it means “stock_daily_record” is the relationship owner, so Stock will NOT UPDATE the relationship. 2. inverse=”false” If inverse=”false” (default) in the set variable, it means “stock” is the relationship owner, and Stock will UPDATE the relationship. If keyword “inverse” is not define, the inverse = “false” will be used, which is |
復習用に保存
この項目をブックマークに追加したり、難しい内容としてマークしたり、復習セットに入れたりできます。
役に立ちましたか? はい いいえ
ユーザー評価で最も役立つ内容:
- What is Hibernate?
- What is ORM?
- What does an ORM solution comprises of?
- What are the different levels of ORM quality?
- What the Core interfaces are of hibernate framework?