Hello.
The problem appeared after updating to Hibernate to 6 (from 5.6 to 6.2.0.CR3).
I have entity:
@Entity
@Table(name = "message_queue")
public class MessageQueue {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "message_queue_revision_generator")
@SequenceGenerator(name = "message_queue_revision_generator", sequenceName = "message_queue_revision_seq", allocationSize = 1, schema = "chat")
private Long revision;
@Column(insertable = false, updatable = false)
private long messageId;
@Column(insertable = false, updatable = false)
private long channelId;
@ManyToOne
@JoinColumns({
@JoinColumn(name = "channelId", referencedColumnName = "channel_id"),
@JoinColumn(name = "messageId", referencedColumnName = "id")
})
private ChannelMessage message;
}
and
@Entity
@DynamicUpdate
@Table(name = "messages")
public class ChannelMessage extends ChannelMessageRaw {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "messages_id_generator")
@SequenceGenerator(name = "messages_id_generator", sequenceName = "messages_id_seq", allocationSize = 1, schema = "chat")
private long id;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
private ChatChannel channel;
}
And when the service starts, an error appears:
Caused by: org.hibernate.tuple.entity.CompositeValueGenerationException: Property of on-execution generated embeddable is not generated: _com_repository_subscribers_entity_MessageQueue_message.id
at org.hibernate.tuple.entity.CompositeGeneratorBuilder.createCompositeOnExecutionGenerator(CompositeGeneratorBuilder.java:104) ~[hibernate-core-6.2.0.CR3.jar:6.2.0.CR3]
at org.hibernate.tuple.entity.CompositeGeneratorBuilder.build(CompositeGeneratorBuilder.java:71) ~[hibernate-core-6.2.0.CR3.jar:6.2.0.CR3]
at org.hibernate.tuple.entity.EntityMetamodel.buildGenerator(EntityMetamodel.java:489) ~[hibernate-core-6.2.0.CR3.jar:6.2.0.CR3]
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:312) ~[hibernate-core-6.2.0.CR3.jar:6.2.0.CR3]
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:514) ~[hibernate-core-6.2.0.CR3.jar:6.2.0.CR3]
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:143) ~[hibernate-core-6.2.0.CR3.jar:6.2.0.CR3]
The error is thrown in CompositeGeneratorBuilder class in createCompositeOnExecutionGenerator method. Judging by the code, there is no generator for the id field, although everything is indicated in the annotations. And it is not clear what to do next. Can you advise please.