mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - simplify if, remove unused
This commit is contained in:
@@ -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<Bindable> 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<String, Object> mapId = new LinkedHashMap<String, Object>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
+16
-19
@@ -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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -28,14 +28,14 @@ public class FactoryBaseProperties {
|
||||
*/
|
||||
public void create(List<Bindable> 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<BindableProperty> newList = new ArrayList<BindableProperty>(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<Bindable> list, BeanDescriptor<?> desc, DmlMode mode, boolean withLobs) {
|
||||
private void add(BeanProperty[] props, List<Bindable> 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<BindableProperty> list, BeanDescriptor<?> desc, DmlMode mode, boolean withLobs) {
|
||||
private void addCompound(BeanProperty[] props, List<BindableProperty> list, DmlMode mode, boolean withLobs) {
|
||||
|
||||
for (int i = 0; i < props.length; i++) {
|
||||
BindableProperty item = (BindableProperty) factoryProperty.create(props[i], mode, withLobs);
|
||||
|
||||
Reference in New Issue
Block a user