mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
no effective change - format only
This commit is contained in:
@@ -4,6 +4,7 @@ import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequest;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.avaje.ebeaninternal.server.persist;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedHashMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Used to hold BatchedPstmt objects for batch based execution.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.avaje.ebeaninternal.server.persist;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
/**
|
||||
* Defines bean insert update and delete implementation.
|
||||
*/
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
package com.avaje.ebeaninternal.server.persist;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
import com.avaje.ebeaninternal.api.BindParams;
|
||||
import com.avaje.ebeaninternal.server.core.DbExpressionHandler;
|
||||
@@ -22,6 +11,16 @@ import com.avaje.ebeaninternal.server.type.TypeManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Binds bean values to a PreparedStatement.
|
||||
*/
|
||||
|
||||
@@ -148,7 +148,7 @@ public final class DefaultPersister implements Persister {
|
||||
|
||||
BeanManager<T> mgr = beanDescriptorManager.getBeanManager(beanType);
|
||||
|
||||
for (T liveBean: liveBeans) {
|
||||
for (T liveBean : liveBeans) {
|
||||
T draftBean = draftHandler.publishToDestinationBean(liveBean);
|
||||
// reset @DraftDirty and @DraftReset properties
|
||||
draftHandler.resetDraft(draftBean);
|
||||
@@ -166,7 +166,7 @@ public final class DefaultPersister implements Persister {
|
||||
*/
|
||||
private <T> List<Object> getBeanIds(BeanDescriptor<T> desc, List<T> beans) {
|
||||
List<Object> idList = new ArrayList<>();
|
||||
for (T liveBean: beans) {
|
||||
for (T liveBean : beans) {
|
||||
idList.add(desc.getBeanId(liveBean));
|
||||
}
|
||||
return idList;
|
||||
@@ -194,7 +194,7 @@ public final class DefaultPersister implements Persister {
|
||||
BeanManager<T> mgr = beanDescriptorManager.getBeanManager(beanType);
|
||||
|
||||
List<T> livePublish = new ArrayList<>(draftBeans.size());
|
||||
for (T draftBean: draftBeans) {
|
||||
for (T draftBean : draftBeans) {
|
||||
T liveBean = draftHandler.publishToDestinationBean(draftBean);
|
||||
livePublish.add(liveBean);
|
||||
|
||||
@@ -889,7 +889,7 @@ public final class DefaultPersister implements Persister {
|
||||
private void resetModifyState() {
|
||||
Object details = getValue();
|
||||
if (details instanceof BeanCollection<?>) {
|
||||
modifyListenReset((BeanCollection<?>)details);
|
||||
modifyListenReset((BeanCollection<?>) details);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,7 @@ public class PstmtFactory {
|
||||
/**
|
||||
* Return a prepared statement taking into account batch requirements.
|
||||
*/
|
||||
public PreparedStatement getPstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe)
|
||||
throws SQLException {
|
||||
public PreparedStatement getPstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe) throws SQLException {
|
||||
|
||||
BatchedPstmtHolder batch = t.getBatchControl().getPstmtHolder();
|
||||
PreparedStatement stmt = batch.getStmt(sql, batchExe);
|
||||
@@ -63,8 +62,7 @@ public class PstmtFactory {
|
||||
/**
|
||||
* Return a callable statement taking into account batch requirements.
|
||||
*/
|
||||
public CallableStatement getCstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe)
|
||||
throws SQLException {
|
||||
public CallableStatement getCstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe) throws SQLException {
|
||||
|
||||
BatchedPstmtHolder batch = t.getBatchControl().getPstmtHolder();
|
||||
CallableStatement stmt = (CallableStatement) batch.getStmt(sql, batchExe);
|
||||
|
||||
@@ -12,41 +12,41 @@ import java.sql.SQLException;
|
||||
*/
|
||||
public class DeleteHandler extends DmlHandler {
|
||||
|
||||
private final DeleteMeta meta;
|
||||
private final DeleteMeta meta;
|
||||
|
||||
public DeleteHandler(PersistRequestBean<?> persist, DeleteMeta meta) {
|
||||
super(persist, meta.isEmptyStringAsNull());
|
||||
this.meta = meta;
|
||||
}
|
||||
public DeleteHandler(PersistRequestBean<?> persist, DeleteMeta meta) {
|
||||
super(persist, meta.isEmptyStringAsNull());
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and bind the delete statement.
|
||||
*/
|
||||
/**
|
||||
* Generate and bind the delete statement.
|
||||
*/
|
||||
@Override
|
||||
public void bind() throws SQLException {
|
||||
|
||||
sql = meta.getSql(persistRequest);
|
||||
SpiTransaction t = persistRequest.getTransaction();
|
||||
public void bind() throws SQLException {
|
||||
|
||||
PreparedStatement pstmt;
|
||||
if (persistRequest.isBatched()) {
|
||||
pstmt = getPstmt(t, sql, persistRequest, false);
|
||||
} else {
|
||||
pstmt = getPstmt(t, sql, false);
|
||||
}
|
||||
dataBind = bind(pstmt);
|
||||
meta.bind(persistRequest, this);
|
||||
logSql(sql);
|
||||
}
|
||||
sql = meta.getSql(persistRequest);
|
||||
SpiTransaction t = persistRequest.getTransaction();
|
||||
|
||||
/**
|
||||
* Execute the delete non-batch.
|
||||
*/
|
||||
PreparedStatement pstmt;
|
||||
if (persistRequest.isBatched()) {
|
||||
pstmt = getPstmt(t, sql, persistRequest, false);
|
||||
} else {
|
||||
pstmt = getPstmt(t, sql, false);
|
||||
}
|
||||
dataBind = bind(pstmt);
|
||||
meta.bind(persistRequest, this);
|
||||
logSql(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the delete non-batch.
|
||||
*/
|
||||
@Override
|
||||
public int execute() throws SQLException, OptimisticLockException {
|
||||
int rowCount = dataBind.executeUpdate();
|
||||
checkRowCount(rowCount);
|
||||
public int execute() throws SQLException, OptimisticLockException {
|
||||
int rowCount = dataBind.executeUpdate();
|
||||
checkRowCount(rowCount);
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dml;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.avaje.ebeaninternal.api.ConcurrencyMode;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.api.ConcurrencyMode;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable;
|
||||
import com.avaje.ebeaninternal.server.persist.dmlbind.BindableId;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Meta data for delete handler. The meta data is for a particular bean type. It
|
||||
* is considered immutable and is thread safe.
|
||||
@@ -69,12 +69,12 @@ public final class DeleteMeta {
|
||||
id.dmlBind(bind, bean);
|
||||
|
||||
switch (persist.getConcurrencyMode()) {
|
||||
case VERSION:
|
||||
version.dmlBind(bind, bean);
|
||||
break;
|
||||
case VERSION:
|
||||
version.dmlBind(bind, bean);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,14 +89,14 @@ public final class DeleteMeta {
|
||||
|
||||
boolean publish = request.isPublish();
|
||||
switch (request.determineConcurrencyMode()) {
|
||||
case NONE:
|
||||
return publish ? sqlNone : sqlDraftNone;
|
||||
case NONE:
|
||||
return publish ? sqlNone : sqlDraftNone;
|
||||
|
||||
case VERSION:
|
||||
return publish ? sqlVersion : sqlDraftVersion;
|
||||
case VERSION:
|
||||
return publish ? sqlVersion : sqlDraftVersion;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Invalid mode " + request.determineConcurrencyMode());
|
||||
default:
|
||||
throw new RuntimeException("Invalid mode " + request.determineConcurrencyMode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public final class DeleteMeta {
|
||||
}
|
||||
version.dmlAppend(request);
|
||||
}
|
||||
|
||||
|
||||
return request.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,77 +18,77 @@ import java.sql.SQLException;
|
||||
*/
|
||||
public final class DmlBeanPersister implements BeanPersister {
|
||||
|
||||
private final UpdateMeta updateMeta;
|
||||
private final UpdateMeta updateMeta;
|
||||
|
||||
private final InsertMeta insertMeta;
|
||||
private final InsertMeta insertMeta;
|
||||
|
||||
private final DeleteMeta deleteMeta;
|
||||
private final DeleteMeta deleteMeta;
|
||||
|
||||
|
||||
public DmlBeanPersister(UpdateMeta updateMeta, InsertMeta insertMeta, DeleteMeta deleteMeta) {
|
||||
|
||||
this.updateMeta = updateMeta;
|
||||
this.insertMeta = insertMeta;
|
||||
this.deleteMeta = deleteMeta;
|
||||
}
|
||||
public DmlBeanPersister(UpdateMeta updateMeta, InsertMeta insertMeta, DeleteMeta deleteMeta) {
|
||||
|
||||
/**
|
||||
* execute the bean delete request.
|
||||
*/
|
||||
public int delete(PersistRequestBean<?> request) {
|
||||
this.updateMeta = updateMeta;
|
||||
this.insertMeta = insertMeta;
|
||||
this.deleteMeta = deleteMeta;
|
||||
}
|
||||
|
||||
DeleteHandler delete = new DeleteHandler(request, deleteMeta);
|
||||
return execute(request, delete);
|
||||
}
|
||||
/**
|
||||
* execute the bean delete request.
|
||||
*/
|
||||
public int delete(PersistRequestBean<?> request) {
|
||||
|
||||
/**
|
||||
* execute the bean insert request.
|
||||
*/
|
||||
public void insert(PersistRequestBean<?> request) {
|
||||
DeleteHandler delete = new DeleteHandler(request, deleteMeta);
|
||||
return execute(request, delete);
|
||||
}
|
||||
|
||||
InsertHandler insert = new InsertHandler(request, insertMeta);
|
||||
execute(request, insert);
|
||||
}
|
||||
/**
|
||||
* execute the bean insert request.
|
||||
*/
|
||||
public void insert(PersistRequestBean<?> request) {
|
||||
|
||||
/**
|
||||
* execute the bean update request.
|
||||
*/
|
||||
public void update(PersistRequestBean<?> request) {
|
||||
InsertHandler insert = new InsertHandler(request, insertMeta);
|
||||
execute(request, insert);
|
||||
}
|
||||
|
||||
UpdateHandler update = new UpdateHandler(request, updateMeta);
|
||||
execute(request, update);
|
||||
}
|
||||
/**
|
||||
* execute the bean update request.
|
||||
*/
|
||||
public void update(PersistRequestBean<?> request) {
|
||||
|
||||
/**
|
||||
* execute request taking batching into account.
|
||||
*/
|
||||
private int execute(PersistRequestBean<?> request, PersistHandler handler) {
|
||||
UpdateHandler update = new UpdateHandler(request, updateMeta);
|
||||
execute(request, update);
|
||||
}
|
||||
|
||||
/**
|
||||
* execute request taking batching into account.
|
||||
*/
|
||||
private int execute(PersistRequestBean<?> request, PersistHandler handler) {
|
||||
|
||||
boolean batched = request.isBatched();
|
||||
try {
|
||||
handler.bind();
|
||||
if (batched) {
|
||||
handler.addBatch();
|
||||
try {
|
||||
handler.bind();
|
||||
if (batched) {
|
||||
handler.addBatch();
|
||||
return -1;
|
||||
|
||||
} else {
|
||||
return handler.execute();
|
||||
}
|
||||
} else {
|
||||
return handler.execute();
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
// log the error to the transaction log
|
||||
String errMsg = StringHelper.replaceStringMulti(e.getMessage(), new String[]{"\r","\n"}, "\\n ");
|
||||
String msg = "ERROR executing DML bindLog["+handler.getBindLog()+"] error["+errMsg+"]";
|
||||
String errMsg = StringHelper.replaceStringMulti(e.getMessage(), new String[]{"\r", "\n"}, "\\n ");
|
||||
String msg = "ERROR executing DML bindLog[" + handler.getBindLog() + "] error[" + errMsg + "]";
|
||||
if (request.getTransaction().isLogSummary()) {
|
||||
request.getTransaction().logSummary(msg);
|
||||
}
|
||||
throw new PersistenceException(msg, e);
|
||||
throw new PersistenceException(msg, e);
|
||||
|
||||
} finally {
|
||||
if (!batched && handler != null) {
|
||||
} finally {
|
||||
if (!batched && handler != null) {
|
||||
handler.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
-21
@@ -9,25 +9,25 @@ import com.avaje.ebeaninternal.server.persist.BeanPersisterFactory;
|
||||
* Factory for creating a DmlBeanPersister for a bean type.
|
||||
*/
|
||||
public class DmlBeanPersisterFactory implements BeanPersisterFactory {
|
||||
|
||||
private final MetaFactory metaFactory;
|
||||
|
||||
public DmlBeanPersisterFactory(DatabasePlatform dbPlatform) {
|
||||
this.metaFactory = new MetaFactory(dbPlatform);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a DmlBeanPersister for the given bean type.
|
||||
*/
|
||||
public BeanPersister create(BeanDescriptor<?> desc) {
|
||||
|
||||
UpdateMeta updMeta = metaFactory.createUpdate(desc);
|
||||
DeleteMeta delMeta = metaFactory.createDelete(desc);
|
||||
InsertMeta insMeta = metaFactory.createInsert(desc);
|
||||
|
||||
return new DmlBeanPersister(updMeta, insMeta, delMeta);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private final MetaFactory metaFactory;
|
||||
|
||||
public DmlBeanPersisterFactory(DatabasePlatform dbPlatform) {
|
||||
this.metaFactory = new MetaFactory(dbPlatform);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a DmlBeanPersister for the given bean type.
|
||||
*/
|
||||
public BeanPersister create(BeanDescriptor<?> desc) {
|
||||
|
||||
UpdateMeta updMeta = metaFactory.createUpdate(desc);
|
||||
DeleteMeta delMeta = metaFactory.createDelete(desc);
|
||||
InsertMeta insMeta = metaFactory.createInsert(desc);
|
||||
|
||||
return new DmlBeanPersister(updMeta, insMeta, delMeta);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -254,13 +254,13 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest {
|
||||
* Check with useGeneratedKeys to get appropriate PreparedStatement.
|
||||
*/
|
||||
protected PreparedStatement getPstmt(SpiTransaction t, String sql, boolean genKeys) throws SQLException {
|
||||
|
||||
|
||||
Connection conn = t.getInternalConnection();
|
||||
if (genKeys) {
|
||||
// the Id generated is always the first column
|
||||
// Required to stop Oracle10 giving us Oracle rowId??
|
||||
// Other jdbc drivers seem fine without this hint.
|
||||
int[] columns = { 1 };
|
||||
int[] columns = {1};
|
||||
return conn.prepareStatement(sql, columns);
|
||||
|
||||
} else {
|
||||
@@ -272,7 +272,7 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest {
|
||||
* Return a prepared statement taking into account batch requirements.
|
||||
*/
|
||||
protected PreparedStatement getPstmt(SpiTransaction t, String sql, PersistRequestBean<?> request,
|
||||
boolean genKeys) throws SQLException {
|
||||
boolean genKeys) throws SQLException {
|
||||
|
||||
BatchedPstmtHolder batch = t.getBatchControl().getPstmtHolder();
|
||||
PreparedStatement stmt = batch.getStmt(sql, request);
|
||||
|
||||
@@ -5,14 +5,14 @@ package com.avaje.ebeaninternal.server.persist.dml;
|
||||
*/
|
||||
public enum DmlMode {
|
||||
|
||||
/**
|
||||
* The Insert SET.
|
||||
*/
|
||||
INSERT,
|
||||
|
||||
/**
|
||||
* The Update SET.
|
||||
*/
|
||||
UPDATE,
|
||||
|
||||
/**
|
||||
* The Insert SET.
|
||||
*/
|
||||
INSERT,
|
||||
|
||||
/**
|
||||
* The Update SET.
|
||||
*/
|
||||
UPDATE,
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dml;
|
||||
|
||||
import com.avaje.ebeaninternal.api.ConcurrencyMode;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.api.ConcurrencyMode;
|
||||
import com.avaje.ebeaninternal.api.SpiUpdatePlan;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dml;
|
||||
|
||||
import com.avaje.ebeaninternal.api.ConcurrencyMode;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.api.ConcurrencyMode;
|
||||
import com.avaje.ebeaninternal.api.SpiUpdatePlan;
|
||||
import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Bean DML persistence implementation</TITLE>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Bean DML persistence implementation</TITLE>
|
||||
</HEAD>
|
||||
<Body BGCOLOR="#ffffff">
|
||||
Bean DML persistence implementation
|
||||
|
||||
</Body>
|
||||
</HTML>
|
||||
</HTML>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Item held by Meta objects used to generate and bind bean insert update and
|
||||
* delete statements.
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyCompound;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bindable for a Immutable Compound value object.
|
||||
*/
|
||||
|
||||
+4
-5
@@ -1,15 +1,14 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
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.InheritInfo;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bindable for inserting a discriminator value.
|
||||
*/
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bindable for a Embedded bean.
|
||||
*/
|
||||
|
||||
+5
-6
@@ -1,14 +1,14 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bindable for a DB encrypted BeanProperty.
|
||||
*/
|
||||
@@ -48,8 +48,7 @@ public class BindableEncryptedProperty implements Bindable {
|
||||
/**
|
||||
* Bind a value in a Insert SET clause.
|
||||
*/
|
||||
public void dmlBind(BindableRequest request, EntityBean bean)
|
||||
throws SQLException {
|
||||
public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
|
||||
|
||||
Object value = null;
|
||||
if (bean != null) {
|
||||
|
||||
+7
-8
@@ -1,11 +1,5 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
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;
|
||||
@@ -13,6 +7,11 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bindable for a EmbeddedId.
|
||||
*/
|
||||
@@ -83,8 +82,8 @@ public final class BindableIdEmbedded implements BindableId {
|
||||
|
||||
if (matches == null) {
|
||||
String m = "Matches for 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?";
|
||||
+ " 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
public class BindableIdEmpty implements BindableId {
|
||||
|
||||
public boolean isEmpty() {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
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.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bindable for a single scalar id property.
|
||||
*/
|
||||
|
||||
@@ -49,15 +49,12 @@ public class BindableList implements Bindable {
|
||||
}
|
||||
|
||||
public void dmlAppend(GenerateDmlRequest request) {
|
||||
|
||||
for (Bindable item : items) {
|
||||
item.dmlAppend(request);
|
||||
}
|
||||
}
|
||||
|
||||
public void dmlBind(BindableRequest bindRequest, EntityBean bean)
|
||||
throws SQLException {
|
||||
|
||||
public void dmlBind(BindableRequest bindRequest, EntityBean bean) throws SQLException {
|
||||
for (Bindable item : items) {
|
||||
item.dmlBind(bindRequest, bean);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bindable for a single BeanProperty.
|
||||
*/
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Bindable for insert on a property with a GeneratedProperty.
|
||||
* <p>
|
||||
|
||||
+3
-3
@@ -1,14 +1,14 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bindable for update on a property with a GeneratedProperty.
|
||||
* <p>
|
||||
|
||||
+4
-5
@@ -1,10 +1,5 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.sql.SQLException;
|
||||
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;
|
||||
@@ -12,6 +7,10 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne;
|
||||
import com.avaje.ebeaninternal.server.deploy.id.ImportedId;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bindable for a unidirectional relationship.
|
||||
* <p>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.DmlMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A factory that builds Bindable for BeanPropertyAssocOne properties.
|
||||
*/
|
||||
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyCompound;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.DmlMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Add base properties to the BindableList for a bean type.
|
||||
* <p>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.avaje.ebeaninternal.server.persist.dmlbind;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne;
|
||||
import com.avaje.ebeaninternal.server.persist.dml.DmlMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A factory that builds Bindable for embedded bean properties.
|
||||
*/
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Bindable objects to support Bean DML</TITLE>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Bindable objects to support Bean DML</TITLE>
|
||||
</HEAD>
|
||||
<Body BGCOLOR="#ffffff">
|
||||
Bindable objects to support Bean DML
|
||||
|
||||
</Body>
|
||||
</HTML>
|
||||
</HTML>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Persistence Implementation</TITLE>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Persistence Implementation</TITLE>
|
||||
</HEAD>
|
||||
<Body BGCOLOR="#ffffff">
|
||||
Persistence Implementation
|
||||
|
||||
<p>
|
||||
Implementing the saving and deleting of beans, and the executing of
|
||||
updateable and callable sql.
|
||||
Implementing the saving and deleting of beans, and the executing of
|
||||
updateable and callable sql.
|
||||
</p>
|
||||
|
||||
</Body>
|
||||
</HTML>
|
||||
</HTML>
|
||||
|
||||
@@ -10,21 +10,21 @@ import java.util.Map;
|
||||
*/
|
||||
public class BeanPropertiesReader {
|
||||
|
||||
private final Map<String,Integer> propertyIndexMap = new HashMap<>();
|
||||
|
||||
private final Map<String, Integer> propertyIndexMap = new HashMap<>();
|
||||
|
||||
private final String[] props;
|
||||
|
||||
|
||||
public BeanPropertiesReader(Class<?> clazz) {
|
||||
this.props = getProperties(clazz);
|
||||
for (int i=0; i<props.length; i++) {
|
||||
for (int i = 0; i < props.length; i++) {
|
||||
propertyIndexMap.put(props[i], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String[] getProperties() {
|
||||
return props;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return Arrays.toString(props);
|
||||
}
|
||||
@@ -32,14 +32,14 @@ public class BeanPropertiesReader {
|
||||
public Integer getPropertyIndex(String property) {
|
||||
return propertyIndexMap.get(property);
|
||||
}
|
||||
|
||||
|
||||
private String[] getProperties(Class<?> clazz) {
|
||||
try {
|
||||
Field field = clazz.getField("_ebean_props");
|
||||
return (String[]) field.get(null);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Error getting _ebean_props field on type "+clazz, e);
|
||||
throw new IllegalStateException("Error getting _ebean_props field on type " + clazz, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import com.avaje.ebean.bean.EntityBean;
|
||||
*/
|
||||
public interface BeanPropertyGetter {
|
||||
|
||||
/**
|
||||
* Return the value of a given bean property.
|
||||
*/
|
||||
Object get(EntityBean bean);
|
||||
/**
|
||||
* Return the value of a given bean property.
|
||||
*/
|
||||
Object get(EntityBean bean);
|
||||
|
||||
Object getIntercept(EntityBean bean);
|
||||
Object getIntercept(EntityBean bean);
|
||||
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ package com.avaje.ebeaninternal.server.properties;
|
||||
*/
|
||||
public interface BeanPropertyInfo {
|
||||
|
||||
/**
|
||||
* Create an EntityBean for this type.
|
||||
*/
|
||||
Object createEntityBean();
|
||||
|
||||
/**
|
||||
* Return the getter for a given bean property.
|
||||
*/
|
||||
BeanPropertyGetter getGetter(int position);
|
||||
|
||||
/**
|
||||
* Return the setter for a given bean property.
|
||||
*/
|
||||
BeanPropertySetter getSetter(int position);
|
||||
/**
|
||||
* Create an EntityBean for this type.
|
||||
*/
|
||||
Object createEntityBean();
|
||||
|
||||
/**
|
||||
* Return the getter for a given bean property.
|
||||
*/
|
||||
BeanPropertyGetter getGetter(int position);
|
||||
|
||||
/**
|
||||
* Return the setter for a given bean property.
|
||||
*/
|
||||
BeanPropertySetter getSetter(int position);
|
||||
}
|
||||
|
||||
+4
-4
@@ -7,8 +7,8 @@ package com.avaje.ebeaninternal.server.properties;
|
||||
*/
|
||||
public interface BeanPropertyInfoFactory {
|
||||
|
||||
/**
|
||||
* Create the BeanReflect for the given plain bean and its EntityBean equivalent.
|
||||
*/
|
||||
BeanPropertyInfo create(Class<?> entityBeanType);
|
||||
/**
|
||||
* Create the BeanReflect for the given plain bean and its EntityBean equivalent.
|
||||
*/
|
||||
BeanPropertyInfo create(Class<?> entityBeanType);
|
||||
}
|
||||
|
||||
@@ -7,17 +7,17 @@ import com.avaje.ebean.bean.EntityBean;
|
||||
*/
|
||||
public interface BeanPropertySetter {
|
||||
|
||||
/**
|
||||
* Set the property value of a bean.
|
||||
*/
|
||||
void set(EntityBean bean, Object value);
|
||||
/**
|
||||
* Set the property value of a bean.
|
||||
*/
|
||||
void set(EntityBean bean, Object value);
|
||||
|
||||
/**
|
||||
* Set the property value of a bean with interception checks.
|
||||
* <p>
|
||||
* This could invoke lazy loading and or oldValues creation.
|
||||
* </p>
|
||||
*/
|
||||
void setIntercept(EntityBean bean, Object value);
|
||||
/**
|
||||
* Set the property value of a bean with interception checks.
|
||||
* <p>
|
||||
* This could invoke lazy loading and or oldValues creation.
|
||||
* </p>
|
||||
*/
|
||||
void setIntercept(EntityBean bean, Object value);
|
||||
|
||||
}
|
||||
|
||||
+4
-6
@@ -1,11 +1,10 @@
|
||||
package com.avaje.ebeaninternal.server.properties;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Modifier;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
* A BeanReflect implementation based on the enhancement that creates EntityBean
|
||||
@@ -20,11 +19,10 @@ public final class EnhanceBeanPropertyInfo implements BeanPropertyInfo {
|
||||
public EnhanceBeanPropertyInfo(Class<?> clazz) {
|
||||
try {
|
||||
if (Modifier.isAbstract(clazz.getModifiers())) {
|
||||
this.constructor = null;
|
||||
this.constructor = null;
|
||||
} else {
|
||||
this.constructor = defaultConstructor(clazz);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
package com.avaje.ebeaninternal.server.properties;
|
||||
|
||||
/**
|
||||
* Creates a BeanReflectFactory based on the enhancement that
|
||||
* Creates a BeanReflectFactory based on the enhancement that
|
||||
* creates EntityBean implementations.
|
||||
*/
|
||||
public final class EnhanceBeanPropertyInfoFactory implements BeanPropertyInfoFactory {
|
||||
|
||||
public BeanPropertyInfo create(Class<?> entityBeanType) {
|
||||
return new EnhanceBeanPropertyInfo(entityBeanType);
|
||||
}
|
||||
public BeanPropertyInfo create(Class<?> entityBeanType) {
|
||||
return new EnhanceBeanPropertyInfo(entityBeanType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Bean Reflection</TITLE>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Bean Reflection</TITLE>
|
||||
</HEAD>
|
||||
<Body BGCOLOR="#ffffff">
|
||||
Bean reflection Implementation
|
||||
|
||||
<p>
|
||||
Abstracts the bean property getter and setter methods.
|
||||
Allows Code generation or reflection to be used.
|
||||
Abstracts the bean property getter and setter methods.
|
||||
Allows Code generation or reflection to be used.
|
||||
</p>
|
||||
|
||||
</Body>
|
||||
</HTML>
|
||||
</HTML>
|
||||
|
||||
Reference in New Issue
Block a user