Message Boards

« Back to 2.- Usage ( From Xml file to CRUD Portlet)

RE: Insert values into table via API

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Insert values into table via API
Answer
11/5/15 9:51 AM
Hi, I'm Ricardo from Spain.

I'm trying to use the code generated by xmlportletfactory to insert values into the tables in a migration process.

Im using this code with the *LocalServiceUtil generated by the xmlportletfactory:

 1
 2Translations translations = TranslationsLocalServiceUtil.createTranslations(idTranslation);
 3            
 4translations.setCompanyId(Long.parseLong(companyId));
 5translations.setGroupId(Long.parseLong(groupId));
 6translations.setUserId(Long.parseLong(userId));
 7...
 8translations.setLogical_delete(logicalDelete);
 9            
10TranslationsLocalServiceUtil.addTranslations(translations);

My question is regarding the id for the table.

There is a way to get the next id I have to use using the API?
Is this the right way to insert values via API?

Thanks in advance and sorry for my bad english.

RE: Insert values into table via API
Answer
11/16/15 8:11 AM as a reply to RICARDO GARCIA HERNANZ.
Hola Ricardo,

there is a better API for adding entities. Search TranslationsLocalServiceUtil.for addTranslations, there the numeric identifier will be created for you automatically.