Fórum

UUID

Charles Johnson, modificado 8 Anos atrás.

UUID

Junior Member Postagens: 25 Data de Entrada: 01/05/15 Postagens Recentes
in https://dev.liferay.com/develop/learning-paths/-/knowledge_base/6-2/integrating-your-persistence-framework-into-your-a , the code:
guestbook.setUuid(serviceContext.getUuid());

comes up as an error in my Liferay IDE, since guestbook doesn't have that method

I submitted a pull request on a small grammatical error on the preceding page btw
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: UUID

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
setUuid() would only be added if you have 'uuid="true"' in your service.xml file and built services.
Charles Johnson, modificado 8 Anos atrás.

RE: UUID

Junior Member Postagens: 25 Data de Entrada: 01/05/15 Postagens Recentes
setUuid() would only be added if you have 'uuid="true"' in your service.xml file and built services.


OK David. I don't recall the tutorial discussing that, but of course i might have missed it. In fact, service xml does not have that attribute anywhere
Just to be clear, i pasted the code into my IDE as instructed at
Create a method for adding guestbook entries. This method is similar to the method you created earlier for adding guestbooks:

( https://dev.liferay.com/develop/learning-paths/-/knowledge_base/6-2/integrating-your-persistence-framework-into-your-a )
The following might be worth considering maybe? In the absence of a better alternative that allows compilation, i'll do this for now
entry.setEntryId(serviceContext.getUuid().hashCode());
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: UUID

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Nah, entry ids should be unique and also set using a sequencer or, in Liferay land, a value from CounterLocalServiceUtil.increment(Entry.class.getName()).
Charles Johnson, modificado 8 Anos atrás.

RE: UUID

Junior Member Postagens: 25 Data de Entrada: 01/05/15 Postagens Recentes
CounterLocalServiceUtil.increment(Entry.class.getName()).

Thanks. That works. I'll edit on Github with that, as the tutorial is wrong
Charles Johnson, modificado 8 Anos atrás.

RE: UUID

Junior Member Postagens: 25 Data de Entrada: 01/05/15 Postagens Recentes
Now a pull request
https://github.com/cehjohnson/liferay-docs/commit/12a8ce4c737a92b2a2a46ba6b3c1297db6a9ca95
thumbnail
Richard Sezov, modificado 8 Anos atrás.

RE: UUID

Regular Member Postagens: 220 Data de Entrada: 07/02/07 Postagens Recentes
Hey guys,

The EntryID and the UUID are two different fields. Both are accounted for in the Guestbook portlet. The source code for the completed portlet is out on Github; you can view EntryLocalServiceImpl here.

Here's the snippet of code we're talking about:


                long entryId = counterLocalService.increment();
		
		Entry entry = entryPersistence.create(entryId);
		
		entry.setUuid(serviceContext.getUuid());



As you can see, we already use couterLocalService to set the entryId. The UUID field is a separate field. We actually don't introduce the UUID until later in the Learning Path, when it's required for either Resources or Assets (I forget which).

Hope this helps!
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: UUID

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
@Charles,

The generic counterLocalService.increment() method uses a generic counter and counterLocalService.increment(Entity.class) uses a separate counter just for Entity objects.

Richard is exactly right and I probably should have checked out the code specifically, but I was just trying to answer your question...
thumbnail
Vishal Kumar, modificado 8 Anos atrás.

RE: UUID

Regular Member Postagens: 198 Data de Entrada: 12/12/12 Postagens Recentes
May it will help
https://www.liferay.com/community/forums/-/message_boards/message/12078162
http://searchsoa.techtarget.com/definition/UUID
http://stackoverflow.com/questions/19907956/how-to-get-uuid-from-user
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: UUID

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Vishal Kumar:
May it will help
https://www.liferay.com/community/forums/-/message_boards/message/12078162
http://searchsoa.techtarget.com/definition/UUID
http://stackoverflow.com/questions/19907956/how-to-get-uuid-from-user


Again, Vishal is totally wrong here. The first and last posts talk about getting the UUID for the user. The OP's original post was how to set a UUID on a custom entity. As UUIDs are meant to be unique identifiers (Vishal would know that if he had read the second link), you should not reuse the user's UUID on another entity.
thumbnail
Xavier NICOLZA, modificado 8 Anos atrás.

RE: UUID

New Member Mensagem: 1 Data de Entrada: 08/03/16 Postagens Recentes
Hello,

I don't know if my answer is too late but I resolved this problem by checking the "UUID" and "UUID accessor" boxes in the Entity configuration windows and (re)Build Services.