auto-increment

JPA SequenceGenerator and GeneratedValue: name / generator property unique only per class?

依然范特西╮ 提交于 2019-12-10 19:35:31
问题 I use JPA + OpenJPA with PostgreSQL as backend RDBMS. The primary keys of my tables usually consist of a SERIAL / BIGSERIAL column. So PostgreSQL automatically generates IDs for new entries ( strategy=GenerationType.IDENTITY ). The annotations of ID property look like this: @Id @SequenceGenerator(name="myseq",sequenceName="foobartable_fooid_seq") @GeneratedValue(generator="myseq",strategy=GenerationType.IDENTITY) My question is: Can I copy and paste this annotations block to several entities,

SQLite PRIMARY key AutoIncrement doesn't work

故事扮演 提交于 2019-12-10 18:48:34
问题 I'm trying to a have a table with an auto incremented primary key. The SQL query for table creation is included. Problem is the auto-increment does not work. Meaning when I insert a row with NULL as the value of conversation_id it just inserts null . I have this problem on multiple tables. -- Table: conversations CREATE TABLE conversations ( conversation_id INTEGER (64) PRIMARY KEY UNIQUE, target_id BIGINT (64), sender_id BIGINT (64), status STRING (16) NOT NULL DEFAULT unseen, is_group

PHP function to increment variable by 1 each time

亡梦爱人 提交于 2019-12-10 15:46:52
问题 I have started writing a PHP script for a game about creatures, there are 4 yes/no questions and what I am trying to do is write a function that will display 2 buttons that say yes and no and give then different names each time I run the function, for example yes1 and no1, then the next time the function is run the names of the buttons will be yes2 and no2. I have attempted to do this already but it is not working correctly, below is the code I have done so far, any help would be much

Updating generator value issue

99封情书 提交于 2019-12-10 14:51:53
问题 I'm currently working on modifying a Firebird v. 1.5 database. The database structure will be modified running queries from a delphi application using interbase components, the problem I'm facing is that I need to run a lot of queries, some of which include creating generators and updating the generator value, the problem is that I need to achieve this in as few queries as possible, but it seems(at least to me) that this is not really possible, what I'm trying to do is the following: /* this

Incrementing revision numbers in table's composite key

时间秒杀一切 提交于 2019-12-10 10:43:22
问题 I'm running SQL Server 2014 locally for a database that will be deployed to an Azure SQL V12 database. I have a table that stores values of extensible properties for a business-entity object, in this case the three tables look like this: CREATE TABLE Widgets ( WidgetId bigint IDENTITY(1,1), ... ) CREATE TABLE WidgetProperties ( PropertyId int IDENTITY(1,1), Name nvarchar(50) Type int -- 0 = int, 1 = string, 2 = date, etc ) CREATE TABLE WidgetPropertyValues ( WidgetId bigint, PropertyId int,

Column with alternate serials

假如想象 提交于 2019-12-10 10:33:58
问题 I would like to create a table of user_widgets which is primary keyed by a user_id and user_widget_id, where user_widget_id works like a serial, except for that it starts at 1 per each user. Is there a common or practical solution for this? I am using PostgreSQL, but an agnostic solution would be appreciated as well. Example table: user_widgets | user_id | user_widget_id | user_widget_name | +-----------+------------------+----------------------+ | 1 | 1 | Andy's first widget | +-----------+-

pg_dump serial datatype issues

孤人 提交于 2019-12-10 09:33:36
问题 Could someone explain to me why a PostgreSQL table created with the following scripts: CREATE TABLE users ( "id" serial NOT NULL, "name" character varying(150) NOT NULL, "surname" character varying (250) NOT NULL, "dept_id" integer NOT NULL, CONSTRAINT users_pkey PRIMARY KEY ("id") ) gets dumped by pg_dump in the following format: CREATE TABLE users( "id" integer NOT NULL, "name" character varying(150) NOT NULL, "surname" character varying (250) NOT NULL, "dept_id" integer NOT NULL ); ALTER

How to set AUTO_INCREMENT from another table

笑着哭i 提交于 2019-12-10 04:32:18
问题 How can I set the AUTO_INCREMENT on CREATE TABLE or ALTER TABLE from another table? I found this question, but not solved my issue: How to Reset an MySQL AutoIncrement using a MAX value from another table? I also tried this: CREATE TABLE IF NOT EXISTS `table_name` ( `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT, `columnOne` tinyint(1) NOT NULL, `columnTwo` int(12) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=(SELECT `AUTO_INCREMENT` FROM `INFORMATION

How can i change _id field in MongoDB Collection to User_id?

爱⌒轻易说出口 提交于 2019-12-10 02:02:23
问题 I am new user for MongoDB Database. In MongoDb whatever insert into some collection defaultly one field is added that is _id field. For Example: db.users.insert({"User_id":"1","User_Name":"xxx","Address":"yyyy"}) db.users.find() It shows { "_id" : ObjectId("528475fc326b403f580d2eba"), "User_id" : "1", "User_Name" : "xxx",Address" : "yyyy" } I don't need _id field and i want to replace that _id field to User_id with auto increment values. Is it possible. Please help me. Thanks in advance. 回答1:

Large Auto Increment IDs

别说谁变了你拦得住时间么 提交于 2019-12-10 00:12:34
问题 I'm having a strange issue with some auto-inc IDs on a table, where instead of going up by 1 each time, it seems to be going up by 10 each time. I'm using the ClearDB MySQL Addon for Heroku PHP 5.5.15 Apache 2.4.10 Laravel dev branch (4.something) I've created the database via artisan's migrate functionality, My migration for the database table is <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateCheckinTable extends Migration { /** *