@Override public int getUpdateCount() { if (result.length == 0) { throw new CayenneRuntimeException("No update results"); } if (result.length == 1) { return result[0]; } throw new CayenneRuntimeException("This result is a batch update"); }
@Override public void nextGlobalException(Exception ex) { throw new CayenneRuntimeException(ex); } }
@Override public boolean startUnknownPrefetch(PrefetchTreeNode node) { throw new CayenneRuntimeException("Unknown prefetch node: %s", node); } }
/** * Retrieves a stream to be used to write Ascii characters to the <code>CLOB</code> * value that this <code>Clob</code> object represents, starting at position * <code>pos</code>. * <p> * Calling this method always throws an <code>SQLException</code>. */ public java.io.OutputStream setAsciiStream(long pos) throws SQLException { throw new CayenneRuntimeException("Not supported"); }
/** * Returns a DataContext that holds this object. Object becomes assocaiated with a * DataContext either when the object is fetched using a query, or when a new object * is registered explicitly with a DataContext. */ public DataContext getDataContext() { if (objectContext == null || objectContext instanceof DataContext) { return (DataContext) objectContext; } throw new CayenneRuntimeException("ObjectContext is not a DataContext: " + objectContext); }
/** * This method is used by {@link ExpressionParser} * @param partToken {@link Token#image} from {@link ExpressionParser} */ void setPartToken(String partToken) { part = NAME_TO_PART.get(partToken); if(part == null) { throw new CayenneRuntimeException("Unknown timestamp part: %s", partToken); } this.partName = partToken; }
public ObjEntity getObjEntity(Class<?> entityClass) { ObjEntity entity = objEntitiesByClassName.get(entityClass.getName()); if (entity == OBJ_DUPLICATE_MARKER) { throw new CayenneRuntimeException("Can't perform lookup. There is more than one ObjEntity mapped to %s" , entityClass.getName()); } return entity; }
@Override public void nextGlobalException(Exception ex) { throw new CayenneRuntimeException("Raising from underlyingQueryEngine exception.", Util .unwindException(ex)); } });
/** * Returns a primary key value for a persistent object. Only works for * single column primary keys. If an object is transient or has a compound * ObjectId, an exception is thrown. */ public static Object pkForObject(Persistent dataObject) { Map<String, Object> pk = extractObjectId(dataObject); if (pk.size() != 1) { throw new CayenneRuntimeException("Expected single column PK, got %d columns, ID: %s", pk.size(), pk); } return pk.entrySet().iterator().next().getValue(); }
public Object setValueDirectly(Object value) throws CayenneRuntimeException { if (value == null || value instanceof List) { Object old = this.objectList; setObjectList((List) value); return old; } else { throw new CayenneRuntimeException("Value must be a list, got: %s", value.getClass().getName()); } }
public EhCacheQueryCache(CacheManager cacheManager) { if (cacheManager != null) { this.cacheManager = cacheManager; init(); } else { throw new CayenneRuntimeException("CacheManager cannot be null."); } }
public void removeProjectDetailObject(Preferences preference) { try { preference.removeNode(); projectCayennePreferences.remove(preference); } catch (BackingStoreException e) { throw new CayenneRuntimeException("Error delete preferences", e); } } }
public Object setValueDirectly(Object value) throws CayenneRuntimeException { if (value == null || value instanceof List) { Object old = this.objectList; setObjectList((List) value); return old; } else { throw new CayenneRuntimeException("Value must be a list, got: " + value.getClass().getName()); } }
final MappingNamespace getNonNullNamespace() { MappingNamespace parent = getDataMap(); if (parent == null) { throw new CayenneRuntimeException("Entity '%s' has no parent MappingNamespace (such as DataMap)", getName()); } return parent; } }
protected String getLocation(DataNodeDescriptor nodeDescriptor) { String location = nodeDescriptor.getParameters(); if (location == null) { throw new CayenneRuntimeException("Null 'location' for nodeDescriptor '%s'", nodeDescriptor.getName()); } return location; }
GraphDiff onSyncFlush(ObjectContext originatingContext, GraphDiff childChanges) { if (!(originatingContext instanceof DataContext)) { throw new CayenneRuntimeException( "No support for committing ObjectContexts that are not DataContexts yet. " + "Unsupported context: " + originatingContext); } return new DataDomainFlushAction(this).flush( (DataContext) originatingContext, childChanges); }
@Override protected void appendChildrenAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOException { super.appendChildrenAsEJBQL(parameterAccumulator, out, rootId); if(0 != getEscapeChar()) { if('\'' == getEscapeChar()) { throw new CayenneRuntimeException("unable to escape an EJBQL like clause with a single quote character"); } out.append(" escape '"); out.append(getEscapeChar()); out.append("'"); } }
/** * Returns an ObjectId of an object on the other side of the to-one relationship, for * this DataRow representing a source of relationship. Returns null if snapshot FK * columns indicate a null to-one relationship. */ public ObjectId createTargetObjectId(String entityName, DbRelationship relationship) { if (relationship.isToMany()) { throw new CayenneRuntimeException("Only 'to one' can have a target ObjectId."); } Map<String, Object> target = relationship.targetPkSnapshotWithSrcSnapshot(this); return (target != null) ? new ObjectId(entityName, target) : null; }
public GraphBuilder createGraphBuilder(GraphType type, boolean doLayout) { try { GraphBuilder builder = type.getBuilderClass().newInstance(); builder.buildGraph(getProjectController(), domain, doLayout); put(type, builder); return builder; } catch (Exception e) { throw new CayenneRuntimeException("Could not instantiate GraphBuilder", e); } }
/** * Returns an ObjectId of an object on the other side of the to-one relationship, for * this DataRow representing a source of relationship. Returns null if snapshot FK * columns indicate a null to-one relationship. */ public ObjectId createTargetObjectId(String entityName, DbRelationship relationship) { if (relationship.isToMany()) { throw new CayenneRuntimeException("Only 'to one' can have a target ObjectId."); } Map target = relationship.targetPkSnapshotWithSrcSnapshot(this); return (target != null) ? new ObjectId(entityName, target) : null; }