Using H2 as embedded DB. When JVM exits (Hibernate Session is closed)
identity reset. When I start my application all the new inserts are
actually updating the old data. I am using MVCC=TRUE to make sure data
is not lost after each JVM exit. I also want to make sure that
identity (sequence) continues from where it was left off rather than
restart from 1 again.

Hibernate Config xml:
<hibernate-configuration>

    <session-factory>
        <!-- Database connection settings -->
        <property name="connection.driver_class">org.h2.Driver</
property>
        <property name="connection.url">jdbc:h2:file:/c:/
dm;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;TRACE_LEVEL_SYSTEM_OUT=4</
property>
        <property name="connection.username">sa</property>
        <property name="connection.password"></property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">10</property>
        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.H2Dialect</
property>
        <!-- Enable Hibernate's automatic session context management --
>
        <property name="current_session_context_class">thread</
property>
        <!-- Disable the second-level cache  -->
        <property
name="cache.provider_class">org.hibernate.cache.NoCacheProvider</
property>
        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>
        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">create</property>

        <mapping resource="resources/hibernate/dm_alerts.hbm.xml"/>

    </session-factory>

</hibernate-configuration>


alert db xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>

<hibernate-mapping package="com.bfm.app.dmserver.hibernate">
        <class name="Alert" table="dm_alerts">
        <id name="alertId"  type="long" column="alert_id">
            <generator class="identity"/>
        </id>
        <property name="groupId" type="long" column="group_id"/>
        <property name="alertStatus" type="string" column="status" />
        <property name="alertLevel" type="string"
column="alert_level" />
        <property name="alertCreator" type="string"
column="alert_creator" />
        <property name="owner" type="string" column="owner" />
        <property name="description" type="string"
column="description" length="1000"/>
        <property name="updateTime" type="java.sql.Timestamp"
column="update_time" insert="true" update="true"/>
        <property name="createTime" type="java.sql.Timestamp"
column="create_time" insert="true" update="false"/>
        <property name="client" type="string" column="client" />
        <property name="dataCenter" type="string"
column="data_center" />
        <property name="host" type="string" column="host" />
        <property name="elevation" type="string" column="elevation" />
        <property name="server" type="string" column="server" />
        <property name="networkSegment" type="string"
column="network_segment" />
        <property name="enterpriseService" type="string"
column="enterprise_service" />
        <property name="application" type="string"
column="application" />
        </class>
</hibernate-mapping>



-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to