aspose file tools*
The moose likes Object Relational Mapping and the fly likes Domain Model of Java Persistent with Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Domain Model of Java Persistent with Hibernate" Watch "Domain Model of Java Persistent with Hibernate" New topic
Author

Domain Model of Java Persistent with Hibernate

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
In JPwH's Caveat Emptor domain model (Fig 4.1) it uses 2 associations between Bid and Item classes to represent the successful bid must be from the Set of associated Bid instances. I'm not confortable with this design. For one thing, it is difficult to represent in UML that the associated successful Bid instance must be in the Set of all Bid instances associated with this Item.

I just want to know is there any better way to model this?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Actaully it is what it is.

An Item will have a collection of bids made on it. One of them will be the highest winning Bid.

In the Item, I want to be able to call Bid getWinningBid(), or if I want to list out all the Bids, I want to be able to call List<Bid> getBids()

I could have Java code that loops through the List and gets the one with the highest bid, if the database doesn't store a winning_bid_id in the item table.

In the case of the example app CaveatEmptor, it is in the database and that is how they modeled the relationships and the object model. It is a nice design.

You also need to keep in mind that CaveatEmptor is a sample app to demonstrate all the different types of mapping that you might come accross in Hibernate, not a, this is the design you must follow.

So you can do whatever you want to do in your model or you mapping, Hibernate will be able to handle it.

Personally, I agree with the design in CaveatEmptor on the Item to Bids two relationships, in the object model and the database design. But this is my opinion.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Domain Model of Java Persistent with Hibernate