use of org.apache.cayenne.map.EJBQLQueryDescriptor in project cayenne by apache.
the class EJBQLQueryIT method testEncodeAsXML.
@Test
public void testEncodeAsXML() {
String ejbql = "select a FROM Artist a";
String name = "Test";
StringWriter w = new StringWriter();
XMLEncoder e = new XMLEncoder(new PrintWriter(w));
String separator = System.getProperty("line.separator");
String s = "<query name=\"" + name + "\" type=\"EJBQLQuery\">" + separator + "<ejbql><![CDATA[" + ejbql + "]]></ejbql>" + separator + "</query>" + separator;
EJBQLQueryDescriptor descriptor = new EJBQLQueryDescriptor();
descriptor.setEjbql(ejbql);
descriptor.setName(name);
descriptor.encodeAsXML(e, new EmptyConfigurationNodeVisitor());
assertEquals(w.getBuffer().toString(), s);
}
use of org.apache.cayenne.map.EJBQLQueryDescriptor in project cayenne by apache.
the class EjbqlQueryScriptsTab method setEJBQL.
void setEJBQL(String text) {
EJBQLQueryDescriptor query = getQuery();
if (query == null) {
return;
}
if (text != null && text.trim().isEmpty()) {
text = null;
}
// will call "verify" even if no changes have occured....
if (!Util.nullSafeEquals(text, query.getEjbql())) {
query.setEjbql(text);
mediator.fireQueryEvent(new QueryEvent(this, query));
}
}
Aggregations