-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow @GeneratedValue for non-@Id fields #113
Comments
@glassfishrobot Commented |
@glassfishrobot Commented However I vote that will be nice if this works :
|
@glassfishrobot Commented |
@glassfishrobot Commented About the GenericGenerator and GeneratorType (both from Hibernate) we indeed should discuss in separate issue and of course I will not say "because Hibernate have them", you can trust me I am an engineer ! Nayden |
@glassfishrobot Commented |
@glassfishrobot Commented |
@glassfishrobot Commented
and so on as PK not just Sequence, auto increment or table with PK nextvals. |
@glassfishrobot Commented I asked what are these other annotations, and why should the standard have them? I repeat the point i made to you earlier (which you are supposed to raise in a separate issue) ... if you are going to PROPOSE something, then kindly explain WHAT role it performs. If you want non-numeric PK generation, like some implementations do with things like "UUID" then you can define the column type ... but there's no need of a special annotation for that, since you already have @column! |
@glassfishrobot Commented |
|
Is there any update on this? The annotations still don't seem to be working without additional annotations such as Id. I've tried options from the post below excluding extra Id or column annotations and the field is not generated. https://stackoverflow.com/questions/47934661/generate-unpredictable-random-id-for-entity |
Do we have any updates on this? |
I think this would be a good addition. But if not already a separate request, I suggest we consider how this plays with update/insert handling. I assume the intention here is specifically for insertion-time generation. However, update-time generators are plenty useful as well - modified-timestamp e.g. I'd actually suggest not re-using
Depending on how robust and flexible we want to make this, I'd also suggest having a look at https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/main/java/org/hibernate/tuple/ValueGeneration.java It illustrates some things I've had to deal with implementing this for Hibernate over the years. |
Agree with @sebersole! |
Indeed. If we do this, we should go the whole hog and do this issue, #342, and update-time generation all at once. Note that there's an existing issue, #51, which proposes using
That's not awful at all. (It's superficially a bit different to the track we took with the generator framework in Hibernate, but it's not at all inconsistent with the ideas there.) Anyway, I actually want to close #51 because the proposal there is written up in a very weird way, and it's had no activity, but I'm recording the idea here, since it's a possible approach we could take if/when we decide to address this issue, probably in conjunction with #342. |
This is still open ya? Or is it closed? How do we fix it? Thanks |
In my case I needed to include a field whose value was generated by a sequence in the Oracle database. Adding Generated from Hibernate worked
|
Hello,
My scenario is the following - I have a @MappedSuperclass which defines a field pk (which is generated value with a custom generic generator) but I also have an entity called Order with a property code. I have created a custom generic generator which calculates on the server what the order code must be, but even though I have specified it as this:
This generator is never called. I checked the javadoc and there explicitly says that the @GeneratedValue is used together with @id. My proposal is to allow it to be used on columns that are not @id.
The text was updated successfully, but these errors were encountered: