Powered by Syntax Highlighter scripts!

FOR XML PATH in Microsoft SQL Server for quick debugging on Multiple Table Joins

I was having a case where I need to search users who have more than 1 role and also see the Role names at the same time. It is not for use in application and its for me to debug on an issue.
I found that the FOR XML PATH clause on SELECT statement can be used to extract all of this information in one shot.

SELECT ID, FIRST_NAME, LAST_NAME, USERNAME,
 (SELECT COUNT(1) FROM USER_ROLE UR WHERE UR.USER_ID = AU.ID) AS ROLE_COUNT,
 (SELECT R.NAME as role FROM ROLE R, USER_ROLE UR
  WHERE R.ID = UR.ROLE_ID
  AND UR.USER_ID = TU.ID
  FOR XML PATH('')
 ) AS ROLE_NAMES
FROM MY_APP_USER AU
WHERE (SELECT COUNT(1) FROM USER_ROLE UR WHERE UR.USER_ID = AU.ID) > 1
;

GZip encryption changes for json content

Enabling GZIP encryption for Jersey Resource classes


 Jersey REST Service
 com.sun.jersey.spi.container.servlet.ServletContainer
 
  com.sun.jersey.config.property.packages
  com.mypackage1.resource;com.mypackage2.resource.provider
 
 
  com.sun.jersey.api.json.POJOMappingFeature
  true
 
 
  com.sun.jersey.spi.container.ContainerResponseFilters
  com.sun.jersey.api.container.filter.GZIPContentEncodingFilter
 
 1

Installing apache webserver locally and enabling gzip compression for json response on ajax calls

Tried installing the apache web server in my laptop,
First used the mod_jk connector to connect to local tomcat. (ref to link)
Then disabled the mod_jk connector and switched to use the mod_proxy connector to connect to local tomcat. (ref to link)

Goal of installing apache http server locally is to enable gzip compression for the site content.

Enabled compression in tomcat directly using the connector syntax below,

 Jersey REST Service
 com.sun.jersey.spi.container.servlet.ServletContainer
 
  com.sun.jersey.config.property.packages
  com.mypackage1.resource;com.mypackage2.resource.provider
 
 
  com.sun.jersey.api.json.POJOMappingFeature
  true
 
 
  com.sun.jersey.spi.container.ContainerResponseFilters
  com.sun.jersey.api.container.filter.GZIPContentEncodingFilter
 
 1


This worked fine as long as we use the port 8080, once we have the web server listening on port 80 infront of tomcat, the gzip compression is not enabled.
To get the gzip enabled on apache http server, added the line below to httpd-vhosts.conf file

AddOutputFilterByType DEFLATE text/html application/json text/plain text/xml text/javascript text/json text/x-js application/x-javascript application/javascript

This however is working for compression the response JSON for some ajax calls and not working for some ajax calls.