Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of bag tag in Hibernate?

I need to know how to use the bag tag and what is the purpose of it?

like image 374
gokul Avatar asked Jul 22 '10 08:07

gokul


2 Answers

For collection mapping

If your table does not have an index column, and you still wish to use List as the property type, you can map the property as a Hibernate < bag>. A bag does not retain its order when it is retrieved from the database, but it can be optionally sorted or ordered.

http://docs.jboss.org/hibernate/core/3.3/reference/en/html/collections.html

like image 61
Damian Leszczyński - Vash Avatar answered Oct 06 '22 08:10

Damian Leszczyński - Vash


From the API:

A bag is an unordered, unkeyed collection that can contain the same element multiple times. A bag permits duplicates, so it has no primary key. The Java collections API, curiously, has no Bag.

like image 35
McGin Avatar answered Oct 06 '22 06:10

McGin