Hi,

L�zaro Miguel Fung wrote:
Hi,

How I can get a sequence value using SequenceManagerNextValImpl before OJB
insert a new object in the DB.


You can generate an Identity object before insert, then the PK fields will be set in object and you can get them from the generated Identity, see
http://db.apache.org/ojb/docu/guides/sequencemanager.html#Force+computation+of+unique+values


Another possibility is to lookup a new sequence value using SequenceManager#getUniqueValue(FieldDescriptor field) via
broker.serviceSequenceManager()
and then *set* the PK values by your own in the new object (The PK fields can be obtained from the ClassDescriptor and this from broker.getClassDescriptorFor(object)).


In both cases I recommend to use broker.store(Object obj, ObjectModification mod) for best performance.

Or use one of OJB callback interfaces to extract the PK value before insert (PersistenceBrokerAware, PBLifeCycleListener more info see javadoc).

All suggestions are not possible when database IDENTITY columns will be used (but you don't ;-)), see
http://db.apache.org/ojb/docu/guides/sequencemanager.html#Identity+based+sequence+manager


regards,
Armin


TIA.

LFung



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to