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 a month 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
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
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
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
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
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
report generation using jsp
report generation using jsp  report generation coding using jsp
Excel File data upload into postgresql database in struts 1.x
Excel File data upload into postgresql database in struts 1.x  Dear members please explain how Excel Files data upload into postgresql database in struts 1.x
report generation - EJB
report generation   how to create the report in java
PDF Generation for unicode characters
PDF Generation for unicode characters  Hi, How a PDF file having unicode characters is generated in JSP
retrieving data in to the dropdown box from postgresql database in core java
retrieving data in to the dropdown box from postgresql database in core...=st.executeQuery("SELECT role_name from role WHERE dept_id=1234"); if(rs...) { JOptionPane.showMessageDialog(this, "The generated Id is:"); dispose
insert data using drop down box in java into database postgresql
and postgresql as data base syntax which i m using is like:- java class...("addressafterretirement", new Model()); public form1a(Integer emp_id) { eid=emp_id; Form form = new Form("f
insert data using drop down box in java into database postgresql
and postgresql as data base syntax which i m using is like:- java class...("addressafterretirement", new Model()); public form1a(Integer emp_id) { eid=emp_id; Form form = new Form("f
insert data using drop down box in java into database postgresql
and postgresql as data base syntax which i m using is like:- java class...("addressafterretirement", new Model()); public form1a(Integer emp_id) { eid=emp_id; Form form = new Form("f
insert data using drop down box in java into database postgresql
and postgresql as data base syntax which i m using is like:- java class...("addressafterretirement", new Model()); public form1a(Integer emp_id) { eid=emp_id; Form form = new Form("f
total id
total id  how to print and total my id number ..for example if my id is 0123456789 the output will look like this : 0123456789 0+1+2+3+4+5+6+7+8+9=45 help me plz
Session ID
Session ID  How can I change the session ID of the page?   ...' session ID values because it is very likely to result in the loss of the session or with people acquiring other users' data. The session ID value should be managed
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
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method="post" enctype="multipart/form-data" name="form1"> this action page can't get String tp = request.getParameter("indegrates"). i wrote article upload
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method="post" enctype="multipart/form-data" name="form1"> this action page can't get String tp = request.getParameter("indegrates"). i wrote article upload
Hibernate Synchronizer
Hibernate Synchronizer       Hibernate Synchronizer is a free Eclipse plugin code generation tool to be used with the Hibernate persistence framework. The plugin
id creation
id creation  CREATE TABLE mohan2 ( sno bigint(20) NOT NULL AUTO_INCREMENT, name varchar(30) NOT NULL, sal int(30) NOT NULL, eid varchar(30) NOT NULL, PRIMARY KEY (sno,eid) ) import java.sql.*; import
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
Tutorials   
Java Spring Hibernate Struts Training Hibernate envers revtype values Hibernate envers audit example Hibernate envers example Hibernate envers revinfo table revinfo table sql Hibernate maven dependency example What is the difference between JPA and Hibernate? How to turn off hbm2ddl? Hibernate hbm2ddl.auto values Hibernate table not mapped error - solution Hibernate error class is not mapped Hibernate Envers custom revinfo table Hibernate Envers - REVINFO table doesn't exist How to enable second level cache in Hibernate 5? How to enable second level cache in Hibernate 5? java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based! org.hibernate.validator cannot be resolved error java.lang.ClassNotFoundException: org.hibernate.cache.TimestampsRegion java.lang.ClassNotFoundException: org.hibernate.cache.TimestampsRegion property hibernate.cache.region.factory_class is not given Hibernate example step by step in Eclipse with MySQL How to make Struts Hibernate and Spring Based Login/Registration Application? What is the use of Hibernate Native SQL? What is the use of Hibernate is used? How to integrate Struts and Hibernate in an application? How to create the program in Java for getting the forgotten Password Form? How to write create JPA Many-to-Many Relationship in Java? What is the DAO Layer in any application? What is Spring Struts Hibernate DAO Layer? How to write Example code for CRUD application in hibernate annotation? Where to update the Hibernate tools? Query conversion convert into hql how to convert sql into hql package org.hibernate.util does not exist C3P0 with Hibernate What do you understand by JPA? Hibernate Query Checker Jpa many to many relationship What do you understand by Hibernate in Java? What are criteria Queries in Hibernate? How to use Associations and Joins in Hibernate? Hibernate 4 Example with Eclipse How to learn Hibernate? What is Hibernate Framework? hibernate faq 15/03/14 hibernate 15/03/2014 Hibernate Criteria Wildcard how to add mulitiple projections this is a hibernate question

Ads

 
Advertisement null

Ads