Posts

Showing posts from July, 2013

nth Highest salary

Find the Nth highest salary Solution: Common logic for all database is as... select t.name,t.salary from employee t   where N= (               select count(u.salary) from                   (select distinct salary from employee ) as u                   where t.salary<= u.salary        )

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role

Errror: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role....... Solution: Add lazy=false in your hbm file where you have declare collection... Example: <set name="hhResume" inverse="true" lazy="false" >             <key>                 <column name="UID" not-null="true" />             </key>             <one-to-many class="com.example.HhCandidate" />         </set>

Read gzip response from a URL using Java

Here is a code template..... public static String readGZFile(String url) throws IOException {            StringBuffer dataBuffer =new StringBuffer();            InputStream gzipStream = new GZIPInputStream((new URL(url)).openStream());            Reader decoder = new InputStreamReader(gzipStream, "UTF-8");            BufferedReader buffered = new BufferedReader(decoder);            int i=0;            String line=buffered.readLine();            while(line !=null){                dataBuffer.append(line);                line=buffered.readLine();           ...