-->
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: String PK, not auto-generated - save fails
PostPosted: Thu Jul 28, 2005 3:07 pm 
Beginner
Beginner

Joined: Wed Aug 11, 2004 3:50 pm
Posts: 26
First, I have tried to search... nothing. Second, I know that java.lang.String PKs, managed by the application are stupid. But this is legacy code that I have to deal with. So, please don't flame me.

I have no problem reading data from this table, or updating any other table with a more "normal" java.lang.Long PK. But I am trying to create a new row and it's giving me a headache. Here are some questions:

1) Since I am not auto-generating keys as normal, is <generator class="assigned" /> the right clause in the HBM file?

2) In the method call, should I be doing session.save(obj) or session.saveOrUpdate(obj)?

3) It is supposed to be in a transaction, right?

Thx.

P.S.: I did not list the exact error message because I get different ones depending on what I try... so I thought I'd get the basics straight first.


Top
 Profile  
 
 Post subject: Re: String PK, not auto-generated - save fails
PostPosted: Thu Jul 28, 2005 3:18 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
bmelloni wrote:
1) Since I am not auto-generating keys as normal, is <generator class="assigned" /> the right clause in the HBM file?

Yes.

bmelloni wrote:
2) In the method call, should I be doing session.save(obj) or session.saveOrUpdate(obj)?

This might help you. Probably there is even more information in the FAQ or at least in the documentation.
http://www.hibernate.org/116.html#A19

bmelloni wrote:
3) It is supposed to be in a transaction, right?

Well, transactions are nice. If you don't use them, you won't be able to profit from their advantages. :)

Best regards
Sven


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.