-->
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.  [ 11 posts ] 
Author Message
 Post subject: replacement of increment <generator> ?
PostPosted: Thu Apr 12, 2007 2:12 am 
Newbie

Joined: Thu Apr 12, 2007 1:38 am
Posts: 10
Location: Bangalore
Hi !

As increment <generator> is not working in multi user environment and I want the same functionality given by increment, So I am looking for an alternate solution to increment <generator>.

So if any one can help in this regard.

I have also heard about hilo <generator>. So if any one can make some light on hilo, it would be great to me.

Thanks in Advance.

Maulik

_________________
mk_king


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 9:44 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
http://www.hibernate.org/hib_docs/v3/re ... -generator


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Thu Apr 12, 2007 9:58 am 
Newbie

Joined: Thu Apr 12, 2007 1:38 am
Posts: 10
Location: Bangalore
Thanks Ananasi !

I allready have gone through this tutorial.
But I m telling my problem some in more description.

Actually we are using <generator> increment , but when multiple users are accessing this page, it fails.

and suppose if we native or any other <generator> it is generating random number as id, so we are getting the exception - ArrayIndexOutOfBoundException.

So I want a solution for the same.

Plz if U can do some help for the regard !


Thanks once again !

_________________
mk_king


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 9:59 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
What database are you using?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 10:01 am 
Newbie

Joined: Thu Apr 12, 2007 1:38 am
Posts: 10
Location: Bangalore
Oracle10g

_________________
mk_king


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 10:06 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Then I would suggest creating sequences for each table and using the sequence generator. That's what I do for my Oracle mappings, and it works very well in a multi-user environment.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 10:10 am 
Newbie

Joined: Thu Apr 12, 2007 1:38 am
Posts: 10
Location: Bangalore
ok. I am trying for that.

_________________
mk_king


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 10:17 am 
Newbie

Joined: Thu Apr 12, 2007 1:38 am
Posts: 10
Location: Bangalore
Nop ! It's not workng !

The same error - ArrayIndexOutOfBoundException.

My problem is that - Actually it should take id 137 as last id is 136, but it's taking id as 2000238. So it's going out of the range of Array and it's giving error. if I change id value to 137 in the database then it's working fine...

So here comes the problem.

_________________
mk_king


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 10:27 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
I have no idea what that last post means. What Array is the id going into? What SQL did you use to set up your sequence? Where is 2000238 coming from? You will need to show mapping files, POJO, access code, etc for anyone to attempt to solve this problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 1:24 pm 
Beginner
Beginner

Joined: Thu Apr 12, 2007 10:43 am
Posts: 21
Location: Brazil
Hi mk,

Like Ananasi said, please show your mapping files, POJO's and DAO's. In the meantime, try to change the id property mapping on your table to something like this:

<id name="idPropertyName" column="ID_COLUMN_NAME">
<generator class="native">
<param name="sequence">ORACLE_SEQUENCE_NAME</param>
</generator>
</id>

I suggest you define idPropertyName in the Java class as Long. Cheers,

Roger


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 24, 2007 9:00 am 
Newbie

Joined: Thu Apr 12, 2007 1:38 am
Posts: 10
Location: Bangalore
Sorry Friends !
Actually I was away from my computer for a few days !
Any ways my problem is solved !
I need to use hilo <generator> only.
I'll put all the programming code in my next posting even with problem !
I will also show how hilo is processing and it can be replaced for any <generator>.

Thanking U all.

Regards,
Maulik

_________________
mk_king


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 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.