Tuesday, March 25, 2008

Hibernate and Stored Procedure.

Calling Stored procedure from Hibernate is really easy if it is adhered to certain rules.

Pre Condition: Function or Procedure should always return Refcursor. The return type of Ref cursor is also depends on the Database and drivers the application is using.
a) It supports IN and OUT.
b) If you use SP wiht Oracle own driver , Hibernate requires the first parameter of the SP is OUT.
c) In Oracle 9 or newer version , the type of the OUT parameter has to be SYS_REFCURSOR
d) In Older version of Oracle it can be declared as REF CURSOR.
e) For different database like MySQL and MS SQL the syntax differs.


2) Create the SP/Function
REATE OR REPLACE PROCEDURE GET_EMPLOYEE_DETAIL(OUT_RESULT OUT SYS_REFCURSOR) AS
BEGIN
//Write application business logic and return the SYS_REFCURSOR here
//OR

open OUT_RESULT for SELECT * FROM EMPLOYEE WHERE DEPT_ID =100
END;
/


3) Create the hibernate mapping file for SP/Function. Usually it will be StoredProcedure-hbm.xml

a) This mapping is not same as class and table mapping. But we need to use SQL-named Query mapping for this.
b) This SQL Query mapping we need add callable="true" attribute. This enable the handling of SP from Hibernate and output of the procedure.


hibernate-mapping
< name="GetEmployeeDetail_SP" callable="true">
< alias="employee" class="com.test.employee">
< / return >

{ call PIP.GET_EMPLOYEE_DETAIL(?) }
< / sql-query >
< / hibernate-mapping >


4) Execute the Procedure.
List l = HibernateUtil.getSession().getNamedQuery("GetEmployeeDetail_SP").list();

a) After execution we will received it as a list which contains the hydrated object of employee class.

Monday, March 17, 2008

Job Scheduler in WAS 6.0

job Scheduler in Commonj.TimerManager using WAS 6.0

1) create a JNDI using Resource => AsyncBeans=> TimerManager in WAS 6.0
2) Create a reference in the web.xml file like this.
a) Go to deployment descriptor file
b) Select the reference button
c) Select give the resource name, JNDI name and all the details in that tab.
d) Save it and refreence will be created in web.xml.


3) Create a CachingTimer.java

public class CachingTimer {
public void loadTimer(){
try {
InitialContext ctx = new InitialContext();
TimerManager tm = (TimerManager)ctx.lookup("java:comp/env/tm/PipCaching");
//Set the timer to expire the cache every thirty minutes
//from now and repeat for every 30 minutes

Timer timer =tm.scheduleAtFixedRate(new CacheAdminImplTimerListener(),1000*30, 1000*30);
}catch(Exception e){
e.printStackTrace();
}
}

Here timer also have a method called schedule() which fires job based on the interval time. say for an example,

Timer timer =tm.schedule(new CacheAdminImplTimerListener(),1000*30, 1000*30);

In this case, if the first job start time is 2.00 Am and it takes 20 minutes to complete then after the gap of 30 minutes the second job will be fired.
It is not fired at fixed rate frequency.


4) Create a java class which implements TimerListener interface.

public class CacheAdminImplTimerListener
implements TimerListener {

public void timerExpired(Timer timer) {
// Here actually write the business logic.
CacheAdmin c =new CacheAdminImpl();
c.removeAllCache();
}
}


timerExpired() method is the abstract method in TimerListener class and this method needs to be overridden in the implementation class.


5) To Stop the timer or Cancel the timer then we need to implement the StopTimerListener class and CancelTimerListener class.

Tuesday, March 11, 2008

H1B - approved petition for the year 2007

The following are H1B approved by INS for each employer. It seems india is on the top list.
Rank Employer Approved Petitions
1 Infosys Technologies 4,559
2 Wipro 2,567
3 Satyam Computer Services 1,396
4 Cognizant Tech Solutions 962
5 Microsoft 959
6 Tata Consultancy Services 797
7 Patni Computer Systems 477
8 US Technology Resources 416
9 I-Flex Solutions 374
10 Intel 369
11 Accenture 331
12 Cisco 324
13 Ernst & Young 302
14 Larsen & Toubro Infotech 292
15 Deloitte & Touche 283
16 Google 248
17 Mphasis Corporation 248
18 University Of Illinois At Chicago 246
19 American Unit 245
20 JSMN International 245
21 Objectwin Technology 243
22 Deloitte Consulting 242
23 Prince Georges County Public Schools 238
24 JPMorgan Chase 236
25 Motorola 234
26 Marlabs 229
27 KPMG 227
28 Goldman Sachs 224
29 Tech Mahindra Americas 217
30 Verinon Technology Solutions 213
31 The Johns Hopkins Med. Insts. 205
32 Yash Technologies 202
33 Advansoft International 201
34 University Of Maryland 199
35 Baltimore City Public Schools 196
36 Pricewaterhousecoopers 192
37 Polaris Software Lab India 191
38 University Of Michigan 191
39 Everest Business Solutions 190
40 IBM 184
41 Apex Technology Group 174
42 New York City Public Schools 171
43 Software Research Group 167
44 Everest Consulting Group 165
45 University Of Pennsylvania 163
46 GSS America 160
47 Qualcomm 158
48 University Of Minnesota 151
49 Mascon Global Consulting 150
50 Micron Technology 149
51 The Ohio State University 147
52 Stanford University 146
53 Columbia University 143
54 First Tek Technologies 143
55 U S Tech Solutions 143
56 Globalcynex 142
57 Global Consultants 141
58 Xceltech 139
59 University At Albany Suny 138
60 Dis. Natl. Institutes Of Health 136
61 Lehman Brothers 135
62 McKinsey 135
63 Yale University 132
64 Merrill Lynch 131
65 Dibon Solutions 130
66 Syntel Consulting 130
67 NYC-HHC Harlem Hospital Center 129
68 University Of Florida Intl. Center 128
69 EBusinessware 127
70 Harvard University 127
71 Univ. Of California Los Angeles 127
72 Univ. Wisconsin Madison 127
73 Semafor Technologies 126
74 Vision Systems Group 126
75 Advent Global Solutions 125
76 Bloomberg 125
77 Hallmark Global Technologies 125
78 Cosmos Foundation 124
79 Cummins 124
80 Covansys 123
81 University Of Pittsburgh 122
82 Xenosoft Technologies 121
83 Northwestern University 120
84 Peri Software Solutions 120
85 Morgan Stanley 119
86 Flextronics Software Systems 118
87 Emory University 117
88 Texas Instruments 117
89 Cleveland Clinic Foundation 114
90 Indiana Univ Purdue 114
91 Techgene Solutions 114
92 Oracle 113
93 Credit Suisse Securities 112
94 HD Dimension 112
95 Summitworks Technologies 112
96 The Pennsylvania State University 112
97 University Of Washington 111
98 V-Soft Consulting Group 111
99 Sirsai 110
100 Intelliswift Software 109
101 Supreme Soft 109
102 American Solutions 108
103 HTC Global Services 108
104 Univ. Of Missouri Columbia 108
105 Yahoo 108
106 Massachusetts General Hospital 107
107 Rite Aid Corporation 107
108 V L S Systems 107
109 University Of California Davis 106
110 Cyberthink 105
111 Inek Technologies 105
112 Vedicsoft Solutions 105
113 Global Teachers Research 104
114 Univ. Of California San Francisco 104
115 Chevron 103
116 HCL America 102
117 Delasoft 101
118 Deloitte Tax 101
119 Washington University In St Louis 101
120 Mutex Systems 100
121 Apollo Consulting Services Corp 99
122 Capgemini U S 99
123 Univ. of Texas Southwestern Med. Ctr. At Dallas 99
124 International Tech Solutions 98
125 Oklahoma State University 98
126 Purdue Univ. Dept Of Chemistry 98
127 Astir IT Solutions 97
128 Terra Infotech 97
129 The Univ. Of Alabama At Birmingham 97
130 Divihn Integration 96
131 JCG Technologies 96
132 Capital One Services 95
133 Dallas Independent School District 95
134 Meridian Technologies 95
135 Technology People 95
136 Diaspark 94
137 Kanbay 92
138 MGL Americas 90
139 Baylor College Of Medicine 89
140 California State Univ Northridge 89
141 Enterprise Solutions 89
142 Amgen 88
143 Orionsoft 88
144 Xpedite Technologies 88
145 Jass & Associates 87
146 General Electric 86
147 Intelligroup 86
148 MCS Global 86
149 The University Of Iowa 86
150 Mass. Inst. of Tech. 85
151 Mount Sinai Medical Center 85
152 Radiant Global 85
153 Terasoft International 85
154 U.S. Virgin Islands Dept Of Ed 85
155 Amsol 83
156 Intl. Students And Scholars Office 83
157 The Univ. Of Texas M.D. Anderson Cancer 83
158 California Institute Of Technology 82
159 Technosoft Corporation 82
160 Amazon Global Resources 81
161 University Of Utah 81
162 Amtex Systems 80
163 Business Integra 80
164 CMC Americas 80
165 RedSalsa Technologies 80
166 Softpath System 80
167 University Of Southern California 80
168 Virtue Group 80
169 EMC Corporation 79
170 University Of Colorado 79
171 Ventech Solutions 79
172 Citigroup Global Markets 78
173 Innergraph 78
174 Premier IT Solutions 78
175 Surya Systems 78
176 The University Of Texas At Austin 78
177 Georgia Institute Of Technology 77
178 Genome Intl. 76
179 Multivision 76
180 Nexus Software Solutions 76
181 Techno Soft 76
182 Advansoft Worldwide 75
183 Dell USA 75
184 ISR Info Way 75
185 North Carolina State University 75
186 Niit Technologies 75
187 University Of Virginia 75
188 3i Infotech Consulting 74
189 Duke Univ. Univ. Med. Ctr. 74
190 Louisiana State University 74
191 Vanderbilt University 74
192 Vensoft 74
193 Ebusiness Application Solutions 73
194 Materials Software System 73
195 Vensoft 73
196 Vmware 73
197 Bilinguals 72
198 HSBC Bank 72
199 ICSA 72
200 R Square 72
Courtesy : Businessweek.