File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Mapping  java.util.List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Mapping  java.util.List" Watch "Mapping  java.util.List" New topic

Mapping java.util.List

Kunal Sathe
Ranch Hand

Joined: Apr 08, 2005
Posts: 49
Hello All,

I am relatively new to Hibernate and hence this question. I have a java class that contains elements of the type java.util.List.

public class Application extends DataObject {

private List investments = null;

public List getInvestments() {
return investments;

public void setInvestments(List investments) { = investments;


I am creating the Hibernate mapping file. How do I map an attribute of the type java.util.List.

Any help will be highly appreciated. If you can point me to the right place in the documentation, that will be great too.

Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
List is an interface; you need to use an implementing class, like

and map it with a <list>.
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Kunal,

from "Java Persistence with Hibernate (Manning 2006)

Item has a List of Bids.

Kunal Sathe
Ranch Hand

Joined: Apr 08, 2005
Posts: 49
Thanks for your responses Edvins and Hermann. I am implementing the solution.

I agree. Here's the link:
subject: Mapping java.util.List
It's not a secret anymore!