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 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









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
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
Maven Repository/Dependency: postgresql | postgresql
Maven Repository/Dependency of Group ID postgresql and Artifact ID postgresql. Latest version of postgresql:postgresql dependencies. # Version Release Date 1 8.4-702.jdbc3
pojo generation - Hibernate
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
Maven Repository/Dependency: postgresql | pljava-public
Maven Repository/Dependency of Group ID postgresql and Artifact ID pljava-public. Latest version of postgresql:pljava-public dependencies. # Version Release Date 1 1.0.0b4
Maven Repository/Dependency: com.eventsourcing | eventsourcing-postgresql
Maven Repository/Dependency of Group ID com.eventsourcing and Artifact ID eventsourcing-postgresql. Latest version of com.eventsourcing:eventsourcing-postgresql dependencies. # Version Release Date
Maven Repository/Dependency: ru.yandex.qatools.embed | postgresql-embedded
Maven Repository/Dependency of Group ID ru.yandex.qatools.embed and Artifact ID postgresql-embedded. Latest version of ru.yandex.qatools.embed:postgresql-embedded dependencies. # Version Release Date
Maven Repository/Dependency: com.snacktrace | storm-postgresql
Maven Repository/Dependency of Group ID com.snacktrace and Artifact ID storm-postgresql. Latest version of com.snacktrace:storm-postgresql dependencies. # Version Release Date 1
Maven Repository/Dependency: com.dripower | postgresql-async_2.11
Maven Repository/Dependency of Group ID com.dripower and Artifact ID postgresql-async_2.11. Latest version of com.dripower:postgresql-async_2.11 dependencies. # Version Release Date
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
Maven Repository/Dependency: com.github.honoluluhenk.id-class | id-class-jpa-hibernate-integration
Maven Repository/Dependency of Group ID com.github.honoluluhenk.id-class and Artifact ID id-class-jpa-hibernate-integration. Latest version of com.github.honoluluhenk.id-class:id-class-jpa-hibernate-integration dependencies
Hibernate id annotation
In this section, you will learn how to do mapping of id through annotation
Maven Repository/Dependency: io.github.greycode | shardingsphere-sql-parser-postgresql
Maven Repository/Dependency of Group ID io.github.greycode and Artifact ID shardingsphere-sql-parser-postgresql. Latest version of io.github.greycode:shardingsphere-sql-parser-postgresql dependencies. # Version
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
Maven Repository/Dependency: org.postgresql | postgresql
Maven Repository/Dependency of Group ID org.postgresql and Artifact ID postgresql. Latest version of org.postgresql:postgresql dependencies. # Version Release Date 1 42.7.1
Maven Repository/Dependency: com.ariht | config-generation-maven-plugin
Maven Repository/Dependency of Group ID com.ariht and Artifact ID config-generation-maven-plugin. Latest version of com.ariht:config-generation-maven-plugin dependencies. # Version Release Date
Artifacts of postgresql
List of Artifacts of postgresql maven depenency
Maven Repository/Dependency: us.fatehi | schemacrawler-postgresql
Maven Repository/Dependency of Group ID us.fatehi and Artifact ID schemacrawler-postgresql. Latest version of us.fatehi:schemacrawler-postgresql dependencies. # Version Release Date
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
id
id  how to find date of birth and gender in id in html with the help of javascript
Maven Repository/Dependency: io.vertx | vertx-mysql-postgresql-client
Maven Repository/Dependency of Group ID io.vertx and Artifact ID vertx-mysql-postgresql-client. Latest version of io.vertx:vertx-mysql-postgresql-client dependencies. # Version Release Date
Maven Repository/Dependency: com.github.jasync-sql | jasync-postgresql
Maven Repository/Dependency of Group ID com.github.jasync-sql and Artifact ID jasync-postgresql. Latest version of com.github.jasync-sql:jasync-postgresql dependencies. # Version Release Date
Maven Repository/Dependency: io.vertx | vertx-mysql-postgresql-client-jasync
Maven Repository/Dependency of Group ID io.vertx and Artifact ID vertx-mysql-postgresql-client-jasync. Latest version of io.vertx:vertx-mysql-postgresql-client-jasync dependencies. # Version Release Date
report generation - EJB
report generation   how to create the report in java
Maven dependency for com.github.honoluluhenk.id-class - id-class-jpa-hibernate-integration version 1.0.1 is released. Learn to use id-class-jpa-hibernate-integration version 1.0.1 in Maven based Java projects
1.0.1 of id-class-jpa-hibernate-integration released The developers of   com.github.honoluluhenk.id-class - id-class-jpa-hibernate-integration project... version of  com.github.honoluluhenk.id-class - id-class-jpa-hibernate
Maven dependency for com.github.honoluluhenk.id-class - id-class-jpa-hibernate-integration version 1.0.0 is released. Learn to use id-class-jpa-hibernate-integration version 1.0.0 in Maven based Java projects
1.0.0 of id-class-jpa-hibernate-integration released The developers of   com.github.honoluluhenk.id-class - id-class-jpa-hibernate-integration project... version of  com.github.honoluluhenk.id-class - id-class-jpa-hibernate
Maven dependency for com.github.honoluluhenk.id-class - id-class-jpa-hibernate-integration version 0.0.4 is released. Learn to use id-class-jpa-hibernate-integration version 0.0.4 in Maven based Java projects
0.0.4 of id-class-jpa-hibernate-integration released The developers of   com.github.honoluluhenk.id-class - id-class-jpa-hibernate-integration project... version of  com.github.honoluluhenk.id-class - id-class-jpa-hibernate
Maven dependency for com.github.honoluluhenk.id-class - id-class-jpa-hibernate-integration version 0.0.3 is released. Learn to use id-class-jpa-hibernate-integration version 0.0.3 in Maven based Java projects
0.0.3 of id-class-jpa-hibernate-integration released The developers of   com.github.honoluluhenk.id-class - id-class-jpa-hibernate-integration project... version of  com.github.honoluluhenk.id-class - id-class-jpa-hibernate
Maven Repository/Dependency: hibernate | hibernate-tools-hibernate
Maven Repository/Dependency of Group ID hibernate and Artifact ID hibernate-tools-hibernate. Latest version of hibernate:hibernate-tools-hibernate dependencies. # Version Release Date You
Maven Repository/Dependency: org.finos.legend.engine | legend-engine-executionPlan-generation
Maven Repository/Dependency of Group ID org.finos.legend.engine and Artifact ID legend-engine-executionPlan-generation. Latest version of org.finos.legend.engine:legend-engine-executionPlan-generation dependencies
PDF Generation for unicode characters
PDF Generation for unicode characters  Hi, How a PDF file having unicode characters is generated in JSP
Hibernate Synchronizer
Hibernate Synchronizer       Hibernate Synchronizer is a free Eclipse plugin code generation tool to be used with the Hibernate persistence framework. The plugin
Maven Repository/Dependency: hibernate | hibernate
Maven Repository/Dependency of Group ID hibernate and Artifact ID hibernate. Latest version of hibernate:hibernate dependencies. # Version Release Date 1 2.0.1 01 Aug
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.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
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

Ads