From 498f567e377162bff80c12efeb000f5409b7848c Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Fri, 31 Jul 2015 23:03:17 +1200
Subject: [PATCH] No effective change - format only
---
.../server/persist/dmlbind/Bindable.java | 28 ++---
.../persist/dmlbind/BindableAssocOne.java | 2 +-
.../dmlbind/BindableDiscriminator.java | 40 +++----
.../persist/dmlbind/BindableEmbedded.java | 68 +++++------
.../dmlbind/BindableEncryptedProperty.java | 90 +++++++--------
.../server/persist/dmlbind/BindableId.java | 38 +++----
.../persist/dmlbind/BindableIdEmbedded.java | 4 +-
.../persist/dmlbind/BindableIdEmpty.java | 2 +-
.../persist/dmlbind/BindableIdScalar.java | 2 +-
.../server/persist/dmlbind/BindableList.java | 48 ++++----
.../BindablePropertyInsertGenerated.java | 48 ++++----
.../BindablePropertyUpdateGenerated.java | 68 +++++------
.../dmlbind/BindableUnidirectional.java | 74 ++++++------
.../persist/dmlbind/FactoryAssocOnes.java | 42 +++----
.../persist/dmlbind/FactoryEmbedded.java | 58 +++++-----
.../server/persist/dmlbind/FactoryId.java | 2 +-
.../persist/dmlbind/FactoryProperty.java | 88 +++++++--------
.../persist/dmlbind/FactoryVersion.java | 30 ++---
.../dmlbind/MatchedImportedProperty.java | 106 +++++++++---------
19 files changed, 419 insertions(+), 419 deletions(-)
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java
index 82a17b75d..c1b3ec1e2 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java
@@ -22,21 +22,21 @@ import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
*/
public interface Bindable {
- /**
- * For Updates including only changed properties add the Bindable to the
- * list if it should be included in the 'update set'.
- */
- void addToUpdate(PersistRequestBean> request, List list);
+ /**
+ * For Updates including only changed properties add the Bindable to the
+ * list if it should be included in the 'update set'.
+ */
+ void addToUpdate(PersistRequestBean> request, List list);
- /**
- * append sql to the buffer with prefix and suffix options.
- */
- void dmlAppend(GenerateDmlRequest request);
+ /**
+ * append sql to the buffer with prefix and suffix options.
+ */
+ void dmlAppend(GenerateDmlRequest request);
- /**
- * Bind given the request and bean. The bean could be the oldValues bean
- * when binding a update or delete where clause with ALL concurrency mode.
- */
- void dmlBind(BindableRequest request, EntityBean bean) throws SQLException;
+ /**
+ * Bind given the request and bean. The bean could be the oldValues bean
+ * when binding a update or delete where clause with ALL concurrency mode.
+ */
+ void dmlBind(BindableRequest request, EntityBean bean) throws SQLException;
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableAssocOne.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableAssocOne.java
index 4b0c6aa59..1547fc8aa 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableAssocOne.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableAssocOne.java
@@ -40,7 +40,7 @@ public class BindableAssocOne implements Bindable {
public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
- EntityBean assocBean = (EntityBean)assocOne.getValue(bean);
+ EntityBean assocBean = (EntityBean) assocOne.getValue(bean);
Object boundValue = importedId.bind(request, assocBean);
if (boundValue == null && assocBean != null) {
// this is the scenario for a derived foreign key
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java
index dd9a7ad6b..34b2fb596 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java
@@ -15,31 +15,31 @@ import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
*/
public class BindableDiscriminator implements Bindable {
- private final String columnName;
- private final Object discValue;
- private final int sqlType;
+ private final String columnName;
+ private final Object discValue;
+ private final int sqlType;
- public BindableDiscriminator(InheritInfo inheritInfo) {
- this.columnName = inheritInfo.getDiscriminatorColumn();
- this.discValue = inheritInfo.getDiscriminatorValue();
- this.sqlType = inheritInfo.getDiscriminatorType();
- }
+ public BindableDiscriminator(InheritInfo inheritInfo) {
+ this.columnName = inheritInfo.getDiscriminatorColumn();
+ this.discValue = inheritInfo.getDiscriminatorValue();
+ this.sqlType = inheritInfo.getDiscriminatorType();
+ }
- public String toString() {
- return columnName + " = " + discValue;
- }
+ public String toString() {
+ return columnName + " = " + discValue;
+ }
- public void addToUpdate(PersistRequestBean> request, List list) {
- throw new PersistenceException("Never called (only for inserts)");
- }
+ public void addToUpdate(PersistRequestBean> request, List list) {
+ throw new PersistenceException("Never called (only for inserts)");
+ }
- public void dmlAppend(GenerateDmlRequest request) {
- request.appendColumn(columnName);
- }
+ public void dmlAppend(GenerateDmlRequest request) {
+ request.appendColumn(columnName);
+ }
- public void dmlBind(BindableRequest bindRequest, EntityBean bean) throws SQLException {
+ public void dmlBind(BindableRequest bindRequest, EntityBean bean) throws SQLException {
- bindRequest.bind(columnName, discValue, sqlType);
- }
+ bindRequest.bind(columnName, discValue, sqlType);
+ }
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java
index bec5aab8c..7d5a5d5c6 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java
@@ -14,47 +14,47 @@ import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
*/
public class BindableEmbedded implements Bindable {
- private final Bindable[] items;
+ private final Bindable[] items;
- private final BeanPropertyAssocOne> embProp;
+ private final BeanPropertyAssocOne> embProp;
- public BindableEmbedded(BeanPropertyAssocOne> embProp, List bindList) {
- this.embProp = embProp;
- this.items = bindList.toArray(new Bindable[bindList.size()]); //this.props = propList.toArray(new BeanProperty[propList.size()]);
+ public BindableEmbedded(BeanPropertyAssocOne> embProp, List bindList) {
+ this.embProp = embProp;
+ this.items = bindList.toArray(new Bindable[bindList.size()]); //this.props = propList.toArray(new BeanProperty[propList.size()]);
+ }
+
+ public String toString() {
+ return "BindableEmbedded " + embProp + " items:" + Arrays.toString(items);
+ }
+
+ public void dmlAppend(GenerateDmlRequest request) {
+
+ for (int i = 0; i < items.length; i++) {
+ items[i].dmlAppend(request);
}
+ }
- public String toString() {
- return "BindableEmbedded " + embProp + " items:" + Arrays.toString(items);
+ public void addToUpdate(PersistRequestBean> request, List list) {
+ if (request.isAddToUpdate(embProp)) {
+ list.add(this);
}
+ }
- public void dmlAppend(GenerateDmlRequest request) {
+ public void dmlBind(BindableRequest bindRequest, EntityBean bean) throws SQLException {
- for (int i = 0; i < items.length; i++) {
- items[i].dmlAppend(request);
- }
- }
-
- public void addToUpdate(PersistRequestBean> request, List list) {
- if (request.isAddToUpdate(embProp)) {
- list.add(this);
- }
- }
-
- public void dmlBind(BindableRequest bindRequest, EntityBean bean) throws SQLException {
-
- // get the embedded bean
- EntityBean embBean = (EntityBean)embProp.getValue(bean);
- if (embBean == null) {
- for (int i = 0; i < items.length; i++) {
- items[i].dmlBind(bindRequest, null);
- }
- } else {
- //EntityBeanIntercept ebi = embBean._ebean_getIntercept();
- for (int i = 0; i < items.length; i++) {
- //if (ebi.isLoadedProperty(props[i].getPropertyIndex())) {
- items[i].dmlBind(bindRequest, embBean);
- //}
- }
+ // get the embedded bean
+ EntityBean embBean = (EntityBean) embProp.getValue(bean);
+ if (embBean == null) {
+ for (int i = 0; i < items.length; i++) {
+ items[i].dmlBind(bindRequest, null);
+ }
+ } else {
+ //EntityBeanIntercept ebi = embBean._ebean_getIntercept();
+ for (int i = 0; i < items.length; i++) {
+ //if (ebi.isLoadedProperty(props[i].getPropertyIndex())) {
+ items[i].dmlBind(bindRequest, embBean);
+ //}
}
}
+ }
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java
index 44a091299..72e736e79 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java
@@ -14,56 +14,56 @@ import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
*/
public class BindableEncryptedProperty implements Bindable {
- private final BeanProperty prop;
-
- private final boolean bindEncryptDataFirst;
+ private final BeanProperty prop;
- public BindableEncryptedProperty(BeanProperty prop, boolean bindEncryptDataFirst) {
- this.prop = prop;
- this.bindEncryptDataFirst = bindEncryptDataFirst;
+ private final boolean bindEncryptDataFirst;
+
+ public BindableEncryptedProperty(BeanProperty prop, boolean bindEncryptDataFirst) {
+ this.prop = prop;
+ this.bindEncryptDataFirst = bindEncryptDataFirst;
+ }
+
+ public String toString() {
+ return prop.toString();
+ }
+
+ public void addToUpdate(PersistRequestBean> request, List list) {
+ if (request.isAddToUpdate(prop)) {
+ list.add(this);
+ }
+ }
+
+ public void dmlAppend(GenerateDmlRequest request) {
+
+ // columnName = AES_ENCRYPT(?,?)
+ request.appendColumn(prop.getDbColumn(), prop.getDbBind());
+ }
+
+
+ /**
+ * Bind a value in a Insert SET clause.
+ */
+ public void dmlBind(BindableRequest request, EntityBean bean)
+ throws SQLException {
+
+ Object value = null;
+ if (bean != null) {
+ value = prop.getValue(bean);
}
- public String toString() {
- return prop.toString();
+ // get Encrypt key
+ String encryptKeyValue = prop.getEncryptKey().getStringValue();
+
+ if (!bindEncryptDataFirst) {
+ // H2 encrypt function ... different parameter order
+ request.bindNoLog(encryptKeyValue, Types.VARCHAR, prop.getName() + "=****");
}
+ request.bindNoLog(value, prop);
- public void addToUpdate(PersistRequestBean> request, List list) {
- if (request.isAddToUpdate(prop)) {
- list.add(this);
- }
+ if (bindEncryptDataFirst) {
+ // MySql, Postgres, Oracle
+ request.bindNoLog(encryptKeyValue, Types.VARCHAR, prop.getName() + "=****");
}
+ }
- public void dmlAppend(GenerateDmlRequest request) {
-
- // columnName = AES_ENCRYPT(?,?)
- request.appendColumn(prop.getDbColumn(), prop.getDbBind());
- }
-
-
- /**
- * Bind a value in a Insert SET clause.
- */
- public void dmlBind(BindableRequest request, EntityBean bean)
- throws SQLException {
-
- Object value = null;
- if (bean != null) {
- value = prop.getValue(bean);
- }
-
- // get Encrypt key
- String encryptKeyValue = prop.getEncryptKey().getStringValue();
-
- if (!bindEncryptDataFirst){
- // H2 encrypt function ... different parameter order
- request.bindNoLog(encryptKeyValue, Types.VARCHAR, prop.getName() + "=****");
- }
- request.bindNoLog(value, prop);
-
- if (bindEncryptDataFirst){
- // MySql, Postgres, Oracle
- request.bindNoLog(encryptKeyValue, Types.VARCHAR, prop.getName() + "=****");
- }
- }
-
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableId.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableId.java
index 5b8e0f3ac..80f86154f 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableId.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableId.java
@@ -19,24 +19,24 @@ public interface BindableId extends Bindable {
* Return true if there is no Id properties at all.
*/
boolean isEmpty();
-
- /**
- * Return true if this is a concatenated key.
- */
- boolean isConcatenated();
-
- /**
- * Return the DB Column to use with genGeneratedKeys.
- */
- String getIdentityColumn();
-
- /**
- * Create the concatenated id for inserts with PFK relationships.
- *
- * Really only where there are ManyToOne assoc beans that make up the
- * primary key and the values can be got from those.
- *
- */
- boolean deriveConcatenatedId(PersistRequestBean> persist);
+
+ /**
+ * Return true if this is a concatenated key.
+ */
+ boolean isConcatenated();
+
+ /**
+ * Return the DB Column to use with genGeneratedKeys.
+ */
+ String getIdentityColumn();
+
+ /**
+ * Create the concatenated id for inserts with PFK relationships.
+ *
+ * Really only where there are ManyToOne assoc beans that make up the
+ * primary key and the values can be got from those.
+ *
+ */
+ boolean deriveConcatenatedId(PersistRequestBean> persist);
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java
index be1ce40d4..feeec637f 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java
@@ -57,7 +57,7 @@ public final class BindableIdEmbedded implements BindableId {
public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
- EntityBean idValue = (EntityBean)embId.getValue(bean);
+ EntityBean idValue = (EntityBean) embId.getValue(bean);
for (int i = 0; i < props.length; i++) {
@@ -86,7 +86,7 @@ public final class BindableIdEmbedded implements BindableId {
EntityBean bean = persist.getEntityBean();
// create the new id
- EntityBean newId = (EntityBean)embId.createEmbeddedId();
+ EntityBean newId = (EntityBean) embId.createEmbeddedId();
// populate it from the assoc one id values...
for (int i = 0; i < matches.length; i++) {
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java
index 9134a7deb..f1c434e69 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java
@@ -8,7 +8,7 @@ import com.avaje.ebeaninternal.server.core.PersistRequestBean;
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
public class BindableIdEmpty implements BindableId {
-
+
public boolean isEmpty() {
return true;
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java
index e17946d92..a1900a9dd 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java
@@ -57,7 +57,7 @@ public final class BindableIdScalar implements BindableId {
request.appendColumn(uidProp.getDbColumn());
}
- public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
+ public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
Object value = uidProp.getValue(bean);
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java
index e2cbf2be8..46000fae1 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java
@@ -12,37 +12,37 @@ import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
*/
public class BindableList implements Bindable {
- private final Bindable[] items;
+ private final Bindable[] items;
- public BindableList(List list) {
- items = list.toArray(new Bindable[list.size()]);
+ public BindableList(List list) {
+ items = list.toArray(new Bindable[list.size()]);
+ }
+
+ public void addAll(List list) {
+ for (int i = 0; i < items.length; i++) {
+ list.add(items[i]);
}
+ }
- public void addAll(List list) {
- for (int i = 0; i < items.length; i++) {
- list.add(items[i]);
- }
+ public void addToUpdate(PersistRequestBean> request, List list) {
+ for (int i = 0; i < items.length; i++) {
+ items[i].addToUpdate(request, list);
}
-
- public void addToUpdate(PersistRequestBean> request, List list) {
- for (int i = 0; i < items.length; i++) {
- items[i].addToUpdate(request, list);
- }
+ }
+
+ public void dmlAppend(GenerateDmlRequest request) {
+
+ for (int i = 0; i < items.length; i++) {
+ items[i].dmlAppend(request);
}
+ }
- public void dmlAppend(GenerateDmlRequest request) {
+ public void dmlBind(BindableRequest bindRequest, EntityBean bean)
+ throws SQLException {
- for (int i = 0; i < items.length; i++) {
- items[i].dmlAppend(request);
- }
- }
-
- public void dmlBind(BindableRequest bindRequest, EntityBean bean)
- throws SQLException {
-
- for (int i = 0; i < items.length; i++) {
- items[i].dmlBind(bindRequest, bean);
- }
+ for (int i = 0; i < items.length; i++) {
+ items[i].dmlBind(bindRequest, bean);
}
+ }
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java
index 9a4f88340..9a6f1cd90 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java
@@ -14,33 +14,33 @@ import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
*
*/
public class BindablePropertyInsertGenerated extends BindableProperty {
-
- private final GeneratedProperty gen;
- public BindablePropertyInsertGenerated(BeanProperty prop, GeneratedProperty gen) {
- super(prop);
- this.gen = gen;
- }
-
+ private final GeneratedProperty gen;
+
+ public BindablePropertyInsertGenerated(BeanProperty prop, GeneratedProperty gen) {
+ super(prop);
+ this.gen = gen;
+ }
+
public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
-
- Object value = gen.getInsertValue(prop, bean);
-
- // generated value should be the correct type
- if (bean != null){
- // support PropertyChangeSupport
- //prop.setValueIntercept(bean, value);
- prop.setValue(bean, value);
- }
+
+ Object value = gen.getInsertValue(prop, bean);
+
+ // generated value should be the correct type
+ if (bean != null) {
+ // support PropertyChangeSupport
+ //prop.setValueIntercept(bean, value);
+ prop.setValue(bean, value);
+ }
request.bind(value, prop);
}
- /**
- * Always bind on Insert SET.
- */
- @Override
- public void dmlAppend(GenerateDmlRequest request){
- request.appendColumn(prop.getDbColumn());
- }
-
+ /**
+ * Always bind on Insert SET.
+ */
+ @Override
+ public void dmlAppend(GenerateDmlRequest request) {
+ request.appendColumn(prop.getDbColumn());
+ }
+
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java
index 15b9afd81..705b62051 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java
@@ -16,17 +16,17 @@ import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
*
*/
public class BindablePropertyUpdateGenerated extends BindableProperty {
-
- private final GeneratedProperty gen;
-
- public BindablePropertyUpdateGenerated(BeanProperty prop, GeneratedProperty gen) {
- super(prop);
- this.gen = gen;
- }
-
- /**
- * Add BindablePropertyUpdateGenerated if the property is loaded.
- */
+
+ private final GeneratedProperty gen;
+
+ public BindablePropertyUpdateGenerated(BeanProperty prop, GeneratedProperty gen) {
+ super(prop);
+ this.gen = gen;
+ }
+
+ /**
+ * Add BindablePropertyUpdateGenerated if the property is loaded.
+ */
public void addToUpdate(PersistRequestBean> request, List list) {
if (gen.includeInAllUpdates()) {
list.add(this);
@@ -37,28 +37,28 @@ public class BindablePropertyUpdateGenerated extends BindableProperty {
public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
- Object value = gen.getUpdateValue(prop, bean);
-
- // generated value should be the correct type
- request.bind(value, prop);
-
- // only register the update value if it was included
- // in the bean in the first place
- if (request.getPersistRequest().isLoadedProperty(prop)) {
- //if (request.isIncluded(prop)) {
- // need to set the generated value to the bean later
- // after the where clause has been generated
- request.registerUpdateGenValue(prop, bean, value);
- }
+ Object value = gen.getUpdateValue(prop, bean);
+
+ // generated value should be the correct type
+ request.bind(value, prop);
+
+ // only register the update value if it was included
+ // in the bean in the first place
+ if (request.getPersistRequest().isLoadedProperty(prop)) {
+ //if (request.isIncluded(prop)) {
+ // need to set the generated value to the bean later
+ // after the where clause has been generated
+ request.registerUpdateGenValue(prop, bean, value);
}
-
- /**
- * Always bind on Insert SET.
- */
- @Override
- public void dmlAppend(GenerateDmlRequest request){
- request.appendColumn(prop.getDbColumn());
- }
-
-
+ }
+
+ /**
+ * Always bind on Insert SET.
+ */
+ @Override
+ public void dmlAppend(GenerateDmlRequest request) {
+ request.appendColumn(prop.getDbColumn());
+ }
+
+
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java
index f27bb195c..8651752b3 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java
@@ -21,48 +21,48 @@ import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
*/
public class BindableUnidirectional implements Bindable {
- private final BeanPropertyAssocOne> unidirectional;
+ private final BeanPropertyAssocOne> unidirectional;
- private final ImportedId importedId;
+ private final ImportedId importedId;
- private final BeanDescriptor> desc;
+ private final BeanDescriptor> desc;
- public BindableUnidirectional(BeanDescriptor> desc, BeanPropertyAssocOne> unidirectional) {
- this.desc = desc;
- this.unidirectional = unidirectional;
- this.importedId = unidirectional.getImportedId();
+ public BindableUnidirectional(BeanDescriptor> desc, BeanPropertyAssocOne> unidirectional) {
+ this.desc = desc;
+ this.unidirectional = unidirectional;
+ this.importedId = unidirectional.getImportedId();
+ }
+
+ public String toString() {
+ return "BindableShadowFKey " + unidirectional;
+ }
+
+ public void addToUpdate(PersistRequestBean> request, List list) {
+ throw new PersistenceException("Never called (for insert only)");
+ }
+
+ public void dmlAppend(GenerateDmlRequest request) {
+ // always included (in insert)
+ importedId.dmlAppend(request);
+ }
+
+
+ public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
+
+ PersistRequestBean> persistRequest = request.getPersistRequest();
+ Object parentBean = persistRequest.getParentBean();
+
+ if (parentBean == null) {
+ Class> localType = desc.getBeanType();
+ Class> targetType = unidirectional.getTargetType();
+
+ String msg = "Error inserting bean [" + localType + "] with unidirectional relationship. ";
+ msg += "For inserts you must use cascade save on the master bean [" + targetType + "].";
+ throw new PersistenceException(msg);
}
- public String toString() {
- return "BindableShadowFKey " + unidirectional;
- }
-
- public void addToUpdate(PersistRequestBean> request, List list) {
- throw new PersistenceException("Never called (for insert only)");
- }
-
- public void dmlAppend(GenerateDmlRequest request) {
- // always included (in insert)
- importedId.dmlAppend(request);
- }
-
-
- public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
-
- PersistRequestBean> persistRequest = request.getPersistRequest();
- Object parentBean = persistRequest.getParentBean();
-
- if (parentBean == null) {
- Class> localType = desc.getBeanType();
- Class> targetType = unidirectional.getTargetType();
-
- String msg = "Error inserting bean [" + localType + "] with unidirectional relationship. ";
- msg += "For inserts you must use cascade save on the master bean [" + targetType + "].";
- throw new PersistenceException(msg);
- }
-
- importedId.bind(request, (EntityBean)parentBean);
- }
+ importedId.bind(request, (EntityBean) parentBean);
+ }
}
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 a009c8929..20e21c1e1 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
@@ -10,33 +10,33 @@ import com.avaje.ebeaninternal.server.persist.dml.DmlMode;
* A factory that builds Bindable for BeanPropertyAssocOne properties.
*/
public class FactoryAssocOnes {
-
- public FactoryAssocOnes() {
- }
-
- /**
- * Add foreign key columns from associated one beans.
- */
- public void create(List list, BeanDescriptor> desc, DmlMode mode) {
- BeanPropertyAssocOne>[] ones = desc.propertiesOneImported();
+ public FactoryAssocOnes() {
+ }
- for (int i = 0; i < ones.length; i++) {
+ /**
+ * Add foreign key columns from associated one beans.
+ */
+ public void create(List list, BeanDescriptor> desc, DmlMode mode) {
+
+ BeanPropertyAssocOne>[] ones = desc.propertiesOneImported();
+
+ for (int i = 0; i < ones.length; i++) {
if (!ones[i].isImportedPrimaryKey()) {
switch (mode) {
- case INSERT:
- if (!ones[i].isInsertable()) {
- continue;
- }
- break;
- case UPDATE:
- if (!ones[i].isUpdateable()) {
- continue;
- }
- break;
+ 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/FactoryEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java
index f4981e30f..7cedbbaa2 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java
@@ -13,35 +13,35 @@ import com.avaje.ebeaninternal.server.persist.dml.DmlMode;
*/
public class FactoryEmbedded {
- private final FactoryProperty factoryProperty;
+ private final FactoryProperty factoryProperty;
+
+ public FactoryEmbedded(boolean bindEncryptDataFirst) {
+ factoryProperty = new FactoryProperty(bindEncryptDataFirst);
+ }
+
+ /**
+ * Add bindable for the embedded properties to the list.
+ */
+ public void create(List list, BeanDescriptor> desc, DmlMode mode, boolean withLobs) {
+
+ BeanPropertyAssocOne>[] embedded = desc.propertiesEmbedded();
+
+ for (int j = 0; j < embedded.length; j++) {
+
+ BeanProperty[] props = embedded[j].getProperties();
+
+ List bindList = new ArrayList(props.length);
+
+ for (int i = 0; i < props.length; i++) {
+ Bindable item = factoryProperty.create(props[i], mode, withLobs);
+ if (item != null) {
+ bindList.add(item);
+ }
+ }
+
+ list.add(new BindableEmbedded(embedded[j], bindList));
+ }
+ }
- public FactoryEmbedded(boolean bindEncryptDataFirst) {
- factoryProperty = new FactoryProperty(bindEncryptDataFirst);
- }
-
- /**
- * Add bindable for the embedded properties to the list.
- */
- public void create(List list, BeanDescriptor> desc, DmlMode mode, boolean withLobs) {
-
- BeanPropertyAssocOne>[] embedded = desc.propertiesEmbedded();
-
- for (int j = 0; j < embedded.length; j++) {
-
- BeanProperty[] props = embedded[j].getProperties();
-
- List bindList = new ArrayList(props.length);
-
- for (int i = 0; i < props.length; i++) {
- Bindable item = factoryProperty.create(props[i], mode, withLobs);
- if (item != null){
- bindList.add(item);
- }
- }
-
- list.add(new BindableEmbedded(embedded[j], bindList));
- }
- }
-
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryId.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryId.java
index fb703db2b..6a57341db 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryId.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryId.java
@@ -21,7 +21,7 @@ public class FactoryId {
if (id == null) {
return new BindableIdEmpty();
- }
+ }
if (!id.isEmbedded()) {
return new BindableIdScalar(id);
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryProperty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryProperty.java
index 1582a9d70..5c03e3b87 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryProperty.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryProperty.java
@@ -13,53 +13,53 @@ import com.avaje.ebeaninternal.server.persist.dml.DmlMode;
*/
public class FactoryProperty {
- private final boolean bindEncryptDataFirst;
-
- public FactoryProperty(boolean bindEncryptDataFirst) {
- this.bindEncryptDataFirst = bindEncryptDataFirst;
- }
+ private final boolean bindEncryptDataFirst;
- /**
- * Create a Bindable for the property given the mode and withLobs flag.
- */
- public Bindable create(BeanProperty prop, DmlMode mode, boolean withLobs) {
+ public FactoryProperty(boolean bindEncryptDataFirst) {
+ this.bindEncryptDataFirst = bindEncryptDataFirst;
+ }
- if (DmlMode.INSERT.equals(mode) && !prop.isDbInsertable()){
- return null;
- }
- if (DmlMode.UPDATE.equals(mode) && !prop.isDbUpdatable()){
- return null;
- }
-
- if (prop.isLob()) {
- if (!withLobs) {
- // Lob exclusion
- return null;
- } else {
- return prop.isDbEncrypted() ? new BindableEncryptedProperty(prop, bindEncryptDataFirst) : new BindableProperty(prop);
- }
- }
+ /**
+ * Create a Bindable for the property given the mode and withLobs flag.
+ */
+ public Bindable create(BeanProperty prop, DmlMode mode, boolean withLobs) {
- GeneratedProperty gen = prop.getGeneratedProperty();
- if (gen != null) {
- if (DmlMode.INSERT.equals(mode)) {
- if (gen.includeInInsert()) {
- return new BindablePropertyInsertGenerated(prop, gen);
- } else {
- return null;
- }
-
- }
- if (DmlMode.UPDATE.equals(mode)) {
- if (gen.includeInUpdate()) {
- return new BindablePropertyUpdateGenerated(prop, gen);
- } else {
- // An 'Insert Timestamp' is never updated
- return null;
- }
- }
- }
+ if (DmlMode.INSERT.equals(mode) && !prop.isDbInsertable()) {
+ return null;
+ }
+ if (DmlMode.UPDATE.equals(mode) && !prop.isDbUpdatable()) {
+ return null;
+ }
+ if (prop.isLob()) {
+ if (!withLobs) {
+ // Lob exclusion
+ return null;
+ } else {
return prop.isDbEncrypted() ? new BindableEncryptedProperty(prop, bindEncryptDataFirst) : new BindableProperty(prop);
- }
+ }
+ }
+
+ GeneratedProperty gen = prop.getGeneratedProperty();
+ if (gen != null) {
+ if (DmlMode.INSERT.equals(mode)) {
+ if (gen.includeInInsert()) {
+ return new BindablePropertyInsertGenerated(prop, gen);
+ } else {
+ return null;
+ }
+
+ }
+ if (DmlMode.UPDATE.equals(mode)) {
+ if (gen.includeInUpdate()) {
+ return new BindablePropertyUpdateGenerated(prop, gen);
+ } else {
+ // An 'Insert Timestamp' is never updated
+ return null;
+ }
+ }
+ }
+
+ return prop.isDbEncrypted() ? new BindableEncryptedProperty(prop, bindEncryptDataFirst) : new BindableProperty(prop);
+ }
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryVersion.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryVersion.java
index 767a0cbd7..628c98cd7 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryVersion.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryVersion.java
@@ -8,20 +8,20 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty;
*/
public class FactoryVersion {
-
- public FactoryVersion() {
- }
-
- /**
- * Create a Bindable for the version property(s) for a bean type.
- */
- public Bindable create(BeanDescriptor> desc) {
- BeanProperty versionProperty = desc.getVersionProperty();
- if (versionProperty == null) {
- return null;
- }
-
- return new BindableProperty(versionProperty);
- }
+ public FactoryVersion() {
+ }
+
+ /**
+ * Create a Bindable for the version property(s) for a bean type.
+ */
+ public Bindable create(BeanDescriptor> desc) {
+
+ BeanProperty versionProperty = desc.getVersionProperty();
+ if (versionProperty == null) {
+ return null;
+ }
+
+ return new BindableProperty(versionProperty);
+ }
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java
index 2211e9d3d..9e4da8a12 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java
@@ -18,69 +18,69 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne;
*/
class MatchedImportedProperty {
- private final BeanPropertyAssocOne> assocOne;
+ private final BeanPropertyAssocOne> assocOne;
- private final BeanProperty foreignProp;
+ private final BeanProperty foreignProp;
- private final BeanProperty localProp;
+ private final BeanProperty localProp;
- protected MatchedImportedProperty(BeanPropertyAssocOne> assocOne, BeanProperty foreignProp,
- BeanProperty localProp) {
- this.assocOne = assocOne;
- this.foreignProp = foreignProp;
- this.localProp = localProp;
- }
+ protected MatchedImportedProperty(BeanPropertyAssocOne> assocOne, BeanProperty foreignProp,
+ BeanProperty localProp) {
+ this.assocOne = assocOne;
+ this.foreignProp = foreignProp;
+ this.localProp = localProp;
+ }
- protected void populate(EntityBean sourceBean, EntityBean destBean) {
- Object assocBean = assocOne.getValue(sourceBean);
- if (assocBean == null) {
- String msg = "The assoc bean for " + assocOne + " is null?";
- throw new NullPointerException(msg);
- }
+ protected void populate(EntityBean sourceBean, EntityBean destBean) {
+ Object assocBean = assocOne.getValue(sourceBean);
+ if (assocBean == null) {
+ String msg = "The assoc bean for " + assocOne + " is null?";
+ throw new NullPointerException(msg);
+ }
- Object value = foreignProp.getValue((EntityBean)assocBean);
- localProp.setValue(destBean, value);
- }
+ Object value = foreignProp.getValue((EntityBean) assocBean);
+ localProp.setValue(destBean, value);
+ }
- /**
- * Create the array of matchedImportedProperty based on the properties and descriptor.
- */
- protected static MatchedImportedProperty[] build(BeanProperty[] props, BeanDescriptor> desc) {
+ /**
+ * Create the array of matchedImportedProperty based on the properties and descriptor.
+ */
+ protected static MatchedImportedProperty[] build(BeanProperty[] props, BeanDescriptor> desc) {
- MatchedImportedProperty[] matches = new MatchedImportedProperty[props.length];
+ MatchedImportedProperty[] matches = new MatchedImportedProperty[props.length];
- for (int i = 0; i < props.length; i++) {
- // find matching assoc one property for dbColumn
- matches[i] = MatchedImportedProperty.findMatch(props[i], desc);
- if (matches[i] == null) {
- // ok, the assoc ones are not on the bean?
- return null;
- }
- }
- return matches;
- }
-
- private static MatchedImportedProperty findMatch(BeanProperty prop, BeanDescriptor> desc) {
+ for (int i = 0; i < props.length; i++) {
+ // find matching assoc one property for dbColumn
+ matches[i] = MatchedImportedProperty.findMatch(props[i], desc);
+ if (matches[i] == null) {
+ // ok, the assoc ones are not on the bean?
+ return null;
+ }
+ }
+ return matches;
+ }
- // find matching against the local database column
- String dbColumn = prop.getDbColumn();
+ private static MatchedImportedProperty findMatch(BeanProperty prop, BeanDescriptor> desc) {
- BeanPropertyAssocOne>[] assocOnes = desc.propertiesOne();
- for (int i = 0; i < assocOnes.length; i++) {
- if (assocOnes[i].isImportedPrimaryKey()) {
-
- // search using the ImportedId from the assoc one
- BeanProperty foreignMatch = assocOnes[i].getImportedId().findMatchImport(dbColumn);
+ // find matching against the local database column
+ String dbColumn = prop.getDbColumn();
- if (foreignMatch != null) {
- return new MatchedImportedProperty(assocOnes[i], foreignMatch, prop);
- }
- }
- }
-
- // there was no matching assoc one property.
- // example UserRole bean missing assoc one to User?
- return null;
- }
+ BeanPropertyAssocOne>[] assocOnes = desc.propertiesOne();
+ for (int i = 0; i < assocOnes.length; i++) {
+ if (assocOnes[i].isImportedPrimaryKey()) {
+
+ // search using the ImportedId from the assoc one
+ BeanProperty foreignMatch = assocOnes[i].getImportedId().findMatchImport(dbColumn);
+
+ if (foreignMatch != null) {
+ return new MatchedImportedProperty(assocOnes[i], foreignMatch, prop);
+ }
+ }
+ }
+
+ // there was no matching assoc one property.
+ // example UserRole bean missing assoc one to User?
+ return null;
+ }
}