Thursday, July 22, 2010

Element 'bean' cannot have character [children], because the type's content type is element-only

Encountered this error yesterday and spend some time on figuring out what could be wrong with the config and later on comparision with the previous version found the bean definition had an additional '-' character.In the Spring context file ,if the bean definition needs any special characters ,it must be enclosed with the escape character else the forementioned exception is thrown.

Monday, July 19, 2010

Vaadin

Vaadin is framework for developing web applications in Java . The application can be deployed on any Java server (Tomcat, WebSphere,etc). Ajax and other web related stuff are automatically handled by the framework.Vaadin renders its UI using GWT but all the logic and data are on the server-side.For the Server Client communication Vaadin uses JSON since JSON has better performance when compared with XML.

Vaadin provides plugin for Eclipse.The documentation mentions this could be used in Eclipse version Galileo and Ganymede.But could not install the plugin with Ganymede .Tried with Galileo and it works like charm!

When trying to use csvalidation.jar for Client Side Validations ran into Run Time Exceptions later from the Vaadin team came to know it was due the Java version I was using.Upgrading to csvalidation-0.3.4.jar works for JRE 1.5 .More details on this on
http://vaadin.com/forum/-/message_boards/message/178918

The http://vaadin.com/tutorial/-/page/skeleton.html#skeleton.application is a good place to start a simple sample application.

Friday, July 2, 2010

Spring Web Services

Web services is the technology that integrates Web-based applications using the XML, SOAP, WSDL and UDDI open standards over the Internet . XML is used to define the data structure, SOAP is used to transfer the data, WSDL is used for describing the services available and UDDI is used for listing what services are available. Web services allow organizations to communicate data without the knowledge of each other's IT systems behind the firewall.

Web services do not provide the user with a GUI instead the services are shared through a programmatic interface across a network.

Web services allow different applications from different platforms to communicate with each other since all communication is in XML.

A detailed tutorial about implementing Spring Web Service which I found very useful is at
http://webcache.googleusercontent.com/search?q=cache:K3fszlCL9JQJ:www.lulu.com/content/content_download_redirect.php%3FmetaId%3D1090073+maven+dependecies+for+Spring+web+service&cd=2&hl=en&ct=clnk&gl=sg

Hibernate Criteria Sample Implementation

The Criteria interface in Hibernate is used to create and execute object-oriented queries.
The following are some commonly used criterion.
(i) To query based on simple search criteria like Employee Type Permanent and Confirmation Date less than Request Date
Criteria criteria = session.createCriteria( Emp.class );
Criterion[] criterions = new Criterion[] {
Restrictions.eq( "empType", 'P' ),
Restrictions.and( Restrictions.isNotNull( "confirmationDate" ),
Restrictions.le( "confirmationDate",
requestDate ) )
};
for ( Criterion criterion : criterions ) {
criteria.add( criterion );
}
List result=criteria.list( );

(ii) To Retrieve values between

Criteria criteria = session.createCriteria( Emp.class );
Criterion[] criterions = new Criterion[] {
Restrictions.between( "joiningDate", startDate,endDate )};
for ( Criterion criterion : criterions ) {
criteria.add( criterion );
}
List result=criteria.list( );

(iii) Using In Clause
Criteria criteria = session.createCriteria( Emp.class );
Criterion[] criterions = new Criterion[] {
Restrictions.in( "empType",new Object[]{'P','C','R' )};
for ( Criterion criterion : criterions ) {
criteria.add( criterion );
}
List result=criteria.list( );

(iv) To find Record Count.
Criteria criteria = session.createCriteria( Emp.class );
criteria.setProjection(Projections.rowCount());
result=criteria.list( );
if ((null != result) && (!result.isEmpty())) {
Integer rowCount = (Integer) result.get(0);
}

(v) Returning 'n' columns from the Entity List based on Search Criteria
Criteria criteria = session.createCriteria( Emp.class );
Criterion[] criterions = new Criterion[] {
Restrictions.in( "empType",new Object[]{'P','C','R' )};
for ( Criterion criterion : criterions ) {
criteria.add( criterion );
}
criteria.setProjection( Projections.projectionList( )
.add( Projections.property( fieldName1 )) .add( Projections.property( fieldName2 ) ) );
List result=criteria.list( );

(vi) Return Result based on descending order
Criteria criteria = session.createCriteria( Emp.class );
Criterion[] criterions = new Criterion[] {
Restrictions.in( "empType",new Object[]{'P','C','R' )};
for ( Criterion criterion : criterions ) {
criteria.add( criterion );
}
crietrai.addOrder( Order.desc("empName") )
List result=criteria.list( );