-->
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: Problem saving Array
PostPosted: Sun Jan 11, 2004 1:50 am 
Newbie

Joined: Tue Oct 14, 2003 8:21 pm
Posts: 4
I'm having a problem saving an object that uses an Array. I know arrays are bad, but I need a strongly typed collection. Here's what things look like.

The parent object (Plan)
Code:
   /**
    * @hibernate.array role="getGoals" cascade="save-update"
    * @hibernate.collection-index column="GOAL_ID"
    * @hibernate.collection-key column="PLAN_ID"
    * @hibernate.collection-one-to-many class="com.ebiz.bom.soap.Goal"
    *
    */
   public Goal[] getGoals()
   {
      return goals;
   }


The child object (Goal)
Code:
   /**
    * @hibernate.many-to-one column="PLAN_ID" class="com.ebiz.bom.soap.Plan" cascade="none"
    *
    * @return Plan
    *
    */
   public Plan getPlan()
   {
      return plan;
   }


Everything seems to work fine until I try and save the Plan object. At that point I get several queries that are fine then something like this:

[STDOUT] Hibernate: update GOALS set PLAN_ID=null, GOAL_ID=null where PLAN_ID=?

Then obviously I get a few exceptions. None of the Goal[] array object are null, and I'm completely lost at this point.

I'm running the latest Hibernate on JBoss 3.2.3 & MySQL ver 4.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 11, 2004 5:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You should not use GoalID as collection index. The index column must start from 0 for every array, I suspect this is not the case in your db.


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.