mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#304 - ElasticSearch integration part 1 / doc store integration
This commit is contained in:
1 parent
cb1fe297d6
commit
8d3b4a0407
209 files changed
+6736
-573
No files matched your search
@@ -1,6 +1,5 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dml;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
@@ -17,7 +16,6 @@ import javax.persistence.OptimisticLockException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Base class for Handler implementations.
|
||||
@@ -48,7 +46,10 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest {
|
||||
|
||||
protected String sql;
|
||||
|
||||
protected ArrayList<UpdateGenValue> updateGenValues;
|
||||
/**
|
||||
* The generated value for the @Version property. Must be set after where clause is bound.
|
||||
*/
|
||||
protected Object versionValue;
|
||||
|
||||
protected DmlHandler(PersistRequestBean<?> persistRequest, boolean emptyStringToNull) {
|
||||
this.now = System.currentTimeMillis();
|
||||
@@ -224,11 +225,8 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest {
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void registerUpdateGenValue(BeanProperty prop, EntityBean bean, Object value) {
|
||||
if (updateGenValues == null) {
|
||||
updateGenValues = new ArrayList<UpdateGenValue>();
|
||||
}
|
||||
updateGenValues.add(new UpdateGenValue(prop, bean, value));
|
||||
public void registerGeneratedVersion(Object versionValue) {
|
||||
this.versionValue = versionValue;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,11 +234,8 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest {
|
||||
* clause has been bound.
|
||||
*/
|
||||
public void setUpdateGenValues() {
|
||||
if (updateGenValues != null) {
|
||||
for (int i = 0; i < updateGenValues.size(); i++) {
|
||||
UpdateGenValue updGenVal = updateGenValues.get(i);
|
||||
updGenVal.setValue();
|
||||
}
|
||||
if (versionValue != null) {
|
||||
persistRequest.setVersionValue(versionValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,30 +277,4 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hold the values from GeneratedValue that need to be set to the bean
|
||||
* property after the where clause has been built.
|
||||
*/
|
||||
private static final class UpdateGenValue {
|
||||
|
||||
private final BeanProperty property;
|
||||
|
||||
private final EntityBean bean;
|
||||
|
||||
private final Object value;
|
||||
|
||||
private UpdateGenValue(BeanProperty property, EntityBean bean, Object value) {
|
||||
this.property = property;
|
||||
this.bean = bean;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value to the bean property.
|
||||
*/
|
||||
private void setValue() {
|
||||
// support PropertyChangeSupport
|
||||
property.setValueIntercept(bean, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -42,13 +42,14 @@ public class BindablePropertyUpdateGenerated extends BindableProperty {
|
||||
// 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);
|
||||
if (prop.isVersion()) {
|
||||
if (request.getPersistRequest().isLoadedProperty(prop)) {
|
||||
// set to the bean after the where clause has been generated
|
||||
request.registerGeneratedVersion(value);
|
||||
}
|
||||
} else {
|
||||
// @WhenModified set without invoking interception
|
||||
prop.setValueChanged(bean, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,5 +61,4 @@ public class BindablePropertyUpdateGenerated extends BindableProperty {
|
||||
request.appendColumn(prop.getDbColumn());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public interface BindableRequest {
|
||||
* Register the value from a update GeneratedValue. This can only be set to
|
||||
* the bean property after the where clause has bean built.
|
||||
*/
|
||||
void registerUpdateGenValue(BeanProperty prop, EntityBean bean, Object value);
|
||||
void registerGeneratedVersion(Object value);
|
||||
|
||||
/**
|
||||
* Return the original PersistRequest.
|
||||
|
||||
Reference in new issue
Block a user