id-generation

org.hibernate.MappingException: The increment size of the sequence is set to [10] in the entity mapping while … size is [1]

不打扰是莪最后的温柔 提交于 2020-06-27 10:44:46
问题 We run into a problem when updating to Spring Boot 2.2 and the associated Hibernate 5.4.x. We do have the following sequence generator @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "hilo_sequence_generator") @GenericGenerator( name = "hilo_sequence_generator", strategy = "...", parameters = { @Parameter(name = "sequence_name", value = "XXX_SEQUENCE"), @Parameter(name = "initial_value", value = "1"), @Parameter(name = "increment_size", value = "10"), @Parameter(name =

Modify Id generation for a Grails Plugin

北战南征 提交于 2020-01-05 13:49:25
问题 I am using a plugin for Grails - the Amazon S3 plugin - and the domain object provided by the plugin doesn't specify the Id Generator. I am using Postgresql and require the id genrator to be identity. I could copy the plugin in my plugins directory and mess with the domain object provided but that doesn't sound like a clean approach.Could I add the correct id generation at runtime? Or maybe there is a better way. 回答1: If you are using 1.2, you could provide a default mapping for all your GORM

How to insert a record with custom id use Spring data jdbc?

徘徊边缘 提交于 2019-12-23 10:18:04
问题 For Spring Data JPA, I can use annotation @GeneratedValue(strategy = GenerationType.AUTO) insert a record with custom id, but for Spring Data JDBC, how to insert a record with custom id? I had tried to insert with id, but no any exception threw, and the record is not inserted into the table. 回答1: The way to do that with Spring Data JDBC is to register a BeforeSaveEvent ApplicationListener that creates the id and sets it in the entity. @Bean public ApplicationListener<BeforeSaveEvent>

@GeneratedValue with strategy=GenerationType.AUTO generates repeated value after restart

▼魔方 西西 提交于 2019-12-20 12:31:33
问题 I have a hibernate entity with an ID configured as @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; The creation of new elements works ok in the first run. But if I restart my application and retrieve back the records, the next time I try to persist this entity, hibernate tries to use the same ID generated when the application was not restarted. I get the error below, and when running with trace option, I was able to see that the ID was being reused *Hibernate: insert into

Does the path of a Document have any bearing on the random ID auto-generated by Firestore?

我只是一个虾纸丫 提交于 2019-12-18 09:44:57
问题 If I want to know the (random) ID of a document before saving it to Firestore (without writing custom code), I can do the following: String id = db.collection("collection-name").document().getId(); Does it make a difference if I give "collection-name" in the code above but use that id to save the document to collection "some-other-collection" ? In other words, does the collection name (or more generally, path of the document) have any bearing on the random ID generated by Firestore? Are

native generator class in hibernate

懵懂的女人 提交于 2019-11-28 07:14:18
问题 I have this part of hibernate mapping xml file, and I was looking for a good example for what does native mean. <hibernate-mapping> <class name="com.hib.Task" table="tasks"> <id name="id" type="int" column="id" > <generator class="native"/> </id> I know it's something related to unique identifier property, but I would really like to have an example. Sorry for the newbie question, I'm new to hibernate and programming in general :) Thank you! 回答1: Native means Your generator will use identity

Hibernate with Oracle sequence doesn't use it

谁说我不能喝 提交于 2019-11-27 19:06:47
I have configured hibernate to use oracle sequence. Sequence is created with cache=20, increment=1. All works fine, hibernate persisting entities. The id value is strange: 50,51....76,201,202...209,1008,1009,5129,5130 .... If I ask for sequence value (select hibernate_sequence.nextval from dual) I get value like 2,3,4 .... If I turn on hibernate sql debug, there is time to time call "select hibernate_sequence.nextval from dual" but number assigned by hibernate to ID doesn't relay on sequence! @Id @Column(name = "ID", insertable = false, updatable = false) @SequenceGenerator(name =

Hibernate ID Generator

梦想的初衷 提交于 2019-11-27 04:33:55
Anyone know of some good tutorials on how to create a custom ID generator for hibernate? paxdiablo A cursory search of Google for 'hibernate custom id generator tutorial' turned up the following possibilities. I've excluded those that don't look useful and summarized the content of each. http://www.devx.com/Java/Article/30396 - covers the issues of generating an ID before the data is persisted (and hence does not yet have a business key). http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#mapping-declaration - the whole document is very useful but not so much a tutorial as

Hibernate with Oracle sequence doesn't use it

▼魔方 西西 提交于 2019-11-26 22:45:59
问题 I have configured hibernate to use oracle sequence. Sequence is created with cache=20, increment=1. All works fine, hibernate persisting entities. The id value is strange: 50,51....76,201,202...209,1008,1009,5129,5130 .... If I ask for sequence value (select hibernate_sequence.nextval from dual) I get value like 2,3,4 .... If I turn on hibernate sql debug, there is time to time call "select hibernate_sequence.nextval from dual" but number assigned by hibernate to ID doesn't relay on sequence!

Hibernate ID Generator

…衆ロ難τιáo~ 提交于 2019-11-26 11:16:42
问题 Anyone know of some good tutorials on how to create a custom ID generator for hibernate? 回答1: A cursory search of Google for 'hibernate custom id generator tutorial' turned up the following possibilities. I've excluded those that don't look useful and summarized the content of each. http://www.devx.com/Java/Article/30396 - covers the issues of generating an ID before the data is persisted (and hence does not yet have a business key). http://docs.jboss.org/hibernate/core/3.6/reference/en-US