Questions tagged [id-generation]

81 questions
3
votes
3 answers

MySQL 5 atomic id generator

My logic need to know the ID of a table before INSERT (setting the id manually while inserting). Because the logic using this ID is on more than one server, letting mysql create an id might be a good idea but the function I wrote is not atomic so…
Christof Aenderl
  • 4,233
  • 3
  • 37
  • 48
3
votes
2 answers

Schema-validation: missing table [SEQUENCE_NAME] when using Hibernate Sequence Generator Strategy

I have some problems with the hibernate id generation and a ms sql server. I am using the GenerationType.SEQUENCE in my application to generate Ids with hibernate. @Id @SequenceGenerator(name = "SequenceGenerator", sequenceName =…
3
votes
5 answers

Fast way to create a unique string ID/key from a known set of potential IDs in JavaScript

Say you want to have a set of 1- to 2-digit hexadecimal numbers, so 256 numbers. Just using a small set to get at the problem, but it would work with any sized string. So you have a potential N or 256 numbers in this case. You are going to…
Lance
  • 75,200
  • 93
  • 289
  • 503
3
votes
2 answers

How to unify @GenericGenerator declaration for multiple entities using same custom id generator?

There are many entities in my project that utilize the same custom IdentifierGenerator for @Id generation using SpringDataJPA/Hibernate. An example entity; @Entity @Table(name = "CHAIRS") public class ChairEntity { @Id …
buræquete
  • 14,226
  • 4
  • 44
  • 89
3
votes
2 answers

Why is the id null in the entity after saveandflush but not null in the database?

I use the latest Spring Boot with Spring Data JPA and Hibernate. The database used is Oracle 11G. I've been searching a solution for a couple of days but nothing worked. I struggle to retrieve the id of an entity newly inserted (successfully) in the…
Ivan
  • 129
  • 3
  • 6
3
votes
1 answer

Custom primary key generator in JPA

I am using org.hibernate.id.IdentifierGenerator to generate a primary key column as follows. In the following given example, currently it just increments the key of type INT(11) (MySQL) sequentially i.e. it does like auto_increment in MySQL but it…
Tiny
  • 27,221
  • 105
  • 339
  • 599
2
votes
2 answers

Oracle before-insert trigger and Hibernate id generator setting

I have an entity which is persisted in an Oracle schema. On DB insert, a trigger generates an entity ID by using a DB sequence. Using the trigger is mandatory since it also updates another table beside the ID generating sequence (kind of log table)…
rainer198
  • 3,195
  • 2
  • 27
  • 42
2
votes
1 answer

Fluent nHibernate AutoMapping & ID Generation Scheme

How can I use Fluent NHibernate (with AutoMapping) to configure the default ID generation scheme to Guid.Comb? I can see that I could specify in each entity (or a base class) the following code: Id(entity => entity.Id, "Id").GuidComb(); Which is…
James
  • 7,877
  • 7
  • 42
  • 57
2
votes
1 answer

Hibernate: Own ID-Generator Sequence for every entity

I currently use this approach for generating ids: @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; The effect is, when I save enity of type A it gets the id '1', then I save Enity B and it gets id '2' (instead of 1,…
MarkusJackson
  • 225
  • 2
  • 12
2
votes
1 answer

Sequential number generation with etcd cluster

I am exploring etcd to implement a sequential number generator for distributed environment. My requirement is to generate non repeating sequential number to be used in each request for multiple instances of same application. And there can be n such…
IhtkaS
  • 1,314
  • 3
  • 15
  • 31
2
votes
2 answers

MongoDb sequential int id generator for C# class hierarchy

I have a C# classes hierarchy with separated BsonClass mappings. All my classes use custom sequential int id generation. Last Id stored in special collection called "Counter". My problem is when mongo collection methods like InsertOneAsync get…
2
votes
1 answer

hibernate cant assign ID as double

I tried to assign ID for hibernate with double data type with this xml
user965347
  • 186
  • 2
  • 16
2
votes
2 answers

Secure ID in Java with persistency

I'm preparing a Java library that need to assign a unique id to the generated objects for serialization purposes. Once a unique id is generated, I have to ensure that the next time I use the library, there is no possibility to reassign an id to an…
mat_boy
  • 12,998
  • 22
  • 72
  • 116
2
votes
1 answer

Generate short id in ebean prior save entity to database

I want to get id of entity before it saved to database. If i have EbeanEntity with: @Id private UUID id; and call Ebean.nextId(EbeanEntity.class); return value is very complex(ce9d8486-2128-4a66-bef4-4158b6de2c7e). I need short value, like when…
cynepnaxa
  • 1,024
  • 1
  • 14
  • 30
2
votes
2 answers

How can I know what id Razor Html helpers generate?

In a Razor view, assume I have something like this: @Html.HiddenFor(model => model.Värde) Here, "Värde" is Swedish for "Value". Note it contains "ä". For this, Razor will generate HTML like this:
Kjell Rilbe
  • 1,331
  • 14
  • 39