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 best solutions below
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
- JPA 2.0 CriteriaQuery with predicate on type being a class or any subclass of
- JPA Portability Between MYSQL and MongoDB
- JPA2 get column metadata (type, lenth, nullable, etc)
- Set Customized Validation Exception Message in JPA 2.0
- Unidirectional @OneToOne with reversed foreign key
- OpenJPA OneToMany and composite key in parent and child table
- JPA number generators without primary key and general use
- Container cannot inject EntityManager using @PersistentContext
- Returning result from 3 tables using JPA criteria
- JPA OneToMany with Jointable, deleting a link deletes right-side object
- Handling field of Integer with specific count of digits in entity
- JPA Criteria API .in-Clause with empty list
- Left Join in Spring Data JPA's Specification
- JPA Criteria Join OneToMany table where clause does not work
- Native query IN clause throwing sql error
Related Questions in SEQUENCE
- Recent development in recoding repeated variables in R?
- All increasing sequence of length k of first n whole numbers
- Oracle sequence.NEXTVAL strange order from JSP app
- Creating an alphanumeric sequence
- Longest Snake Sequence
- Using a BackSlash in Java
- R add columns indicating start and end for a sequence within columns
- I can't figure out this sequence - 11110000111000110010
- Tools for generate sequence diagram(UML) from PHP class(files)
- Custom List data structure implementing SequenceType with using of GeneratorOf struct
- Longest Snake Sequence in an Array
- Longest Snake Sequence in a list of numbers
- XQuery - Doing math on elements within a sequence and aggregating results
- group by until changed sequence
- Multiple TSQL sequences in one sequence
Related Questions in AUTOGENERATECOLUMN
- Using image in bool-type column when using AutoGenerateColumn (WPF)
- My autogenerated columns do not show in Datagrid
- Asp.net c# GridView Sort AutoGenerateColumns false
- Setting ToolTip for DataGridView automatically created columns
- AutoGeneratedColumn Event in Datagrid?
- Generated value for nonPK field
- Create a Function with 'while' loop in python and use the function to generate a new column in a data frame
- How to convert a unix time to GMT+8 human readable date without FROM_UNIXTIME() function?
- Programatically add ValidationRules to WPF DataGrid when autogenerating columns
- Using Mode=TwoWay and AutogenerateColumns=True in Silverlight 3 DataGrid
- Datagrid WPF: Bind datepicker in AutogeneratedColumns
- Making dynamically created linkbutton to fire an event on click
- set max display width for a column in WPF datagrid
- Controlling DBML EntityRef creation in DBML with multiple foreign keys
- in an asp.net gridview, should autogeneratecolumns=true ignore datakeys?
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)
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?
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)