I am very newbie to hibernate. I am learning about Mappings in hibernate in which case i have to go for Collection Mapping and Association Mapping. My confusion is "If an entity or class has collection of values for a particular variable, then we can map those values using any one of the collection interfaces available in java"
in that case why we go for collection instead of onetomany. Please provide a simple real time example for when we use collection and association mapping
I think you are confused in Collection and Association.
It is not necessary that every association must be a single Object, it can be collection of Objects.
@OneToMany(fetch = FetchType.LAZY, mappedBy = "stock")
public Set<StockDailyRecord> getStockDailyRecords() {
return this.stockDailyRecords;
}
See : http://www.mkyong.com/hibernate/hibernate-one-to-many-relationship-example-annotation/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With