Matt RaibleMatt Raible is a Web Architecture Consultant specializing in open source frameworks.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

My What's New in Spring 3.1 Presentation

My first business trip of the year was to Dublin, CA this past week. Trish joined me because she wanted to take some pictures of San Francisco. She got some awesome shots as you can see below.

Lombard Ave in SF with Bay view Kissing Sea lions Pier 38 San Fran San Francisco Bay Bridge at Night Bay Bridge San Francisco at Night

Balclutha Maritime Museum San Fran

On Tuesday night, I attended Twitter's Open Source Summit with a co-worker and had a great time.

On Wednesday, I talked about What's New in Spring 3.1 at the Silicon Valley Spring User Group. I discussed the support for Java 7, Servlet 3, Hibernate 4 (and JPA 2 with Spring Data) and the new Cache Abstraction. I mentioned how spring-data-jpa-examples is a great sample project and showed a bunch of code from my Spring Kickstart project. I was surprised to find that no one in the audience (all Spring users) was using Java Config. Below are the slides from my presentation and you can also download the PDF.

Posted in Java at Feb 04 2012, 05:47:14 PM MST 2 Comments
Comments:

Quick question about java config rather than xml. I'm using mysql and having the improvednamingstrategy for my hibernate properties is important but I can't get it set when configuring using Java. Are you able to?

This is what I have:

public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(){
        final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
        factoryBean.setDataSource( this.restDataSource() );
        factoryBean.setPackagesToScan( new String[ ] { "com.breakpointcreative" } );

        final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(){
            {
                this.setDatabase( Database.MYSQL );
                this.setDatabasePlatform( PersistenceConfig.this.hibernateDialect );
                this.setShowSql( PersistenceConfig.this.hibernateShowSql );
                this.setGenerateDdl( false );
            }
        };
        factoryBean.setJpaVendorAdapter( vendorAdapter );

        factoryBean.setJpaProperties( this.additionlProperties() );

        return factoryBean;
    }

....

    final Properties additionlProperties(){
        return new Properties(){
            {
                this.setProperty("hibernate.ejb.naming_strategy", ImprovedNamingStrategy.class.getName());
                this.setProperty("hibernate.dialect", MySQL5InnoDBDialect.class.getName());
            }
        };
    }

I had to resort to lower casing my table and column names in the database since ImprovedNamingStrategy did not seem to get set.

Posted by Chris on February 06, 2012 at 12:56 PM MST #

Chris - there's a "namingStrategy" property you should be able to use.

Posted by Matt Raible on February 06, 2012 at 01:00 PM MST #

Post a Comment:
  • HTML Syntax: Allowed