-->
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.  [ 1 post ] 
Author Message
 Post subject: Can't update only inserts with assigned id
PostPosted: Fri Nov 10, 2006 1:04 pm 
Newbie

Joined: Fri Nov 10, 2006 12:41 pm
Posts: 3
Hibernate version: 3.2

Code:
// Person.hbm

<hibernate-mapping package="">
<class name="Person"
   table="person"

<set name="PermissionModifiers"
         inverse="true"
         cascade="save-update">

   <key column="person" />
   <one-to-many class="PersonPermission" />
</set>

</hibernate-mapping>

// PersonPermission.hbm
<hibernate-mapping package="">
   <class
      name="PersonPermission"
      table="person_permission"
   >
      <meta attribute="sync-DAO">false</meta>
      
<!-- need to define Interceptor.isUnsaved()
      
      <composite-id>
         <key-many-to-one name="Person" class="Person" column="person" />
         <key-many-to-one name="Permission" class="Permission" column="permission" />
      </composite-id>
-->
      
      <id
         name="Id"
         type="string"
         column="id"
      >
         <generator class="assigned"/>
      </id>
      
      <many-to-one
         name="Person"
         column="person"
         class="Person"
         not-null="true"
      >
      </many-to-one>
      
      <many-to-one
         name="Permission"
         column="permission"
         class="Permission"
         not-null="true"
      >
      </many-to-one>
      
      <property
         name="Permitted"
         column="permitted"
         type="boolean"
         not-null="true"
      />
      
   </class>   
</hibernate-mapping>



postgres database

I create new PersonPermission objects and set the collection on the person and then try to persist using

session.saveOrUpdate(person);
session.flush();

But it only inserts never updates the state of the Permitted attribute for previously inserted rows.

The id is assigned in the Java and the database table is correctly populated.

So I get a row like

4:1, 4, 1, false

then I create a new PersonPermission object that has Permitted=true but is otherwise identical, add it to a collection and set the collection on the person, then persist as above. But the update never happens.

Any clues people?
Thanks.

[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.