Annotation Interface SQLInsert
The givenSQL statement must have exactly the number of JDBC? parameters that Hibernate expects, that is, one for each column mapped by the entity, in the exact order Hibernate expects. In particular, theprimary key columns must come last.
If a column shouldnot be written as part of the insert statement, and has no corresponding JDBC parameter in the custom SQL, it must be mapped usinginsertable=false.
A custom SQL insert statement might assign a value to a mapped column as it is written. In this case, the corresponding property of the entity remains unassigned after the insert is executed unless@Generated is specified, forcing Hibernate to reread the state of the entity after each insert.
Similarly, a custom insert statement might transform a mapped column value as it is written. In this case, the state of the entity held in memory loses synchronization with the database after the insert is executed unless@Generated(writable=true) is specified, again forcing Hibernate to reread the state of the entity after each insert.
If an entity hassecondary tables, it may have a@SQLInsert annotation for each secondary table. Thetable() member must specify the name of the secondary table.
Required Element Summary
Required ElementsOptional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanIs the statement callable (aka aCallableStatement)?Deprecated, for removal: This API element is subject to removal in a future version.useverify()with anExpectationclassThe name of the table affected by the insert statement.Class<? extendsExpectation>AnExpectationclass used to verify that the operation was successful.
Element Details
sql
String sqlProcedure name or SQLINSERTstatement.
callable
boolean callableIs the statement callable (aka aCallableStatement)?- Default:
- false
verify
Class<? extendsExpectation> verifyAnExpectationclass used to verify that the operation was successful.- Default:
- org.hibernate.jdbc.Expectation.class
check
Deprecated, for removal: This API element is subject to removal in a future version.useverify()with anExpectationclassAResultCheckStyleused to verify that the operation was successful.- Default:
- NONE
table
String tableThe name of the table affected by the insert statement. Required when the statement affects asecondary table of an entity. Not required for collections nor when the insert statement affects the primary table of an entity.- Returns:
- the name of the secondary table
- Since:
- 6.2
- Default:
- ""