views:

10

answers:

1

Hello,

I was thinking if I could set the list elements type in hibernate mapping files.

So far I found this collection-type attribute like here:

<list name="privileges" cascade="all" table="user_privilege" collection-type="">

, but I am not sure if I put my list element full class name if Hibernate will generate my domain classes properly.

Is there another way of doing this or I have to manually set types of my Lists in my classes like here:

Generated by Hibernate:

private List privileges = new ArrayList(0);

Manually changed:

private List<UserPrivilege> privileges = new ArrayList(0);

Thanks.

+1  A: 

collection-type attribute set's type of collection class if you want to use some custom Collection implementation, other then standard java.util.ArrayList et consortes.

If your mappings are correct it's just a matter of hbm2java tool settings. See reference.

Example:

<hibernatetool destdir="${build.dir}/generated">
  <configuration configurationfile="hibernate.cfg.xml"/>
  <hbm2java jdk5="true"/>
</hibernatetool>
wciesiel

related questions