Hi All,
I just cannot use @CollectionOfElements with @Embeddable. The following is my classes and mappings:
@MappedSuperclass public abstract class AbstractEntity implements Serializable { @CollectionOfElements protected Set<Audit> audits; ... }
@Embeddable public class Audit implements Serializable { @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "user_id", nullable = false) protected User user;
@Temporal(TemporalType.TIMESTAMP) @Column(name = "time_stamp") protected Date timeStamp = null; ... }
@Entity @Table(name = "test_result") public class TestResult extends AbstractEntity { ... }
Hibernate created the following table:
CREATE TABLE `test_result_audits` ( `test_result_id` bigint(20) NOT NULL, `timeStamp` datetime DEFAULT NULL, `user` tinyblob, KEY `FK7698D96DD913D5B7` (`test_result_id`), CONSTRAINT `FK7698D96DD913D5B7` FOREIGN KEY (`test_result_id`) REFERENCES `test_result` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
The annotations in the Embeddable class are totally ignored. I have tried different ways in the past several days, but nothing worked.
Any help will be appreciated.
-ZJ
|