Hi ranchers,
I'm new to hibernate and could do with some advice. I've done lots of reading and have got started....so far so good
However, despite reading this excellent link
http://www.xylax.net/hibernate/index.html and others, i'm still a little unsure on how to map pojo's that may have inheritance or composition.
OK as an example lets imagine database tables:
Product(id, other product stuff)
TyreProduct(id, tyreWidth, tyreRim, other tyre product stuff)
BeerProduct(id, other beer specific product stuff)
So id is the primary key of product and tyreproduct or beer product have a one-to-one relationship (so the same pk).
My basic POJO may look like:
So my question is...is the class design ok and how would one tackle the mapping? I've had a play but don't seem to quite get things correct at the moment. I'm thinking that i need to use "one table per concrete class". Does that sound the best way? And if so how would my mapping look?
Thats my first question.
My second question is concerning composition. Lets imagine i have a class called TyreSize that records all the details required for a tyre size. So the class may look like:
With this new TyreSize object i could therefore remove the width and other tyre size specifics so my TyreProduct class could look like:
So is the use of the TyreSize object inside TyreProduct ok...and how would i map that?
I feel greedy asking two questions like this....but any help to get me on my way would be greatly appreciated. I think if i could see something in action for the above a lot of the reading i have done already would probably fall into place.
Cheers
