Wednesday, June 19, 2013

Counting Crows setlist 2013

@Bank of America Pavillion, Boston, MA 18th June 2013

Black and Blue
Omaha
Start Again
Richard Manuel is Dead
Round Here
Catapult
Daylight Fading
Return of the Grievous Angel
You Ain't Goin' Nowhere
1492
Colorblind
Children in Bloom
Goodnight L.A.
Hospital
Anna Begins
Meet on the Ledge
A Long December
Rain King

Encore:
Washington Square
Holiday in Spain
Walkaways
Hanginaround 

Saturday, June 15, 2013

Everclear summerland tour 2013 setlist

Everclear setlist at House of Blues, Boston, MA on 15th June 2013.

Monday, March 25, 2013

Ibatis queryForList returning a List of String objects

Using an IBatis query that returns mutiple rows from the database, each row can be returned as an object and all these individual objects can be encompassed in a List.

query
<select id="getEmpNames" resultClass="java.lang.String">
        select names from emp_address where dept_id = #value#
    </select>
   
    Java code
    public class EmployeeDaoImpl extends SqlMapClientDaoSupport {
    ...
    ...
        public List<String> getEmpNames(Long deptId) {
       
         List<String> tempList = getSqlMapClientTemplate().queryForList("getEmpNames", deptId);
         return tempList;
         }
     ..
     }
   

For example if the above code snippet returns 5 rows from the database, IBatis internally constructs 5 String objects and returns a List<String>.

Friday, March 8, 2013

Convert java attributes to start with upperCase when being written to xml file using XStream

    if (xstream == null) {
                xstream = new XStream(){
                  
                    @Override
                    protected MapperWrapper wrapMapper(MapperWrapper next) {
                            return new UpperCaseMapper(next);
                    }
                };
            }
           
    private static class UpperCaseMapper extends MapperWrapper {
        public UpperCaseMapper(Mapper wrapped) {
                super(wrapped);
        }

        @Override
        public String serializedMember(Class type, String memberName) {
            String camelCase = memberName.substring(0, 1).toUpperCase() + memberName.substring(1);
            return super.serializedMember(type, camelCase);
        }
       
        @Override
        public String realMember(Class type, String serialized) {
                String camelCase = serialized.substring(0, 1).toLowerCase()
                                + serialized.substring(1);
                return super.realMember(type, camelCase);
        }
    }

Saturday, January 26, 2013

Soundgarden setlist @ Orpheum Theatre, Boston, MA in 2013

Searching With My Good Eye Closed
Spoonman
Jesus Christ Pose
Outshined
By Crooked Steps
Taree
My Wave
Been Away Too Long
The Day I Tried to Live
Blow Up the Outside World
Fell on Black Days
Ugly Truth
Drawing Flies
Hunted Down
Non-State Actor
Blood on the Valley Floor
Mailman
A Thousand Days Before
Burden in My Hand
Head Down
Loud Love
4th of July

Encore:
Incessant Mace
Rusty Cage
Black Hole Sun
Slaves & Bulldozers

source: www.setlist.fm

Saturday, January 12, 2013

Ibatis return custom java object from query as List

Using IBatis if a sql query returns a number of rows and you need to IBatis to convert these rows to a java Object then you need to

1) create a resultMap entry where you map the propery in the java object to a column in a table
2) create a statement which contains the query and specify a resultMap (This is has been defined by above step 1)

using the above two configurations, Ibatis converts each row into a new MyClass() object and then populates it with the data from that row.

java code snippet
Map parameterMap = new HashMap();
parameterMap.put("inputNames", "abc");
      
List nameList = (List) getSqlMapClientTemplate().queryForList("getEmpDetails", parameterMap);
       
 

ibatis config       
<sqlMap namespace="myQueries">

    <resultMap id="idMap" class="com.test.MyClass">
        <result property="myId" column="ID_COLUMN_IN_DATABASE_TABLE"/>
        <result property="name" column="NAME_COLUMN_IN_DATABASE_TABLE"/>
    </resultMap>
   
    <statement id="getEmpDetails" resultMap="idMap"
        parameterClass="java.util.Map">
        select mytable.ID_COLUMN_IN_DATABASE_TABLE, mytable.NAME_COLUMN_IN_DATABASE_TABLE
        from mytable
        where mytable.name = #inputNames#
    </statement>
   
</sqlMap>

Using XStream to set xmlns attribute (xml namespace)

Thoughtworks xstream does not have an API to add xmlns attribute to xml root element. There is a work around to do the same using their useAttributeFor() API. Its a bit of hack but serves the purpose.

java pojo
public class TestXmlns {
    private String name;
    private String address;
    private String xmlns;
   
    ...get/set for above attributes.
   
}

create an instance of xstream and add below configuration
xstream.useAttributeFor(TestXmlns.class, "xmlns");

Example:
TestXmlns x1 = new TestXmlns();
x1.setName("abc");
x1.setAddress("zyx");
z1.setXmlns("http://com.company.mytest");

XStream xstream = new XStream();
xstream.useAttributeFor(TestXmlns.class, "xmlns");

String xmlString = xstream.toXML(x1);

output
<TestXmlns xmlns="http://com.company.mytest">
    <name>abc</name>
    <address>xyz</address>
</TestXmlns>