-->
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: ID Generator
PostPosted: Fri Oct 17, 2003 2:05 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 3:34 pm
Posts: 54
Location: Farroupilha - Brasil
Hi all,

I'm using the "native" generator class for the Id's in many classes and it works fine ... however in some situations I want to assign an ID manually but seems that save() doesn't consider the assigned id.

MyClass obj = new MyClass()
obj.setName("name");
session.save(obj) ; #Generate an ID (1)

I try :

obj.setId(1);
obj.setName("name");
session.save(obj) ; #Also generate an ID (2)

It is possible to keep the "native" generator and also be able to inform ID manually ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 17, 2003 3:56 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No.
What is your need, do you want to skip some ids ?
Do you want to use already defined ids ?
Those ids are considered technical stuffs, no need to manage them.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 17, 2003 4:31 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 3:34 pm
Posts: 54
Location: Farroupilha - Brasil
I have a client-server system.
I use the same classes/mappings for two applications ... one application create the user/groups in they database (Server) ... another app (Desktop) get those users/groups throught HTTP (XML) and insert in a local database ...
When I update the Desktop database I need to compare the actual groups with the groups from Server ... if I insert the groups in the local database with a diferent id (generated) I can't compare the information ... by using the ID.

I have an idea ... I will create two mapping files for the same class .. one to the Server that uses the "native generator" and another to the Desktop that uses an "assigned generator" ...

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 17, 2003 5:01 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Why not using 2 slightly different mappings ?
Server = native
Client = assigned

That's the way you use it if I understand it well : Client never create an object that hasn't been created by Server before

_________________
Emmanuel


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.