Hello!
I'm learning to use peers in Turbine. In my database (mysql) I've a column which type
is mediumblob.
And I was unable to do BasePeer.doSelect(Criteria) without this path to
org.apache.turbine.util.db.SqlExpression.java:
@@ -158,6 +158,11 @@
{
criteria = quoteString(criteria.toString());
}
+ else if( criteria instanceof byte[])
+ {
+ criteria = encodeBytes((byte[]) criteria);
+ }
+
if ( comparison.equals(Criteria.LIKE) )
{
return buildLike( columnName, (String)criteria, ignoreCase, db );
@@ -406,5 +411,27 @@
.append(value)
.append("'")
.toString();
+ }
+
+ /**
+ Encodes a byte[] ready for placement in a SQL expression.
+
+ @param value the byte[] to quote
+ @return encoded value as String
+ */
+ static String encodeBytes(byte value[])
+ {
+ StringBuffer result = new StringBuffer("0x");
+ int count = value.length;
+ for(int i=0; i<count; i++)
+ {
+ String hex = Integer.toHexString(value[i]&0xff);
+ if (hex.length()==1)
+ {
+ result.append("0");
+ }
+ result.append(hex);
+ }
+ return result.toString();
}
}
Is it making any sense?
Slawek
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]
- Re: DB (Postgres & Transactions, unresolved issues) Nissim
- Re: DB (Postgres & Transactions, unresolved issues) Sean Legassick
- Re: DB (Postgres & Transactions, unresolved issues) Nissim
- Re: DB (Postgres & Transactions, unresolved issues) Sean Legassick
- [PATCH] Re: DB (Postgres & Transactions, unresolved iss... Nissim
- Re: [PATCH] Re: DB (Postgres & Transactions, unresolved... Nissim
- Re: [PATCH] Re: DB (Postgres & Transactions, unresolved... John McNally
- Re: [PATCH] Re: DB (Postgres & Transactions, unresolved... Sean Legassick
- Re: [PATCH] Re: DB (Postgres & Transactions, unresolved... Nissim
- Re: [PATCH] Re: DB (Postgres & Transactions, unresolved... Sean Legassick
- Re: [PATH] SqlExpression Slawomir Gawin
- Re: [PATH] SqlExpression John McNally
- RE: [PATH] SqlExpression Slawomir Gawin
- Re: [PATH] SqlExpression John McNally
- Re: [PATCH] Re: DB (Postgres & Transactions, unresolved... John McNally
- Re: [PATCH] Re: DB (Postgres & Transactions, unresolved... Sean Legassick
- Re: DB (Postgres & Transactions, unresolved issues) Daniel L. Rall
- Re: DB (Postgres & Transactions, unresolved issues) Nissim
- Re: DB (Postgres & Transactions, unresolved issues) Sean Legassick
- Non-HTML Screens Jason van Zyl
- Re: Non-HTML Screens Sean Legassick
