掲示板

Why does service builder change database column names.

10年前 に Dave Semeraro によって更新されました。

Why does service builder change database column names.

New Member 投稿: 18 参加年月日: 13/05/10 最新の投稿
Hello, I am writing a liferay portlet that access a remote database. I am following the example in the liferay in action section 10.4. My database has columns with the names "start" and "end". I create and entity in service.xml with those column names but when I run service builder it seems to change the column names to "start_" and "end_" in the portlet-hbm.xml file.

<property name="start" column="start_" type="com.liferay.portal.dao.orm.hibernate.LongType" />
<property name="end" column="end_" type="com.liferay.portal.dao.orm.hibernate.LongType" />

Other similar columns like "etime" are not changed. This is causing problems in queries and generates the following error:

13:55:14,268 ERROR [JDBCExceptionReporter:101] Unknown column 'jobsimpl0_.start_' in 'field list'

Are there reserved names for columns in liferay?
thumbnail
10年前 に M J によって更新されました。

RE: Why does service builder change database column names. (回答)

Regular Member 投稿: 184 参加年月日: 13/03/01 最新の投稿
Yes, start and end are reserved words. They are described in the portal-impl\src\com\liferay\portal\tools\servicebuilder\dependencies\bad_column_names.txt file. This file is included in the source liferay-portal-src-6.1.1-ce-ga2-20120731132656558.zip.
10年前 に Dave Semeraro によって更新されました。

RE: Why does service builder change database column names.

New Member 投稿: 18 参加年月日: 13/05/10 最新の投稿
Ah, that is unfortunate. I will have a look at the list. My problem is that I have no control over what is in the column names of the legacy database I am accessing. Names like start and end seem pretty common to me. I expect that others might be having problems similar to mine. Things seem to work fine after I change the column names in portal-dbm.xml from start_ and end_ back to start and end. Am I likely to run into problems later on if I do that? Will there be problems with using the search container for example? Maybe the reserved words only impact the operation of service builder. Is there some sort of in depth explanation of why the reserved words exist beyond the list in the source code? Thanks,

dave
thumbnail
10年前 に David H Nebinger によって更新されました。

RE: Why does service builder change database column names. (回答)

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Try setting the db-name attribute on the column; SB will rename columns that do not have a corresponding db-name attribute defined.
10年前 に Dave Semeraro によって更新されました。

RE: Why does service builder change database column names.

New Member 投稿: 18 参加年月日: 13/05/10 最新の投稿
Thank you very much. Setting the db-name attribute did the trick. I need to play around more with the settings in service.xml to more fully understand what they do. Thanks again.