Hi all,
I'm new to JPA and am running into a problem for which I haven't found an answer yet. I was hoping someone here could lead me in the right direction.
My database (MySQL) is setup as such:
Code:
CREATE TABLE `snapshots` (
`id` BIGINT(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE = InnoDB;
CREATE TABLE `snapshots_timestamps` (
`id` BIGINT(20) NOT NULL,
`key` VARCHAR(50) NOT NULL,
`value` DATETIME NOT NULL,
PRIMARY KEY (`id`, `key`)
) ENGINE = InnoDB;
I'm working to create an entity as follows:
Code:
import org.joda.time.LocalDateTime;
@Entity
@Table(name = "snapshots")
public Snapshot {
private Map<String, LocalDateTime> timestamps;
@Column(name = "value", nullable = false)
//@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
@ElementCollection(fetch = FetchType.EAGER)
@MapKeyColumn(name = "key", nullable = false)
@Fetch(FetchMode.SELECT)
@CollectionTable(name = "snapshot_timestamps", joinColumns = @JoinColumn(name = "id"))
public Map<String, LocalDateTime> getTimestamps() {
return timestamps;
}
}
The @Type declaration shown is what I'd normally use if it was a simple column. However, this doesn't seem to work, resulting in the following error when attempting to persist the entity:
Quote:
org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl release
INFO: HHH000010: On release of batch it still contained JDBC statements
The entity does not persist.
So I know I'm doing something wrong. I'm really hoping it's something simple, but will appreciate whatever guidance the community can provide.
Thanks so much!
Chris