Uday Pratap Singh

I am Uday Pratap Singh, a Groovy Follower, Grails Learner, and Spock Lover working at TO THE NEW in technology division. Please go through my blog posts below

Grails

GORM goodies read, discard, refresh

Grails docs are the best source to understand how to make best use of GORM methods and now the GORM Gotcha's series By Peter Ledbrook is also making the docs easy to understand. So many time it happens when the domain instance values gets updated without calling save method.It happens because the object is attached to hibernate session,...

07-Sep-2010

Grails

How to Map database table without id with grails domain

Recently I got a query regarding mapping a database table which do not have any id and version. For example the table have two varchar fields username and password nothing more than that. Although it was something strange for me that table doesn't have the id field. The good thing is that the username is a primary key in the table and...

07-Sep-2010

Node.js

Add Page number using Page Property of CSS

In my recent Nodejs project, we were required to generate the pdf document from HTML page. We are using iText renderer for doing this. The client had the requirement that each page bottom right needed to have a number on it. All these things need to be replicated on every page. So for doing this we need to know more about the CSS3...

20-Aug-2010

Technology

Enum datatype in mysql

Recently in a Grails project that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be one of value of Enum. So they...

23-Jul-2010

Grails

Grails Hibernate Filter Plugin a Life Saver

The project I am currently working on is also accessible from the iPhone. In the last few months so many changes have been done on the web application (developed in groovy/grails). Now the client wants the same thing on iPhone as well. He has a separate development team for iPhone application. The iPhone application developer wanted to...

13-Jul-2010

Technology

Merge two PDF files

In my current project the user has the option to add pdf file into the system. Recently we got the requirement to add a cover page to each pdf document that user downloads. We were already using the iText API for generating pdf so the task to do that was easy. After going through the documentation of iText I found a way to merge two pdf...

12-Jul-2010

Technology

Drop unique constraint in MySQL

Recently in my Grails project I mentioned a domain field as unique in constraints. So the table automatically created also had the same constraint, but as the requirement changed the field was not supposed to be unique. Now we need to remove that constraint from the database table as well. The trick in MySQL is that it stores the unique...

02-Jul-2010

Grails

Change SQL datatype for Grails domain String fields

The Grails automatically identifies what should be the datatype of the field in sql table e.g; fields with String datatype are converted to varchar(255), but sometimes we need to store the data more than 255 characters. In such cases earlier I used to alter the table in the database. But now I found the better solution for this problem....

07-Jun-2010

Grails

Change default table engine in Grails 1.1

Recently in our project the client had the requirement that he want each table have 'InnoDB' but Grails by default provided the MyIsam tables. We highly depends upon the create drop, update feature of grails and We dont want to change the table engine of every table manually. So after reading few docs of Grail we found the clean way of...

07-Jun-2010

Grails

Use custom method for id generation in grails

Hibernate usage in Grails is one of my favorite topic so to learn more about it I just started reading Hibernate. In hibernate I found that user can manually assign the id of object but in grails we need to rely on it and it generates it own sequential ids. Though there is no harm and saves our time as well to generate id, but there may...

07-Jun-2010

Grails

Injecting method to convert String number to number (Having , $ brackets)

Recently in my project we have use case where users have the habit of entering number as 100,000 and they write the -ve numbers as (100,000). Some times they also pur $ with the number field Initially when we were not aware of this we were populating the object like Expense expense =new Expense(params) This throw exception as the...

21-May-2010

Technology

Converting pdf file to image file using imagemagick and groovy

Recently in one of my project user have the requirement where he can upload the pdf file and its get converted into the image file, that can be used by the user for manipulations. After looking at here and there finally we find out the imagemagick tool which converts pdf file to image file. Its very easy to use this tool, all you need...

19-Apr-2010