Hibernate Tutorial 19 - Implementing Inheritance With Table Per Class Strategy

preview_player
Показать описание
Table per class inheritance strategy.
Рекомендации по теме
Комментарии
Автор

Thank You for the entire tutorial.. You are too good. 
The knowledge that you possess, the way you explain. PERFECT 
Thank You So much

SoHitJodi
Автор

Hi Koushik,
This tutorial contradicts your explanation provided in Tutorial 17 in which you said it is difficult to decide which table FK relationship maintain to.
Suppose with this strategy I have a user class that has list of Vehicle and we are implementing One-To-Many relationship with Vehicle class. Then in that list I add Vehicle object, TwoWheeler object, FourWheeler object.
Then I am saving the user object into the DB with cascadeType.ALL
Now because of One-To-many there will be a mapping table created by Hibernate.Can you please explain which PK id will be considered in the mapping table as we have 3 different kind of Vehicle object.

niketkumar
Автор

Concepts are well explained. thank you

sphiwemodise
Автор

because even if the members are private, you still have public getter/setter which are inherited, and then accessible through the children classes.

Shikam
Автор

when 9 year old video helps me a issue i face for half day

vishaln
Автор

@NullPointerDude i changed it also, but now vehicleId is incrementing like this: 32768, 65536 and so on... Do you have any idea how to solve this problem?

pokipsi
Автор

Hi, wonderful tutorial !! I have a question. Is it possible to sort in this strategy in fields that are not in the parent but are in children? Do you have any idea? And if not then you can give an alternative.Thanks :)

dsvdfsvfd
Автор

You failed to explain how this solves issue with ForeignKey that you explained in the beginning of "Implementing Inheritance". If a User class has a memeber variable of VehicleClass and it does getVehicle, which table will it refer and fetch? TwoWheeler or FourWheeler?

AbhishekGupta-kncz
Автор

Please help me out ... I have a doubt in this video :
Vehicle member varibles are private, meaning they wont be inherited by TwoWheeler and FourWheelers Classes . Speaking other way, TwoWheeler and FourWheeeler class wont be having a seperate copy of Vehicle Id and VehicleName . Even then we can see that Hibernate creates separate column ( and values ) for Vehicle Id and VehicleName in the TwoWheeler and FourWheelers Classes . I am not able to understand this part . Please help me out .

vs
Автор

@pokipsi777 does it actually matter ? the id's are used as a primary key to make the entry unique. It doesn't serve any other purpose

nmbpeterv
Автор

You should include option to download your code!

anetakostic
Автор

Hi All, I have written same code which is shown in this tutorial but in twowheeler and fourwheeler table my vehicle_name value is null whereas vehicle_id is correct. Please suggest what is the reason of not getting vehicle_name. Thanks in advance.

sajidalikhan
Автор

Hi Santosh... Are you getting any error. If Yes, can you please paste that error.

yashjadhav
Автор

Hi Kosuhik, I am getting this error "Cannot use identity column key generation with union-subclass mapping for" . I am using MySQL DB. if I change to ), the error is resolved. But you have used AUTO only in this tutorial and still it's working for you. Is this error DB specific?

nehaagrawal
Автор

Agree with last comment. GenerationType would be TABLE if u use table per class.

nehajain
Автор

@pokipsi777 You need a table generator.

simplyianm