Foros de discusión

Why does service builder change database column names.

Dave Semeraro, modificado hace 10 años.

Why does service builder change database column names.

New Member Mensajes: 18 Fecha de incorporación: 10/05/13 Mensajes recientes
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
M J, modificado hace 10 años.

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

Regular Member Mensajes: 184 Fecha de incorporación: 1/03/13 Mensajes recientes
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.
Dave Semeraro, modificado hace 10 años.

RE: Why does service builder change database column names.

New Member Mensajes: 18 Fecha de incorporación: 10/05/13 Mensajes recientes
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
David H Nebinger, modificado hace 10 años.

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

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Try setting the db-name attribute on the column; SB will rename columns that do not have a corresponding db-name attribute defined.
Dave Semeraro, modificado hace 10 años.

RE: Why does service builder change database column names.

New Member Mensajes: 18 Fecha de incorporación: 10/05/13 Mensajes recientes
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.