-->
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.  [ 4 posts ] 
Author Message
 Post subject: Simple map question
PostPosted: Tue Jan 24, 2006 7:17 pm 
Newbie

Joined: Tue Jan 24, 2006 7:02 pm
Posts: 4
I've been banging my head on this problem all day long, as has a co-worker.

I have a class, A, which contains a Map. The Map has class B as a key, and value of an Integer (counting how many of class B are required to pass some business rule).

Of course, I'd like to persist this map. The end result of our mappings is that the tables created for class A have no reference at all to the map.

We're using XDoclet, but even by hand, we get the same result. The relevant section of the hbm is:

<map
name="requiredBs"
table="RequiredBs"
lazy="false"
sort="unsorted"
cascade="save-update"
>

<key
column="aId"
>
</key>

<index-many-to-many
class="com.domain.B"
column="B"
/>

<element
column="numBs"
type="integer"
not-null="false"
unique="false"
/>

</map>


In looking at other classes that we've addressed, in NO cases where we are using a map has there been any indication of the association between the containing class and the table for the map itself. I even went so far as to look at "Hibernate In Action" (page 214), and add in a Set attribute exactly as their example shows, and to manually edit the hbm. The result was the same.

We've looked, and looked ...... googled, searched the forums, consulted books. I'm pulling my hair out!

Any suggestions, thoughts?

j


Top
 Profile  
 
 Post subject: Well .... long day
PostPosted: Tue Jan 24, 2006 7:29 pm 
Newbie

Joined: Tue Jan 24, 2006 7:02 pm
Posts: 4
Okay, okay ... it's been a long day. The reference from one table to the other is through the id's involved. So ... I'm still left my exception about the transient object.

Could that be a configuration issue?

j


Top
 Profile  
 
 Post subject: Cascade not creating objects
PostPosted: Wed Jan 25, 2006 12:22 am 
Newbie

Joined: Tue Jan 24, 2006 7:02 pm
Posts: 4
At this point, it appears that the transient object error is caused by Hibernate not creating sub-objects even when cascade="all" is specified. If I modifiy my DAO to loop over the subobjects first, and persist them, then everything is okay.

Definitely not the way things are supposed to happen.

Any hints/tips/suggestions?

j


Top
 Profile  
 
 Post subject: Cascade not creating objects
PostPosted: Wed Jan 25, 2006 12:28 am 
Newbie

Joined: Tue Jan 24, 2006 7:02 pm
Posts: 4
At this point, it appears that the transient object error is caused by Hibernate not creating sub-objects even when cascade="all" is specified. If I modifiy my DAO to loop over the subobjects first, and persist them, then everything is okay.

Definitely not the way things are supposed to happen.

Any hints/tips/suggestions?

j


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