From: Marco P. <mar...@cm...> - 2002-04-18 07:33:02
|
Nope, does not support the standard.. instead it uses something like the following -- Referential integrity create table main(id int identity,name varchar) create table ref(id int identity,idMain int, foreign key(idMain)references main(id)) So alter tables are not allowed, i did take a look at the Contraints class but i see no way this would fit in... Any suggestions on that ? Could always try to check the people from Hsql when they will be supporting alter table... Greetings -----Original Message----- From: Gavin_King/Cirrus%CI...@ci... [mailto:Gavin_King/Cirrus%CI...@ci...] Sent: woensdag 17 april 2002 8:41 To: Marco Pas Subject: RE: [Hibernate-devel] Is there a way to setup referential integrty? > 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 ? yeah, it looks like HSQLDialect is written to not support foreign key constraints. (I didn't write it myself.) Does HSQL use the standard kind of SQL to create foreign key constraints? ie. alter table add constraint.... If so, you probably just need to change HSQLDialect.hasAlterTable() and possibly HSQLDialect.dropCOnstraints() to return true. Would you have a play with that for me if you get a chance? TIA. > 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! Both the object and relational models support null references, so hibernate does too! If you want to disallow a null reference, use the following mapping: <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" not-null="true" class="com.mticket.Client"/> </class> |