Hi, The lifecycle callbacks probably aren't the right place to do what you want. Generated values are made available in the PostPersist callback which isn't suitable for your purposes. The spec doesn't explicitly state that you cannot make them available in PrePersist but it wouldn't be something that you could rely on.
You might be better off removing the @GeneratedValue annotation and obtaining the sequence value manually - and manipulating the value before calling the setter. You might be able to get something to work with OpenJPA's Transaction Events [1]. There's not a lot of documentation on them, and I don't know if you'll be able to modify the entities before they're written to the database. They're also a bit brittle from the little I've seen. [1] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_runtime_pm_event Hope this helps, -mike On Tue, Nov 23, 2010 at 6:12 PM, nasseria1 <[email protected]> wrote: > > Hi all, > > We want to use a custom sequence generator so that manipulating its > generated value before persisting it into database would be possible. > > For example, the generated value for a sample primary key that used > database > sequence generator is 205 and before persisting the entity, we just want to > manipulate the generated value using a specified algorithm. As it's clear, > I > want to use the database sequence, but modifying the generated value is the > main requirement. > > To resolve this, I inspected the generated value in @PrePersist entity > callback, but it did not include the generated value. > > I would appreciate for any ideas > Nasser > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/Manipulating-sequence-generated-value-before-persisting-entities-tp5768846p5768846.html > Sent from the OpenJPA Developers mailing list archive at Nabble.com. >
