-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How model restricted "many" side
PostPosted: Thu Aug 19, 2004 4:28 pm 
Newbie

Joined: Wed Aug 11, 2004 4:48 pm
Posts: 12
Hello!

I would like to map two tables as 1 to 0 or 1. Or 1 to 0 or (n) in generic case.

Let's pretend that i have next tables.

create table document (
id int pk,
foo varchar
)

create table description(
document_id int,
description_type int,
contents varchar
)

Notice that description has discriminator field. In reality several classes generated such as, Reason, Status, CoordinatedDescription etc.

I would like to link document to description (of particular type) as 1 to 0 or 1, means i do not need store empty descriptions.

Have tryed to use one-to-one association on document side, but it will produce exception, when i try delete document without description.

Code:
<class name="Document">
  <id ...>
  <one-to-one name="reason" class="Reason" constrained="true"     cascade="all">
On the description side i would like to substitute document_id
</class>
Code:


<class name="Description">
  <id name="documentId" column="document_id">
     <generator class="foreign">
       <param name="property">Document</param>
     </generator>
  </id>
  <discriminator column="description_type">
  <one-to-one name="document" class="Document">
  <subclass name="Reason" discriminator-value="1"/> 
  <subclass name="Status" discriminator-value="2"/> 
  <subclass name="CoordinatedDiscription" discriminator-value="3"/> 
  ...
</class>


Can somebody explain how get it to work?
Any thoughts will be highly appreciated!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.