-->
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: [composite-id] Objects cannot be saved , no errors output.
PostPosted: Sun Oct 05, 2003 6:28 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:46 am
Posts: 34
Location: Taiwan
Suppose this scenario :

class Site has one Sting key : Sitename
class User has two keys (composite key) : Sitename + Username
I wrote User.hbm.xml as follows :
Code:
<class name="foo.User" table="User">
  <composite-id>
    <key-property name="SiteEnglishName" type="java.lang.String"/>
    <key-property name="Username"        type="java.lang.String"/>
  </composite-id>
</class>

I also implemented equals() and hashCode() in class User.

By this defination , I can query User correctly.

But , when I want to add new User , it just doesn't work.
I am sure I set the two keys correctly.
When I turn set 'show_sql' to true , I found hibernate just 'SELECT' and did nothing.
There is no 'INSERT' statement found.

What's the problem ?

P.S. Hibernate 2.1 beta2


Top
 Profile  
 
 Post subject: Re: [composite-id] Objects cannot be saved , no errors outpu
PostPosted: Sun Oct 05, 2003 6:30 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:46 am
Posts: 34
Location: Taiwan
smallufo wrote:
<key-property name="SiteEnglishName" type="java.lang.String"/>

sorry , typo .
It is <key-property name="Sitename" type="java.lang.String"/>


Top
 Profile  
 
 Post subject: Re: [composite-id] Objects cannot be saved , no errors outpu
PostPosted: Mon Oct 06, 2003 2:07 am 
Regular
Regular

Joined: Mon Oct 06, 2003 1:59 am
Posts: 52
smallufo wrote:
Suppose this scenario :


But , when I want to add new User , it just doesn't work.
I am sure I set the two keys correctly.
When I turn set 'show_sql' to true , I found hibernate just 'SELECT' and did nothing.
There is no 'INSERT' statement found.

What's the problem ?

P.S. Hibernate 2.1 beta2


Have you done Session.flush() or a Transaction.commit() after Session.save() ?

_________________
"Wisest of the Maia was Ol


Top
 Profile  
 
 Post subject: Re: [composite-id] Objects cannot be saved , no errors outpu
PostPosted: Mon Oct 06, 2003 2:27 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:46 am
Posts: 34
Location: Taiwan
tradem wrote:
Have you done Session.flush() or a Transaction.commit() after Session.save() ?


Oops.....I must be becoming more forgetful...
I forgot adding flush()...Sorry...


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.