-->
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: Several applications with shared database
PostPosted: Wed Sep 17, 2008 3:37 am 
Newbie

Joined: Tue Mar 11, 2008 7:52 am
Posts: 5
Hi...!

This is a general question altough I'm using Hibernate Annotations, JPA and PostgreSQL. I've searched through the forums and documentation and found some mentions but no solutions...

I've got an application running a database. There is a sequence named "hibernate-sequence". Nothing special until now.

I do a initial load of some data, using DBUnit. That works well, but there is a problem: the sequence doesn't get incremented so when I do the first insert using an Hibernate DAO, there is a ConstraintViolationException. The sequence gives me an ID that already exists in the table.

That is a real problem itself, but leads me to further preoupations. ¿What if there are several applications using the same database? Let's say for example, one with Hibernate, another with PHP and one more with classic JDBC.

¿Will work the ID generation? For now it seems not. ¿What can be done?

I guess there are some people with the same questions, it would be fine to find a good answer :-)

Lots of thanks...!

satanicoPlan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 23, 2008 12:01 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

Once you have multiple applications accessing the same database you have to make sure that they play after the rules. If you are using the sequence to generate ids for objects in the Hibernate application, the same sequence should be used with the other applications. At the very least you have to ensure that the ids generated by non Hibernate application cannot interfere with the sequence values.

As in any other case where several applications have to work together you have to define some sort of contract to make thigns work.

--Hardy


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.