Proper way to add UUIDs to new tables in plugin [Generic|Ninja Plugin]

66 views
Skip to first unread message

Antoni Ten Monrós

unread,
Nov 22, 2017, 6:51:41 AM11/22/17
to iDempiere
I've been trying the fantastic Ninja plugin to help accelerate plugin development, and I'm creating some new tables for a customization, to extend some tables with information that is internal to customization I am doing. However, the ninja plugin does not create the _UU columns automatically, and despite me looking for it, I could not find documentation on UUIDs for custom tables.

My questions are as follow:

- Are UUIDs for new tables necessary/important? I assume that yes to both, they are, but I just want to make sure. I can't find an explanation of how UUIDs are actually used in iDempiere.
- I've added columns of type String with length 36 to my custom tables, and named them [tablename]_UU. I've also added table indexes on those columns. Is this enough?

 I had to add the columns manually as the Ninja plugin didn't create them automatically for me. I would report that on Red1's forum, but my account was been awaiting activation for a while.

Nicolas Micoud

unread,
Nov 22, 2017, 6:56:50 AM11/22/17
to iDempiere
Hi,

UUID are used by 2Pack. It's a good practice to have them on tables.
There is a process "UUID Generator" that you can execute in System that will look for those missing columns and fill them with values.
Otherwise, you can find a sql function generate_uuid()

Regards,

Nicolas

Antoni Ten Monrós

unread,
Nov 22, 2017, 9:51:14 AM11/22/17
to iDempiere
On Wednesday, November 22, 2017 at 12:56:50 PM UTC+1, Nicolas Micoud wrote:
Hi,

UUID are used by 2Pack. It's a good practice to have them on tables.
There is a process "UUID Generator" that you can execute in System that will look for those missing columns and fill them with values.
Otherwise, you can find a sql function generate_uuid()

Regards,

Nicolas

Assume that I have an automatically generated X_/I_/ M set of files, as well as a model factory (all provided by Ninja), as well as the relevant tables and windows packed out. There is no data initially in the tables. When the plugin in installed, and activated, will the system recognize the _UU columns, and automatically start generating UUIDs for them, when data is inserted? I know how to generate missing UUIDs, but I don't want to need to generate them manually every so often, as it kind of defeats the purpose.

Nicolas Micoud

unread,
Nov 22, 2017, 11:54:53 AM11/22/17
to iDempiere
Yes, the system will generate uuid for new records if :
 - you use the PO.saveEx() method
 - the column _UU is present in the table

The generate_uuid function is to be used only for direct sql injection.
For legacy record (eg: migration from ADempiere), the UUID generator should be used
Message has been deleted

Antoni Ten Monrós

unread,
Nov 22, 2017, 12:26:21 PM11/22/17
to iDempiere
On Wednesday, November 22, 2017 at 5:54:53 PM UTC+1, Nicolas Micoud wrote:
Yes, the system will generate uuid for new records if :
 - you use the PO.saveEx() method
 - the column _UU is present in the table

The generate_uuid function is to be used only for direct sql injection.
For legacy record (eg: migration from ADempiere), the UUID generator should be used

Thanks for the information.

I assume that normal users creating records also generate UUIDs when using the built in save buttons. I guess I will need to replace all my save() with saveEx() though... 

Heng Sin Low

unread,
Nov 22, 2017, 1:17:57 PM11/22/17
to idem...@googlegroups.com
save() and saveEx() will both populate the _UU column, I guess Nicolas is just recommended the use of saveEx() over save() here.

On Thu, Nov 23, 2017 at 1:15 AM, Antoni Ten Monrós <kuro...@gmail.com> wrote:

On Wednesday, November 22, 2017 at 5:54:53 PM UTC+1, Nicolas Micoud wrote:
Yes, the system will generate uuid for new records if :
 - you use the PO.saveEx() method
 - the column _UU is present in the table

The generate_uuid function is to be used only for direct sql injection.
For legacy record (eg: migration from ADempiere), the UUID generator should be used

Ok, nice to know, I wasn't sure about that. I assume that users hitting the save button also trigger it.

Also, interesting that I need to use saveEx() when programatically saving for it to create the _UU. I guess I have to change a bunch of save() to saveEx()

--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/bff8327e-565f-438f-b9e5-c6fa26daf8ff%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages