SQL: WHEN CASE NULL fails. (via All Wrong)

February 13, 2011 Leave a comment

Imagine you want to find all the null values in a column in a database table (SQL Server). x 1 2 NULL 4 5 Here is the SQL that performs the task as required: SELECT x, CASE x WHEN NULL THEN 'yes' ELSE 'no' END AS result FROM someTable The result he expected was: x result 1 no 2 no NULL yes 4 no 5 no But that isn't what he got. His result was like this: x result 1 no 2 no NULL no 4 no 5 no Curiously, if you run this: SELECT x, CASE x WHEN 1 THEN ' … Read More

via All Wrong

Advertisements
Categories: Uncategorized

Switching my projects to Mercurial

April 12, 2010 Leave a comment

For the longest time I have been an advocate for Subversion. I still think this is a great source control system. But, since I have been using my home Linux machine (running ssh on a non-22-port for obvious reasons) setting up Subversion for use over ssh tunneling proved to be such a painstaking task that I had to abandon it.
I have been playing with Mercurial ever since its first public release, but I have never done any serious development using Mercurial. Thankfully, Mercurial has an ability to run clone command using ssh protocol. Having ssh running on a non-22 port is not a problem.
All you have to do is:
hg clone ssh://yourhost:12345/project_repo — where project_repo is an hg repository in your home directory.
So, with all that said I am officially switching to Mercurial for all of my development works.

Categories: Uncategorized

More on Maven JUnit 4 testing

October 10, 2009 1 comment

In order for Surefire Maven plugin to recognize JUnit test classes their names must end in …Test

for example:

MyTests.java – will be ignored (even though it is annotated with @Test)

Categories: Uncategorized Tags: , , ,

JUnit 4.4

October 8, 2009 Leave a comment

This is very odd. JUnit 4.4 would find test suite class unless its name ends in …Test?

Categories: Uncategorized

M2Eclipse POM

October 8, 2009 Leave a comment

While using M2Eclipse I often have to add plugins to control Java source compatibility as well as code encoding used. Here I am going to post a plain-vanilla POM with the default configuration that I find useful.


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.khvatov</groupId>
    <artifactId>sample-maven</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>sample-maven</name>
    <url>http://maven.apache.org</url>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.0.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.2</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

Categories: Uncategorized Tags: , ,

Perpetual learning

October 4, 2009 Leave a comment

The more I read books the more I realize that I know very little. Trying to read as many books as one can at once is not a good idea. If I don’t pick up a book in month, I have to start reading it from the beginning (this is related to technical books).

Categories: Uncategorized

Hello, blog!

October 3, 2009 Leave a comment

This blog will serve me as a journal to keep my track of my experiences with Java language (and possibly other languages) as well as notable events in my life.

I will be posting code snippets, personal photos and everything else I find worth sharing the general audience.

Categories: Uncategorized