|
I have a similar bug in that HQL insert statement
It is happening with H2, under hibernate 5.0.0.CR2 and 4.3.2.Final
my query is:
insert into DifferenceVersion ( volume,volumeVersionFrom,volumeVersionTo,parentFrom ) select :vol,:vvfrom,:vvto,dfrom from DirectoryVersion as dfrom where dfrom.volumeVersion=:vvfrom and not exists (select dto from DirectoryVersion dto where dto.volumeVersion=:vvto and dfrom.path=dto.path )
I can give my entities with JPA annotations if useful.
Here is DirectoryVersion (note I use naturalId)
----------------------
??@Entity @Table(uniqueConstraints = @UniqueConstraint(columnNames = { "volumeVersion_ID", "path" }
)) @Cacheable @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @NaturalIdCache(region = "naturalId.DirectoryVersion") public class DirectoryVersion { public DirectoryVersion() { }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID", unique = true, nullable = false) private Long id;
@NaturalId @ManyToOne(optional = false, fetch = FetchType.LAZY) private VolumeVersion volumeVersion;
@NaturalId @Column(nullable=false,/* nullable = false, length = 4096,*/columnDefinition="VARCHAR_IGNORECASE(4096) NOT NULL ") private String path;
@ManyToOne(optional = false, fetch = FetchType.LAZY) private Volume volume;
@ManyToOne(optional = true, fetch = FetchType.LAZY) private DirectoryVersion parent;
@Temporal(TemporalType.TIMESTAMP) private Date modifiedTime;
private Boolean hidden = false;
private Boolean system = false;
@Column(nullable = true, length = 32000) private String errorText;
... } ?? ----------------------
|