MySQL Delete On Joined Tables

If you want to (for example) delete all users with the guest role from your database : DELETE FROM user WHERE EXISTS ( SELECT * FROM role WHERE role.id = user.role_id AND role.name = 'guest' );

December 2, 2007 · 1 min · Dave Perrett

Get complete AppFuse sources

To get the complete, exploded source of an AppFuse application, run : $ mvn appfuse:full-source

November 28, 2007 · 1 min · Dave Perrett

Appfuse "failed to lazily initialize a collection of role"

If you are getting a failed to lazily initialize a collection of role error in AppFuse , you need to un-comment the lazyLoadingFilter filter and associated filter-mapping in src/main/webapp/WEB-INF/web.xml . <filter> <filter-name>lazyLoadingFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>lazyLoadingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

November 27, 2007 · 1 min · Dave Perrett

Skip AppFuse Tests

To skip tests when compiling/running AppFuse applications, add the -Dmaven.test.skip=true argument to your Maven call : $ mvn jetty:run-war -Dmaven.test.skip=true

November 27, 2007 · 1 min · Dave Perrett

Hibernate OneToMany Relationships

Here’s an example of a one-to-many relationship using Spring MVC and Hibernate with annotations. The Album class has many Photo s, and each Photo belongs to an Album. ...

November 26, 2007 · 3 min · Dave Perrett

Hibernate 'TYPE=storage_engine is deprecated'

If you are getting errors similar to WARN [main] JDBCExceptionReporter.logWarnings(49) | 'TYPE=storage_engine is deprecated; use ENGINE=storage_engine instead' in hibernate, it probably means you are using MySQL5 but have your application set up for MySQL4. In your applications database settings config file ( pom.xml in my case, otherwise might be in properties.xml or something) change the hibernate.dialect setting from MySQLInnoDBDialect to MySQL5InnoDBDialect : <hibernate.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</hibernate.dialect>

November 21, 2007 · 1 min · Dave Perrett

JScript Debugger for IE

First, download and install the debugger from the IE Blog Next, you need to make sure that debugging is enabled in the IE options. Go to Tools->Internet Options->Advanced and make sure these options are de-selected : ...

July 26, 2007 · 1 min · Dave Perrett

OS X zsh shell config

Here’s a zsh shell configuration file for OS X, based almost entirely on a post at Fried CPU . All i changed was the ls and ll aliases because Fried’s didn’t work for me. To use it, save it in a file called .zshrc in your home directory. You might also want to set zsh as your default shell . ...

July 25, 2007 · 4 min · Dave Perrett

Regex to reject an extension

If you want a regular expression to match anything except a certain extension (such as .png) : ^((?!\.png$).)*$

July 25, 2007 · 1 min · Dave Perrett

Set OS X Default Shell

You need to use Niutl to change your shell. In the terminal : $ sudo niutil -createprop . /users/dave shell /bin/zsh Alternatively, you can use the NetInfo Manager utility (in the Utilities folder). Select your user in the navigator, and change the value of the shell property. ...

July 25, 2007 · 1 min · Dave Perrett