public void setDiscriminator (Discriminator discriminator) { if (this.discriminator != null) { throw new SqlMapException ("A discriminator may only be set once per result map."); } this.discriminator = discriminator; }
public void setDiscriminator (Discriminator discriminator) { if (this.discriminator != null) { throw new SqlMapException ("A discriminator may only be set once per result map."); } this.discriminator = discriminator; }
/** * Get a mappedstatement by its ID * * @param id - the statement ID * @return - the mapped statement */ public MappedStatement getMappedStatement(String id) { MappedStatement ms = (MappedStatement) mappedStatements.get(id); if (ms == null) { throw new SqlMapException("There is no statement named " + id + " in this SqlMap."); } return ms; }
/** * Get a cache model by ID * * @param id - the ID * @return - the cache model */ public CacheModel getCacheModel(String id) { CacheModel model = (CacheModel) cacheModels.get(id); if (model == null) { throw new SqlMapException("There is no cache model named " + id + " in this SqlMap."); } return model; }
/** * Get a parameter map by ID * * @param id - the ID * @return - the parameter map */ public ParameterMap getParameterMap(String id) { ParameterMap map = (ParameterMap) parameterMaps.get(id); if (map == null) { throw new SqlMapException("There is no parameter map named " + id + " in this SqlMap."); } return map; }
/** * Get a parameter map by ID * * @param id - the ID * @return - the parameter map */ public ParameterMap getParameterMap(String id) { ParameterMap map = (ParameterMap) parameterMaps.get(id); if (map == null) { throw new SqlMapException("There is no parameter map named " + id + " in this SqlMap."); } return map; }
public static Date format(String format, String datetime) { try { return new SimpleDateFormat(format).parse(datetime); } catch (ParseException e) { throw new SqlMapException("Error parsing default null value date. Format must be '" + format + "'. Cause: " + e); } }
public void setProperties(Properties props) throws SQLException, TransactionException { String utxName = null; try { utxName = (String) props.get("UserTransaction"); InitialContext initCtx = new InitialContext(); userTransaction = (UserTransaction) initCtx.lookup(utxName); } catch (NamingException e) { throw new SqlMapException("Error initializing JtaTransactionConfig while looking up UserTransaction (" + utxName + "). Cause: " + e); } }
public void setProperties(Properties props) throws SQLException, TransactionException { String utxName = null; try { utxName = (String) props.get("UserTransaction"); InitialContext initCtx = new InitialContext(); userTransaction = (UserTransaction) initCtx.lookup(utxName); } catch (NamingException e) { throw new SqlMapException("Error initializing JtaTransactionConfig while looking up UserTransaction (" + utxName + "). Cause: " + e); } }
public void setDefaultStatementTimeout(Integer defaultTimeout) { errorContext.setActivity("setting default timeout"); if (defaultTimeout != null) { try { defaultStatementTimeout = defaultTimeout; } catch (NumberFormatException e) { throw new SqlMapException("Specified defaultStatementTimeout is not a valid integer"); } } }
public void setJavaTypeName(String javaTypeName) { try { if (javaTypeName == null) { this.javaType = null; } else { this.javaType = Resources.classForName(javaTypeName); } } catch (ClassNotFoundException e) { throw new SqlMapException("Error setting javaType property of ParameterMap. Cause: " + e, e); } }
public void setDefaultStatementTimeout(Integer defaultTimeout) { errorContext.setActivity("setting default timeout"); if (defaultTimeout != null) { try { defaultStatementTimeout = defaultTimeout; } catch (NumberFormatException e) { throw new SqlMapException("Specified defaultStatementTimeout is not a valid integer"); } } }
public void putPreparedStatement(SqlMapExecutorDelegate delegate, String sql, PreparedStatement ps) { if (delegate.isStatementCacheEnabled()) { if (!isInBatch()) { if (hasPreparedStatementFor(sql)) throw new SqlMapException("Duplicate prepared statement found. This is likely a bug."); preparedStatements.put(sql, ps); } } }
/** * Add a mapped statement * * @param ms - the mapped statement to add */ public void addMappedStatement(MappedStatement ms) { if (mappedStatements.containsKey(ms.getId())) { throw new SqlMapException("There is already a statement named " + ms.getId() + " in this SqlMap."); } ms.setBaseCacheKey(hashCode()); mappedStatements.put(ms.getId(), ms); }
public SqlMapSession openSession(Connection conn) { try { SqlMapSessionImpl sqlMapSession = new SqlMapSessionImpl(this); sqlMapSession.open(); sqlMapSession.setUserConnection(conn); return sqlMapSession; } catch (SQLException e) { throw new SqlMapException("Error setting user provided connection. Cause: " + e, e); } }
public void process(Node node) throws Exception { Properties attributes = NodeletUtils.parseAttributes(node, state.getGlobalProps()); String id = attributes.getProperty("id"); if (state.isUseStatementNamespaces()) { id = state.applyNamespace(id); } if (state.getSqlIncludes().containsKey(id)) { throw new SqlMapException("Duplicate <sql>-include '" + id + "' found."); } else { state.getSqlIncludes().put(id, node); } } });
private Class resolveClass(String resultClassName) { try { if (resultClassName != null) { return Resources.classForName(state.getConfig().getTypeHandlerFactory().resolveAlias(resultClassName)); } else { return null; } } catch (ClassNotFoundException e) { throw new SqlMapException("Error. Could not initialize class. Cause: " + e, e); } }
private Class resolveClass(String resultClassName) { try { if (resultClassName != null) { return Resources.classForName(state.getConfig().getTypeHandlerFactory().resolveAlias(resultClassName)); } else { return null; } } catch (ClassNotFoundException e) { throw new SqlMapException("Error. Could not initialize class. Cause: " + e, e); } }
public void process(Node node) throws Exception { Properties attributes = NodeletUtils.parseAttributes(node, state.getGlobalProps()); String type = attributes.getProperty("type"); state.getConfig().getErrorContext().setActivity("configuring the Result Object Factory"); ResultObjectFactory rof; try { rof = (ResultObjectFactory) Resources.instantiate(type); state.getConfig().setResultObjectFactory(rof); } catch (Exception e) { throw new SqlMapException("Error instantiating resultObjectFactory: " + type, e); } } });
private void initialize(ResultSet rs) { if (getResultClass() == null) { throw new SqlMapException("The automatic ResultMap named " + this.getId() + " had a null result class (not allowed)."); } else if (Map.class.isAssignableFrom(getResultClass())) { initializeMapResults(rs); } else if (getDelegate().getTypeHandlerFactory().getTypeHandler(getResultClass()) != null) { initializePrimitiveResults(rs); } else if (DomTypeMarker.class.isAssignableFrom(getResultClass())) { initializeXmlResults(rs); } else { initializeBeanResults(rs); } }