Thursday, February 19, 2009

A neat little DAO for hibernate I came up with

No need to create new DAOs for each project if you use this little gem. Its not in groovy because GMaven has some problems with generics but this has seemed to remove the need to have multiple DAOs for annotated classes that just do basic crud functionality. Check it out and feel free to comment(Not that anyone reads these anyway :-)).

import java.util.List;

public class GenericDao extends HibernateDaoSupport{
public List getObject(T object){
return getHibernateTemplate().findByExample(object);
public List getAllObjects(Class thisClass){
return getHibernateTemplate().loadAll(thisClass);
public Object addObject(T object){
return getHibernateTemplate().save(object);
public void updateObject(T object){

Tuesday, February 17, 2009

WTF is up with native in BPEL

To anyone that has tried to play around with BPEL they quickly realize that if a partnerlink has a schema of type "Native" than the payload must be in a Base64Binary string. This means that without a schema you can't just assign a string to a native payload. This is so that non-text content (such as pictures or audio) can be sent to a partnerlink, however, it creates extra work and aggravation 99% of the time.

So the easiest way to remedy this problem is to create a embedded java in your BPEL to convert your variable to a string. This post is designed to walk you through that.

First we need to import the Binary encoder so right before all of the partnerlinks in our BPEL document we will want to add this import (This is for Oracle BPEL and the class maybe different for other flavors)


Depending on the direction you want to go.

Ok now we have our import now we need to create a variable to house our encoded string, I used...

Finally we will create our embedded Java, here is what mine looks like I encoded my string decoding would be similar.
String input = (String)getVariableData();
Base64Encoder Encoder = new Base64Encoder();

String encoded = Base64Encoder.encode(input);
catch(Exception ex)

my is "ReceiveAddToDb_Dequeue_InputVariable","genericMessage","/ns6:genericMessage/ns6:payload"

Then I use an assign to assign the variable to the native payload.