0

I have to map a table using JPA, but this table has a multicolumn key with some of that as Oracle virtual columns. When I try to make the insert, Hibernate (the implementation of JPA that I've used) return to me this error:

"ORA-54013: INSERT operation disallowed on virtual columns"

I've tried @Column(name = "field", insertable = false, updatable = false) on my fields, but because the field is part of a the table multifields key, apparently JPA need to write this field anyway.

I can't modify the DB, i'm searching for a solution that involes only hibernate.

Has anyone encountered the same problem and has a solution?

  • I have... But that's really long ago. What I have in my memory is that the problem was solved by adding writable views in front of it – Gimby Jul 03 '19 at 07:30
  • Thank you for the answer, but I can't modify the DB, i'm searching for a solution that involes only hibernate. – Giuseppe Caiazzo Jul 03 '19 at 07:42
  • Fair enough; but Hibernate is not the problem here. It's a database error, not a Hibernate one. Hibernate has little knowledge of Oracle's virtual columns, it just wants to write data to a table. – Gimby Jul 03 '19 at 07:45
  • Ok, and is possible to say hibernate to not write on a column even if it is a key column? – Giuseppe Caiazzo Jul 03 '19 at 07:47
  • `@Transient` would remove the field from every query generated by hibernate. Though that also includes selects – XtremeBaumer Jul 03 '19 at 07:52
  • Exactly, i need the fields in all the queries but not in the insert one. Even i need that hibernate engine recognize that 2 entities are equals using all the fields of the key. With @Transient I will lost this feature. – Giuseppe Caiazzo Jul 03 '19 at 07:55
  • For equality, hibernate should use the `equals()` method and not some annotations (atleast afaik) – XtremeBaumer Jul 03 '19 at 08:05
  • I've tried to ridefine to equals method but hibernate ignore it. – Giuseppe Caiazzo Jul 03 '19 at 08:08
  • Not sure if this is the right approach as hibernate provide query interceptors which can be used to modify the query before sending it to the database,we have used it in our project.It can be used in this case,but this might not be a very clean solution. – user06062019 Jul 03 '19 at 09:31

0 Answers0