-->
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: How to create primary key value using function
PostPosted: Mon Apr 17, 2006 12:19 pm 
Newbie

Joined: Tue Mar 28, 2006 11:46 am
Posts: 10
Hey,

I am using hibernate 3.1.3 version.

I have a USER table in oracle database with two fields OJBECTID and NAME. I have created a function "createObjId(arg1, arg2)" in oracle to generate a primary key value (for OBJECTID field).

My question is in mapping file how I can call this function so that an id can be generated using this function when inserting record. And how I will pass the args to the method while inserting a record.

I can do this using direct JDBC by:
insert into USER (OBJECTID, NAME) values (createObjId('key1', 'key2'), 'user2');

I am looking to perform the same using hibernate.

Thanks.

Sanjeev Singal


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 1:32 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
create a class that will implement org.hibernate.id.IdentifierGenerator and use it as identity generator.

You may want to look at SequenceHiLoGenerator and other H classes for references an inspiration

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.