/* */ }
/* */
/* */ public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx)
/* */ throws CreateException
/* */ {
/* 75 */ PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext();
/* */ Object pk;
/* 76 */ if (ctx.getId() == null) { Connection con = null;
/* 79 */ PreparedStatement ps = null;
/* 80 */ ResultSet rs = null;
/* */ Object pk;
/* */ try { if (this.log.isDebugEnabled())
/* */ {
/* 85 */ this.log.debug("executing sql: " + this.pkSql);
/* */ }
/* */
/* 88 */ con = this.entityBridge.getDataSource().getConnection();
/* 89 */ ps = con.prepareStatement(this.pkSql);
/* 90 */ rs = ps.executeQuery();
/* */
/* 92 */ if (!rs.next())
/* */ {
/* 94 */ throw new CreateException("pk-sql " + this.pkSql + " returned no results!");
/* */ }
/* */
/* 97 */ pk = this.pkField.loadArgumentResults(rs, 1);
/* 98 */ pctx.setFieldValue(this.pkField.getRowIndex(), pk);
/* 99 */ pk = this.entityBridge.extractPrimaryKeyFromInstance(ctx);
/* */ }
/* */ catch (SQLException e)
/* */ {
/* 103 */ this.log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e);
/* 104 */ throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState());
/* */ }
/* */ finally
/* */ {
/* 109 */ JDBCUtil.safeClose(rs);
/* 110 */ JDBCUtil.safeClose(ps);
/* 111 */ JDBCUtil.safeClose(con);
/* */ }
/* */
/* 114 */ if (pk == null)
/* */ {
/* 116 */ this.log.error("Primary key for created instance is null.");
/* 117 */ throw new CreateException("Primary key for created instance is null.");
/* */ }
/* */
/* 120 */ pctx.setPk(pk);
/* */ }
/* */ else
/* */ {
/* */ try
/* */ {
/* 127 */ pctx.flush();
/* */ }
/* */ catch (SQLException e)
/* */ {
/* 131 */ if ("23000".equals(e.getSQLState()))
/* */ {