test driving of java applications
Donnerstag, 28. Mai 2009
JPA and default values
Today I found out that it is not possible to define default values of fields which are mapped to a column of table in a database. The workaround is to do the work in the default constructor and a manual tweak of the generated database schema. IMHO this is one of the cases which prevents fully automatic schema generation and increases the development time and chance of bugs :-(
Mittwoch, 27. Mai 2009
Expose for Vista
Many software developers are fighting a war against the chaos of many open windows at the same time. A few weeks ago I found the holy hand grenade on a Kubuntu box built by the secret research institution of the developers fraction: a feature called expose. It arranges all open windows next to each other and zooms out so its easy to catch a glimpse of them. Since the Kubuntu box didn't run very stable I searched a solution for Vista. Found many commercial and noncommercial versions and decided to use the one called switcher. It's kewl, very configurable, free and stable. It can be downloaded from the product website http://insentient.net/. I already shared it with my brothers in arms and got quiet a response so I thought it might be worth blogging about it...
Mittwoch, 20. Mai 2009
Germany - a country full of terrorists
*attention - sarcasm*
Today I saw it in the news on youtube: 82 million terrorists are living in Germany. Thank god the german state pays attention and is going to hunt down all the black hats:
Today I saw it in the news on youtube: 82 million terrorists are living in Germany. Thank god the german state pays attention and is going to hunt down all the black hats:
Dienstag, 12. Mai 2009
jQuery Autocomplete Plugin
jQuery doesn't ship with an auto complete UI component. I found a very nice, and very very very very flexible jQuery Plugin doing this job named Autocomplete. It supports static and dynamic data and cause of its event model it's very flexible. For instance it's no problem to have a autocomplete text field for a ZIP code which automatically fills in an additional city field. It also has formatters which can be used to format the proposals - eg. the ZIP field fills in ZIP codes but provides ZIP - CITY as proposal.
sunshine live webradio without the annoying advertisments popup
Quick access to pure dance / trance / techno music without any overhead of pictures, advertisements and clicks is available at this url: Sunshine Live - Livestream
UTF-8 character encoding problems with ISO-8859-1 encoded Java property files
Java property files need to be ISO-8859-1 encoded. But when it comes to i18n of an application you'll have to overcome the limitations of this character set. In short: ISO-8859-1 does not support all required characters. Changing the encoding of property files to utf-8 is not (yet) supported by Java. To overcome this limitation the guys from http://propedit.sourceforge.jp built an editor named PropertiesEditor. It writes the property file with properly escaped UTF8 symbols.
Donnerstag, 7. Mai 2009
Hibernate Transactions and Connection Pooling
After 2 years of Java development using hibernate I noticed that my understanding of hibernate sessions and transactions was completely wrong. I thought:
- I can interact with the database within and without a transaction.
- Performance is better without a transaction.
- Inserting a single entity without a transaction is good thing.
- I don't need to step into the details of connection pooling until performance issues occurs.
- If I call session.close() the session is closed and hibernate takes care of open transactions
- Interaction with a database always requires a transaction in hibernate. There is a feature called auto-commit which opens a transaction before executing a statement and closes it immediately after execution of the statement. This behavior is causing performance issues if a huge amount of queries is executed(Lazy Collections). So if I'm working with hibernate, I have to define the scope of the transaction(s).
- Performance difference between commit and rollback within a transaction which not issued any write access is really hard to measure - there is no real difference.
- Inserting a single entity without a transaction is impossible.
- [ INFO] 21:17:01 org.hibernate.connection.DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!)
- If I call session.close() using built in connection pooling the last transaction is untouched and reused by the next session obtained by sessionFactory.openSession(). Worst case scenario is one day of inserts and updates and the next day a transaction.rollBack() causes a heavy data loss. Using an alternative connection pooling (eg C3p0) is a must do, not a nice to have.
How to install Eclipse Subversive SVN Plugin
1. Adding the required update sites to the Eclipse Update/Add-On Manager
Open Eclipse and navigate to Help->Software Updates...

Switch to the Available Software tab und use the Add Site... Button to the following URL's:
http://download.eclipse.org/technology/subversive/0.7/update-site/
http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/

Note that these URL's may change over the time. Have a look at the Eclipse project site of Subversive to get fresh URL's.
2. Selecting and installing the required components
The following components needs to be checked:
Subversive SVN Connectors
Subversive SVN Team Provider
SVNKit 1.3.0 Implementation

Click Install... and restart Eclipse after installation finished.
Freitag, 17. April 2009
Using Derby in a comfortable way in eclipse
Today I decided to test if Derby is better then hsqldb from the usablility poit of view. After a few hours I found a very comfortable way to integrate derby into my eclipse. I created a small test project with a hibernate setup and tests. Everything worked fine. IMHO Derby is simple to set up and its simple to have a look in the database tables. At least more simple than it is using hsqldb. If anyone is interested in the manuals that helped me to set up the environment, heres a link list:
In order to use this setup, you need to create a derby database. How to do this, is described here:
http://db.apache.org/derby/integrate/SQuirreL_Derby.html
- Integrating derby into eclipse:
http://db.apache.org/derby/integrate/plugin_howto.html
Note: In the projects properties you can modify the path, where Derby stores the database files. -
Starting the database network server:
http://db.apache.org/derby/integrate/plugin_help/start_server.html -
Using Squirrel as front end:
http://db.apache.org/derby/integrate/SQuirreL_Derby.html
public static SessionFactory createDerbyFactory() {
AnnotationConfiguration annotationConfiguration = new AnnotationConfiguration();
annotationConfiguration.setProperty("hibernate.connection.driver_class", "org.apache.derby.jdbc.ClientDriver");
annotationConfiguration.setProperty("hibernate.connection.url", "jdbc:derby://localhost:1527/simpletest");
annotationConfiguration.setProperty("hibernate.connection.username", "user");
annotationConfiguration.setProperty("hibernate.connection.password", "user");
annotationConfiguration.setProperty("hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
annotationConfiguration.setProperty("hibernate.show_sql", "true");
annotationConfiguration.setProperty("hibernate.format_sql", "true");
annotationConfiguration.setProperty("hibernate.hbm2ddl.auto", "create-drop");
annotationConfiguration.addAnnotatedClass(Person.class);
return annotationConfiguration.buildSessionFactory();
}
In order to use this setup, you need to create a derby database. How to do this, is described here:
http://db.apache.org/derby/integrate/SQuirreL_Derby.html
Dienstag, 14. April 2009
Ein Witz in der Java API Doc
May the force be with you :-)
-->
http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html
Here are some examples of usage:
Object[] arguments = {
new Integer(7),
new Date(System.currentTimeMillis()),
"a disturbance in the Force"
};
String result = MessageFormat.format(
"At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.",
arguments);
output: At 12:30 PM on Jul 3, 2053, there was a disturbance
in the Force on planet 7.
Abonnieren
Posts (Atom)