Insert into a view in Oracle

In the db there is a table (repo) which uses an identity column (repo_id) for the primary key of the table.
In the db there is a view (bitbucket_repo) which uses the repo table and in the view there is the repo_id column.
We need to insert into bitbucket_repo which of course writes to table repo.
in Hibernate version 5.2.17 it would generate a SQL of:

insert into bitbucket_repo (branch_nm, path_nm, project_nm, repo_nm, repo_type, repo_url) values (?, ?, ?, ?, ?, ?)

however in Hibernate version 6.6.2 the generated SQL is:

insert into bitbucket_repo (branch_nm,path_nm,project_nm,repo_nm,repo_type,repo_url,repo_id) values (?,?,?,?,?,?,default)

this generates an error of:

ORA-32575: Explicit column default is not supported for modifying views

I have tried the @View annotation and tried to use the @GeneratedColumn but could not figure out what to use for the required value arg.

My question is how to do this insert into the view.

Thanks

It’s unfortunate that Oracle doesn’t support the default keyword in this context, but this change was done to fix HHH-13104.
If you are sure that you don’t have entities that are composed of just identifier/PK columns, you can override the OracleDialect to return a subtype of Oracle12cIdentityColumnSupport in Dialect#getIdentityColumnSupport(), which will then return null for getIdentityInsertString().

That way, you can get rid of the identifier column.

I was able to use a annotation to have hibernate generate the insert statement without using the PK column and default keyword:

@Id
@Generated
@JsonProperty("repoId")
@Column(name = "repo_Id", nullable = false)
private Integer repoId;

Thanks for sharing, I was wondering if that could work, but wasn’t sure and didn’t want to suggest something that might not work, but happy to hear this works for you. FTR, this is using the org.hibernate.annotations.Generated annotation.