mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-11 22:32:22 +00:00
#1183 - ENH: Add support for transaction profiling
This commit is contained in:
1 parent
093f82a87f
commit
7ebef51859
46 files changed
+1063
-68
No files matched your search
@@ -114,6 +114,8 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
|
||||
|
||||
private final Map<String, String> namedQuery;
|
||||
|
||||
private final short profileBeanId;
|
||||
|
||||
public enum EntityType {
|
||||
ORM, EMBEDDED, VIEW, SQL, DOC
|
||||
}
|
||||
@@ -406,7 +408,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
|
||||
this.name = InternString.intern(deploy.getName());
|
||||
this.baseTableAlias = "t0";
|
||||
this.fullName = InternString.intern(deploy.getFullName());
|
||||
|
||||
this.profileBeanId = deploy.getProfileId();
|
||||
this.beanType = deploy.getBeanType();
|
||||
this.rootBeanType = PersistenceContextUtil.root(beanType);
|
||||
this.prototypeEntityBean = createPrototypeEntityBean(beanType);
|
||||
@@ -528,6 +530,14 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the id used in profiling to identify the bean type.
|
||||
*/
|
||||
@Override
|
||||
public short getProfileId() {
|
||||
return profileBeanId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive an array of property positions for properties that are initialised in the constructor.
|
||||
* These properties need to be unloaded when populating beans for queries.
|
||||
|
||||
@@ -79,6 +79,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Creates BeanDescriptors.
|
||||
@@ -325,6 +326,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
readEntityBeanTable();
|
||||
readEntityDeploymentAssociations();
|
||||
readInheritedIdGenerators();
|
||||
setProfileIds();
|
||||
// creates the BeanDescriptors
|
||||
readEntityRelationships();
|
||||
|
||||
@@ -727,6 +729,23 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set profileIds based on descriptor full name order.
|
||||
*/
|
||||
private void setProfileIds() {
|
||||
|
||||
List<? extends DeployBeanDescriptor<?>> deployDescriptors = deployInfoMap.values().stream()
|
||||
.map(DeployBeanInfo::getDescriptor)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
deployDescriptors.sort(Comparator.comparing(DeployBeanDescriptor::getFullName));
|
||||
|
||||
short id = 0;
|
||||
for (DeployBeanDescriptor<?> desc : deployDescriptors) {
|
||||
desc.setProfileId(++id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the BeanTable from the deployment information gathered so far.
|
||||
*/
|
||||
@@ -1044,7 +1063,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
prop.setUnidirectional();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!findMappedBy(prop)) {
|
||||
makeUnidirectional(info, prop);
|
||||
return;
|
||||
|
||||
@@ -204,6 +204,8 @@ public class DeployBeanDescriptor<T> {
|
||||
|
||||
private List<DeployBeanProperty> idProperties;
|
||||
|
||||
private short profileId;
|
||||
|
||||
/**
|
||||
* Construct the BeanDescriptor.
|
||||
*/
|
||||
@@ -620,6 +622,20 @@ public class DeployBeanDescriptor<T> {
|
||||
setBaseTable(new TableName(viewName), "", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the profileId to identity this bean type.
|
||||
*/
|
||||
public void setProfileId(short profileId) {
|
||||
this.profileId = profileId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the profileId to identify this bean type.
|
||||
*/
|
||||
public short getProfileId() {
|
||||
return profileId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the base table. Only properties mapped to the base table are by default persisted.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user