diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdMap.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdMap.java deleted file mode 100644 index dc33dd9b6..000000000 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdMap.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.avaje.ebeaninternal.server.persist.dmlbind; - -import java.sql.SQLException; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; - -import javax.persistence.PersistenceException; - -import com.avaje.ebean.bean.EntityBean; -import com.avaje.ebeaninternal.server.core.PersistRequestBean; -import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; -import com.avaje.ebeaninternal.server.deploy.BeanProperty; -import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; - -/** - * Bindable for a concatenated id that is not embedded. - */ -public final class BindableIdMap implements BindableId { - - private final BeanProperty[] uids; - - private final MatchedImportedProperty[] matches; - - public BindableIdMap(BeanProperty[] uids, BeanDescriptor desc) { - this.uids = uids; - matches = MatchedImportedProperty.build(uids, desc); - } - - public boolean isEmpty() { - return false; - } - - public boolean isConcatenated() { - return true; - } - - public String getIdentityColumn() { - // return null for concatenated keys - return null; - } - - @Override - public String toString() { - return Arrays.toString(uids); - } - - /** - * Does nothing for BindableId. - */ - public void addToUpdate(PersistRequestBean request, List list) { - // do nothing (id not changing) - } - - public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < uids.length; i++) { - request.appendColumn(uids[i].getDbColumn()); - } - } - - public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException { - - LinkedHashMap mapId = new LinkedHashMap(); - for (int i = 0; i < uids.length; i++) { - Object value = uids[i].getValue(bean); - - request.bind(value, uids[i]); - - // putting logicalType into map rather than - // the dbType (which may have been converted). - mapId.put(uids[i].getName(), value); - } - request.setIdValue(mapId); - } - - public boolean deriveConcatenatedId(PersistRequestBean persist) { - - if (matches == null) { - String m = "Matches for the concatinated key columns where not found?" - + " I expect that the concatinated 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(); - - // populate it from the assoc one id values... - for (int i = 0; i < matches.length; i++) { - matches[i].populate(bean, bean); - } - - return true; - } - -} diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java index c92035260..a009c8929 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java @@ -22,24 +22,21 @@ public class FactoryAssocOnes { BeanPropertyAssocOne[] ones = desc.propertiesOneImported(); for (int i = 0; i < ones.length; i++) { - if (ones[i].isImportedPrimaryKey()){ - // excluded as already part of the primary key - - } else { - switch (mode) { - case INSERT: - if (!ones[i].isInsertable()) { - continue; - } - break; - case UPDATE: - if (!ones[i].isUpdateable()) { - continue; - } - break; - } - list.add(new BindableAssocOne(ones[i])); - } - } + if (!ones[i].isImportedPrimaryKey()) { + switch (mode) { + case INSERT: + if (!ones[i].isInsertable()) { + continue; + } + break; + case UPDATE: + if (!ones[i].isUpdateable()) { + continue; + } + break; + } + list.add(new BindableAssocOne(ones[i])); + } + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java index efd36a064..9ce0717fb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java @@ -28,14 +28,14 @@ public class FactoryBaseProperties { */ public void create(List list, BeanDescriptor desc, DmlMode mode, boolean withLobs) { - add(desc.propertiesBaseScalar(), list, desc, mode, withLobs); + add(desc.propertiesBaseScalar(), list, mode, withLobs); BeanPropertyCompound[] compoundProps = desc.propertiesBaseCompound(); for (int i = 0; i < compoundProps.length; i++) { BeanProperty[] props = compoundProps[i].getScalarProperties(); List newList = new ArrayList(props.length); - addCompound(props, newList, desc, mode, withLobs); + addCompound(props, newList, mode, withLobs); BindableCompound compoundBindable = new BindableCompound(compoundProps[i], newList); @@ -43,7 +43,7 @@ public class FactoryBaseProperties { } } - private void add(BeanProperty[] props, List list, BeanDescriptor desc, DmlMode mode, boolean withLobs) { + private void add(BeanProperty[] props, List list, DmlMode mode, boolean withLobs) { for (int i = 0; i < props.length; i++) { Bindable item = factoryProperty.create(props[i], mode, withLobs); @@ -53,7 +53,7 @@ public class FactoryBaseProperties { } } - private void addCompound(BeanProperty[] props, List list, BeanDescriptor desc, DmlMode mode, boolean withLobs) { + private void addCompound(BeanProperty[] props, List list, DmlMode mode, boolean withLobs) { for (int i = 0; i < props.length; i++) { BindableProperty item = (BindableProperty) factoryProperty.create(props[i], mode, withLobs);