Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
How to get Liferay to pickup mysql database changes Nick Lindberg 8 de mayo de 2012 10:12
RE: How to get Liferay to pickup mysql database changes David H Nebinger 8 de mayo de 2012 11:19
RE: How to get Liferay to pickup mysql database changes Nick Lindberg 8 de mayo de 2012 11:57
RE: How to get Liferay to pickup mysql database changes Nick Lindberg 8 de mayo de 2012 12:56
RE: How to get Liferay to pickup mysql database changes David H Nebinger 8 de mayo de 2012 16:49
RE: How to get Liferay to pickup mysql database changes Amos Fong 8 de mayo de 2012 20:41
RE: How to get Liferay to pickup mysql database changes Hitoshi Ozawa 8 de mayo de 2012 21:17
RE: How to get Liferay to pickup mysql database changes David H Nebinger 8 de mayo de 2012 21:19
RE: How to get Liferay to pickup mysql database changes Hitoshi Ozawa 8 de mayo de 2012 21:24
RE: How to get Liferay to pickup mysql database changes Nick Lindberg 9 de mayo de 2012 6:31
RE: How to get Liferay to pickup mysql database changes Nick Lindberg 9 de mayo de 2012 6:33
RE: How to get Liferay to pickup mysql database changes Hitoshi Ozawa 9 de mayo de 2012 6:48
RE: How to get Liferay to pickup mysql database changes Nick Lindberg 9 de mayo de 2012 6:57
RE: How to get Liferay to pickup mysql database changes Nick Lindberg 9 de mayo de 2012 13:10
RE: How to get Liferay to pickup mysql database changes Hitoshi Ozawa 9 de mayo de 2012 14:14
RE: How to get Liferay to pickup mysql database changes Hitoshi Ozawa 8 de mayo de 2012 14:51
Nick Lindberg
How to get Liferay to pickup mysql database changes
8 de mayo de 2012 10:12
Respuesta

Nick Lindberg

Ranking: Junior Member

Mensajes: 28

Fecha de incorporación: 5 de enero de 2012

Mensajes recientes

Hello,

I was able to get into the mysql lportal database and change the createDate on a bunch of web content I'd created, within the JournalArticle table. I verified that the new date was correct and did a

flush tables;

but I cannot seem to get Liferay to pick up to the changes, and if I modify the web content, the new article version object it creates in the database still copies the old createDate value from before me changing it.

Is it a no no to manually udpate database entries? I didn't know how else to do it, and I haven't been able to figure out how to get Liferay to pick up my changes.

Thanks--
Nick
David H Nebinger
RE: How to get Liferay to pickup mysql database changes
8 de mayo de 2012 11:19
Respuesta

David H Nebinger

Ranking: Liferay Legend

Mensajes: 7004

Fecha de incorporación: 1 de septiembre de 2006

Mensajes recientes

You should never update the database directly.

Try reindexing all search indices to see if that fixes your problem.
Nick Lindberg
RE: How to get Liferay to pickup mysql database changes
8 de mayo de 2012 11:57
Respuesta

Nick Lindberg

Ranking: Junior Member

Mensajes: 28

Fecha de incorporación: 5 de enero de 2012

Mensajes recientes

David H Nebinger:
You should never update the database directly.

Try reindexing all search indices to see if that fixes your problem.


Is there a reason I should never update the database directly? I'm not sure how else to change the create date.

I'll try that and see if it works.
Nick Lindberg
RE: How to get Liferay to pickup mysql database changes
8 de mayo de 2012 12:56
Respuesta

Nick Lindberg

Ranking: Junior Member

Mensajes: 28

Fecha de incorporación: 5 de enero de 2012

Mensajes recientes

Nick Lindberg:
David H Nebinger:
You should never update the database directly.

Try reindexing all search indices to see if that fixes your problem.


Is there a reason I should never update the database directly? I'm not sure how else to change the create date.

I'll try that and see if it works.


OK-- I reindexed the search indices and even cleared the database cache, all under the Server Administration tab of the control panel. No dice.

I guess I don't understand the relationship between the database and how Liferay stores objects in it. Once an object is created, does it rely on a local cache not within the database to get metadata?
Hitoshi Ozawa
RE: How to get Liferay to pickup mysql database changes
8 de mayo de 2012 14:51
Respuesta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensajes: 7990

Fecha de incorporación: 23 de marzo de 2010

Mensajes recientes

Have you tried restarting your server? This forces liferay to get data from the database.
David H Nebinger
RE: How to get Liferay to pickup mysql database changes
8 de mayo de 2012 16:49
Respuesta

David H Nebinger

Ranking: Liferay Legend

Mensajes: 7004

Fecha de incorporación: 1 de septiembre de 2006

Mensajes recientes

Nick Lindberg:
Nick Lindberg:
David H Nebinger:
You should never update the database directly.

Try reindexing all search indices to see if that fixes your problem.


Is there a reason I should never update the database directly? I'm not sure how else to change the create date.

I'll try that and see if it works.


OK-- I reindexed the search indices and even cleared the database cache, all under the Server Administration tab of the control panel. No dice.

I guess I don't understand the relationship between the database and how Liferay stores objects in it. Once an object is created, does it rely on a local cache not within the database to get metadata?


And that's the whole reason not to modify the database directly.

The Liferay database is not published for a reason. The reason is the API does significantly more stuff than just simple SQL insert statements. There are internally managed foreign keys, there are things which are updated not just in the database but also in the indices, in jackrabbit, etc.

Since all of this is managed by the code and not by the database, any updates to the code will change how and when the database is updated. Even if it did work for you in a 6.1 GA1 version, GA2 is coming out in a couple of weeks and the database/code may change again.

Sticking with the API is the only way to insure the changes are done correctly.
Amos Fong
RE: How to get Liferay to pickup mysql database changes
8 de mayo de 2012 20:41
Respuesta

Amos Fong

LIFERAY STAFF

Ranking: Liferay Legend

Mensajes: 1844

Fecha de incorporación: 7 de octubre de 2008

Mensajes recientes

Agree with David, always use APIs when possible.

Also, you'll need to reindex AFTER you clear the database cache, either through server admin or restarting like Hitoshi says. Clearing from server admin should work, but restarting will for sure clear all caches.
Hitoshi Ozawa
RE: How to get Liferay to pickup mysql database changes
8 de mayo de 2012 21:17
Respuesta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensajes: 7990

Fecha de incorporación: 23 de marzo de 2010

Mensajes recientes

The "right" way is to create a portlet to modify the "createDate" using setCreateDate(Date createDate) method in JournalArticleModel. Liferay API actually updates the memory entity instead of directly updating the database. Database is updated in the background.

using http://docs.liferay.com/portal/6.1/javadocs/com/liferay/portlet/journal/model/JournalArticleModel.html
David H Nebinger
RE: How to get Liferay to pickup mysql database changes
8 de mayo de 2012 21:19
Respuesta

David H Nebinger

Ranking: Liferay Legend

Mensajes: 7004

Fecha de incorporación: 1 de septiembre de 2006

Mensajes recientes

Well, if all you're doing is bulk-changing some records, I see no harm in starting a portlet plugin to leverage the service builder interface and just process them all in bulk, w/o implementing the full blown interface... Web service client might be an option, but I don't know if the fields are visible through the web service api or not...
Hitoshi Ozawa
RE: How to get Liferay to pickup mysql database changes
8 de mayo de 2012 21:24
Respuesta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensajes: 7990

Fecha de incorporación: 23 de marzo de 2010

Mensajes recientes

"createDate" is an internal field and it's not visible by default to web service nor LocalServiceUtil's update.
Nick Lindberg
RE: How to get Liferay to pickup mysql database changes
9 de mayo de 2012 6:31
Respuesta

Nick Lindberg

Ranking: Junior Member

Mensajes: 28

Fecha de incorporación: 5 de enero de 2012

Mensajes recientes

Hitoshi Ozawa:
The "right" way is to create a portlet to modify the "createDate" using setCreateDate(Date createDate) method in JournalArticleModel. Liferay API actually updates the memory entity instead of directly updating the database. Database is updated in the background.

using http://docs.liferay.com/portal/6.1/javadocs/com/liferay/portlet/journal/model/JournalArticleModel.html


I've found the setCreateDate() method and have been trying to figure out how to use it. The problem is that I only really need to do this for like 15 pieces of web content and I don't want to create a portlet just for that purpose, which is why I went with the direct database method.

Can I just create a run a .java file directly on the server, if I import the right libraries, or do I need to do it all through Liferay?
Nick Lindberg
RE: How to get Liferay to pickup mysql database changes
9 de mayo de 2012 6:33
Respuesta

Nick Lindberg

Ranking: Junior Member

Mensajes: 28

Fecha de incorporación: 5 de enero de 2012

Mensajes recientes

Amos Fong:
Agree with David, always use APIs when possible.

Also, you'll need to reindex AFTER you clear the database cache, either through server admin or restarting like Hitoshi says. Clearing from server admin should work, but restarting will for sure clear all caches.


I've tried all of these-- clearing the cache then reindexing, restarting Liferay, etc-- none of it is picking up the new createDate I modified in the database.
Hitoshi Ozawa
RE: How to get Liferay to pickup mysql database changes
9 de mayo de 2012 6:48
Respuesta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensajes: 7990

Fecha de incorporación: 23 de marzo de 2010

Mensajes recientes

This probably means you've modified the wrong "createDate". Have to check the code to see which createDate is being used to display.
Nick Lindberg
RE: How to get Liferay to pickup mysql database changes
9 de mayo de 2012 6:57
Respuesta

Nick Lindberg

Ranking: Junior Member

Mensajes: 28

Fecha de incorporación: 5 de enero de 2012

Mensajes recientes

Hitoshi Ozawa:
This probably means you've modified the wrong "createDate". Have to check the code to see which createDate is being used to display.


I dunno. It's the only one I found. The piece of web content has an article ID of 16332... and there are two revisions, which is why it's showing two objects in the following query. That looks right doesn't it?

mysql> SELECT createDate,modifiedDate,statusDate,displayDate,expirationDate,reviewDate FROM JournalArticle WHERE ArticleID = 16332;
+---------------------+---------------------+---------------------+---------------------+----------------+------------+
| createDate | modifiedDate | statusDate | displayDate | expirationDate | reviewDate |
+---------------------+---------------------+---------------------+---------------------+----------------+------------+
| 2012-03-08 15:17:12 | 2012-05-08 15:17:12 | 2012-05-08 15:17:12 | 2011-02-08 15:15:00 | NULL | NULL |
| 2012-03-08 15:17:12 | 2012-05-08 16:47:46 | 2012-05-08 16:47:46 | 2011-02-08 15:15:00 | NULL | NULL |
+---------------------+---------------------+---------------------+---------------------+----------------+------------+
2 rows in set (0.00 sec)


I changed the createDate to 2012-03-08 from 2012-05-08, but it still shows May 8th in my Asset Publisher after trying all of the refresh mechanisms.

Is it alot of work to create a new portlet that I can use to modify createDate?
Nick Lindberg
RE: How to get Liferay to pickup mysql database changes
9 de mayo de 2012 13:10
Respuesta

Nick Lindberg

Ranking: Junior Member

Mensajes: 28

Fecha de incorporación: 5 de enero de 2012

Mensajes recientes

Figured it out. I also had to change the entry for the article in the table "AssetEntry" within the database. The way to find it is to do a lookup on the articleId within the JournalArticle table, and then to use the layoutUuid to search for the same entry in the AssetEntry table and change the createDate there as well.

Then clearing the cache and reindexing solves the problem.

Thanks for everybody's help. I'm going to add a wiki on how to do this. It's a quick and dirty hack to but gets the job done.

Here it is:

http://www.liferay.com/community/wiki/-/wiki/Main/Changing+the+metadata+%28like+createDate%29%20fields+on+Asset+Publisher+Web+Content
Hitoshi Ozawa
RE: How to get Liferay to pickup mysql database changes
9 de mayo de 2012 14:14
Respuesta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensajes: 7990

Fecha de incorporación: 23 de marzo de 2010

Mensajes recientes

Nice to hear that you got it working. Thanks for the wiki page! emoticon