File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
EJB 3 in Action
this week in the
EJB and other Java EE Technologies
Object Relational Mapping
HSQL db for JPA: auto incremented for a regular column
Joined: Jul 26, 2011
Apr 09, 2012 15:15:53
This is just a regular column that I want to have it auto incremented
@Column(name = "NUMBER", columnDefinition="int GENERATED BY DEFAULT AS IDENTITY (start with 1) ") @Basic private int number;
After loading data, the NUMBER is always zero.
Am I missing something or doing something wrong or is HSQL db sql syntax incorrect?
Joined: Oct 01, 2007
Apr 10, 2012 08:30:34
Blog:Java Persistence Performance
Joined: Jul 26, 2011
Apr 14, 2012 13:41:38
0. Thanks, James.
HyperSQL User Guide
HyperSQL Database Engine (HSQLDB) 2.2
CREATE TABLE star (id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, firstname VARCHAR(20), lastname VARCHAR(20)) CREATE TABLE movies (starid INTEGER, movieid INTEGER PRIMARY KEY, title VARCHAR(40)) INSERT INTO star (id, firstname, lastname) VALUES (DEFAULT, 'Felix', 'the Cat') INSERT INTO movies (starid, movieid, title) VALUES (IDENTITY(), 10, 'Felix in Hollywood')
2. Below is OK. Nothing unusual.
@Id @Column(name = "ID") @GeneratedValue(strategy=GenerationType.IDENTITY) @Basic private long id;
3. What I want is NOT an ID, rather a regular colum with auto-incremented.
This is OK by point 1. That's if we create using DDL itself.
But below is not OK. Could there be something else?
@Column(name = "NUMBER") @GeneratedValue(strategy=GenerationType.IDENTITY) private int number;
I agree. Here's the link:
subject: HSQL db for JPA: auto incremented for a regular column
Regarding Jtable row Deletion
Something is wrong in my SQL update
how to set auto increment field value ?
Leaving any property unmapped to a column in Hibernate using annotation
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014