Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ID GENERATOR FOR DATABASES???

 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Xperts,

I am using MySQL. MY student.hbm.xml consist the part of code is looking like

<id name="id" column="student_id" type="integer">
<generator class="native"/>
</id>

OK. I want to use Oracle, MySQL, SyBase and Postregs databases. I know only the hibernate.hbm.xml configurations needed. Is it all the databases supports all the id generators. How can i create the same database for all the databases(Oracle, SyBase and Postregs databases). for eg. if i am using integer type in sybase, oracle consist number type. so each db consist different. How can rectify this. Kindly replsy this mail. thank you for all.

Edward
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there is a good cross-database solution here. I've used sequence numbers with Oracle and UDB and the syntax is different. You could make a cross-platform solution with a table of keys.

This pretty inefficient if you read and update for every insert. Lots of people use a compound key. Get the number from the database, then run a separate counter from 000 to 999 (for example). When the memory counter runs out, get another database key. So if the database gives you 1 you might use keys 1000 through 1999 before going back to the database to get 2. This cuts way down on database trips and also works well in a cluster.
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hI experts,

I am developing Application using Struts with Hibernate. In my development some tables to be connected with my application.

Experts just u tell that the Definitions of the Hibernate is Common for all the Databases which are currently Used by all the developers.

If yes then please tell me the sequence of the Coding for the mapping in Hibernate which satisfy all Databases (i.e. Oracle, Sybase, MySQL, MS SqlServer,PostgreSQL).

If no then is there is any alternative way to accomplish the task. We cannot depend on one database, because the client requirements are vary time to time and based on their Standards.

Thanks
Edward
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic