-->
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: Association between class and join-subclass
PostPosted: Fri Sep 23, 2005 5:03 am 
Newbie

Joined: Mon Aug 15, 2005 11:25 am
Posts: 10
Hibernate version: 3.1

Name and version of the database you are using: MySQL 4.1.12a-nt

Hello,

I have a little problem with an association :

- I have an object Profile and an object Method.
- A Profile contains many methods.
- A profile contains a default method.
- A method have a sub-classe : MethodSubclasse

Here is my mapping file :

Code:
   <!--  ********************************************************************
                        CONFIDENTIALITY_PROFILE TABLE
    ********************************************************************** -->
   <class name="ConfidentialityProfile" table="confidentiality_profile">
      <id name="id" type="long">
         <generator class="identity"/>
      </id>
      <property name="name"/>
      <property name="description"/>
      <property name="startValidity" column="start_validity"/>
      <property name="endValidity" column="end_validity"/>
      
      <set name="confidentialityMethods" cascade="all,delete-orphan">
         <key column="confidentiality_profile_id" />
         <one-to-many class="ConfidentialityMethod"/>
      </set>
      <many-to-one name="systemUser" class="SystemUser" column="system_user_id" not-null="true"/>
<!--    <many-to-one name="defaultConfidentialityMethod" class="ConfidentialityMethod" column="default_confidentiality_method_id" unique="true" not-null="true" /> -->
      <one-to-one name="defaultConfidentialityMethod" class="ConfidentialityMethod" constrained="true" />
   </class>

   <!--  ********************************************************************
                        CONFIDENTIALITY_METHOD TABLE
    ********************************************************************** -->
   <class name="ConfidentialityMethod" table="confidentiality_method">
      <id name="id" type="long">
         <generator class="identity"/>
      </id>

      <property name="name"/>
      <property name="description"/>
      <property name="startValidity" column="start_validity"/>
      <property name="endValidity" column="end_validity"/>
      <property name="status"/>
      <property name="statusComment" column="status_comment"/>
      <property name="statusDate" column="status_date"/>

      <map name="attributes" table="confidentiality_method_attributes">
         <key column="id"/>
         <map-key column="attribute_name" type="string"/>
         <element column="attribute_value" type="serializable" not-null="true"/>
      </map>
      <many-to-one name="confidentialityProfile" class="ConfidentialityProfile" column="confidentiality_profile_id" not-null="true"/>

      <!--  ********************************************************************
                           CONFIDENTIALITY_METHOD_SUBCLASS TABLE
       ********************************************************************** -->
      <joined-subclass name="ConfidentialityMethodSubclass" table="confidentiality_method_subclass">
         <key column="id"/>
      </joined-subclass>
   </class>


If I'm using this in the Profile object :

Code:
   <many-to-one name="defaultConfidentialityMethod" class="ConfidentialityMethod" column="default_confidentiality_method_id" unique="true" not-null="true" />


When I change the default method, it works but when I do getDefaultMethod, it return a Method object and not a DefaultSubclass object...

If I'm using :

Code:
      <one-to-one name="defaultConfidentialityMethod" class="ConfidentialityMethod" constrained="true" />


I receive the good object (MethodSubclass) but when I change the default method, the DB is not updated...

I don't know where is the problem...

Thank you...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 10:26 am 
Newbie

Joined: Mon Aug 15, 2005 11:25 am
Posts: 10
Nobody can help me?


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.