Hibernate generation Id to postgreSQL

Ads
 

Hibernate generation Id to postgreSQL

Hi,

I'm trying to implement a id generator in Hibernate, but I'm having a problem. Hibernate doesn't seems to reset the counting when the id is generated. For example:

1 - In PostgreSQL I have a table (that entries were done with Hibernate script):

carId|car_description

1|john

2|mike

3|Peter

2 - Now, I clean the table, and next time I insert a new value on car_description, when I think that hibernate catch the min value(0 because the db is empty), it inserts the last value created (saved in memory perhaps).

carId|car_description

4|Michael

My class is:

@Entity @Table(name="tb_career") public class Career implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq_career") @SequenceGenerator(initialValue = 1, allocationSize = 1, name = "seqcareer", sequenceName = "seqcareer")

@Column(name="car_id", unique=true, nullable=false)
private Integer carId;
@Column(name="car_description", length=255)
private String carDescription;
//bi-directional many-to-many association to Course
@ManyToMany(mappedBy="tbCareers")
private List<Course> tbCourses;

Kind Regards! Thanks!

View Answers

Ads









Related Tutorials/Questions & Answers:
Hibernate generation Id to postgreSQL
Hibernate generation Id to postgreSQL  Hi, I'm trying to implement a id generator in Hibernate, but I'm having a problem. Hibernate doesn't seems to reset the counting when the id is generated. For example: 1 - In PostgreSQL I
id generation
id generation  CREATE TABLE `mohan2` ( `sno` bigint(20) NOT NULL... to employee id automatically generate please try this code, useful for u thanks ...");%> any body want to employee id automatically generate please try
Advertisements
hibernate postgresql 9.4 dialect
hibernate postgresql 9.4 dialect  Hi, Which is the hibernate postgresql 9.4 dialect? Thanks   Hi, The postgresql 9.4 dialect...; Hi, This is available in Hibernate ORM 5.2. Thanks
hibernate postgresql 9.4 dialect
hibernate postgresql 9.4 dialect  Hi, Which is the hibernate postgresql 9.4 dialect? Thanks   Hi, The postgresql 9.4 dialect...; Hi, This is available in Hibernate ORM 5.2. Thanks
hibernate postgresql 9.4 dialect
hibernate postgresql 9.4 dialect  Hi, Which is the hibernate postgresql 9.4 dialect? Thanks   Hi, The postgresql 9.4 dialect...; Hi, This is available in Hibernate ORM 5.2. Thanks
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate?   Here is an example - package...(); } } Output: Hibernate: select this_.emp_id as emp1_0_0_, this_.date_of_join
Version of postgresql>postgresql dependency
List of Version of postgresql>postgresql dependency
id
id  how to find date of birth and gender in id in html with the help of javascript
Hibernate id annotation
In this section, you will learn how to do mapping of id through annotation
pdf generation.
pdf generation.  i want to generate the data which is stored in mysql data base in pdf format with php. how i will do
Barcode generation
Barcode generation  hi, I am working on a project where there is a alias no. with symbology EAN-13 for generation of barcode... now i have to write the logic for one item no if their are two or more quantities it should
Hibernate Example
This section contains a simple Hibernate 4 example using Annotation with source code. The eclipse id and Apache Tomcat is used in this example
Artifacts of postgresql
List of Artifacts of postgresql maven depenency
hibernate sample code
This section contains a simple Hibernate 4 example using Annotation with source code. The eclipse id and Apache Tomcat is used in this example
PDF Generation for unicode characters
PDF Generation for unicode characters  Hi, How a PDF file having unicode characters is generated in JSP
HIBERNATE
HIBERNATE   What is difference between Jdbc and Hibernate
hibernate
hibernate  what is hibernate listeners
hibernate
hibernate  what is hibernate flow
Maven Dependency postgresql >> 7.2
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version7.2 in your project
Maven Dependency postgresql >> 7.3-jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version7.3-jdbc3 in your project
Maven Dependency postgresql >> 7.3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version7.3 in your project
Maven Dependency postgresql >> 7.4-jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version7.4-jdbc3 in your project
Maven Dependency postgresql >> 7.4
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version7.4 in your project
Maven Dependency postgresql >> 7.4.1-jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version7.4.1-jdbc3 in your project
Maven Dependency postgresql >> 7.4.1
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version7.4.1 in your project
Maven Dependency postgresql >> 8.0-312.jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.0-312.jdbc3 in your project
Maven Dependency postgresql >> 8.0-318.jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.0-318.jdbc3 in your project
Maven Dependency postgresql >> 8.1-404.jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.1-404.jdbc3 in your project
Maven Dependency postgresql >> 8.1-407.jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.1-407.jdbc3 in your project
Maven Dependency postgresql >> 8.1-408.jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.1-408.jdbc3 in your project

Ads