Gavin,

i am using HSQLDB and i now that it supports constraints, i have set the
dialect to HSQLDB but no constraints
appear. I use a many-to-one mapping, are there any properties extra that i
have to set ?

In the understanding example i use a many-to-one mapping for clients /
orders.
A client can have multiple orders but and must refer to one client.. 
So IMHO an order without a client should not be possible....
After generating the DBSchemaExport and running the understanding code.... i
cam to the conclusion that it works perfectly.. That is not what i expected
!

example
  <class name="com.mticket.Client" table="Clients">
    <id name="clientId" type="long">
      <generator class="cirrus.hibernate.id.HiLoGenerator"/>
    </id>
    <property name="name"/>
  </class>

  <class name="com.mticket.Order" table="Orders">
    <id name="orderId" type="long">
      <generator class="cirrus.hibernate.id.HiLoGenerator"/>
    </id>
    <property name="description"/>
    <many-to-one name="client" column="clientId"
class="com.mticket.Client"/>
  </class>

-- code snippet
SessionFactory sessions = ds.buildSessionFactory(props);
Session sess = sessions.openSession();

Order o = (Order) sess.create(com.mticket.Order.class);
o.setDescription( "Order description" );
sess.commit();
--



-----Original Message-----
From: Gavin_King/[EMAIL PROTECTED]
[mailto:Gavin_King/[EMAIL PROTECTED]
Sent: woensdag 17 april 2002 7:15
To: Marco Pas
Cc: [EMAIL PROTECTED]
Subject: Re: [Hibernate-devel] Is there a way to setup referential
integrity?



> Is it possible to use/enforce referential integrity within Hibernate,
using
> DBSchemaExport ?
> the DBSchemaExport creates perfect tables, but there is it possible to
let
> it also generate the referential integrity ?

certainly. foreign key constraints are generated for those databases which
support them. You need to set the system property hibernate.dialect when
running DBSchemaExport :)

_______________________________________________
Hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to