-->
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: If query works - why not save? (where clause)
PostPosted: Tue Jun 27, 2006 10:46 am 
Newbie

Joined: Mon Apr 10, 2006 10:33 am
Posts: 7
Location: LA
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3

This is a pretty basic question I would think...(not sure why it won't work)

Say I've got a simple mapping document that starts off like this:
Code:
<hibernate-mapping>
   <class name="myClass" table="myFirstTable">
      
      <id name="firstID" type="string" column="ID">
         <meta attribute="scope-set">protected</meta>
         <generator class="native"/>
      </id>

...etc. etc. might have some simple properties.
Then the mapping (same document) also has a property that's a list of Strings that come from a related table, like this:
Code:
      <list name="relatedStrings"
          table="mySecondTable"
          where="typeCode = 'someType'">
         <key column="foreignKeyID"/>
         <element column="myContent" type="String"/>
      </list>


I can generate a "myClass" class from this and I can read instances of it from the tables no problem.

-BUT-

When I add a couple of strings to the "relatedStrings" list and go to try and save the new object - NOTHING. No errors but no new table data either.

Am I wrong to assume that if my mapping document succeeds in pulling data from the table it ought to also be able to write new data back?

(even if the new data is some extra elements of a list generated from a related table?)

Or do the components of the list (unlike String) NEED to be separately mapped classes themselves (with their own mapping documents)?

It seems odd that it works in one direction but not the other.

Any ideas would be most helpful!

E


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 8:04 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I presume that there's a cut and paste error there? How can you have a <list> without an <index> or <list-index>?

To get the save to work, add an appropriate cascade (all-delete-orphan looks appropriate here).

_________________
Code tags are your friend. Know them and use them.


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.