java - how to implement @GeneratedValue with my own strategy for generating keys -


i want implement own strategy generating primary keys new rows in table, example want id of host 172.24.85.20 8520.

can somehow extend @generatedvalue annotation? approach recommend?

10x in advance!

gal

in projects i'm using custom key, because need entities unique identity before persist() called. solution not using @generatedvalue annotation, initialize id-field manually. @generatedvalue annotation depends on database , primary key provider it. in case id field calculated , set before calling entitymanager.persist() or step can handled in @prepersist annotated entitylistener method (http://www.java2s.com/tutorial/java/0355__jpa/entitylistenerpreupdate.htm). apart extending annotations not possible (why not possible extend annotations in java?); combine annotations using stereotypes or create own annotations.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -