wso2 data services server - CRUD insert using a java generated GUID

StackOverflow https://stackoverflow.com/questions/17115016

  •  31-05-2022
  •  | 
  •  

سؤال

I have an entity that requires a GUID for it's primary key. Ideally, I would like to use a java class to generate the GUID before adding the entity to the database, so that I can control exactly how the GUID is created.

Is it possible to delegate the key generation to a java class with WSO2 DSS? How?

هل كانت مفيدة؟

المحلول

you can try to generate the GUID within the SQL statement, using ORACLE (for example) functions. I guess you will success if the algorithm is not too complex. This way, your insert statement would look like:

Insert into table (c1, c2, ..) values (functions for ID, v2,...)

Although the best practice is to use a trigger before insert which call a database sequence to generate a new guid.

You can also try to make a xslt transformation where you implement the algorithm to generate de guid. You would just have to perform the transformation before calling to dss.

Hope it helps!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top