留言板

Liferay 6.1 what is classPk in the database?

thumbnail
Elijah Mangason,修改在11 年前。

Liferay 6.1 what is classPk in the database?

Junior Member 帖子: 65 加入日期: 12-5-14 最近的帖子
Is there documentation on the value of classPk in the databse? It appears as primary key in some tables, but then is cross referenced in others with a different meaning. Where can I get information on this, and the general design of the database? Any help or suggestions appreciated.
thumbnail
David H Nebinger,修改在11 年前。

RE: Liferay 6.1 what is classPk in the database?

Liferay Legend 帖子: 14914 加入日期: 06-9-2 最近的帖子
This is the only documentation you need to know: DO NOT LOOK IN THE DATABASE!

The database is not yours. It is not yours to modify, insert, update, or delete records on. It is not documented because you're not supposed to be in there.

Liferay provides APIs for accessing info in the database. Those are your only authorized points of entry.

Why is this important? Because the class pk column you see today might not be in the version that comes out tomorrow. If you use the APIs, that won't affect you (as long as the method signatures don't change emoticon).

Seriously, I'm not trying to be a jerk with this response. I'm trying to educate. Too many people have tried gleeming inforation about the data model only to end in failure.

That said, I'm sure you really want to know. Class PK is the primary key for some other record. The classNameId is a FK to the classname_ table which indicates the type of record (i.e. com.liferay.portal.model.User). Knowing the class name, you can then go to the corresponding table (in this case the user_ table) and infer the ClassPK is actually the user id.

This is used to allow some actual DB entity to be bound to some other DB entity w/o specifically creating separate many-to-many join tables w/ all of the various entities that may need a connection.
thumbnail
Elijah Mangason,修改在11 年前。

RE: Liferay 6.1 what is classPk in the database?

Junior Member 帖子: 65 加入日期: 12-5-14 最近的帖子
Many thanks for your erudite response! Actually, between the time I posted the question and the arrival of your reply, I figured it out. Don't worry, I am not doing any CRUD operations on the database directly as I understand the problems with that. Instead, I am using the Liferay APIs (UserLocalServiceUtil, TeamLocalServiceUtil, OrganizationLocalServiceUtil, etc.), which make more sense than trying to patch it together table by table.