I get the following error:
javax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.xx.xx.xx.S3ObjectsEntity
I already tried this without any effect:
ids for this class must be manually assigned before calling save():
Hibernate: ids for this class must be manually assigned before calling save()
ids for this class must be manually assigned before calling save()
None of the above will work and I get the same error message.
This is my Entity.java:
@Entity
@Table(name = "s3objects", schema = "public", catalog = "CustomerReportBDD")
public class S3ObjectsEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "s3objects_id",unique=true, nullable = false)
private Long s3Objects_Id;
@Basic
@Column(name = "etag", nullable = true, length = 100)
private String etag;
@Basic
@Column(name = "bucketname", nullable = true, length = 100)
private String bucketname;
@Basic
@Column(name = "objectkey", nullable = true, length = 100)
private String objectkey;
@Basic
@Column(name = "lastmodified", nullable = true, length = 100)
private String lastmodified;
@Basic
@Column(name = "storageclass", nullable = true, length = 100)
private String storageclass;
@Basic
@Column(name = "owner_id", nullable = true)
private Integer owner_id;
And the sql script that I used to create the table :
DROP TABLE IF EXISTS s3objects CASCADE;
CREATE TABLE s3objects (
s3objects_id SERIAL,
etag varchar(100),
bucketname varchar(100),
objectkey varchar(100),
lastmodified varchar(100),
storageclass varchar(100),
owner_id varchar(100) ,
CONSTRAINT s3objectsKey PRIMARY KEY(s3objects_id)
);
The owner id is nullable in the base.
I works perfectly, when I manually add all fields in the base (with s3object_id & owner_id at null)
I tried to do that on the entity:
@GeneratedValue ( strategy=GenerationType.AUTO)
And that:
@SequenceGenerator(name="s3ObjectSequence", sequenceName = "s3objects_s3objects_id_seq",allocationSize = 1)
@GeneratedValue ( strategy=GenerationType.SEQUENCE, generator = "s3ObjectSequence")
s3objects_s3objects_id_seq is a sequence present in the base after the creation of the table in the database.
Edit 1:
added the option
<properties>
<property name="hibernate.jdbc.fetch_size" value="1000" />
<property name="show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
In my persist.xml
The tables are created from entities but I always get the same error message.