I have the entity of some BusinessParticipant, it just simple flat entity. And these Participants may be organized in groups, by user's wish. The group has no data, just id. So creating entity and table seems overkill... I'll wish to have 2 db tables, one for participants and one to link the participant to it's group. The problem is how should I generate the group id? All the GenerateValue & co. work with @id annotation only. Are there any way to mark the field that is not PK, to be automatically generated?
Generated value for nonPK field
4.8k views Asked by ellabi At
2
There are 2 answers
0
Petar Tahchiev
On
I have created a proposal for JPA to support @GeneratedValue on non-id fields.
Please vote here for it to be included in a future release
Related Questions in JPA-2.0
- Upgrading from Hibernate 4.x to 5.x producing SQLException Invalid Column Index
- Cannot create a table in H2 with a custom enum
- JPA criteria select multiple fields from subquery
- Spring boot 3, javax.persistence and entity scan
- Issue with Jpa and inheritance
- Joining pageable tables without relation using JPA criteria
- JPA ElementCollection foreign key mapping error
- JPA [EcliseLink]: Cannot change the type of an instance of parent A to subclass B In the single table inheritance
- SpringBoot JPA in MySQL
- In JPA2 and Java 10, how do I map the value of an enum to an @Enumerated column?
- can do this with JPA / Hibernate criteriabuilder
- JPA Criteria Subquery with select multiple colums and max() function
- How to properly / efficiently manage entity manager JPA Spring @Transactional for large datasets?
- Build a jpa specification query without retriving child entity data
- findAll() in spring boot
Related Questions in SEQUENCE
- How to find out how many of each 2, 3 and 4 required to fit in 100 using excel?
- Sequences - Find the next term in the sequence
- Direct boot from USB without changing BIOS setting or selecting from boot manager
- How do I shuffle these blocks and make a win/loss game-state?
- Triggering Actions in a sequence Python Reaper
- How inaccurate is QueryResult's underestimatedCount?
- How can I expand six days beyond each date in a list of arbitrary dates?
- Channel importance in sequence classification
- Pyspark Cummularive Sum Window Date and Sequence Number
- Running tests on both parallel and sequence mode using groups and dependsOnGroups attribute
- Displaying the number from the sequence by using the sequence ID
- What are the types of arrays with variable size and accommodating different types in Nim?
- Generating a pseudorandom binary sequence where the same number does not occur more than twice in a row
- Generate all combinations of array of arrays
- Coupon collector’s test (for testing sequences)
Related Questions in AUTOGENERATECOLUMN
- How to read a boolean that was bound to a Gridview with autogenerated columns
- Create a Function with 'while' loop in python and use the function to generate a new column in a data frame
- Include companyID for each customer and link it to other tables SQL
- How to convert a unix time to GMT+8 human readable date without FROM_UNIXTIME() function?
- Postgres - create a column (alter table) as a calculation of other two columns
- AutoGeneratedColumn Event in Datagrid?
- insert select with autogenerate column
- Auto generation of apply functions in python
- how to generate sequence id in composite primary with @IdClass in springboot hibernate
- .Net Core auto-generated string primary key
- How to set column width of autogenerated columns in Kendo UI Grid for angular
- How to create composite primary key with one auto generated value?
- How can we use pandas to generate min, max, mean, median, ...as new columns for the dataframe?
- trying to insert json with a value that's being used with a generated datetime field
- Asp.net c# GridView Sort AutoGenerateColumns false
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Depends on your persistence provider. For example, ObjectDB supports
@GeneratedValueon normal fields, but this is non-standard functionality. If you're using Hibernate, there's no clean way to do this, see this stackoverflow question: Hibernate JPA Sequence (non-Id)