Archive for January, 2007
WordPress 2.1
As soon as I saw that folks at WordPress have update to 2.1, I decied to give it a shot because of the very annoying TineMCE errors. So here we are good and running on version 2.1 ![]()
Delete Duplicate Rows From an Oracle Table
Yesterday i was loading data into tables, some how i messed up loading the same data two times.
Here is a solution how to remove duplicate rows:
DELETE FROM THE_TABLE
WHERE rowid not in
(SELECT MIN(rowid)
FROM our_table
GROUP BY COL1, COL2, COL3… ) ;
Here COL1, COL2, COL3 constitute the identifying key for each record.
The GROUP BY is used on the columns that make the primary key for the table. This script deletes each row in the group after the first row.
Config file in SpringFramework
Pack xml files in SpringFramework.
In my recent project, we are using a in-house framework (which i would be calling as “Framework”) which is backed by SpringFramework and Hiberante ( i had also added DWR support also ). We have actually added some helper methods and class hierarchies to avoid bolier plate code as much as possible.
One of the possible problems that i was thinkging was to have all of the SpringFramework related config files packed in a single jar file. As this will be in a jar file, so it would be difficult for the team who is using this framework (means that they wouldn’t really mess with the xml files) to go and possible modify them, which will eventually brick the framework.
I know that some of the readers will definately not agree, but to avoid potential problems, and to keep the Framework config files isolated from other .xml files that users will create for SpringMVC or other parts of Spring , we really needed to do that. Here is the solution :
First, you need to modify the web.xml and make it look like this :
[code lang=”xml”]
classpath*:adapter-config.xml,
classpath*:dao-tier-config.xml,
classpath*:service-config.xml,
classpath*:web-config.xml
[/code]
You will see that we added ‘classpath*:’ as prefix of every .xml file. We ingnored ‘myapp-servlet.xml’ as this file is not part of the framewok.
Next, add all of the files wiht ‘classpath*:’ in a single jar file and put it in the WEB-INF/lib folder. Thats all !.
This similar approach can also be used in the Spring based non-web applications.
JavaScript Object Notation
Recently I was looking at JSON (JavaScript Object Notation) and found it very intresting and usefull to me, but first let me show you how it works.
In JavaScript you need to specify data, one thig is you can do is that represent this data in xml (which you may recieve from server) like this :
[code lang=”javascript”]
Now if you are want to represent the same data in JSON, you would like this :
[code lang=”javascript”]
person = {
name : ‘Muhammad Mansoor’,
age : 22 ,
url : ‘http://mansoor.hadeedian.net/blog’
}
[/code]
quite Simple, and meaningfull.
But you dont have to think of JSON as the repalcement for XML. This is the stuff that you would be primarly using only in JavaScript such as:
- Transfer Complex Objects in JS.
- Recieved JSON object in JS, so you dont have to parse it, (which you would have done if you have got XML).
The good part about JSON is that it not limited to JavaScript, you would definately find implementation of JSON in you favourite programming language, and with more than 20 implementation on JSON.org, it is really worth looking at.
Dont think of JSON as replacing XML, XML has its own grounds, and surely it does not overlaps with other standards such as XML-RPC, SOAP etc. etc.