[exo-jcr-commits] exo-jcr SVN: r1200 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation: db and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Dec 26 09:04:18 EST 2009
Author: sergiykarpenko
Date: 2009-12-26 09:04:18 -0500 (Sat, 26 Dec 2009)
New Revision: 1200
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-302: CQJDBCStorageConnection single db queries updated
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2009-12-26 12:15:51 UTC (rev 1199)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2009-12-26 14:04:18 UTC (rev 1200)
@@ -65,22 +65,22 @@
/**
* FIND_ITEM_BY_NAME NEW.
*/
- protected String FIND_ITEM_BY_NAME_NEW;
+ protected String FIND_ITEM_BY_NAME_CQ;
/**
* FIND_NODE_BY_ID.
*/
- protected String FIND_ITEM_BY_ID_NEW;
+ protected String FIND_ITEM_BY_ID_CQ;
/**
* FIND_NODES_BY_PARENTID NEW.
*/
- protected String FIND_NODES_BY_PARENTID_NEW;
+ protected String FIND_NODES_BY_PARENTID_CQ;
/**
* GET_PROPERTIES_BY_PARENT_ID
*/
- protected String GET_PROPERTIES_BY_PARENTID;
+ protected String GET_PROPERTIES_BY_PARENTID_CQ;
/**
* FIND_REFERENCE_PROPERTIES
@@ -238,7 +238,7 @@
try
{
- ResultSet resultSet = getChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
+ ResultSet resultSet = getChildPropertiesByParentIdentifierCQ(getInternalId(parent.getIdentifier()));
List<PropertyData> children = new ArrayList<PropertyData>();
if (resultSet.next())
{
@@ -317,7 +317,7 @@
ResultSet resultSet = null;
try
{
- resultSet = findItemByIdentifierWithAllData(cid);
+ resultSet = findItemByIdentifierCQ(cid);
if (resultSet.next())
{
int itemType = resultSet.getInt(COLUMN_CLASS);
@@ -379,7 +379,7 @@
ResultSet resultSet = null;
try
{
- resultSet = findItemByNameWithAllData(parentId, name.getAsString(), name.getIndex());
+ resultSet = findItemByNameCQ(parentId, name.getAsString(), name.getIndex());
if (resultSet.next())
{
// return itemData(parent.getQPath(), item, item.getInt(COLUMN_CLASS), parent.getACL());
@@ -868,11 +868,11 @@
// }
// }
- protected abstract ResultSet findItemByIdentifierWithAllData(String identifier) throws SQLException;
+ protected abstract ResultSet findItemByIdentifierCQ(String identifier) throws SQLException;
- protected abstract ResultSet findItemByNameWithAllData(String parentId, String name, int index) throws SQLException;
+ protected abstract ResultSet findItemByNameCQ(String parentId, String name, int index) throws SQLException;
protected abstract ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
- protected abstract ResultSet getChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException;
+ protected abstract ResultSet getChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2009-12-26 12:15:51 UTC (rev 1199)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2009-12-26 14:04:18 UTC (rev 1200)
@@ -53,13 +53,13 @@
protected PreparedStatement findItemById;
- protected PreparedStatement findItemByIdNew;
+ protected PreparedStatement findItemByIdCQ;
protected PreparedStatement findItemByPath;
protected PreparedStatement findItemByName;
- protected PreparedStatement findItemByNameNew;
+ protected PreparedStatement findItemByNameCQ;
protected PreparedStatement findChildPropertyByPath;
@@ -83,12 +83,14 @@
protected PreparedStatement findValueByPropertyIdOrderNumber;
protected PreparedStatement findNodesByParentId;
+
+ protected PreparedStatement findNodesByParentIdCQ;
protected PreparedStatement findNodesCountByParentId;
protected PreparedStatement findPropertiesByParentId;
- protected PreparedStatement getPropertiesByParentId;
+ protected PreparedStatement getPropertiesByParentIdCQ;
protected PreparedStatement insertNode;
@@ -176,7 +178,7 @@
FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
- FIND_ITEM_BY_ID_NEW =
+ FIND_ITEM_BY_ID_CQ =
"select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
+ " where (I.ID=?) or (I.PARENT_ID=? and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
+ " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
@@ -185,7 +187,7 @@
FIND_ITEM_BY_NAME =
"select * from JCR_MITEM" + " where PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
- FIND_ITEM_BY_NAME_NEW =
+ FIND_ITEM_BY_NAME_CQ =
"select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
+ ", (select ID from JCR_MITEM where PARENT_ID=? and NAME=? and I_INDEX=?) I2"
+ " where (I.ID=I2.ID) or (I.PARENT_ID=I2.ID and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
@@ -215,7 +217,7 @@
FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
- FIND_NODES_BY_PARENTID_NEW =
+ FIND_NODES_BY_PARENTID_CQ =
"select I.*, V.DATA, V.ORDER_NUM"
+ " from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID), (select ID from JCR_MITEM where PARENT_ID=? and I_CLASS=1) I2"
+ " where (I.I_CLASS=1 AND I.ID=I2.ID) or (I.I_CLASS=2 and I.PARENT_ID=I2.ID and"
@@ -227,7 +229,7 @@
FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by ID";
// property may contain no values
- GET_PROPERTIES_BY_PARENTID =
+ GET_PROPERTIES_BY_PARENTID_CQ =
"select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
+ " where I.I_CLASS=2 and I.PARENT_ID=? order by ID, ORDER_NUM";
@@ -409,17 +411,17 @@
/**
* {@inheritDoc}
*/
- protected ResultSet findItemByNameWithAllData(String parentId, String name, int index) throws SQLException
+ protected ResultSet findItemByNameCQ(String parentId, String name, int index) throws SQLException
{
- if (findItemByNameNew == null)
- findItemByNameNew = dbConnection.prepareStatement(FIND_ITEM_BY_NAME_NEW);
+ if (findItemByNameCQ == null)
+ findItemByNameCQ = dbConnection.prepareStatement(FIND_ITEM_BY_NAME_CQ);
else
- findItemByNameNew.clearParameters();
+ findItemByNameCQ.clearParameters();
- findItemByNameNew.setString(1, parentId);
- findItemByNameNew.setString(2, name);
- findItemByNameNew.setInt(3, index);
- return findItemByNameNew.executeQuery();
+ findItemByNameCQ.setString(1, parentId);
+ findItemByNameCQ.setString(2, name);
+ findItemByNameCQ.setInt(3, index);
+ return findItemByNameCQ.executeQuery();
}
/**
@@ -489,14 +491,14 @@
@Override
protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
- if (findNodesByParentId == null)
- findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_NEW);
+ if (findNodesByParentIdCQ == null)
+ findNodesByParentIdCQ = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_CQ);
else
- findNodesByParentId.clearParameters();
+ findNodesByParentIdCQ.clearParameters();
- findNodesByParentId.setString(1, parentIdentifier);
+ findNodesByParentIdCQ.setString(1, parentIdentifier);
//findNodesByParentId.setString(2, parentIdentifier);
- return findNodesByParentId.executeQuery();
+ return findNodesByParentIdCQ.executeQuery();
}
/**
@@ -641,27 +643,27 @@
}
@Override
- protected ResultSet findItemByIdentifierWithAllData(String identifier) throws SQLException
+ protected ResultSet findItemByIdentifierCQ(String identifier) throws SQLException
{
- if (findItemByIdNew == null)
- findItemByIdNew = dbConnection.prepareStatement(FIND_ITEM_BY_ID_NEW);
+ if (findItemByIdCQ == null)
+ findItemByIdCQ = dbConnection.prepareStatement(FIND_ITEM_BY_ID_CQ);
else
- findItemByIdNew.clearParameters();
- findItemByIdNew.setString(1, identifier);
- findItemByIdNew.setString(2, identifier);
- return findItemByIdNew.executeQuery();
+ findItemByIdCQ.clearParameters();
+ findItemByIdCQ.setString(1, identifier);
+ findItemByIdCQ.setString(2, identifier);
+ return findItemByIdCQ.executeQuery();
}
@Override
- protected ResultSet getChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException
+ protected ResultSet getChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
- if (getPropertiesByParentId == null)
- getPropertiesByParentId = dbConnection.prepareStatement(GET_PROPERTIES_BY_PARENTID);
+ if (getPropertiesByParentIdCQ == null)
+ getPropertiesByParentIdCQ = dbConnection.prepareStatement(GET_PROPERTIES_BY_PARENTID_CQ);
else
- getPropertiesByParentId.clearParameters();
+ getPropertiesByParentIdCQ.clearParameters();
- getPropertiesByParentId.setString(1, parentIdentifier);
- return getPropertiesByParentId.executeQuery();
+ getPropertiesByParentIdCQ.setString(1, parentIdentifier);
+ return getPropertiesByParentIdCQ.executeQuery();
}
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2009-12-26 12:15:51 UTC (rev 1199)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2009-12-26 14:04:18 UTC (rev 1200)
@@ -51,12 +51,14 @@
protected PreparedStatement findItemById;
- protected PreparedStatement findItemByIdNew;
+ protected PreparedStatement findItemByIdCQ;
protected PreparedStatement findItemByPath;
protected PreparedStatement findItemByName;
+ protected PreparedStatement findItemByNameCQ;
+
protected PreparedStatement findChildPropertyByPath;
protected PreparedStatement findPropertyByName;
@@ -77,10 +79,14 @@
protected PreparedStatement findNodesByParentId;
+ protected PreparedStatement findNodesByParentIdCQ;
+
protected PreparedStatement findNodesCountByParentId;
protected PreparedStatement findPropertiesByParentId;
+ protected PreparedStatement getPropertiesByParentIdCQ;
+
protected PreparedStatement insertItem;
protected PreparedStatement insertNode;
@@ -177,17 +183,26 @@
FIND_ITEM_BY_NAME =
"select * from JCR_SITEM"
+ " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
+
+ FIND_ITEM_BY_NAME_CQ =
+ "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
+ + ", (select ID from JCR_SITEM where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=?) I2"
+ + " where (I.ID=I2.ID) or (I.PARENT_ID=I2.ID and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
+ + " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
+ + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by I.I_CLASS, I.N_ORDER_NUM, V.ORDER_NUM";
- FIND_ITEM_BY_ID_NEW =
- "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
- + " from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
- + " where I.ID=? OR (I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and I.NAME IN ('[http://www.jcp.org/jcr/1.0]primaryType')) order by V.ORDER_NUM";
+ FIND_ITEM_BY_ID_CQ =
+ "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
+ + " where (I.ID=?) or (I.PARENT_ID=? and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
+ + " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
+ + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by I.I_CLASS, I.N_ORDER_NUM, V.ORDER_NUM";
FIND_PROPERTY_BY_NAME =
"select V.DATA"
+ " from JCR_SITEM I, JCR_SVALUE V"
+ " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+
FIND_REFERENCES =
"select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME" + " from JCR_SREF R, JCR_SITEM P"
+ " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
@@ -202,12 +217,23 @@
FIND_NODES_BY_PARENTID =
"select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
+ FIND_NODES_BY_PARENTID_CQ =
+ "select I.*, V.DATA, V.ORDER_NUM"
+ + " from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID), (select ID from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?) I2"
+ + " where (I.I_CLASS=1 AND I.ID=I2.ID) or (I.I_CLASS=2 and I.PARENT_ID=I2.ID and"
+ + " (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes'"
+ + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by I.I_CLASS, I.N_ORDER_NUM, V.ORDER_NUM";
+
FIND_NODES_COUNT_BY_PARENTID =
"select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
FIND_PROPERTIES_BY_PARENTID =
"select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
+ GET_PROPERTIES_BY_PARENTID_CQ =
+ "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
+ + " where I.I_CLASS=2 and CONTAINER_NAME=? and I.PARENT_ID=? order by ID, ORDER_NUM";
+
INSERT_NODE =
"insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
+ I_CLASS_NODE + ",?,?)";
@@ -397,21 +423,7 @@
return findItemByName.executeQuery();
}
- @Override
- protected ResultSet findItemByNameWithAllData(String parentId, String name, int index) throws SQLException
- {
- if (findItemByName == null)
- findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
- else
- findItemByName.clearParameters();
- findItemByName.setString(1, containerName);
- findItemByName.setString(2, parentId);
- findItemByName.setString(3, name);
- findItemByName.setInt(4, index);
- return findItemByName.executeQuery();
- }
-
/**
* {@inheritDoc}
*/
@@ -608,30 +620,61 @@
}
@Override
- protected ResultSet findItemByIdentifierWithAllData(String identifier) throws SQLException
+ protected ResultSet findItemByNameCQ(String parentId, String name, int index) throws SQLException
{
- if (findItemByIdNew == null)
- findItemByIdNew = dbConnection.prepareStatement(FIND_ITEM_BY_ID_NEW);
+ if (findItemByNameCQ == null)
+ findItemByNameCQ = dbConnection.prepareStatement(FIND_ITEM_BY_NAME_CQ);
else
- findItemByIdNew.clearParameters();
- findItemByIdNew.setString(1, identifier);
- findItemByIdNew.setString(2, containerName);
- findItemByIdNew.setString(3, identifier);
- return findItemByIdNew.executeQuery();
+ findItemByNameCQ.clearParameters();
+
+ findItemByNameCQ.setString(1, containerName);
+ findItemByNameCQ.setString(2, parentId);
+ findItemByNameCQ.setString(3, name);
+ findItemByNameCQ.setInt(4, index);
+ return findItemByNameCQ.executeQuery();
}
+
@Override
+ protected ResultSet findItemByIdentifierCQ(String identifier) throws SQLException
+ {
+
+ if (findItemByIdCQ == null)
+ findItemByIdCQ = dbConnection.prepareStatement(FIND_ITEM_BY_ID_CQ);
+ else
+ findItemByIdCQ.clearParameters();
+ findItemByIdCQ.setString(1, identifier);
+ findItemByIdCQ.setString(2, identifier);
+ return findItemByIdCQ.executeQuery();
+ }
+
+ @Override
protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
- // TODO Auto-generated method stub
- return null;
+
+
+ if (findNodesByParentIdCQ == null)
+ findNodesByParentIdCQ = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_CQ);
+ else
+ findNodesByParentIdCQ.clearParameters();
+
+ findNodesByParentIdCQ.setString(1, containerName);
+ findNodesByParentIdCQ.setString(2, parentIdentifier);
+ return findNodesByParentIdCQ.executeQuery();
}
@Override
- protected ResultSet getChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException
+ protected ResultSet getChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
- // TODO Auto-generated method stub
- return null;
+ if (getPropertiesByParentIdCQ == null)
+ getPropertiesByParentIdCQ = dbConnection.prepareStatement(GET_PROPERTIES_BY_PARENTID_CQ);
+ else
+ getPropertiesByParentIdCQ.clearParameters();
+
+ getPropertiesByParentIdCQ.setString(1, containerName);
+ getPropertiesByParentIdCQ.setString(2, parentIdentifier);
+ return getPropertiesByParentIdCQ.executeQuery();
+
}
}
More information about the exo-jcr-commits
mailing list