Annotation Interface SQLUpdate
The given SQL 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,
the primary key columns come last unless
the entity is versioned, in which case
there must be a second JDBC parameter for the version column, which comes
after the primary key.
If a column should not be written as part of the update statement,
and has no corresponding JDBC parameter in the custom SQL, it must be mapped
using updatable=false
.
A custom SQL update 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 update is executed unless
@Generated(event=UPDATE)
is specified, forcing Hibernate
to reread the state of the entity after each update.
Similarly, a custom update 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 update is executed unless
@Generated(event=UPDATE, writable=true)
is specified, again
forcing Hibernate to reread the state of the entity after each update.
If an entity has secondary
tables, it may have a @SQLUpdate
annotation for each secondary table.
The table()
member must specify the name of the secondary table.
-
Required Element Summary
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
Is the statement callable (aka aCallableStatement
)?Deprecated.The name of the table affected by the update statement.Class<? extends Expectation>
AnExpectation
class used to verify that the operation was successful.
-
Element Details
-
sql
String sqlProcedure name or SQLUPDATE
statement.
-
-
-
callable
boolean callableIs the statement callable (aka aCallableStatement
)?- Default:
- false
-
verify
Class<? extends Expectation> verifyAnExpectation
class used to verify that the operation was successful.- Default:
- org.hibernate.jdbc.Expectation.class
-
check
Deprecated.useverify()
with anExpectation
classAResultCheckStyle
used to verify that the operation was successful.- Default:
- NONE
-
table
String tableThe name of the table affected by the update statement. Required when the statement affects a secondary 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:
- ""
-
verify()
with anExpectation
class