// insert-after-ejb-post-create
try {
pctx.flush();
} catch (SQLException e) {
if ("23000".equals(e.getSQLState())) {
throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getPrimaryKey());
} else {
throw new CreateException("Failed to create instance: pk=" + ctx.getPrimaryKey() +
", state=" + e.getSQLState() +
", msg=" + e.getMessage());
}