I'm having some awful JAXB/Hibernate crossover problems with Sets. In order to send my objects with JAXB, I have had to make my Sets non-generic, as it can't find the generics information. However, I can't seem to get Hibernate to accept that my subclass of Set is a Set. At once, I got "Illegal attempt to map a non collection as a @OneToMany ..." exception, which I soon found was because Hibernate only accepts a few classes for @OneToMany. I thought (from the fairly sparse docs) that I could use the @Target annotation to tell Hibernate that it should consider the field a Set regardless of what reflection says, but I'm still getting the same exception.
My class (in excerpt) looks like this:
Code:
@Entity
@Table(name = "OC_ConfigurationSet")
public class ConfigurationSet {
@Id
@Column(name = "Id")
long id;
@OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE}, targetEntity = DeliveryConfig.class)
@JoinTable(name="OC_ConfigSetXDeliveryConfig",
joinColumns= @JoinColumn(name = "ConfigurationSetID"),
inverseJoinColumns= @JoinColumn(name = "DeliveryConfigID"))
@Target(Set.class)
DeliveryConfigSet deliveries;
}
The DeliveryConfigSet class is this simple:
Code:
public class DeliveryConfigSet extends HashSet<DeliveryConfig> {
}
Should @Target in conjunction with the targetEntity argument on @OneToMany not be able to do this for me? Is there some other way I can convince Hibernate to map this?
I'm using the Hibernate that comes with JBoss 5.1.0 GA (I believe that is 3.3.1.GA) on an Ubuntu 8.10 x86 box against an Oracle 10 database.
Thanks in advance,
-Lars