• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mapping advice

 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

This is the current mapping i have:



I think for performance its better to have only one collection (in order to have 1 FK and one join), but from the OO (object oriented) point of view is better to have different category list for each category type.


What do you think?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, technically, what you posted isn't your mapping, it is your Object Model.

But, why not put it into one Map, Map<String, List<Category>>

Or if you have Subclasses of Category, then use

List<? super Category>

But in that case, whenever you need to know the exact type to cast or something then you will have to check the actual type. But if all your code in Supplier just calls methods of Category (interface or super class) then you won't have to know the exact type.

Hope that helps

Mark
 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will consider Map (i need first to read on it).
In the book there is a chapter on legacy.

One of the example is that item has 1:m with Bid and also 1:1 with Bid (the successfull bid). they solve it with formula.

Do you think formula can be a solution here? or this is not the solution that you need to consider on the first place (this is the chapter about legacy and in my case i run hbm2ddl).

Thank you
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by avihai marchiano:
I will consider Map (i need first to read on it).
In the book there is a chapter on legacy.

One of the example is that item has 1:m with Bid and also 1:1 with Bid (the successfull bid). they solve it with formula.

Do you think formula can be a solution here? or this is not the solution that you need to consider on the first place (this is the chapter about legacy and in my case i run hbm2ddl).

Thank you


yeah, I think they are different.

You have different Category types, which might be better mapped with Inheritance mappings.

The Bid and Item relationships are two different relationships in the database. One for all the bids the item has received, this is with the Bid table having a fk item_id in the Bid table, whereas the successful Bid is a bid_id field in the Item table.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic