[PersistenceException: error getting the following sequence]

I get this error when trying to save data in a model in db.

@Entity
public class User extends Model {
   @Required
   public String name; 
   @Email
   public String email; 
   @Required @MaxLength(value=10)
   public String username;
   @Required @MinLength(value=4)
   public String password;
   @Id 
   public int id;
}

This is my class.

This is an error when I try to save the model in db.

enter image description here

I will take care of any efforts to help! many thanks.

EDIT: table structure here enter image description here

+5
source share
3 answers

I think with ebean you should physically name and annotate your id. You may also need to provide this name for the auxiliary sequencer (I don’t remember). This shows how to do it.

+10
source

This worked for me:

@Entity
@Table(name = "table", schema = "schema")
public class Bean extends Model{

   @Id
   @Column(name = "idcolumn")
   @SequenceGenerator(name="gen", sequenceName="schema.table_idcolumn_seq",allocationSize=1) 
   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "gen")
   private int id;
}

SequenceGenerator, , Hibernate: https://hibernate.atlassian.net/browse/HHH-7232

sequenceName SequenceGenerator.

+2

:

@SequenceGenerator(name = "SEQUENCE_NAME", sequenceName = "PST_BUSINESS.S_BUSINESS_DOMAIN")
@Entity
@Table(name = "TB_BUSINESS_DOMAIN", schema = "PST_BUSINESS")
public class PstBusinessDomain extends PstAbstractBaseMappedEntity {

, , .

+1

All Articles