-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Mapping Problem with Relationsships
PostPosted: Wed May 25, 2005 6:02 am 
Beginner
Beginner

Joined: Fri May 21, 2004 3:49 pm
Posts: 21
Location: Germany, Mainz
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3

Hey,
I got a quite problematic thing here, I have got 3 mappings, system, customer, systemtype.
To keep my database clean I used some foreign keys. After creating my mapping files I got stuck at my dao test.
Here is the top-part of my System.hbm.xml:
Code:
  <composite-id name="id" class="itecon.bo.model.SystemId">
      <key-property name="Scid" type="java.lang.Long">
        <column name="SCID" scale="22" precision="0" not-null="true" sql-type="NUMBER" />
      </key-property>
      <key-property name="Ssystemtype" type="java.lang.Long">
        <column name="SSYSTEMTYPE" scale="22" precision="0" not-null="true" sql-type="NUMBER" />
      </key-property>
    </composite-id>
    <many-to-one name="Customer" class="itecon.bo.model.Customer" update="false" insert="false">
      <column name="SCID" scale="22" precision="0" not-null="false" />
    </many-to-one>
    <many-to-one name="Systemtype" class="itecon.bo.model.Systemtype" update="false" insert="false">
      <column name="SSYSTEMTYPE" scale="22" precision="0" not-null="false" />
    </many-to-one>
    <property name="Sid" type="java.lang.Long">
      <column name="SID" scale="22" precision="0" not-null="true" unique="true" sql-type="NUMBER" />
    </property>

As explained above, system references the primary keys of systemtype and customer, but my problem is, that Sid should be auto_incremental but <generator> is not allowed.

So my question is: Do I have an architectural problem, or are there any workaroungs to fix this?

I thank in advance for all tips and hints.

Regards Valentin


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 11:39 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
I think before all, first you need is a brain.

You have architectural problems, you mapped "the composite id" as your id, then why you need the Sid?

"Generators are for generating unique id's"
For property's there is no generator logically, generators are for id's!

_________________
-developer


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

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.