Is it possible to patch an entity in Hibernate not on a specific table, but on predefined queries?

Those. let me have a class

class Test { private int Id; private String Name; private String Remark; } 

and in the database there is a table of such a structure

 CREATE TABLE sqls ( `name` VARCHAR, `select` CLOB, `refresh` CLOB, `insert` CLOB `update` CLOB `delete` CLOB ); INSERT INTO sqls ( `name`, `select`, `refresh`, `insert`, `update`, `delete` ) VALUES ( "TEST", "SELECT id, name, remark FROM mytable", "SELECT id, name, remark FROM mytable WHERE id = :id", "INSERT INTO mytable (id, name, remark) VALUES (:id, :name, :remark)", "UPDATE mytable SET name = :name, remark = :remark WHERE id = :id", "DELETE FROM mytable WHERE id = :id" ); 

and I want my class to work not directly with the table mytable , but through such predefined queries. By itself, requests will not be so simple. There will be both joins and procedure calls for insert / update

If Hibernate does not know how to do this, is there ORMy with this functionality?

  • one
    The @ NamedQueries and @ NamedQuery mechanism just allows you to perform predefined queries. They need to annotate Entity. @ NamedNativeQueries @ NamedNativeQuery also exist - many mny 6:50 pm
  • @manymny From what I found. 1) The query can be defined only at compilation. In rantayme it is impossible. (Or manually collect the config) 2) Only a SELECT query can be defined. Any INSERT / UPDATE for a particular entity cannot be determined at all - Anton Shchyrov
  • one
  • @manymny Thank you. Just my case. ORM is not applicable when you have rules that don't map to the ORM logic. And the last post direct execution of UPDATE without being tied to an entity. - Anton Shchyrov

0