I have the following service.xml:
<!-- PK fields -->
<column name="id" type="long" primary="true"/>
<!-- Group instance -->
<!-- <column name="groupId" type="long" /> -->
<!-- Certificate fields -->
<column name="version" type="int" />
<column name="subject" type="String" />
<column name="serial" type="String" />
<column name="encoded" type="Blob" />
<column name="to_auth" type="boolean" />
<column name="to_sign" type="boolean" />
<column name="ins_date" type="Date" />
<column name="alt_date" type="Date" />
<column name="requests" type="Collection" entity="APPLET_REQUEST"/>
<column name="user_certifcates" type="Collection" entity="USER_CERTIFICATE"/>
<!-- Order -->
<order by="asc">
<order-column name="id" />
</order>
<!-- Finder methods: TODO: gets dos campos que pretendo -->
<finder name="id" return-type="Collection">
<finder-column name="id" />
</finder>
</entity>
<!-- PK fields -->
<column name="userid" type="long" primary="true"/>
<column name="companyid" type="long" primary="true"/>
<column name="certificateid" type="long" primary="true"/>
<!-- Group instance -->
<!-- <column name="groupId" type="long" /> -->
<!-- User_Certificate fields -->
<!-- Order -->
<order by="asc">
<order-column name="userid" />
</order>
<finder name="userid" return-type="Collection">
<finder-column name="userid" />
</finder>
</entity>
I deployed the service with the first entity and no problem appeared. When I insert the second entity and made deploy of the service, liferay showed the next error message:
Caused by: com.liferay.portal.kernel.upgrade.UpgradeException: Upgrade code using unsupported class type 2004
How can i solve this problem?
Admitted, Liferay's error message is - well - not terribly helpful. I've filed LPS-57190 to change this in future. The relevant code changes are already mentioned in the ticket. As of now, if you look at the code that I've touched for this issue, you'll see that the 2004 is the SQL-type of one of the columns that ServiceBuilder tries to update. This number is from java.sql.Types. Inspecting that class, it's BLOB - so it seems SB has some problems upgrading your BLOB column.
You can (and should) write your own upgrade code, to explicitly take care of what Liferay can't do itself. Liferay itself comes with quite a lot of UpgradeAction
s that will alter the database upon installing a new release. The standard operation of upgrading a table (e.g. described in this thread) is not always what you want.
Here's how to prevent Liferay from automatically upgrading your tables - look up UpgradeAction and let Liferay know that you upgraded to the new required table structure yourself.