I am getting an error. Hibernate is generating the SQL statement. It
works on HSQL and on Oracle. But it doesn't work with H2. I am
having issues with HSQL for testing and would like to switch to H2.
But this issue is preventing the change. Any help is appreciated.
Included is the first part of the stacktrace and the Hibernate mapping
file. I assume this is caused by using the "discriminator" in the
hibernate map. Please let me know if more information is required.
org.springframework.jdbc.UncategorizedSQLException: Hibernate
operation: could not insert: [gov.va.med.mhv.sm.model.Patient];
uncategorized SQLException for SQL [insert into SMS_USER (OPLOCK,
ACTIVE, CREATED_DATE, MODIFIED_DATE, LAST_NAME, FIRST_NAME,
EMAIL_ADDRESS, EMAIL_NOTIFICATION, DEFAULT_MESSAGE_FILTER,
LAST_EMAIL_NOTIFICATION, STATUS, SSN, NSSN, DOB, ICN, USER_TYPE,
USER_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?)];
SQL state [90012]; error code [90012]; Parameter #16 is not set
[90012-66]; nested exception is org.h2.jdbc.JdbcSQLException:
Parameter #16 is not set [90012-66]
Caused by: org.h2.jdbc.JdbcSQLException: Parameter #16 is not set
[90012-66]
at org.h2.message.Message.getSQLException(Message.java:89)
at org.h2.message.Message.getSQLException(Message.java:93)
at org.h2.message.Message.getSQLException(Message.java:71)
at org.h2.expression.Parameter.checkSet(Parameter.java:65)
<?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>
<typedef name="UserType" class="model.type.GenericEnumUserType">
<param name="enumClass">enumeration.UserTypeEnum</param>
</typedef>
<typedef name="UserStatusType"
class="model.type.GenericEnumUserType">
<param name="enumClass">enumeration.UserStatusEnum</param>
</typedef>
<typedef name="EmailNotificationType"
class="model.type.GenericEnumUserType">
<param name="enumClass">enumeration.EmailNotificationEnum</
param>
</typedef>
<typedef name="MessageFilterType"
class="model.type.GenericEnumUserType">
<param name="enumClass">enumeration.MessageFilterEnum</param>
</typedef>
<class name="model.User"
table="SMS_USER"
optimistic-lock="version"
select-before-update="true"
dynamic-update="true"
discriminator-value="-1">
<!-- begin inherited fields -->
<id name="id" column="USER_ID" type="long">
<generator class="native">
<param name="sequence">GEN_SMS_SEQ</param>
</generator>
</id>
<!-- DISCRIMINATOR this is position dependent; must be after <id/> --
>
<discriminator column="USER_TYPE" type="long"/>
<!-- END DISCRIMINATOR -->
<version column="OPLOCK" name="oplock" type="long"/>
<property name="active" type="boolean">
<column name="ACTIVE" precision="1" scale="0" not-
null="true" />
</property>
<property name="createdDate" type="timestamp" insert="true"
update="false">
<column name="CREATED_DATE"/>
</property>
<property name="modifiedDate" type="timestamp">
<column name="MODIFIED_DATE"/>
</property>
<!-- inherited fields -->
<property name="lastName" type="string">
<column name="LAST_NAME" length="50"/>
</property>
<property name="firstName" type="string">
<column name="FIRST_NAME" length="50"/>
</property>
<property name="email" type="string">
<column name="EMAIL_ADDRESS" length="100"/>
</property>
<property name="emailNotification"
type="EmailNotificationType">
<column name="EMAIL_NOTIFICATION"/>
</property>
<property name="messageFilter" type="MessageFilterType">
<column name="DEFAULT_MESSAGE_FILTER"/>
</property>
<property name="lastNotification" type="timestamp">
<column name="LAST_EMAIL_NOTIFICATION"/>
</property>
<property name="status" type="UserStatusType">
<column name="STATUS"/>
</property>
<property name="ssn" type="string">
<column name="SSN"/>
</property>
<property name="nssn" type="string">
<column name="NSSN" length="5"/>
</property>
</class>
<subclass name="model.Patient"
extends="model.User"
discriminator-value="0">
<property name="dob" type="date">
<column name="DOB" not-null="false"/>
</property>
<property name="icn" type="string">
<column name="ICN" not-null="false"/>
</property>
<bag name="facilities" cascade="all">
<key column="USER_ID" not-null="true" />
<one-to-many class="model.PatientFacility" />
</bag>
</subclass>
<subclass name="model.Clinician"
extends="model.User"
discriminator-value="1">
<property name="stationNo" type="string">
<column name="STATION_NO" not-null="false"/>
</property>
<property name="duz" type="string">
<column name="DUZ" not-null="false"/>
</property>
</subclass>
<subclass name="model.Administrator"
extends="model.User"
discriminator-value="2">
</subclass>
</hibernate-mapping>