@SuppressWarnings({"unchecked", "rawtypes"}) private BeanProperty createProperty(BeanDescriptorMap owner, DeployBeanProperty prop) { if (prop instanceof DeployBeanPropertyAssocOne<?>) { return new BeanPropertyAssocOne(owner, (DeployBeanPropertyAssocOne<?>) prop); } else { return new BeanProperty(prop); } }
private SqlUpdate deleteByParentId(Object parentId) { DefaultSqlUpdate delete = new DefaultSqlUpdate(deleteByParentIdSql); bindParentId(delete, parentId); return delete; }
private List<Object> findIdsByParentId(Object parentId, Transaction t) { String rawWhere = deriveWhereParentIdSql(false); SpiEbeanServer server = server(); Query<?> q = server.find(getPropertyType()); bindParentIdEq(rawWhere, parentId, q); return server.findIds(q, t); }
private List<Object> findIdsByParentIdList(List<Object> parentIds, Transaction t) { String rawWhere = deriveWhereParentIdSql(true); String inClause = getIdBinder().getIdInValueExpr(false, parentIds.size()); String expr = rawWhere + inClause; SpiEbeanServer server = server(); Query<?> q = server.find(getPropertyType()); bindParentIdsIn(expr, parentIds, q); return server.findIds(q, t); }
@Override public boolean deriveConcatenatedId(PersistRequestBean<?> persist) { if (matches == null) { String m = "No matches for " + embId.getFullBeanName() + " the concatenated key columns where not found?" + " I expect that the concatenated key was null, and this bean does" + " not have ManyToOne assoc beans matching the primary key columns?"; throw new PersistenceException(m); } EntityBean bean = persist.getEntityBean(); // create the new id EntityBean newId = (EntityBean) embId.createEmbeddedId(); // populate it from the assoc one id values... for (MatchedImportedProperty match : matches) { match.populate(bean, newId); } // support PropertyChangeSupport embId.setValueIntercept(bean, newId); return true; }
@Override public ElPropertyValue buildElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy) { if (embedded) { BeanProperty embProp = embeddedPropsMap.get(remainder); if (embProp == null) { String msg = "Embedded Property " + remainder + " not found in " + getFullBeanName(); throw new PersistenceException(msg); } if (chain == null) { chain = new ElPropertyChainBuilder(true, propName); } chain.add(this); chain.setEmbedded(true); return chain.add(embProp).build(); } return createElPropertyValue(propName, remainder, chain, propertyDeploy); }
/** * Remove a bean from the cache given its Id. */ void beanCacheApplyInvalidate(Collection<String> keys) { if (beanCache != null) { if (beanLog.isDebugEnabled()) { beanLog.debug(" REMOVE {}({})", cacheName, keys); } beanCache.removeAll(new HashSet<>(keys)); } for (BeanPropertyAssocOne<?> imported : propertiesOneImported) { imported.cacheClear(); } }
private SqlUpdate deleteByParentIdList(List<Object> parentIds) { StringBuilder sb = new StringBuilder(100); sb.append(deleteByParentIdInSql); sb.append(targetIdBinder.getIdInValueExpr(false, parentIds.size())); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); bindParentIds(delete, parentIds); return delete; }
private void cacheDeleteImported(boolean clear, EntityBean entityBean, CacheChangeSet changeSet) { for (BeanPropertyAssocOne<?> imported : propertiesOneImported) { imported.cacheDelete(clear, entityBean, changeSet); } }
private List<Object> findIdsByParentIdList(List<Object> parentIds, Transaction t) { String rawWhere = deriveWhereParentIdSql(true); String inClause = getIdBinder().getIdInValueExpr(false, parentIds.size()); String expr = rawWhere + inClause; SpiEbeanServer server = server(); Query<?> q = server.find(getPropertyType()); bindParentIdsIn(expr, parentIds, q); return server.findIds(q, t); }
private List<Object> findIdsByParentId(Object parentId, Transaction t) { String rawWhere = deriveWhereParentIdSql(false); SpiEbeanServer server = server(); Query<?> q = server.find(getPropertyType()); bindParentIdEq(rawWhere, parentId, q); return server.findIds(q, t); }
@Override public boolean deriveConcatenatedId(PersistRequestBean<?> persist) { if (matches == null) { String m = "No matches for " + embId.getFullBeanName() + " the concatenated key columns where not found?" + " I expect that the concatenated key was null, and this bean does" + " not have ManyToOne assoc beans matching the primary key columns?"; throw new PersistenceException(m); } EntityBean bean = persist.getEntityBean(); // create the new id EntityBean newId = (EntityBean) embId.createEmbeddedId(); // populate it from the assoc one id values... for (MatchedImportedProperty match : matches) { match.populate(bean, newId); } // support PropertyChangeSupport embId.setValueIntercept(bean, newId); return true; }
@Override public ElPropertyValue buildElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy) { if (embedded) { BeanProperty embProp = embeddedPropsMap.get(remainder); if (embProp == null) { String msg = "Embedded Property " + remainder + " not found in " + getFullBeanName(); throw new PersistenceException(msg); } if (chain == null) { chain = new ElPropertyChainBuilder(true, propName); } chain.add(this); chain.setEmbedded(true); return chain.add(embProp).build(); } return createElPropertyValue(propName, remainder, chain, propertyDeploy); }
/** * Invalidate parts of cache due to SqlUpdate or external modification etc. */ void persistTableIUD(TableIUD tableIUD, CacheChangeSet changeSet) { if (invalidateQueryCache) { changeSet.addInvalidate(desc); return; } if (noCaching) { return; } changeSet.addInvalidate(desc); // inserts don't invalidate the bean cache if (tableIUD.isUpdateOrDelete()) { changeSet.addClearBean(desc); } // any change invalidates the query cache changeSet.addClearQuery(desc); // any change invalidates the collection IDs cache for (BeanPropertyAssocOne<?> imported : propertiesOneImported) { imported.cacheClear(changeSet); } }
private SqlUpdate deleteByParentIdList(List<Object> parentIds) { StringBuilder sb = new StringBuilder(100); sb.append(deleteByParentIdInSql); sb.append(targetIdBinder.getIdInValueExpr(false, parentIds.size())); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); bindParentIds(delete, parentIds); return delete; }
private void cacheDeleteImported(boolean clear, EntityBean entityBean, CacheChangeSet changeSet) { for (BeanPropertyAssocOne<?> imported : propertiesOneImported) { imported.cacheDelete(clear, entityBean, changeSet); } }
@SuppressWarnings({"unchecked", "rawtypes"}) private BeanProperty createBeanProperty(BeanDescriptorMap owner, DeployBeanProperty deployProp) { if (deployProp instanceof DeployBeanPropertyAssocOne) { return new BeanPropertyAssocOne(owner, desc, (DeployBeanPropertyAssocOne) deployProp); } if (deployProp instanceof DeployBeanPropertySimpleCollection<?>) { return new BeanPropertySimpleCollection(desc, (DeployBeanPropertySimpleCollection) deployProp); } if (deployProp instanceof DeployBeanPropertyAssocMany) { return new BeanPropertyAssocMany(desc, (DeployBeanPropertyAssocMany) deployProp); } return new BeanProperty(desc, deployProp); }
/** * Remove a bean from the cache given its Id. */ void beanCacheApplyInvalidate(Collection<String> keys) { if (beanCache != null) { if (beanLog.isDebugEnabled()) { beanLog.debug(" REMOVE {}({})", cacheName, keys); } beanCache.removeAll(new HashSet<>(keys)); } for (BeanPropertyAssocOne<?> imported : propertiesOneImported) { imported.cacheClear(); } }