play1 icon indicating copy to clipboard operation
play1 copied to clipboard

Hibernate 5.2.x with PostgreSQL

Open nguyk opened this issue 7 years ago • 4 comments

Hi,

With the old versions of hibernate (4.x) we made a special class to associate the sequence to an id for each table. But now with hibernate 5.2.x we need to put annotation on the id to specify sequence so it breaks our generic way of associating sequence with the id for each table

Anyone went through this and have a solution?

nguyk avatar Jan 24 '18 10:01 nguyk

You can use GenericModel like this.

package models;

import org.hibernate.annotations.GenericGenerator;
import play.db.jpa.GenericModel;

import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public class BaseModel extends GenericModel {
    @Id
    @GenericGenerator(name = "uuid", strategy = "uuid")
    public String id;

}

fivesmallq avatar Feb 06 '18 02:02 fivesmallq

Thank you for your help, but this is what I want to avoid actually, to put an annotation on every single "id"

nguyk avatar Feb 06 '18 08:02 nguyk

You can extends BaseModel.

If you every table id strategy is not the same, it seems there is no good way

fivesmallq avatar Feb 06 '18 08:02 fivesmallq

Okay I see, thank you, I'm going to try and let you know if it's working well

nguyk avatar Feb 06 '18 09:02 nguyk