Hibernate generation Id to postgreSQL

Ads

 
 

Share on Google+Share on Google+

Raul Estrela
Hibernate generation Id to postgreSQL
0 Answer(s)      5 years and 5 months ago
Posted in : Hibernate

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!

Ads
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 criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate
HIBERNATE COMPOSITE ID - Hibernate
HIBERNATE COMPOSITE ID  Hi, I have a database table structure as CREATE TABLE `attendance` ( `sno` int(11) NOT NULL auto_increment, `empRef` int(8) default NULL, `dat` date default NULL, `timeIn` time
Automatic primary Generation in Hibernate - Hibernate
Automatic primary Generation in Hibernate   Hi, Ow primary key is generated automatically in hibernate.give me sample code.Thank u
sql script generation - Hibernate
sql script generation  he show_sql shows the sql statements but doesn't show the Create Table statements (the table definetions) on creation?? is there any way to do that in hibernate? Generate the sql script for tables
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
Using Hibernate <generator> to generate id incrementally - Struts
Using Hibernate to generate id incrementally  Hi All, How to increment id using Hibernate ( or if any other) to generate id. I am using... on Hibernate visit to : http://www.roseindia.net/hibernate/index.shtml http
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
Table generation error - EJB
Table generation error  Hi friends I am using EJB3.0 with sun java system application server 9.1 with postgresql database. Actually when i make... "CREATE TABLE BookShop (ID INTEGER NOT NULL, BOOKNAME VARCHAR(255), AUTHOR VARCHAR
Artifacts of postgresql
List of Artifacts of postgresql maven depenency
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
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
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 >> 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-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
Maven Dependency postgresql >> 8.2-504.jdbc4
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.2-504.jdbc4 in your project
Maven Dependency postgresql >> 8.2-507.jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.2-507.jdbc3 in your project
Maven Dependency postgresql >> 8.2-511.jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.2-511.jdbc3 in your project
Maven Dependency postgresql >> 8.3-603.jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.3-603.jdbc3 in your project
Maven Dependency postgresql >> 8.3-606.jdbc3
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.3-606.jdbc3 in your project
Maven Dependency postgresql >> 8.3-606.jdbc4
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.3-606.jdbc4 in your project
Maven Dependency postgresql >> 8.4-701.jdbc4
You should include the dependency code given in this page to add Maven Dependency of postgresql >> postgresql version8.4-701.jdbc4 in your project