Hi everybody,
while executing a query there turned up an SQLException. I wonder if
this is a bug or if I made a mistake.
Here is the concerning section of my repository_user.xml:
<class-descriptor class="modulverwaltung.beans.ojb.Module"
table="MODUL">
<field-descriptor name="name" column="modul_Name"
jdbc-type="VARCHAR" primarykey="true" />
<field-descriptor name="courseOfStudy" column="Zuordnung"
jdbc-type="VARCHAR" />
...
</class-descriptor>
As you see, the column 'name' is of type VARCHAR.
The according bean is:
public class Module implements Serializable {
protected String name;
protected String courseOfStudy;
...
}
Now I want to execute following Code:
Criteria crit = new Criteria();
crit.addEqualTo("courseOfStudy", courseOfStudy);
if (excludeModules != null) {
for (int i = 0; i < excludeModules.length; i++) {
crit.addNotEqualToColumn("name", excludeModules[i]);
}
}
ReportQueryByCriteria q = QueryFactory.newReportQuery(Module.class,
crit);
q.addOrderByAscending("name");
q.setAttributes(new String[] { "name" });
try {
iter = broker.getReportQueryIteratorByQuery(q);
for (int i = 0; iter.hasNext(); i++) {
...
}
}
...
As you see, I'm adding a notEqualToColumn Criteria with the following
parameters:
--> name: the concerning column (table column's name is modul_name)
--> excludeModules[]: a String[] which says which column values should
be excluded
The SQL statement which OJB generates is:
SELECT A0.modul_Name FROM MODUL A0 WHERE (A0.Zuordnung = 'Bachelor') AND
A0.modul_Name <> ALP I: Funktionale Programmierung ORDER BY 1
So, this causes an SQLException, because the name which to be excluded
(ALP I: Funktionale Programmierung) is of type VARCHAR but there aren't
any enclosing quotation marks. The correct Statement should say:
SELECT A0.modul_Name FROM MODUL A0 WHERE (A0.Zuordnung = 'Bachelor') AND
A0.modul_Name <> 'ALP I: Funktionale Programmierung' ORDER BY 1
Maybe this is a bug or have i overlooked something?
Thanks for help,
Abid
--
Abid Hussain
Mail: [EMAIL PROTECTED]
Web: http://www.abid76.de
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]