Рет қаралды 5,666
In today’s video I will compare Composition over Inheritance.
Like all object-oriented programing languages, Java supports the fundamental concepts of inheritance and composition.
There is an important difference between both concepts. Inheritance enables you to model an is-a association between two classes by extending a superclass. Composition models a has-a association by referencing another class in an instance variable.
You can use both concepts with JPA and Hibernate. But when should you use which one and what is the best way to do that?
For plain Java classes, there have been hundreds of discussions about this question. And there is a clear winner.
If you like this video, please give me your thumbs up and share it with your friends and co-workers.
Ultimate Guide to Association Mappings with JPA and Hibernate: www.thoughts-on-java.org/ulti...
Like my channel? Subscribe!
➜ bit.ly/2cUsid8
Join the free Member Library:
goo.gl/dtyIIC
Read the accompanying post: www.thoughts-on-java.org/comp...
Want to connect with me?
Blog: www.thoughts-on-java.org/
Twitter: / thjanssen123
Facebook: / thoughtsonjava