User: dsundstrom
Date: 01/11/28 15:09:36
Modified: src/main/org/jboss/ejb/plugins/cmp/jdbc/ejbql
SQLGenerator.java SQLTarget.java
Log:
Corrected SELECT parsing code to correctly accecpt collection
valued cmr fields.
Revision Changes Path
1.3 +3 -5
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/ejbql/SQLGenerator.java
Index: SQLGenerator.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/ejbql/SQLGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SQLGenerator.java 2001/09/01 22:03:17 1.2
+++ SQLGenerator.java 2001/11/28 23:09:36 1.3
@@ -62,11 +62,9 @@
}
private String getSelectClause(CMRField cmrField) {
- if(cmrField.isSingleValued()) {
- String identifier = idManager.getTableAlias(cmrField);
- return
SQLUtil.getColumnNamesClause(cmrField.getEntityBridge().getJDBCPrimaryKeyFields(),
identifier);
- }
- throw new IllegalArgumentException("Select path is a collection valued cmr
field.");
+ String identifier = idManager.getTableAlias(cmrField);
+ return SQLUtil.getColumnNamesClause(
+ cmrField.getEntityBridge().getJDBCPrimaryKeyFields(), identifier);
}
private String getSelectClause(CMPField cmpField) {
1.9 +24 -13
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/ejbql/SQLTarget.java
Index: SQLTarget.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/ejbql/SQLTarget.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SQLTarget.java 2001/11/13 22:26:25 1.8
+++ SQLTarget.java 2001/11/28 23:09:36 1.9
@@ -127,7 +127,7 @@
// verify that the abstract schema already exists
// this method will throw an exception if the identifier
// is unknown or if the identifer does not map to a schema
- idManager.getExistingAbstractSchema(identifier);
+ idManager.getExistingEntityPathElement(identifier);
selectPath = identifier;
} else {
// select a.b.c.d style query
@@ -136,17 +136,29 @@
// are we done yet?
if(i<selectPathList.size()-1) {
// nope, assure that the next cmr field exists and update path
- path = getSingleValuedCMRField(path, (String)selectPathList.get(i));
+ String temp = getSingleValuedCMRField(
+ path, (String)selectPathList.get(i));
+ if(temp == null) {
+ throw new IllegalArgumentException("Select path element " +
+ "is not a single valued cmr field: " +
+ path + "." + selectPathList.get(i));
+ }
+ path = temp;
} else {
- // get the final cmp field, if possible, otherwise it is a single
valued cmr field
- String cmpFieldPath = getCMPField(path,
(String)selectPathList.get(i));
+ // get the final cmp field, if possible, otherwise it must be a
+ // single valued cmr field
+ String cmpFieldPath = getCMPField(
+ path, (String)selectPathList.get(i));
if(cmpFieldPath != null) {
path = cmpFieldPath;
} else {
// create the single valued cmr field object
- String cmrFieldPath = getSingleValuedCMRField(path,
(String)selectPathList.get(i));
+ String cmrFieldPath = getSingleValuedCMRField(
+ path, (String)selectPathList.get(i));
if(cmrFieldPath == null) {
- throw new IllegalStateException("Unknown path: " + path + "."
+ selectPathList.get(i));
+ throw new IllegalArgumentException("Select path is not " +
+ "a single valued cmr field or a cmp field: " +
+ path + "." + selectPathList.get(i));
}
path = cmrFieldPath;
}
@@ -161,7 +173,8 @@
}
public Object getSelectObject() {
- PathElement selectPathElement = idManager.getExistingPathElement(selectPath);
+ PathElement selectPathElement =
+ idManager.getExistingPathElement(selectPath);
if(selectPathElement instanceof AbstractSchema) {
AbstractSchema schema = (AbstractSchema)selectPathElement;
return schema.getEntityBridge();
@@ -170,14 +183,12 @@
return cmpField.getCMPFieldBridge();
} else if(selectPathElement instanceof CMRField) {
CMRField cmrField = (CMRField)selectPathElement;
- if(cmrField.isSingleValued()) {
- return cmrField.getEntityBridge();
- }
- throw new IllegalStateException("Select path is a collection valued cmr
field.");
+ return cmrField.getEntityBridge();
}
// should never happen
- throw new IllegalStateException("Select path element is instance of unknown
type: " +
- "selectPath=" + selectPath + " selectPathElement=" + selectPathElement);
+ throw new IllegalStateException("Select path element is instance of " +
+ "unknown type: selectPath=" + selectPath +
+ " selectPathElement=" + selectPathElement);
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development