-->
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.  [ 7 posts ] 
Author Message
 Post subject: ternary association problem
PostPosted: Tue Jan 27, 2004 7:17 pm 
Beginner
Beginner

Joined: Tue Jan 06, 2004 4:51 pm
Posts: 48
Hi,

I'm getting a when I try to access a ternary:
Code:
net.sf.hibernate.MappingException: component class not found
   net.sf.hibernate.cfg.Binder.bindComponent(Binder.java:764)




Here is my mapping file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
          "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
          "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
  <class name="com.cc.tss.TaskTemplate" table="task_template">

    <id name="id" type="integer" column="id">
        <generator class="sequence">
            <param name="sequence">task_template_id_seq</param>
        </generator>
    </id>

    <property name="name" column="name" type="string"/>
         
    <set    name="tasksAndPayRates"
            table="task_task_template"
            lazy="false"
            order-by="task_id"
            cascade="all">
        <key column="template_id"/>
        <composite-element class="TaskAndPayRate">
            <many-to-one name="task" class="Task" column="task_id"/>
            <many-to-one name="payRate" class="PayRate" column="pay_rate_id"/>
        </composite-element>
    </set>

  </class>
</hibernate-mapping>


Task and PayRate are both defined with their own mapping files (that work). My tables look like:

task_template (id, name)
task_task_template (template_id, task_id, payRate_id)

Any help would be appreciated!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2004 8:56 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
set the full class name on it.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 12:37 pm 
Beginner
Beginner

Joined: Tue Jan 06, 2004 4:51 pm
Posts: 48
Thanks, that worked.

However, despite my cascade="all" attribute it isn't updating the set table "task_task_template". Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 7:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Using composite-elements and components in general means you don't need to map them as entities. But you did it
Quote:
Task and PayRate are both defined with their own mapping files (that work).

Remove them

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 7:09 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
and cascade is useless in this case (composite-elements)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 10:05 pm 
Newbie

Joined: Fri Jan 30, 2004 6:48 pm
Posts: 12
Can ternary associations done this way be represented in xdoclet? I see the @hibernate.collection-composite-element tag but am not sure how to go about defining the many-to-ones nested inside the <composite-element> tag. In the case above, what should the TaskAndPayRate class look like? can I put xdoclet tags in my analogous class even though the class isn't meant to be persisted on it's own?

I tried doing a ternary assoc. via xdoclet using the map index association strategy, but had problems with cascade-delete of the map's keys.

thanks in advance
Justin


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 11:43 pm 
Newbie

Joined: Fri Jan 30, 2004 6:48 pm
Posts: 12
I figured this out after a little more trial and error. I simply gave the composite element class getters and setters for the many-to-one objects and set @hibernate.many-to-one tag for each of them. no other hibernate tags were needed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.