
pedal.template.methodGetValueList.stg Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pedal-dialect Show documentation
Show all versions of pedal-dialect Show documentation
Pedal-dialect is a collection of dialect (database) and provider (e.g. Hibernate) specific implementations for use with JPA. It enables non-standard SQL data types (arrays, sets, bit-sets) and dialect specific features such as support for the Postgresql Copy command.
methodBody(attributes, entityClass) ::= <<
public String getValueList(Object entity) {
StringBuilder builder = new StringBuilder();
typed = ()entity;
try {
} catch (Exception e) {
throw new RuntimeException(e);
}
builder.append("\\n");
return builder.substring(1);
}
>>
process(attribute) ::= <<
builder.append("\\t");
{
builder.append(typed.());
var = typed.();
if (var == null) {
builder.append("\\\\N");
} else {
converter = ().class.newInstance();
String s = converter.convert(var);
builder.append(s == null ? "\\\\N" : s);
converter = ().class.newInstance();
Object converted = converter.convertToDatabaseColumn(var);
builder.append(converted == null ? "\\\\N" : converted);
if (var.isEmpty()) {
builder.append("\\\\N");
} else {
java.util.Iterator it = var.iterator();
StringBuilder array = new StringBuilder();
while (it.hasNext()) {
Object o = it.next();
array.append(",").append(o);
}
String arrayStr = array.length() == 0 ? "" : array.substring(1);
builder.append("{").append(arrayStr).append("}");
}
for (int i = 0; i \< ; i++) {
builder.append(var.get(i) ? "1" : "0");
}
builder.append(var.());
}
}
>>
simpleValue(attribute, methods, var) ::= <<
= .();
builder.append();
builder.append();
if ( == null) {
builder.append("\\\\N");
} else {
builder.append();
builder.append();
}
>>
typeNameEvaluator(method) ::= <<
[]
>>
hexEncode(var) ::= <<
"\\\\\\\\x" + org.apache.commons.codec.binary.Hex.encodeHexString()
>>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy