I have the following class:
Code:
@Entity
@Table(name = "locations")
public class Location {
@Id
private int id;
...
@CollectionOfElements(fetch = FetchType.EAGER)
@JoinTable(
name = "types_with_location_view",
joinColumns = @JoinColumn(name = "location_id")
)
@Column(name = "type")
@Basic(fetch = FetchType.EAGER)
private List<String> types;
...
}
Which corresponds to the following database schema:
Code:
CREATE TABLE locations (
id int(10) unsigned NOT NULL auto_increment,
...
PRIMARY KEY (`id`)
)
CREATE TABLE locations_types (
location_id varchar(16) NOT NULL,
type_id smallint(5) unsigned NOT NULL,
PRIMARY KEY (`location_id`,`type_id`)
)
CREATE TABLE types (
id smallint(5) unsigned NOT NULL auto_increment,
type varchar(10) NOT NULL,
PRIMARY KEY (`id`)
)
My problem is when I get a Location using a Hibernate query, the Location.types instance is a PersistentBag. I thought setting the fetch type to EAGER would force hibernate to use an ArrayList or something.
I can't have any Hibernate specific classes in my Location object after Hibernate returns it back to me. Can anyone help me out here?
Thanks,
Eric