Menu

Tutorial 1 - Hello World

Cemal Koplay

Class Mapping File

QHibernate supports class mapping xml files just like Hibernate framework.You can see the mapping file content below and qt types(qint32, QString, QDateTime etc.) are used in it.

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping>

  <class name="SampleClass" table="sampletable">

    <id name="id" type="qint32">
      <column name="sample_id" />
      <generator class="native" />
    </id>

    <property name="textField1" type="QString">
      <column name="text_field_1" length="20"/>
    </property>

    <property name="textField2" type="QString">
      <column name="text_field_2" length="20"/>
    </property>

    <property name="dateTimeField" type="QDateTime">
      <column name="date_time_field"/>
    </property>

    <property name="dateField" type="QDate">
      <column name="date_field"/>
    </property>

    <property name="timeField" type="QTime">
      <column name="time_field"/>
    </property>

    <property name="integerField" type="qint32">
      <column name="integer_field"/>
    </property>

    <property name="realField" type="double">
      <column name="real_field"/>
    </property>

</class>

Related

Wiki: Home