Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Dave Semeraro
Why does service builder change database column names.
May 10, 2013 10:38 AM
Answer

Dave Semeraro

Rank: New Member

Posts: 18

Join Date: May 10, 2013

Recent Posts

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?
M J
RE: Why does service builder change database column names.
May 10, 2013 3:51 PM
Answer

M J

Rank: Regular Member

Posts: 184

Join Date: March 1, 2013

Recent Posts

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
RE: Why does service builder change database column names.
May 12, 2013 5:47 PM
Answer

Dave Semeraro

Rank: New Member

Posts: 18

Join Date: May 10, 2013

Recent Posts

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
David H Nebinger
RE: Why does service builder change database column names.
May 12, 2013 6:23 PM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11795

Join Date: September 1, 2006

Recent Posts

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
RE: Why does service builder change database column names.
May 13, 2013 7:55 AM
Answer

Dave Semeraro

Rank: New Member

Posts: 18

Join Date: May 10, 2013

Recent Posts

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.