Foros de discusión

UUID

Charles Johnson, modificado hace 8 años.

UUID

Junior Member Mensajes: 25 Fecha de incorporación: 1/05/15 Mensajes recientes
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 hace 8 años.

RE: UUID

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
setUuid() would only be added if you have 'uuid="true"' in your service.xml file and built services.
Charles Johnson, modificado hace 8 años.

RE: UUID

Junior Member Mensajes: 25 Fecha de incorporación: 1/05/15 Mensajes recientes
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 hace 8 años.

RE: UUID

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
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 hace 8 años.

RE: UUID

Junior Member Mensajes: 25 Fecha de incorporación: 1/05/15 Mensajes recientes
CounterLocalServiceUtil.increment(Entry.class.getName()).

Thanks. That works. I'll edit on Github with that, as the tutorial is wrong
Charles Johnson, modificado hace 8 años.

RE: UUID

Junior Member Mensajes: 25 Fecha de incorporación: 1/05/15 Mensajes recientes
Now a pull request
https://github.com/cehjohnson/liferay-docs/commit/12a8ce4c737a92b2a2a46ba6b3c1297db6a9ca95
thumbnail
Richard Sezov, modificado hace 8 años.

RE: UUID

Regular Member Mensajes: 220 Fecha de incorporación: 7/02/07 Mensajes recientes
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 hace 8 años.

RE: UUID

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
@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 hace 8 años.

RE: UUID

Regular Member Mensajes: 198 Fecha de incorporación: 12/12/12 Mensajes recientes
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 hace 8 años.

RE: UUID

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
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 hace 8 años.

RE: UUID

New Member Mensaje: 1 Fecha de incorporación: 8/03/16 Mensajes recientes
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.