HHH-18216 delegate @Save to insert() when entity has no id assigned
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
1657a19baf
commit
386bb1138a
|
@ -131,6 +131,24 @@ public class LifecycleMethod extends AbstractAnnotatedMethod {
|
|||
.append(parameterName)
|
||||
.append(") {\n\t");
|
||||
}
|
||||
if ( "upsert".equals(operationName) ) {
|
||||
//TODO: only do this for @GeneratedValue
|
||||
declaration
|
||||
.append("\t\tif (")
|
||||
.append(sessionName)
|
||||
.append(".getFactory().getPersistenceUnitUtil().getIdentifier(")
|
||||
.append(iterateParameter ? "_entity" : parameterName)
|
||||
.append(") == null)\n")
|
||||
.append("\t\t\t")
|
||||
.append(sessionName)
|
||||
.append('.')
|
||||
.append("insert")
|
||||
.append('(')
|
||||
.append(iterateParameter ? "_entity" : parameterName)
|
||||
.append(')')
|
||||
.append(";\n")
|
||||
.append("\t\telse\n\t");
|
||||
}
|
||||
declaration
|
||||
.append("\t\t")
|
||||
.append(sessionName)
|
||||
|
|
Loading…
Reference in New Issue