Tuesday, November 15, 2011

type-mappinmg for byte[] in standardjbosscmp-jdbc.xml

http://community.jboss.org/thread/23104?decorator=print&displayFullThread=true

 

After many hours investigating this problem I have found a solution myself.

Here the mapping required in standardjbosscmp-jdbc.xml if you want to read and write to blob fields using an byte[] java type rather than some serialized java.lang.Object:

<java-type>[B</java-type>
<jdbc-type>VARBINARY</jdbc-type>
<sql-type>IMAGE</sql-type>

and the entity bean abstract get & set methods will be as below:

public abstract byte[] getField();
public abstract void setField(byte[] value);

Now I can read and write to the blob using array's of bytes just like any byte[] which is simple, neat and tidy coding exercise.

I guess you would need to be a bit careful with really big blobs as when the entity bean is read from the DB it will bring the whole blob into memory and hold it in a byte[].

The <java-type> of '[B' means a byte[] type. This you will not find in any documentation. I found this by looking at the JBoss source code in the process of trying to understand what was going on with blobs. The class in where I found the '[B' is:

org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil

 

Cheers,

Sarang

As I mentioned in my previous post on productivity, using the productivity tools DOES help a lot.... a snapshot of my productivity analysis since I started using these tools. I have been, according to RescueTime, amongst top 13% productive people! :)
Not reading too much into these statistics, I can definitely say that I have felt considerable improvement in my productivity!






Enhanced by Zemanta

Wednesday, November 2, 2011

Some good productivity tools

Some excellent FOSS tools to enhance productivity –
  1. Grindstone – Timers for Task Management
  2. RescueTime – For analyzing computer usage
  3. ManicTime tracker – Similar to RescueTime
  4. Approach: Pomodoro Technique
Will blog about more details sometime later.
Right now, I don’t want this post to affect my productivity ;)

And yeah, this DOES help a lot!!!

Cheers,
Sarang