-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to use Hibernate with MySQL and PostgreSQL in same time
PostPosted: Tue Jul 26, 2011 2:30 am 
Newbie

Joined: Tue Jul 26, 2011 2:17 am
Posts: 2
Hello !

We have a project to develop working with MySQL or PostgreSQL.
For the moment, if I change my database, I've to change the mapping. For exemple "id" in MySQL are auto-increments, and in hibernate I've to set a sequence.

I would like to know if there is a solution to write only one mapping compatible with MySQL and PostgreSQL ?

Thanks for your response !

Teutates.


Top
 Profile  
 
 Post subject: Re: How to use Hibernate with MySQL and PostgreSQL in same time
PostPosted: Tue Jul 26, 2011 12:17 pm 
Newbie

Joined: Mon Jan 31, 2011 3:23 pm
Posts: 5
As for the id-Problem, have you tried javax.persistence.GenerationType.AUTO? This makes hibernate choose the correct stategy for obtaining db-level ids.

_________________
http://www.winfonet.eu


Top
 Profile  
 
 Post subject: Re: How to use Hibernate with MySQL and PostgreSQL in same time
PostPosted: Wed Jul 27, 2011 3:13 am 
Newbie

Joined: Tue Jul 26, 2011 2:17 am
Posts: 2
Hi ! Thank you for your response !

I've tried but for Id it's the same error. In fact, the real problem is with sequence, Hibernate choose "hibernate_sequence".
If I create this sequence it will be the same for all tables of the database.
If I specifiy the sequence, I've to edit the mapping if I want to use Mysql
This is my problem ...

Maybe, I've not well understanding your tips, I've test :
Code:
   @Id
   @GeneratedValue(strategy=GenerationType.AUTO)
   @Column(name = "id_user")
   public Long getId() {
      return id;
   }


Right ?

Byebye


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