josefmezera / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

1.4.x - AUTO_SERVER problem #592

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start h2 console, create table 'test'. Insert data to created table.

2. Conigure datasource with JPA in spring
<bean id='dataSource' 
class='org.springframework.jdbc.datasource.DriverManagerDataSource'>
        <property name='driverClassName' value='${jdbc.driverClassName}'/>
        <property name='url' value='${jdbc.url}'/>
        <property name='username' value='${jdbc.username}'/>
        <property name='password' value='${jdbc.password}'/>
    </bean>

<bean id="myEmf" 
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="pl.fabinux.model" />
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
        </property>
        <property name="jpaProperties">
            <props>
                <prop key="showSql">${hibernate.showSql}</prop>
                <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            </props>
        </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="myEmf" />
    </bean>

or

<bean id='sessionFactory' 
class='org.springframework.orm.hibernate4.LocalSessionFactoryBean'>
        <property name='dataSource' ref='dataSource'/>
        <property name="packagesToScan" value="pl.fabinux.model"/>
        <property name="hibernateProperties">
            <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
                <property name="properties">
                    <props>
                        <prop key="showSql">${hibernate.showSql}</prop>
                        <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
                        <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                    </props>
                </property>
            </bean>
        </property>
    </bean>

     konfiguracja transakcji hibernate 
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

Properties file:
jdbc.url=jdbc:h2:/home/user/test;AUTO_SERVER=true
jdbc.username=test
jdbc.password=test

3. Start application.
3. Execute code:
List<Entity> list = entityManager.createQuery( "from " + clazz.getName() 
).getResultList();
Object list is empty now.

What is the expected output? What do you see instead?
Data from table and in version 1.4.182 output is empty.

Additional informations:
If I change db version to 1.3.176 all work perfectly.
If I connect at first to database (1.4.182) from sql client with 
AUTO_SERVER=true (squirrel SQL in my case) and then I start application all 
work good too.

Original issue reported on code.google.com by fabian.z...@gmail.com on 1 Dec 2014 at 10:50

GoogleCodeExporter commented 9 years ago
That's because 1.4.182 and 1.3.176 use different internal storage engines.

So 1.4.182 is writing the data to a file that looks like "test.mv.db" and 
1.3.176 is writing the data to a file that looks like "test.h2.db"

to make them both use the same engine, you need to add the option 
"MV_STORE-false" to your database URL.

Original comment by noelgrandin on 6 Jan 2015 at 7:56