Hey guys (and possible girls :)
I have found an interesting "issue" when using LiquiBase to
create database views.
My app is running on WebSphere and using JNDI data source that has no
scheme defined (as it is used by more then one application and each
application specifies schema in its own configuration).
In Hibernate I can specify schema using :
- <prop key="hibernate.default_schema">${jdbc.schema}</prop>
In LiquiBase I can do the same using Spring's integration :
- <bean id="liquibase"
class="liquibase.integration.spring.SpringLiquibase">
- <property
name="dataSource" ref="dataSource" />
- <property
name="changeLog"
value="classpath:db-changelog.xml" />
- <property
name="defaultSchema" value="${jdbc.schema}"
/>
- </bean>
Now imagine that I have a view to be created :
- <changeSet author="zbynek"
id="create_view_mad_server_properties_joined">
-
<comment>replaceIfExists is not allowed on
db2</comment>
-
<createView
viewName="MAD_SERVER_PROPERTIES_JOINED">
- SELECT
ROWNUMBER() OVER() as ID, MAD_SERVER_ID as MAD_SERVER_ID, SUBSTR(
xmlserialize
-
(xmlagg (xmltext (concat (',',
MAD_SERVER_PROPERTY.NAME))) AS VARCHAR(255)), 2)
- as
PROPERTIES FROM mad_server INNER JOIN MAD_SERVER_TO_PROPERTY ON
MAD_SERVER_TO_PROPERTY.MAD_SERVER_ID
-
= mad_server.ID INNER JOIN
MAD_SERVER_PROPERTY ON MAD_SERVER_TO_PROPERTY.PROPERTY_ID
- =
MAD_SERVER_PROPERTY.ID GROUP BY MAD_SERVER_ID
- </createView>
- </changeSet>
When this changeSet gets executed it will look for table 'mad_server'
(please don't laugh) in default schema (which is same as DB user) rather
than in schema I provided via Spring.And since the table is in schema I
provided this SQL fails - obviously.
I could put SCHEMA.mad_server into the SQL but that would loose the portability.
Any idea how this could be done? Or is it database (or DB2) related "issue"/feature.
All this happens on DB2 9.7.
Thanks !
PS : If I use local data source with schema specified it work fine !