views:

36

answers:

1

Here is my hibernate config, but for some reason it fails to load those properties that I have added to <property name="hibernateProperties"> and log says in startup that INFO org.hibernate.cfg.Environment - hibernate.properties not found.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"&gt;

    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="org.hibernate.dialect.PostgreSQLDialect" />
        <property name="url" value="jdbc:postgresql://localhost:5432/testdatabase" />
        <property name="username" value="postgres" />
        <property name="password" value="password" />
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="myDataSource" />
        <property name="packagesToScan" value="org.test"/>
        <property name="hibernateProperties">
            <value>
                hbm2ddl.auto=create
                hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
                hibernate.show_sql=true             
            </value>
        </property>
    </bean>

    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

</beans>

EDIT: Full log:

    2010-08-29 15:27:15,986 [main] INFO  org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.3.1.GA
    2010-08-29 15:27:15,997 [main] INFO  org.hibernate.cfg.Environment - Hibernate 3.2.6
    2010-08-29 15:27:16,000 [main] INFO  org.hibernate.cfg.Environment - hibernate.properties not found
    2010-08-29 15:27:16,002 [main] INFO  org.hibernate.cfg.Environment - Bytecode provider name : cglib
    2010-08-29 15:27:16,005 [main] INFO  org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
    2010-08-29 15:27:16,113 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: org.test.TestEntity
    2010-08-29 15:27:16,145 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity org.test.TestEntity on table TestEntity
    2010-08-29 15:27:16,188 [main] INFO  org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
    2010-08-29 15:27:16,188 [main] INFO  org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean - Building new Hibernate SessionFactory
    2010-08-29 15:27:16,238 [main] INFO  org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
    2010-08-29 15:27:16,663 [main] INFO  org.hibernate.cfg.SettingsFactory - RDBMS: PostgreSQL, version: 9.0beta4
    2010-08-29 15:27:16,664 [main] INFO  org.hibernate.cfg.SettingsFactory - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.3 JDBC3 with SSL (build 603)
    2010-08-29 15:27:16,667 [main] INFO  org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.PostgreSQLDialect
    2010-08-29 15:27:16,672 [main] INFO  org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory
    2010-08-29 15:27:16,674 [main] INFO  org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    2010-08-29 15:27:16,674 [main] INFO  org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
    2010-08-29 15:27:16,674 [main] INFO  org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
    2010-08-29 15:27:16,674 [main] INFO  org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
    2010-08-29 15:27:16,674 [main] INFO  org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
    2010-08-29 15:27:16,675 [main] INFO  org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
    2010-08-29 15:27:16,675 [main] INFO  org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
    2010-08-29 15:27:16,675 [main] INFO  org.hibernate.cfg.SettingsFactory - Connection release mode: auto
    2010-08-29 15:27:16,675 [main] INFO  org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
    2010-08-29 15:27:16,675 [main] INFO  org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
    2010-08-29 15:27:16,676 [main] INFO  org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
    2010-08-29 15:27:16,676 [main] INFO  org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
    2010-08-29 15:27:16,676 [main] INFO  org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    2010-08-29 15:27:16,678 [main] INFO  org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
    2010-08-29 15:27:16,678 [main] INFO  org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
    2010-08-29 15:27:16,678 [main] INFO  org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
    2010-08-29 15:27:16,678 [main] INFO  org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
    2010-08-29 15:27:16,678 [main] INFO  org.hibernate.cfg.SettingsFactory - Query cache: disabled
    2010-08-29 15:27:16,678 [main] INFO  org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.NoCacheProvider
    2010-08-29 15:27:16,678 [main] INFO  org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
    2010-08-29 15:27:16,678 [main] INFO  org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
    2010-08-29 15:27:16,683 [main] INFO  org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
    2010-08-29 15:27:16,683 [main] INFO  org.hibernate.cfg.SettingsFactory - Statistics: disabled
    2010-08-29 15:27:16,683 [main] INFO  org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
    2010-08-29 15:27:16,684 [main] INFO  org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
    2010-08-29 15:27:16,684 [main] INFO  org.hibernate.cfg.SettingsFactory - Named query checking : enabled
    2010-08-29 15:27:16,703 [main] INFO  org.hibernate.impl.SessionFactoryImpl - building session factory
    2010-08-29 15:27:16,888 [main] INFO  org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
2010-08-29 15:27:17,096 [main] INFO  org.springframework.orm.hibernate3.HibernateTransactionManager - Using DataSource [org.apache.commons.dbcp.BasicDataSource@15b55bc] of Hibernate SessionFactory for HibernateTransactionManager
A: 

I think the hibernateProperties are getting set incorrectly (unless Spring has a new way of setting properties that I don't know about). Typically properties are set manually like this:

    <property name="hibernateProperties">
        <props>
            <prop key="hbm2ddl.auto">create</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>

The other way (which I prefer) is just to stick these properties in a hibernate.properties file and then put that file in the root directory of the classpath. That's probably what the error message is referring to.

Kaleb Brasee