Hi!, Below is the code through which I achieved the auto generated columns, But I have one serious issue with it and that is, It is generating the sequence incremented by 1 on every consecutive entry like 1,2,3. But If i restart the application server then the next sequence become like something 32768,32769 and if again restart then seq become 65536, 65537. What I want the seq has to start from 1 and increment by 1 whether I restart the server or not.Please provide me some solution on that.
One more thing, I changed the data type of mediaId from BigDecimal to Integer to incorporate @TableGenerator is this possible GeneratedValue can work with BigDecimal, if Yes please provide a solution.
private Integer mediaId;
@Id @TableGenerator(name = "MEDIA_TABLE_GENERATOR", table = "MEDIA", initialValue = 0, allocationSize = 1, pkColumnValue = "MEDIA_ID") @GeneratedValue(strategy = GenerationType.TABLE) @Column(name = "MEDIA_ID", unique = true, nullable = false, precision = 22, scale = 0) public Integer getMediaId() { return this.mediaId; }
|