掲示板

UUID

8年前 に Charles Johnson によって更新されました。

UUID

Junior Member 投稿: 25 参加年月日: 15/05/01 最新の投稿
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
8年前 に David H Nebinger によって更新されました。

RE: UUID

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
setUuid() would only be added if you have 'uuid="true"' in your service.xml file and built services.
8年前 に Charles Johnson によって更新されました。

RE: UUID

Junior Member 投稿: 25 参加年月日: 15/05/01 最新の投稿
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
8年前 に David H Nebinger によって更新されました。

RE: UUID

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Nah, entry ids should be unique and also set using a sequencer or, in Liferay land, a value from CounterLocalServiceUtil.increment(Entry.class.getName()).
8年前 に Charles Johnson によって更新されました。

RE: UUID

Junior Member 投稿: 25 参加年月日: 15/05/01 最新の投稿
CounterLocalServiceUtil.increment(Entry.class.getName()).

Thanks. That works. I'll edit on Github with that, as the tutorial is wrong
8年前 に Charles Johnson によって更新されました。

RE: UUID

Junior Member 投稿: 25 参加年月日: 15/05/01 最新の投稿
Now a pull request
https://github.com/cehjohnson/liferay-docs/commit/12a8ce4c737a92b2a2a46ba6b3c1297db6a9ca95
thumbnail
8年前 に Richard Sezov によって更新されました。

RE: UUID

Regular Member 投稿: 220 参加年月日: 07/02/07 最新の投稿
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
8年前 に David H Nebinger によって更新されました。

RE: UUID

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
@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
8年前 に Vishal Kumar によって更新されました。

RE: UUID

Regular Member 投稿: 198 参加年月日: 12/12/12 最新の投稿
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
8年前 に David H Nebinger によって更新されました。

RE: UUID

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
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
8年前 に Xavier NICOLZA によって更新されました。

RE: UUID

New Member 投稿: 1 参加年月日: 16/03/08 最新の投稿
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.